/* Wealth Tracker — Wealthfolio-inspired look (neutral #fcfcfb light theme, Flexoki dark, Inter / Merriweather / JetBrains Mono) */

:root {
  --bg: #fcfcfb;
  --bg-2: #f6f6f4;
  --card: #f6f6f4;
  --ui: #e6e6e3;
  --ui-2: #d9d9d6;
  --ui-3: #cdcdc9;
  --tx: #100f0f;
  --tx-2: #6b6b67;
  --tx-3: #9c9c97;
  --input-bg: #fcfcfb;
  --hover: rgba(16, 15, 15, 0.045);
  --success: #66800b;
  --danger: #af3029;
  --warning: #ad8301;
  --info: #205ea6;
  --success-bg: #edeecf;
  --danger-bg: #ffe1d5;
  --warning-bg: #faeec6;
  /* chart series — monochrome ink steps (identity also carried by legend, gaps and tooltips) */
  --s1: #282726;
  --s2: #878783;
  --s3: #c6c6c2;
  --grid: #e6e6e3;
  --shadow: 0 1px 2px rgba(16, 15, 15, .04), 0 8px 24px -12px rgba(16, 15, 15, .12);
  --radius: 10px;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Merriweather", ui-serif, Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100f0f; --bg-2: #1c1b1a; --card: #1c1b1a;
    --ui: #282726; --ui-2: #343331; --ui-3: #403e3c;
    --tx: #cecdc3; --tx-2: #878580; --tx-3: #6f6e69;
    --input-bg: #100f0f; --hover: rgba(255, 255, 255, 0.05);
    --success: #879a39; --danger: #d14d41; --warning: #d0a215; --info: #4385be;
    --success-bg: #252d09; --danger-bg: #3e1715; --warning-bg: #3a2d04;
    --s1: #e6e4d9; --s2: #8f8d87; --s3: #4a4846;
    --grid: #282726;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #100f0f; --bg-2: #1c1b1a; --card: #1c1b1a;
  --ui: #282726; --ui-2: #343331; --ui-3: #403e3c;
  --tx: #cecdc3; --tx-2: #878580; --tx-3: #6f6e69;
  --input-bg: #100f0f; --hover: rgba(255, 255, 255, 0.05);
  --success: #879a39; --danger: #d14d41; --warning: #d0a215; --info: #4385be;
  --success-bg: #252d09; --danger-bg: #3e1715; --warning-bg: #3a2d04;
  --s1: #e6e4d9; --s2: #8f8d87; --s3: #4a4846;
  --grid: #282726;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--tx);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ui-3); outline-offset: 2px; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.muted { color: var(--tx-2); }
.faint { color: var(--tx-3); }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.error-text { color: var(--danger); min-height: 1.4em; margin: .5rem 0 0; font-size: 13px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s ease; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 12px; border-right: 1px solid var(--ui);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-serif); font-weight: 700; font-size: 17px; text-decoration: none; padding: 4px 10px 18px; letter-spacing: -.01em; }
.brand-lg { font-size: 24px; padding: 0 0 6px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--tx); position: relative; flex: none; }
.brand-mark::after {
  content: ""; position: absolute; inset: 0;
  background: var(--bg);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M7 21l6-6 4 4 8-9' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M7 21l6-6 4 4 8-9' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--tx-2); text-decoration: none; font-weight: 500; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--hover); color: var(--tx); }
