:root {
  color-scheme: light;
  --bg: #f7f7f3;
  --surface: #ffffff;
  --surface-2: #e7ebe4;
  --text: #19211d;
  --muted: #66736b;
  --primary: #236554;
  --primary-soft: #d8e8df;
  --line: #d8ddd5;
  --green: #2e7d52;
  --orange: #e18b21;
  --red: #c63d32;
  --blue: #2e647c;
  --shadow: 0 12px 28px rgba(18, 32, 26, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.screen {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 18px;
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 24px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.header-with-action .header-actions {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.ai-panel {
  margin-bottom: 12px;
}

.ai-panel .tabs {
  margin-bottom: 0;
}

.ai-status,
.ai-empty {
  margin-top: 0;
}

.ai-empty h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.ai-report-meta {
  margin-bottom: 12px;
}

.ai-report-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.ai-report-head h2 {
  margin: 0;
  font-size: 18px;
}

.ai-history-modal {
  max-height: min(80dvh, 640px);
  display: grid;
  grid-template-rows: auto 1fr;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.ai-history-list {
  overflow: auto;
  padding: 8px;
}

.ai-history-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.ai-history-item.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.ai-history-item strong {
  display: block;
  margin-bottom: 4px;
}

.ai-history-item p {
  margin: 0;
  font-size: 13px;
}

.ai-history-count {
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
}

.ai-history-empty {
  padding: 24px 12px;
  text-align: center;
}

.brand h1,
.header h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.brand p,
.header p,
.muted {
  margin: 6px 0 0;
  color: var(--muted);
}

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.form {
  display: grid;
  gap: 10px;
}

.form h2,
.panel h2 {
  margin: 0;
  font-size: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #fff;
  color: var(--text);
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.primary,
.secondary,
.icon-button,
.chip {
  border: 0;
  border-radius: 7px;
  min-height: 44px;
}

.primary {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  padding: 0 16px;
}

.secondary {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  padding: 0 16px;
}

.danger {
  background: #f8dfdc;
  color: var(--red);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.switch-line {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}

.switch-line input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
  min-height: 40px;
}

.header strong {
  font-size: 24px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.metric {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric b {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.list {
  display: grid;
  gap: 10px;
}

.check-card {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.check-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.check-card-actions .icon-button {
  width: 44px;
  min-height: 44px;
}

.thumb {
  width: 96px;
  height: 72px;
  border-radius: 6px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.check-card h2,
.finding h2 {
  margin: 0;
  font-size: 17px;
}

.check-card p,
.finding p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-weight: 800;
  font-size: 13px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--red);
}

.dot.complete {
  background: var(--green);
}

.dot.partial {
  background: var(--orange);
}

.dot.none {
  background: var(--red);
}

.camera-input {
  display: none;
}

.icon-button {
  width: 48px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}

.icon-button svg,
.nav-item svg,
.thumb svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
  margin-top: 12px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
}

.month-nav-btn {
  min-width: 40px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  padding: 0;
}

.month-picker {
  position: relative;
  flex: 1;
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 0 8px;
}

.month-picker-label {
  font-size: 16px;
  font-weight: 800;
  pointer-events: none;
}

.month-picker-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  margin: 0;
}

.month-nav-actions {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.weekday,
.day {
  min-width: 0;
  text-align: center;
}

.weekday {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 0;
}

.day {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
}

.day.selected {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.day.today:not(.selected) {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.day.empty {
  border-color: transparent;
  background: transparent;
}

.day small {
  color: var(--muted);
  font-size: 10px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0 16px;
  font-weight: 800;
}

.chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.finding {
  padding: 14px;
}

.finding-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.server-grid {
  display: grid;
  gap: 10px;
}

.location-row {
  display: grid;
  grid-template-columns: 40px 1fr 48px;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.location-order {
  display: grid;
  gap: 4px;
}

.location-order .icon-button {
  min-height: 32px;
  width: 40px;
  background: var(--surface-2);
  color: var(--text);
  border-radius: 6px;
}

.location-order .icon-button:disabled {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.nav-item {
  border: 0;
  background: transparent;
  min-height: 54px;
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 2px;
  font-weight: 800;
  font-size: 12px;
}

.nav-item span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  width: min(520px, calc(100% - 32px));
  margin: 0 auto;
  background: #18211d;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

.modal {
  width: min(720px, 100%);
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}

.modal img {
  width: 100%;
  max-height: 78dvh;
  object-fit: contain;
  background: #111;
  display: block;
}

.modal .modal-actions {
  padding: 10px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 420px) {
  .screen {
    padding: 14px;
  }

  .summary {
    grid-template-columns: 1fr;
  }

  .check-card {
    grid-template-columns: 84px 1fr auto;
    gap: 10px;
  }

  .check-card-actions .icon-button {
    width: 40px;
    min-height: 40px;
  }

  .thumb {
    width: 84px;
    height: 66px;
  }
}
