/* Secured Stash — design system
   Apple HIG inspired: system type scale, grouped inset lists, 44pt targets, semantic colours,
   light/dark via prefers-color-scheme (+ manual override), reduced motion respected. */

:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f6f6f9;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.2);
  --sep: rgba(60, 60, 67, 0.16);
  --text: #0b0b0f;
  --text-2: rgba(60, 60, 67, 0.68);
  --text-3: rgba(60, 60, 67, 0.42);
  --accent: #0a7a5c;
  --accent-hover: #086a50;
  --accent-tint: rgba(10, 122, 92, 0.11);
  --on-accent: #ffffff;
  --pos: #12804a;
  --neg: #c9302c;
  --warn: #a35f00;
  --focus: #0a66d8;

  --c-bank: #2f6fdb;
  --c-crypto: #e37b00;
  --c-metals: #b8921b;
  --c-invest: #7553d1;
  --c-property: #0e8f9c;
  --c-other: #8a8a92;
  --c-liability: #c9302c;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.02);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 200ms;
  --tabbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.36);
    --sep: rgba(84, 84, 88, 0.6);
    --text: #f5f5f7;
    --text-2: rgba(235, 235, 245, 0.66);
    --text-3: rgba(235, 235, 245, 0.36);
    --accent: #2fc28f;
    --accent-hover: #4fd1a2;
    --accent-tint: rgba(47, 194, 143, 0.16);
    --on-accent: #00281b;
    --pos: #3ad27c;
    --neg: #ff6961;
    --warn: #ffb340;
    --focus: #4ea1ff;
    --c-bank: #5b93ff;
    --c-crypto: #ff9f2e;
    --c-metals: #e1bc45;
    --c-invest: #a08af0;
    --c-property: #3cc6d3;
    --c-other: #a1a1aa;
    --c-liability: #ff6961;
    --shadow: none;
    --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e; --fill: rgba(118,118,128,.24); --fill-2: rgba(118,118,128,.36);
  --sep: rgba(84,84,88,.6); --text: #f5f5f7; --text-2: rgba(235,235,245,.66); --text-3: rgba(235,235,245,.36);
  --accent: #2fc28f; --accent-hover: #4fd1a2; --accent-tint: rgba(47,194,143,.16); --on-accent: #00281b;
  --pos: #3ad27c; --neg: #ff6961; --warn: #ffb340; --focus: #4ea1ff;
  --c-bank: #5b93ff; --c-crypto: #ff9f2e; --c-metals: #e1bc45; --c-invest: #a08af0; --c-property: #3cc6d3; --c-other: #a1a1aa; --c-liability: #ff6961;
  --shadow: none; --shadow-pop: 0 12px 40px rgba(0,0,0,.6);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 17px/1.35 var(--font);
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
[hidden] { display: none !important; }

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

.num, .amount, td, .tabular { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- type scale (HIG) ---------- */
.t-large { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: -0.022em; }
.t-title1 { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.02em; }
.t-title2 { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.018em; }
.t-title3 { font-size: 20px; line-height: 25px; font-weight: 600; letter-spacing: -0.016em; }
.t-headline { font-size: 17px; line-height: 22px; font-weight: 600; }
.t-body { font-size: 17px; line-height: 22px; }
.t-callout { font-size: 16px; line-height: 21px; }
.t-sub { font-size: 15px; line-height: 20px; }
.t-foot { font-size: 13px; line-height: 18px; letter-spacing: -0.004em; }
.t-cap { font-size: 12px; line-height: 16px; letter-spacing: 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }

/* ---------- app shell ---------- */
.shell { min-height: 100dvh; }
.main {
  padding: calc(var(--safe-t) + 8px) 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
  max-width: 1120px;
  margin: 0 auto;
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 12px 4px 12px; }
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: 4px; align-items: center; }
.page-sub { margin: -6px 4px 16px; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-2); font-size: 10.5px; font-weight: 500; letter-spacing: 0.01em; text-decoration: none !important;
  min-height: 44px;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
.brand { display: none; }