.nav-item.active { background: var(--ui); color: var(--tx); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item .badge { margin-left: auto; }

.main { padding: 28px 36px 64px; max-width: 1240px; width: 100%; margin-inline: auto; outline: none; }

/* collapsed sidebar: icons only (desktop; on phones the sidebar is a bottom bar) */
.nav-collapse svg { transition: transform .2s ease; }
@media (min-width: 761px) {
  .nav-collapsed .app { grid-template-columns: 64px minmax(0, 1fr); }
  .nav-collapsed .sidebar { padding-inline: 10px; overflow: hidden; }
  .nav-collapsed .brand { visibility: hidden; }
  .nav-collapsed .sidebar .nav-item { justify-content: center; padding: 9px 0; position: relative; }
  .nav-collapsed .sidebar .nav-item > span:not(.badge) { display: none; }
  .nav-collapsed .sidebar .nav-item .badge { position: absolute; top: 5px; right: 8px; width: 8px; height: 8px; min-width: 0; padding: 0; font-size: 0; border-radius: 50%; margin: 0; }
  .nav-collapsed .nav-collapse svg { transform: rotate(180deg); }
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title { font-family: var(--font-serif); font-weight: 700; font-size: 26px; letter-spacing: -.015em; margin: 0; line-height: 1.25; }
.page-sub { margin: 4px 0 0; color: var(--tx-2); }
.crumb { color: var(--tx-2); text-decoration: none; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.crumb:hover { color: var(--tx); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--ui); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 600; margin: 0; }
.card-sub { font-size: 12.5px; color: var(--tx-2); margin: 2px 0 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.grid-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.mt { margin-top: 16px; }

/* ---------- hero ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.hero-label { color: var(--tx-2); font-size: 13px; font-weight: 500; display: flex; gap: 8px; align-items: center; }
.hero-value { font-size: 48px; font-weight: 600; letter-spacing: -.025em; line-height: 1.1; margin: 4px 0 6px; }
.hero-value .ccy { font-size: 20px; font-weight: 500; color: var(--tx-2); margin-right: 8px; letter-spacing: 0; }
.delta { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13.5px; }
.delta svg { width: 14px; height: 14px; }

/* ---------- stat tiles ---------- */
.tile { padding: 14px 16px; }
.tile-label { display: flex; align-items: center; gap: 8px; color: var(--tx-2); font-size: 12.5px; font-weight: 500; }
.tile-value { font-size: 22px; font-weight: 600; letter-spacing: -.015em; margin: 4px 0 2px; }
.tile-delta { font-size: 12.5px; }
.tile-delta .delta { display: inline; }
.tile-delta .delta svg { vertical-align: -2px; margin-right: 4px; }
.key { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }

/* ---------- pills / segmented ---------- */
.seg { display: inline-flex; background: var(--ui); border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; color: var(--tx-2); font-weight: 500; font-size: 13px; }
.seg button:hover { color: var(--tx); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--tx); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; background: var(--ui); color: var(--tx-2); white-space: nowrap; }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }
.badge-bad { background: var(--danger-bg); color: var(--danger); }
.badge svg { width: 12px; height: 12px; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--ui-2); background: var(--bg); color: var(--tx);
  font-weight: 500; font-size: 13.5px; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--tx); color: var(--bg); border-color: var(--tx); }
.btn-primary:hover { background: var(--tx); opacity: .88; }
.btn-danger { color: var(--danger); }
.btn-ghost { border-color: transparent; background: none; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-color: transparent; background: none; color: var(--tx-2); }
.btn-icon:hover { color: var(--tx); }
.btn-xs { width: 24px; height: 24px; }
.btn-xs svg { width: 13px; height: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--tx-2); }
.input, .field input, .field select, .field textarea, select.input {
  height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--ui-2);
  background: var(--input-bg); width: 100%; min-width: 0;
}
.field textarea { height: auto; padding: 8px 12px; min-height: 70px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--tx-3); box-shadow: 0 0 0 3px var(--hover); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.inline-check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--tx-2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { text-align: left; font-weight: 500; color: var(--tx-2); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--ui); white-space: nowrap; }
.t td { padding: 9px 10px; border-bottom: 1px solid var(--ui); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t .r, .t th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t tbody tr:hover td { background: var(--hover); }
.t tr.group-row td { background: none; font-weight: 600; font-size: 12px; color: var(--tx-2); text-transform: uppercase; letter-spacing: .04em; padding-top: 16px; }
.t tr.total-row td { font-weight: 600; border-top: 1px solid var(--ui-2); }
.t tr.sub-row td { font-weight: 600; color: var(--tx-2); }
.cell-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-name a { text-decoration: none; font-weight: 500; }
.cell-name a:hover { text-decoration: underline; text-underline-offset: 3px; }
.cell-name small { display: block; color: var(--tx-2); font-size: 12px; font-weight: 400; }
.avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--ui); color: var(--tx-2); display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; letter-spacing: .02em; }
.empty { text-align: center; color: var(--tx-2); padding: 28px 12px; }

