/* ShoeCare console. Palette "Bench, Kraft & Thread": the tokens below are docs/BRAND.md verbatim.
   The page is a tan workbench (light) or a shoe-box black-brown (dark); what the customer reads sits on a paper docket
   with a perforated stub; the care tag stays kraft in both themes. Colour is the third cue: stitch + printed word + colour.
   Build on token NAMES only; raw hex belongs to this file (and to measured swatches and wear levels).
   stitch.css (the stitch component, perforation, care tag, risk dots, test box) is linked by both layouts. */
:root {
  color-scheme: light;
  --bg: #E4D5B7; --surface: #F7F0E0; --surface-2: #EEE3CC; --kraft: #CDAE79; --kraft-2: #BFA066;
  --ink: #251C12; --muted: #574B3C; --line: #BFAA82; --line-strong: #8A7650;
  --brand: #1D4E9E; --brand-ink: #163D80; --brand-fg: #FFFFFF; --brand-soft: rgba(29,78,158,.10);
  --ok: #27602F; --warn: #7A5000; --nv: #545A69; --bad: #9E1F28;
  --ok-soft: rgba(39,96,47,.12); --warn-soft: rgba(122,80,0,.12); --nv-soft: rgba(84,90,105,.12); --bad-soft: rgba(158,31,40,.12);
  --k-ink: #251C12; --k-muted: #3F3426; --k-brand: #12336B; --k-warn: #5E3E00; --k-ok: #1B4723; --k-nv: #3E4452; --k-bad: #7A141C;
  --wear-1: #E8D2A0; --wear-2: #C9985A; --wear-3: #8E5B2B;
  /* derived */
  --bg-2: color-mix(in srgb, var(--bg) 88%, var(--ink)); --faint: color-mix(in srgb, var(--muted) 75%, var(--surface));
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand);
  --edge: 0 1px 0 var(--line-strong), 0 5px 0 -2px var(--line);
  --scrim: rgba(37,28,18,.55);
  --toast-ok: #6CC283; --toast-warn: #E3A63A; --toast-bad: #F2767A; --toast-link: #A9C6F7;
  --grain: repeating-linear-gradient(0deg, rgba(0,0,0,.025) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(255,255,255,.04) 0 1px, transparent 1px 4px);
  /* type: system stacks only */
  --display: "Rockwell", "Rockwell Nova", "Roboto Slab", "Sitka Heading", "Cambria", "Georgia", serif;
  --caps: "Arial Narrow", "Avenir Next Condensed", "Roboto Condensed", "Franklin Gothic Medium", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 12px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 20px; --fs-xl: 28px; --fs-2xl: 44px; --fs-hero: 72px;
  --r: 4px; --radius: 4px; --radius-sm: 4px; --radius-xs: 2px;
  --page-w: 1180px; --gutter: 24px; --bar-h: 48px; --tab-h: 56px; --stub-w: 188px;
  /* compatibility aliases for older module code */
  --warn-ink: var(--warn); --nv-ink: var(--nv); --ok-ink: var(--ok); --bad-ink: var(--bad); --on-brand: var(--brand-fg); --line-2: var(--line-strong);
  --info: var(--nv); --info-ink: var(--nv); --info-soft: var(--nv-soft); --ink-2: var(--ink); --focus: var(--brand);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17120D; --surface: #211A13; --surface-2: #2A2118; --kraft: #C4A773; --kraft-2: #A98B57;
  --ink: #F1E6D0; --muted: #B3A48D; --line: #3A2F23; --line-strong: #6B5B45;
  --brand: #86AEF2; --brand-ink: #A9C6F7; --brand-fg: #0E1A33; --brand-soft: rgba(134,174,242,.14);
  --ok: #6CC283; --warn: #E3A63A; --nv: #9AA1AE; --bad: #F2767A;
  --ok-soft: rgba(108,194,131,.14); --warn-soft: rgba(227,166,58,.14); --nv-soft: rgba(154,161,174,.14); --bad-soft: rgba(242,118,122,.14);
  --wear-1: #6E5A36; --wear-2: #A5753A; --wear-3: #D08A45;
  --bg-2: color-mix(in srgb, var(--bg) 82%, var(--ink)); --scrim: rgba(0,0,0,.66);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #17120D; --surface: #211A13; --surface-2: #2A2118; --kraft: #C4A773; --kraft-2: #A98B57;
    --ink: #F1E6D0; --muted: #B3A48D; --line: #3A2F23; --line-strong: #6B5B45;
    --brand: #86AEF2; --brand-ink: #A9C6F7; --brand-fg: #0E1A33; --brand-soft: rgba(134,174,242,.14);
    --ok: #6CC283; --warn: #E3A63A; --nv: #9AA1AE; --bad: #F2767A;
    --ok-soft: rgba(108,194,131,.14); --warn-soft: rgba(227,166,58,.14); --nv-soft: rgba(154,161,174,.14); --bad-soft: rgba(242,118,122,.14);
    --wear-1: #6E5A36; --wear-2: #A5753A; --wear-3: #D08A45;
    --bg-2: color-mix(in srgb, var(--bg) 82%, var(--ink)); --scrim: rgba(0,0,0,.66);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--bar-h) + 16px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; overflow-wrap: anywhere; }
