/* ---------- tokens ----------
   Design language modelled on Claude's interface: warm ivory / charcoal neutrals,
   clay accent, serif display type with a clean sans for UI. Values are approximations
   (Claude's own fonts are proprietary; Source Serif 4 stands in for the display serif). */
@font-face { font-family: "Source Serif 4"; src: url("../vendor/fonts/source-serif-4.woff2") format("woff2"); font-weight: 200 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Serif 4"; src: url("../vendor/fonts/source-serif-4-ext.woff2") format("woff2"); font-weight: 200 900; font-display: swap; unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
:root {
  color-scheme: light;
  --bg: #faf9f5;
  --sidebar-bg: #f5f4ed;
  --surface: #ffffff;
  --surface-2: #f5f4ed;
  --surface-3: #ebe9df;
  --border: #e5e2d7;
  --border-strong: #d3cfc2;
  --text-1: #141413;
  --text-2: #3d3d3a;
  --text-3: #73726c;
  --grid: #eeece4;
  --axis: #d3cfc2;
  --neutral: #a8a69d;
  --tooltip-bg: #ffffff;
  --accent: #c96442;
  --accent-ink: #ffffff;
  --accent-soft: #f7e9e2;
  --pnl-pos: #3d7d3a;
  --pnl-neg: #b5372b;
  --cvd-pos: #2a78d6;
  --cvd-neg: #e0661f;
  --pos-text: #3d7d3a;
  --neg-text: #b5372b;
  --pos-soft: #e7f0e3;
  --neg-soft: #f7e3e0;
  --warn: #9a6a00;
  /* categorical chart palette — validated for colour-vision deficiency, fixed order */
  --series-1: #c96442; --series-2: #2a78d6; --series-3: #1baf7a; --series-4: #8a5cc4;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #b58a12;
  --shadow: 0 1px 2px rgba(20, 20, 19, .04), 0 2px 8px rgba(20, 20, 19, .03);
  --radius: 12px;
  --sidebar-w: 248px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-serif: "Source Serif 4", "Tiempos Text", Georgia, "Times New Roman", serif;
  font-family: var(--font-sans);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #262624;
  --sidebar-bg: #1f1e1d;
  --surface: #30302e;
  --surface-2: #3a3936;
  --surface-3: #45443f;
  --border: #3f3e3a;
  --border-strong: #55534d;
  --text-1: #faf9f5;
  --text-2: #c2c0b6;
  --text-3: #9c9a92;
  --grid: #3a3936;
  --axis: #55534d;
  --neutral: #7a7870;
  --tooltip-bg: #1f1e1d;
  --accent: #d97757;
  --accent-ink: #1f1e1d;
  --accent-soft: #46302a;
  --pnl-pos: #7fbf73;
  --pnl-neg: #ec8a7c;
  --cvd-pos: #3987e5;
  --cvd-neg: #e0883a;
  --pos-text: #8fcb84;
  --neg-text: #f09a8d;
  --pos-soft: #2c3a29;
  --neg-soft: #46302c;
  --warn: #e7b84a;
  --series-1: #d4704f; --series-2: #3987e5; --series-3: #199e70; --series-4: #9d7be0;
  --series-5: #d55181; --series-6: #2f9a2f; --series-7: #7f74e0; --series-8: #ad861a;
  --shadow: none;
}
:root[data-pnl="blueorange"] { --pos-text: #1f6fcf; --neg-text: #b8501a; }
:root[data-theme="dark"][data-pnl="blueorange"] { --pos-text: #6aa8f0; --neg-text: #ec9a5c; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text-1); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-family: var(--font-serif); font-size: 28px; font-weight: 500; margin: 0; letter-spacing: -0.01em; }
h2 { font-family: var(--font-serif); font-size: 17px; font-weight: 550; margin: 0; letter-spacing: -0.005em; }
h3 { font-size: 12px; font-weight: 600; margin: 0 0 8px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
p { margin: 0 0 10px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.pos { color: var(--pos-text); }
.neg { color: var(--neg-text); }
.flat { color: var(--text-2); }
.num, table.data td.num, table.data th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
pre.err { white-space: pre-wrap; background: var(--surface-2); padding: 12px; border-radius: 8px; font-size: 12px; }
kbd { font: 11px ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }

/* ---------- layout ---------- */
.topbar { display: none; }
#sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 14px; overflow-y: auto; z-index: 20;
}
#main { margin-left: var(--sidebar-w); min-height: 100vh; }
.page { max-width: 1320px; margin: 0 auto; padding: 24px 28px 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-serif); font-weight: 600; font-size: 19px; color: var(--text-1); padding: 4px 6px; }
.brand:hover { text-decoration: none; }
.beta { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 2px 5px; margin-left: -2px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M7 22l6-7 5 4 7-10' stroke='white' stroke-width='3.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; }
:root[data-theme="dark"] .brand-mark { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M7 22l6-7 5 4 7-10' stroke='%231d1c1a' stroke-width='3.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
/* segmented switches — same pattern as bruh-lad's theme switch */
.section-switch, .mode-switch, .seg, .theme-switch { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.section-switch a, .mode-switch button, .seg button, .theme-switch button {
  flex: 1; text-align: center; padding: 6px 8px; color: var(--text-3); font-weight: 550; font-size: 13px; border: 0; background: none; cursor: pointer; font-family: inherit;
}
.section-switch > * + *, .mode-switch > * + *, .seg > * + *, .theme-switch > * + * { border-left: 1px solid var(--border); }
.section-switch a:hover, .mode-switch button:hover, .seg button:hover, .theme-switch button:hover { text-decoration: none; color: var(--text-1); background: var(--surface-2); }
.section-switch a.on, .mode-switch button.on, .seg button.on, .theme-switch button[aria-checked="true"] { background: var(--accent-soft); color: var(--text-1); font-weight: 650; }
.theme-switch button { padding: 5px 6px; font-size: 12.5px; }
.switch-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; margin: 0 2px -8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { display: flex; align-items: center; gap: 2px; padding: 10px 0 2px; }
.nav-toggle { flex: 1; display: flex; align-items: center; gap: 6px; padding: 4px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; font: 600 11px var(--font-sans); color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; text-align: left; }
.nav-toggle:hover { color: var(--text-1); background: var(--surface-2); }
.nav-chev { flex: none; transition: transform .18s ease; }
.nav-section.shut .nav-chev { transform: rotate(-90deg); }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 2px; }
.nav-grip { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: var(--text-3); cursor: grab; touch-action: none; opacity: 0; transition: opacity .15s; }
.nav-section:hover .nav-grip, .nav-grip:focus-visible, .nav-section.dragging .nav-grip { opacity: 1; }
.nav-grip:hover { background: var(--surface-2); color: var(--text-1); }
.nav-section.dragging { background: var(--surface-2); border-radius: 8px; box-shadow: var(--shadow); }
.nav-section.dragging .nav-grip { cursor: grabbing; }
.nav-items { display: flex; flex-direction: column; gap: 2px; }
@media (hover: none) { .nav-grip { opacity: .55; } }
.help-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: 600 16px var(--font-serif); cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow); }
.help-btn:hover { color: var(--accent); border-color: var(--accent); }
.help-fixed { position: fixed; top: 16px; right: 20px; z-index: 25; }
.nav a, .sidebar-foot a, .theme-btn {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--text-2); font-weight: 500; font-size: 13.5px;
  background: none; border: 0; cursor: pointer; font-family: inherit; text-align: left; width: 100%;
}
.nav a:hover, .sidebar-foot a:hover, .theme-btn:hover { background: var(--surface-2); color: var(--text-1); text-decoration: none; }
.nav a.active, .sidebar-foot a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }

.page > .page-head:first-child, .page > .notice:first-child { margin-right: 46px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-3); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head .hint { color: var(--text-3); font-size: 12px; }
.chart { position: relative; height: 260px; }
.chart.tall { height: 320px; }
.chart.short { height: 180px; }
.chart.xs { height: 120px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stats.big { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--text-3); display: flex; align-items: center; flex-wrap: wrap; gap: 2px 4px; line-height: 1.35; min-width: 0; }
.stat-label .tag { margin: 0; }
.stat-value { font-family: var(--font-serif); font-size: 22px; font-weight: 550; font-variant-numeric: lining-nums; margin-top: 4px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats.big .stat-value { font-size: 27px; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.35; overflow-wrap: anywhere; }
.tip { display: inline-grid; place-items: center; width: 15px; height: 15px; margin: 0 2px 0 5px; vertical-align: 1px; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--text-3); font: 600 10px/1 inherit; font-family: inherit; text-transform: none; letter-spacing: 0; cursor: help; user-select: none; flex: none; }
.tip:hover, .tip:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }
.tip-bubble { position: fixed; z-index: 1000; max-width: min(300px, calc(100vw - 16px)); padding: 8px 11px; border-radius: 8px; background: var(--text-1); color: var(--bg); font-size: 12.5px; line-height: 1.45; font-weight: 450; text-transform: none; letter-spacing: 0; box-shadow: 0 4px 16px rgba(0, 0, 0, .18); pointer-events: none; }
.tip-bubble[hidden] { display: none; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 8px; display: flex; gap: 2px; }
.meter > span { display: block; height: 100%; border-radius: 3px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv.cols2 { grid-template-columns: auto 1fr auto 1fr; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-1); font: 550 13px/1.2 inherit; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--neg-text); }
.btn.ghost { border-color: transparent; background: none; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.icon-btn { background: none; border: 0; color: var(--text-2); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text-1); }
input, select, textarea {
  font: inherit; font-size: 13px; color: var(--text-1); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 7px 9px; min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 70px; width: 100%; line-height: 1.5; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
[hidden] { display: none !important; }   /* components set display:flex/grid — hidden must always win */
label.field { display: flex; flex-direction: column; justify-content: flex-end; gap: 5px; font-size: 12px; color: var(--text-2); font-weight: 550; min-width: 0; }
label.field input, label.field select, label.field textarea { width: 100%; font-weight: 400; }
label.field .hint { margin-top: -3px; }
label.field .hint { font-weight: 400; color: var(--text-3); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.form-grid .span2 { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; background: var(--surface); }
legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 12px; cursor: pointer; color: var(--text-2); user-select: none; }
.chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); }
.chip-add { width: 90px; padding: 4px 9px; border-radius: 999px; font-size: 12px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 11.5px; margin: 1px 2px 1px 0; white-space: nowrap; }
.tag.bad { background: var(--neg-soft); color: var(--neg-text); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.pill { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 650; letter-spacing: .03em; }
.pill.long { background: var(--pos-soft); color: var(--pos-text); }
.pill.short { background: var(--neg-soft); color: var(--neg-text); }
.pill.open { background: var(--accent-soft); color: var(--accent); }
.grade { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); font-weight: 700; font-size: 12px; }