/* editable matrix */
.matrix td.cell { padding: 0; }
.matrix .cell-btn {
  display: block; white-space: nowrap; width: 100%; min-width: 104px; height: 40px; padding: 0 10px;
  border: 0; background: none; text-align: right; font-variant-numeric: tabular-nums; border-radius: 6px;
}
.matrix .cell-btn:hover { background: var(--ui); }
.matrix .cell-btn.missing { color: var(--warning); }
.matrix .cell-btn.closed { color: var(--tx-3); }
.matrix .cell-btn::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.matrix .cell-btn.src-import::before, .lg-dot.src-import { background: var(--tx-2); }
.matrix .cell-btn.src-manual::before, .lg-dot.src-manual { background: transparent; box-shadow: inset 0 0 0 1.5px var(--tx-2); }
.matrix .cell-btn.src-xlsx::before, .lg-dot.src-xlsx { background: var(--ui-3); }
.lg-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.asof { font-size: 9.5px; color: var(--tx-3); margin-left: 3px; font-weight: 400; }
.row-act { opacity: 0; margin-left: auto; width: 26px; height: 26px; }
.matrix tr:hover .row-act, .row-act:focus-visible { opacity: 1; }
.matrix .cell-name { justify-content: space-between; }
.archive-toggle td { padding: 6px 10px !important; background: none !important; }
.archive-toggle button { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; font-weight: 600; color: var(--tx-2); padding: 6px 0; font-size: 13px; }
.archive-toggle button:hover { color: var(--tx); }
.archive-toggle svg { width: 15px; height: 15px; }
.archive-toggle .chev svg { transition: transform .15s; }
.archive-toggle button[aria-expanded="true"] .chev svg { transform: rotate(90deg); }
.archived-row td { color: var(--tx-2); }
.acc-row.is-archived { opacity: .6; }
.matrix input.cell-input { width: 100%; min-width: 104px; height: 40px; border: 1px solid var(--tx-3); border-radius: 6px; padding: 0 10px; text-align: right; background: var(--input-bg); font-variant-numeric: tabular-nums; }
.matrix td.sticky { min-width: 200px; }
.matrix th.sticky, .matrix td.sticky { position: sticky; left: 0; background: var(--card); z-index: 1; }
.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--tx-2); align-items: center; }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--tx-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .crosshair { stroke: var(--ui-3); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--tx-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--bg); color: var(--tx); border: 1px solid var(--ui-2); border-radius: 8px;
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; min-width: 150px;
}
.tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.tooltip .tt-row > span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--tx-2); }
.tooltip .tt-total { border-top: 1px solid var(--ui); margin-top: 4px; padding-top: 4px; font-weight: 600; }

.alloc-bar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; margin: 6px 0 14px; }
.alloc-bar > div { height: 100%; min-width: 2px; }
.alloc-list { display: flex; flex-direction: column; gap: 8px; }
.alloc-row { display: grid; grid-template-columns: 1fr auto 52px; gap: 10px; align-items: center; font-size: 13.5px; }
.alloc-row > span:first-child { display: inline-flex; align-items: center; gap: 8px; }

/* account list */
.acc-list { display: flex; flex-direction: column; }
.acc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 8px; border-radius: 8px; text-decoration: none; }
.acc-row:hover { background: var(--hover); }
.acc-row + .acc-row { border-top: 1px solid var(--ui); }
.acc-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.acc-val small { display: block; font-weight: 400; font-size: 12px; }
.acc-group-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--tx-2); padding: 14px 8px 4px; display: flex; justify-content: space-between; }
.acc-group-label:first-child { padding-top: 0; }

/* callouts */
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; background: var(--warning-bg); color: var(--tx); font-size: 13.5px; }
.callout svg { width: 18px; height: 18px; color: var(--warning); flex: none; margin-top: 1px; }
.callout.info { background: var(--ui); }
.callout.info svg { color: var(--tx-2); }
.callout a { font-weight: 500; }