body.public { overflow-wrap: normal; }
img, svg, canvas, video { max-width: 100%; }
a { color: var(--brand-ink); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r); }
::selection { background: var(--brand); color: var(--brand-fg); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
h1 { font: 700 clamp(28px, 4.4vw, 44px)/1.08 var(--display); letter-spacing: -.01em; }
h2 { font: 700 20px/1.25 var(--display); }
h3 { font: 700 16px/1.3 var(--font); }
p { margin: 0; }
.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* the stamped print on a care label */
.eyebrow, .caps { font: 700 12px/1.3 var(--caps); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.display { font: 700 clamp(44px, 9vw, 72px)/1 var(--display); letter-spacing: -.01em; font-variant-numeric: lining-nums tabular-nums; }
.display.md { font-size: clamp(28px, 5vw, 44px); } .display.sm { font-size: 28px; }
.serif { font-family: var(--display); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 14px; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 10px 14px; background: var(--ink); color: var(--bg); border-radius: var(--r); }
.skip-link:focus { top: 8px; }
[hidden] { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .row.between { justify-content: space-between; flex-wrap: nowrap; }
.stack { display: grid; gap: 16px; } .stack.sm { gap: 10px; } .stack.lg { gap: 28px; }
.grow { flex: 1; min-width: 0; } .right { margin-left: auto; }

/* ---------- shell: the woven-tape top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; padding-top: env(safe-area-inset-top); background: repeating-linear-gradient(0deg, color-mix(in srgb, var(--line) 60%, transparent) 0 1px, transparent 1px 4px), var(--surface-2); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: repeating-linear-gradient(90deg, var(--line-strong) 0 8px, transparent 8px 13px); pointer-events: none; }
.topbar-in { display: flex; align-items: center; gap: 28px; height: var(--bar-h); max-width: var(--page-w); margin: 0 auto; padding: 0 var(--gutter); }
/* the wordmark is a label sewn in: kraft, stitched, slab */
.brand { position: relative; display: inline-flex; align-items: center; gap: 8px; flex: none; padding: 5px 14px; background-color: var(--kraft); background-image: var(--grain); color: var(--k-ink); text-decoration: none; border-radius: 2px; }
.brand::before { content: ""; position: absolute; inset: 2px; pointer-events: none; border-radius: 1px;
  --run: var(--k-ink) 0 5px, transparent 5px 8px;
  background: repeating-linear-gradient(90deg, var(--run)) left top / 100% 1px no-repeat, repeating-linear-gradient(90deg, var(--run)) left bottom / 100% 1px no-repeat,
    repeating-linear-gradient(0deg, var(--run)) left top / 1px 100% no-repeat, repeating-linear-gradient(0deg, var(--run)) right top / 1px 100% no-repeat; }
.brand:hover { text-decoration: none; }
.brand .i { width: 16px; height: 16px; color: var(--k-ink); }
.wm { font: 700 18px/1 var(--display); letter-spacing: -.01em; color: var(--k-ink); }
.wm em { font-style: normal; }
.topnav { display: flex; align-items: center; flex: 1; }
.topnav a { position: relative; padding: 14px 14px; color: var(--muted); text-decoration: none; font: 700 13px/1 var(--caps); letter-spacing: .14em; text-transform: uppercase; }
.topnav a + a::before { content: ""; position: absolute; left: -4px; top: 50%; width: 8px; height: 8px; margin-top: -4px; opacity: .8;
  background: linear-gradient(45deg, transparent 44%, var(--line-strong) 44% 56%, transparent 56%), linear-gradient(-45deg, transparent 44%, var(--line-strong) 44% 56%, transparent 56%); }
.topnav a:hover { color: var(--ink); text-decoration: none; }
.topnav a[aria-current="page"] { color: var(--ink); }
.topnav a[aria-current="page"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 8px; height: 2px; background: repeating-linear-gradient(90deg, var(--ink) 0 6px, transparent 6px 9px); }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
/* the page that carries its own "Examine a shoe" hides the bar's */
body[data-page="dashboard"] .top-examine, body[data-page="analyze"] .top-examine { display: none; }
.wallet-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: var(--r); color: var(--ink); text-decoration: none; font: 700 13px var(--mono); font-variant-numeric: tabular-nums; }
.wallet-chip .wl { font: 700 11px var(--caps); letter-spacing: .14em; text-transform: uppercase; } .wallet-chip.low { border-color: var(--warn); color: var(--warn); }
.user-menu { position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 700 12px var(--caps); letter-spacing: .08em; cursor: pointer; }
.avatar:hover { border-color: var(--ink); }
.pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 240px; padding: 6px; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--edge); }
.pop .who { display: grid; padding: 10px 12px 8px; font-size: 14px; } .pop .who span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.pop a, .pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: var(--r); color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; font-size: 14px; }
.pop a:hover, .pop button:hover, .more-sheet a:hover { background: var(--surface-2); text-decoration: none; }
.pop hr { margin: 6px 0; }

