/* Budget It demo - layout and components. Mobile first; desktop from 1024px. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
.num, td.num, .stat-value, .money { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Shell ---------- */
.skip-link { position: absolute; left: var(--sp-2); top: -48px; z-index: 50; background: var(--brand); color: var(--brand-contrast); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); }
.skip-link:focus { top: var(--sp-2); }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); text-decoration: none; color: var(--text); font-weight: 700; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-name { font-size: var(--fs-lg); letter-spacing: -0.02em; }
.workspace { display: flex; flex-direction: column; min-width: 0; margin-left: auto; text-align: right; }
@media (max-width: 479px) { .workspace { display: none; } .sample-badge { margin-left: auto; } }
.workspace strong { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace span { font-size: var(--fs-xs); color: var(--text-muted); }
.sample-badge { font-size: var(--fs-xs); font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }

.main { flex: 1; width: 100%; min-width: 0; max-width: 1120px; margin: 0 auto; padding: var(--sp-4) var(--sp-4) calc(var(--nav-h) + var(--sp-8)); }
.main:focus { outline: none; }

/* Bottom navigation (mobile) */
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--text-muted); text-decoration: none; min-height: var(--tap);
}
.nav a svg { width: 22px; height: 22px; }
.nav a[aria-current="page"] { color: var(--brand); }
.nav a.nav-record span.bubble {
  width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center;
  background: var(--brand); color: var(--brand-contrast); box-shadow: var(--shadow-2); margin-top: -18px;
}
.nav a.nav-record svg { width: 26px; height: 26px; }
.nav .nav-label-desktop { display: none; }
.nav .nav-more-desktop { display: none; }

@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 248px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; padding: var(--sp-3) var(--sp-6); }
  .nav {
    position: sticky; top: 61px; inset: auto; height: calc(100vh - 61px); padding: var(--sp-4) var(--sp-3);
    display: flex; flex-direction: column; gap: var(--sp-1); border-top: 0; border-right: 1px solid var(--border); background: var(--bg);
  }
  .nav a { flex-direction: row; justify-content: flex-start; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); border-radius: var(--radius); }
  .nav a:hover { background: var(--surface-sunken); }
  .nav a[aria-current="page"] { background: var(--brand-soft); }
  .nav a.nav-record { order: -1; margin-bottom: var(--sp-3); }
  .nav a.nav-record span.bubble { width: auto; height: auto; margin: 0; border-radius: var(--radius); padding: var(--sp-2) var(--sp-3); display: flex; gap: var(--sp-2); box-shadow: none; flex: 1; }
  .nav a.nav-record svg { width: 20px; height: 20px; }
  .nav a.nav-record .nav-label-mobile { display: none; }
  .nav a.nav-record .nav-label-desktop { display: inline; }
  .nav .nav-more-desktop { display: flex; }
  .main { padding: var(--sp-6) var(--sp-8) var(--sp-10); }
}

/* ---------- Page scaffolding ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-2xl); }
.page-head p { color: var(--text-muted); margin-top: var(--sp-1); }
.eyebrow { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.back { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--text-muted); text-decoration: none; font-size: var(--fs-sm); margin-bottom: var(--sp-2); min-height: 32px; }
.section { margin-top: var(--sp-6); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.section-head h2 { font-size: var(--fs-lg); }
.section-head a { font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
.grid { display: grid; gap: var(--sp-3); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } .split > * { min-width: 0; }
  .split { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--sp-5); align-items: start; } }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-4); box-shadow: var(--shadow-1); }
.card + .card { margin-top: var(--sp-3); }
.grid > .card + .card, .grid-2 > .card + .card, .grid-3 > .card + .card, .grid-4 > .card + .card { margin-top: 0; }
.card h3 { font-size: var(--fs-md); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:hover { border-color: var(--border-strong); }
.card-hero { background: var(--brand); color: var(--brand-contrast); border-color: transparent; }
.card-hero .muted, .card-hero .stat-label { color: color-mix(in srgb, var(--brand-contrast) 78%, transparent); }

/* Stats */
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: var(--fs-sm); color: var(--text-muted); display: flex; align-items: center; gap: var(--sp-1); }
.stat-value { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.stat-value.sm { font-size: var(--fs-xl); }
.stat-sub { font-size: var(--fs-sm); color: var(--text-muted); }
.delta { font-size: var(--fs-sm); font-weight: 600; }
.delta.up { color: var(--positive); }
.delta.down { color: var(--negative); }
.stats-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-3); }
.stat-value { overflow-wrap: anywhere; }
@media (max-width: 479px) { .stat-value { font-size: var(--fs-xl); } .stat-value.sm { font-size: var(--fs-lg); } .card-hero .stat-value { font-size: var(--fs-2xl) !important; } }
@media (min-width: 1024px) { .stats-row.four { grid-template-columns: repeat(4, 1fr); } }