/* ---------- import ---------- */
.dropzone {
  display: block;
  border: 1.5px dashed var(--ui-3); border-radius: var(--radius); padding: 36px 20px; text-align: center;
  background: var(--bg); transition: background .15s, border-color .15s; cursor: pointer;
}
.dropzone:hover, .dropzone.over { background: var(--hover); border-color: var(--tx-3); }
.dropzone svg { width: 28px; height: 28px; color: var(--tx-2); }
.dropzone h3 { margin: 10px 0 4px; font-size: 15px; }
.dropzone p { margin: 0; color: var(--tx-2); font-size: 13px; }
.supported { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.check-list li { display: flex; gap: 8px; align-items: center; }
.check-list svg { width: 15px; height: 15px; flex: none; }
.plan-acc { border: 1px solid var(--ui); border-radius: 8px; padding: 12px 14px; margin-top: 10px; background: var(--bg); }
.plan-acc-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.plan-acc-head select { max-width: 320px; height: 32px; }
.chg-old { color: var(--tx-3); text-decoration: line-through; margin-right: 6px; }
.skip { color: var(--tx-3); }

/* ---------- modal / toast ---------- */
.modal { border: 1px solid var(--ui-2); border-radius: 12px; padding: 0; background: var(--bg); color: var(--tx); width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(16, 15, 15, .35); }
.modal form { padding: 20px 22px; }
.modal h2 { font-family: var(--font-serif); font-size: 19px; margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.modal-actions .right { display: flex; gap: 8px; margin-left: auto; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--tx); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 500; font-size: 13.5px;
  transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--ui); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card p { margin: 6px 0 20px; }

.skeleton { color: var(--tx-2); padding: 40px 0; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .grid-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 40;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--ui);
  }
  .sidebar .brand, .sidebar .nav-bottom { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; width: auto; flex: 1; text-align: center; }
  .nav-item .badge { display: none; }
  .main { padding: 20px 16px 96px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .hero-value { font-size: 36px; }
  .page-title { font-size: 22px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .card { padding: 16px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
  .matrix td.sticky { min-width: 140px; max-width: 160px; }
  .matrix td.sticky small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
}
@media (forced-colors: active) {
  .alloc-bar > div, .key { forced-color-adjust: none; }
}

/* live prices */
.live-status { display: inline-flex; align-items: center; gap: 6px; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--success); display: inline-block; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--tx-3); display: inline-block; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.sym { border: 1px solid var(--ui-2); background: var(--bg); border-radius: 5px; font-family: var(--font-mono); font-size: 11px; padding: 0 5px; margin-right: 6px; color: var(--tx); display: inline-flex; align-items: center; gap: 3px; }
.sym:hover { border-color: var(--tx-3); }
.sym-off { color: var(--tx-3); border-style: dashed; }
.sym svg { width: 11px; height: 11px; color: var(--warning); }
.badge svg { width: 12px; height: 12px; }

/* account modal */
.fieldset { border: 1px solid var(--ui); border-radius: 8px; padding: 10px 12px 12px; margin: 0 0 12px; }
.fieldset legend { font-size: 12.5px; font-weight: 600; color: var(--tx-2); padding: 0 4px; }

/* import */
.replace-note { font-size: 12.5px; color: var(--warning); white-space: nowrap; }
.plan-t td { padding-top: 7px; padding-bottom: 7px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 12px; }
.map-grid select { height: 34px; }
.csv-preview { font-size: 12px; }
.csv-preview th, .csv-preview td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.csv-preview th.mapped { color: var(--tx); background: var(--ui); }

.carried { color: var(--tx-3); font-style: italic; }
.matrix td.sticky small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* read-only / not-yet-open cells */
.matrix .cell-static { display: block; min-width: 104px; height: 40px; line-height: 40px; padding: 0 10px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--tx-2); cursor: default; }
.matrix .cell-static::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.matrix .cell-static.src-import::before { background: var(--ui-3); }
.matrix .cell-static.src-manual::before { box-shadow: inset 0 0 0 1.5px var(--ui-3); }
.matrix .cell-static.src-xlsx::before { background: var(--ui-2); }
.matrix .cell-static.not-open, .not-open-key {
  background: repeating-linear-gradient(135deg, transparent 0 5px, var(--ui) 5px 6px);
  border-radius: 6px; opacity: .8;
}
.not-open-key { display: inline-block; width: 22px; height: 10px; }
.matrix .cell-static.not-open::before { display: none; }
.locked-row td.sticky a { color: var(--tx-2); }
.lock { display: inline-flex; vertical-align: -2px; margin-right: 5px; color: var(--tx-3); }
.lock svg { width: 13px; height: 13px; }
.matrix th .btn-xs { vertical-align: middle; margin-right: 2px; color: var(--tx-3); }

/* labels of full-width rows stay visible while the grid scrolls sideways */
.matrix .sticky-label { position: sticky; left: 10px; display: inline-flex; gap: 8px; align-items: center; }