/* ---------- the docket: one paper sheet with a perforated stub column ---------- */
.main { max-width: var(--page-w); margin: 0 auto; padding: 24px var(--gutter) 72px; min-height: calc(100vh - var(--bar-h)); }
.main:focus { outline: none; }
#banners:empty { display: none; }
.docket { position: relative; display: grid; grid-template-columns: var(--stub-w) minmax(0, 1fr); background: var(--surface); border-radius: var(--r); box-shadow: var(--edge); }
.docket__body, #app { min-width: 0; }
.docket__body { padding: 28px 32px 40px; }
.stub { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 28px 18px 24px 22px; }
.stub::after { content: ""; position: absolute; right: 0; top: 14px; bottom: 14px; width: 9px; background: radial-gradient(circle, var(--line-strong) 1.4px, transparent 2px) 0 0 / 9px 9px repeat-y; }
.stub::before { content: ""; position: absolute; right: -7px; top: 0; bottom: 0; width: 14px; pointer-events: none;
  background: radial-gradient(circle 7px at 50% 0, var(--bg) 98%, transparent) top / 14px 14px no-repeat, radial-gradient(circle 7px at 50% 100%, var(--bg) 98%, transparent) bottom / 14px 14px no-repeat; }
.stub__serial { font: 700 22px/1.1 var(--mono); letter-spacing: -.02em; color: var(--ink); }
.stub__date { font: 13px/1.3 var(--mono); color: var(--muted); }
.stub__status { margin-top: 10px; font: 700 12px/1.4 var(--caps); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.stub__status:empty { display: none; }
.stub__caption { margin-top: auto; padding-top: 24px; align-self: flex-start; writing-mode: vertical-rl; transform: rotate(180deg); font: 700 11px/1 var(--caps); letter-spacing: .24em; text-transform: uppercase; color: var(--faint); white-space: nowrap; }
@media (max-width: 1099px) {
  .docket { grid-template-columns: minmax(0, 1fr); }
  .stub { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; padding: 14px 24px 16px; }
  .stub::after { left: 14px; right: 14px; top: auto; bottom: 0; width: auto; height: 9px; background: radial-gradient(circle, var(--line-strong) 1.4px, transparent 2px) 0 0 / 9px 9px repeat-x; }
  .stub::before, .stub__caption { display: none; }
  .stub__serial { font-size: 17px; } .stub__status { margin: 0; }
  .docket__body { padding: 24px 24px 36px; }
}
@media (max-width: 860px) {
  :root { --gutter: 16px; }
  .main { padding: 14px var(--gutter) calc(var(--tab-h) + 48px + env(safe-area-inset-bottom)); }
  .docket__body { padding: 20px 16px 28px; }
  .stub { padding: 10px 16px 14px; }
  .topnav, .topbar .top-examine, .topbar .wallet-chip, .topbar .user-menu { display: none; }
  .topbar-in { gap: 12px; justify-content: space-between; }
}
.page { display: grid; gap: 28px; align-content: start; }
.page-head { display: grid; gap: 8px; } .page-head .sub { color: var(--muted); max-width: 62ch; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- phone tag-strip + More sheet ---------- */
.tabbar, .more-sheet { display: none; }
@media (max-width: 860px) {
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: repeating-linear-gradient(0deg, color-mix(in srgb, var(--line) 60%, transparent) 0 1px, transparent 1px 4px), var(--surface-2); }
  .tabbar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: repeating-linear-gradient(90deg, var(--line-strong) 0 8px, transparent 8px 13px); }
  .tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 44px; border: 0; background: none; color: var(--muted); text-decoration: none; font: 700 11px/1 var(--caps); letter-spacing: .1em; text-transform: uppercase; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tabbar .i { width: 22px; height: 22px; }
  .tabbar [aria-current="page"], .tabbar .current { color: var(--ink); }
  .tabbar [aria-current="page"]::after, .tabbar .current::after { content: ""; position: absolute; bottom: 4px; width: 22px; height: 2px; background: repeating-linear-gradient(90deg, var(--ink) 0 5px, transparent 5px 8px); }
  /* the raised round eyelet is the phone's one filled button */
  .tabbar .tab-examine { color: var(--ink); }
  .tabbar .tab-examine .ring { display: grid; place-items: center; width: 56px; height: 56px; margin-top: -26px; border-radius: 50%; background: var(--brand); color: var(--brand-fg); box-shadow: 0 0 0 4px var(--kraft-2), 0 0 0 5px var(--line-strong); }
  .tabbar .tab-examine::after { display: none; }
  .tabbar .tab-examine span.t { margin-top: 1px; }
  .more-sheet { position: fixed; inset: 0; z-index: 60; background: var(--scrim); align-items: flex-end; }
  .more-sheet:not([hidden]) { display: flex; }
  .more-sheet .sheet { width: 100%; max-height: 80vh; overflow: auto; padding: 18px 12px calc(18px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: var(--r) var(--r) 0 0; border-top: 2px dashed var(--line-strong); animation: sheet-up .22s ease-out; }
  .more-sheet .eyebrow { display: block; padding: 0 12px 8px; }
  .more-sheet a, .more-sheet button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 12px; border: 0; background: none; color: var(--ink); border-radius: var(--r); text-decoration: none; font-size: 16px; text-align: left; cursor: pointer; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.toasts { position: fixed; z-index: 90; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
@media (max-width: 860px) { .toasts { left: 16px; right: 16px; width: auto; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); } }

/* ---------- the footer line of the signed-in pages ---------- */
.foot { max-width: var(--page-w); margin: 0 auto; padding: 0 var(--gutter) 28px; display: flex; gap: 8px 22px; flex-wrap: wrap; color: var(--muted); font: 700 12px/1.4 var(--caps); letter-spacing: .12em; text-transform: uppercase; }
.foot a { color: var(--muted); } .foot a:hover { color: var(--ink); }
@media (max-width: 860px) { .foot { padding-bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); } }

/* ---------- sections inside a docket: a caps label, a hairline, a body ---------- */
.sect { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 12px 32px; padding: 26px 0; border-top: 1px solid var(--line); }
.sect:first-of-type { border-top: 0; padding-top: 0; }
.sect-head h2 { font: 700 12px/1.3 var(--caps); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sect-head p { margin-top: 8px; font-size: 14px; color: var(--muted); max-width: 30ch; }
.sect-body { min-width: 0; }
.sect.full { grid-template-columns: minmax(0, 1fr); } .sect.full .sect-head { margin-bottom: 4px; }
.rule { height: 1px; background: var(--line); border: 0; margin: 0; } .rule.thick { height: 2px; background: var(--ink); }
.grid12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px; }
.grid12 > .col-3 { grid-column: span 3; } .grid12 > .col-4 { grid-column: span 4; } .grid12 > .col-5 { grid-column: span 5; } .grid12 > .col-6 { grid-column: span 6; }
.grid12 > .col-7 { grid-column: span 7; } .grid12 > .col-8 { grid-column: span 8; } .grid12 > .col-9 { grid-column: span 9; } .grid12 > .col-12 { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .sect { display: block; padding: 20px 0; } .sect-head { margin-bottom: 14px; } .sect-head p { max-width: none; }
  .grid12 { grid-template-columns: 1fr; gap: 18px; } .grid12 > * { grid-column: 1 / -1 !important; }
}

/* ---------- buttons: one filled "Examine a shoe" per view, everything else quiet ---------- */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 9px 16px; border: 1.5px solid var(--line-strong); border-radius: var(--r); background: transparent; color: var(--ink); font: 700 14px/1.2 var(--font); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .15s, border-color .15s, transform .08s; }
.btn:hover { border-color: var(--ink); text-decoration: none; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.cta, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.btn.cta::before { content: ""; position: absolute; inset: 3px; border: 1px dashed color-mix(in srgb, var(--brand-fg) 55%, transparent); border-radius: 2px; pointer-events: none; }
.btn.cta:hover, .btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: var(--brand-fg); }
:root[data-theme="dark"] .btn.cta:hover, :root[data-theme="dark"] .btn.primary:hover { background: color-mix(in srgb, var(--brand) 86%, #fff); border-color: transparent; }
.btn.ghost { border-color: transparent; } .btn.ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 60%, var(--line)); } .btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.danger.fill { background: var(--bad); color: var(--bg); border-color: var(--bad); }
.btn.sm { min-height: 34px; padding: 5px 12px; font-size: 13px; } .btn.lg { min-height: 52px; padding: 13px 26px; font-size: 16px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--ink); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.cta[aria-busy="true"]::after, .btn.primary[aria-busy="true"]::after { border-color: var(--brand-fg); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--r); background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.link { background: none; border: 0; padding: 0; color: var(--brand-ink); text-decoration: underline; text-underline-offset: .2em; cursor: pointer; font-size: inherit; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; } .field > label, .field > .lbl { font: 700 12px/1.2 var(--caps); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.field .hint { font-size: 13px; color: var(--muted); } .field .err, .err { font-size: 14px; color: var(--bad); }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 9px 12px; border: 1.5px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--ink); font-size: 16px; }
textarea.input { min-height: 92px; resize: vertical; line-height: 1.45; }
.input:hover { border-color: var(--ink); } .input:focus-visible { border-color: var(--brand); box-shadow: var(--ring); }
.input.invalid, .input[aria-invalid="true"] { border-color: var(--bad); }
.input::placeholder { color: var(--faint); }
select.input { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; } .form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
/* the switch: a sewn toggle (input.switch, appearance none) */
input.switch { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 46px; height: 26px; margin: 0; border: 1.5px solid var(--line-strong); border-radius: var(--r); background: var(--surface-2); cursor: pointer; transition: background .15s; }
input.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 17px; height: 17px; border-radius: 2px; background: var(--line-strong); transition: transform .15s, background .15s; }
input.switch:checked { background: var(--brand); border-color: var(--brand); } input.switch:checked::after { transform: translateX(20px); background: var(--brand-fg); }
input.switch:focus-visible { box-shadow: var(--ring); }
.check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; } .check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.seg { display: inline-flex; border: 1.5px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.seg button { min-height: 36px; padding: 6px 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font: 700 12px var(--caps); letter-spacing: .14em; text-transform: uppercase; } .seg button + button { border-left: 1.5px solid var(--line-strong); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button, .tabs a { padding: 10px 0; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); cursor: pointer; font: 700 12px var(--caps); letter-spacing: .14em; text-transform: uppercase; text-decoration: none; white-space: nowrap; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 20px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; } .setting .txt { display: grid; gap: 2px; cursor: pointer; } .setting .txt b { font-weight: 700; } .setting .txt span { font-size: 14px; color: var(--muted); max-width: 56ch; }
@media (max-width: 640px) { .setting:has(.range-field) { grid-template-columns: 1fr; } }
.pick { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px; border: 1.5px solid var(--line-strong); border-radius: var(--r); background: transparent; cursor: pointer; font-size: 14px; }
.pick[aria-pressed="true"] { border-color: var(--ink); background: var(--surface-2); }

/* ---------- chips, badges, banners, callouts ---------- */
.chip, .badge, .tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--line-strong); border-radius: var(--r); font: 700 12px/1.4 var(--caps); letter-spacing: .12em; text-transform: uppercase; color: var(--ink); background: transparent; white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 55%, transparent); background: var(--ok-soft); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: var(--warn-soft); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 55%, transparent); background: var(--bad-soft); }
.badge.brand, .badge.info { color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand) 50%, transparent); background: var(--brand-soft); }
.badge.nv { color: var(--nv); background: var(--nv-soft); }
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); line-height: 1; }
.banner, .alert, .callout { display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin: 12px 0; border: 1px solid var(--line-strong); border-left-width: 4px; border-radius: var(--r); background: var(--surface-2); font-size: 14px; }
.banner.warn, .alert.warn { border-color: var(--warn); background: var(--warn-soft); } .banner.bad, .alert.bad { border-color: var(--bad); background: var(--bad-soft); }
.banner.ok, .alert.ok { border-color: var(--ok); background: var(--ok-soft); } .banner.info, .callout { border-color: var(--nv); background: var(--nv-soft); }
.callout { display: block; }
@media (max-width: 640px) { .banner { flex-wrap: wrap; } }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--ink); color: var(--bg); border-left: 4px solid var(--toast-link); box-shadow: var(--edge); font-size: 14px; pointer-events: auto; animation: toast-in .2s ease-out; }
.toast .body { flex: 1; } .toast a { color: var(--bg); } .toast.bad { border-left-color: var(--toast-bad); } .toast.ok { border-left-color: var(--toast-ok); } .toast.warn { border-left-color: var(--toast-warn); }
:root[data-theme="dark"] .toast a { color: var(--bg); }
.toast .x { border: 0; background: none; color: var(--bg); opacity: .7; cursor: pointer; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- dialog ---------- */
.scrim { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: var(--scrim); animation: fade .15s ease-out; }
.dialog { position: relative; width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 26px 24px 20px; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--edge); animation: rise .2s ease-out; }
.dialog.wide { width: min(720px, 100%); } .dialog h2 { font-size: 22px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.secret { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px dashed var(--line-strong); border-radius: var(--r); font: 14px var(--mono); word-break: break-all; background: var(--surface-2); }
@keyframes fade { from { opacity: 0; } } @keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@media (max-width: 640px) { .scrim { align-items: end; padding: 0; } .dialog, .dialog.wide { width: 100%; border-radius: var(--r) var(--r) 0 0; border-bottom: 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); animation: sheet-up .22s ease-out; } }