/* Evidence chip */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-sunken); color: var(--text-muted); white-space: nowrap; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.actual { color: var(--evidence-actual); background: var(--positive-soft); }
.chip.estimated { color: var(--warning); background: var(--warning-soft); }
.chip.stale { color: var(--evidence-stale); background: var(--warning-soft); }
.chip.missing, .chip.provisional { color: var(--negative); background: var(--negative-soft); }
.chip.neutral::before { display: none; }
.chip.reversed { color: var(--text-muted); text-decoration: line-through; }

.evidence-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-sunken); margin: var(--sp-2) 0; }
.evidence-bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-xs); color: var(--text-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Alerts / insights */
.alerts { display: grid; gap: var(--sp-2); }
.alert { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: var(--sp-3); align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3) var(--sp-3) var(--sp-3) 0; text-decoration: none; color: inherit; overflow: hidden; }
.alert::before { content: ""; align-self: stretch; margin: calc(-1 * var(--sp-3)) 0; background: var(--info); }
.alert.warning::before { background: var(--accent); }
.alert.critical::before { background: var(--negative); }
.alert .alert-topic { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.alert .alert-title { font-weight: 600; }
.alert .alert-detail { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }
.alert svg { color: var(--text-faint); width: 18px; height: 18px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; min-height: 56px; text-decoration: none; color: inherit; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.row-sub { display: block; font-size: var(--fs-sm); color: var(--text-muted); }
.row-end { text-align: right; flex: none; }
.row-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-sunken); color: var(--text-muted); }
.row-icon svg { width: 20px; height: 20px; }
.row-icon.purchase { background: var(--info-soft); color: var(--info); }
.row-icon.batch { background: var(--accent-soft); color: var(--accent); }
.row-icon.dayclose { background: var(--brand-soft); color: var(--brand); }
.row-icon.count { background: var(--warning-soft); color: var(--warning); }
.row-icon.expense, .row-icon.reversal { background: var(--negative-soft); color: var(--negative); }
.row-icon.payment { background: var(--positive-soft); color: var(--positive); }
a.row:hover .row-title { color: var(--brand); }
.is-reversed .row-title, .is-reversed .row-end { text-decoration: line-through; color: var(--text-faint); }

/* Definition ledger */
.ledger { display: grid; gap: 0; margin: 0; }
.ledger > div { display: flex; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-2) 0; border-top: 1px dashed var(--border); }
.ledger > div:first-child { border-top: 0; }
.ledger dt { color: var(--text-muted); }
.ledger dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.ledger .total { border-top: 1px solid var(--border-strong); }
.ledger .total dt, .ledger .total dd { color: var(--text); font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--sp-4)); padding: 0 var(--sp-4); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { text-align: left; padding: var(--sp-2) var(--sp-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-weight: 600; color: var(--text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
td a { font-weight: 600; text-decoration: none; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--tap); padding: 0 var(--sp-4); border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--stone-400); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); padding: 0 var(--sp-2); }
.btn-danger { color: var(--negative); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.actions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
@media (min-width: 640px) { .actions-grid { grid-template-columns: repeat(3, 1fr); } }
.action { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); text-decoration: none; color: inherit; min-height: 112px; }
.action:hover { border-color: var(--brand); }
.action .row-icon { width: 40px; height: 40px; }
.action strong { font-size: var(--fs-md); }
.action span.muted { font-size: var(--fs-sm); }