@media (min-width: 960px) {
  html:not(.fm) .shell { display: grid; grid-template-columns: 240px 1fr; }
  html:not(.fm) .tabbar {
    position: sticky; top: 0; inset: auto; height: 100dvh; padding: 20px 12px;
    display: flex; flex-direction: column; gap: 2px; border-top: 0; border-right: 0.5px solid var(--sep);
    background: var(--surface-2);
  }
  html:not(.fm) .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; border-radius: var(--r-sm); font-size: 15px; color: var(--text); }
  html:not(.fm) .tab svg { width: 20px; height: 20px; color: var(--accent); }
  html:not(.fm) .tab:hover { background: var(--fill); }
  html:not(.fm) .tab[aria-current="page"] { background: var(--accent-tint); color: var(--text); font-weight: 600; }
  html:not(.fm) .brand { display: flex; align-items: center; gap: 10px; padding: 4px 12px 20px; font-weight: 700; font-size: 17px; }
  html:not(.fm) .brand svg { width: 28px; height: 28px; }
  html:not(.fm) .tabbar .spacer { flex: 1; }
  html:not(.fm) .main { padding: 24px 32px 48px; width: 100%; }
}

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px; }
.card + .card, .section + .section, .card + .section, .section + .card { margin-top: 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; min-height: 32px; }
.card-head h2, .card-head h3 { margin: 0; }
.section-title { margin: 24px 16px 6px; color: var(--text-2); font-size: 13px; line-height: 18px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.02em; display: flex; justify-content: space-between; gap: 8px; }
.section-title .cat-link { color: inherit; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; text-decoration: none; }
.section-title .cat-link svg { width: 12px; height: 12px; color: var(--text-3); }
.section-title .cat-link:hover { color: var(--accent); }
.section-foot { margin: 6px 16px 0; color: var(--text-2); font-size: 13px; line-height: 18px; }
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 760px) { html:not(.fm) .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } html:not(.fm) .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { html:not(.fm) .grid-main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; } }

/* grouped inset list */
.list { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; margin: 0; padding: 0; list-style: none; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 16px;
  position: relative; width: 100%; text-align: left; background: none; border: 0; color: inherit; text-decoration: none !important;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--sep); }
.row.has-icon + .row.has-icon::before { left: 60px; }
button.row, a.row, label.row { cursor: pointer; }
button.row:hover, a.row:hover { background: var(--fill); }
button.row:active, a.row:active { background: var(--fill-2); }
.row .grow { flex: 1; min-width: 0; }
.row .title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .subtitle { display: block; color: var(--text-2); font-size: 13px; line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { text-align: right; flex-shrink: 0; }
.row .chev { color: var(--text-3); width: 14px; height: 14px; flex-shrink: 0; }
.row .ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.row .ico svg { width: 18px; height: 18px; }
.row.destructive { color: var(--neg); justify-content: center; }
.row.accent { color: var(--accent); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r); border: 0; cursor: pointer;
  font-weight: 600; font-size: 16px; text-decoration: none !important; white-space: nowrap;
  transition: transform 120ms var(--ease), opacity var(--dur) var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-tinted { background: var(--accent-tint); color: var(--accent); }
.btn-tinted:hover { background: color-mix(in srgb, var(--accent-tint) 70%, var(--accent) 12%); }
.btn-plain { background: none; color: var(--accent); padding: 0 10px; }
.btn-plain:hover { background: var(--fill); }
.btn-gray { background: var(--fill); color: var(--text); }
.btn-danger { background: var(--neg); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 15px; border-radius: 10px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn.loading { pointer-events: none; }
.btn.loading::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; color: var(--accent);
  display: inline-grid; place-items: center; cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--fill); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.spinning svg { animation: spin 1s linear infinite; }
.icon-btn .dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--neg); border: 2px solid var(--bg); }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 13px; font-weight: 500; color: var(--text-2); padding-left: 2px; }
.field .hint { font-size: 13px; color: var(--text-2); padding-left: 2px; }
.field .error { font-size: 13px; color: var(--neg); padding-left: 2px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--r); border: 1px solid transparent;
  background: var(--fill); color: var(--text); outline: none;
}
textarea.input { min-height: 96px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 18px; }
.input:focus { border-color: var(--accent); background: var(--surface); }
.input[aria-invalid="true"] { border-color: var(--neg); }
.input::placeholder { color: var(--text-3); }
.input-group { display: flex; gap: 8px; }
.input-group > .input { flex: 1; min-width: 0; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.input.num { text-align: right; }

.seg { display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; padding: 0 12px; min-height: 30px; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button[aria-pressed="true"] { background: #636366; } }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { background: #636366; }

.switch { position: relative; display: inline-block; vertical-align: middle; width: 51px; height: 31px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--fill-2); }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); transition: transform var(--dur) var(--ease); }
.switch input:checked + span { background: var(--pos); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; line-height: 18px; font-weight: 500; background: var(--fill); color: var(--text-2); white-space: nowrap; border: 0; }
button.chip { cursor: pointer; min-height: 28px; }
.chip.pos { background: color-mix(in srgb, var(--pos) 14%, transparent); color: var(--pos); }
.chip.neg { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }
.chip.accent { background: var(--accent-tint); color: var(--accent); }
.chip.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip svg { width: 12px; height: 12px; }
.dot-k { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; display: inline-block; }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--accent-tint); font-size: 15px; line-height: 20px; }
.banner svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--accent); margin-top: 1px; }
.banner.warn { background: color-mix(in srgb, var(--warn) 13%, transparent); }
.banner.warn svg { color: var(--warn); }
.banner.danger { background: color-mix(in srgb, var(--neg) 12%, transparent); }
.banner.danger svg { color: var(--neg); }

