:root {
  color-scheme: light;
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f2f3ef;
  --border: #e3e6df;
  --text: #0e1311;
  --text-2: #4a524e;
  --muted: #7b837e;
  --grid: #ebede8;
  --grid-strong: #d3d8d1;
  --s1: #2a78d6;   /* blue: saved, income, net worth (validated chart pair) */
  --s2: #eb6834;   /* orange: owed, spending */
  --seq: #2a78d6;
  --good: #0ca30c;
  --good-text: #0a7a4f;
  --bad: #d03b3b;
  --warn: #fab219;
  --accent: #0f8f74;
  --accent-2: #0b6e6a;
  --accent-soft: rgba(15, 143, 116, .10);
  --ring: rgba(15, 143, 116, .28);
  --shadow: 0 1px 2px rgba(16, 24, 20, .04), 0 10px 30px -18px rgba(16, 24, 20, .18);
  --shadow-hover: 0 2px 4px rgba(16, 24, 20, .05), 0 18px 40px -18px rgba(16, 24, 20, .28);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f0e; --surface: #121816; --surface-2: #19211e; --border: #24302b;
    --text: #eef2ef; --text-2: #b7c2bc; --muted: #84908a; --grid: #1c2421; --grid-strong: #33403a;
    --s1: #3987e5; --s2: #d95926; --seq: #3987e5; --good-text: #3fcf8e;
    --accent: #22c39a; --accent-2: #12977a; --accent-soft: rgba(34, 195, 154, .12); --ring: rgba(34, 195, 154, .35);
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -20px rgba(0, 0, 0, .7);
    --shadow-hover: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 20px 44px -20px rgba(0, 0, 0, .85);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f0e; --surface: #121816; --surface-2: #19211e; --border: #24302b;
  --text: #eef2ef; --text-2: #b7c2bc; --muted: #84908a; --grid: #1c2421; --grid-strong: #33403a;
  --s1: #3987e5; --s2: #d95926; --seq: #3987e5; --good-text: #3fcf8e;
  --accent: #22c39a; --accent-2: #12977a; --accent-soft: rgba(34, 195, 154, .12); --ring: rgba(34, 195, 154, .35);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -20px rgba(0, 0, 0, .7);
  --shadow-hover: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 20px 44px -20px rgba(0, 0, 0, .85);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
  display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--grid-strong) transparent; }

/* ---------- sidebar ---------- */
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px; }
.brand .logo { width: 36px; height: 36px; flex: none; filter: drop-shadow(0 6px 14px rgba(15, 143, 116, .35)); transition: transform .5s var(--ease); }
.brand:hover .logo { transform: rotate(-8deg) scale(1.06); }
.brand b { font-size: 18px; letter-spacing: -.02em; display: block; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 11.5px; }
nav { display: flex; flex-direction: column; gap: 18px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 12px 6px; }
nav button { position: relative; display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; background: none; border: 0;
  padding: 9px 12px; border-radius: 10px; cursor: pointer; color: var(--text-2); font-weight: 500;
  transition: background .2s var(--ease), color .2s var(--ease), transform .15s var(--ease); }
nav button svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .3s var(--ease); }
nav button:hover { background: var(--surface-2); color: var(--text); }
nav button:hover svg { transform: scale(1.12); }
nav button:active { transform: scale(.98); }
nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
nav button::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent); transform: scaleY(0); transition: transform .3s var(--ease); }
nav button.active::before { transform: scaleY(1); }
.ask-group { margin-top: auto; }
.ask-group button { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 650;
  box-shadow: 0 10px 24px -12px var(--accent); padding: 11px 14px; }
.ask-group button:hover { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; filter: brightness(1.08);
  box-shadow: 0 14px 30px -12px var(--accent); }
