@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400..700;1,9..144,400..600&family=Hanken+Grotesk:wght@400;500;600;700;800&display=swap');

/* ============================================================================
   Hamyon — "Private Statement" design system
   An editorial-fintech ledger: warm ink-on-paper, a single gilt accent, a
   high-contrast display serif (Fraunces) for figures + a grotesque (Hanken)
   for chrome. Dark-first with a light "paper ledger" theme.

   Chart series colors (--s1..--s8, --seq-*) are the CVD-validated categorical
   palette wired into charts.js (DARK_STEP) — never repurposed for chrome and
   never changed here.
   ========================================================================== */

:root, html[data-theme="dark"] {
  color-scheme: dark;

  --page:        #100f0c;
  --page-2:      #0a0906;
  --card:        #1a1714;
  --card-2:      #211d18;
  --elevated:    #262119;
  --inset:       #141210;
  --hairline:        rgba(241, 233, 214, 0.085);
  --hairline-strong: rgba(241, 233, 214, 0.16);
  --rule:            rgba(241, 233, 214, 0.11);

  --ink:         #f4efe3;
  --ink-2:       #c4bdac;
  --ink-3:       #8b8474;
  --ink-4:       #625d51;

  --accent:      #dcae37;            /* gilt */
  --accent-2:    #f2d485;            /* bright gilt (gradients) */
  --accent-ink:  #1b1405;
  --accent-soft: rgba(220, 174, 55, 0.13);
  --accent-line: rgba(220, 174, 55, 0.32);

  --good:        #37bd7d;
  --good-soft:   rgba(55, 189, 125, 0.13);
  --bad:         #e86d6d;
  --bad-soft:    rgba(232, 109, 109, 0.13);
  --warn:        #f0b429;
  --warn-soft:   rgba(240, 180, 41, 0.14);
  --serious:     #ec835a;
  --info:        #6ea9ec;
  --info-soft:   rgba(110, 169, 236, 0.13);

  --grid:        #2c2e2a;
  --axis:        #3a3c37;

  /* chart series (dark steps, validated on --card) — DO NOT CHANGE */
  --s1: #3987e5; --s2: #199e70; --s3: #c98500; --s4: #008300;
  --s5: #9085e9; --s6: #e66767; --s7: #d55181; --s8: #d95926;
  --seq-lo: #184f95; --seq-hi: #86b6ef;
  /* spend-intensity heat ramp (near-zero → hottest day), tuned for the dark surface */
  --heat-1: #46331a; --heat-2: #71491b; --heat-3: #ab6a24; --heat-4: #dd8a34; --heat-5: #f2833f;

  --shadow-1: inset 0 1px 0 rgba(255,249,235,.035), 0 1px 2px rgba(0,0,0,.5), 0 12px 30px -18px rgba(0,0,0,.72);
  --shadow-2: inset 0 1px 0 rgba(255,249,235,.045), 0 4px 16px rgba(0,0,0,.5), 0 34px 64px -28px rgba(0,0,0,.78);
  --shadow-pop: 0 10px 40px -8px rgba(0,0,0,.6);

  --font-display: "Fraunces", "New York", ui-serif, Georgia, "Times New Roman", serif;
  --font-sans:    "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    ui-monospace, "SF Mono", "Menlo", Consolas, monospace;
}

html[data-theme="light"] {
  color-scheme: light;

  --page:        #f3f0e7;
  --page-2:      #ebe7db;
  --card:        #fdfcf8;
  --card-2:      #f8f6ee;
  --elevated:    #ffffff;
  --inset:       #efece1;
  --hairline:        rgba(38, 32, 16, 0.10);
  --hairline-strong: rgba(38, 32, 16, 0.17);
  --rule:            rgba(38, 32, 16, 0.13);

  --ink:         #1c1a12;
  --ink-2:       #55503f;
  --ink-3:       #8a8472;
  --ink-4:       #b0aa97;

  --accent:      #9a7413;
  --accent-2:    #caa03a;
  --accent-ink:  #fffdf4;
  --accent-soft: rgba(154, 116, 19, 0.11);
  --accent-line: rgba(154, 116, 19, 0.30);

  --good:        #0a7d45;
  --good-soft:   rgba(10, 125, 69, 0.10);
  --bad:         #c03535;
  --bad-soft:    rgba(192, 53, 53, 0.09);
  --warn:        #97650a;
  --warn-soft:   rgba(240, 180, 41, 0.18);
  --serious:     #b4552e;
  --info:        #2a78d6;
  --info-soft:   rgba(42, 120, 214, 0.09);

  --grid:        #e4e1d5;
  --axis:        #c9c5b6;

  /* chart series (light steps, validated on --card) — DO NOT CHANGE */
  --s1: #2a78d6; --s2: #1baf7a; --s3: #eda100; --s4: #008300;
  --s5: #4a3aa7; --s6: #e34948; --s7: #e87ba4; --s8: #eb6834;
  --seq-lo: #cde2fb; --seq-hi: #1c5cab;
  /* spend-intensity heat ramp (near-zero → hottest day), tuned for the light surface */
  --heat-1: #f7e5c0; --heat-2: #f2c774; --heat-3: #e79a3f; --heat-4: #d76a2c; --heat-5: #b23a24;

  --shadow-1: 0 1px 2px rgba(40,34,16,.05), 0 10px 24px -14px rgba(40,34,16,.16);
  --shadow-2: 0 2px 10px rgba(40,34,16,.07), 0 26px 50px -24px rgba(40,34,16,.22);
  --shadow-pop: 0 12px 40px -8px rgba(40,34,16,.24);
}

