/* ==========================================================================
   MoneyPilot — components.css
   Cards, buttons, stats, meters, tables, pills, callouts, forms, charts.
   Reads tokens from base.css. Declares no raw colour.
   ========================================================================== */

/* --- Card ---------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.card-flat  { box-shadow: none; }
.card-quiet { background: var(--surface-2); }
.card-hover { transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast); }
.card-hover:hover { border-color: var(--border-strong); box-shadow: var(--sh-2); text-decoration: none; }
a.card, a.card-hover { color: inherit; display: block; }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-head h3, .card-head h2 { font-size: var(--t-md); }
.card-body { padding: 16px; }
.card-body-tight { padding: 12px 16px; }
.card-foot {
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--t-sm);
}

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: var(--t-sm); font-weight: 500;
  white-space: nowrap;
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--text-inv); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-accent  { background: var(--accent); color: var(--text-inv); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost   { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn-quiet   { background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--surface-3); color: var(--text); }
.btn-danger  { background: var(--danger); color: var(--text-inv); }
.btn-danger:hover { filter: brightness(1.08); }
.btn-soft    { background: var(--primary-soft); color: var(--primary-ink); }
.btn-soft:hover { background: var(--primary-line); }

.btn-lg  { padding: 12px 22px; font-size: var(--t-base); border-radius: var(--r-md); }
.btn-sm  { padding: 6px 11px; font-size: var(--t-xs); }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 34px; height: 34px; flex: none; }
.btn-icon.btn-sm { width: 28px; height: 28px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.btn-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
}
.btn-group > button {
  padding: 6px 12px;
  font-size: var(--t-xs); font-weight: 500;
  color: var(--text-2);
  border-right: 1px solid var(--border);
}
.btn-group > button:last-child { border-right: 0; }
.btn-group > button[aria-selected="true"] { background: var(--primary); color: var(--text-inv); }

/* --- Icons --------------------------------------------------------------- */
.i { width: 18px; height: 18px; flex: none; stroke-width: 1.7; }
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }
.i-xl { width: 28px; height: 28px; }

/* --- Badges & pills ------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--t-xs); font-weight: 500;
  white-space: nowrap;
}
.badge-green  { background: var(--success-soft); color: var(--success); }
.badge-amber  { background: var(--warn-soft);    color: var(--warn); }
.badge-red    { background: var(--danger-soft);  color: var(--danger); }
.badge-blue   { background: var(--info-soft);    color: var(--info); }
.badge-primary{ background: var(--primary-soft); color: var(--primary-ink); }
.badge-accent { background: var(--accent-soft);  color: var(--accent-ink); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Status pills for the moderation queue. Label + colour, never colour alone. */
.st {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-pill);
  font-size: var(--t-xs); font-weight: 500;
}
.st-live     { background: var(--success-soft); color: var(--success); }
.st-review   { background: var(--warn-soft);    color: var(--warn); }
.st-held     { background: var(--danger-soft);  color: var(--danger); }
.st-thin     { background: var(--surface-3);    color: var(--text-2); }

/* --- Avatar -------------------------------------------------------------- */
.avatar {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: var(--t-xs); font-weight: 600;
  background: var(--primary-soft); color: var(--primary-ink);
  letter-spacing: .02em;
}
.avatar-sm { width: 28px; height: 28px; font-size: 10.5px; }
.avatar-lg { width: 48px; height: 48px; font-size: var(--t-sm); }
.avatar.v2 { background: var(--accent-soft);  color: var(--accent-ink); }
.avatar.v3 { background: var(--success-soft); color: var(--success); }
.avatar.v4 { background: var(--info-soft);    color: var(--info); }
.avatar.v5 { background: var(--warn-soft);    color: var(--warn); }

