/* Checkpoint design system ------------------------------------------------- */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --ink: #17201d;
  --ink-2: #3d4844;
  --muted: #5f6a65;
  --line: #e2dfd6;
  --line-strong: #cbc7bb;
  --brand: #0e5a52;
  --brand-2: #13796e;
  --brand-ink: #ffffff;
  --brand-soft: #e3f0ec;
  --accent: #b2691a;
  --accent-soft: #f8ebda;
  --good: #1f7a4d;
  --good-soft: #e2f2e8;
  --warn: #9a610f;
  --warn-soft: #fbf0da;
  --alert: #b03a2e;
  --alert-soft: #f9e3df;
  --info: #2f5d8a;
  --info-soft: #e3ecf5;
  --chart-1: #0e5a52;
  --chart-2: #c27a2c;
  --chart-3: #5b7fa6;
  --chart-4: #8a6bae;
  --chart-5: #c25a4a;
  --chart-grid: #e7e4dc;
  --shadow: 0 1px 2px rgba(23, 32, 29, 0.05), 0 2px 8px rgba(23, 32, 29, 0.04);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 248px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1513;
    --surface: #161e1b;
    --surface-2: #1c2622;
    --ink: #e8eeeb;
    --ink-2: #c3cdc9;
    --muted: #97a39e;
    --line: #27322e;
    --line-strong: #36433e;
    --brand: #4fb3a4;
    --brand-2: #6cc7b9;
    --brand-ink: #08110f;
    --brand-soft: #173430;
    --accent: #e0a15a;
    --accent-soft: #3a2a17;
    --good: #5cc08a;
    --good-soft: #15301f;
    --warn: #e0b04f;
    --warn-soft: #33280f;
    --alert: #ef7d6e;
    --alert-soft: #3a1c18;
    --info: #7da9d6;
    --info-soft: #172636;
    --chart-1: #4fb3a4;
    --chart-2: #e0a15a;
    --chart-3: #7da9d6;
    --chart-4: #b69ad6;
    --chart-5: #ef7d6e;
    --chart-grid: #26302c;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1513; --surface: #161e1b; --surface-2: #1c2622; --ink: #e8eeeb; --ink-2: #c3cdc9; --muted: #97a39e;
  --line: #27322e; --line-strong: #36433e; --brand: #4fb3a4; --brand-2: #6cc7b9; --brand-ink: #08110f;
  --brand-soft: #173430; --accent: #e0a15a; --accent-soft: #3a2a17; --good: #5cc08a; --good-soft: #15301f;
  --warn: #e0b04f; --warn-soft: #33280f; --alert: #ef7d6e; --alert-soft: #3a1c18; --info: #7da9d6;
  --info-soft: #172636; --chart-1: #4fb3a4; --chart-2: #e0a15a; --chart-3: #7da9d6; --chart-4: #b69ad6;
  --chart-5: #ef7d6e; --chart-grid: #26302c; --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-2); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; color: var(--ink); }
h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
small, .small { font-size: .875rem; }
.muted { color: var(--muted); }
.num, td.num, .stat-value { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }

