/* konber — styles. Tokens first; dark mode is its own selected set. */
:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7873;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --pos: #006300;
  --neg: #c12e2e;
  --good: #0ca30c;
  --warn: #b97800;
  --warn-bg: rgba(250, 178, 25, 0.16);
  --bad: #d03b3b;
  --bad-bg: rgba(208, 59, 59, 0.10);
  --good-bg: rgba(12, 163, 12, 0.10);
  --info-bg: rgba(42, 120, 214, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  /* categorical slots (validated order) */
  --c0: #898781; --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #6250d6; --c8: #e34948;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #242423;
    --border: rgba(255, 255, 255, 0.10); --border-strong: rgba(255, 255, 255, 0.18);
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8d86; --grid: #2c2c2a; --axis: #383835;
    --accent: #3987e5; --accent-soft: rgba(57, 135, 229, 0.16);
    --pos: #2fbf2f; --neg: #f07373; --warn: #fab219; --warn-bg: rgba(250, 178, 25, 0.12);
    --bad: #f07373; --bad-bg: rgba(208, 59, 59, 0.16); --good-bg: rgba(12, 163, 12, 0.16); --info-bg: rgba(57, 135, 229, 0.12);
    --shadow: none;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #0ca30c; --c7: #9085e9; --c8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #242423;
  --border: rgba(255, 255, 255, 0.10); --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8d86; --grid: #2c2c2a; --axis: #383835;
  --accent: #3987e5; --accent-soft: rgba(57, 135, 229, 0.16);
  --pos: #2fbf2f; --neg: #f07373; --warn: #fab219; --warn-bg: rgba(250, 178, 25, 0.12);
  --bad: #f07373; --bad-bg: rgba(208, 59, 59, 0.16); --good-bg: rgba(12, 163, 12, 0.16); --info-bg: rgba(57, 135, 229, 0.12);
  --shadow: none;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #0ca30c; --c7: #9085e9; --c8: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; margin: 16px 0; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn-text { color: var(--warn); font-weight: 500; }
.pct { font-size: 0.92em; opacity: 0.9; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 8px; }
.row.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; padding: 18px 12px; border-right: 1px solid var(--border); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); padding: 4px 8px 12px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge { margin-left: auto; background: var(--surface-2); color: var(--text-2); border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.nav a.on .nav-badge { background: var(--accent); color: var(--accent-ink); }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); }
.sidebar-foot .nw { font-size: 18px; font-weight: 650; }
.main { padding: 24px 28px 64px; max-width: 1280px; width: 100%; outline: none; }