/* ---------- Forms ---------- */
.form { display: grid; gap: var(--sp-4); }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-size: var(--fs-sm); font-weight: 600; }
.field .hint { font-size: var(--fs-xs); color: var(--text-muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.input:focus { border-color: var(--brand); outline: 2px solid color-mix(in srgb, var(--brand) 30%, transparent); outline-offset: 0; }
.input[aria-invalid="true"] { border-color: var(--negative); }
.input-affix { display: flex; align-items: stretch; }
.input-affix .affix { display: grid; place-items: center; padding: 0 var(--sp-3); background: var(--surface-sunken); border: 1px solid var(--border-strong); color: var(--text-muted); font-size: var(--fs-sm); }
.input-affix .affix:first-child { border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.input-affix .affix:last-child { border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; }
.input-affix .input { border-radius: 0; }
.input-affix .input:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.input-affix .input:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 650; padding: 0; margin-bottom: var(--sp-2); }
.form-errors { background: var(--negative-soft); color: var(--negative); border-radius: var(--radius); padding: var(--sp-3); font-size: var(--fs-sm); }
.form-errors ul { margin: var(--sp-1) 0 0; padding-left: var(--sp-5); }
.form-footer { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); padding: var(--sp-4) 0 var(--sp-2); display: grid; gap: var(--sp-2); }
@media (min-width: 1024px) { .form-footer { bottom: 0; } }

/* Stepper for counts: large targets, works with gloves and flour on fingers */
.stepper { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.stepper button { border: 0; background: var(--surface-sunken); font-size: 1.25rem; font-weight: 700; cursor: pointer; min-height: var(--tap); }
.stepper button:active { background: var(--border); }
.stepper input { border: 0; text-align: center; font-weight: 700; font-size: var(--fs-lg); min-width: 0; font-variant-numeric: tabular-nums; background: transparent; }
.stepper input:focus { outline: none; }
.stepper:focus-within { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Segmented control */
.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: var(--radius); background: var(--surface-sunken); border: 1px solid var(--border); flex-wrap: wrap; }
.segmented button, .segmented a { border: 0; background: transparent; padding: 6px 12px; min-height: 36px; border-radius: 8px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.segmented [aria-pressed="true"], .segmented [aria-current="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.choice-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.choice-chips label { position: relative; }
.choice-chips input { position: absolute; opacity: 0; inset: 0; }
.choice-chips span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--sp-3); border: 1px solid var(--border-strong); border-radius: 999px; font-size: var(--fs-sm); cursor: pointer; background: var(--surface); }
.choice-chips input:checked + span { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.choice-chips input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.preview { background: var(--surface-sunken); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); }
.preview .stat-value { font-size: var(--fs-xl); }
.callout { border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); background: var(--info-soft); color: var(--text); }
.callout.warning { background: var(--warning-soft); }
.callout.positive { background: var(--positive-soft); }
.callout.negative { background: var(--negative-soft); }
.callout strong { display: block; margin-bottom: 2px; }

.product-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-4); background: var(--surface); }
.product-card + .product-card { margin-top: var(--sp-3); }
.product-card header { display: flex; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.avail { font-size: var(--fs-sm); color: var(--text-muted); }
.balance { display: flex; justify-content: space-between; font-size: var(--fs-sm); padding-top: var(--sp-3); margin-top: var(--sp-3); border-top: 1px dashed var(--border); }
.balance.ok { color: var(--positive); }
.balance.bad { color: var(--negative); font-weight: 600; }

details.disclosure { border-top: 1px solid var(--border); padding-top: var(--sp-3); margin-top: var(--sp-3); }
details.disclosure summary { cursor: pointer; font-weight: 600; font-size: var(--fs-sm); color: var(--brand); min-height: 32px; display: flex; align-items: center; }
details.disclosure[open] summary { margin-bottom: var(--sp-2); }
.definition { font-size: var(--fs-sm); color: var(--text-muted); }
.definition code { font-family: var(--font-mono); font-size: 0.85em; background: var(--surface-sunken); padding: 1px 4px; border-radius: 4px; }

/* Charts */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--text-muted); font-size: 11px; }
.chart .label-strong { fill: var(--text); font-weight: 600; }
.chart .axis { stroke: var(--border); }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 2 3; }

/* Toast */
.toast-region { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--sp-3)); z-index: 60; width: min(560px, calc(100% - 32px)); display: grid; gap: var(--sp-2); pointer-events: none; }
@media (min-width: 1024px) { .toast-region { bottom: var(--sp-6); } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--sp-3); background: var(--stone-900); color: #fff; border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow-2); animation: toast-in 160ms ease-out; }
:root[data-theme="dark"] .toast { background: #f5f2ee; color: var(--stone-900); }
.toast span { flex: 1; font-size: var(--fs-sm); }
.toast a, .toast button { color: var(--green-200); background: none; border: 0; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 32px; }
:root[data-theme="dark"] .toast a, :root[data-theme="dark"] .toast button { color: var(--green-700); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Dialog */
dialog { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(480px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }
dialog::backdrop { background: rgb(18 16 14 / 0.5); }
dialog form { padding: var(--sp-5); display: grid; gap: var(--sp-4); }

.empty { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--text-muted); }
.empty h3 { color: var(--text); margin-bottom: var(--sp-1); }
.tag { display: inline-block; font-size: var(--fs-xs); font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--surface-sunken); color: var(--text-muted); }
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; border: 0; }
.footnote { font-size: var(--fs-xs); color: var(--text-faint); margin-top: var(--sp-6); }

/* Compact steppers when three sit side by side on a phone */
.field-row.three .stepper { grid-template-columns: 34px minmax(28px, 1fr) 34px; }
.field-row.three .stepper button { font-size: 1.1rem; }
.field-row.three .field > label { font-size: var(--fs-xs); }
.stats-row .stat-value { font-size: clamp(1.15rem, 5.4vw, 1.75rem); }
.stats-row .stat-value.sm { font-size: clamp(1.05rem, 4.6vw, 1.375rem); }
.product-card header { align-items: flex-start; flex-wrap: wrap; }
.product-card header .tag { white-space: nowrap; }

/* Grid children may shrink below their content width; tables scroll inside .table-wrap */
.grid > *, .grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }

/* SVG charts scale with their container; enlarge labels on narrow screens */
@media (max-width: 640px) { .chart text { font-size: 19px; } }