/* ---------- overview ---------- */
.hero .label { font-size: 15px; color: var(--text-2); font-weight: 500; }
.hero .value { font-size: 44px; line-height: 52px; font-weight: 700; letter-spacing: -0.03em; margin: 2px 0 10px; font-variant-numeric: tabular-nums; }
@media (max-width: 380px) { .hero .value { font-size: 36px; line-height: 44px; } }
.hero .deltas { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 15px; }
.delta { display: inline-flex; align-items: baseline; gap: 6px; }
.delta b { font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 0.5px solid var(--sep); }
.kpi .k { font-size: 13px; color: var(--text-2); }
.kpi .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }

.alloc-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--fill); }
.alloc-bar span { display: block; min-width: 3px; }
.legend { display: grid; gap: 2px; margin-top: 12px; }
.legend .row { min-height: 40px; padding: 6px 4px; }
.legend .row + .row::before { left: 26px; }

.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .axis { font-size: 11px; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--sep); stroke-width: 0.5; }
.chart .total-line { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cursor { stroke: var(--text-3); stroke-width: 1; }
.chart-tip {
  position: absolute; top: 0; pointer-events: none; z-index: 2; min-width: 160px;
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-pop); padding: 8px 10px; font-size: 13px; line-height: 18px;
  border: 0.5px solid var(--sep);
}
.chart-tip .tip-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.chart-tip .tip-row span:first-child { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.chart-empty { display: grid; place-items: center; min-height: 180px; color: var(--text-2); font-size: 15px; text-align: center; padding: 16px; }

.spark { width: 64px; height: 24px; flex-shrink: 0; }
.spark path { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.acc-value { font-weight: 500; font-variant-numeric: tabular-nums; }
.acc-delta { font-size: 13px; font-variant-numeric: tabular-nums; }
.badge-src { display: inline-flex; vertical-align: -2px; margin-left: 4px; color: var(--text-3); }
.badge-src svg { width: 13px; height: 13px; }

.sync-line { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); margin: -4px 4px 12px; flex-wrap: wrap; }
.sync-line button { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px 4px; font-size: 13px; }

/* ---------- history grid ---------- */
.table-wrap { overflow: auto; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); max-height: 70vh; overscroll-behavior: contain; }
table.grid-table { border-collapse: separate; border-spacing: 0; font-size: 14px; min-width: 100%; }
.grid-table th, .grid-table td { padding: 0; white-space: nowrap; border-bottom: 0.5px solid var(--sep); }
.grid-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); font-weight: 600; font-size: 12px; color: var(--text-2); padding: 10px 12px; text-align: right; text-transform: uppercase; letter-spacing: 0.02em; }
.grid-table th.sticky, .grid-table td.sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; min-width: 150px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; padding: 0 12px; border-right: 0.5px solid var(--sep); }
.grid-table thead th.sticky { z-index: 3; }
.grid-table tr.group td { background: var(--surface-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-2); padding: 8px 12px; }
.grid-table tr.group td.sticky { background: var(--surface-2); }
.grid-table tr.total td { font-weight: 700; background: var(--surface-2); }
.grid-table tr.total td.sticky { background: var(--surface-2); }
.grid-table td.cell { text-align: right; min-width: 104px; }
.grid-table td.cell input {
  width: 100%; min-height: 40px; border: 0; background: transparent; text-align: right; padding: 0 12px; font-variant-numeric: tabular-nums; outline: none; font-size: 14px;
}
.grid-table td.cell input:hover { background: var(--fill); }
.grid-table td.cell input:focus { background: var(--accent-tint); box-shadow: inset 0 0 0 2px var(--accent); }
.grid-table td.cell.est input { color: var(--text-3); font-style: italic; }
.grid-table td.ro { padding: 0 12px; height: 40px; }
.grid-table td.cur, .grid-table th.cur { background: color-mix(in srgb, var(--accent-tint) 55%, var(--surface)); }