/* Layout ---------------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--surface) calc(var(--sidebar) - 1px), var(--line) 0 var(--sidebar), transparent 0); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 32px; height: 32px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav .nav-btn {
  display: flex; width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; align-items: center; gap: 12px; padding: 10px 12px; min-height: 44px;
  border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 520;
}
.nav a:hover, .nav .nav-btn:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot .who { padding: 8px 12px; font-size: .875rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; width: 100%; text-align: left; }
.main { min-width: 0; padding: 32px clamp(16px, 4vw, 48px) 64px; }
.container { max-width: 1180px; margin: 0 auto; }
.topbar { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--muted); margin: 0; max-width: 62ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: .8rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 40px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.section { margin-top: 36px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-title h2 { margin: 0; }

/* Cards & stats --------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-tight { padding: 14px 16px; }
.card h2, .card h3 { margin-bottom: 4px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 0; color: var(--muted); font-size: .9rem; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-head { padding: 18px 20px 0; }
.stat-label { font-size: .85rem; color: var(--muted); font-weight: 560; }
.stat-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; margin-top: 2px; }
.stat-sub { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.stat-sm .stat-value { font-size: 1.25rem; }
.tone-good { color: var(--good); } .tone-warn { color: var(--warn); } .tone-alert { color: var(--alert); } .tone-info { color: var(--info); }

/* Hero (readiness) ------------------------------------------------------ */
.hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: center; }
.gauge { position: relative; width: 188px; height: 188px; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .track { stroke: var(--surface-2); }
.gauge .meter { transition: stroke-dasharray .6s ease; }
.gauge-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.gauge-value { font-size: 2.6rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge-caption { font-size: .8rem; color: var(--muted); margin-top: 6px; font-weight: 560; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-weight: 650; font-size: .9rem; }
.status-on_track { background: var(--good-soft); color: var(--good); }
.status-close { background: var(--warn-soft); color: var(--warn); }
.status-behind { background: var(--alert-soft); color: var(--alert); }
.hero h1 { font-size: 1.7rem; margin: 12px 0 8px; }
.hero-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.fact { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.fact .stat-value { font-size: 1.2rem; }

/* Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .95rem;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-2); color: var(--brand-ink); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: transparent; color: var(--alert); border-color: color-mix(in srgb, var(--alert) 40%, transparent); }
.btn-danger:hover { background: var(--alert-soft); color: var(--alert); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; border-radius: 8px; }
.btn-icon { min-height: 36px; width: 36px; padding: 0; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.inline-form { display: inline; }

/* Badges & chips -------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 650; white-space: nowrap; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-alert { background: var(--alert-soft); color: var(--alert); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--surface-2); color: var(--ink-2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--ink-2); text-decoration: none; font-size: .9rem; font-weight: 560; background: var(--surface); }
.chip:hover { background: var(--surface-2); color: var(--ink); }
.chip[aria-current="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* Alerts / flashes ------------------------------------------------------ */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; font-size: .95rem; }
.alert .icon { margin-top: 2px; }
.alert-success { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); color: var(--ink); }
.alert-error { background: var(--alert-soft); border-color: color-mix(in srgb, var(--alert) 30%, transparent); color: var(--ink); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 25%, transparent); color: var(--ink); }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--ink); }
.callout { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; font-size: .92rem; color: var(--ink-2); }
.callout strong { color: var(--ink); }

/* Next steps ------------------------------------------------------------ */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.steps li + li { border-top: 1px solid var(--line); }
.step { display: flex; gap: 14px; align-items: flex-start; padding: 14px 4px; text-decoration: none; color: inherit; }
.step:hover .step-title { color: var(--brand); }
.step-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.step-dot.good { background: var(--good-soft); color: var(--good); }
.step-dot.warn { background: var(--warn-soft); color: var(--warn); }
.step-dot.alert { background: var(--alert-soft); color: var(--alert); }
.step-dot.info { background: var(--info-soft); color: var(--info); }
.step-title { font-weight: 640; line-height: 1.35; }
.step-detail { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.step .chev { margin-left: auto; color: var(--muted); margin-top: 6px; }

.option-card { display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer; color: inherit; text-decoration: none; font: inherit; width: 100%; }
.option-card:hover { border-color: var(--brand); color: inherit; }
a.stat-link { color: inherit; text-decoration: none; transition: border-color .15s; }
a.stat-link:hover { border-color: var(--brand); }
.move-impact { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; min-width: 92px; }
.move-impact strong { font-size: 1.05rem; color: var(--good); font-variant-numeric: tabular-nums; }
.move-impact span { font-size: .75rem; color: var(--muted); }
.longterm-link { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.longterm-link .icon { color: var(--brand); }
.longterm-link:hover { border-color: var(--brand); color: inherit; }
.budget-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) auto; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.budget-row:last-child { border-bottom: 0; }
.budget-row .amounts { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .92rem; }
.grid-table td, .grid-table th { padding: 8px 10px; font-size: .85rem; }
.grid-table td.dim { color: var(--muted); }
.txn-cat select { min-height: 36px; padding: 4px 8px; font-size: .88rem; width: auto; max-width: 220px; }
.amount-in { color: var(--good); }
@media (max-width: 700px) { .budget-row { grid-template-columns: minmax(0, 1fr) auto; } .budget-row .progress { grid-column: 1 / -1; } }

/* Progress -------------------------------------------------------------- */
.progress { position: relative; height: 12px; border-radius: 999px; background: var(--surface-2); overflow: visible; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--brand); max-width: 100%; }
.progress-fill.warn { background: var(--accent); }
.progress-fill.alert { background: var(--alert); }
.progress-fill.good { background: var(--good); }
.progress-marker { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); opacity: .55; border-radius: 2px; }
.limit-row { padding: 16px 0; }
.limit-row + .limit-row { border-top: 1px solid var(--line); }
.limit-row .row-between { margin-bottom: 8px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c, var(--brand)); }

/* Tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-weight: 620; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .num, .table th.num { text-align: right; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table a.rowlink { color: var(--ink); text-decoration: none; font-weight: 580; }
.table a.rowlink:hover { color: var(--brand); text-decoration: underline; }

/* Forms ----------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.field .help { font-size: .82rem; color: var(--muted); }
.field .error { font-size: .85rem; color: var(--alert); font-weight: 560; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
input[type="search"], input[type="url"], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--alert); }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-prefix input { padding-left: 26px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .95rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--brand); flex: none; }
input[type="range"] { width: 100%; accent-color: var(--brand); min-height: 32px; }
input[type="file"] { font: inherit; font-size: .9rem; max-width: 100%; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 22px; text-align: center; background: var(--surface-2); color: var(--muted); }
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dropzone strong { color: var(--ink); display: block; margin-bottom: 4px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; align-items: center; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 650; font-size: 1.05rem; margin-bottom: 10px; padding: 0; }
.fieldset-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--surface); }
.fieldset-card + .fieldset-card { margin-top: 16px; }

/* Dialog ---------------------------------------------------------------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 21, 19, .45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dialog-head h2 { margin: 0; font-size: 1.15rem; }
.dialog-body { padding: 20px; }

/* Empty states ---------------------------------------------------------- */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); }
.empty .btn { margin-top: 10px; }

/* Charts ---------------------------------------------------------------- */
.chart { position: relative; height: 300px; }
.chart-sm { height: 220px; }
.chart-lg { height: 360px; }
[data-performance]:not(.loaded) .chart { display: none; }
.list.notes-list li { display: block; padding: 8px 0; }
.icon-inline { display: inline-block; vertical-align: -3px; }

/* Lists ----------------------------------------------------------------- */
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.task-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line-strong); display: grid; place-items: center; background: var(--surface); cursor: pointer; flex: none; color: var(--brand-ink); padding: 0; }
.task-check:hover { border-color: var(--brand); }
.task-check.on { background: var(--brand); border-color: var(--brand); }
.acct-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* Prose (AI output, notes) --------------------------------------------- */
.prose { max-width: 72ch; }
.prose h2 { font-size: 1.15rem; margin-top: 1.4rem; }
.prose h3 { font-size: 1rem; margin-top: 1.2rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .3rem 0; }
.pre-wrap { white-space: pre-wrap; }

/* Auth & landing -------------------------------------------------------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(440px, 100%); }
.auth-card .brand { justify-content: center; padding-bottom: 18px; }
.landing { max-width: 1100px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 40px) 64px; }
.landing-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 56px; }
.landing-hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.landing-hero h1 { font-size: clamp(2.1rem, 4.5vw, 3.2rem); letter-spacing: -0.025em; line-height: 1.08; }
.landing-hero p.lead { font-size: 1.2rem; color: var(--ink-2); max-width: 46ch; }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 64px; }
.feature .icon { color: var(--brand); width: 26px; height: 26px; margin-bottom: 10px; }
.footer-note { margin-top: 48px; color: var(--muted); font-size: .85rem; text-align: center; }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 50; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px; }
  .topbar .brand { padding: 0; }
  .main { padding: 20px 16px 56px; }
  .hero { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .hero-facts { grid-template-columns: minmax(0, 1fr); text-align: left; width: 100%; }
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .landing-hero, .feature-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  h1 { font-size: 1.5rem; }
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .stat-value { font-size: 1.35rem; }
  .gauge { width: 160px; height: 160px; }
  .gauge-value { font-size: 2.2rem; }
  .table th, .table td { padding: 10px 8px; }
}
@media print {
  .sidebar, .topbar, .page-head .actions, .btn, form { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* Claims ----------------------------------------------------------------- */