/* ---------- filter bar ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.filters select, .filters input { padding: 6px 8px; }
.filters .count { margin-left: auto; color: var(--text-3); font-size: 12px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text-1); }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.click { cursor: pointer; }
table.data tbody tr.click:hover { background: var(--surface-2); }
table.data tfoot td { font-weight: 650; border-top: 1px solid var(--border-strong); }
table.compact td, table.compact th { padding: 6px 10px; }
.sym { font-weight: 650; }

/* month heat table */
table.heat td { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; padding: 7px 8px; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(0, 1.1fr); gap: 6px; }
.cal .dow { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 0 4px 2px; }
.cal .cell { min-height: 84px; border-radius: 8px; border: 1px solid var(--border); padding: 6px 8px; background: var(--surface); display: flex; flex-direction: column; gap: 2px; cursor: default; position: relative; min-width: 0; }
.cal .cell.out { opacity: .35; }
.cal .cell.has { cursor: pointer; }
.cal .cell.has:hover { border-color: var(--border-strong); }
.cal .cell .d { font-size: 11px; color: var(--text-3); }
.cal .cell .v { font-weight: 650; font-size: 14px; margin-top: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .cell .n { font-size: 11px; color: var(--text-3); }
.cal .v-short { display: none; }
.cal .cell.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal .cell .jn { position: absolute; top: 6px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal .week { background: var(--surface-2); border-color: transparent; }
.cal-nav { display: flex; gap: 8px; align-items: center; }
.cal-nav .title { font-weight: 650; font-size: 16px; min-width: 150px; text-align: center; }

/* year heatmap */
.yearmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.yearmap span { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-3); }

/* ---------- trade form ---------- */
.exec-table input, .exec-table select { width: 100%; padding: 5px 7px; }
.exec-table td { padding: 5px 6px; }
.form-actions { position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.calc-preview { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.calc-preview b { font-variant-numeric: tabular-nums; }
.shots { display: flex; gap: 10px; flex-wrap: wrap; }
.shot { position: relative; width: 160px; height: 100px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.shot img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.shot button { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 5px; cursor: pointer; font-size: 12px; padding: 2px 6px; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 8px; padding: 14px; text-align: center; color: var(--text-3); font-size: 12.5px; cursor: pointer; }
.dropzone.over { border-color: var(--accent); color: var(--accent); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 100; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 6px; }
.checklist { display: flex; flex-direction: column; gap: 6px; }

/* ---------- modal / toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: min(520px, 100%); max-height: 90vh; max-height: 90dvh; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.modal.wide { width: min(880px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 18px; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.modal footer { flex: none; flex-wrap: wrap; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { max-width: min(560px, 92vw); background: var(--text-1); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 550; transition: opacity .3s; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.error { background: var(--pnl-neg); color: #fff; }
.toast.out { opacity: 0; }

/* ---------- notices ---------- */
.notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); font-size: 13px; }

/* ---------- empty / home ---------- */
.empty { text-align: center; padding: 40px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-2); }
.empty-title { font-weight: 650; font-size: 15px; color: var(--text-1); margin-bottom: 6px; }
.empty .btn { margin: 4px; }
.hero { padding: 40px 0 24px; }
.hero h1 { font-size: 40px; letter-spacing: -0.02em; }
.hero p { color: var(--text-2); font-size: 15px; max-width: 640px; margin-top: 10px; }
.choice { display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); color: var(--text-1); transition: border-color .15s, transform .15s; }
.choice:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.choice h2 { font-size: 19px; }
.choice ul { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; line-height: 1.7; }
.choice .go { color: var(--accent); font-weight: 600; margin-top: auto; }
.choice .mini { display: flex; gap: 14px; font-size: 12px; color: var(--text-3); }
.choice .mini b { color: var(--text-1); font-size: 16px; display: block; }
.note { background: var(--accent-soft); color: var(--text-1); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; }
.note.warn { background: var(--accent-soft); }
.callout-list { display: flex; flex-direction: column; gap: 8px; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.callout .ic { font-weight: 700; width: 18px; flex: none; text-align: center; }
.callout.good .ic { color: var(--pos-text); }
.callout.bad .ic { color: var(--neg-text); }
.callout.warn .ic { color: var(--warn); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; font: 550 13px inherit; font-family: inherit; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text-1); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--text-1); }

