:root {
  color-scheme: light;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #cbd5e1;
  --soft: #f1f5f9;
  --panel: #ffffff;
  --brand: #0369a1;
  --brand-dark: #075985;
  --success: #047857;
  --success-soft: #d1fae5;
  --warn: #9a3412;
  --warn-soft: #ffedd5;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html { background: #e2e8f0; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #f8fafc;
  font-family: "Nirmala UI", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button, input, select { font: inherit; }
button, label[for] { -webkit-tap-highlight-color: transparent; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 16px;
  color: white;
  background: var(--brand-dark);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.eyebrow, .step-label {
  margin: 0 0 3px;
  font-size: 0.72rem;
  font-weight: 800;
  color: inherit;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.24rem; }
h2 { margin-bottom: 0; font-size: 1.2rem; }
h3 { margin-bottom: 8px; font-size: 1.04rem; }

main {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 16px 14px calc(94px + env(safe-area-inset-bottom));
}

.view { display: none; }
.view.active { display: block; }

.page-title { margin: 3px 2px 14px; }
.page-title .eyebrow { color: var(--brand); }

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

.summary-grid > div, .export-counts > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
}

.summary-grid span, .export-counts span, .setup-stat span, .latest-zip > span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.summary-grid strong, .export-counts strong {
  display: block;
  margin-top: 2px;
  font-size: 1.35rem;
}

.notice {
  margin-bottom: 12px;
  padding: 11px 12px;
  border: 1px solid;
  border-radius: 7px;
  font-weight: 700;
  line-height: 1.45;
}

.notice.warning { color: var(--warn); background: var(--warn-soft); border-color: #fdba74; }

.panel {
  margin-bottom: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.step-label { color: var(--brand); }

.status-pill {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: #e0f2fe;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-pill.success { color: var(--success); background: var(--success-soft); }
.status-pill.error { color: var(--danger); background: var(--danger-soft); }
.status-pill.neutral { color: #475569; background: var(--soft); }

.field-label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.88rem;
  font-weight: 800;
}

input, select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  color: var(--ink);
  background: white;
  outline: none;
}

input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px #bae6fd; }

.input-action-row, .button-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.input-action-row input { min-width: 0; }

.primary-button, .secondary-button, .danger-button, .icon-button, .filter-button, .text-button, .camera-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  text-align: center;
}

.primary-button, .secondary-button, .danger-button {
  min-height: 48px;
  padding: 11px 16px;
}

.primary-button { color: white; background: var(--brand); }
.primary-button:hover, .primary-button:focus-visible { background: var(--brand-dark); }
.secondary-button { color: var(--brand-dark); background: white; border: 1px solid var(--brand); }
.danger-button { color: white; background: var(--danger); }
.full { display: block; width: 100%; }
.label-button { display: flex; align-items: center; justify-content: center; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--brand-dark);
  background: white;
  font-size: 1.2rem;
}

.consumer-match {
  margin-top: 12px;
  padding: 12px;
  border-left: 4px solid var(--success);
  border-radius: 4px;
  background: var(--success-soft);
}

.consumer-match span, .consumer-match small { display: block; color: #065f46; }
.consumer-match strong { display: block; margin: 3px 0; font-size: 1.12rem; }

.attributes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.attributes-grid[hidden] { display: none; }
.attribute-wide { grid-column: 1 / -1; }
.attribute-wide .field-message { margin-top: 4px; }

.camera-button {
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 18px;
  border: 2px dashed var(--brand);
  color: var(--brand-dark);
  background: #f0f9ff;
}

.camera-button strong { margin: 8px 0 4px; font-size: 1.08rem; }
.camera-button small { color: #475569; font-weight: 600; }

.camera-mark {
  position: relative;
  display: block;
  width: 48px;
  height: 34px;
  border: 3px solid currentColor;
  border-radius: 6px;
}

.camera-mark::before {
  position: absolute;
  top: -9px;
  left: 13px;
  width: 16px;
  height: 7px;
  border: 3px solid currentColor;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  content: "";
}

.camera-mark::after {
  position: absolute;
  top: 7px;
  left: 14px;
  width: 12px;
  height: 12px;
  border: 3px solid currentColor;
  border-radius: 50%;
  content: "";
}

.photo-preview { margin: 12px 0; }
.photo-preview img { display: block; width: 100%; max-height: 52vh; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #0f172a; }
.preview-meta { display: flex; justify-content: space-between; gap: 8px; padding-top: 7px; color: var(--muted); font-size: 0.8rem; }

.field-message { min-height: 1.2em; margin: 8px 0 0; color: var(--success); font-size: 0.84rem; font-weight: 700; }
.field-message.error { color: var(--danger); }
.supporting, .quiet { color: var(--muted); line-height: 1.45; }
.supporting { margin-bottom: 12px; }
.quiet { margin: 10px 0 0; font-size: 0.82rem; }

.toolbar-panel { position: sticky; z-index: 5; top: 88px; }
.filter-row { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; }
.filter-button { flex: 0 0 auto; min-height: 38px; padding: 7px 10px; color: #475569; background: var(--soft); }
.filter-button.active { color: white; background: var(--brand); }

.empty-state { padding: 36px 18px; color: var(--muted); text-align: center; }
.record-list { display: grid; gap: 8px; }
.record-item {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto 38px;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
}
.record-thumb { width: 62px; height: 72px; border-radius: 4px; object-fit: cover; background: var(--soft); }
.record-body { min-width: 0; }
.record-body strong, .record-body span, .record-body small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-body span, .record-body small { color: var(--muted); }
.record-body span { margin: 2px 0; }
.record-export-state { padding: 4px 6px; border-radius: 999px; color: #475569; background: var(--soft); font-size: 0.68rem; font-weight: 800; }
.record-export-state.done { color: var(--success); background: var(--success-soft); }
.danger-icon { width: 36px; height: 36px; color: var(--danger); background: var(--danger-soft); }

.export-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.progress-wrap { margin-top: 12px; }
progress { width: 100%; height: 12px; accent-color: var(--brand); }
.progress-wrap span { display: block; margin-top: 4px; color: var(--muted); font-size: 0.8rem; }
.latest-zip strong, .latest-zip small { display: block; overflow-wrap: anywhere; }
.latest-zip strong { margin: 4px 0; }
.latest-zip small { margin-bottom: 12px; color: var(--muted); }
.latest-zip .button-row > * { flex: 1; }

.setup-stat { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setup-stat strong { font-size: 1.2rem; }
.text-button { display: block; width: fit-content; min-height: 40px; margin: 8px auto 0; padding: 8px 10px; color: var(--brand-dark); background: transparent; }
.danger-text { color: var(--danger); }
.danger-zone { border-color: #fecaca; }

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.1);
}

.nav-button {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 55px;
  border: 0;
  border-radius: 6px;
  color: #475569;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 800;
}
.nav-button span { display: grid; place-items: center; min-width: 27px; height: 24px; padding: 0 5px; border-radius: 999px; color: inherit; background: var(--soft); font-size: 0.7rem; }
.nav-button.active { color: var(--brand-dark); background: #e0f2fe; }
.nav-button.active span { color: white; background: var(--brand); }

.toast {
  position: fixed;
  z-index: 100;
  right: 16px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 520px;
  margin: auto;
  padding: 12px 14px;
  border-radius: 7px;
  color: white;
  background: #0f172a;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
  font-weight: 700;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (min-width: 700px) {
  body { background: #e2e8f0; }
  .app-header { padding-right: max(24px, calc((100vw - 760px) / 2)); padding-left: max(24px, calc((100vw - 760px) / 2)); }
  main { padding-top: 24px; }
  .panel { padding: 20px; }
  .bottom-nav { right: 50%; left: auto; width: 760px; transform: translateX(50%); border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
}

@media (max-width: 430px) {
  .stack-mobile { display: grid; }
  .attributes-grid { grid-template-columns: 1fr; }
  .attribute-wide { grid-column: auto; }
  .record-item { grid-template-columns: 54px minmax(0, 1fr) 34px; }
  .record-thumb { width: 54px; height: 66px; }
  .record-export-state { grid-column: 2; width: fit-content; }
  .record-delete { grid-column: 3; grid-row: 1 / span 2; }
}

@media print {
  .app-header, .bottom-nav { display: none; }
  main { width: 100%; padding: 0; }
}