/* --- Stat tile ----------------------------------------------------------- */
/* A KPI is a headline number, not a chart. Delta carries direction in an
   arrow AND a sign, so it survives greyscale and colour blindness. */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 14px 15px;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0;
}
.stat-top { display: flex; align-items: center; gap: 9px; }
.stat-ic {
  width: 30px; height: 30px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2);
}
.stat-ic.green  { background: var(--success-soft); color: var(--success); }
.stat-ic.amber  { background: var(--warn-soft);    color: var(--warn); }
.stat-ic.red    { background: var(--danger-soft);  color: var(--danger); }
.stat-ic.blue   { background: var(--info-soft);    color: var(--info); }
.stat-ic.accent { background: var(--accent-soft);  color: var(--accent-ink); }
.stat-label { font-size: var(--t-xs); color: var(--text-3); font-weight: 500; letter-spacing: .01em; }
.stat-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-xl); font-weight: 500;
  letter-spacing: -.022em; line-height: 1.05;
}
.stat-value small { font-size: var(--t-sm); color: var(--text-3); margin-left: 3px; font-weight: 400; }
.stat-foot { display: flex; align-items: center; gap: 7px; font-size: var(--t-xs); color: var(--text-3); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-family: var(--mono); }
.delta.up   { color: var(--success); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--text-3); }
/* On a price screen "up" is bad news, so the meaning inverts explicitly. */
.delta.cost-up   { color: var(--danger); }
.delta.cost-down { color: var(--success); }

/* --- Hero figure --------------------------------------------------------- */
.figure-hero { display: flex; flex-direction: column; gap: 3px; }
.figure-hero .fh-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-3xl); font-weight: 500;
  letter-spacing: -.035em; line-height: 1;
}
.figure-hero .fh-sub { font-size: var(--t-sm); color: var(--text-2); }

/* --- Meter (magnitude vs target) ----------------------------------------- */
/* A ranked meter list, not a pie: 13 budget categories is far past what a
   pie can be read at, and meters can be compared and sorted. */
.meter { display: flex; flex-direction: column; gap: 7px; }
.meter-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.meter-name { font-size: var(--t-sm); font-weight: 500; display: flex; align-items: center; gap: 7px; min-width: 0; }
.meter-fig  { font-family: var(--mono); font-size: var(--t-xs); color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter-fig b { color: var(--text); font-weight: 500; }

.bar {
  position: relative;
  height: 7px;
  background: var(--track);
  border-radius: 4px;
  overflow: hidden;
}
.bar > span {
  position: absolute; inset-block: 0; left: 0;
  background: var(--primary);
  border-radius: 4px;
  min-width: 3px;
  transition: width var(--med);
}
.bar.green  > span { background: var(--success); }
.bar.amber  > span { background: var(--warn); }
.bar.red    > span { background: var(--danger); }
.bar.accent > span { background: var(--accent); }
.bar-lg { height: 10px; }
/* Overspend rides past the cap with a 2px surface gap so it reads as its
   own mark rather than a longer fill. */
.bar-over {
  position: absolute; inset-block: 0; right: 0;
  background: var(--danger);
  border-radius: 4px;
  box-shadow: -2px 0 0 0 var(--surface);
}
.meter-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: var(--t-xs); }
.meter-state { font-weight: 500; }
.meter-state.good { color: var(--success); }
.meter-state.warn { color: var(--warn); }
.meter-state.crit { color: var(--danger); }
.meter-state.quiet{ color: var(--text-3); }

/* Stacked composition bar (budget mix). 2px gaps between segments. */
.mixbar { display: flex; height: 10px; border-radius: 4px; overflow: hidden; background: var(--track); gap: 2px; }
.mixbar > span { display: block; height: 100%; }
.mixbar > span:first-child { border-radius: 4px 0 0 4px; }
.mixbar > span:last-child  { border-radius: 0 4px 4px 0; }

/* --- Legend -------------------------------------------------------------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: var(--t-xs); color: var(--text-2); }
.legend-swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.legend-val { font-family: var(--mono); color: var(--text); font-weight: 500; }

/* --- List / rows --------------------------------------------------------- */
.list > li { border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  width: 100%; text-align: left;
  color: inherit;
  transition: background var(--fast);
}
a.item:hover, button.item:hover { background: var(--surface-2); text-decoration: none; }
.item-title { font-size: var(--t-sm); font-weight: 500; }
.item-sub   { font-size: var(--t-xs); color: var(--text-3); }
.item-end   { text-align: right; flex: none; }
.item-val   { font-family: var(--mono); font-size: var(--t-sm); font-weight: 500; font-variant-numeric: tabular-nums; }
.item-val.out { color: var(--danger); }
.item-ic {
  width: 34px; height: 34px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2);
}