.md { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; color: var(--text-1); }
.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.progress { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .help-fixed { display: none; }
  .stats, .stats.big { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stats.big .stat-value { font-size: 22px; }
  .stat { padding: 10px 12px; }
  h1 { font-size: 24px; }
  .page > .page-head:first-child, .page > .notice:first-child { margin-right: 0; }
  .topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 12px; }
  #sidebar { transform: translateX(-100%); transition: transform .2s; top: 49px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
  body.nav-open #sidebar { transform: none; }
  #main { margin-left: 0; }
  .page { padding: 16px 16px 64px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .cal { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .cal .week, .cal .dow.wk { display: none; }
  .cal .cell { min-height: 58px; padding: 4px; }
  .cal .cell .v { font-size: 10px; letter-spacing: -0.02em; text-overflow: clip; }
  .cal .v-full { display: none; }
  .cal .v-short { display: inline; }
  .cal .cell .jn { top: 5px; right: 5px; width: 5px; height: 5px; }
  .cal .cell .n { display: none; }
  .form-grid .span2 { grid-column: auto; }
  .kv.cols2 { grid-template-columns: auto 1fr; }
  .hero h1 { font-size: 26px; }
}
@media print {
  #sidebar, .topbar, .filters, .page-head .actions, .form-actions { display: none !important; }
  #main { margin: 0; }
}

/* ---------- journal ---------- */
.seg.rate { display: inline-flex; width: auto; }
.seg.rate button { padding: 5px 8px; font-size: 14px; flex: none; min-width: 30px; }
.pos-check { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
details.fold { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 16px; }
details.fold > summary { cursor: pointer; font-family: var(--font-serif); font-weight: 550; font-size: 15px; }
.entry-row { padding: 6px 8px; border-radius: 8px; color: var(--text-1); }
.entry-row:hover, .entry-row.on { background: var(--accent-soft); text-decoration: none; }
.entry { display: block; padding: 12px 4px; border-bottom: 1px solid var(--border); color: var(--text-1); }
.entry:hover { background: var(--surface-2); text-decoration: none; }
.entry .small { margin-top: 4px; color: var(--text-2); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cal.cal7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal a.cell { color: var(--text-1); }
.cal a.cell:hover { text-decoration: none; border-color: var(--border-strong); }
.cal .jmood { position: absolute; top: 4px; right: 6px; font-size: 15px; }
.cal .cell .n.ellipsis { font-size: 11px; color: var(--text-3); }
/* ---------- positions ---------- */
.dist { font-size: 11.5px; color: var(--text-3); }
.heat-bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.heat-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.timeline { border-left: 2px solid var(--border-strong); margin-left: 6px; padding-left: 14px; display: flex; flex-direction: column; gap: 10px; }
.timeline .t { position: relative; font-size: 13px; }
.timeline .t::before { content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
/* ---------- live ticker ---------- */
.ticker { font-family: var(--font-serif); font-variant-numeric: tabular-nums; }
/* ---------- overview todo ---------- */
.todo { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-1); font-size: 13.5px; }
.todo:hover { background: var(--surface-2); text-decoration: none; }
.todo .box { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; font-size: 12px; color: var(--accent-ink); flex: none; }
.todo.done { color: var(--text-3); text-decoration: line-through; }
.todo.done .box { background: var(--accent); border-color: var(--accent); }
.ticker-card .stat-value { font-size: 30px; }
/* ---------- help drawer ---------- */
.drawer-wrap { position: fixed; inset: 0; background: rgba(20, 20, 19, .35); z-index: 60; display: flex; justify-content: flex-end; }
.drawer { width: min(440px, 100%); height: 100%; background: var(--bg); border-left: 1px solid var(--border); display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.15); animation: slide-in .18s ease-out; }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-body { padding: 16px 20px 40px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.help-here { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-top: 6px; }
.help-text { font-size: 13.5px; color: var(--text-2); line-height: 1.6; }
.help-text ul { padding-left: 18px; margin: 6px 0; }
.help-text li { margin: 4px 0; }
.help-item { border-bottom: 1px solid var(--border); padding: 8px 2px; }
.help-item summary { cursor: pointer; font-weight: 550; font-size: 14px; }
/* ---------- tour ---------- */
.tour { position: fixed; inset: 0; z-index: 90; }
.tour-spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(20, 20, 19, .55); transition: all .25s ease; pointer-events: none; }
.tour-card { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: 0 12px 40px rgba(0,0,0,.25); width: 340px; transition: left .25s, top .25s; }
.tour-card h2 { margin: 4px 0 6px; }
.tour-card p { font-size: 13.5px; color: var(--text-2); }
.btn.wrap { white-space: normal; text-align: left; max-width: 100%; height: auto; }
.field-label { display: inline; }
/* Simple account type picker */
.type-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; margin-top: 6px; }
.type-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: 400; }
.type-opt:hover { border-color: var(--border-strong); }
.type-opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: var(--surface-2); }
.type-opt input { margin-top: 3px; accent-color: var(--accent); }
.type-opt b { display: block; font-size: 14px; color: var(--text-1); }
.type-opt small { display: block; font-size: 12px; line-height: 1.4; color: var(--text-3); margin-top: 2px; }
/* Input mode chooser */
.mode-choose { max-width: 820px; margin: 6vh auto 0; text-align: center; }
.mode-choose > p { max-width: 620px; margin-left: auto; margin-right: auto; }
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 22px 0 14px; text-align: left; }
.mode-cards.compact { margin: 10px 0 0; gap: 10px; }
.mode-card { display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--text-1); font: inherit; text-align: left; cursor: pointer; }
.mode-card:hover { border-color: var(--accent); }
.mode-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; cursor: default; }
.mode-title { font-family: var(--font-serif); font-size: 22px; font-weight: 600; }
.mode-cards.compact .mode-title { font-size: 17px; }
.mode-lead { color: var(--text-2); font-size: 14px; }
.mode-card ul { margin: 6px 0 0; padding-left: 18px; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.mode-cards.compact .mode-card ul { font-size: 12.5px; }
.mode-badge { font-size: 11.5px; color: var(--text-3); padding: 6px 10px 0; }
.mode-badge b { color: var(--text-2); font-weight: 600; }
.mode-badge a, .sidebar-foot .mode-badge a { display: inline; padding: 0; margin: 0; font-size: inherit; font-weight: 400; background: none; color: var(--text-3); text-decoration: underline; }
.mode-badge a:hover { color: var(--accent); }

/* ---------- spending ---------- */
.add-main { width: 100%; justify-content: center; margin: 2px 0 10px; }
.topbar [data-quick-add] { margin-right: 6px; }
.month-nav { display: flex; gap: 6px; align-items: center; border: 0; }
.month-nav .title { font-weight: 650; font-size: 15px; min-width: 130px; text-align: center; }
.month-nav > * + * { border-left: 0 !important; }
.type-seg { display: inline-flex; width: auto; }
.type-seg button { padding: 6px 18px; font-size: 14px; }
.amount-input { font-size: 20px !important; font-weight: 600 !important; font-variant-numeric: tabular-nums; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cat-chip { cursor: pointer; }
.cat-chip input { position: absolute; opacity: 0; pointer-events: none; }
.cat-chip span { display: inline-block; padding: 6px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 450; color: var(--text-1); white-space: nowrap; }
.cat-chip:hover span { border-color: var(--border-strong); }
.cat-chip input:checked + span { border-color: var(--accent); background: var(--surface-2); box-shadow: 0 0 0 1px var(--accent) inset; font-weight: 600; }
.cat-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.txn-list { display: flex; flex-direction: column; gap: 14px; }
.txn-list.flat { gap: 2px; }
.txn-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.txn-day-head { display: flex; justify-content: space-between; padding: 8px 14px; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.txn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 14px; border: 0; background: transparent; color: var(--text-1); font: inherit; text-align: left; cursor: pointer; }
.txn + .txn { border-top: 1px solid var(--border); }
.txn-list.flat .txn { padding: 7px 6px; border-radius: 8px; }
.txn-list.flat .txn + .txn { border-top: 0; }
.txn:hover { background: var(--surface-2); }
.txn-ic { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; font-size: 17px; }
.txn-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.txn-main b { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-main .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-amt { display: flex; flex-direction: column; align-items: flex-end; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-mini { position: relative; height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: visible; }
.bar-mini.lg { height: 9px; margin: 4px 0; }
.bar-mini span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar-mini span.warn { background: var(--warn); }
.bar-mini span.over { background: var(--pnl-neg); }
.bar-mini span.good { background: var(--pnl-pos); }
.bar-mini i, .budget-bar i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); border-radius: 1px; }
.budget-bar { position: relative; height: 14px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 6px; }
.budget-bar span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.budget-bar span.warn { background: var(--warn); }
.budget-bar span.over { background: var(--pnl-neg); }
.nws + .nws { margin-top: 12px; }
.nws .row { gap: 8px; }
.upcoming { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; }
.upcoming.col { grid-template-columns: 1fr; }
.up-item { display: grid; grid-template-columns: 90px 1fr auto; gap: 8px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.up-item > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .cell.sel { box-shadow: inset 0 0 0 2px var(--text-1); }
.legend-sq { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); margin: 0 4px 0 8px; vertical-align: -2px; }
.filters input[type=search] { flex: 1; min-width: 180px; }
@media (max-width: 700px) {
  .up-item { grid-template-columns: 74px 1fr auto; }
  .month-nav .title { min-width: 0; font-size: 14px; }
  .txn { padding: 9px 10px; gap: 10px; }
}
.tabs a { padding: 9px 14px; font-size: 13px; font-weight: 550; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text-1); text-decoration: none; }
.tabs a.on { color: var(--text-1); border-bottom-color: var(--accent); }
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.sub-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-1); font: inherit; text-align: left; cursor: pointer; min-width: 0; }
.sub-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.sub-day { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 54px; height: 46px; flex: none; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); line-height: 1.1; }
.sub-day b { font-size: 17px; }
.sub-day small { font-size: 8.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.sub-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sub-main b, .sub-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.side-actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 6px; margin: 2px 0 10px; }
.side-actions .btn { justify-content: center; padding: 7px 8px; }
.tag.est { font-family: var(--font-sans); letter-spacing: 0; background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--text-2); border-color: transparent; font-size: 10.5px; font-weight: 600; text-transform: lowercase; vertical-align: 2px; cursor: help; }
.onboard { max-width: 760px; margin: 4vh auto 0; }
.onboard > p { max-width: 680px; }
.est-form .form-sep { border-top: 1px solid var(--border); margin: 4px 0; }

