/* ---------- Tokens ----------
   One look in two modes: white with bright green, and a softened dark mode
   (charcoal instead of pure black, off-white text, calmer green and orange).
   Category colours are the validated chart palette (light / dark steps). */
:root {
  color-scheme: light;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Inter Tight", "Inter", system-ui, sans-serif;
  --display-weight: 700;
  --radius: 14px;
  --radius-sm: 12px;
  --tabbar-h: 64px;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f5f4;
  --surface-3: #eceeec;
  --panel: #ffffff;
  --border: #ececec;
  --border-strong: #dadada;
  --text: #0a0a0a;
  --text-2: #4b4b4b;
  --muted: #74777a;

  --accent: #00a106;
  --accent-ink: #ffffff;
  --accent-soft: #e5f8e6;
  --accent-btn: #00c805;
  --accent-btn-ink: #ffffff;
  --fab-shadow: 0 6px 20px rgba(0, 200, 5, 0.35);

  --up: #00a106;
  --down: #e64a00;
  --up-soft: rgba(0, 200, 5, 0.10);
  --down-soft: rgba(255, 80, 0, 0.10);
  --pill-up: #00c805;
  --pill-down: #ff5000;
  --pill-up-ink: #ffffff;
  --pill-down-ink: #ffffff;
  --chart-up: #00c805;
  --chart-down: #ff5000;

  --grid: #f1f1f1;
  --axis: #d4d4d4;
  --c-cash: #2a78d6;
  --c-bist: #eb6834;
  --c-us: #1baf7a;
  --c-gold: #eda100;
  --c-income: #2a78d6;
  --c-expense: #eb6834;

  --shadow: none;
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --toast-bg: #0a0a0a;
  --toast-ink: #ffffff;
  --toast-accent: #00e106;

  --ill-gold: #ffd23f;
  --ill-gold-2: #e6a100;
  --ill-gold-3: #fff3bd;
  --ill-accent: #00c805;
  --ill-accent-2: #7fe382;
  --ill-soft: #eafaeb;
  --ill-ink: #0f3f12;
  --ill-paper: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121417;
    --surface: #121417;
    --surface-2: #1a1d21;
    --surface-3: #23272c;
    --panel: #181b1f;
    --border: #23272b;
    --border-strong: #31363b;
    --text: #e6e8e9;
    --text-2: #b3b8bc;
    --muted: #868c92;
    --accent: #52c483;
    --accent-ink: #0c1a12;
    --accent-soft: rgba(82, 196, 131, 0.13);
    --accent-btn: #43b373;
    --accent-btn-ink: #0b1a11;
    --fab-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    --up: #52c483;
    --down: #ec8466;
    --up-soft: rgba(82, 196, 131, 0.12);
    --down-soft: rgba(236, 132, 102, 0.12);
    --pill-up: rgba(82, 196, 131, 0.16);
    --pill-down: rgba(236, 132, 102, 0.16);
    --pill-up-ink: #6fd29a;
    --pill-down-ink: #f29a80;
    --chart-up: #52c483;
    --chart-down: #ec8466;
    --grid: #1c1f22;
    --axis: #3a3f45;
    --c-cash: #3987e5;
    --c-bist: #d95926;
    --c-us: #199e70;
    --c-gold: #c98500;
    --c-income: #3987e5;
    --c-expense: #d95926;
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    --toast-bg: #262a2f;
    --toast-ink: #e6e8e9;
    --toast-accent: #6fd29a;
    --ill-gold: #e6c04e;
    --ill-gold-2: #b98a1c;
    --ill-gold-3: #f4e2a6;
    --ill-accent: #43b373;
    --ill-accent-2: #2d7a4f;
    --ill-soft: #182219;
    --ill-ink: #2b3035;
    --ill-paper: #1e2226;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121417;
  --surface: #121417;
  --surface-2: #1a1d21;
  --surface-3: #23272c;
  --panel: #181b1f;
  --border: #23272b;
  --border-strong: #31363b;
  --text: #e6e8e9;
  --text-2: #b3b8bc;
  --muted: #868c92;
  --accent: #52c483;
  --accent-ink: #0c1a12;
  --accent-soft: rgba(82, 196, 131, 0.13);
  --accent-btn: #43b373;
  --accent-btn-ink: #0b1a11;
  --fab-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  --up: #52c483;
  --down: #ec8466;
  --up-soft: rgba(82, 196, 131, 0.12);
  --down-soft: rgba(236, 132, 102, 0.12);
  --pill-up: rgba(82, 196, 131, 0.16);
  --pill-down: rgba(236, 132, 102, 0.16);
  --pill-up-ink: #6fd29a;
  --pill-down-ink: #f29a80;
  --chart-up: #52c483;
  --chart-down: #ec8466;
  --grid: #1c1f22;
  --axis: #3a3f45;
  --c-cash: #3987e5;
  --c-bist: #d95926;
  --c-us: #199e70;
  --c-gold: #c98500;
  --c-income: #3987e5;
  --c-expense: #d95926;
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --toast-bg: #262a2f;
  --toast-ink: #e6e8e9;
  --toast-accent: #6fd29a;
  --ill-gold: #e6c04e;
  --ill-gold-2: #b98a1c;
  --ill-gold-3: #f4e2a6;
  --ill-accent: #43b373;
  --ill-accent-2: #2d7a4f;
  --ill-soft: #182219;
  --ill-ink: #2b3035;
  --ill-paper: #1e2226;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-family: var(--font-display); font-size: 26px; font-weight: var(--display-weight); letter-spacing: -0.02em; }
h2 { font-family: var(--font-display); font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Privacy mode: amounts blur until tapped off. */
.private .m { filter: blur(8px); transition: filter 0.2s; user-select: none; }

/* ---------- Splash & auth ---------- */
.splash { min-height: 100vh; display: grid; place-items: center; }
.splash-logo, .logo-mark {
  width: 52px; height: 52px; border-radius: 15px;
  background: url("/icons/icon.svg") center / cover;
}
.splash-logo { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; transform: scale(0.94); } }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 24px; padding: 32px 26px; box-shadow: var(--shadow);
}
.auth-card .logo-mark { margin-bottom: 18px; }
.auth-card h1 { font-size: 24px; }
.auth-card p { color: var(--text-2); margin: 8px 0 22px; }
.auth-card form { display: grid; gap: 12px; }
.auth-note { font-size: 12.5px; color: var(--muted); margin-top: 16px !important; margin-bottom: 0 !important; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand .logo-mark { width: 30px; height: 30px; border-radius: 9px; }
.topbar .spacer { flex: 1; }
main { padding: 4px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px); max-width: 1180px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--border);
}
.tab {
  display: grid; justify-items: center; gap: 3px; padding: 6px 0;
  background: none; border: 0; color: var(--muted); font-size: 11px; font-weight: 550; text-decoration: none;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--text); }