/* ---------------------------------------------------------------- base --- */

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01" 1;
}

/* atmosphere: warm gilt aura + a faint engraved guilloché, banknote-style */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1100px 520px at 16% -12%, var(--accent-soft), transparent 58%),
    radial-gradient(880px 460px at 98% -4%, color-mix(in srgb, var(--good) 6%, transparent), transparent 55%),
    radial-gradient(1200px 800px at 50% 120%, var(--page-2), transparent 60%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image: repeating-radial-gradient(circle at 115% -10%,
      transparent 0 62px, color-mix(in srgb, var(--accent) 3%, transparent) 62px 63px);
}

.serif { font-family: var(--font-display); letter-spacing: -0.012em; font-optical-sizing: auto; }

.num, .money, td.money {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.num-serif, .kpi-value {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.015em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; }

::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ----------------------------------------------------------- app shell --- */

.shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: 244px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--hairline);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card) 55%, var(--page)), color-mix(in srgb, var(--page-2) 60%, var(--page)));
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar::after { /* gilt spine */
  content: ""; position: absolute; top: 0; right: -1px; width: 1px; height: 100%;
  background: linear-gradient(180deg, transparent, var(--accent-line) 22%, transparent 60%);
}

.wordmark { display: flex; align-items: baseline; gap: 9px; padding: 6px 10px 20px; color: var(--ink); }
.wordmark:hover { text-decoration: none; }
.wordmark .mark { font-family: var(--font-display); font-size: 25px; font-weight: 600; letter-spacing: -0.01em; }
.wordmark .mark em { font-style: normal; color: var(--accent); }
.wordmark .tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.24em;
  color: var(--ink-3); font-weight: 700;
}

.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 550; font-size: 14.5px;
  border: 1px solid transparent;
  position: relative;
  transition: background .16s ease, color .16s ease;
}
.nav-link:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--ink); }
.nav-link.active::before {
  content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-link .nav-ico { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); flex: 0 0 auto; }
.nav-link.active .nav-ico, .nav-link:hover .nav-ico { color: var(--accent); }
.nav-link .nav-ico svg { width: 18px; height: 18px; }

.nav-sep { font-size: 10px; text-transform: uppercase; letter-spacing: .18em; color: var(--ink-4); font-weight: 700; padding: 16px 12px 6px; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--hairline); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; flex-direction: column; padding: 0 10px; min-width: 0; }
.user-chip .name { font-weight: 650; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .mail { color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 32px 14px;
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  border-bottom: 1px solid var(--hairline);
}
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.page-title .crumb { color: var(--ink-3); font-weight: 500; font-family: var(--font-sans); font-size: 13px; letter-spacing: 0; }
.topbar-spacer { flex: 1; }

.content { padding: 26px 32px 64px; display: flex; flex-direction: column; max-width: 1600px; width: 100%; margin: 0 auto; }
/* The routed page fragment (#dash, #tx-page, #settings, #analytics) is the SINGLE child of
   .content, so a gap on .content separates nothing. Make the fragment itself the flex column
   so the vertical rhythm actually applies between the sections inside it. */
.content > * { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* --------------------------------------------------------- components --- */

.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  box-shadow: var(--shadow-1);
  padding: 20px 22px;
  min-width: 0;
}
.card > h2, .card-title {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--ink-3); font-weight: 700;
  margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}
.card-title .hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink-3); }

/* section label — a clean underlined header (no separate rule element) */
.section-head { display: flex; align-items: baseline; gap: 12px; margin: 10px 0 0; padding-bottom: 11px; border-bottom: 1px solid var(--hairline); }
.section-head .lbl { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.section-head .sub { color: var(--ink-3); font-size: 12.5px; }
.section-head .grow { flex: 1; }
.rule { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--hairline-strong);
  background: var(--card-2);
  color: var(--ink); font-family: var(--font-sans); font-weight: 600; font-size: 13.5px;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent) 8%, var(--card-2)); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: color-mix(in srgb, var(--accent) 70%, #000);
  color: var(--accent-ink); font-weight: 700;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 6px 18px -8px color-mix(in srgb, var(--accent) 60%, transparent);
}
.btn.primary:hover { filter: brightness(1.04); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: transparent; }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { padding: 13px 24px; font-size: 15px; border-radius: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--hairline); background: transparent;
  color: var(--ink-2); cursor: pointer; font-size: 15px;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.icon-btn:hover { border-color: var(--accent-line); color: var(--ink); background: var(--accent-soft); }

input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="date"], input[type="month"], input[type="number"], input[type="search"], select, textarea {
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--inset);
  border: 1px solid var(--hairline-strong);
  border-radius: 10px; padding: 9px 12px; min-width: 0;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; font-family: var(--font-mono); font-size: 13px; }