/* cash / invested split rows */
.matrix tr.part-row td { border-bottom: 0; padding-top: 0; padding-bottom: 0; }
.matrix tr.part-row + tr:not(.part-row) td { border-top: 1px solid var(--ui); }
.matrix .cell-btn.part, .matrix .cell-static.part { height: 26px; line-height: 26px; font-size: 12px; color: var(--tx-2); }
.matrix .cell-btn.part::before, .matrix .cell-static.part::before { display: none; }
.part-label { display: block; padding-left: 14px; font-size: 12px; color: var(--tx-2); border-left: 1px solid var(--ui-2); margin-left: 4px; }
.derived { color: var(--tx-3); }

/* documents by year */
.doc-year { padding: 12px 16px; }
.doc-year-head { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 4px 0; min-width: 0; }
.doc-year-head .chev svg { width: 15px; height: 15px; color: var(--tx-2); transition: transform .15s; }
.doc-year-head[aria-expanded="true"] .chev svg { transform: rotate(90deg); }
.doc-year-title { font-family: var(--font-serif); font-weight: 700; font-size: 17px; }
.doc-year-names { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }

/* money flows */
.flow-tile { padding: 4px 0; }
.month-stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--ui); border-radius: 8px; background: var(--bg); }
.month-stat b { font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-list { display: flex; flex-direction: column; gap: 7px; }
.cat-row { display: grid; grid-template-columns: 160px minmax(40px, 1fr) 76px 38px; gap: 10px; align-items: center; font-size: 13px; }
.cat-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-bar { height: 8px; background: var(--ui); border-radius: 4px; overflow: hidden; }
.cat-bar i { display: block; height: 100%; border-radius: 4px; }
.cat-row .num { text-align: right; }
@media (max-width: 760px) { .cat-row { grid-template-columns: 120px minmax(30px, 1fr) 64px 32px; } }

/* goals */
.goal-bar { height: 6px; background: var(--ui); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.goal-bar.lg { height: 10px; border-radius: 5px; margin: 8px 0 10px; }
.goal-bar i { display: block; height: 100%; background: var(--s1); border-radius: inherit; }
.goal-now { display: flex; align-items: baseline; justify-content: space-between; }
.goal-facts { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--tx-2); min-height: 20px; }
.goal-facts b { color: var(--tx); font-weight: 600; }
.goal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--ui); font-size: 12.5px; }
.goal-foot svg { width: 13px; height: 13px; vertical-align: -2px; }
.goal-mini-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 24px; }
.goal-mini { text-decoration: none; display: block; padding: 4px 0; }
.goal-mini-top { display: flex; justify-content: space-between; font-weight: 500; font-size: 13.5px; }
.notify-box { border: 1px solid var(--ui); border-radius: 10px; padding: 14px 16px; background: var(--bg); min-width: 0; }
.notify-box h3 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.notify-box h3 svg { width: 16px; height: 16px; }
.steps { margin: 0 0 12px; padding-left: 18px; font-size: 13px; color: var(--tx-2); display: flex; flex-direction: column; gap: 3px; }
.steps b { color: var(--tx); }
code { font-family: var(--font-mono); font-size: 12px; background: var(--ui); padding: 1px 5px; border-radius: 4px; }
.adv { margin: -4px 0 10px; font-size: 12.5px; color: var(--tx-2); }
.adv summary { cursor: pointer; margin-bottom: 6px; }
@media (max-width: 760px) {
  .nav-item { font-size: 9.5px; padding: 6px 2px; }
  .nav-item svg { width: 17px; height: 17px; }
}

/* demo */
.login-or { display: flex; align-items: center; gap: 10px; color: var(--tx-3); font-size: 12px; margin: 10px 0 12px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--ui); }
.login-note { font-size: 12px; margin: 8px 0 0 !important; text-align: center; }
.demo-banner { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 10px;
  background: var(--tx); color: var(--bg); border-radius: 999px; padding: 6px 6px 6px 14px; font-size: 12.5px; font-weight: 500; box-shadow: var(--shadow); white-space: nowrap; }
.demo-banner button { border: 0; border-radius: 999px; background: var(--bg); color: var(--tx); font-size: 12px; font-weight: 600; padding: 4px 10px; }
.dot-demo { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
body.is-demo .main { padding-top: 56px; }
@media (max-width: 760px) { .demo-banner { top: 8px; font-size: 11.5px; } }

.mail-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.field-hint { font-size: 11.5px; color: var(--tx-2); min-height: 15px; }

.key-ring { background: var(--card); box-shadow: inset 0 0 0 2px var(--s1); border-radius: 50%; }