.tab-add {
  justify-self: center; width: 52px; height: 52px; border-radius: 18px; border: 0;
  background: var(--accent-btn); color: var(--accent-btn-ink);
  display: grid; place-items: center; box-shadow: var(--shadow-lg); margin-top: -18px;
}
.tab-add svg { width: 26px; height: 26px; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100vh; padding: 22px 14px;
    border-right: 1px solid var(--border); background: var(--surface);
  }
  .sidebar .brand { padding: 0 10px 18px; }
  .nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
    color: var(--text-2); text-decoration: none; font-weight: 550; border: 0; background: none; text-align: left;
  }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item.active { background: var(--accent-soft); color: var(--text); }
  .nav-item.active svg { color: var(--accent); }
  .sidebar .side-add { margin: 6px 0 14px; }
  .sidebar .side-foot { margin-top: auto; padding: 12px; font-size: 12.5px; color: var(--muted); display: grid; gap: 10px; }
  .topbar .brand, .tabbar, .topbar .mobile-only { display: none; }
  .topbar { padding: 18px 32px 10px; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; position: static; }
  main { padding: 0 32px 48px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: transform 0.08s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent-btn); color: var(--accent-btn-ink); border-color: transparent; }
.btn.danger { color: var(--down); }
.btn.danger.solid { background: var(--down); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
  border: 0; background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm svg { width: 17px; height: 17px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; font-size: 13.5px; text-decoration: none; }

/* Segmented control */
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px;
  background: var(--surface-3); border: 1px solid var(--border);
}
.seg button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-2); min-width: 36px;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg button svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 2px; }
.seg.full { display: flex; }
.seg.full button { flex: 1; padding: 8px 10px; }