label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .error { color: var(--bad); font-size: 12.5px; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--inset); border: 1px solid var(--hairline);
  border-radius: 11px; flex-wrap: wrap;
}
.seg a {
  padding: 6px 12px; border-radius: 8px;
  color: var(--ink-2); font-size: 13px; font-weight: 550; white-space: nowrap;
  transition: color .12s ease, background .12s ease;
}
.seg a:hover { color: var(--ink); text-decoration: none; }
.seg a.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1); font-weight: 650; }

/* "Custom" period entry: a segment-styled button + a small anchored panel with two date
   inputs. The panel is absolutely positioned off the button so it never reflows the bar. */
.custom-period { position: relative; display: inline-flex; z-index: 70; }
.custom-period > button {
  padding: 6px 12px; border-radius: 8px; border: 0; background: transparent; cursor: pointer;
  color: var(--ink-2); font-size: 13px; font-weight: 550; white-space: nowrap; font-family: inherit;
  transition: color .12s ease, background .12s ease;
}
.custom-period > button:hover { color: var(--ink); }
.custom-period > button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1); font-weight: 650; font-variant-numeric: tabular-nums; }
.cp-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  display: flex; flex-direction: column; gap: 10px;
  min-width: 250px; padding: 14px;
  background: var(--card); border: 1px solid var(--hairline-strong);
  border-radius: 12px; box-shadow: var(--shadow-2);
}
.cp-panel .cp-dates { display: flex; gap: 10px; }
.cp-panel label { display: flex; flex-direction: column; gap: 5px; flex: 1 1 0; min-width: 0; }
.cp-panel input[type="date"] { width: 100%; box-sizing: border-box; font-size: 13px; padding: 7px 9px; }
.cp-panel .error { margin: 0; color: var(--bad); font-size: 12.5px; }

/* Month report card: the in-progress month reads visually provisional. */
.monthcard td, .monthcard th { white-space: nowrap; }
.monthcard .current { opacity: .62; font-style: italic; }

/* Salary-cycle card: one meter per week of the payday→payday cycle. */
.cycle-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.cycle-row { display: grid; grid-template-columns: minmax(5.5rem, auto) minmax(60px, 1fr) minmax(8.5rem, auto);
             gap: 12px; align-items: center; }
.cycle-row .lbl { font-size: 12.5px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.cycle-row .bar { height: 12px; border-radius: 6px; background: var(--inset); overflow: hidden; }
.cycle-row .bar i { display: block; height: 100%; border-radius: 6px;
                    background: color-mix(in srgb, var(--accent) 75%, var(--card)); }
.cycle-row .val { text-align: right; font-size: 12.5px; color: var(--ink-2);
                  font-variant-numeric: tabular-nums; white-space: nowrap; }
.budget-row .bar i.warn { background: color-mix(in srgb, var(--warn) 80%, var(--card)); }
.budget-row .bar i.over { background: color-mix(in srgb, var(--bad) 80%, var(--card)); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; font-size: 12px; font-weight: 600;
  border-radius: 99px; border: 1px solid var(--hairline);
  background: var(--inset); color: var(--ink-2); white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: 0 0 auto; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 99px; white-space: nowrap;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: var(--inset); color: var(--ink-3); border: 1px solid var(--hairline); }
a.badge:hover { text-decoration: none; filter: brightness(1.08); }

.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle .track {
  width: 40px; height: 23px; border-radius: 99px;
  background: var(--inset); border: 1px solid var(--hairline-strong); transition: background .15s ease, border-color .15s ease;
}
.toggle .track::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--ink-3); transition: transform .2s cubic-bezier(.3,.8,.3,1), background .15s ease;
}
.toggle input:checked + .track { background: var(--accent-soft); border-color: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(17px); background: var(--accent); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------ dashboard masthead */

.masthead {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 32px; align-items: start;
  padding: 4px 2px 2px;
}
.eyebrow {
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent);
  font-weight: 700; display: flex; align-items: center; gap: 10px;
}
.eyebrow::before { content: ""; width: 26px; height: 1px; background: var(--accent-line); }
.eyebrow .dim { color: var(--ink-3); }