.ask-group button.active { color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.ask-group button::before { display: none; }

main { max-width: 1240px; width: 100%; margin: 0 auto; padding: 30px 36px 70px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.025em; font-weight: 720; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.tab { display: none; }
.tab.active { display: block; animation: rise .45s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.tab.active > * { animation: rise .5s var(--ease) both; }
.tab.active > *:nth-child(2) { animation-delay: .04s; } .tab.active > *:nth-child(3) { animation-delay: .08s; }
.tab.active > *:nth-child(4) { animation-delay: .12s; } .tab.active > *:nth-child(n+5) { animation-delay: .16s; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
  margin-bottom: 16px; min-width: 0; transition: box-shadow .3s var(--ease), border-color .3s var(--ease); }
.card:hover { box-shadow: var(--shadow-hover); border-color: var(--grid-strong); }
.card.flush { padding: 0; overflow-x: auto; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.card h4 { margin: 16px 0 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 .card { margin-bottom: 0; }
.grid2 + .card, .card + .grid2 { margin-top: 16px; }
.wide { grid-column: 1 / -1; }
.muted { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.month-bar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
label { color: var(--text-2); display: inline-flex; gap: 8px; align-items: center; }

button { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 15px; cursor: pointer;
  transition: background .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease), transform .12s var(--ease), filter .2s; }
button:hover { background: var(--surface-2); border-color: var(--grid-strong); }
button:active { transform: scale(.97); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 8px 20px -12px var(--accent); }
button.primary:hover { filter: brightness(1.08); box-shadow: 0 12px 26px -12px var(--accent); }
button.ghost { background: none; }
button.danger { color: var(--bad); }
button.icon { border: 0; background: none; padding: 4px 8px; color: var(--muted); }
button.icon:hover { color: var(--bad); }
input, select { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px; min-width: 0;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
input:hover, select:hover { border-color: var(--grid-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
button:focus-visible, [tabindex]:focus-visible, a:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.inline { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.inline input { flex: 1 1 160px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tiles.small { margin: 14px 0 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease); }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: var(--grid-strong); }
.tiles.small .tile:hover { transform: none; box-shadow: none; }
.tiles.small .tile { box-shadow: none; background: var(--surface-2); border: 0; }
.tile .label { color: var(--text-2); font-size: 12.5px; }
.tile .value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 3px; }
.tile.hero { background: radial-gradient(120% 140% at 0% 0%, var(--accent-soft), transparent 60%), var(--surface); }
.tile.hero .value { font-size: 30px; }
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.up { color: var(--good-text); }
.down { color: var(--bad); }

.chart { position: relative; height: 240px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: hidden; }  /* nothing ever draws over the next card */
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin: -4px 0 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.barlist { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 10px; background: var(--surface-2); border-radius: 4px; position: relative; }
.bar-row .fill { height: 100%; background: var(--seq); border-radius: 4px; min-width: 2px; }
.bar-row .fill.over { background: var(--bad); }
.bar-row .budget { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); border-radius: 1px; }
.bar-row .amt { text-align: right; min-width: 90px; }
.bar-row .amt small { display: block; color: var(--muted); font-size: 11px; }
.bar-row .amt small.over { color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface-2); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.chip b { font-weight: 600; margin-left: 6px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
.filters input { flex: 1 1 220px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .desc { color: var(--muted); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl select { padding: 3px 6px; font-size: 12.5px; }
.tbl .pos { color: var(--good-text); }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }

.list { display: grid; gap: 6px; }
.list .item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 9px 12px; background: var(--surface-2);
  border-radius: 10px; font-size: 13px; border: 1px solid transparent; transition: border-color .2s var(--ease), background .2s var(--ease); }
.list .item:hover { border-color: var(--border); }
.list .item .r { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.list .item.err { color: var(--bad); }
.list .item.ok::before { content: "✓"; color: var(--good-text); margin-right: 6px; }

.progress { height: 14px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.progress div { height: 100%; background: var(--seq); border-radius: 6px; transition: width .4s; }
.progress div.full { background: var(--good); }

.drop { display: grid; place-items: center; text-align: center; border: 2px dashed var(--border); border-radius: 12px; padding: 34px 16px; cursor: pointer; color: var(--text-2); margin-bottom: 10px; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--surface-2); }
.drop input { display: none; }
.drop small { color: var(--muted); }
.howto { margin: 0; padding-left: 18px; color: var(--text-2); display: grid; gap: 8px; font-size: 13px; }

.empty { text-align: center; padding: 36px 20px; }
.empty .row { justify-content: center; margin: 0; }
.empty p { color: var(--text-2); max-width: 520px; margin: 8px auto 18px; }

.tooltip { position: fixed; pointer-events: none; z-index: 20; background: var(--text); color: var(--surface); padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4; box-shadow: 0 4px 14px rgba(0,0,0,.18); white-space: nowrap; }
.tooltip .k { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; z-index: 30; font-size: 13px; }

.plan-head { display: flex; justify-content: space-between; align-items: center; }
.plan-head h3 { margin: 0; }
.icon-text { border: 0; background: none; color: var(--accent); padding: 4px 6px; }
#planView { margin-top: 12px; }
.plan-bar { display: flex; gap: 2px; height: 14px; margin: 10px 0 8px; }
.plan-bar span { border-radius: 4px; min-width: 3px; }
.plan-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--text-2); }
.plan-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.plan-legend b { color: var(--text); font-weight: 600; margin-left: 4px; }
.plan-note { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
#planForm label { display: flex; gap: 10px; align-items: center; margin: 12px 0 4px; flex-wrap: wrap; }
#planForm .item input, #planForm .item select { flex: 1 1 120px; }
#planForm .item { padding: 6px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.card-grid .card { margin-bottom: 0; display: flex; flex-direction: column; gap: 10px; }
.cc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cc-head h3 { margin: 0; }
.cc-head small { color: var(--muted); display: block; font-size: 12px; margin-top: 2px; }
.cc-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text-2); }
.cc-row b { color: var(--text); font-weight: 600; }
.cc-sec { border-top: 1px solid var(--grid); padding-top: 10px; font-size: 13px; }
.cc-sec h4 { margin: 0 0 6px; }
.rule { display: grid; grid-template-columns: 46px 1fr; gap: 8px; align-items: baseline; padding: 3px 0; }
.rule .pctb { font-weight: 650; text-align: right; }
.rule small { display: block; color: var(--muted); }
.cc-sec ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--text-2); }
.cc-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font-size: 12.5px; }
.cc-form label { display: grid; gap: 3px; }
.cc-form .full { grid-column: 1 / -1; }
.cc-form textarea { font: inherit; font-size: 12.5px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; color: inherit; min-height: 90px; }
.callout { border-left: 4px solid var(--warn); }
.callout p { margin: 4px 0 0; color: var(--text-2); }
.guide details { border-top: 1px solid var(--grid); padding: 10px 0; }
.guide details:first-of-type { border-top: 0; }
.guide summary { cursor: pointer; font-weight: 600; }
.guide p, .guide li { color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
.guide ul, .guide ol { padding-left: 20px; display: grid; gap: 6px; margin: 8px 0 0; }
.tbl.compact td, .tbl.compact th { padding: 6px 10px 6px 0; }
.tiles.idx { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 4px; }
.tiles.idx .value { font-size: 19px; }
.spark { display: block; width: 100%; height: 26px; margin-top: 6px; }
.results { max-height: 220px; overflow-y: auto; margin-top: 8px; }
.results .item { cursor: pointer; }
.results .item:hover { outline: 1px solid var(--accent); }
.detail-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin: 14px 0 4px; flex-wrap: wrap; }
.detail-head b { font-size: 15px; }
.detail-head .value { font-size: 20px; font-weight: 650; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 10px 0; }
.kv div { background: var(--surface-2); border-radius: 8px; padding: 7px 10px; font-size: 12px; color: var(--text-2); }
.kv b { display: block; font-size: 14px; color: var(--text); margin-top: 1px; }
.calc-in { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.calc-in label { display: grid; gap: 4px; font-size: 12.5px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.status.ok { color: var(--good-text); }
.status.bad { color: var(--bad); }
.status.warn { color: var(--text-2); }
.list .item.ready { align-items: flex-start; }
.list .item.ready .r { white-space: normal; }

.grid2.inner { margin-top: 12px; }
.grid2.inner h4 { margin-top: 0; }
.chart.short { height: 190px; }
.row.slim { margin: 12px 0 0; }
.row.slim input { width: 120px; }
.steps { display: grid; gap: 0; margin: 6px 0 4px; }
.step { display: grid; grid-template-columns: 22px 1fr; gap: 10px; position: relative; padding-bottom: 14px; }
.step::before { content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 2px; background: var(--border); }
.step:last-child::before { display: none; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2); border: 2px solid var(--border); }
.step.now .dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.done .dot { background: var(--good); border-color: var(--good); color: #fff; }
.step b { display: block; }
.step span { color: var(--text-2); font-size: 13px; }
.mix-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.mix-row:last-child { border-bottom: 0; }
.mix-row .pctb { font-weight: 700; font-size: 15px; }
.mix-row small { display: block; color: var(--muted); }
.mix-row button { font-size: 12px; padding: 4px 10px; }

.chat-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.chat-wrap .card { margin-bottom: 0; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 120px); min-height: 420px; }
.chat-head { display: flex; align-items: center; gap: 10px; }
.chat-head h3 { margin: 0; }
.chat-head .muted { font-size: 12px; }
.chat-head .icon-text { margin-left: auto; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 14px 2px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); }
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant p:last-child, .msg.assistant ul:last-child, .msg.assistant ol:last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 8px; padding-left: 20px; }
.msg.assistant h4 { margin: 10px 0 6px; font-size: 13.5px; color: var(--text); }
.msg.assistant table { border-collapse: collapse; margin: 6px 0 10px; font-size: 12.5px; display: block; overflow-x: auto; }
.msg.assistant th, .msg.assistant td { border-bottom: 1px solid var(--border); padding: 5px 10px 5px 0; text-align: left; white-space: nowrap; }
.msg.assistant th { color: var(--text-2); font-weight: 600; }
.msg.status { align-self: flex-start; color: var(--muted); font-size: 12.5px; padding: 0 4px; }
.msg.error { align-self: flex-start; color: var(--bad); font-size: 13px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--border); padding-top: 12px; }
.chat-form textarea { flex: 1; resize: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font: inherit; color: inherit; max-height: 160px; }
.chat-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#chatSuggest { margin-bottom: 10px; }
#chatSuggest button { border-radius: 999px; font-size: 12.5px; padding: 5px 12px; background: var(--surface-2); border: 0; }
.chat-side .list .item { align-items: flex-start; }