.filter-grid { display: grid; grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr)); gap: 10px 12px; }
.sel-col { width: 36px; }
.sel-box { width: 20px; height: 20px; accent-color: var(--brand); }
.flow-bar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin-top: 6px; }
.flow-bar span { display: block; height: 100%; }
.flow-bar span + span { border-left: 2px solid var(--surface); }
.timeline { list-style: none; margin: 8px 0 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 6px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); }
.timeline li.future::before { background: var(--surface); border-color: var(--line-strong); }
.doc-checklist { display: flex; gap: 6px; flex-wrap: wrap; }
.member-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(172px, 1fr) 108px 100px auto auto; gap: 8px; align-items: center; }
.member-row[hidden] { display: none; }
.members .member { display: block; }
.member-view { display: flex; align-items: center; gap: 12px; }
.member-view > form { margin: 0; }
.member-view[hidden] { display: none; }
.avatar { flex: 0 0 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; }
@media (max-width: 900px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid .field:first-child { grid-column: 1 / -1; }
  .member-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 6rem;
    grid-template-areas: "name name name" "rel rel year" "covered covered covered" "cancel save save"; }
  .member-row .m-name { grid-area: name; }
  .member-row .m-rel { grid-area: rel; }
  .member-row .m-year { grid-area: year; }
  .member-row .m-covered { grid-area: covered; }
  .member-row .m-cancel { grid-area: cancel; }
  .member-row .m-save { grid-area: save; }
}

.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.source-row { flex-wrap: wrap; gap: 8px; }
.target-select { min-height: 34px; padding: 4px 8px; font-size: .85rem; width: auto; max-width: 220px; }

