/* Finance Manager: plain, light, spreadsheet-clean. No external resources. */

:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --line: #dde1e5;
  --line-strong: #c3c9cf;
  --text: #1c2126;
  --muted: #5a656f;
  --accent: #2c5f8a;
  --accent-strong: #234e72;
  --accent-soft: #e8f0f6;
  --income: #2a7348;
  --expense: #ab3a2d;
  --warn: #8a5a00;
  --warn-bg: #fdf5e3;
  --danger: #a3322a;
  --danger-bg: #fbeceb;
  --ok-bg: #eaf5ee;
  --radius: 4px;
  --sidebar: 224px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --tone-gray: #6c7680;
  --tone-blue: #3f6f9f;
  --tone-teal: #2f8079;
  --tone-green: #4a8a4f;
  --tone-olive: #8a8a3a;
  --tone-amber: #b98322;
  --tone-red: #b5524a;
  --tone-plum: #85609a;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--accent); color: #fff; padding: 8px 12px; border-radius: var(--radius);
}
.skip:focus { top: 8px; }

svg.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .16s ease; }
.topbar { display: none; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.brand { font-weight: 650; font-size: 1.02rem; padding: 4px 8px 16px; display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 3px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
.nav a:hover { background: var(--surface-alt); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 4px; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.who { padding: 0 8px 8px; font-size: .88rem; overflow-wrap: anywhere; }
.who strong { display: block; }
.linkish {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; background: none; border: 0;
  border-radius: var(--radius); cursor: pointer; text-align: left; color: var(--text);
}
.linkish:hover { background: var(--surface-alt); }

main { padding: 24px 28px 48px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 860px) {
  .shell { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 12px;
  }
  .topbar .brand { padding: 0; flex: 1; }
  html:not(.js) #nav-toggle { display: none; }
  /* Without JavaScript the sidebar simply stays visible, stacked above the page. */
  html:not(.js) .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  html.js .sidebar {
    position: fixed; z-index: 30; top: 49px; left: 0; bottom: 0; height: auto; width: min(290px, 86vw);
    transform: translateX(-102%); transition: transform .15s ease; visibility: hidden;
  }
  html.js body.nav-open .sidebar { transform: none; visibility: visible; }
  .sidebar .brand, .collapse-btn { display: none; }
  .scrim { position: fixed; inset: 49px 0 0 0; background: rgba(28,33,38,.3); z-index: 25; }
  body:not(.nav-open) .scrim, html:not(.js) .scrim { display: none; }
  body.nav-open { overflow: hidden; }
  main { padding: 16px 14px 40px; }
}
@media (min-width: 861px) { .scrim { display: none; } }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: var(--surface-alt); border-color: #aab1b8; color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8b2922; border-color: #8b2922; color: #fff; }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { background: var(--surface-alt); border-color: var(--line); }
.btn-sm { padding: 3px 8px; font-size: .86rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.icon-btn { padding: 5px; border: 1px solid transparent; background: none; border-radius: var(--radius); cursor: pointer; color: var(--muted); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-alt); border-color: var(--line); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
input[type="month"], input[type="search"], input[type="file"], select, textarea {
  width: 100%; padding: 7px 9px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); min-height: 36px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); }
.field { margin-bottom: 14px; min-width: 0; }
.field .help, .help { color: var(--muted); font-size: .82rem; margin: 3px 0 0; }
.field-error { color: var(--danger); font-size: .84rem; margin: 4px 0 0; }
.form-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #efc6c2; border-radius: var(--radius); padding: 8px 10px; margin-bottom: 12px; font-size: .92rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: .92rem; }
.check input { margin: 0; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.segmented label { margin: 0; font-weight: 500; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 6px 14px; cursor: pointer; border-right: 1px solid var(--line-strong); }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--accent); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 16px; }
@media (max-width: 980px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid.cols-2 { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .grid.cols-4 { grid-template-columns: 1fr; } }

.stat .label { color: var(--muted); font-size: .84rem; }
.stat .value { font-size: 1.5rem; font-weight: 650; margin: 2px 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .note { color: var(--muted); font-size: .84rem; min-height: 1.3em; }
.pos { color: var(--income); }
.neg { color: var(--expense); }
.stat.warn { border-color: #e4c98a; background: var(--warn-bg); }

.notice { border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--surface); padding: 9px 12px; border-radius: var(--radius); margin-bottom: 14px; }
.notice.warn { border-left-color: #c9962b; background: var(--warn-bg); color: #4d3500; }
.notice.error { border-left-color: var(--danger); background: var(--danger-bg); color: #5c1a15; }
.notice.success { border-left-color: var(--income); background: var(--ok-bg); color: #1f4b32; }
.flash { list-style: none; margin: 0 0 14px; padding: 0; }
.flash li { margin-bottom: 6px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
@media (min-width: 861px) { .table-wrap { overflow: visible; } }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th { position: sticky; top: 0; z-index: 2; font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--surface-alt); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover { color: var(--text); }
.table tbody tr:hover { background: var(--surface-alt); }
.table tbody tr.selected { background: var(--accent-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.name-cell { max-width: 340px; overflow-wrap: anywhere; }
.table .row-note { display: block; color: var(--muted); font-size: .82rem; }
.table .row-actions { white-space: nowrap; text-align: right; }
.table tfoot td { font-weight: 600; background: var(--surface-alt); border-bottom: 0; }
.check-col { width: 34px; }
.sort-ind { margin-left: 3px; color: var(--accent); }

.tone { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: baseline; background: var(--tone-gray); flex: none; }
.tone-gray { --tone: var(--tone-gray); } .tone-blue { --tone: var(--tone-blue); } .tone-teal { --tone: var(--tone-teal); }
.tone-green { --tone: var(--tone-green); } .tone-olive { --tone: var(--tone-olive); } .tone-amber { --tone: var(--tone-amber); }
.tone-red { --tone: var(--tone-red); } .tone-plum { --tone: var(--tone-plum); }
.tone.tone-gray { background: var(--tone-gray); } .tone.tone-blue { background: var(--tone-blue); } .tone.tone-teal { background: var(--tone-teal); }
.tone.tone-green { background: var(--tone-green); } .tone.tone-olive { background: var(--tone-olive); } .tone.tone-amber { background: var(--tone-amber); }
.tone.tone-red { background: var(--tone-red); } .tone.tone-plum { background: var(--tone-plum); }

.tag { display: inline-block; font-size: .76rem; padding: 1px 7px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--muted); background: var(--surface); white-space: nowrap; }
.tag.income { color: var(--income); border-color: #b7d6c3; background: var(--ok-bg); }
.tag.expense { color: var(--expense); border-color: #e3c0bb; background: var(--danger-bg); }
.tag.warn { color: var(--warn); border-color: #e4c98a; background: var(--warn-bg); }

@media (max-width: 720px) {
  .table.stack thead { position: absolute; left: -9999px; }
  .table thead th { position: static; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { border-bottom: 1px solid var(--line-strong); padding: 8px 4px; position: relative; }
  .table.stack td { border: 0; padding: 3px 6px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: none; }
  .table.stack td.check-col { position: absolute; right: 0; top: 6px; width: auto; }
  .table.stack td.check-col::before, .table.stack td:not([data-label])::before { content: none; }
  .table.stack td.name-cell { max-width: none; }
  .table.stack td.row-actions { justify-content: flex-end; }
  .table.stack tfoot { display: block; }
  .table.stack tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; }
  .table.stack tfoot td { width: auto; }
}

/* ---------- filters / pagination ---------- */
.filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px 12px; align-items: end; }
.filters .field { margin: 0; }
.filters .span2 { grid-column: span 2; }
@media (max-width: 1000px) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filters .span2 { grid-column: 1 / -1; } }
.filter-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.results-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 16px 0 8px; flex-wrap: wrap; }
.bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; background: var(--accent-soft); border: 1px solid #c4d7e6; border-radius: var(--radius); margin-bottom: 8px; }
.bulk select { width: auto; min-height: 30px; padding: 3px 8px; }
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 32px; padding: 5px 9px; text-align: center; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; background: var(--surface); color: var(--text); }
.pagination a:hover { background: var(--surface-alt); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .gap { border: 0; background: none; color: var(--muted); }
#results[aria-busy="true"] { opacity: .6; transition: opacity .1s; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 10px; }
.state-error { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px; background: var(--danger-bg); border: 1px solid #efc6c2; border-radius: var(--radius); color: #5c1a15; }
.loading { color: var(--muted); padding: 18px 4px; }

/* ---------- progress / lists ---------- */
.progress { height: 8px; background: #e9ecef; border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width .2s ease; }
.progress.over > span { background: var(--expense); }
.progress.near > span { background: #c9962b; }
.budget-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.budget-row:last-child { border-bottom: 0; }
.budget-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.budget-top .amt { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }
.budget-top .over-note { color: var(--expense); font-weight: 600; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .sub { color: var(--muted); font-size: .82rem; display: block; }
.mini-list .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches label { margin: 0; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches span { display: block; width: 26px; height: 26px; border-radius: 4px; border: 2px solid transparent; outline: 1px solid var(--line-strong); outline-offset: -1px; cursor: pointer; }
.swatches input:checked + span { border-color: var(--surface); outline: 2px solid var(--text); }
.swatches input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatches .tone-gray span, .swatches span.tone-gray { background: var(--tone-gray); }
.swatches span.tone-blue { background: var(--tone-blue); } .swatches span.tone-teal { background: var(--tone-teal); }
.swatches span.tone-green { background: var(--tone-green); } .swatches span.tone-olive { background: var(--tone-olive); }
.swatches span.tone-amber { background: var(--tone-amber); } .swatches span.tone-red { background: var(--tone-red); }
.swatches span.tone-plum { background: var(--tone-plum); }

.month-switch { display: flex; align-items: center; gap: 6px; }
.month-switch .label { min-width: 8.5em; text-align: center; font-weight: 600; }

/* ---------- dialogs and toasts ---------- */
dialog { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: 0 6px 24px rgba(20,28,36,.14); }
dialog::backdrop { background: rgba(28,33,38,.35); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 16px; max-height: calc(100vh - 200px); overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-alt); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; }
.keys dt { text-align: right; }
.keys dd { margin: 0; color: var(--muted); }
kbd { font-family: var(--mono); font-size: .82rem; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 3px; background: var(--surface-alt); }

#toasts { position: fixed; z-index: 60; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 28px)); }
.toast { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: #26303a; color: #fff; padding: 10px 12px; border-radius: var(--radius); font-size: .92rem; animation: toast-in .15s ease; }
.toast.success { border-left: 4px solid #6bbf8a; }
.toast.error { border-left: 4px solid #e58a80; }
.toast.warn { border-left: 4px solid #e2b95a; }
.toast button { background: none; border: 0; color: #cfe3f5; text-decoration: underline; cursor: pointer; padding: 0 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- charts ---------- */
.chart-card .card-head { margin-bottom: 8px; }
.chart-box { position: relative; min-height: 120px; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-table { width: 100%; }
.legend { display: flex; gap: 14px; font-size: .84rem; color: var(--muted); flex-wrap: wrap; margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: baseline; }
.legend .l-income { background: var(--income); } .legend .l-expense { background: var(--expense); } .legend .l-line { background: var(--accent); }
.ax-text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.ax-grid { stroke: #e7eaed; stroke-width: 1; }
.ax-zero { stroke: var(--line-strong); stroke-width: 1; }
.m-income { fill: var(--income); } .m-expense { fill: var(--expense); }
.m-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.m-dot { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.m-hit { fill: transparent; }
.mark:hover, .mark:focus { opacity: .8; outline: none; }
.mark:focus-visible { stroke: var(--text); stroke-width: 2; }
.bar-tone-gray { fill: var(--tone-gray); } .bar-tone-blue { fill: var(--tone-blue); } .bar-tone-teal { fill: var(--tone-teal); }
.bar-tone-green { fill: var(--tone-green); } .bar-tone-olive { fill: var(--tone-olive); } .bar-tone-amber { fill: var(--tone-amber); }
.bar-tone-red { fill: var(--tone-red); } .bar-tone-plum { fill: var(--tone-plum); }
.tooltip { position: absolute; z-index: 5; pointer-events: none; background: #26303a; color: #fff; font-size: .82rem; padding: 5px 8px; border-radius: var(--radius); white-space: nowrap; transform: translate(-50%, -100%); }
.tooltip b { font-weight: 600; }
.range-bar { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; }
.range-bar .field { margin: 0; }
.range-bar input { width: auto; }
.top-list { list-style: none; margin: 0; padding: 0; counter-reset: top; }
.top-list li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.top-list li:last-child { border-bottom: 0; }
.top-list li::before { counter-increment: top; content: counter(top); color: var(--muted); width: 1.2em; font-variant-numeric: tabular-nums; }
.top-list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px 14px; }
.auth-card { width: min(420px, 100%); }
.auth-card .brand { padding: 0 0 16px; justify-content: center; font-size: 1.15rem; }
.auth-card h1 { font-size: 1.2rem; margin-bottom: 14px; }
.auth-foot { text-align: center; margin-top: 14px; font-size: .92rem; color: var(--muted); }

/* ---------- import ---------- */
.row-error { color: var(--danger); font-size: .84rem; }
/* Card statement preview: the description is a link that opens a small editor. */
.row-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.row-link:hover { color: var(--accent-strong); }
.import-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
tr.is-dup td, tr.is-bad td { color: var(--muted); }
tr.is-bad { background: var(--danger-bg); }



/* ---------- additions: layout ---------- */
.nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 8px 3px; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 10px; padding: 6px 8px; cursor: pointer;
  background: var(--surface-alt); border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted);
}
.search-trigger:hover { border-color: var(--line-strong); color: var(--text); }
.search-trigger span { flex: 1; text-align: left; }
.badge { position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--expense); color: #fff; font-size: .68rem; line-height: 16px; text-align: center; }
.bell { position: relative; text-decoration: none; }
.bottom-nav, .fab { display: none; }
@media (max-width: 860px) {
  main { padding-bottom: 88px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; color: var(--muted); text-decoration: none; font-size: .72rem; border-radius: var(--radius); }
  .bottom-nav a[aria-current="page"] { color: var(--accent-strong); font-weight: 600; }
  .fab { display: grid; place-items: center; justify-self: center; width: 48px; height: 48px; margin-top: -22px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; cursor: pointer; box-shadow: 0 1px 4px rgba(20,28,36,.25); }
  .fab svg.icon { width: 22px; height: 22px; }
  #toasts { bottom: 76px; }
}

/* ---------- additions: icons, chips, small parts ---------- */
.cat-label { display: inline-flex; align-items: center; gap: 6px; }
svg.icon.cat-icon { width: 16px; height: 16px; color: var(--tone-gray); }
.tone-text-gray { color: var(--tone-gray); } .tone-text-blue { color: var(--tone-blue); } .tone-text-teal { color: var(--tone-teal); }
.tone-text-green { color: var(--tone-green); } .tone-text-olive { color: var(--tone-olive); } .tone-text-amber { color: var(--tone-amber); }
.tone-text-red { color: var(--tone-red); } .tone-text-plum { color: var(--tone-plum); }
.sub-cat { padding-left: 28px !important; }
.block { display: block; }
.tag-chip { display: inline-block; font-size: .74rem; padding: 0 7px; margin-left: 4px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); text-decoration: none; }
a.tag-chip:hover { background: #d8e6f1; }
.row-meta { display: block; font-size: .8rem; }
.row-meta .tag-chip:first-child { margin-left: 0; }
.chips { display: flex; gap: 6px; margin-top: 4px; }
.chip { font-size: .78rem; padding: 1px 8px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; }
.chip:hover { background: var(--accent-soft); }
.chip-static { display: inline-block; padding: 2px 9px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); font-size: .88rem; }
.chip-static.pos { color: var(--income); } .chip-static.neg { color: var(--expense); }
.inline-cat { display: inline-flex; align-items: center; gap: 6px; padding: 1px 4px; margin: -1px -4px; border: 1px dashed transparent; background: none; border-radius: var(--radius); cursor: pointer; color: inherit; text-align: left; }
.inline-cat:hover { border-color: var(--line-strong); background: var(--surface); }
.inline-select { width: auto; min-height: 28px; padding: 2px 6px; }
.notes-check { margin-top: 26px; }
.roll { margin-top: 26px; }
fieldset.field { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
fieldset.field legend { font-weight: 600; font-size: .88rem; padding: 0; margin-bottom: 6px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; }
.icon-grid label { margin: 0; }
.icon-grid input { position: absolute; opacity: 0; pointer-events: none; }
.icon-grid span:not(.sr-only) { display: grid; place-items: center; height: 34px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; color: var(--muted); }
.icon-grid input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.icon-grid input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
li.inactive { opacity: .6; }
.views-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.views-bar select { width: auto; min-width: 160px; }

/* quick add, onboarding, alerts */
.quick-add { margin-bottom: 16px; }
.quick-row { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 4px 4px 4px 10px; }
.quick-row svg.icon { color: var(--accent); }
.quick-row input { border: 0; min-height: 34px; background: none; padding: 4px; }
.quick-row input:focus { outline: none; }
.quick-row:focus-within { outline: 2px solid var(--accent); }
.quick-preview { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.quick-add .help { margin-top: 4px; }
.checklist, .alert-list { list-style: none; margin: 0; padding: 0; }
.checklist li, .alert-list li { display: flex; gap: 8px; align-items: center; padding: 6px 0; }
.checklist li.done a { color: var(--muted); text-decoration: line-through; }
.checklist li.done svg.icon { color: var(--income); }
.alert-list li.error svg.icon { color: var(--expense); } .alert-list li.warn svg.icon { color: #b07b12; }

/* search dialog */
dialog.search-dialog { width: min(620px, calc(100vw - 20px)); margin-top: 10vh; }
.search-box { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.search-box input { border: 0; min-height: 36px; padding: 4px; }
.search-box input:focus { outline: none; }
.search-results { max-height: 52vh; overflow-y: auto; }
.search-group { padding: 8px 14px 2px; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.search-option { display: flex; justify-content: space-between; gap: 12px; padding: 8px 14px; color: var(--text); text-decoration: none; }
.search-option.active { background: var(--accent-soft); }
.search-title { font-weight: 500; overflow-wrap: anywhere; }
.search-hint { padding: 10px 14px; margin: 0; }

/* passwords */
.pw { position: relative; }
.pw input { padding-right: 38px; }
.pw-toggle { position: absolute; right: 2px; top: 2px; height: 32px; width: 34px; display: grid; place-items: center; background: none; border: 0; border-radius: var(--radius); cursor: pointer; color: var(--muted); }
.pw-toggle:hover { color: var(--text); background: var(--surface-alt); }
.caps-warn { color: #8a5a00; font-size: .84rem; margin: 4px 0 0; }
.meter { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.meter-track { flex: 1; height: 6px; background: #e9ecef; border-radius: 3px; overflow: hidden; }
.meter-bar { display: block; height: 100%; width: 0; background: var(--expense); }
.meter[data-level="2"] .meter-bar { background: #c9962b; }
.meter[data-level="3"] .meter-bar, .meter[data-level="4"] .meter-bar { background: var(--income); }
.meter-label { font-size: .8rem; color: var(--muted); min-width: 8.5em; }
.match-note { font-size: .84rem; margin: 4px 0 0; color: var(--expense); }
.match-note.ok { color: var(--income); }

/* goals, accounts */
.goal-grid, .account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.goal-grid .card + .card, .account-grid .card + .card { margin-top: 0; }
.goal-head { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.goal-title h2 { margin-bottom: 2px; }
.ring { width: 72px; height: 72px; flex: none; }
.ring circle { fill: none; stroke-width: 7; }
.ring-track { stroke: #e9ecef; } .ring-fill { stroke: var(--tone-teal); stroke-linecap: round; }
.ring-text { font-size: 15px; font-weight: 600; fill: var(--text); }
.goal .mini-list li { align-items: center; }
.goal .actions { margin-top: 10px; }
.account-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.account-balance { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; margin: 6px 0 2px; }
.account.archived { opacity: .65; }
.account.total { background: var(--surface-alt); }
.account .actions { margin-top: 8px; }

/* budgets */
.budget-name { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.budget-note { margin: 6px 0 0; }
.budget-top .row-actions { margin-left: auto; }

/* ---------- additions: charts ---------- */
.m-budget { fill: var(--accent); }
.m-line-expense { stroke: var(--expense); }
.m-line-budget { stroke: var(--accent); stroke-dasharray: 5 4; stroke-width: 1.5; }
.m-area { fill: var(--accent); fill-opacity: .1; stroke: none; }
.legend .l-line { background: var(--accent); }
.legend .sw, i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: baseline; }
i.sw.tone-gray { background: var(--tone-gray); } i.sw.tone-blue { background: var(--tone-blue); } i.sw.tone-teal { background: var(--tone-teal); }
i.sw.tone-green { background: var(--tone-green); } i.sw.tone-olive { background: var(--tone-olive); } i.sw.tone-amber { background: var(--tone-amber); }
i.sw.tone-red { background: var(--tone-red); } i.sw.tone-plum { background: var(--tone-plum); }
.chart-legend { margin-top: 8px; }
.seg { stroke: #fff; stroke-width: 1; }
.slice { stroke: #fff; stroke-width: 1.5; }
.donut-wrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: center; }
.donut-wrap .legend { flex-direction: column; gap: 4px; margin: 0; }
.donut-value { font-size: 18px; font-weight: 600; fill: var(--text); }
.track { fill: #e9ecef; }
.spark-grid { display: grid; gap: 12px; }
.spark-cell { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 8px 4px; min-width: 0; }
.spark-head { display: flex; justify-content: space-between; gap: 8px; font-size: .86rem; }
.spark { fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke: var(--tone-gray); }
.spark-blue { stroke: var(--tone-blue); } .spark-teal { stroke: var(--tone-teal); } .spark-green { stroke: var(--tone-green); }
.spark-olive { stroke: var(--tone-olive); } .spark-amber { stroke: var(--tone-amber); } .spark-red { stroke: var(--tone-red); } .spark-plum { stroke: var(--tone-plum); }
.spark-dot:hover, .spark-dot:focus { fill: var(--text); outline: none; }
.heat-wrap { overflow-x: auto; }
.heat { fill: #edf0f2; background: #edf0f2; }
.heat-1 { fill: #cfe0ec; background: #cfe0ec; } .heat-2 { fill: #9fc0d9; background: #9fc0d9; }
.heat-3 { fill: #5f93bb; background: #5f93bb; } .heat-4 { fill: #2c5f8a; background: #2c5f8a; }
.heat-legend { align-items: center; gap: 4px; margin: 6px 0 0; }
.heat-legend i.heat { width: 12px; height: 12px; margin: 0; border-radius: 2px; }
.range-bar select { min-width: 150px; }
.range-note { flex-basis: 100%; margin: 0; }

/* ---------- reports and print ---------- */
.report-table tr.group th { background: var(--surface-alt); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.report-table tr.total td { font-weight: 600; border-top: 1px solid var(--line-strong); }
.report-table tfoot td { border-top: 2px solid var(--line-strong); }
.print-only { display: none; }
@media print {
  body { background: #fff; font-size: 11pt; }
  .sidebar, .topbar, .bottom-nav, .scrim, .no-print, .actions, #toasts, .skip { display: none !important; }
  .shell { display: block; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; break-inside: avoid; }
  .card + .card { margin-top: 14pt; }
  .grid.cols-2 { display: block; }
  .table th, .table td { padding: 3pt 6pt; }
  .table thead th { position: static; background: none; }
  .print-only { display: block; }
  a { color: inherit; text-decoration: none; }
}

.grid > .card + .card { margin-top: 0; }
.btn kbd { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35); color: inherit; }
.field .help ul { margin: 4px 0 0; padding-left: 18px; }
.field .help li { margin: 0; }
.chart-box .donut-wrap svg { width: 240px; max-width: 100%; height: auto; }
.chart-box .heat-wrap svg { width: auto; max-width: none; }
.chart-box .spark-cell svg { width: 100%; }

.budget-amt { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; font-size: .9rem; font-variant-numeric: tabular-nums; }
.budget-amt .over-note { color: var(--expense); font-weight: 600; }
.budget-top { margin-bottom: 2px; }
@media (max-width: 420px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat .value { font-size: 1.1rem; }
  .card { padding: 12px; }
  .page-head .btn kbd { display: none; }
}

/* ---------- foldable sidebar ---------- */
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.sidebar-top .brand { padding-bottom: 12px; }
.collapse-btn { margin-bottom: 8px; }
.nav-group { margin: 0; }
.nav-group-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 12px 8px 3px; background: none; border: 0;
  cursor: pointer; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
.nav-group-toggle:hover { color: var(--text); }
.nav-group-toggle svg.icon { width: 14px; height: 14px; transition: transform .15s ease; }
.nav-group-toggle[aria-expanded="false"] svg.icon { transform: rotate(-90deg); }
html.js .nav-label { display: none; }
.nav a, .linkish, .search-trigger, .brand { position: relative; }
@media (min-width: 861px) {
  html[data-sidebar="collapsed"] { --sidebar: 60px; }
  html[data-sidebar="collapsed"] .sidebar { padding: 12px 8px; overflow: visible; }
  html[data-sidebar="collapsed"] .sidebar-top { flex-direction: column; align-items: center; }
  html[data-sidebar="collapsed"] .sidebar-top .brand { padding-bottom: 6px; }
  html[data-sidebar="collapsed"] .nav-text, html[data-sidebar="collapsed"] .brand-text, html[data-sidebar="collapsed"] .who {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: -1px;
  }
  html[data-sidebar="collapsed"] .nav a, html[data-sidebar="collapsed"] .linkish, html[data-sidebar="collapsed"] .search-trigger {
    justify-content: center; padding: 8px 0;
  }
  html[data-sidebar="collapsed"] .nav-group-toggle, html[data-sidebar="collapsed"] .nav-label { display: none; }
  html[data-sidebar="collapsed"] .nav-group { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
  html[data-sidebar="collapsed"] .nav-group-body[hidden] { display: block !important; }
  html[data-sidebar="collapsed"] .nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--accent); }
  html[data-sidebar="collapsed"] .nav a[data-tip]:hover::after, html[data-sidebar="collapsed"] .nav a[data-tip]:focus-visible::after,
  html[data-sidebar="collapsed"] .linkish[data-tip]:hover::after, html[data-sidebar="collapsed"] .linkish[data-tip]:focus-visible::after,
  html[data-sidebar="collapsed"] .search-trigger[data-tip]:hover::after, html[data-sidebar="collapsed"] .brand[data-tip]:hover::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); z-index: 50;
    background: #26303a; color: #fff; padding: 3px 8px; border-radius: var(--radius); font-size: .82rem; font-weight: 500; white-space: nowrap; pointer-events: none;
  }
  html[data-sidebar="collapsed"] .sidebar-foot { border-top: 0; }
}
@media (max-width: 860px) { .nav-group-toggle { padding-top: 14px; } }
.field-hint { font-size: .84rem; margin: 4px 0 0; color: var(--muted); }
.field-hint.ok { color: var(--income); }
.field-hint.bad { color: var(--expense); }

/* ---------- insights, people, setup ---------- */
.insight-list { list-style: none; margin: 0; padding: 0; }
.insight-list li { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; }
.insight-list li svg.icon { margin-top: 3px; }
.insight-list li a { color: var(--text); text-decoration: none; }
.insight-list li a:hover { text-decoration: underline; }
.insight-list li.good svg.icon { color: var(--income); }
.insight-list li.warn svg.icon { color: #b07b12; }
.insight-list li.bad svg.icon { color: var(--expense); }
.insight-list li.info svg.icon { color: var(--accent); }
.person-net { font-weight: 600; margin: 4px 0 8px; }
.setup .card + .card { margin-top: 16px; }
.setup h2 { margin-bottom: 8px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 14px; }
.danger-zone { border-color: #e3c0bb; }
.danger-zone h3 { margin-bottom: 4px; }
.form-error ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- disclosure sections, split rows, reconcile ---------- */
details.more { margin: 4px 0 12px; border-top: 1px solid var(--line); padding-top: 8px; }
details.more > summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--accent-strong); padding: 4px 0; }
details.more[open] > summary { margin-bottom: 8px; }
.split-row { display: grid; grid-template-columns: 1fr 9rem auto; gap: 8px; margin-bottom: 6px; align-items: center; }
.tx-history { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.split-chip { background: #efe9f5; color: #5d3f73; }
.rec-chip { background: var(--ok-bg); color: #1f4b32; }
details.reconcile { margin: 12px 0; }
details.reconcile > summary { cursor: pointer; font-weight: 600; }
.sys-status { font-size: .8rem; color: var(--muted); }
.sys-status.offline { color: var(--expense); font-weight: 600; }

#sys-status { position: fixed; z-index: 40; left: calc(var(--sidebar) + 14px); bottom: 10px; padding: 2px 8px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
#sys-status:empty { display: none; }
@media (max-width: 860px) { #sys-status { left: 12px; bottom: 76px; } }
.sidebar-top .brand { flex: 1; min-width: 0; padding-right: 0; font-size: .98rem; }
.brand-text { white-space: nowrap; }
@media (max-width: 860px) { .sidebar .collapse-btn, .sidebar .sidebar-top { display: none; } }

/* ---------- month plan ---------- */
.plan-head { flex-wrap: wrap; gap: 8px; }
.plan-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.plan-nav strong { min-width: 9.5em; text-align: center; text-transform: capitalize; }
.plan > .grid, .plan .notice, .plan-filter { margin-top: 12px; }
.plan .notice p { margin: 2px 0; }
.plan .notice details { margin-top: 6px; }
.plan-table tr.plan-future td { color: var(--muted); }
.plan-table tr.plan-future td.num.pos { color: var(--income); }
.plan-table tr.plan-future td.num.neg { color: var(--expense); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.plan-summary { margin-top: 12px; padding: 10px 14px; }
.plan-line { margin: 0; }
.account-limit { margin: 6px 0; }
.account-limit .progress { margin-top: 4px; }
