:root {
  --canvas: #f0f0f0;
  --surface: #ffffff;
  --surface-soft: #f8f7f3;
  --ink: #141310;
  --muted-ink: #5c5a54;
  --brand-yellow: #ffd400;
  --brand-red: #b61928;
  --brand-black: #0c0b0a;
  --success: #176b4d;
  --warning: #825200;
  --danger: #a31422;
  --line: #d5d3cc;
  --focus: #5e3fc9;
  --shadow-sm: 0 1px 2px rgba(12, 11, 10, 0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --topbar-height: 72px;
  --sidebar-width: 300px;
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 16px; line-height: 1.55; overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button, select, input[type="checkbox"], input[type="radio"], input[type="range"] { cursor: pointer; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: Poppins, Inter, sans-serif; line-height: 1.15; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 1000; background: var(--brand-yellow); color: var(--ink); padding: 12px 16px; border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: 16px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.eyebrow { margin-bottom: 6px; color: var(--brand-red); font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.topbar { position: fixed; inset: 0 0 auto 0; z-index: 50; height: var(--topbar-height); display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; padding: 8px 12px; color: white; background: var(--brand-black); border-bottom: 1px solid #292721; }
.brand-lockup { min-width: 0; display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-lockup img { width: 44px; height: 44px; object-fit: contain; }
.brand-lockup span { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.brand-lockup b { font-family: Poppins, Inter, sans-serif; white-space: nowrap; }
.brand-lockup small { color: #c9c7c0; font-size: .7rem; white-space: nowrap; }
.icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: inherit; transition: background-color 180ms ease, opacity 180ms ease; }
.icon-button:hover { background: rgba(255,255,255,.1); }
.icon-button:active { background: rgba(255,255,255,.16); }
.icon-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.save-cluster { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; }
.save-status { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: #63c49d; }
.save-status[data-state="saving"] .save-dot { background: var(--brand-yellow); animation: pulse 1s infinite; }
.save-status[data-state="offline"] .save-dot, .save-status[data-state="error"] .save-dot { background: #ff6b73; }
.save-status[data-state="conflict"] .save-dot { background: #ffab3d; }
.last-saved { max-width: 120px; color: #a9a69f; font-size: .63rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-strip { position: fixed; top: var(--topbar-height); left: 0; right: 0; z-index: 42; height: 50px; padding: 7px 16px 9px; background: var(--surface); border-bottom: 1px solid var(--line); }
.progress-strip-copy { display: flex; justify-content: space-between; gap: 16px; font-size: .74rem; }
.progress-strip-copy span { color: var(--muted-ink); font-weight: 600; }
.progress-strip-copy b { font-variant-numeric: tabular-nums; }
.progress-track { height: 7px; margin-top: 5px; overflow: hidden; background: #deddd8; border-radius: 999px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--brand-yellow); border-right: 3px solid var(--brand-black); transition: width 220ms ease; }

.sidebar { position: fixed; z-index: 60; inset: 0 auto 0 0; width: min(88vw, var(--sidebar-width)); display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform 220ms ease-out; }
.sidebar.is-open { transform: translateX(0); }
.sidebar-scrim { position: fixed; z-index: 55; inset: 0; background: rgba(12,11,10,.55); }
.sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 16px 16px; border-bottom: 1px solid var(--line); }
.sidebar-head h2 { margin: 0; font-size: 1rem; }
.sidebar-close { color: var(--ink); }
.sidebar-close:hover { background: var(--canvas); }
#module-nav { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 10px 120px; }
.nav-group { margin-bottom: 12px; }
.nav-group-title { margin: 14px 10px 6px; color: var(--muted-ink); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.module-link { width: 100%; min-height: 48px; display: grid; grid-template-columns: 26px 1fr auto; gap: 9px; align-items: center; border: 0; border-radius: 11px; padding: 8px 10px; text-align: left; background: transparent; color: var(--ink); }
.module-link:hover { background: var(--surface-soft); }
.module-link[aria-current="page"] { background: var(--brand-yellow); }
.module-index { font-size: .74rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.module-link-label { font-size: .84rem; line-height: 1.25; }
.module-check { width: 18px; height: 18px; display: grid; place-items: center; border: 1px solid #aaa79f; border-radius: 50%; color: transparent; font-size: .68rem; }
.module-link[data-complete="true"] .module-check { background: var(--success); border-color: var(--success); color: white; }
.module-link[aria-current="page"] .module-check { border-color: var(--brand-black); }
.sidebar-foot { position: absolute; inset: auto 0 0; padding: 14px; background: linear-gradient(to bottom, rgba(255,255,255,.92), white 20%); border-top: 1px solid var(--line); }
.sidebar-foot p { margin: 0 0 10px; font-size: .84rem; }

.main-content { min-height: 100dvh; padding: calc(var(--topbar-height) + 66px) 16px 104px; }
#page-content { width: min(100%, 880px); margin-inline: auto; }
.page-head { margin-bottom: 22px; }
.page-kicker { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--brand-red); font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.page-head h1 { margin-bottom: 8px; font-size: clamp(1.75rem, 7vw, 3rem); letter-spacing: -.045em; }
.page-head p { max-width: 64ch; color: var(--muted-ink); }
.module-progress-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin-top: 16px; }
.module-progress-row .progress-track { height: 8px; margin: 0; }
.module-progress-row b { font-size: .8rem; font-variant-numeric: tabular-nums; }

.form-card, .dashboard-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.form-card { margin-bottom: 16px; padding: 20px 16px; scroll-margin-top: 146px; }
.form-card[data-priority="critical"] { border-left: 5px solid var(--brand-red); }
.field-topline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.field-label { display: block; margin-bottom: 10px; font-weight: 750; line-height: 1.35; }
.priority-pill, .evidence-pill, .status-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: .66rem; font-weight: 800; letter-spacing: .03em; }
.priority-pill[data-priority="critical"] { background: #f8dee1; color: #7e101b; }
.priority-pill[data-priority="essential"] { background: #fff1b5; color: #624b00; }
.priority-pill[data-priority="optional"] { background: #ecebe6; color: #56534c; }
.evidence-pill { background: #e4f2eb; color: #15543e; }
.status-pill { background: var(--canvas); color: var(--muted-ink); }
.field-help { margin: 8px 0 0; color: var(--muted-ink); font-size: .83rem; }
.field-error { min-height: 1.25em; margin: 7px 0 0; color: var(--danger); font-size: .84rem; font-weight: 600; }
.source-panel { margin: 12px 0 0; padding: 12px; background: #f8f6ec; border: 1px solid #e7dfb8; border-radius: var(--radius-sm); }
.source-panel summary { min-height: 36px; display: flex; align-items: center; cursor: pointer; color: var(--warning); font-size: .8rem; font-weight: 700; }
.source-panel p { margin: 6px 0 0; color: var(--muted-ink); font-size: .8rem; }
.prefill-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="date"], input[type="time"], input[type="number"], input[type="password"], textarea, select {
  width: 100%; min-height: 48px; border: 1px solid #aaa79f; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); padding: 11px 14px; appearance: none;
}
select { padding-right: 44px; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 20px) 20px, calc(100% - 14px) 20px; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
textarea { min-height: 116px; resize: vertical; }
input:hover, textarea:hover, select:hover { border-color: #716e67; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }

.option-grid { display: grid; grid-template-columns: 1fr; gap: 9px; }
.option-button { min-height: 48px; display: flex; align-items: center; gap: 10px; border: 1px solid #aaa79f; border-radius: var(--radius-sm); padding: 10px 12px; text-align: left; background: var(--surface); color: var(--ink); transition: border-color 160ms ease, background-color 160ms ease; }
.option-button:hover { border-color: var(--brand-black); }
.option-button[aria-pressed="true"] { border-color: var(--brand-black); background: var(--brand-yellow); box-shadow: inset 0 0 0 1px var(--brand-black); }
.option-marker { flex: none; width: 20px; height: 20px; display: grid; place-items: center; border: 1.5px solid #7a7770; border-radius: 6px; background: white; }
.option-button[data-mode="single"] .option-marker { border-radius: 50%; }
.option-button[aria-pressed="true"] .option-marker { border-color: var(--brand-black); background: var(--brand-black); color: white; }
.option-button[aria-pressed="true"] .option-marker::after { content: "✓"; font-size: .72rem; font-weight: 900; }
.segment-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.segment-row .option-button { justify-content: center; text-align: center; }

.range-wrap { display: grid; grid-template-columns: auto minmax(80px, 1fr) auto auto; gap: 12px; align-items: center; }
.range-wrap input { width: 100%; accent-color: var(--brand-red); }
.range-value { min-width: 48px; min-height: 44px; display: grid; place-items: center; background: var(--brand-black); color: var(--brand-yellow); border-radius: 10px; font-weight: 800; font-variant-numeric: tabular-nums; }
.range-label { color: var(--muted-ink); font-size: .72rem; }

.confirmation-row { min-height: 48px; display: grid; grid-template-columns: 24px 1fr; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.confirmation-row input { width: 22px; height: 22px; accent-color: var(--success); }

.repeater-list { display: grid; gap: 12px; }
.repeater-item { position: relative; padding: 16px 12px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-soft); }
.repeater-item-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.repeater-item-head b { font-size: .82rem; }
.repeater-fields { display: grid; gap: 12px; }
.subfield label { display: block; margin-bottom: 5px; color: var(--muted-ink); font-size: .75rem; font-weight: 700; }
.remove-item { width: 44px; height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--danger); }
.remove-item:hover { background: #f8dee1; }
.remove-item svg { width: 20px; height: 20px; margin: auto; fill: none; stroke: currentColor; stroke-width: 2; }
.repeater-add { margin-top: 12px; }

.file-drop { display: grid; place-items: center; min-height: 130px; border: 2px dashed #aaa79f; border-radius: var(--radius-sm); padding: 20px; text-align: center; background: var(--surface-soft); }
.file-drop input { width: 100%; min-height: 48px; margin-top: 10px; }
.file-progress { margin-top: 10px; }
.file-list { display: grid; gap: 8px; margin-top: 12px; }
.file-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.file-row span { min-width: 0; }
.file-row b, .file-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row small { color: var(--muted-ink); }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; font-weight: 750; text-decoration: none; transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, opacity 160ms ease; }
.button:active { opacity: .78; }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-primary { background: var(--brand-black); color: white; }
.button-primary:hover { background: #2a2822; }
.button-secondary { background: var(--brand-yellow); color: var(--brand-black); border-color: var(--brand-black); }
.button-secondary:hover { background: #ffe45f; }
.button-quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.button-quiet:hover { border-color: var(--ink); }
.button-danger { background: #fff; color: var(--danger); border-color: #e5b4b9; }
.button-full { width: 100%; }

.page-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; margin-top: 24px; padding: 12px; background: rgba(240,240,240,.94); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); }
.bottom-nav { position: fixed; z-index: 45; inset: auto 0 0; height: 68px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 5px max(6px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); background: var(--surface); border-top: 1px solid var(--line); }
.bottom-nav button { position: relative; min-width: 0; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; border-radius: 10px; background: transparent; color: var(--muted-ink); font-size: .66rem; font-weight: 700; }
.bottom-nav button:hover, .bottom-nav button[aria-current="page"] { background: #fff5b9; color: var(--ink); }
.bottom-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge { position: absolute; top: 1px; right: calc(50% - 24px); min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; border-radius: 999px; background: var(--brand-red); color: white; font-size: .6rem; font-variant-numeric: tabular-nums; }

.dashboard-hero { position: relative; overflow: hidden; padding: 24px 18px; background: var(--brand-black); color: white; border-radius: var(--radius-lg); }
.dashboard-hero::after { content: ""; position: absolute; width: 180px; height: 180px; right: -90px; bottom: -110px; border: 20px solid var(--brand-yellow); border-radius: 50%; opacity: .38; }
.dashboard-hero .eyebrow { color: var(--brand-yellow); }
.dashboard-hero h1 { max-width: 14ch; margin-bottom: 10px; font-size: clamp(2rem, 9vw, 4rem); letter-spacing: -.055em; }
.dashboard-hero p { max-width: 58ch; color: #d8d6cf; }
.hero-progress { position: relative; width: 130px; height: 130px; display: grid; place-items: center; margin-top: 22px; border-radius: 50%; background: conic-gradient(var(--brand-yellow) var(--progress), #302e28 0); }
.hero-progress::before { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--brand-black); }
.hero-progress strong { position: relative; color: var(--brand-yellow); font-size: 2rem; font-variant-numeric: tabular-nums; }
.dashboard-grid { display: grid; gap: 14px; margin-top: 16px; }
.dashboard-card { padding: 18px 16px; }
.dashboard-card h2 { margin-bottom: 12px; font-size: 1.1rem; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-box { padding: 12px 8px; background: var(--surface-soft); border-radius: 10px; text-align: center; }
.stat-box strong, .stat-box span { display: block; }
.stat-box strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat-box span { color: var(--muted-ink); font-size: .68rem; }
.pending-list, .conflict-list { display: grid; gap: 8px; }
.pending-item { width: 100%; min-height: 52px; display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; text-align: left; background: white; }
.pending-item:hover { border-color: var(--brand-black); }
.pending-marker { width: 10px; height: 10px; border-radius: 50%; background: var(--brand-red); }
.pending-item span { font-size: .83rem; line-height: 1.25; }
.pending-item small { color: var(--muted-ink); font-size: .68rem; }
.empty-state { padding: 20px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; color: var(--muted-ink); }

.conflict-banner { margin-bottom: 18px; padding: 14px; background: #fff1dc; border: 1px solid #e2ad63; border-left: 6px solid var(--warning); border-radius: var(--radius-sm); }
.conflict-banner h2 { font-size: 1rem; }
.conflict-card { padding: 14px; border: 1px solid #e2ad63; border-radius: 10px; background: white; }
.conflict-values { display: grid; gap: 10px; margin: 10px 0; }
.conflict-value { min-width: 0; padding: 10px; background: var(--surface-soft); border-radius: 8px; }
.conflict-value b, .conflict-value pre { display: block; }
.conflict-value pre { max-height: 160px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: .72rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.error-summary { margin-bottom: 18px; padding: 16px; border: 1px solid #e5b4b9; border-left: 6px solid var(--danger); border-radius: var(--radius-sm); background: #fff5f6; }
.error-summary h2 { font-size: 1rem; }
.error-summary ul { margin-bottom: 0; padding-left: 20px; }
.error-summary a { color: var(--danger); font-weight: 700; }
.toast-region { position: fixed; z-index: 200; left: 16px; right: 16px; bottom: 84px; display: grid; justify-items: center; pointer-events: none; }
.toast { width: min(100%, 460px); padding: 12px 14px; border-radius: 10px; background: var(--brand-black); color: white; box-shadow: 0 12px 40px rgba(0,0,0,.24); font-size: .84rem; animation: toast-in 180ms ease-out; }
.toast[data-type="error"] { background: var(--danger); }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (min-width: 560px) {
  .option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .segment-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .repeater-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-card.wide { grid-column: 1 / -1; }
  .conflict-values { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 768px) {
  .topbar { grid-template-columns: 44px 1fr auto; padding-inline: 24px; }
  .progress-strip { padding-inline: 24px; }
  .main-content { padding-inline: 32px; }
  .form-card { padding: 24px; }
  .dashboard-hero { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 34px; }
  .hero-progress { margin-top: 0; margin-right: 30px; }
  .page-actions { grid-template-columns: auto auto; justify-content: end; }
}

@media (min-width: 1024px) {
  .menu-button, .sidebar-close, .bottom-nav { display: none; }
  .topbar { left: var(--sidebar-width); grid-template-columns: 1fr auto; }
  .brand-lockup { display: none; }
  .progress-strip { left: var(--sidebar-width); }
  .sidebar { top: 0; width: var(--sidebar-width); transform: none; z-index: 51; }
  .sidebar-head { padding-top: 24px; min-height: 122px; background: var(--brand-black); color: white; border-bottom-color: #292721; }
  .sidebar-head .eyebrow { color: var(--brand-yellow); }
  .main-content { margin-left: var(--sidebar-width); padding-top: calc(var(--topbar-height) + 76px); padding-bottom: 46px; }
  #page-content { width: min(100%, 940px); }
  .page-actions { position: sticky; bottom: 18px; z-index: 20; }
  .toast-region { left: calc(var(--sidebar-width) + 16px); bottom: 24px; }
}

@media (min-width: 1440px) {
  :root { --sidebar-width: 320px; }
  .main-content { padding-inline: 56px; }
  #page-content { width: min(100%, 1040px); }
  .option-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .topbar, .progress-strip, .sidebar, .bottom-nav, .page-actions, .toast-region { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  body { background: white; }
}