/* Mobile ---------------------------------------------------------------- */
.tabbar { display: none; }
.show-sm, .show-sm-block { display: none; }
@media (max-width: 900px) {
  .app { background: none; }  /* no desktop sidebar stripe */
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); }
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px;
    color: var(--muted); text-decoration: none; font: inherit; font-size: .72rem; font-weight: 600; background: none; border: 0; cursor: pointer;
  }
  .tabbar .icon { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--brand); }
  .footer-note { margin-bottom: 0; }
}
@media (max-width: 640px) {
  .main { padding-left: 14px; padding-right: 14px; padding-top: 16px; }
  .page-head { margin-bottom: 16px; gap: 12px; }
  .page-head p { font-size: .95rem; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .card { padding: 16px; border-radius: 12px; }
  .card-flush { padding: 0; }
  .card-flush .card-head { padding: 14px 16px 0; }
  .grid-4, .grid-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid { gap: 12px; }
  .card-tight { padding: 12px 14px; }
  .stat-label { font-size: .78rem; }
  .stat-value, .stat-sm .stat-value { font-size: 1.2rem; }
  .stat-sub { font-size: .76rem; line-height: 1.35; }
  .section { margin-top: 24px; }
  /* Moves / next steps: text gets the full width, the dollar value sits underneath */
  .step { padding: 12px 0; gap: 12px; }
  .step:has(.move-impact) { display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: 12px; }
  .step .move-impact { grid-column: 2; flex-direction: row; align-items: baseline; justify-content: flex-start; gap: 6px; min-width: 0; margin-top: 6px; text-align: left; }
  .step-title { font-size: .97rem; }
  .step-detail { font-size: .86rem; }
  /* Tables: tighter, and drop secondary columns */
  .table { font-size: .86rem; }
  .table th, .table td { padding: 9px 8px; }
  .table th { font-size: .7rem; }
  .hide-sm { display: none !important; }
  .show-sm { display: table-cell; }
  .show-sm-block { display: block; }
  .hero-facts .stat-value { font-size: 1.1rem; }
  .chart { height: 240px; }
  .chart-lg { height: 280px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .budget-row { gap: 6px 12px; }
  .kv { gap: 6px 12px; font-size: .93rem; }
  dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  .dialog-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-actions .btn { flex: 1 1 auto; }
  .txn-cat select { max-width: 150px; }
  h1 { font-size: 1.45rem; }
  .hero h1 { font-size: 1.35rem; }
}

/* AI reading progress overlay */
.read-progress { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(15, 21, 19, .5); backdrop-filter: blur(3px); animation: rp-fade .2s ease-out; }
.rp-card { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.rp-head { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.rp-head > .icon { width: 28px; height: 28px; color: var(--brand); animation: rp-pulse 1.6s ease-in-out infinite; }
.rp-head strong { display: block; font-size: 1.05rem; }
.rp-files { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; }
.rp-file { margin: 0; flex: 0 0 76px; text-align: center; transition: opacity .3s; opacity: .55; }
.rp-file.reading, .rp-file.read { opacity: 1; }
.rp-file figcaption { font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.rp-thumb { position: relative; height: 96px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); transition: border-color .3s, box-shadow .3s; }
.rp-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.rp-thumb .icon { width: 26px; height: 26px; }
.rp-file.reading .rp-thumb { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.rp-file.read .rp-thumb::after { content: "\2713"; position: absolute; right: 4px; bottom: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--good); color: #fff; font-size: .75rem; display: grid; place-items: center; animation: rp-pop .25s ease-out; }
.rp-scan { display: none; position: absolute; left: 0; right: 0; height: 30%; background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--brand) 35%, transparent) 85%, var(--brand)); animation: rp-scan 1.4s ease-in-out infinite alternate; }
.rp-file.reading .rp-scan { display: block; }
.rp-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-bottom: 14px; }
.rp-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--brand)); background-size: 200% 100%; animation: rp-shimmer 1.5s linear infinite; transition: width .3s linear; }
.rp-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rp-steps li { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); font-size: .92rem; transition: color .3s; }
.rp-steps li small { display: none; font-size: .78rem; color: var(--muted); margin-top: 2px; }
.rp-steps li.active { color: var(--ink); font-weight: 600; }
.rp-steps li.active small { display: block; font-weight: 400; }
.rp-steps li.done { color: var(--ink-2); }
.rp-dot { flex: 0 0 18px; height: 18px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--line-strong); position: relative; }
.rp-steps li.active .rp-dot { border-color: var(--brand-soft); border-top-color: var(--brand); animation: rp-spin .8s linear infinite; }
.rp-steps li.done .rp-dot { border-color: var(--good); background: var(--good); }
.rp-steps li.done .rp-dot::after { content: ""; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.rp-foot { margin: 16px 0 0; }
@keyframes rp-fade { from { opacity: 0; } }
@keyframes rp-pulse { 50% { transform: scale(1.15) rotate(8deg); opacity: .7; } }
@keyframes rp-scan { from { top: -30%; } to { top: 100%; } }
@keyframes rp-shimmer { to { background-position: -200% 0; } }
@keyframes rp-spin { to { transform: rotate(360deg); } }
@keyframes rp-pop { from { transform: scale(0); } }
@media (prefers-reduced-motion: reduce) {
  .read-progress, .rp-head > .icon, .rp-scan, .rp-bar span, .rp-steps li.active .rp-dot, .rp-file.read .rp-thumb::after { animation: none; }
  .rp-file.reading .rp-scan { top: 35%; }
}

/* Claim visit details & service lines */
.kv.kv-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 24px; }
.kv-grid > div { min-width: 0; }
.kv-grid dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.kv-grid dd { text-align: left; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; letter-spacing: .01em; }
.line-rows { display: grid; gap: 8px; }
.line-row { display: grid; grid-template-columns: 7rem 5rem minmax(0, 1fr) 4rem 8rem; gap: 8px; align-items: center; }
.line-row[hidden] { display: none; }
.line-head { padding: 0 2px; }
@media (max-width: 640px) {
  .kv.kv-grid { grid-template-columns: 1fr 1fr; gap: 12px 16px; }
  .kv-grid > .kv-wide { grid-column: 1 / -1; }
  .line-head { display: none; }
  .line-row { grid-template-columns: 1fr 1fr 4rem; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
  .line-row > input[name^="line_desc"] { grid-column: 1 / -1; grid-row: 2; }
  .line-row > .input-prefix { grid-column: 1 / -1; }
}

/* Inbox review */
.proposal .kv { grid-template-columns: max-content minmax(0, 1fr); }
.proposal .kv dd { overflow-wrap: anywhere; }
.proposal .kv dd.clip { max-width: none; }
.adds li { align-items: center; gap: 10px; }
.adds .badge { flex: 0 0 auto; }
.grow { flex: 1; min-width: 0; }
.text-right { text-align: right; }
.clip-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.unchanged summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.unchanged summary:hover { color: var(--ink); }
.unchanged .list li { gap: 12px; padding: 7px 0; align-items: flex-start; }
.unchanged .list li > :first-child { flex: 0 0 auto; }
.unchanged .list li > .text-right { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.source-row > .source-name { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
.source-row > form:first-of-type { flex: 1; min-width: 0; }
.source-row .target-select { width: 100%; max-width: none; }