/* accounts grouped by type */
.type-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.type-chip { display: inline-flex; gap: 8px; align-items: baseline; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 13px; text-decoration: none; }
.type-chip:hover { border-color: var(--accent); color: var(--text); }
.type-chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.type-chip b.neg { color: var(--neg-text); }
[id^="grp-"] { scroll-margin-top: 70px; }
.acct-row .deductf .hint { font-weight: 400; }
.acct-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: baseline; color: var(--text); text-decoration: none; padding: 2px 0; }
.acct-row:hover .ellipsis { color: var(--accent); }
.first-snap { display: flex; flex-direction: column; justify-content: center; gap: 14px; flex: 1; }

/* light ↔ dark: a gentle cross-fade instead of a flash */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .45s; animation-timing-function: cubic-bezier(.4, 0, .2, 1); }
.theme-fading, .theme-fading *, .theme-fading *::before, .theme-fading *::after { transition: background-color .4s ease, color .4s ease, border-color .4s ease, fill .4s ease, stroke .4s ease, box-shadow .4s ease !important; }

/* no dead space: cards in a row are equal height, and a chart fills whatever height its card gets */
.grid > .card { display: flex; flex-direction: column; }
.grid > .card > .chart:last-child { flex: 1 1 auto; height: auto; min-height: 260px; }
.grid > .card > .chart.tall:last-child { min-height: 320px; }
.grid > .card > .chart.short:last-child { min-height: 180px; }
.grid > .card > .chart:last-child > canvas { position: absolute; inset: 0; }
.grid > .card > .table-wrap:last-child { flex: 1 1 auto; }
/* net worth by type (single balance update) */
.breakdown { display: flex; flex-direction: column; gap: 12px; }
.bd-row { display: grid; grid-template-columns: minmax(110px, 1.1fr) minmax(60px, 2fr) auto 52px; gap: 12px; align-items: center; font-size: 14px; }
.bd-label { display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bd-label .dot { flex: none; margin: 0; }
.grid > .card > :is(a, button, .btn) { align-self: flex-start; }
.bd-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bd-bar > span { display: block; height: 100%; border-radius: 999px; }
.bd-row b { font-variant-numeric: tabular-nums; text-align: right; }
.bd-pct { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .bd-row { grid-template-columns: minmax(0, 1fr) auto 44px; } .bd-bar { display: none; } }
/* a lone last stat on a 2-column phone grid takes the full row */
@media (max-width: 900px) { .stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; } }
.seg.sm button { padding: 3px 10px; font-size: 12px; }
.journal-side { position: sticky; top: 16px; align-self: start; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.week-strip a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 8px; color: var(--text); text-decoration: none; }
.week-strip a:hover { background: var(--surface-2); }
.week-strip a.on { background: var(--accent-soft); }
.wk-mood { font-size: 18px; line-height: 1.2; }
@media (max-width: 1100px) { .journal-side { position: static; } }
