@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;

  --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;

  --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; }

.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; }
.mast-controls .period-range { font-size: 12.5px; color: var(--ink-3); font-family: var(--font-mono); }

/* --------------------------------------------------- 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; } }

/* --------------------------------------------------------------- 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; }
.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; }

/* 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; }
.filter-bar .field { min-width: 0; }
.filter-bar .field input, .filter-bar .field select { font-size: 13px; padding: 7px 10px; }

.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; }

/* ---------------------------------------------------------------- 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 --- */

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; max-width: 1180px; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }
.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); }
@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%; }