.hero-net { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.hero-fig { font-family: var(--font-display); font-optical-sizing: auto; font-variant-numeric: tabular-nums lining-nums;
  font-size: clamp(40px, 5.4vw, 66px); font-weight: 600; line-height: .95; letter-spacing: -0.022em; }
.hero-fig.pos { color: var(--good); }
.hero-fig.neg { color: var(--bad); }
.hero-unit { display: flex; flex-direction: column; gap: 2px; }
.hero-unit .ccy { font-family: var(--font-mono); font-size: 14px; color: var(--ink-2); font-weight: 600; }
.hero-unit .cap { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }

.flow { margin-top: 20px; max-width: 560px; }
.flow-bar {
  display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 2px;
  background: var(--inset); border: 1px solid var(--hairline);
}
.flow-bar i { display: block; height: 100%; }
.flow-bar i.in { background: linear-gradient(90deg, color-mix(in srgb, var(--good) 70%, transparent), var(--good)); border-radius: 99px 0 0 99px; }
.flow-bar i.out { background: linear-gradient(90deg, var(--serious), color-mix(in srgb, var(--serious) 70%, transparent)); border-radius: 0 99px 99px 0; }
.flow-legend { display: flex; gap: 22px; margin-top: 12px; flex-wrap: wrap; }
.flow-legend .fl { display: flex; align-items: baseline; gap: 8px; }
.flow-legend .k { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.flow-legend .k::before { content: ""; width: 9px; height: 9px; border-radius: 3px; }
.flow-legend .in .k::before { background: var(--good); }
.flow-legend .out .k::before { background: var(--serious); }
.flow-legend .v { font-family: var(--font-mono); font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }

.mast-controls { display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
                 position: relative; z-index: 70; }
.mast-controls .period-range { font-size: 12.5px; color: var(--ink-3); font-family: var(--font-mono); }

/* Card (account) filter — matches the .seg switcher's inset look */
.card-select {
  appearance: none; -webkit-appearance: none;
  padding: 7px 30px 7px 12px; border-radius: 10px;
  background: var(--inset); border: 1px solid var(--hairline);
  color: var(--ink); font-size: 13px; font-weight: 550; cursor: pointer;
  max-width: 220px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23888' stroke-width='1.4'><path d='M3 4.5 6 7.5 9 4.5'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
  transition: border-color .12s ease, color .12s ease;
}
.card-select:hover { border-color: var(--ink-3); }
.card-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --------------------------------------------------- accounts rail --- */

.acct-rail {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.acct {
  position: relative; overflow: hidden;
  border: 1px solid var(--hairline-strong); border-radius: 15px;
  background:
    linear-gradient(150deg, var(--card-2), var(--card) 62%),
    var(--card);
  box-shadow: var(--shadow-1);
  padding: 15px 17px 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.acct::before { /* card sheen */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120px 80px at 88% -10%, var(--accent-soft), transparent 70%);
}
.acct .brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.acct .name { font-size: 12px; font-weight: 650; color: var(--ink-2); letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct .glyph { width: 24px; height: 16px; border-radius: 3px; background: linear-gradient(135deg, var(--accent-2), var(--accent)); opacity: .85; flex: 0 0 auto; }
.acct .bal { font-family: var(--font-display); font-optical-sizing: auto; font-variant-numeric: tabular-nums; font-size: 21px; font-weight: 600; letter-spacing: -0.015em; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct .conv { font-size: 11.5px; color: var(--ink-3); font-family: var(--font-mono); }

/* -------------------------------------------------------- stat strip --- */

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat {
  background: var(--card); border: 1px solid var(--hairline); border-radius: 14px;
  box-shadow: var(--shadow-1); padding: 15px 18px; display: flex; flex-direction: column; gap: 5px; min-width: 0;
}
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat .v { font-family: var(--font-display); font-optical-sizing: auto; font-variant-numeric: tabular-nums;
  font-size: 25px; font-weight: 600; line-height: 1.1; letter-spacing: -0.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v.pos { color: var(--good); } .stat .v.neg { color: var(--bad); }
.stat .v.cat { font-size: 19px; display: flex; align-items: center; gap: 8px; }
.stat .s { font-size: 12px; color: var(--ink-3); }
.stat.link { transition: border-color .15s ease, transform .12s ease; }
.stat.link:hover { border-color: var(--accent-line); transform: translateY(-1px); text-decoration: none; }

/* legacy KPI grid (kept for compatibility, restyled) */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: var(--card); border: 1px solid var(--hairline); border-radius: 14px; box-shadow: var(--shadow-1);
  padding: 15px 18px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.kpi .kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); font-weight: 700;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi .kpi-value { font-size: 25px; font-weight: 600; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .kpi-value .ccy { font-size: 13px; color: var(--ink-3); font-weight: 500; font-family: var(--font-mono); }
.kpi .kpi-sub { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kpi-value.pos { color: var(--good); } .kpi-value.neg { color: var(--bad); }
.balance-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.balance-chip { display: flex; flex-direction: column; gap: 2px; padding: 12px 15px; border-radius: 12px; min-width: 0;
  background: var(--card); border: 1px solid var(--hairline); box-shadow: var(--shadow-1); }
.balance-chip .lbl { font-size: 11px; color: var(--ink-3); font-weight: 650; letter-spacing: .04em; }
.balance-chip .val { font-size: 15px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------- insights --- */

.insight-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: stretch; }
.insight {
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow-1);
  display: flex; gap: 13px; align-items: flex-start; min-width: 0;
}
.insight .ico {
  font-size: 16px; line-height: 1; width: 34px; height: 34px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 10px;
  background: var(--inset); border: 1px solid var(--hairline);
}
.insight.GOOD .ico  { background: var(--good-soft); border-color: transparent; }
.insight.INFO .ico  { background: var(--info-soft); border-color: transparent; }
.insight.WARN .ico  { background: var(--warn-soft); border-color: transparent; }
.insight.ALERT .ico { background: var(--bad-soft); border-color: transparent; }
.insight .t { font-weight: 650; font-size: 14px; line-height: 1.3; }
.insight .d { color: var(--ink-2); font-size: 12.5px; line-height: 1.5; margin-top: 3px; }
.insight.lead { background: linear-gradient(150deg, var(--card-2), var(--card) 72%); border-color: var(--hairline-strong); }

/* --------------------------------------------------------------- charts --- */

.charts-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.chart-card { grid-column: span 6; display: flex; flex-direction: column; }
.chart-card.wide { grid-column: span 12; }
.chart-card.third { grid-column: span 4; }
.chart-box { width: 100%; height: 300px; }
.chart-box.tall { height: 348px; }
.chart-box.short { height: 224px; }
@media (max-width: 1100px) { .chart-card, .chart-card.third { grid-column: span 12; } }

/* ---- spending calendar: a real month grid (rendered by charts.js renderCalendar) ---- */
.cal-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 22px 26px; }
.cal-month { min-width: 0; }
.cal-mh {
  font-family: var(--font-display); font-optical-sizing: auto;
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink-2); margin: 0 2px 10px;
}
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 5px; }
.cal-dow span { text-align: center; font-size: 9.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-4); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-blank { aspect-ratio: 1 / 1; }
.cal-day {
  aspect-ratio: 1 / 1; border-radius: 8px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  color: var(--ink-3); border: 1px solid transparent; text-decoration: none;
}
.cal-day .cal-n { font-size: 11px; font-weight: 650; line-height: 1; font-variant-numeric: tabular-nums; color: inherit; }
.cal-day .cal-amt {
  font-size: 8.5px; font-weight: 600; line-height: 1; font-family: var(--font-mono);
  color: inherit; opacity: .82; max-width: 92%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-day.zero { color: var(--ink-4); }
.cal-day.out { background: transparent; color: var(--ink-4); opacity: .4; }
a.cal-day { cursor: pointer; transition: transform .1s ease, box-shadow .1s ease, border-color .1s ease; }
a.cal-day:hover { transform: translateY(-1px); box-shadow: 0 5px 15px -5px rgba(0,0,0,.5); border-color: var(--hairline-strong); text-decoration: none; }
.cal-day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day.today.zero .cal-n, .cal-day.today.out .cal-n { color: var(--accent); opacity: 1; }

/* --------------------------------------------------------------- tables --- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); font-weight: 700; padding: 9px 11px;
  border-bottom: 1px solid var(--hairline-strong); white-space: nowrap;
}
table.data td { padding: 11px 11px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
table.data tbody tr { transition: background .1s ease; }
table.data tr:hover td { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
table.data tbody tr:last-child td { border-bottom: 0; }
td.money, th.money { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* `table.data th` (0,1,2) outranks a bare `th.money` (0,1,1), which silently left-aligned
   every numeric HEADER above its right-aligned cells. Match the table's own specificity. */
table.data th.money, table.data th.num { text-align: right; }
table.data td.num { text-align: right; white-space: nowrap; }
.money.pos { color: var(--good); font-weight: 650; }
.money.neg { color: var(--ink); }
.share-bar { height: 6px; border-radius: 3px; background: var(--inset); overflow: hidden; min-width: 72px; }
.share-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding-top: 14px; }
.pagination .info { color: var(--ink-3); font-size: 12.5px; margin-right: auto; }

/* ------------------------------------------------------------ tx table --- */

.tx-merchant { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tx-declined .tx-merchant, .tx-declined td.money { text-decoration: line-through; color: var(--ink-3); }
.tx-neutral td { color: var(--ink-3); }
td .cat-select { max-width: 190px; font-size: 12.5px; padding: 5px 9px; background: transparent; border-color: transparent; }
td .cat-select:hover { border-color: var(--hairline-strong); background: var(--inset); }
.comment-cell { color: var(--ink-2); font-size: 12.5px; max-width: 220px; }
.comment-cell .placeholder { color: var(--ink-3); opacity: .6; }
.auto-badge { font-size: 10px; vertical-align: super; color: var(--accent); cursor: help; }

/* sortable column headers */
table.data th .sort-th { color: inherit; text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
table.data th .sort-th:hover { color: var(--ink); }
.sort-ind { color: var(--accent); font-size: 9px; }

/* filtered totals bar */
.tx-totals { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; padding: 2px 2px 16px; }
.tx-totals .tt-count { color: var(--ink-3); font-size: 12.5px; margin-right: auto; }
.tx-totals .tt-item { font-size: 12.5px; color: var(--ink-3); }
.tx-totals .tt-k { text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; }
.tx-totals .tt-item b { color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 6px; font-weight: 650; }
.tx-totals .tt-item b.pos { color: var(--good); }

/* inline tag editor (datalist-backed: pick an existing tag or type a new one) */
.tag-cell { max-width: 160px; }
.tag-input { width: 100%; font-size: 12.5px; padding: 5px 8px; color: var(--ink-2);
  background: transparent; border: 1px solid transparent; border-radius: 7px; }
.tag-input::placeholder { color: var(--ink-4); }
.tag-input:hover, .tag-input:focus { border-color: var(--hairline-strong); background: var(--inset); outline: none; }

/* balance-info reclassification + original-message viewer */
.reclass { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; }
.dir-select { font-size: 11.5px; padding: 3px 8px; border-radius: 8px; border: 1px solid var(--hairline);
  background: var(--inset); color: var(--ink-2); max-width: 200px; cursor: pointer; }
.dir-select:hover { border-color: var(--hairline-strong); color: var(--ink); }
.raw-btn { border: none; background: transparent; cursor: pointer; font-size: 14px; line-height: 1;
  padding: 4px 7px; border-radius: 8px; opacity: .55; transition: opacity .12s ease, background .12s ease; }
.raw-btn:hover { opacity: 1; background: var(--inset); }
.raw-msg { white-space: pre-wrap; word-break: break-word; margin: 0; max-height: 340px; overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; line-height: 1.55;
  background: var(--inset); border: 1px solid var(--hairline); border-radius: 10px; padding: 14px 16px; color: var(--ink); }
.danger-zone { margin-top: 8px; padding: 14px 16px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); background: var(--bad-soft); }
.danger-zone .sub-h { margin-top: 0; }

.filter-bar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
/* Every filter is an equal-growing cell so wrapped rows stay aligned; search gets a bit more room. */
.filter-bar .field { flex: 1 1 160px; min-width: 0; }
.filter-bar .field.grow { flex: 2 1 220px; }
.filter-bar .field input, .filter-bar .field select { width: 100%; box-sizing: border-box; font-size: 13px; padding: 7px 10px; }
/* Actions sit on their own full-width row instead of being stranded after the fields. */
.filter-actions { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.banner {
  display: flex; align-items: center; gap: 11px;
  border: 1px solid color-mix(in srgb, var(--warn) 42%, transparent);
  background: var(--warn-soft); border-radius: 12px; padding: 12px 16px; font-size: 13.5px;
}
.banner .grow { flex: 1; }

/* ---------------------------------------------------- typical spending --- */

/* Rates inside a card: same reading rhythm as .stat, without a second card border
   around each tile. */
.rate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.rate { display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding: 12px 14px; border-radius: 12px; background: var(--inset); }
.rate .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-3); font-weight: 700; }
.rate .v { font-family: var(--font-display); font-optical-sizing: auto; font-variant-numeric: tabular-nums;
  font-size: 22px; font-weight: 600; line-height: 1.1; letter-spacing: -0.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate .s { font-size: 11.5px; color: var(--ink-3); }

.avg-skew { margin: 14px 0 0; padding: 10px 14px; border-radius: 11px; font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); background: var(--warn-soft); }

.avg-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 18px; margin-top: 16px; }
.fact { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 8px 0; }
.fact .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); font-weight: 700; }
.fact .v { font-size: 15px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fact .sub { font-size: 12px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.fact { border-radius: 10px; padding: 8px 10px; margin: 0 -10px;
  transition: background .12s ease; }
a.fact:hover { background: var(--inset); text-decoration: none; }

/* ------------------------------------------------------- capture health --- */

/* Name · freshness · counts. The middle column is the one being read, so it holds
   its width and the counts trail off to the right. */
.health-rows { display: flex; flex-direction: column; gap: 2px; }
.health-row {
  display: grid; grid-template-columns: minmax(7rem, auto) minmax(6.5rem, auto) 1fr;
  gap: 12px; align-items: baseline; padding: 7px 10px; border-radius: 9px; font-size: 13.5px;
}
.health-row:nth-child(odd) { background: var(--inset); }
.health-row .badge { margin-right: 5px; }

.recent { border: 1px solid var(--hairline); border-radius: 11px; padding: 10px 13px; }
.recent summary { cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.recent-row {
  display: grid; grid-template-columns: minmax(6.5rem, auto) minmax(5.5rem, auto) auto 1fr;
  gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--hairline);
}
.recent-row:first-of-type { margin-top: 8px; }
/* The preview is one line of a bank alert — never let it push the row wide. */
.recent-row > :last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- modal --- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, var(--page-2) 74%, transparent);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .18s ease;
}
.modal {
  width: 100%; max-width: 580px; background: var(--elevated);
  border: 1px solid var(--hairline-strong); border-radius: 18px; box-shadow: var(--shadow-2);
  padding: 22px 24px; display: flex; flex-direction: column; gap: 15px; max-height: 90vh; overflow-y: auto;
  animation: pop .2s cubic-bezier(.2,.8,.2,1);
}
.modal h3 { font-size: 19px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------------------------------------------------------------- toast --- */

#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--elevated); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--hairline-strong));
  border-radius: 12px; box-shadow: var(--shadow-2);
  padding: 12px 16px; font-size: 13.5px; max-width: 360px; animation: toast-in .22s ease;
}
.toast.ok { border-color: color-mix(in srgb, var(--good) 45%, var(--hairline-strong)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ----------------------------------------------------------- empty state --- */

.empty { text-align: center; padding: 60px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .big { font-size: 46px; }
.empty h2 { font-size: 25px; font-family: var(--font-display); }
.empty p { color: var(--ink-2); max-width: 500px; margin: 0; }
.checklist { margin: 20px auto 0; text-align: left; display: flex; flex-direction: column; gap: 11px; max-width: 480px; width: 100%; }
.checklist a.step {
  display: flex; gap: 14px; align-items: center; border: 1px solid var(--hairline);
  background: var(--card); padding: 15px 18px; border-radius: 13px; color: var(--ink);
  transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.checklist a.step:hover { border-color: var(--accent-line); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-1); }
.checklist .n {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-family: var(--font-display); font-weight: 700; font-size: 15px;
}
.checklist .s-title { font-weight: 650; font-size: 14.5px; }
.checklist .s-sub { color: var(--ink-3); font-size: 12.5px; }

/* ---------------------------------------------------------------- auth --- */

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; position: relative; z-index: 1; }
.auth-card {
  width: 100%; max-width: 410px; background: var(--card);
  border: 1px solid var(--hairline-strong); border-radius: 20px; box-shadow: var(--shadow-2);
  padding: 34px 34px 28px; display: flex; flex-direction: column; gap: 17px;
}
.auth-card .wordmark { padding: 0 0 6px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-note { font-size: 13px; color: var(--ink-2); text-align: center; }

/* ------------------------------------------------------------- settings --- */

/* Multi-column flow (not grid): cards keep their natural height and pack tightly down each
   column, so a short card next to a tall one no longer leaves a gap or an over-stretched box. */
.settings-grid { column-count: 2; column-gap: 16px; max-width: 1180px; }
.settings-grid > .card { break-inside: avoid; width: 100%; margin: 0 0 16px; }
/* A wide card (e.g. a data table) spans both columns so its content isn't clipped. */
.settings-grid > .card.span-all { column-span: all; }
@media (max-width: 860px) { .settings-grid { column-count: 1; } }
.sub-section + .sub-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--hairline); }
.sub-h { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); font-weight: 700; margin: 0 0 12px; display: flex; align-items: baseline; gap: 8px; }
.sub-h .hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink-3); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .lbl { font-weight: 600; font-size: 13.5px; }
.setting-row .sub { color: var(--ink-3); font-size: 12px; }
.code-pill {
  font-family: var(--font-mono); background: var(--inset); border: 1px dashed var(--hairline-strong);
  border-radius: 9px; padding: 7px 13px; font-size: 15px; letter-spacing: .16em; color: var(--accent);
}
.wizard-status { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 13.5px; }
.wizard-status .pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.wizard-status.active .pulse { background: var(--good); animation: none; box-shadow: 0 0 0 4px var(--good-soft); }
.wizard-status.error .pulse { background: var(--bad); animation: none; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------------------------------------------------------- trust panel --- */

.trust { border: 1px solid var(--hairline); background: var(--inset); border-radius: 12px; padding: 13px 15px; }
.trust-h { font-size: 12.5px; font-weight: 700; margin-bottom: 9px; display: flex; align-items: center; gap: 7px; }
.trust-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.trust-list li { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; display: flex; gap: 9px; }
.trust-list li::before { content: "✓"; color: var(--good); font-weight: 800; flex: 0 0 auto; }
.trust-list li.no::before { content: "!"; color: var(--warn); font-weight: 800; width: 12px; text-align: center; }
.consent { display: flex; align-items: flex-start; gap: 9px; font-weight: 400; cursor: pointer;
  font-size: 12.5px; color: var(--ink-2); line-height: 1.5;
  border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; }
.consent input { margin-top: 2px; flex: 0 0 auto; }

/* -------------------------------------------------------------- report --- */

.report-md { line-height: 1.7; font-size: 14.5px; max-width: 860px; }
.report-md h1, .report-md h2, .report-md h3, .report-md h4 { font-family: var(--font-display); margin: 22px 0 8px; font-weight: 600; letter-spacing: -0.01em; }
.report-md h2 { font-size: 23px; } .report-md h3 { font-size: 18px; }
.report-md p { margin: 9px 0; }
.report-md li { margin: 5px 0; }
.report-md code { font-family: var(--font-mono); font-size: .9em; background: var(--inset); padding: 1px 6px; border-radius: 6px; }
.report-md hr { border: 0; border-top: 1px solid var(--hairline); margin: 20px 0; }
.report-md strong { color: var(--ink); font-weight: 700; }

/* -------------------------------------------------------------- tabs --- */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--hairline); flex-wrap: wrap; }
.tabs a {
  padding: 10px 16px 11px; color: var(--ink-3); font-weight: 600; font-size: 13.5px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s ease;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------ subscriptions */

.subs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(248px, 1fr)); gap: 16px; }
.sub-card { background: var(--card); border: 1px solid var(--hairline); border-radius: 14px; box-shadow: var(--shadow-1);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 7px; }
.sub-card .m { font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-card .amt { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: 21px; font-weight: 600; }
.sub-card .meta { color: var(--ink-3); font-size: 12px; display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }

/* -------------------------------------------------------------- motion --- */

.reveal { animation: rise .55s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 45ms); }
/* `rise` animates transform, which makes every .reveal its own stacking context — so a later
   sibling (the account rail) paints ABOVE an earlier one (the masthead) no matter what z-index
   its children carry. Any block that opens a floating panel must outrank the blocks below it. */