.list-head {
  padding: 8px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: var(--t-xs);
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
  display: flex; justify-content: space-between; gap: 10px;
}

/* --- Table --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; font-size: var(--t-sm); }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table thead th {
  font-family: var(--mono); font-size: var(--t-xs); font-weight: 400;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
  background: var(--surface-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }

details.datatoggle > summary {
  cursor: pointer; list-style: none;
  font-family: var(--mono); font-size: var(--t-xs);
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
  padding: 8px 0;
}
details.datatoggle > summary::-webkit-details-marker { display: none; }
details.datatoggle > summary:hover { color: var(--text-2); }

/* --- Callout ------------------------------------------------------------- */
.callout {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--t-sm); line-height: 1.5;
}
.callout > .i { margin-top: 1px; }
.callout-warn { background: var(--warn-soft);    border-color: var(--accent-line); color: var(--warn); }
.callout-crit { background: var(--danger-soft);  border-color: var(--danger);      color: var(--danger); }
.callout-good { background: var(--success-soft); border-color: var(--success);     color: var(--success); }
.callout-info { background: var(--primary-soft); border-color: var(--primary-line);color: var(--primary-ink); }
.callout strong { font-weight: 600; }

/* --- Insight card -------------------------------------------------------- */
/* Severity is carried by the icon glyph (alert / check / info) and by the
   wording of the headline, not by a coloured rail down the side — so it
   still survives greyscale and colour blindness without the stripe. */
.insight {
  display: grid;
  grid-template-columns: auto 1fr;
  /* When a card is stretched to a taller neighbour, keep the rows at their
     natural height — otherwise the spare height is shared out and the action
     button balloons. */
  align-content: start;
  gap: 4px 12px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
}
.insight-ic { grid-row: 1 / span 3; width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.insight-title { font-size: var(--t-sm); font-weight: 600; }
.insight-body  { font-size: var(--t-sm); color: var(--text-2); line-height: 1.5; }
.insight-act   { justify-self: start; margin-top: 6px; }
.insight.crit .insight-ic { background: var(--danger-soft); color: var(--danger); }
.insight.warn .insight-ic { background: var(--warn-soft); color: var(--warn); }
.insight.good .insight-ic { background: var(--success-soft); color: var(--success); }
.insight.info .insight-ic { background: var(--primary-soft); color: var(--primary-ink); }

/* --- Provenance ---------------------------------------------------------- */
/* The line that separates TruePrice from a number in a spreadsheet.
   A widened scope is called out in the warning token, never hidden. */
.prov {
  font-family: var(--mono); font-size: var(--t-xs);
  color: var(--text-3);
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 6px;
}
.prov .sep { opacity: .55; }
.prov .scope-state, .prov .scope-national { color: var(--warn); font-weight: 500; }
.prov .flagged { color: var(--danger); }

/* --- Forms --------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: var(--t-sm); font-weight: 500; }
.field .hint { font-size: var(--t-xs); color: var(--text-3); line-height: 1.45; }
.field .err  { font-size: var(--t-xs); color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: var(--t-base);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input-money { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.select { appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.textarea { min-height: 84px; resize: vertical; }

.input-group { position: relative; display: flex; align-items: center; }
.input-group > .i { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-left: 34px; }
.input-prefix { position: absolute; left: 12px; font-family: var(--mono); color: var(--text-3); pointer-events: none; }
.input-group.money > .input { padding-left: 28px; }

.check { display: flex; align-items: flex-start; gap: 9px; font-size: var(--t-sm); cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--primary); width: 15px; height: 15px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
/* Squared, not pill. A pill pads its own ends and forces every label into a
   lozenge, which reads as decoration and crowds longer category names; a
   plain rounded rectangle lets the label set its own width. */
.chip {
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--t-xs); font-weight: 500;
  white-space: nowrap;
}
.chip:hover { border-color: var(--text-3); text-decoration: none; }
.chip[aria-pressed="true"], .chip[aria-current="true"] {
  background: var(--primary); border-color: var(--primary); color: var(--text-inv);
}