/* ---------- data: tables, facts, kpis, rows, cards ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { padding: 8px 12px 8px 0; border-bottom: 2px solid var(--ink); text-align: left; font: 700 12px/1.2 var(--caps); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
table.t th.sortable { cursor: pointer; } table.t th.sortable:hover { color: var(--ink); }
table.t th[aria-sort="ascending"]::after { content: " ↑"; } table.t th[aria-sort="descending"]::after { content: " ↓"; }
table.t td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
table.t .num { text-align: right; padding-right: 0; } table.t td.td-actions { text-align: right; white-space: nowrap; }
table.t tr.clickable { cursor: pointer; } table.t tr.clickable:hover td { background: var(--surface-2); }
.pagebar { display: flex; justify-content: center; padding: 14px 0 0; }
@media (max-width: 640px) {
  table.t.stackable thead { display: none; } table.t.stackable tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.t.stackable td { display: flex; justify-content: space-between; gap: 16px; border: 0; padding: 3px 0; text-align: right; }
  table.t.stackable td[data-label]::before { content: attr(data-label); color: var(--muted); font: 700 12px var(--caps); text-transform: uppercase; letter-spacing: .12em; text-align: left; }
}
.facts { margin: 0; display: grid; } .facts > div { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: 14px; } .facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.rows > * { padding: 12px 0; border-bottom: 1px solid var(--line); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 24px; } .kpi .v { font: 700 28px/1 var(--display); font-variant-numeric: tabular-nums; } .kpi .l { margin-top: 6px; font: 700 12px var(--caps); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
/* cards are for owned objects (a pair, an analysis): card stock with the stacked-paper edge */
.obj, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--edge); }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; } .card-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.kraft-card { background-color: var(--kraft); background-image: var(--grain); color: var(--k-ink); border-radius: var(--r); padding: 18px; }
.crumbs { display: flex; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.sub { color: var(--muted); }
/* photographs sit on a plain well */
.well { background: var(--surface-2); border-radius: var(--r); }
.band { display: flex; height: 44px; } .band.tall { height: 80px; } .band.slim { height: 14px; } .band > * { flex: var(--w, 1) 1 0; min-width: 0; background: var(--sw); }
/* the receipt strip: perforated top and bottom */
.receipt { position: relative; padding: 22px 20px; background: var(--surface-2); font-family: var(--mono); }
.receipt::before, .receipt::after { content: ""; position: absolute; left: 0; right: 0; height: 9px; background: radial-gradient(circle, var(--line-strong) 1.4px, transparent 2px) 0 0 / 9px 9px repeat-x; }
.receipt::before { top: -4px; } .receipt::after { bottom: -4px; }

/* ---------- states: skeleton (a moving needle highlight), empty tag, error ---------- */
.skel { border-radius: var(--r); background: linear-gradient(100deg, var(--surface-2) 30%, color-mix(in srgb, var(--line) 70%, var(--surface-2)) 40%, var(--surface-2) 50%); background-size: 300% 100%; animation: needle 1.6s linear infinite; }
.skel.chart { height: 240px; } .skel.line { height: 14px; margin: 8px 0; } .skel.kpi-s { height: 90px; } .skel.block { height: 120px; } .skel.photo { aspect-ratio: 1; }
@keyframes needle { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.empty { display: grid; justify-items: start; gap: 10px; padding: 28px 24px; border: 2px dashed var(--line); border-radius: var(--r); color: var(--muted); }
.empty .big { display: grid; place-items: center; width: 44px; height: 44px; border: 2px dashed var(--line-strong); border-radius: 50%; color: var(--muted); } .empty .big .i { width: 22px; height: 22px; }
.empty h3 { color: var(--ink); font: 700 20px/1.2 var(--display); } .empty p { max-width: 50ch; }

/* ---------- motion ---------- */
@keyframes sewn-in { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0); } }
#app:not(.settled) .stagger > *, .sewn-in { animation: sewn-in .55s ease-out both; }
.stagger > :nth-child(2) { animation-delay: .06s; } .stagger > :nth-child(3) { animation-delay: .12s; } .stagger > :nth-child(4) { animation-delay: .18s; } .stagger > :nth-child(n+5) { animation-delay: .24s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .skel { animation: none; }
}
@media print { .topbar, .tabbar, .stub, .foot, .toasts, #banners { display: none !important; } .docket { box-shadow: none; display: block; } body { background: #fff; } }

/* ---------- charts (lib/charts.js, lib/usagechart.js): hand-drawn SVG, tokens only ---------- */
.ch { position: relative; width: 100%; } .ch-box { outline: none; } .ch-box:focus-visible { box-shadow: var(--ring); }
.ch-svg { display: block; width: 100%; height: auto; overflow: visible; }
.ch-grid line { stroke: var(--line); stroke-width: 1; } .ch-grid text, .ch-xaxis text { fill: var(--muted); font: 11px var(--mono); }
.ch-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 7 3; }
.ch-dot { fill: var(--surface); stroke: var(--c); stroke-width: 1.75; } .ch-dot.sm { fill: var(--c); stroke: none; }
.ch-cross { stroke: var(--ink); stroke-width: 1; } .ch-ring { fill: var(--surface); stroke: var(--c); stroke-width: 2.5; } .ch-hit { cursor: crosshair; }
.ch-msg { margin: 0; padding: 28px 0; color: var(--muted); }
.ch-tip { position: absolute; z-index: 3; pointer-events: none; min-width: 150px; max-width: 240px; padding: 9px 12px; border-radius: var(--r); background: var(--ink); color: var(--bg); font-size: 13px; }
.ch-tip-h { font-weight: 700; margin-bottom: 5px; } .ch-tip-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; } .ch-tip-row b { font-variant-numeric: tabular-nums; }
.ch-key { display: inline-block; width: 10px; height: 10px; background: var(--c); flex: none; border-radius: 1px; }
.ch-key.dashed { width: 18px; height: 3px; background: repeating-linear-gradient(90deg, var(--c) 0 5px, transparent 5px 8px); }
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 22px; list-style: none; margin: 0 0 14px; padding: 0; font-size: 14px; } .ch-legend li { display: inline-flex; align-items: center; gap: 8px; }
.ch-stack-wrap { display: grid; gap: 14px; } .ch-stack { display: flex; gap: 2px; height: clamp(44px, 9vw, 64px); }
.ch-stack > i { display: block; flex-basis: 0; min-width: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); position: relative; }
.ch-stack > i:hover::after, .ch-stack > i:focus-visible::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); white-space: nowrap; padding: 5px 9px; border-radius: var(--r); background: var(--ink); color: var(--bg); font-size: 12px; z-index: 5; }
.ch-stack > i:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; box-shadow: none; }
.ch-stack-key { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 10px 22px; list-style: none; margin: 0; padding: 0; }
.ch-stack-key li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 9px; align-items: center; font-size: 14px; } .ch-stack-key span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-sw { display: block; width: 12px; height: 12px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); } .ch-stack-key small { color: var(--muted); font-size: 12px; min-width: 3ch; text-align: right; }
.ch-tape { display: none; }
.ch-rank { list-style: none; margin: 0; padding: 0; } .ch-rank li { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto; align-items: baseline; gap: 8px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.ch-rank-n { font: 500 12px var(--mono); color: var(--muted); } .ch-rank-name { font: 700 18px/1.15 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .ch-rank-v { font: 700 14px var(--mono); }
.ch-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; } .ch-bars li { display: grid; grid-template-columns: minmax(84px, 138px) minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.ch-bar-track { height: 8px; background: var(--surface-2); overflow: hidden; border-radius: 2px; } .ch-bar-fill { display: block; height: 100%; background: var(--c); border-radius: 2px; } .ch-bar-val { font-variant-numeric: tabular-nums; font-size: 14px; text-align: right; }
.ch-bar-hint { grid-column: 2 / -1; color: var(--muted); font-size: 12px; }
.ch-mini { display: inline-block; vertical-align: middle; } .ch-mini-bar { fill: var(--c); } .ch-mini-na { fill: var(--line-strong); }
.chart { position: relative; width: 100%; } .chart svg { display: block; overflow: visible; max-width: 100%; } .chart text { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.chart .grid-line { stroke: var(--line); shape-rendering: crispEdges; } .chart .axis-line { stroke: var(--ink); shape-rendering: crispEdges; }
.chart .bar { transition: opacity .15s; } .chart .bar:focus-visible { outline: 2px solid var(--brand); }
.chart-tip { position: absolute; pointer-events: none; z-index: 5; min-width: 130px; padding: 8px 10px; border-radius: var(--r); font-size: 13px; background: var(--ink); color: var(--bg); opacity: 0; transition: opacity .12s; } .chart-tip.on { opacity: 1; }
.chart-tip b { display: block; margin-bottom: 3px; } .chart-tip .tr { display: flex; justify-content: space-between; gap: 14px; }
.chart-msg { display: grid; place-items: center; text-align: center; color: var(--muted); min-height: 140px; padding: 20px; border: 2px dashed var(--line); border-radius: var(--r); }

/* ---------- public shell bar (landing, error, shared) ---------- */
.pubbar { position: absolute; z-index: 5; left: 0; right: 0; top: 0; display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) clamp(16px, 4vw, 40px) 14px; }
.pubbar-actions { display: flex; align-items: center; gap: 8px; } .pub-link { color: var(--ink); text-decoration: none; padding: 8px 12px; font: 700 13px var(--caps); letter-spacing: .14em; text-transform: uppercase; } .pub-link:hover { text-decoration: underline; }
.pubbar .icon-btn { color: var(--muted); } .pubbar .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.err-page { min-height: 100vh; display: grid; align-content: center; justify-items: start; gap: 18px; padding: 120px clamp(22px, 8vw, 120px) 80px; background: var(--bg); }
.err-page h1 { font-size: clamp(44px, 8vw, 72px); max-width: 14ch; } .err-page p { max-width: 52ch; color: var(--muted); font-size: 18px; }
.err-page .code { font: 700 12px var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.err-page .brand { position: absolute; top: 20px; left: clamp(16px, 4vw, 40px); }