.masthead, .picker-layer { position: relative; z-index: 20; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.htmx-indicator { opacity: 0; transition: opacity .15s ease; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--hairline-strong);
  border-top-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ------------------------------------------------------------ responsive --- */

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: sticky; top: 0; z-index: 40; width: 100%; height: auto;
    flex-direction: row; align-items: center; gap: 2px; padding: 10px 14px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--hairline);
    background: color-mix(in srgb, var(--page) 90%, var(--card));
    backdrop-filter: blur(8px);
  }
  .sidebar::after { display: none; }
  .wordmark { padding: 0 12px 0 4px; }
  .wordmark .tag { display: none; }
  .nav-sep { display: none; }
  .nav-link { padding: 8px 11px; white-space: nowrap; }
  .nav-link.active::before { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; align-items: center; }
  .user-chip { display: none; }
  .topbar { padding: 12px 18px 10px; }
  .content { padding: 18px 18px 44px; gap: 16px; }
  .masthead { grid-template-columns: 1fr; }
  .mast-controls { align-items: flex-start; }
  .chart-box { height: 260px; }
}

[x-cloak] { display: none !important; }

/* misc utilities */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.mt0 { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 11px; }
.hr { border: 0; border-top: 1px solid var(--hairline); margin: 6px 0; width: 100%; }