/* Star-rating style priority picker */
.stars { display: inline-flex; gap: 3px; }
.stars button { color: var(--border-strong); line-height: 1; padding: 2px; }
.stars button[data-on="1"] { color: var(--accent); }

/* --- Charts -------------------------------------------------------------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--text-3); font-size: 10.5px; font-family: var(--mono); }
.chart .series-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .series-area { opacity: .11; }
.chart .series-dot  { stroke: var(--plot); stroke-width: 2; }
.chart .bar-rect    { rx: 3; }
.chart .hover-band  { fill: var(--text); opacity: 0; }
.chart .hover-band:hover { opacity: .045; }
.chart .crosshair   { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }

.spark { width: 100%; height: 40px; display: block; }
.spark .sp-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark .sp-area { opacity: .13; }
.spark .sp-end  { stroke: var(--plot); stroke-width: 2; }

.chart-tip {
  position: fixed; z-index: 90;
  pointer-events: none;
  background: var(--text); color: var(--bg);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: var(--t-xs); line-height: 1.45;
  box-shadow: var(--sh-3);
  max-width: 220px;
}
.chart-tip .tip-k { opacity: .72; }
.chart-tip .tip-v { font-family: var(--mono); font-weight: 500; }

/* Coverage heat cells — sequential, one hue, light to dark. */
.heat { display: grid; gap: 3px; }
.heat-cell { aspect-ratio: 1; border-radius: 3px; background: var(--track); position: relative; }
.heat-cell[data-level="1"] { background: color-mix(in srgb, var(--primary) 18%, var(--surface-3)); }
.heat-cell[data-level="2"] { background: color-mix(in srgb, var(--primary) 38%, var(--surface-3)); }
.heat-cell[data-level="3"] { background: color-mix(in srgb, var(--primary) 60%, var(--surface-3)); }
.heat-cell[data-level="4"] { background: color-mix(in srgb, var(--primary) 82%, var(--surface-3)); }
.heat-cell[data-level="5"] { background: var(--primary); }

