:root {
  /* palette matched to the YNAB web app: indigo navigation, lime "ready", yellow "needs money" */
  --bg: #faf8f4;
  --card: #ffffff;
  --ink: #202020;
  --muted: #676765;
  --line: #ebe8e1;
  --line-strong: #d9d5cc;
  --side: #1f215f;
  --side-2: #4245a5;
  --side-hover: #2d3077;
  --side-ink: #ffffff;
  --side-muted: #abafcc;
  --side-mark: #c9cbff;
  --accent: #4245a5;
  --accent-ink: #ffffff;
  --accent-soft: #e4e4fb;
  --link: #3f43b5;
  --pos: #2f5a12;   --pos-bg: #c9f08e;
  --warn: #4a3500;  --warn-bg: #f0dd8b;
  --neg: #b4231b;   --neg-bg: #fcd0cb;
  --zero: #6b6b67;  --zero-bg: #ece9e3;
  --rta-pos: #d1f69c; --rta-pos-ink: #1d2a0c; --rta-btn: #678f37;
  --chart-1: #4245a5; --chart-1-soft: rgba(66, 69, 165, .35); --chart-2: #e3b62e; --chart-3: #678f37;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31, 33, 95, .05), 0 4px 14px rgba(31, 33, 95, .05);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121327; --card: #1a1c35; --ink: #ececf6; --muted: #a2a4c0; --line: #2a2d4f; --line-strong: #383c66;
    --side: #0d0e24; --side-2: #4245a5; --side-hover: #1e2050; --side-ink: #ffffff; --side-muted: #9a9dc4; --side-mark: #c9cbff;
    --accent: #7d81f0; --accent-ink: #0d0e24; --accent-soft: #2a2d5c; --link: #a9acff;
    --pos: #c9f08e; --pos-bg: #2f4a17; --warn: #f2dd8b; --warn-bg: #4a3d12;
    --neg: #ff9d92; --neg-bg: #4d1f1c; --zero: #a8a9bd; --zero-bg: #272a47;
    --rta-pos: #3b5a1a; --rta-pos-ink: #e4fbc4; --rta-btn: #8fbf55;
    --chart-1: #7d81f0; --chart-1-soft: rgba(125, 129, 240, .35); --chart-2: #e3b62e; --chart-3: #8fbf55;
    --shadow: none; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 .8rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.4rem 0 .6rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.strong { font-weight: 650; }
.neg { color: var(--neg); }
.pos { color: var(--pos); }
.r { text-align: right; }
.c { text-align: center; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
code { font-size: .82rem; background: var(--zero-bg); padding: .1rem .35rem; border-radius: 5px; word-break: break-all; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout */
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); padding: 1.1rem .8rem; display: flex; flex-direction: column; gap: .3rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.main { padding: 1.4rem 1.8rem 3rem; min-width: 0; }
.brand { display: flex; align-items: center; gap: .7rem; padding: .2rem .5rem 1rem; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--side-2); position: relative; flex: none; }
.logo::before { content: ""; position: absolute; inset: 8px; border: 3px solid var(--side-mark); border-radius: 50%; }
.logo::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; background: var(--side-mark); border-radius: 50%; }
.logo.big { width: 52px; height: 52px; border-radius: 14px; background: var(--side); margin-bottom: .6rem; }
.logo.big::before { inset: 12px; border-width: 4px; }
.brand-name { font-weight: 650; color: #fff; }
.brand-sub { font-size: .75rem; color: var(--side-muted); }
.nav a { display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem; border-radius: 9px; color: var(--side-ink); font-weight: 550; }
.nav a:hover { background: var(--side-hover); text-decoration: none; }
.nav a.active, .nav a.active:hover { background: var(--side-2); color: #fff; }
.acct-section { margin-top: 1rem; }
.acct-head { display: flex; justify-content: space-between; padding: .2rem .7rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--side-muted); }
.acct { display: flex; justify-content: space-between; gap: .5rem; padding: .38rem .7rem; border-radius: 8px; color: var(--side-ink); font-size: .9rem; }
.acct:hover { background: var(--side-hover); text-decoration: none; }
.acct.active { background: var(--side-2); color: #fff; }
.acct .neg { color: #ffb3a8; }
.acct-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-empty { padding: .3rem .7rem; font-size: .85rem; color: var(--side-muted); }
.add-acct { margin: .8rem .7rem 0; font-size: .86rem; color: var(--side-ink); background: rgba(255, 255, 255, .14); padding: .35rem .7rem; border-radius: 8px; align-self: flex-start; }
.add-acct:hover { background: rgba(255, 255, 255, .22); text-decoration: none; }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding: 1rem .7rem 0; border-top: 1px solid var(--side-hover); font-size: .86rem; }
.side-foot a, .side-foot .linklike { color: var(--side-muted); }
.menu-btn { display: none; }
.scrim { display: none; }

/* ---------- common UI */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.6rem; margin-bottom: 1.2rem; }
.page-head > div:first-child { margin-right: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem .95rem; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.primary:disabled { opacity: .45; cursor: default; filter: none; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--zero-bg); }
.btn.small { padding: .32rem .65rem; font-size: .86rem; }
.btn.wide { width: 100%; }
.btn.danger, .btn.ghost.danger { color: var(--neg); }
.btn.danger:not(.ghost) { border-color: var(--neg); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--ink); font-size: 1.3rem; line-height: 1; background: var(--card); }
.icon-btn:hover { border-color: var(--accent); text-decoration: none; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line-strong); border-radius: 8px; padding: .5rem .6rem; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: flex; flex-direction: column; gap: .28rem; font-size: .84rem; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; color: var(--ink); }
label.check input { width: auto; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.stack-col { display: flex; flex-direction: column; gap: 1.2rem; min-width: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.empty { padding: 1.6rem; text-align: center; color: var(--muted); }
.tag { display: inline-block; font-size: .74rem; padding: .08rem .45rem; border-radius: 99px; background: var(--zero-bg); color: var(--zero); font-weight: 600; }
.tag.inflow { background: var(--pos-bg); color: var(--pos); }
.chip { display: inline-flex; gap: .5rem; align-items: center; padding: .25rem .4rem .25rem .7rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: .86rem; font-weight: 600; }
.chip a { width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 50%; }
.flashes { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.flash { padding: .65rem .9rem; border-radius: 9px; font-weight: 550; background: var(--accent-soft); color: var(--pos); }
.flash.error { background: var(--neg-bg); color: var(--neg); }
.toast { position: fixed; left: 50%; bottom: 1.4rem; transform: translate(-50%, 2rem); background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 9px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--neg); color: #fff; }

/* ---------- auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 2rem; display: flex; flex-direction: column; gap: .9rem; box-shadow: var(--shadow); }
.auth-card p { margin: 0 0 .4rem; }

/* ---------- budget */
.budget-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.month-nav { display: flex; align-items: center; gap: .6rem; }
.month-nav h1 { min-width: 10.5rem; text-align: center; }
.rta { display: flex; flex-direction: column; align-items: flex-start; border: 0; border-radius: 14px; padding: .7rem 1.2rem; min-width: 230px; cursor: pointer; font: inherit; text-align: left; transition: transform .1s; }
.rta:hover { transform: translateY(-1px); }
.rta-amount { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rta-label { font-size: .82rem; font-weight: 600; opacity: .85; }
.rta.pos { background: var(--rta-pos); color: var(--rta-pos-ink); }
.rta.neg { background: var(--neg-bg); color: var(--neg); }
.rta.zero { background: var(--zero-bg); color: var(--zero); }
.budget-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 1.2rem; align-items: start; }
.budget-card { padding: .8rem 0 .4rem; }
.budget-card .toolbar { padding: 0 1rem; }
.bt-head, .bt-group, .bt-row { display: grid; grid-template-columns: minmax(0, 1fr) 128px 118px 128px; gap: .6rem; align-items: center; padding: 0 1rem; }
.bt-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding-top: .4rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.bt-group { background: var(--bg); padding-top: .45rem; padding-bottom: .45rem; border-bottom: 1px solid var(--line); font-weight: 650; font-size: .92rem; }
.bt-group .num { color: var(--muted); font-weight: 600; }
.gname { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.add-cat { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--card); color: var(--accent); cursor: pointer; font-weight: 700; line-height: 1; opacity: 0; transition: .15s; }
.bt-group:hover .add-cat, .add-cat:focus { opacity: 1; }
.bt-row { min-height: 52px; padding-top: .35rem; padding-bottom: .35rem; border-bottom: 1px solid var(--line); }
.bt-row:hover { background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.bt-row.flash-row { animation: rowflash .9s; }
@keyframes rowflash { from { background: var(--accent-soft); } }
.is-hidden { opacity: .55; }
.cname { min-width: 0; }
.cat-edit { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cat-edit:hover { color: var(--accent); }
.note-dot { color: var(--accent); margin-left: .2rem; cursor: help; }
.tgt { display: none; margin-top: .25rem; }
.tgt.show { display: block; }
.tbar { height: 5px; border-radius: 99px; background: var(--zero-bg); overflow: hidden; max-width: 260px; }
.tbar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.ttext { font-size: .74rem; color: var(--muted); margin-top: .15rem; }
.assign { text-align: right; padding: .35rem .5rem; border-color: transparent; background: transparent; }
.bt-row:hover .assign, .assign:focus { border-color: var(--line-strong); background: var(--card); }
.act a { color: var(--muted); }
.act a:hover { color: var(--accent); }
.pill { border: 0; border-radius: 99px; padding: .28rem .7rem; font: inherit; font-weight: 650; font-size: .9rem; font-variant-numeric: tabular-nums; cursor: pointer; white-space: nowrap; }
.pill.pos { background: var(--pos-bg); color: var(--pos); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.neg { background: var(--neg-bg); color: var(--neg); }
.pill.zero { background: var(--zero-bg); color: var(--zero); }
.pill:hover { filter: brightness(.96); }
.summary { position: sticky; top: 1.2rem; }
.summary dl { margin: 0; }
.summary dl > div { display: flex; justify-content: space-between; gap: 1rem; padding: .42rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; }
.quick { display: flex; flex-direction: column; gap: .5rem; }
.quick .btn { justify-content: space-between; text-align: left; }
.quick .btn.primary .num { opacity: .9; }
.danger-zone summary { cursor: pointer; color: var(--muted); font-size: .86rem; padding: .3rem 0; }
.danger-zone .btn { margin-top: .45rem; }
.tip { font-size: .8rem; color: var(--muted); margin: 1rem 0 0; }

/* ---------- dialogs */
.dlg { border: 0; border-radius: 16px; padding: 0; width: min(460px, calc(100vw - 2rem)); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.dlg::backdrop { background: rgba(15, 16, 45, .45); }
.dlg form { display: flex; flex-direction: column; gap: .85rem; padding: 1.3rem 1.4rem; }
.dlg h2 { margin: 0; font-size: 1.15rem; }
.dlg p { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .3rem; }
.dlg-actions.spread { justify-content: space-between; flex-wrap: wrap; }
.dlg-actions span { display: flex; gap: .3rem; flex-wrap: wrap; }
.target-box { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem .8rem; display: flex; flex-direction: column; gap: .6rem; margin: 0; }
.target-box legend { font-size: .84rem; font-weight: 600; color: var(--muted); padding: 0 .3rem; }
.delete-box { border-top: 1px solid var(--line); padding-top: .8rem; display: flex; flex-direction: column; gap: .6rem; }

/* ---------- register */
.balances { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.balances > div { display: flex; flex-direction: column; }
.balances .lbl, .kpi .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.balances .num { font-size: 1.1rem; font-weight: 600; }
.balances .op { color: var(--muted); font-size: 1.1rem; }
.head-actions { display: flex; gap: .4rem; }
.tx-entry { margin-bottom: 1.2rem; }
.tx-entry.editing { outline: 2px solid var(--accent); }
.tx-grid { display: grid; grid-template-columns: 150px 1fr 1fr 1fr 120px 120px; gap: .7rem; align-items: end; }
.tx-grid .f-memo { grid-column: span 1; }
.tx-grid .f-tcat { grid-column: span 2; }
.tx-grid .f-clr { padding-bottom: .55rem; }
.tx-grid .f-btn { grid-column: -3 / -1; display: flex; gap: .5rem; justify-content: flex-end; }
.tx-grid:has(.f-acct) { grid-template-columns: 150px 1fr 1fr 1fr 1fr 120px; }
.search input { width: 270px; max-width: 100%; }
.tx-table-wrap { overflow-x: auto; margin: 0 -1.2rem; padding: 0 1.2rem; }
.tx-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tx-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: .5rem .5rem; border-bottom: 1px solid var(--line); }
.tx-table th.r { text-align: right; }
.tx-table td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tx-table tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.tx-table tr.uncat td:nth-child(4) { color: var(--neg); font-weight: 600; }
.tx-table .memo { color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-table .inflow-amt { color: var(--pos); }
.tx-table tr.editing-row { background: var(--accent-soft); }
.tx-table.plain td { padding: .45rem .3rem; }
.tx-table.plain th { padding: .45rem .3rem; }
.tx-table tfoot td { font-weight: 700; border-bottom: 0; }
.tx-table tr.grp td { font-weight: 650; background: var(--bg); }
.tx-table td.indent { padding-left: 1.2rem; }
.clr { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: transparent; color: var(--muted); font-size: .72rem; font-weight: 700; cursor: pointer; line-height: 1; }
.clr.cleared { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.clr.reconciled { border-color: transparent; font-size: .8rem; }
.row-btn { border: 0; background: none; cursor: pointer; padding: .2rem .35rem; border-radius: 6px; color: var(--muted); font-size: .95rem; }
.row-btn:hover { background: var(--zero-bg); color: var(--ink); }
form.inline { display: inline; }

/* ---------- reports */
.range { display: flex; align-items: flex-end; gap: .5rem; flex-wrap: wrap; }
.range label { flex-direction: row; align-items: center; gap: .4rem; }
.range input { width: auto; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.kpi { display: flex; flex-direction: column; gap: .2rem; }
.kpi .big { font-size: 1.35rem; font-weight: 700; }
.chart-box { position: relative; height: 260px; margin-bottom: 1rem; }
.chart-box.donut { height: 240px; }

/* ---------- responsive */
@media (max-width: 1100px) {
  .budget-wrap { grid-template-columns: 1fr; }
  .summary { position: static; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .tx-grid, .tx-grid:has(.f-acct) { grid-template-columns: 1fr 1fr 1fr; }
  .tx-grid .f-btn { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 30; }
  .main { padding: 1rem 1rem 3rem; }
  .menu-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); margin-bottom: .8rem; }
  .budget-head { flex-direction: column; align-items: stretch; }
  .month-nav { justify-content: space-between; }
  .month-nav h1 { font-size: 1.25rem; min-width: 0; }
  .rta { align-items: center; text-align: center; }
  .bt-head { display: none; }
  .bt-group { grid-template-columns: 1fr auto; }
  .bt-group [data-g="assigned"], .bt-group [data-g="activity"] { display: none; }
  .bt-row { grid-template-columns: minmax(0, 1fr) 96px auto; grid-template-areas: "name assign avail" "name act avail"; row-gap: 0; padding-top: .5rem; padding-bottom: .5rem; }
  .bt-row .cname { grid-area: name; }
  .bt-row > div:nth-child(2) { grid-area: assign; }
  .bt-row > div:nth-child(3) { grid-area: act; font-size: .76rem; }
  .bt-row > div:nth-child(4) { grid-area: avail; }
  .assign { border-color: var(--line); background: var(--card); padding: .3rem .4rem; }
  .add-cat { opacity: 1; }
  .tx-grid, .tx-grid:has(.f-acct) { grid-template-columns: 1fr 1fr; }
  .tx-grid .f-memo, .tx-grid .f-tcat, .tx-grid .f-payee, .tx-grid .f-cat { grid-column: 1 / -1; }
  .balances { width: 100%; justify-content: space-between; }
  .balances .num { font-size: .98rem; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .search input { width: 100%; }
  .search { flex: 1; }
  .row2 { grid-template-columns: 1fr; }
}

/* ---------- report tabs, trends, budget vs. actual */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.page-head .sub { margin: .2rem 0 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: var(--card); }
.seg a { padding: .32rem .7rem; font-size: .86rem; font-weight: 600; color: var(--muted); }
.seg a + a { border-left: 1px solid var(--line-strong); }
.seg a:hover { color: var(--ink); text-decoration: none; }
.seg a.on { background: var(--accent); color: var(--accent-ink); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.detail-head h2, .detail-head p { margin: 0; }
.detail-links { display: flex; gap: .4rem; }
.trend-detail { margin-bottom: 1.2rem; }
.mini-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .6rem; margin: .4rem 0 1rem; }
.mini-kpis > div { display: flex; flex-direction: column; gap: .15rem; padding: .55rem .7rem; border-radius: 10px; background: var(--bg); }
.mini-kpis > div.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.mini-kpis .lbl { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mini-kpis .num { font-size: 1.08rem; font-weight: 650; }
.tx-table th a { color: inherit; }
.tx-table th a.sorted { color: var(--ink); }
.tx-table th a.sorted::after { content: " ↓"; }
.tx-table .sel { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.tx-table tr.picked td { background: var(--accent-soft); }
.trends .name-cell a { font-weight: 550; }
.trends .grp-name { display: block; font-size: .74rem; }
.spark-col { width: 104px; }
.spark { width: 96px; height: 24px; display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.trend { font-size: .84rem; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.trend.up { color: var(--neg); }
.trend.down { color: var(--pos); }
.trend.flat { color: var(--muted); }
.year-nav h1 { min-width: 0; margin: 0; font-size: 1.45rem; }
.icon-btn.disabled { opacity: .35; pointer-events: none; }
.used-col { width: 150px; white-space: nowrap; }
.ubar { display: inline-block; vertical-align: middle; width: 86px; height: 6px; border-radius: 99px; background: var(--zero-bg); overflow: hidden; margin-right: .4rem; }
.ubar span { display: block; height: 100%; background: var(--accent); }
.ubar.over span { background: var(--neg); }
.plan-col { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.bva tbody + tbody tr.grp td { border-top: 6px solid var(--card); }
.grid-wrap { max-width: 100%; }
.tx-table.grid { font-size: .82rem; }
.tx-table.grid td, .tx-table.grid th { padding: .4rem .45rem; }
.tx-table.grid th { white-space: nowrap; }
.tx-table.grid .stick { position: sticky; left: 0; background: var(--card); z-index: 1; min-width: 150px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-table.grid tr.grp .stick { background: var(--bg); }
.tx-table.grid .cell span { display: block; }
.tx-table.grid .cell .sub { font-size: .72rem; color: var(--muted); font-weight: 400; }
.tx-table.grid .cell.over > span:first-child { color: var(--neg); font-weight: 650; }
.tx-table.grid tfoot .sub-row td { font-weight: 500; color: var(--muted); }
@media (max-width: 1100px) {
  .mini-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .mini-kpis { grid-template-columns: 1fr 1fr; }
  .controls { width: 100%; }
  .year-nav { width: 100%; justify-content: space-between; }
  .year-nav h1 { font-size: 1.15rem; text-align: center; }
  .trends .spark-col, .trends .alt { display: none; }
  .tx-table.trends { font-size: .8rem; }
  .tx-table.trends td, .tx-table.trends th { padding: .45rem .2rem; }
  .tx-table.trends th { font-size: .64rem; letter-spacing: .03em; }
  .trends .trend { font-size: .76rem; }
  .tx-table.grid .stick { min-width: 120px; max-width: 140px; }
}

/* toolbar actions read as links, like YNAB */
.toolbar .btn.ghost { color: var(--link); }
