/* ---------------------------------------------------------------
   My Finance — one stylesheet, light + dark.
   Chart colours follow the validated reference palette (dataviz skill).
---------------------------------------------------------------- */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --text: #191919;
  --text-2: #666666;
  --accent: #257de0;
  --accent-ink: #1b64be;
  --accent-soft: #e6f0fc;
  --good: #006c10;
  --bad: #b42c2d;
  --bad-fill: #dc3c3d;
  --warn-ink: #8a5a00;
  --warn-soft: #fff3d6;
  --good-soft: #e3f5e6;
  --bad-soft: #fde8e8;
  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --meter-track: #cce3fd;
  --meter-fill: #257de0;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --side-bg: #14284b;
  --side-text: #b9c6dc;
  --side-strong: #ffffff;
  --side-hover: rgba(255, 255, 255, .08);
  --side-on-bg: rgba(255, 255, 255, .14);
  --side-on-bar: #6aabf1;
  --side-line: rgba(255, 255, 255, .12);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0b0b0b;
    --surface: #191919;
    --surface-2: #222222;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #efefef;
    --text-2: #9c9c9c;
    --accent: #338ced;
    --accent-ink: #6aabf1;
    --accent-soft: #14273d;
    --good: #53c556;
    --bad: #eb6263;
    --bad-fill: #dc3c3d;
    --warn-ink: #fbb315;
    --warn-soft: #332709;
    --good-soft: #13291a;
    --bad-soft: #351719;
    --series-1: #338ced;
    --series-2: #e76624;
    --series-3: #00a888;
    --meter-track: #0e3d7e;
    --meter-fill: #338ced;
    --grid: #303030;
    --axis: #474747;
    --shadow: none;
  --side-bg: #101a2c;
  --side-text: #9fadc4;
  --side-strong: #f2f5fa;
  --side-hover: rgba(255, 255, 255, .06);
  --side-on-bg: rgba(106, 171, 241, .16);
  --side-on-bar: #6aabf1;
  --side-line: rgba(255, 255, 255, .08);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0b;
  --surface: #191919;
  --surface-2: #222222;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #efefef;
  --text-2: #9c9c9c;
  --accent: #338ced;
  --accent-ink: #6aabf1;
  --accent-soft: #14273d;
  --good: #53c556;
  --bad: #eb6263;
  --bad-fill: #dc3c3d;
  --warn-ink: #fbb315;
  --warn-soft: #332709;
  --good-soft: #13291a;
  --bad-soft: #351719;
  --series-1: #338ced;
  --series-2: #e76624;
  --series-3: #00a888;
  --meter-track: #0e3d7e;
  --meter-fill: #338ced;
  --grid: #303030;
  --axis: #474747;
  --shadow: none;
  --side-bg: #101a2c;
  --side-text: #9fadc4;
  --side-strong: #f2f5fa;
  --side-hover: rgba(255, 255, 255, .06);
  --side-on-bg: rgba(106, 171, 241, .16);
  --side-on-bar: #6aabf1;
  --side-line: rgba(255, 255, 255, .08);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; color: var(--text-2); margin: 14px 0 6px; font-weight: 600; }