/* ---------- Layout ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin: 6px 0 18px; flex-wrap: wrap; }
.page-head h1 { flex: 1; }
.page-head .sub { width: 100%; color: var(--muted); margin-top: -10px; font-size: 13.5px; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-2.wide-right { grid-template-columns: 5fr 7fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.s-val, .donut-center b, .auth-card h1 { font-family: var(--font-display); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { flex: 1; }
.card.flush { padding: 6px 0; }
.card.flush .card-head { padding: 12px 18px 4px; }

.empty { text-align: center; padding: 26px 12px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }
.empty p { margin: 4px 0 14px; }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #8f8d86; flex: none; }
.live-dot.on { background: #3cc05a; box-shadow: 0 0 0 0 rgba(60, 192, 90, 0.6); animation: live 2s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 7px rgba(60, 192, 90, 0); } 100% { box-shadow: 0 0 0 0 rgba(60, 192, 90, 0); } }

/* ---------- Ticker ---------- */
/* One slim strip: label + change on top, price below; scrolls sideways on phones. */
.ticker {
  display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 3px;
  box-shadow: var(--shadow);
}
.ticker::-webkit-scrollbar { display: none; }
.tick {
  position: relative; flex: 1 0 auto; min-width: 100px; display: grid; gap: 1px; align-content: center;
  padding: 5px 11px; border: 0; background: none; border-radius: 10px; text-align: left;
}
button.tick:hover { background: var(--surface-2); }
.tick + .tick::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 1px; background: var(--border); }
.t-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tick .t-label { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tick .t-chg { font-size: 10.5px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tick .t-val { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.tick.flash-up { animation: flashUp 1s; }
.tick.flash-down { animation: flashDown 1s; }
@keyframes flashUp { 0% { background: var(--up-soft); } }
@keyframes flashDown { 0% { background: var(--down-soft); } }
.tick-more {
  flex: none; padding: 0 12px; border: 0; background: none; border-radius: 10px;
  color: var(--accent); font-weight: 650; font-size: 12.5px; white-space: nowrap;
}
.tick-more:hover { background: var(--surface-2); }

/* ---------- Rows ---------- */
.rows { display: grid; }
.row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 11px 18px; background: none; border: 0; text-align: left; width: 100%;
  border-top: 1px solid var(--border);
}
.rows > .row:first-child { border-top: 0; }
button.row:hover { background: var(--surface-2); }
.row-main { min-width: 0; display: grid; gap: 1px; }
.row-main b { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { text-align: right; display: grid; gap: 1px; font-variant-numeric: tabular-nums; }
.row-end b { font-weight: 650; }
.row-end small { font-weight: 550; }
.row.with-action { grid-template-columns: auto 1fr auto auto; }

.avatar {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  font-weight: 750; font-size: 13px; letter-spacing: -0.02em;
  background: color-mix(in srgb, var(--c, var(--muted)) 16%, transparent); color: var(--c, var(--text));
}
.avatar.round { border-radius: 50%; }
.avatar.emoji { font-size: 19px; background: var(--surface-3); }
.avatar.in { --c: var(--up); }
.avatar.out { --c: var(--down); }
.avatar svg { width: 18px; height: 18px; }

.cat-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px 8px; }
.cat-head h2 { flex: 1; }
.swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.share { font-size: 12.5px; color: var(--muted); font-weight: 600; }

.day-head { padding: 14px 18px 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; display: flex; justify-content: space-between; }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 650;
  background: var(--surface-3); color: var(--text-2); vertical-align: 1px; margin-left: 4px;
}
.tag.gold { background: var(--accent-soft); color: var(--accent); }

/* ---------- Allocation ---------- */
.alloc-box { container-type: inline-size; }
.alloc { display: grid; gap: 18px; align-items: center; }
@container (min-width: 430px) { .alloc { grid-template-columns: 190px 1fr; } }
.donut-wrap { position: relative; width: 190px; height: 190px; margin: 0 auto; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center b { font-size: 17px; font-variant-numeric: tabular-nums; }
.donut-center small { color: var(--muted); }
.legend { display: grid; gap: 4px; }
.legend-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 7px 8px; border-radius: 10px; border: 0; background: none; text-align: left; width: 100%;
}
.legend-row:hover, .legend-row.hl { background: var(--surface-2); }
.legend-row .pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.legend-row small { display: block; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--axis); stroke-width: 1; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 120px;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow-lg); white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px)); opacity: 0; transition: opacity 0.12s;
}
.tooltip.show { opacity: 1; }
.tooltip .tt-title { color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.tooltip .tt-row b { font-weight: 700; }
.tooltip .key { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-empty { height: 180px; display: grid; place-content: center; text-align: center; color: var(--muted); font-size: 13.5px; padding: 0 20px; }

/* ---------- Progress ---------- */
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--c, var(--accent)); }
.goal { display: grid; gap: 7px; padding: 12px 0; border-top: 1px solid var(--border); }
.goal:first-of-type { border-top: 0; padding-top: 2px; }
.goal-top { display: flex; align-items: baseline; gap: 8px; }
.goal-top b { flex: 1; font-weight: 650; }
.goal-top .pct { font-weight: 750; font-variant-numeric: tabular-nums; }
.goal-sub { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; gap: 8px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .stats.four { grid-template-columns: repeat(4, 1fr); } .stats.three { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.stat .s-label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .s-val { font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; margin-top: 3px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .s-sub { font-size: 12px; color: var(--muted); margin-top: 1px; font-variant-numeric: tabular-nums; }
.card > .stats .stat { background: var(--surface-2); }

/* ---------- Budget ---------- */
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav .label { min-width: 120px; text-align: center; font-weight: 700; }
.cat-bars { display: grid; gap: 12px; }
.cat-bar { display: grid; gap: 5px; }
.cat-bar-top { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.cat-bar-top .name { flex: 1; font-weight: 600; }
.cat-bar-top .val { font-variant-numeric: tabular-nums; font-weight: 650; }
.cat-bar-top .pct { color: var(--muted); font-size: 12px; width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.kind-tabs { display: flex; gap: 8px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field > span, .field-label { font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface-2); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s; min-width: 0;
}
textarea.input { height: auto; padding: 10px 14px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.big { height: 56px; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 64px; }
.input-wrap .suffix { position: absolute; right: 14px; color: var(--muted); font-weight: 650; pointer-events: none; }
.input-wrap .inline-btn { position: absolute; right: 6px; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form { display: grid; gap: 14px; }
.form-error { color: var(--down); font-size: 13.5px; font-weight: 600; min-height: 0; }
.form-error:empty { display: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check small { display: block; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.tile {
  display: grid; gap: 2px; padding: 10px 11px; border-radius: 12px; text-align: left;
  border: 1px solid var(--border-strong); background: var(--surface);
}
.tile b { font-size: 13.5px; font-weight: 650; }
.tile small { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.tile.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tile .held { color: var(--accent); font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 600;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.lookup-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.lookup-card .row-main small { white-space: normal; }
.preview { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.preview b { font-size: 17px; }

/* ---------- Sheets (dialogs) ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: 0; max-width: none; max-height: none; width: 100%;
  background: transparent; color: var(--text);
  position: fixed; inset: auto 0 0 0; height: auto;
}
dialog.sheet::backdrop { background: rgba(10, 9, 6, 0.45); backdrop-filter: blur(2px); }
.sheet-panel {
  background: var(--panel); border-radius: 22px 22px 0 0; max-height: 92vh; overflow-y: auto;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); overscroll-behavior: contain;
  animation: sheetUp 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet-grip { width: 38px; height: 5px; border-radius: 9px; background: var(--border-strong); margin: 2px auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; position: sticky; top: -8px; background: var(--panel); padding: 6px 0; z-index: 2; }
.sheet-head h2 { flex: 1; font-size: 19px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet-actions .btn { flex: 1; }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 700px) {
  dialog.sheet { inset: 0; margin: auto; width: min(560px, calc(100% - 32px)); height: fit-content; }
  .sheet-panel { border-radius: 22px; max-height: 88vh; padding: 14px 24px 24px; }
  .sheet-grip { display: none; }
  @keyframes sheetUp { from { transform: translateY(16px) scale(0.98); opacity: 0; } }
}

/* ---------- Menus ---------- */
.menu { display: grid; gap: 4px; }
.menu button {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 12px;
  border: 0; background: var(--surface-2); text-align: left; font-weight: 600;
}
.menu button svg { width: 19px; height: 19px; color: var(--text-2); }
.menu button.danger { color: var(--down); }
.menu button.danger svg { color: var(--down); }

/* ---------- Toasts ---------- */
#toasts {
  position: fixed; z-index: 100; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); pointer-events: none;
}
@media (min-width: 900px) { #toasts { bottom: 24px; } }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 16px; border-radius: 14px;
  background: var(--toast-bg); color: var(--toast-ink); box-shadow: var(--shadow-lg); pointer-events: auto;
  font-size: 14px; font-weight: 550; animation: toastIn 0.2s ease-out;
}
.toast.error { background: #5a1d1d; }
.toast span { flex: 1; }
.toast button { background: none; border: 0; color: var(--toast-accent); font-weight: 700; padding: 4px 6px; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Market table ---------- */
.mtable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.mtable th { text-align: right; font-size: 11.5px; color: var(--muted); font-weight: 650; padding: 6px 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.mtable th:first-child { text-align: left; }
.mtable td { padding: 9px 4px; border-top: 1px solid var(--border); text-align: right; }
.mtable td:first-child { text-align: left; font-weight: 600; }
.mtable .grp td { border-top: 0; padding-top: 16px; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Settings ---------- */
.set-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.card-head + .set-row { border-top: 0; padding-top: 2px; }
.set-row .set-text { flex: 1; min-width: 200px; }
.set-row .set-text small { display: block; color: var(--muted); margin-top: 2px; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 6px 0; }
.status-line .live-dot.bad { background: var(--down); }
.feature-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.feature-list li { display: flex; gap: 10px; font-size: 13.5px; color: var(--text-2); }
.feature-list li b { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Illustrations ---------- */
.art { display: block; }
.art-avatar { padding: 0; overflow: hidden; }
.art-avatar .art { width: 34px; height: 34px; }
.empty .empty-art { width: 150px; height: auto; margin: 0 auto 6px; }
.chart-empty .empty-art { width: 120px; margin: 0 auto 4px; }
.auth-art { margin: -6px auto 14px; max-width: 260px; }
.auth-art .art { width: 100%; height: auto; }

/* ---------- Security ---------- */
.strength { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-top: -4px; }
.strength .bar { height: 6px; }
.strength i { transition: width 0.2s; }
.strength small { color: var(--muted); min-width: 56px; text-align: right; }
.twofa-hint { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 12px; background: var(--accent-soft); font-size: 13.5px; color: var(--text-2); }
.twofa-hint svg { width: 20px; height: 20px; flex: none; color: var(--accent); margin-top: 1px; }
.code-input { text-align: center; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.sec-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.sec-badge svg { width: 14px; height: 14px; }
.sec-badge.ok { background: var(--up-soft); color: var(--up); }
.sec-badge.warn { background: var(--accent-soft); color: var(--accent); }
.sub-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 2px; padding-top: 14px; border-top: 1px solid var(--border); }
.mini-rows { margin: 0 -18px; }
.mini-rows .row { padding-top: 9px; padding-bottom: 9px; }
.mini-rows .avatar { width: 34px; height: 34px; border-radius: 10px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--text-2); font-size: 13.5px; }
.qr-box { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: 16px; border: 1px solid var(--border); width: fit-content; margin: 0 auto; }
.secret-row { display: flex; align-items: center; gap: 10px; justify-content: center; flex-wrap: wrap; font-size: 13px; }
.secret-row code, .codes code { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; letter-spacing: 0.04em; }
.secret-row code { background: var(--surface-2); padding: 4px 8px; border-radius: 8px; font-size: 12.5px; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.codes code { text-align: center; padding: 9px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong); font-size: 14.5px; font-weight: 600; }

/* ---------- Brokerage-style pieces ---------- */
.chg-pill {
  display: inline-block; min-width: 64px; padding: 4px 8px; border-radius: 7px; text-align: center;
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--pill-up-ink); background: var(--pill-up);
}
.chg-pill.down { background: var(--pill-down); color: var(--pill-down-ink); }
.chg-pill.flat { background: var(--surface-3); color: var(--text-2); }
.row-end .chg-pill { justify-self: end; margin-top: 3px; }
.row.has-spark { grid-template-columns: minmax(0, 1fr) 76px auto; }
.row.has-spark > .avatar { display: none; }
.row .spark { display: block; }
.row.has-spark .row-end { min-width: 108px; justify-items: end; }
.spark-cell { display: flex; justify-content: center; }

.flat-hero { padding: 6px 2px 8px; }
.flat-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.flat-label { font-size: 15px; font-weight: 650; color: var(--text); }
.flat-value { font-family: var(--font-display); font-size: clamp(36px, 10vw, 52px); font-weight: var(--display-weight); letter-spacing: -0.035em; line-height: 1.05; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.flat-change { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.flat-change .when { color: var(--muted); font-weight: 500; }
.flat-chart { margin: 14px -2px 4px; min-height: 200px; }
.range-tabs { display: flex; gap: 4px; padding: 8px 0 4px; border-bottom: 1px solid var(--border); }
.range-tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.range-tabs button.on { color: var(--accent); background: var(--accent-soft); }
.flat-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0 2px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.flat-meta b { color: var(--text); font-weight: 700; }
.unit-pill { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--accent-soft); }
.unit-pill button { border: 0; background: none; padding: 5px 10px; border-radius: 999px; font-weight: 700; font-size: 12.5px; color: var(--accent); }
.unit-pill button.on { background: var(--accent-btn); color: var(--accent-btn-ink); }

.card.promo { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.promo .art { width: 128px; height: auto; }
.promo-kicker { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.promo-kicker svg { width: 15px; height: 15px; color: var(--accent); }
.promo h3 { font-family: var(--font-display); font-size: 18px; font-weight: 750; margin: 4px 0 6px; letter-spacing: -0.01em; }
.promo p { margin: 0 0 10px; color: var(--text-2); font-size: 13.5px; }

.pos-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.pos-value { font-family: var(--font-display); font-size: 34px; font-weight: var(--display-weight); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv span { color: var(--muted); }
.kv b { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.kv-big { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; margin-bottom: 6px; }
.kv-big div span { display: block; font-size: 12.5px; color: var(--muted); }
.kv-big div b { font-size: 19px; font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.ring { width: 22px; height: 22px; vertical-align: -5px; margin-left: 6px; }
.section-title { font-family: var(--font-display); font-size: 20px; font-weight: 750; margin: 20px 0 6px; letter-spacing: -0.01em; }
.sticky-actions { position: sticky; bottom: -18px; display: flex; gap: 10px; padding: 12px 0 2px; background: var(--panel); margin-top: 8px; }
.sticky-actions .btn { flex: 1; height: 48px; border-radius: 999px; }

/* ---------- People ---------- */
.uav {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%; object-fit: cover;
  background: color-mix(in srgb, var(--uc, var(--muted)) 18%, var(--surface)); color: var(--uc, var(--text-2));
  font-weight: 750; letter-spacing: -0.02em; line-height: 1;
}
.by { display: inline-flex; align-items: center; gap: 5px; vertical-align: -3px; font-weight: 600; color: var(--text-2); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; text-decoration: none; color: var(--text);
}
.user-chip:hover { background: var(--surface-2); }
.user-chip span { display: grid; min-width: 0; }
.user-chip b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { color: var(--muted); }
.me-btn { padding: 0; text-decoration: none; }
.row-main.wrap small { white-space: normal; }
.me-btn .uav { pointer-events: none; }
.profile { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.profile-pic { position: relative; border: 0; background: none; padding: 0; border-radius: 50%; }
.profile-pic .pic-edit {
  position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-btn); color: var(--accent-btn-ink); border: 2px solid var(--bg);
}
.profile-pic .pic-edit svg { width: 13px; height: 13px; }
.profile-form { display: grid; gap: 10px; flex: 1; min-width: 220px; }
.person.is-off { opacity: 0.55; }
.person .row-main small { white-space: normal; }
.person-line { display: flex; align-items: center; gap: 12px; }
.person-line span { display: grid; }
.link-box { display: flex; gap: 8px; align-items: center; }
.link-box .input { font-size: 13px; font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; }
.readonly-field { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.lock-user { display: grid; justify-items: center; gap: 4px; margin: -4px 0 14px; }
.lock-user b { font-size: 16px; }
.log-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.log-row .log-text { white-space: normal; font-weight: 500; line-height: 1.4; }
.log-row .who { font-weight: 750; }

/* ---------- Flat look ----------
   Sections instead of boxes, pill buttons, quiet chrome. Kept last so these
   win over the generic component rules above. */
.card {
  border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; background: transparent;
  padding: 20px 2px;
}
.card.flush { padding: 8px 0; }
.card.flush .card-head, .cat-head { padding-left: 2px; padding-right: 2px; }
.row { padding-left: 2px; padding-right: 2px; }
button.row:hover { background: var(--surface-2); border-radius: 12px; }
.mini-rows { margin: 0; }
.card.promo { border: 1px solid var(--border); border-radius: 18px; padding: 18px; background: var(--surface); }
.btn, .btn.sm { border-radius: 999px; }
.btn.primary { font-weight: 700; }
.stack { gap: 6px; }
.grid-2 { gap: 0 36px; }
.stat { background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 12px 2px; }
.card > .stats .stat { background: transparent; }
.stat .s-label { font-weight: 500; }
.ticker { border: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: 3px 0; }
.seg { background: transparent; border-color: transparent; }
.seg button.on { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.sidebar { background: var(--bg); }
.nav-item { font-weight: 600; }
.nav-item.active { background: transparent; color: var(--text); font-weight: 800; }
.nav-item.active svg { color: var(--accent); }
.tab-add { border-radius: 50%; box-shadow: var(--fab-shadow); }
.tab.active { color: var(--text); }
.avatar, .mini-rows .avatar { border-radius: 50%; }
.tile { border-radius: 12px; }
.chip { border-radius: 999px; }
.input, select.input, textarea.input { border-radius: 12px; background: var(--surface-2); border-color: transparent; }
.input:focus { border-color: var(--accent); }
.bar > i { background: var(--c, var(--chart-up)); }
h1 { font-size: 30px; letter-spacing: -0.03em; }
.page-head h1 { font-size: 32px; }
.auth-card { border: 0; box-shadow: none; }