/* language switcher */
.lang-switch { display: flex; gap: 2px; padding: 4px; }
.lang-switch a {
  flex: 1; text-align: center; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  padding: 5px 0; border-radius: 7px; color: var(--ink-3); text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.lang-switch a:hover { color: var(--ink); background: var(--inset); }
.lang-switch a.active { color: var(--ink); background: var(--elevated); }
.auth-card .lang-switch { max-width: 190px; margin: 2px auto 6px; }

/* settings/admin card intro line */
.card-desc { color: var(--ink-3); font-size: 13px; line-height: 1.5; margin: -4px 0 15px; }

/* "how is this computed?" info icon + tooltip (used on chart/table/KPI/insight titles) */
.hint-ico {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 15px; height: 15px; margin-left: 7px; padding: 0; vertical-align: middle;
  border-radius: 50%; border: 1px solid var(--hairline-strong); background: transparent;
  color: var(--ink-3); font-size: 10px; font-weight: 700; font-style: normal;
  line-height: 1; text-transform: none; letter-spacing: 0; cursor: help;
  position: relative; user-select: none;
}
.hint-ico:hover, .hint-ico:focus, .hint-ico:focus-visible {
  color: var(--ink); border-color: var(--ink-3); outline: none;
}
.hint-ico::after {
  content: attr(data-hint);
  position: absolute; top: calc(100% + 9px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max-content; max-width: min(280px, 78vw); white-space: normal; text-align: left;
  font-size: 12px; font-weight: 400; font-style: normal; line-height: 1.5; letter-spacing: 0;
  color: var(--ink-2); background: var(--elevated);
  border: 1px solid var(--hairline-strong); border-radius: 10px; padding: 9px 11px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .32);
  opacity: 0; visibility: hidden; transition: opacity .14s ease, transform .14s ease;
  z-index: 60; pointer-events: none;
}
.hint-ico::before {
  content: ''; position: absolute; top: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-bottom-color: var(--elevated);
  opacity: 0; visibility: hidden; transition: opacity .14s ease; z-index: 61; pointer-events: none;
}
.hint-ico:hover::after, .hint-ico:focus::after, .hint-ico:focus-visible::after {
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}
.hint-ico:hover::before, .hint-ico:focus::before, .hint-ico:focus-visible::before {
  opacity: 1; visibility: visible;
}

/* A methodology tooltip overflows below its card. Without help, the NEXT card /
   rail in normal flow paints over it (the reported "cards overlap the popup").
   Cards don't clip it (overflow is visible) — the problem is paint order between
   sibling boxes. Lifting only the hovered card's stacking context fixes it, with
   no effect at rest. :has() is supported in every browser this app targets. */
.card, .insight, .stat, .kpi, .masthead, .section-head, .sub-card { position: relative; }
.card:has(.hint-ico:hover), .card:has(.hint-ico:focus-visible), .card:has(.hint-ico:focus),
.insight:has(.hint-ico:hover), .insight:has(.hint-ico:focus-visible), .insight:has(.hint-ico:focus),
.stat:has(.hint-ico:hover), .stat:has(.hint-ico:focus-visible), .stat:has(.hint-ico:focus),
.kpi:has(.hint-ico:hover), .kpi:has(.hint-ico:focus-visible), .kpi:has(.hint-ico:focus),
.masthead:has(.hint-ico:hover), .masthead:has(.hint-ico:focus-visible), .masthead:has(.hint-ico:focus),
.section-head:has(.hint-ico:hover), .section-head:has(.hint-ico:focus-visible), .section-head:has(.hint-ico:focus),
.sub-card:has(.hint-ico:hover), .sub-card:has(.hint-ico:focus-visible), .sub-card:has(.hint-ico:focus) {
  z-index: 45;
}