.years { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; }
.years .card { scroll-snap-align: start; margin: 0 !important; }
.year-stat { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; margin-top: 8px; }
.year-stat dt { color: var(--text-2); white-space: nowrap; }
.year-stat dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- spending ---------- */
.month-nav { display: inline-flex; align-items: center; gap: 4px; }
.month-nav .t { min-width: 140px; text-align: center; font-weight: 600; }
.bar-list { display: grid; gap: 4px; }
.bar-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 4px; border-radius: 8px; border: 0; background: none; text-align: left; cursor: pointer; width: 100%; }
.bar-item:hover { background: var(--fill); }
.bar-item .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.bar-item .track span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar-item .meta { font-size: 13px; color: var(--text-2); }
.tx-amount { font-variant-numeric: tabular-nums; font-weight: 500; }
.tx-amount.in { color: var(--pos); }
.insight { padding: 12px 0; border-top: 0.5px solid var(--sep); }
.insight:first-child { border-top: 0; padding-top: 0; }
.insight h4 { margin: 0 0 4px; font-size: 16px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.insight p { margin: 0; color: var(--text-2); font-size: 15px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.search .input { padding-left: 36px; min-height: 38px; border-radius: 10px; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px calc(24px + var(--safe-b)); }
.auth-box { width: 100%; max-width: 400px; }
.auth-logo { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 16px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); }
.auth-logo svg { width: 34px; height: 34px; }
.auth h1 { text-align: center; margin: 0 0 6px; }
.auth .lead { text-align: center; margin: 0 0 24px; color: var(--text-2); }
.auth .card { padding: 20px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 15px; }
.pin-dots { display: flex; gap: 16px; justify-content: center; margin: 24px 0 28px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--text-2); }
.pin-dots span.on { background: var(--text); border-color: var(--text); }
.pin-dots.shake { animation: shake 360ms; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pinpad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 24px; justify-content: center; }
.pinpad button { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--fill); font-size: 30px; font-weight: 400; cursor: pointer; display: grid; place-items: center; }
.pinpad button:active { background: var(--fill-2); }
.pinpad button.ghost { background: none; font-size: 15px; color: var(--accent); }
.pinpad button svg { width: 26px; height: 26px; }
.qr { background: #fff; padding: 12px; border-radius: 12px; width: 204px; margin: 0 auto; }
.qr svg { width: 180px; height: 180px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-family: var(--mono); font-size: 15px; background: var(--fill); border-radius: var(--r); padding: 14px; text-align: center; }
.secret { font-family: var(--mono); font-size: 14px; word-break: break-all; background: var(--fill); padding: 10px 12px; border-radius: 10px; user-select: all; }
.strength { height: 4px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.strength span { display: block; height: 100%; transform-origin: left; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; line-height: 20px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }

/* ---------- dialog / sheet ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh;
  border-radius: 14px 14px 0 0; background: var(--bg); color: var(--text); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; overflow: hidden;
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.38); }
@media (min-width: 640px) { html:not(.fm) dialog.sheet { margin: auto; border-radius: 16px; max-height: 86dvh; } }
dialog.sheet.wide { max-width: 860px; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 8px; min-height: 52px; background: var(--surface-2); border-bottom: 0.5px solid var(--sep); }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; grid-column: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.sheet-head .l { justify-self: start; }
.sheet-head .r { justify-self: end; grid-column: 3; }
.sheet-body { padding: 16px; overflow: auto; overscroll-behavior: contain; padding-bottom: calc(20px + var(--safe-b)); }
.sheet-body > .list + .section-title { margin-top: 20px; }
@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: sheet-in 280ms var(--ease); }
  @media (min-width: 640px) { html:not(.fm) dialog.sheet[open] { animation: pop-in 200ms var(--ease); } }
  dialog.sheet[open]::backdrop { animation: fade-in 200ms; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop-in { from { transform: scale(0.97); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); z-index: 100; display: grid; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
@media (min-width: 960px) { html:not(.fm) .toasts { bottom: 24px; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: #1c1c1e; color: #fff; box-shadow: var(--shadow-pop); font-size: 15px; line-height: 20px; }
.toast .grow { flex: 1; }
.toast button { border: 0; background: none; color: #4fd1a2; font-weight: 600; cursor: pointer; padding: 6px 4px; }
.toast.error { background: #3a1210; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: sheet-in 240ms var(--ease); } }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 32px 16px; }
.empty .art { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; background: var(--accent-tint); color: var(--accent); display: grid; place-items: center; }
.empty .art svg { width: 28px; height: 28px; }
.empty h3 { margin: 0 0 6px; font-size: 20px; }
.empty p { margin: 0 auto 18px; color: var(--text-2); max-width: 420px; }
.empty .btn-row { justify-content: center; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; font-size: 15px; line-height: 21px; }
.steps li::before { content: counter(step); width: 26px; height: 26px; border-radius: 50%; background: var(--accent-tint); color: var(--accent); font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.copy-field { display: flex; gap: 8px; align-items: center; background: var(--fill); border-radius: 10px; padding: 4px 4px 4px 12px; font-family: var(--mono); font-size: 13px; margin-top: 6px; }
.copy-field span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

@media (pointer: coarse) {
  button.chip { min-height: 36px; padding: 4px 12px; }
  .btn-sm { min-height: 40px; }
  .sync-line button { min-height: 40px; }
}

/* privacy mode */
body.privacy .amount, body.privacy .chart .axis.y, body.privacy .chart-tip, body.privacy .grid-table td.cell input, body.privacy .grid-table td.ro { filter: blur(7px); }
body.privacy .amount:hover { filter: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media print { .tabbar, .page-head .actions, .toasts { display: none !important; } body { background: #fff; } }

/* Chrome "Desktop site" on a phone: boot.js adds .fm and zooms the page back to phone scale;
   desktop-only layout rules above are scoped to html:not(.fm), so the phone layout is kept. */
.fm-note { position: relative; margin: calc(8px + var(--safe-t, 0px)) auto 0; width: min(92vw, 420px);
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 18px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); border: 0.5px solid var(--sep); }
.fm-note button { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 4px 6px; min-height: 32px; }

/* Chrome "Desktop site" compensation (see js/boot.js): zoom multiplies viewport units, so divide them back. */
html.fm body, html.fm .shell, html.fm .auth { min-height: calc(100dvh / var(--fmz, 1)); }
html.fm dialog.sheet { max-height: calc(92dvh / var(--fmz, 1)); }
html.fm .table-wrap { max-height: calc(70vh / var(--fmz, 1)); }
html.fm .sheet-head h2 { max-width: calc(60vw / var(--fmz, 1)); }
html.fm .toasts { width: min(calc(92vw / var(--fmz, 1)), 440px); }
html.fm .fm-note { width: min(calc(92vw / var(--fmz, 1)), 420px); }
.fm-note span { flex: 1; }