p { margin: 0 0 8px; }
code { font-size: 12px; word-break: break-all; }
.icon { flex: none; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; transition: grid-template-columns .2s ease; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: hidden auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 12px; background: var(--side-bg); color: var(--side-text);
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 4px 12px; white-space: nowrap; }
.brand-toggle {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 10px; background: none; cursor: pointer;
}
.brand-toggle:hover { background: var(--side-hover); }
.brand-toggle:focus-visible { outline: 2px solid var(--side-on-bar); outline-offset: 0; }
.brand-name { color: var(--side-strong); font-weight: 650; font-size: 16px; }
.brand-name:hover { text-decoration: none; }
.topbar .menu-btn { display: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--side-text); font: inherit; text-align: left; cursor: pointer; white-space: nowrap;
}
.nav-link:hover { background: var(--side-hover); color: var(--side-strong); text-decoration: none; }
.nav-link.on { background: var(--side-on-bg); color: var(--side-strong); font-weight: 600; }
.nav-link.on::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--side-on-bar);
}
.nav-link:focus-visible { outline: 2px solid var(--side-on-bar); outline-offset: -2px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--side-line); padding-top: 8px; }
.sidebar-foot form { margin: 0; }
.side-user { padding: 6px 10px 8px; font-size: 12px; color: var(--side-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user b { color: var(--side-strong); font-weight: 600; }
.setup-logout { display: flex; justify-content: center; margin: 8px 0 24px; }
.scrim { display: none; }

/* Desktop: the menu button folds the sidebar to an icon rail (remembered). */
@media (min-width: 901px) {
  html.side-collapsed .layout { grid-template-columns: 68px 1fr; }
  html.side-collapsed .sidebar { padding: 16px 10px; }
  html.side-collapsed .brand { padding: 0 0 12px; justify-content: center; }
  html.side-collapsed .brand-name,
  html.side-collapsed .nav-link span,
  html.side-collapsed .side-user { display: none; }
  html.side-collapsed .nav-link { justify-content: center; padding: 10px 0; }
  html.side-collapsed .nav-link.on::before { left: -10px; }
}

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb { font-size: 12px; color: var(--text-2); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 22px 28px 96px; max-width: 1240px; display: flex; flex-direction: column; gap: 16px; }

.fab { display: none; }

/* ---------- Cards, tiles ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
a.card { color: inherit; display: block; }
a.card:hover { text-decoration: none; border-color: var(--border-strong); }
.card h2 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card.narrow { max-width: 400px; width: 100%; }

.hero-grid { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 16px; }
.hero { display: flex; flex-direction: column; justify-content: center; }
.hero-value { font-size: 48px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; margin: 4px 0 6px; overflow-wrap: anywhere; }
.hero-value.smaller { font-size: 34px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tiles.two { grid-template-columns: repeat(2, 1fr); }
.tiles.four { grid-template-columns: repeat(4, 1fr); }
.tiles.flat { margin: 6px 0 12px; }
.tile { padding: 14px 16px; }
.tile-label { font-size: 13px; color: var(--text-2); margin: 0 0 2px; }
.tile-value { font-size: 20px; font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two-col > div { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.settled-list { line-height: 1.9; margin: 0 0 6px; }
.owe-sep { color: var(--text-2); }
.adjusted-box { margin: 4px 0 8px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0; }
.pair p { margin: 0; }

.lena-text, .amt.in, .owe.lena { color: var(--good); }
.dena-text, .owe.dena { color: var(--bad); }
.amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.amt.udhaar { color: var(--warn-ink); }
.owe { white-space: nowrap; font-variant-numeric: tabular-nums; }
.owe b { font-weight: 600; font-size: 12px; margin-right: 4px; }
.owe.settled { color: var(--text-2); }

.notice {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin: 10px 0; font-size: 14px;
}
.notice ul.plain { margin: 6px 0 0; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { padding: 2px 0; }

.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  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: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--bad-fill); border-color: var(--bad-fill); color: #fff; }
.btn.ghost { border-color: transparent; background: none; color: var(--accent-ink); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.big { min-height: 48px; font-size: 16px; }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 0; background: none; color: var(--text-2); cursor: pointer; font-size: 18px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.field label, .label { font-size: 13px; color: var(--text-2); font-weight: 550; }
legend.label { padding: 0; margin-bottom: 5px; }
.opt { font-weight: 400; }
.hint { font-size: 12.5px; color: var(--text-2); margin: 2px 0 0; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 10px; min-height: 40px; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.amount-input { font-size: 26px; font-weight: 600; min-height: 54px; font-variant-numeric: tabular-nums; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 > .field { margin-bottom: 14px; }
.narrow-field { max-width: 260px; }
.form-error {
  color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 8px 10px; font-size: 14px; margin: 4px 0 12px;
}
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; margin: 4px 0 10px; }

.segmented { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.segmented label { flex: 1 1 0; min-width: max-content; cursor: pointer; }
.segmented.four label { flex-basis: 45%; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 8px 10px; border-radius: 7px; font-size: 14px; color: var(--text-2); }
.segmented input:checked + span { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.segmented input:disabled + span { opacity: .45; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 6px 12px; border-radius: 999px; font-size: 14px;
  border: 1px solid var(--border-strong); background: var(--surface);
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.inline-add { display: flex; gap: 6px; margin-top: 8px; }
.inline-add input { min-height: 34px; padding: 5px 10px; }

.split-box { background: var(--surface-2); border-radius: 10px; padding: 12px; margin: -4px 0 14px; }
.shares { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.share-row { display: grid; grid-template-columns: 1fr 140px; gap: 8px; align-items: center; }
.share-row input { min-height: 34px; padding: 5px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.summary { font-size: 14px; background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; }
.summary:empty { display: none; }
.summary ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Filters ---------- */
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; }
.filter-row.wrap input[type="search"] { flex: 1 1 220px; }
.filter-row select, .filter-row input { min-height: 34px; padding: 5px 9px; width: auto; }
.seg-links { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.seg-link { border: 0; background: none; font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 7px; color: var(--text-2); cursor: pointer; }
.seg-link.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.custom-range { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.custom-range input { width: 150px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.sub td { background: var(--surface-2); }
.table tr.total td { font-weight: 600; }
.row-actions { text-align: right; white-space: nowrap; }
tr.is-reversed td, li.is-reversed { opacity: .6; }
tr.is-reversed .amt { text-decoration: line-through; }
tr.is-reversal td { color: var(--text-2); }
/* ---------- Plans: cash flow ---------- */
.plan-section + .plan-section { margin-top: 28px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.section-head h2 { font-size: 18px; margin: 0 0 2px; }
.section-head p { margin: 0; }
.flow-card.is-closed { opacity: .75; }
.actions-inline { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-notes { white-space: pre-line; }
.warn-text { color: var(--warn-ink); margin: 4px 0 0; }
.table tr.is-short td { background: var(--bad-soft); }
.row-actions .btn + .btn { margin-left: 2px; }
.table .row-actions .btn.small { margin: -4px 0; }
.after-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.plain-list li:last-child { border-bottom: 0; }
.plain-list b { font-variant-numeric: tabular-nums; }
.link-note { margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; }
.btn.ghost.danger { color: var(--bad); }
.page-foot { margin-top: 16px; text-align: right; }

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 12px; }
.show-sm { display: none; }

.mini-list { list-style: none; margin: 8px 0 0; padding: 0; }
.mini-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); vertical-align: middle; white-space: nowrap; }
.badge-active, .badge-ongoing, .badge-medium { background: var(--accent-soft); color: var(--accent-ink); }
.badge-received, .badge-completed, .badge-low { background: var(--good-soft); color: var(--good); }
.badge-partial, .badge-on_hold, .badge-pending { background: var(--warn-soft); color: var(--warn-ink); }
.badge-overdue, .badge-high { background: var(--bad-soft); color: var(--bad); }

/* ---------- Charts & figures ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); margin: 0 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--text); font-weight: 600; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.key-1 { background: var(--series-1); }
.key-2 { background: var(--series-2); }
.key-3 { background: var(--series-3); }
.chart-box { position: relative; height: 280px; }
.table-view { margin-top: 10px; font-size: 14px; }
.table-view summary { cursor: pointer; color: var(--accent-ink); font-size: 13px; }
.table-view .table-wrap { max-height: 320px; overflow: auto; margin-top: 8px; }

.segbar { display: flex; gap: 2px; height: 28px; margin: 4px 0 12px; }
.seg { min-width: 4px; border-radius: 4px; display: flex; align-items: center; padding: 0 8px; color: #fff; font-size: 12px; overflow: hidden; }
.seg-1 { background: var(--series-1); }
.seg-2 { background: var(--series-2); }
.seg-3 { background: var(--series-3); }
.seg b { font-weight: 600; }

.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hbars li { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.hbar-track { display: block; height: 12px; }
.hbar { display: block; height: 12px; min-width: 3px; background: var(--series-1); border-radius: 0 4px 4px 0; }
.hbars .num { font-variant-numeric: tabular-nums; }

.meter { height: 8px; border-radius: 999px; background: var(--meter-track); overflow: hidden; margin: 10px 0 6px; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--meter-fill); }
.project-list { list-style: none; margin: 0; padding: 0; }
.project-list li { display: grid; grid-template-columns: minmax(120px, 200px) 1fr auto auto; gap: 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.project-list li:last-child { border-bottom: 0; }
.project-list .meter { margin: 0; }
.project-card h2 { font-size: 16px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; font: inherit; font-size: 14px; padding: 9px 12px; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap;
}
.tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
a.tab:hover { text-decoration: none; color: var(--text); }
.page-tabs { margin-bottom: 0; }

/* ---------- Dialogs ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow: auto;
  border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.dialog.small { width: min(420px, calc(100vw - 24px)); }
.dialog.wide { width: min(1020px, calc(100vw - 24px)); }

/* Several cash flow steps at once */
.bulk-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 6px 0 12px; }
.bulk-tools label.check { margin: 0; }
.bulk-head, .bulk-row {
  display: grid; gap: 8px; align-items: center;
  grid-template-columns: 200px minmax(150px, 1.3fr) minmax(110px, 1fr) 115px 145px 36px;
}
.bulk-head { font-size: 12px; font-weight: 600; color: var(--text-2); padding: 0 2px 6px; }
.bulk-rows { display: flex; flex-direction: column; gap: 8px; }
.bulk-row { border-radius: 10px; }
.bulk-row.is-bad { outline: 2px solid var(--bad); outline-offset: 3px; }
.b-detail { min-width: 0; }
.b-detail.two { display: grid; gap: 6px; }
.b-none { padding-left: 4px; }
.b-amount { text-align: right; font-variant-numeric: tabular-nums; }
.bulk-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 0 4px; }
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dialog-head h2 { margin: 0; font-size: 18px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.toast.error { background: var(--bad-fill); color: #fff; }

/* ---------- Login / setup ---------- */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { text-align: left; }
.login img { display: block; margin-bottom: 8px; }
.login h1 { margin-bottom: 16px; }
.setup-page { padding: 24px 16px 60px; }
.setup { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.setup-head { display: flex; gap: 14px; align-items: flex-start; }
.setup-head h1 { font-size: 22px; margin-bottom: 4px; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; margin-right: 6px; }
.rows { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.setup-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 36px; gap: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr; }
  .tiles.four { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 30; left: 0; top: 0; width: 260px;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 14px; }
  .content { padding: 14px 14px 110px; }
  .two-col, .grid-2 { grid-template-columns: 1fr; }
  .bulk-head { display: none; }
  .bulk-row {
    grid-template-columns: 1fr 1fr 36px; padding: 10px; background: var(--surface-2);
  }
  .bulk-row .b-kind { grid-column: 1 / 3; }
  .bulk-row .b-remove { grid-column: 3; grid-row: 1; }
  .bulk-row .b-detail, .bulk-row .b-label { grid-column: 1 / -1; }
  .bulk-row .b-amount { grid-column: 1; text-align: left; }
  .bulk-row .b-date { grid-column: 2 / -1; }
  .add-btn { display: none; }
  .fab {
    display: grid; place-items: center; position: fixed; right: 18px; bottom: 22px; z-index: 15;
    width: 58px; height: 58px; border-radius: 50%; border: 0;
    background: var(--accent); color: #fff; box-shadow: 0 8px 24px rgba(37, 125, 224, .45); cursor: pointer;
  }
}
@media (max-width: 640px) {
  .after-cols { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .table.steps thead { display: none; }
  .table.steps, .table.steps tbody { display: block; }
  .table.steps tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
  .table.steps tr:last-child { border-bottom: 0; }
  .table.steps td { display: block; border: 0; padding: 0; }
  .table.steps td:nth-child(1) { grid-column: 1 / -1; font-size: 12.5px; color: var(--text-2); }
  .table.steps td:nth-child(1):empty { display: none; }
  .table.steps td:nth-child(2) { grid-column: 1; }
  .table.steps td:nth-child(3) { grid-column: 2; }
  .table.steps td:nth-child(4) { grid-column: 2; font-size: 12.5px; }
  .table.steps td:nth-child(4):not(:empty)::before { content: "Left "; color: var(--text-2); }
  .table.steps td:nth-child(5) { grid-column: 1 / -1; text-align: left; white-space: normal; }
  .table.steps td:nth-child(5):empty { display: none; }
  .table.steps td:empty { display: none; }
  .table.steps tr.sub { background: var(--surface-2); border-radius: 8px; border-bottom: 0; margin: 4px 0; }
  .table.steps tr.sub td { background: none; }
  .table.steps .kind-label { display: none; }
  .tiles, .tiles.two, .tiles.four { grid-template-columns: 1fr 1fr; }
  .tiles.three.flat { grid-template-columns: 1fr; }
  .hero-value { font-size: 40px; }
  .hero-value.smaller { font-size: 28px; }
  .tile-value { font-size: 17px; }
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .row2 { grid-template-columns: 1fr; gap: 0; }
  .clip { max-width: 180px; }
  .dialog {
    width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 16px 16px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .custom-range input { width: 132px; }
  .project-list li { grid-template-columns: 1fr auto; }
  .project-list li .meter { grid-column: 1 / -1; }
  .setup-row { grid-template-columns: 1fr 1fr; }
  .setup-row input[name="name"] { grid-column: 1 / -1; }
  .topbar-actions .btn { padding: 6px 10px; }
}
@media print {
  .sidebar, .topbar-actions, .fab, .filter-row, .actions-row { display: none !important; }
  .layout { display: block; }
}