@media (max-width: 760px) {
  .chat-wrap { grid-template-columns: minmax(0, 1fr); }
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .cc-form { grid-template-columns: minmax(0, 1fr); }
  .chat { height: calc(100vh - 150px); }
  .msg { max-width: 94%; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
  .tile .value { font-size: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile.hero { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: 90px 1fr auto; }
  .bar-row .amt { min-width: 70px; }
}

@media (max-width: 900px) {
  body { display: block; }
  .side { position: sticky; z-index: 6; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px;
    border-right: 0; border-bottom: 1px solid var(--border); overflow: hidden; }
  .brand { padding: 0; } .brand small, .brand b { display: none; } .brand .logo { width: 30px; height: 30px; }
  nav { flex-direction: row; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  .nav-group { flex-direction: row; gap: 2px; } .nav-label { display: none; } .ask-group { margin: 0; }
  nav button { width: auto; white-space: nowrap; padding: 7px 11px; }
  nav button::before { display: none; }
  main { padding: 18px 16px 48px; }
  .page-head h1 { font-size: 23px; }
}

.phone-grid { display: grid; grid-template-columns: 180px 1fr; gap: 22px; align-items: start; }
.phone-qr { background: #fff; border-radius: 14px; padding: 8px; aspect-ratio: 1; display: grid; place-items: center; }
.phone-qr svg { width: 100%; height: auto; display: block; }
.phone-qr p { color: #555; font-size: 12px; text-align: center; margin: 0; }
#phoneCard .howto li { line-height: 1.6; }
#phoneCard .inline { margin: 6px 0 2px; max-width: 320px; }
@media (max-width: 760px) { .phone-grid { grid-template-columns: minmax(0, 1fr); } .phone-qr { max-width: 200px; } }
@supports (padding: env(safe-area-inset-top)) {
  .side { padding-top: max(10px, env(safe-area-inset-top)); }
  main { padding-bottom: max(48px, env(safe-area-inset-bottom)); }
}

/* ---------- roadmap ---------- */
.journey-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.journey-head h3 { margin-bottom: 2px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 6px 12px; font-size: 12.5px; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.journey-map { height: 176px; margin: 6px -6px 0; }
.journey-map svg { width: 100%; height: 100%; display: block; overflow: visible; }
.journey-map .yr { stroke: var(--grid); stroke-dasharray: 2 4; }
.journey-map .yrt { fill: var(--muted); font-size: 10.5px; }
.journey-map .road { fill: none; stroke: var(--grid-strong); stroke-width: 6; stroke-linecap: round; }
.journey-map .road-done { fill: none; stroke: url(#jg); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 1.2s var(--ease); }
.stop { cursor: pointer; outline: none; }
.stop .halo { fill: var(--accent); opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(.4); transition: all .35s var(--ease); }
.stop .node { fill: var(--surface); stroke: var(--accent); stroke-width: 3; transform-box: fill-box; transform-origin: center; transition: transform .3s var(--ease), fill .3s; }
.stop.here .node { fill: var(--accent); }
.stop.here .halo { opacity: .18; transform: scale(1); animation: pulse 2.4s var(--ease) infinite; }
.stop:hover .halo, .stop.sel .halo, .stop:focus-visible .halo { opacity: .2; transform: scale(1); }
.stop:hover .node, .stop.sel .node { transform: scale(1.25); fill: var(--accent); }
.stop .sl { fill: var(--text); font-size: 12px; font-weight: 650; }
.stop .sd { fill: var(--muted); font-size: 11px; }
.journey-map.vertical { height: auto; margin: 10px 0 0; display: grid; gap: 0; }
.vstop { display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; text-align: left; border: 0; background: none;
  padding: 0 4px 14px; border-radius: 10px; position: relative; }
.vstop::after { content: ""; position: absolute; left: 14px; top: 18px; bottom: -2px; width: 2px; background: var(--grid-strong); }
.vstop:last-child::after { display: none; }
.vstop i { width: 16px; height: 16px; margin: 2px 0 0 3px; border-radius: 50%; border: 3px solid var(--accent); background: var(--surface);
  position: relative; z-index: 1; transition: transform .3s var(--ease), background .3s; }
.vstop.here i, .vstop.sel i { background: var(--accent); transform: scale(1.15); }
.vstop b { display: block; } .vstop small { color: var(--muted); } .vstop em { font-style: normal; font-weight: 650; }
.vstop:hover { background: none; } .vstop:active { transform: none; }
@keyframes pulse { 0%, 100% { transform: scale(.85); opacity: .25; } 50% { transform: scale(1.25); opacity: .08; } }
.journey-detail { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; background: var(--surface-2); border-radius: 12px;
  padding: 11px 14px; margin-top: 10px; font-size: 13px; min-height: 44px; }
.journey-detail span { color: var(--text-2); }
.road-grid { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.road-grid .card { margin-bottom: 0; }
.whatif { display: flex; flex-direction: column; gap: 14px; }
.whatif h3 { margin: 0; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 13px; color: var(--text-2); }
.slider output { font-weight: 650; color: var(--text); }
.slider input { grid-column: 1 / -1; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; padding: 0; border: 0; border-radius: 99px;
  background: var(--grid-strong); box-shadow: none; cursor: pointer; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--surface);
  border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .2); transition: transform .2s var(--ease); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
input[type=range]:hover::-webkit-slider-thumb, input[type=range]:active::-webkit-slider-thumb { transform: scale(1.18); }
input[type=range]:focus { box-shadow: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--ring); }
.sip-set { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; font-size: 13px; color: var(--text-2); }
.sip-set label { display: grid; gap: 4px; }
.sip-set input { width: 100%; }
.pill.draft { background: rgba(250, 178, 25, .16); color: #a86d00; }
.stop.drag { cursor: grabbing; }
.stop:not(.here) { cursor: grab; }
.stop.dragging .node { transform: scale(1.4); fill: var(--accent); }
.stop.dragging .halo { opacity: .25; transform: scale(1.2); }
.impact { display: grid; gap: 8px; width: 100%; }
.impact .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.impact .acts button { font-size: 12.5px; padding: 6px 12px; }
.chg-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chg { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); }
.vstop input[type=month] { margin-top: 6px; font-size: 12.5px; padding: 4px 8px; }
.chart .ln { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.decisions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.decisions .card { margin-bottom: 0; }
.dec-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.dec-head h3 { margin: 0; }
.pill { font-size: 11.5px; font-weight: 650; padding: 4px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.bad { background: rgba(208, 59, 59, .12); color: var(--bad); }
.pill.ok { background: var(--accent-soft); color: var(--good-text); }
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: l; }
.ladder li { counter-increment: l; display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: start; padding: 9px 10px;
  border-radius: 12px; font-size: 13px; transition: background .2s var(--ease); }
.ladder li::before { content: counter(l); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px;
  font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.ladder li:hover { background: var(--surface-2); }
.ladder li.now { background: var(--accent-soft); }
.ladder li.now::before { background: var(--accent); color: #fff; border-color: var(--accent); }
.ladder li.past { opacity: .55; }
.ladder li.past::before { content: "✓"; }
.ladder b { display: block; } .ladder span { color: var(--text-2); font-size: 12.5px; }
.ladder em { font-style: normal; font-weight: 650; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.emi-table { display: grid; gap: 4px; margin: 6px 0; }
.emi-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 10px; border-radius: 10px; font-size: 13px; transition: background .2s; }
.emi-row:hover { background: var(--surface-2); }
.emi-row small { display: block; color: var(--muted); font-size: 11.5px; }
.waterfall { display: flex; gap: 3px; height: 16px; border-radius: 8px; overflow: hidden; margin: 6px 0 12px; }
.waterfall span { min-width: 4px; transition: filter .2s, flex .5s var(--ease); }
.waterfall span:hover { filter: brightness(1.15); }
.wf-list { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.wf-list div { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.wf-list i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.wf-list b { margin-left: auto; color: var(--text); font-weight: 600; }
@media (max-width: 1100px) { .decisions { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .road-grid { grid-template-columns: minmax(0, 1fr); } .journey-map { height: 190px; } }

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