/* phone app chrome: hidden on wide screens */
.appbar, .tabbar { display: none; }
@media (max-width: 860px) {
  body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { display: none; }
  .appbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    padding: calc(8px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 8px calc(16px + env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--border); }
  .appbar-brand { display: flex; }
  .appbar-title { flex: 1; font-weight: 650; font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .appbar-add { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
  .offline-pill { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px calc(4px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(4px + env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--border); }
  .tabbar a, .tabbar button { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; justify-content: center;
    border: 0; background: none; font: inherit; font-size: 11px; font-weight: 550; color: var(--muted); cursor: pointer; border-radius: 10px; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .on { color: var(--accent); }
  .tabbar .nav-icon { width: 22px; height: 22px; }
  .tab-badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; line-height: 1; }
  .main { padding: 16px calc(16px + env(safe-area-inset-right)) calc(88px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  .page-head h1 { font-size: 20px; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  /* 16px stops iOS Safari from zooming into focused fields */
  input, select, textarea { font-size: 16px; }
  .pct-input { font-size: 15px; }
  /* the app bar's ＋ covers these on phones */
  .page-head .actions [data-action="new-asset"], .page-head .actions [data-action="new-tx"]:not([data-asset]) { display: none; }
  .page-head .actions:empty, .page-head .actions:not(:has(> :not([data-action="new-asset"]):not([data-action="new-tx"]))) { display: none; }
}

/* ---------- page ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; margin-bottom: 16px; }
.stack > .card, .grid-main > .card, .grid-3 > .card, .tools > .card { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 860px) { .grid-main, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stats.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stats.six { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats, .stats.six { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .stat { padding: 10px 12px; } .stat-value { font-size: 17px; } .stat.hero .stat-value { font-size: 20px; } .stat.hero { grid-column: 1 / -1; } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-value { font-size: 20px; font-weight: 650; margin: 2px 0; overflow-wrap: anywhere; }
.stat.hero .stat-value { font-size: 26px; }
.stat-sub { font-size: 12.5px; color: var(--text-2); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 550; 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.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--bad); border-color: transparent; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled, .btn.busy { opacity: 0.6; cursor: progress; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 13px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link-btn { border: 0; background: none; padding: 0; color: inherit; font: inherit; cursor: pointer; text-align: inherit; }
.link-btn:hover { color: var(--accent); }
button.link-btn.small, .row .link-btn { color: var(--accent); }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; line-height: 1.5; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; margin: 0; flex: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 550; color: var(--text-2); margin-bottom: 12px; min-width: 0; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 13.5px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
label.inline input.search { width: 160px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 0; margin: 0 0 12px; }
legend { font-size: 12.5px; font-weight: 600; padding: 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
[hidden] { display: none !important; }
.hint { font-size: 12.5px; color: var(--muted); }
.search { width: 220px; }
.pct-input { width: 72px; text-align: right; padding: 4px 8px; }
.pct-input.wide { width: 110px; }
.inline-input { border-color: transparent; background: transparent; width: auto; padding: 3px 6px; }
.inline-input:hover { border-color: var(--border-strong); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar select { width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.tags { margin: -4px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 13px; color: var(--text-2); cursor: pointer; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip.on .muted { color: inherit; opacity: 0.7; }
.chip.small { font-size: 12px; padding: 2px 9px; }
.seg-control { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; margin-bottom: 12px; }
.seg-control button { border: 0; background: transparent; font: inherit; font-weight: 550; padding: 5px 14px; border-radius: 7px; color: var(--text-2); cursor: pointer; }
.seg-control button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg-control.small { margin: 0; }
.seg-control.small button { padding: 3px 9px; font-size: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.count { background: var(--surface-2); border-radius: 999px; padding: 0 7px; font-size: 11.5px; margin-left: 4px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--pos); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.tx-buy { background: var(--accent-soft); color: var(--accent); }
.badge.tx-sell { background: var(--surface-2); color: var(--text); }
.badge.tx-income { background: var(--good-bg); color: var(--pos); }
.badge.type-thesis { background: var(--accent-soft); color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; flex: none; }
.dot.lg { width: 12px; height: 12px; margin-right: 2px; }
.live { color: var(--good); font-size: 9px; vertical-align: 2px; }
.stale { color: var(--warn); }

/* ---------- alerts / toasts ---------- */
.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.alert { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--info-bg); font-size: 13.5px; margin-bottom: 12px; }
.alerts .alert { margin: 0; }
.alert.good { background: var(--good-bg); }
.alert.warn { background: var(--warn-bg); }
.alert.bad { background: var(--bad-bg); }
.alert-icon { font-weight: 700; width: 16px; text-align: center; }
.alert.bad .alert-icon { color: var(--bad); }
.alert.warn .alert-icon { color: var(--warn); }
.alert.good .alert-icon { color: var(--pos); }
.alert-text { flex: 1; min-width: 0; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); transition: opacity .3s, transform .3s; }
.toast.error { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast-btn { border: 0; background: rgba(127,127,127,.25); color: inherit; font: inherit; font-weight: 650; padding: 4px 12px; border-radius: 7px; cursor: pointer; }
.toast-btn.ghost { background: transparent; padding: 4px 6px; opacity: .7; }
.form-error { background: var(--bad-bg); color: var(--bad); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-weight: 500; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -2px; }
.table-wrap.scroll-y { max-height: 420px; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.table .num { text-align: right; white-space: nowrap; }
.table.compact th, .table.compact td { padding: 6px 8px; }
.table.compact td:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.table td.date-cell { white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th { border-top: 1px solid var(--border-strong); border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table tr.closed td { opacity: 0.6; }
.table tr.group th { background: var(--surface-2); font-size: 12.5px; padding-top: 7px; padding-bottom: 7px; }
.holdings { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; overflow: hidden; }
.holdings tbody + tbody tr.group th { border-top: 1px solid var(--border); }
.h-name { display: flex; flex-direction: column; }
.trade { font-weight: 600; }
.trade.buy::before { content: "＋ "; color: var(--pos); }
.trade.sell::before { content: "－ "; color: var(--neg); }

/* ---------- charts ---------- */
.chart { width: 100%; min-height: 120px; }
.chart-empty { display: grid; place-items: center; min-height: 160px; color: var(--muted); font-size: 13px; text-align: center; border: 1px dashed var(--border-strong); border-radius: 10px; padding: 16px; }
.line-chart { display: block; overflow: visible; touch-action: pan-y; }
.line-chart .grid { stroke: var(--grid); stroke-width: 1; }
.line-chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.line-chart .line { fill: none; stroke: var(--c1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .area { fill: var(--c1); opacity: 0.1; }
.line-chart .end-dot, .line-chart .hover-dot { fill: var(--c1); stroke: var(--surface); stroke-width: 2; }
.line-chart .cross { stroke: var(--axis); stroke-width: 1; }
.seg-bar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; margin: 4px 0 12px; background: var(--surface); }
.seg-bar.empty { background: var(--surface-2); }
.seg { min-width: 3px; height: 100%; }
.legend { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tbar { position: relative; height: 10px; background: var(--surface-2); border-radius: 4px; min-width: 120px; }
.tbar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; }
.tbar-target { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); border-radius: 1px; transform: translateX(-1px); }
.bar-col { width: 34%; min-width: 140px; }
.tooltip { position: fixed; z-index: 200; pointer-events: none; background: var(--text); color: var(--surface); padding: 7px 10px; border-radius: 8px; font-size: 12.5px; max-width: 280px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.tt-title { opacity: 0.75; font-size: 11.5px; }
.tt-val { font-weight: 650; font-size: 14px; }
.tt-sub { opacity: 0.8; font-size: 11.5px; }
.chips-inline { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; font-size: 13px; }
.kv { display: inline-flex; gap: 6px; }

/* thesis range */
.thesis-range { margin: 8px 0 4px; }
.tr-track { position: relative; height: 8px; margin: 10px 4px 4px; }
.tr-zone { position: absolute; top: 2px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--bad-bg), var(--surface-2) 50%, var(--good-bg)); outline: 1px solid var(--border); }
.tr-mark { position: absolute; top: -3px; width: 14px; height: 14px; border-radius: 50%; transform: translateX(-7px); border: 2px solid var(--surface); }
.tr-mark.entry { background: var(--muted); width: 10px; height: 10px; top: -1px; transform: translateX(-5px); }
.tr-mark.price { background: var(--accent); }
.tr-labels { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.tr-status { font-size: 12.5px; margin-top: 2px; }
.mini-thesis { display: block; color: inherit; padding: 10px 0; border-bottom: 1px solid var(--border); }
.mini-thesis:last-child { border-bottom: 0; }
.mini-thesis:hover { text-decoration: none; }
.mini-thesis:hover strong { color: var(--accent); }

/* ---------- journal ---------- */
.entries { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.entries .card { margin: 0; }
.entry { cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s; }
.entry:hover { border-color: var(--border-strong); }
.entry h3 { margin-top: 2px; }
.prose { font-size: 15px; line-height: 1.65; }
.prose h3, .prose h4, .prose h5 { margin: 16px 0 6px; }
.prose ul, .prose ol { padding-left: 22px; margin: 6px 0 10px; }
.prose ul.checks { list-style: none; padding-left: 4px; }
.prose blockquote { margin: 10px 0; padding: 4px 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.kv-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 8px; font-size: 13.5px; }
.kv-list dt { color: var(--muted); }
.kv-list dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv-list select { width: auto; padding: 3px 8px; }
.todo-list { list-style: none; margin: 0 0 12px; padding: 0; }
.todo { display: flex; align-items: center; justify-content: space-between; gap: 4px 8px; padding: 7px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.todo:last-child { border-bottom: 0; }
.todo label.check { margin: 0; flex: 1 1 160px; min-width: 0; }
.todo-meta { margin-left: auto; }
.todo-text { overflow-wrap: anywhere; }
.todo.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-meta { display: flex; align-items: center; gap: 4px; flex: none; }
.todo-group { font-size: 13px; color: var(--text-2); margin: 16px 0 4px; }
.quick-add { display: flex; gap: 8px; align-items: center; padding: 10px; }
.quick-add input[type="date"] { width: 160px; flex: none; }
@media (max-width: 560px) { .quick-add { flex-wrap: wrap; } .quick-add input[type="date"] { flex: 1; } }

/* ---------- tools ---------- */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 400px) { .tools { grid-template-columns: minmax(0, 1fr); } }
.tool-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; margin-top: 10px; }
.tool-fields .full { grid-column: 1 / -1; }
.tool-out { border-top: 1px solid var(--border); padding-top: 10px; }
.tool-out .kv-list dd strong { font-size: 15px; }

/* ---------- modal ---------- */
.modal { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.modal.wide { width: min(760px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(10, 10, 10, 0.45); }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 8px; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 8px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.spacer { flex: 1; }
/* bottom sheets (More / Add) and phone-sized dialogs */
.sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-bottom: 12px; }
.sheet-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; }
.sheet-btn:hover { border-color: var(--border-strong); }
.sheet-ico { font-size: 20px; color: var(--accent); line-height: 1; }
.sheet-list { display: flex; flex-direction: column; padding-bottom: 8px; }
.sheet-list a, .sheet-list button { display: flex; align-items: center; gap: 14px; padding: 13px 4px; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); font: inherit; font-size: 15px; text-align: left; cursor: pointer; }
.sheet-list a:hover { text-decoration: none; }
.sheet-list .on { color: var(--accent); }
.sheet-list .nav-icon { width: 20px; height: 20px; color: var(--text-2); }
.sheet-list .chev { margin-left: auto; color: var(--muted); font-size: 18px; }
.sheet-nw { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 4px 4px; }
.sheet-nw strong { font-size: 18px; }
.modal.sheet .modal-body { padding-bottom: 16px; }
@media (max-width: 560px) {
  .modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); animation: sheet-up .22s ease-out; }
  .modal.wide { width: 100vw; }
  .modal form { max-height: calc(92vh - env(safe-area-inset-bottom)); }
  .modal-head::before { content: ""; position: absolute; left: 50%; top: 7px; width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); transform: translateX(-50%); }
  .modal-head { position: relative; padding-top: 20px; }
  .modal-foot .btn { flex: 1; justify-content: center; padding: 11px; }
  .modal-foot .spacer { display: none; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } }
.cg-results { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 10px; }
.tx-summary { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; font-size: 13px; min-height: 20px; }
.tx-summary:empty { display: none; }
.bulk-prices { display: flex; flex-direction: column; }
.bulk-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 8px 0; border-bottom: 1px solid var(--border); font-weight: 400; color: var(--text); font-size: 13.5px; }
.input-cur { display: flex; align-items: center; gap: 6px; flex: none; }
.input-cur input { width: 130px; text-align: right; }

/* ---------- empty / welcome ---------- */
.empty { text-align: center; color: var(--muted); padding: 20px 12px; }
.empty p { margin-bottom: 12px; }
.welcome { padding: 28px; max-width: 760px; }
.welcome h2 { font-size: 20px; margin-bottom: 8px; }
.steps { padding-left: 20px; line-height: 1.9; margin: 12px 0 20px; }

@media (forced-colors: active) {
  .seg, .tbar-fill, .dot, .swatch { forced-color-adjust: none; }
}
@media print {
  .sidebar, .actions, .btn, .icon-btn { display: none !important; }
  .shell { display: block; }
}