/* --- Ops strip (console readings) ---------------------------------------- */
.ops-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
  overflow: hidden;
}
.ops-bar > div { padding: 10px 14px; border-right: 1px solid var(--border); min-width: 0; }
.ops-bar > div:last-child { border-right: 0; }
.ops-k { font-size: var(--t-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ops-v { font-family: var(--mono); font-size: var(--t-md); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ops-v small { font-size: var(--t-xs); color: var(--text-3); margin-left: 2px; }
.ops-bar > div.warn  { background: var(--warn-soft); }
.ops-bar > div.warn  .ops-v { color: var(--warn); }
.ops-bar > div.alert { background: var(--danger-soft); }
.ops-bar > div.alert .ops-v { color: var(--danger); }
.ops-bar > div.good  .ops-v { color: var(--success); }

/* --- Empty state --------------------------------------------------------- */
.empty { padding: 34px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-glyph { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); }
.empty p { font-size: var(--t-sm); color: var(--text-2); max-width: 34ch; }

/* --- Steps / timeline ---------------------------------------------------- */
.steps { display: flex; gap: 6px; }
.step-seg { flex: 1; height: 3px; border-radius: 2px; background: var(--border); }
.step-seg[data-on="1"] { background: var(--primary); }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item::before { content: ''; position: absolute; left: 10px; top: 20px; bottom: 0; width: 1px; background: var(--border); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); z-index: 1; }
.tl-dot.on { background: var(--primary); color: var(--text-inv); }

/* --- Modal / sheet ------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: 80;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  animation: fade .16s var(--ease);
}
@keyframes fade { from { opacity: 0 } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  width: min(520px, 100%);
  max-height: 88dvh; overflow-y: auto;
  animation: pop .2s var(--ease);
}
@keyframes pop { from { transform: translateY(10px) scale(.99); opacity: .6 } }
@media (max-width: 560px) {
  .scrim { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 90dvh; }
}

/* --- Toast --------------------------------------------------------------- */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 95;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--text); color: var(--bg);
  padding: 10px 13px;
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  box-shadow: var(--sh-3);
  animation: pop .18s var(--ease);
}
.toast.warn { background: var(--warn); color: #fff; }
.toast.err  { background: var(--danger); color: #fff; }
@media (max-width: 560px) { .toasts { left: 16px; right: 16px; bottom: 84px; max-width: none; } }

/* --- Media ---------------------------------------------------------------
   Photography is documentary here: real Nigerian markets, traders, transport
   and kitchens, because the product is about what those things cost. It is
   never decorative filler, and every image is credited in assets/img.
   A neutral placeholder colour holds the box before the file decodes, so the
   layout never jumps. */
.media {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-card);
  background: var(--surface-3);
}
.media > img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.media-16x9 { aspect-ratio: 16 / 9; }
.media-4x3  { aspect-ratio: 4 / 3; }
.media-3x2  { aspect-ratio: 3 / 2; }
.media-1x1  { aspect-ratio: 1 / 1; }

/* A caption sitting on the image, for provenance or a data point. */
.media-tag {
  position: absolute; left: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  background: rgba(9, 14, 22, .78);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: var(--t-xs); font-weight: 500;
}
.media-tag .mono { color: #fff; }

/* Darkens the lower half so overlaid type stays legible on any photograph. */
.media-scrim::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 34%, rgba(9, 14, 22, .72) 100%);
  pointer-events: none;
}

figure.photo { display: flex; flex-direction: column; gap: 9px; }
figure.photo figcaption { font-size: var(--t-xs); color: var(--text-3); line-height: 1.45; }

/* --- Dropzone ------------------------------------------------------------ */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 30px 18px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-card);
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--fast), background var(--fast);
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-ic {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--primary);
}
.dropzone-t { font-size: var(--t-sm); font-weight: 600; }
.dropzone-s { font-size: var(--t-xs); color: var(--text-3); }

/* --- Month timeline ------------------------------------------------------
   A month drawn to scale with payday marked, so "the rent leaves three weeks
   before you are paid" is something you SEE rather than something you work
   out from two dates in a table. */
.timeline-month { display: flex; flex-direction: column; gap: 6px; }
.tl-track {
  position: relative;
  height: 34px;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border);
}
.tl-mark {
  position: absolute; top: 6px; bottom: 6px;
  width: 4px; margin-left: -2px;
  border-radius: 2px;
  background: var(--text-3);
}
.tl-mark.risk { background: var(--danger); top: 3px; bottom: 3px; width: 5px; }
.tl-pay {
  position: absolute; top: -3px; bottom: -3px;
  width: 3px; margin-left: -1px;
  border-radius: 2px;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent);
}
.tl-scale {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: var(--t-xs); color: var(--text-3);
}

/* --- Page intro ----------------------------------------------------------
   Every screen says what it is for. A console page especially: an operator
   landing on "Coverage" for the first time should not have to infer the job
   from the charts. */
.page-intro {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface-2);
}
.page-intro-ic {
  width: 30px; height: 30px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-ink);
}
.page-intro-b { min-width: 0; }
.page-intro-t { font-size: var(--t-sm); font-weight: 600; margin-bottom: 2px; }
.page-intro-d { font-size: var(--t-sm); color: var(--text-2); line-height: 1.5; }
.page-intro-d b, .page-intro-d strong { color: var(--text); font-weight: 600; }
.page-intro.accent .page-intro-ic { background: var(--accent-soft); color: var(--accent-ink); }

/* --- Datatable ----------------------------------------------------------- */
.dt { display: flex; flex-direction: column; }

.dt-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.dt-search { flex: 1 1 220px; max-width: 320px; }
.dt-search .input { height: 34px; padding-top: 5px; padding-bottom: 5px; }
.dt-count { font-size: var(--t-xs); color: var(--text-2); white-space: nowrap; }
.dt-count b { font-family: var(--mono); color: var(--text); }
.dt-size { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.dt-size .select { width: auto; height: 34px; padding: 4px 30px 4px 10px; font-size: var(--t-sm); }

.dt-scroll { max-height: 62vh; overflow-y: auto; }
.dt-table thead th { z-index: 2; }
.dt-sortable { cursor: pointer; user-select: none; }
.dt-sortable:hover { color: var(--text); background: var(--surface-3); }
.dt-sortable:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.dt-th { display: inline-flex; align-items: center; gap: 5px; }
.num .dt-th { flex-direction: row-reverse; }
.dt-arrow { opacity: 0; font-size: 10px; transition: opacity var(--fast); }
.dt-sortable:hover .dt-arrow { opacity: .45; }
.dt-arrow.on { opacity: 1; color: var(--primary); }

.dt-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.dt-pager { display: flex; gap: 4px; flex-wrap: wrap; }
.dt-pager .btn { min-width: 30px; padding: 5px 8px; }
.dt-pager .btn[disabled] { opacity: .35; }

@media (max-width: 620px) {
  .dt-size { margin-left: 0; }
  .dt-count { order: 3; width: 100%; }
}

/* --- Misc ---------------------------------------------------------------- */
.kbd {
  font-family: var(--mono); font-size: var(--t-xs);
  padding: 1px 5px; border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: var(--r-xs);
  background: var(--surface-2); color: var(--text-2);
}
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.sep { color: var(--text-3); opacity: .6; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-x::-webkit-scrollbar { height: 6px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* --- Ask MoneyPilot ------------------------------------------------------
   The person's own question, right-aligned so a thread reads as a
   conversation. Answers use the standard .insight card, because an answer
   from the engine IS an insight and should not look like a different
   species of statement. */
.ask-you {
  display: flex;
  justify-content: flex-end;
}
.ask-you > span {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: var(--r-lg) var(--r-lg) var(--r-xs) var(--r-lg);
  background: var(--primary);
  color: var(--text-inv);
  font-size: var(--t-sm);
  line-height: 1.5;
}

/* --- Guided tour ---------------------------------------------------------
   A docked bar rather than floating coach marks: it never covers the thing
   it is describing, it survives page navigation, and it reads the same on a
   phone frame as on the desktop console. */
.tour-bar {
  position: fixed; z-index: 120;
  left: 50%; transform: translateX(-50%);
  bottom: 16px;
  width: min(720px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  animation: tour-in .22s var(--ease);
}
@keyframes tour-in { from { transform: translate(-50%, 10px); opacity: 0 } }

.tour-dots { display: flex; flex-direction: column; gap: 4px; }
.tour-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--border-strong); }
.tour-dots span.done { background: var(--primary-line); }
.tour-dots span.on { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.tour-copy { min-width: 0; }
.tour-step { font-family: var(--mono); font-size: var(--t-xs); letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.tour-title { font-size: var(--t-md); font-weight: 600; letter-spacing: -.012em; margin-top: 2px; }
.tour-body { font-size: var(--t-sm); color: var(--text-2); line-height: 1.5; margin-top: 3px; }
.tour-acts { display: flex; gap: 6px; align-items: center; }

@media (max-width: 620px) {
  .tour-bar { grid-template-columns: 1fr; gap: 10px; bottom: 8px; padding: 12px 14px; }
  .tour-dots { flex-direction: row; }
  .tour-acts { justify-content: flex-end; }
}

/* What the current step is talking about. */
.tour-spot {
  position: relative;
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
  animation: tour-pulse 1.6s ease-in-out 2;
}
@keyframes tour-pulse {
  0%, 100% { outline-color: var(--accent); }
  50%      { outline-color: color-mix(in srgb, var(--accent) 30%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .tour-bar, .tour-spot { animation: none; }
}

/* Compact provenance — one line, clipped.

   The wrapping variant above is right under a heading, where it has the full
   card width. Inside a list row it is sharing ~150px with a name, a sparkline,
   a price and a button, and wrapping turned "8 reports · Lagos Mainland · 3d
   ago" into four stacked lines that pushed the row to triple height. */
.prov-1 {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prov-1 > span { display: inline; }

/* Donut — server-rendered, so it needs no sizing from script. */
.donut { display: block; flex: none; }
.donut circle { transition: opacity var(--fast); }
.donut:hover circle { opacity: .82; }
.donut circle:hover { opacity: 1; }

/* --- Dashboard hero, short-month branch ----------------------------------
   A member whose month does not balance still has to get through today. The
   shortfall is the headline; this is the figure underneath it that can
   actually be acted on, set apart so the two are never misread as one number.
   Quiet by construction — it must not compete with the red figure above. */
.hero-split {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.hero-split-fig {
  font-family: var(--mono);
  font-size: var(--t-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.hero-split-fig span {
  font-size: var(--t-sm); font-weight: 400; color: var(--text-3); margin-left: 2px;
}

/* ==========================================================================
   The ledger — components for the classic half of the look
   ========================================================================== */

/* --- Headline figure -----------------------------------------------------
   The one number a screen exists to give. Set in the serif, large, the way a
   statement sets its closing balance — and with lining tabular numerals so it
   never jitters as it counts up. */
.ledger-hero { position: relative; overflow: hidden; isolation: isolate; }
.ledger-hero > .card-body { position: relative; z-index: 1; }
.hero-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--t-xs); font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-3);
}
.hero-fig {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(46px, 11vw, 70px);
  line-height: .95;
  letter-spacing: -.025em;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--text);
}
.hero-fig small {
  font-family: var(--font);
  font-size: var(--t-md); font-weight: 500;
  letter-spacing: 0;
  color: var(--text-3);
  margin-left: 6px;
}
.hero-fig.crit { color: var(--danger); }
.hero-line { font-size: var(--t-sm); color: var(--text-2); line-height: 1.55; max-width: 56ch; }
.hero-line b { color: var(--text); font-weight: 600; }

/* --- Banknote rosette ----------------------------------------------------
   The guilloche engraving on every naira note: interlaced waves braided
   around a medallion, the pattern a rose engine cuts. One faint rosette sits
   in the corner behind a headline figure, felt rather than read. Decoration
   with a single job — to say "money" — and never repeated as wallpaper.

   Painted through a mask so it takes `color` like an icon: currentColor
   fills the box, and the SVG decides where it shows. */
.guilloche {
  position: absolute; z-index: 0;
  /* Centred just inside the corner, so the card shows a quarter of the
     rosette — a corner ornament, clear of the figure and the stamp. */
  right: -150px; top: -150px;
  width: 330px; height: 330px;
  color: var(--primary);
  background-color: currentColor;
  opacity: .16;
  pointer-events: none;
  -webkit-mask: url('../img/guilloche.svg') center / contain no-repeat;
          mask: url('../img/guilloche.svg') center / contain no-repeat;
}
.guilloche.crit { color: var(--danger); opacity: .13; }
:root[data-theme="dark"] .guilloche { opacity: .22; }
@media (max-width: 560px) {
  .guilloche { width: 260px; height: 260px; right: -122px; top: -122px; }
}
/* A positioned ornament paints over in-flow siblings, so the footer is lifted
   above it: the engraving belongs to the figure, not to the pace readings. */
.ledger-hero > .card-foot { position: relative; z-index: 1; }

/* --- Pace ---------------------------------------------------------------
   Two readings on one 0–100% axis, labels left, values right in the ledger
   face. The comparison is the message. */
.pace { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto; gap: 10px 14px; align-items: center; }
.pace-k { font-size: var(--t-xs); color: var(--text-2); white-space: nowrap; }
.pace-v { font-family: var(--mono); font-size: var(--t-xs); font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.pace .bar { height: 6px; }

/* --- Leader rows ---------------------------------------------------------
   Label ··········· value. The dotted leader of a printed price list or a
   table of contents: it carries the eye across the gap so a label and its
   figure are read as one line, without a table's grid. */
.leaders { display: flex; flex-direction: column; gap: 9px; }
.leader { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: var(--t-sm); }
.leader-k { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.leader-dots {
  flex: 1 1 auto; min-width: 14px;
  border-bottom: 1.5px dotted var(--border-strong);
  transform: translateY(-4px);
}
.leader-v { flex: none; font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }

/* --- Stamp ---------------------------------------------------------------
   A rubber stamp for a verdict — "Balances", "Short" — because a verdict on a
   month is a different kind of thing from a label on a line. Slightly
   rotated, like one pressed by hand. Label and colour, never colour alone. */
.stamp {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px 3px;
  border: 1.5px solid currentColor;
  border-radius: var(--r-xs);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
  transform: rotate(-2.5deg);
  background: color-mix(in srgb, currentColor 7%, transparent);
}
.stamp.good { color: var(--success); }
.stamp.warn { color: var(--warn); }
.stamp.crit { color: var(--danger); }
.stamp.info { color: var(--primary); }

/* --- Figures in the ledger voice ----------------------------------------- */
.phone-body .stat { padding: 16px 17px; gap: 10px; }
.phone-body .stat-value {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 27px;
  letter-spacing: -.02em;
  font-variant-numeric: lining-nums tabular-nums;
}
.phone-body .stat-ic { width: 28px; height: 28px; border-radius: 50%; }

/* --- Bars fill on arrival ------------------------------------------------
   A fill that grows from nothing reads as a measurement being taken. It runs
   when a bar is first inserted; a Livewire morph keeps the element, so an
   update animates only through the width transition above. */
@media (prefers-reduced-motion: no-preference) {
  .bar > span { animation: bar-in .9s var(--ease) both; transform-origin: left center; }
}
@keyframes bar-in { from { transform: scaleX(0); } }

/* --- Quick link tiles (phone posture) ------------------------------------ */
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.quick-link {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 13px 13px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--text);
  font-size: var(--t-sm); font-weight: 500;
  box-shadow: var(--sh-1);
  transition: border-color var(--fast), transform var(--fast);
}
.quick-link:hover { border-color: var(--border-strong); text-decoration: none; }
.quick-link:active { transform: scale(.98); }
.quick-link .i { color: var(--primary); }
:root[data-theme="dark"] .quick-link { box-shadow: none; }

/* --- Call to contribute --------------------------------------------------- */
.cta-card {
  display: flex; align-items: center; gap: 14px;
  padding: 18px;
  border-radius: var(--r-card);
  background: var(--primary); color: var(--text-inv);
  position: relative; overflow: hidden; isolation: isolate;
}
.cta-card:hover { text-decoration: none; background: var(--primary-hover); }
/* In the dark theme --primary is a light ink blue, which would make this a
   pale block on a dark page. It stays a deep navy panel with light type. */
:root[data-theme="dark"] .cta-card {
  background: var(--primary-soft); color: var(--text);
  border: 1px solid var(--primary-line);
}
:root[data-theme="dark"] .cta-card:hover { background: color-mix(in srgb, var(--primary-soft) 80%, var(--primary)); }
:root[data-theme="dark"] .cta-card .guilloche { color: var(--primary); opacity: .22; }
:root[data-theme="dark"] .cta-card-ic { background: color-mix(in srgb, var(--primary) 20%, transparent); color: var(--primary-ink); }
.cta-card .guilloche {
  color: var(--text-inv); opacity: .14;
  width: 240px; height: 240px;
  top: 50%; right: -96px;
  transform: translateY(-50%);
}
.cta-card-t { display: block; font-family: var(--serif); font-size: var(--t-md); font-weight: 500; }
.cta-card-s { display: block; font-size: var(--t-xs); opacity: .8; margin-top: 2px; }
.cta-card-ic {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--text-inv) 14%, transparent);
}
