/* ==========================================================================
   Husholdningsbudget
   A quiet, precise interface for two people and eight years of numbers.
   Deep teal on cool neutrals. Tabular figures everywhere money appears.
   ========================================================================== */

:root {
  --paper:        #F1F4F5;
  --surface:      #FFFFFF;
  --surface-2:    #F7F9FA;
  --ink:          #0F161A;
  --ink-2:        #3E4C54;
  --muted:        #6B7B84;
  --line:         #DCE3E6;
  --line-strong:  #C3CED4;

  --accent:       #0E5A50;
  --accent-ink:   #FFFFFF;
  --accent-soft:  #E1EFEC;

  --pos:          #0F6B45;
  --neg:          #AF3329;
  --warn:         #9E560F;
  --over-soft:    #F7E4E2;

  --radius:       8px;
  --radius-sm:    5px;
  --shadow:       0 1px 2px rgba(16,32,40,.05), 0 1px 1px rgba(16,32,40,.04);

  /* Density. This is a working ledger, not a marketing page: the whole month
     should be readable without scrolling, the way the spreadsheet was. */
  --row-h:        1.55rem;
  --maxw:         78rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:       #0D1113;
    --surface:     #151B1E;
    --surface-2:   #1B2327;
    --ink:         #E7EEF0;
    --ink-2:       #B2C2C8;
    --muted:       #7C8F97;
    --line:        #232E33;
    --line-strong: #35454C;

    --accent:      #45C9B0;
    --accent-ink:  #06201C;
    --accent-soft: #10312C;

    --pos:         #4FC28C;
    --neg:         #EE837A;
    --warn:        #DDA75E;
    --over-soft:   #35211F;

    --shadow:      0 1px 2px rgba(0,0,0,.4);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.num, .stat-value, .inp-amount, td.num, .amount-input input {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.muted { color: var(--muted); }
.pos   { color: var(--pos); }
.neg   { color: var(--neg); }
.ta-r  { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Top bar ------------------------------------------------------ */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .7rem clamp(.9rem, 3vw, 1.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--ink); text-decoration: none; font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-mark {
  display: grid; place-items: center;
  width: 1.65rem; height: 1.65rem; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink);
  font-size: .85rem; font-weight: 700;
}
.brand-text { font-size: .98rem; }

.topbar-right { display: flex; align-items: center; gap: .85rem; font-size: .88rem; }
.whoami { color: var(--muted); }
.logout { color: var(--muted); text-decoration: none; }
.logout:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Tabs --------------------------------------------------------- */

.tabs {
  display: flex; gap: .15rem;
  padding: 0 clamp(.5rem, 3vw, 1.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky; top: 0; z-index: 20;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  padding: .7rem .8rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .92rem; font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Layout ------------------------------------------------------- */

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.75rem) clamp(.9rem, 3vw, 1.5rem) 4rem;
}

.page-title {
  margin: 0 0 1rem;
  font-size: clamp(1.35rem, 3.5vw, 1.7rem);
  font-weight: 640;
  letter-spacing: -0.02em;
}

.foot {
  display: flex; gap: .5rem; justify-content: center;
  padding: 1.5rem 1rem 2.5rem;
  color: var(--muted); font-size: .82rem;
}

/* ---------- Month navigator ---------------------------------------------- */

.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; margin-bottom: 1.1rem;
}
.mn-title {
  margin: 0; text-align: center; flex: 1;
  font-size: clamp(1.25rem, 4vw, 1.6rem); font-weight: 640;
  letter-spacing: -0.02em;
}
.mn-btn {
  display: grid; place-items: center;
  width: 2.3rem; height: 2.3rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-size: 1rem;
}
.mn-btn:hover { border-color: var(--line-strong); color: var(--ink); }

/* ---------- Stat strip --------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .6rem;
  margin-bottom: 1.1rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .75rem .85rem;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .1rem;
}
.stat-accent { border-color: var(--accent); }
.stat-label {
  font-size: .74rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
.stat-value { font-size: 1.4rem; font-weight: 620; letter-spacing: -0.02em; }
.stat-sub   { font-size: .78rem; color: var(--muted); }

/* ---------- Buttons ------------------------------------------------------ */

.quick-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.35rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem;
  padding: .55rem .95rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit; font-size: .92rem; font-weight: 550;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); background: var(--surface-2); }
.btn-lg { padding: .8rem 1.4rem; font-size: 1rem; }

.btn-icon {
  background: none; border: 0; cursor: pointer;
  color: var(--muted); font-size: 1.15rem; line-height: 1;
  padding: .15rem .35rem; border-radius: 4px;
}
.btn-icon:hover { color: var(--neg); background: var(--over-soft); }

.link-quiet { color: var(--muted); text-decoration: none; }
.link-quiet:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Panels ------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem clamp(.85rem, 2.5vw, 1.15rem);
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.panel-title {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
  margin: 0 0 .85rem;
  font-size: .95rem; font-weight: 650; letter-spacing: -0.01em;
}
.panel-total {
  font-size: .88rem; font-weight: 550; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.callout {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: var(--radius-sm);
  padding: .7rem .9rem;
  margin: 0 0 1rem;
  font-size: .89rem; color: var(--ink-2);
}

.empty { color: var(--muted); font-size: .92rem; padding: .5rem 0; }
.hint  { color: var(--muted); font-size: .8rem; margin: .35rem 0 0; }

.alert {
  padding: .65rem .85rem; border-radius: var(--radius-sm);
  margin: 0 0 1rem; font-size: .9rem;
}
.alert-ok    { background: var(--accent-soft); color: var(--ink-2); border: 1px solid var(--accent); }
.alert-error { background: var(--over-soft);  color: var(--neg);   border: 1px solid var(--neg); }

/* ---------- Category rows with progress ---------------------------------- */

.cats { list-style: none; margin: 0; padding: 0; }

.cat { padding: .6rem 0; border-top: 1px solid var(--line); }
.cat:first-child { border-top: 0; padding-top: 0; }

.cat-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .75rem; margin-bottom: .35rem;
}
.cat-name { font-size: .93rem; font-weight: 500; }
.cat-nums { font-size: .9rem; white-space: nowrap; }
.cat-nums strong { font-weight: 620; }
.num-sep { color: var(--line-strong); margin: 0 .15rem; }

.bar {
  height: 6px; border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
/* Deliberately unanimated. Bar length is rendered server-side and never
   changes on the client, so animating it would be dead code that only risks
   layout thrash. */
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-fill.is-near { background: var(--warn); }
.bar-fill.is-over { background: var(--neg); }

.cat-foot {
  display: flex; justify-content: space-between; gap: .75rem;
  margin-top: .3rem; font-size: .79rem;
}

.chip {
  display: inline-block;
  padding: .05rem .4rem; margin-left: .35rem;
  border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: .7rem; font-weight: 500; color: var(--muted);
  vertical-align: middle;
}
.chip-child { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Tables ------------------------------------------------------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; font-size: .74rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  padding: .4rem .5rem; border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.table td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table-txn td:first-child { color: var(--muted); font-size: .85rem; }

.inp-amount {
  width: 7.5rem; text-align: right;
  padding: .35rem .5rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink); font: inherit; font-size: .9rem;
}
.inp-amount:focus { background: var(--surface); border-color: var(--accent); }

.result-line { font-size: .9rem; color: var(--ink-2); margin: 0 0 .75rem; }

/* ---------- Forms -------------------------------------------------------- */

.form { max-width: 34rem; }
.form-add { max-width: 28rem; }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.field > label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

input[type="text"], input[type="search"], input[type="date"], select {
  padding: .6rem .7rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink); font: inherit; font-size: .95rem;
  width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }

.amount-input { position: relative; display: flex; align-items: center; }
.amount-input input {
  font-size: 1.85rem; font-weight: 600; letter-spacing: -0.02em;
  padding: .55rem 3rem .55rem .7rem;
}
.amount-suffix {
  position: absolute; right: .8rem;
  color: var(--muted); font-size: 1rem; pointer-events: none;
}

.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: 1.25rem; }
.form-actions-sticky {
  position: sticky; bottom: 0;
  background: linear-gradient(to top, var(--paper) 62%, transparent);
  padding: 1rem 0 1.25rem; margin-top: .5rem;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: .6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem;
  margin-bottom: 1rem;
}
.filters .field { margin-bottom: 0; }
.field-actions { flex-direction: row; align-items: end; gap: .4rem; }

.inline-form { display: flex; gap: .5rem; align-items: center; margin-bottom: .9rem; flex-wrap: wrap; }
.inline-form label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.inline-form select { width: auto; min-width: 13rem; }
form.inline { display: inline; }

/* ---------- Charts ------------------------------------------------------- */

.chart-scroll { width: 100%; }
.chart { display: block; width: 100%; height: 220px; }

.grid      { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.bar-rect  { fill: var(--accent); }
.bar-rect.is-over { fill: var(--neg); }
.plan-tick { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }

.line      { fill: none; stroke: var(--accent); stroke-width: 2;
             vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.area      { fill: var(--accent); opacity: .11; stroke: none; }
.line-debt { stroke: var(--warn); }
.area-debt { fill: var(--warn); }

.chart-axis {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  margin-top: .3rem;
}
.ax {
  font-size: .66rem; color: var(--muted); text-align: center;
  overflow: hidden; white-space: nowrap;
}
.chart-range {
  display: flex; justify-content: space-between;
  font-size: .76rem; color: var(--ink-2); margin-top: .35rem;
}

.legend { display: flex; gap: .9rem; align-items: center; font-size: .78rem; color: var(--muted); margin: .6rem 0 0; }
.key { display: inline-block; width: .8rem; height: .55rem; border-radius: 2px; margin-right: .25rem; vertical-align: middle; }
.key-bar  { background: var(--accent); }
.key-over { background: var(--neg); }
.key-plan { background: none; border-top: 2px dashed var(--ink-2); height: 0; }

.mini-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
  gap: .5rem; margin-bottom: .9rem;
}
.mini-stats > div { display: flex; flex-direction: column; gap: .1rem; }
.mini-stats .num { font-size: 1.05rem; font-weight: 600; }

.details { margin-top: .75rem; }
.details > summary {
  cursor: pointer; font-size: .85rem; color: var(--muted);
  padding: .3rem 0;
}
.details > summary:hover { color: var(--ink); }

/* ---------- Login -------------------------------------------------------- */

.login-body {
  display: grid; place-items: center; min-height: 100dvh;
  padding: 1.5rem;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--accent-soft) 0%, transparent 60%),
    var(--paper);
}
.login-card {
  width: 100%; max-width: 22rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 2rem 1.6rem;
  box-shadow: 0 8px 30px rgba(15,30,38,.09);
  text-align: center;
}
.login-mark {
  display: grid; place-items: center;
  width: 2.7rem; height: 2.7rem; margin: 0 auto 1rem;
  border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 1.25rem; font-weight: 700;
}
.login-card h1 { margin: 0 0 .25rem; font-size: 1.2rem; font-weight: 640; letter-spacing: -0.02em; }
.login-sub { margin: 0 0 1.5rem; color: var(--muted); font-size: .88rem; }
.login-btn-wrap { display: flex; justify-content: center; min-height: 44px; }
.login-note { margin: 1.5rem 0 0; font-size: .77rem; color: var(--muted); line-height: 1.5; }

code {
  font-family: var(--mono); font-size: .86em;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: .05em .3em; border-radius: 3px;
}

/* ---------- Projekt Bolig ------------------------------------------------ */

:root {
  --s1: #0E5A50;   /* teal   — indkomst */
  --s2: #B0761A;   /* amber  — faste udgifter */
  --s3: #3A5CA8;   /* indigo — overskud */
}
@media (prefers-color-scheme: dark) {
  :root { --s1: #45C9B0; --s2: #E0A75A; --s3: #7C9BE8; }
}

.series-1 { fill: var(--s1); }
.series-2 { fill: var(--s2); }
.series-3 { fill: var(--s3); }
.series-key-1, .series-key-2, .series-key-3 {
  display: inline-block; width: .8rem; height: .55rem;
  border-radius: 2px; margin-right: .3rem; vertical-align: middle;
}
.series-key-1 { background: var(--s1); }
.series-key-2 { background: var(--s2); }
.series-key-3 { background: var(--s3); }

.chart-tall { height: 280px; }
.legend { flex-wrap: wrap; }
.legend span { white-space: nowrap; }

.sub-title {
  margin: 1.25rem 0 .6rem;
  font-size: .82rem; font-weight: 650; letter-spacing: .02em;
  text-transform: uppercase; color: var(--muted);
}

.row-total td { border-top: 1px solid var(--line-strong); background: var(--surface-2); }
.table tbody tr.row-total:hover { background: var(--surface-2); }

.badge {
  display: inline-block; padding: .1rem .45rem;
  border-radius: 99px; font-size: .72rem; font-weight: 600;
  white-space: nowrap; border: 1px solid transparent;
}
.badge-ok   { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.badge-run  { background: color-mix(in srgb, var(--s2) 14%, transparent); color: var(--warn); border-color: var(--warn); }
.badge-book { background: color-mix(in srgb, var(--s3) 14%, transparent); color: var(--s3); border-color: var(--s3); }
.badge-wait { background: var(--surface-2); color: var(--muted); border-color: var(--line-strong); }
.badge-off  { background: var(--surface-2); color: var(--muted); border-color: var(--line); }

/* Wide progress bar with a target marker, for the build budget. */
.bar-lg { height: 12px; border-radius: 6px; margin-top: 1rem; position: relative; }
.bar-fill.is-ok { background: var(--accent); }
.bar-mark {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--ink-2); border-radius: 1px;
}

.acct { margin: .9rem 0 0; font-size: .92rem; }

.insights { list-style: none; margin: 0; padding: 0; }
.insights li {
  position: relative; padding: .45rem 0 .45rem 1.1rem;
  border-top: 1px solid var(--line); font-size: .91rem;
}
.insights li:first-child { border-top: 0; }
.insights li::before {
  content: "—"; position: absolute; left: 0; color: var(--muted);
}
.insights li.is-pinned { font-weight: 550; }
.insights li.is-pinned::before { content: "★"; color: var(--accent); font-size: .8em; top: .55rem; }

.todos { list-style: none; margin: 0; padding: 0; }
.todos li {
  display: flex; align-items: center; gap: .5rem;
  padding: .15rem 0; border-top: 1px solid var(--line); font-size: .9rem;
}
.todos li:first-child { border-top: 0; }
.todo-form { flex: 1 1 auto; display: flex; }
.todo-toggle {
  display: flex; align-items: baseline; gap: .5rem;
  width: 100%; padding: .3rem .35rem .3rem 0;
  background: none; border: 0; border-radius: var(--radius-sm);
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.todo-toggle:hover { background: var(--surface-2); }
.todo-mark { color: var(--muted); width: 1rem; flex: 0 0 auto; }
.todos li.is-done .todo-mark { color: var(--accent); }
.todos li.is-done .todo-text { color: var(--muted); text-decoration: line-through; }
.todo-text { flex: 1 1 auto; }

.contacts { display: grid; gap: .75rem; margin-top: .75rem; }
.contact {
  border-left: 2px solid var(--line-strong);
  padding: .1rem 0 .1rem .75rem;
}
.contact h3 { margin: 0 0 .15rem; font-size: .88rem; font-weight: 650; }
.contact-subject { margin: 0 0 .2rem; font-size: .85rem; color: var(--ink-2); }
.contact-status { margin: 0; font-size: .82rem; color: var(--muted); }

/* ---------- Ny udregning ------------------------------------------------- */

.copy-preview {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  margin: 1rem 0;
}
.copy-list { list-style: none; margin: 0; padding: 0; }
.copy-list li { padding: .2rem 0; font-size: .9rem; }
.copy-list strong { font-variant-numeric: tabular-nums; }

.month-list { list-style: none; margin: 0; padding: 0; }
.month-list li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .45rem 0; border-top: 1px solid var(--line); font-size: .9rem;
}
.month-list li:first-child { border-top: 0; }

.table-calc td:first-child { width: 45%; }
.table-year th, .table-year td { white-space: nowrap; }
.table-tasks td:first-child { min-width: 14rem; }

/* ==========================================================================
   LEDGER — the dense, spreadsheet-shaped view
   The workbook put Christina and Sebastian side by side in columns and fit a
   whole month on one screen. That is the layout being matched here; stacked
   cards with big progress bars read worse for this job, not better.
   ========================================================================== */

.sheet { margin-bottom: .9rem; }

.sheet-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
  padding: 0 0 .3rem;
  border-bottom: 1.5px solid var(--ink);
  margin-bottom: 0;
}
.sheet-title {
  margin: 0; font-size: .72rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
}
.sheet-sum { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

table.ledger {
  width: 100%; border-collapse: collapse;
  font-size: .82rem; font-variant-numeric: tabular-nums;
}
table.ledger th {
  padding: .25rem .45rem;
  font-size: .66rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
  text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}
table.ledger th:first-child { text-align: left; }
table.ledger td {
  padding: 0 .45rem;
  height: var(--row-h); line-height: var(--row-h);
  text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.ledger td:first-child {
  text-align: left; white-space: normal; width: 40%;
  color: var(--ink);
}
table.ledger tbody tr:hover td { background: var(--surface-2); }
table.ledger tr.zero td:first-child { color: var(--muted); }
table.ledger tr.zero td { color: var(--muted); }
table.ledger tr.sum td {
  border-top: 1.5px solid var(--ink);
  border-bottom: 0;
  font-weight: 700;
  background: transparent;
}
table.ledger tr.sub td {
  border-top: 1px solid var(--line-strong);
  font-weight: 600;
}
table.ledger .neg { color: var(--neg); }
table.ledger .pos { color: var(--pos); }
table.ledger .dim { color: var(--muted); }

/* A hairline bar drawn in the row itself — conveys over/under without
   stealing a whole row of height per category. */
.spark {
  display: inline-block; vertical-align: middle;
  width: 3.4rem; height: 4px; border-radius: 2px;
  background: var(--line); overflow: hidden; margin-left: .4rem;
}
.spark > i { display: block; height: 100%; background: var(--accent); }
.spark > i.over { background: var(--neg); }
.spark > i.near { background: var(--warn); }

/* Editable cells sit flush in the grid instead of looking like form fields. */
.cell-inp {
  width: 100%; max-width: 7rem;
  padding: 0 .2rem; margin: 0;
  height: calc(var(--row-h) - 4px);
  background: transparent; border: 1px solid transparent; border-radius: 3px;
  color: var(--ink); font: inherit; font-variant-numeric: tabular-nums;
  text-align: right;
}
.cell-inp:hover  { border-color: var(--line-strong); background: var(--surface); }
.cell-inp:focus  { border-color: var(--accent); background: var(--surface); outline: none; }

/* Compact KPI strip */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; margin-bottom: .9rem;
}
.kpi { background: var(--surface); padding: .45rem .6rem; }
.kpi-l { font-size: .64rem; font-weight: 700; letter-spacing: .06em;
         text-transform: uppercase; color: var(--muted); display: block; }
.kpi-v { font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums;
         letter-spacing: -0.01em; }
.kpi-s { font-size: .68rem; color: var(--muted); }

/* Two ledgers side by side on wide screens */
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 60rem) { .cols2 { grid-template-columns: 1fr; gap: .9rem; } }

/* Compact panel variant */
.panel.tight { padding: .7rem .8rem; margin-bottom: .8rem; }

.toolbar {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  margin-bottom: .7rem;
}
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }

/* ==========================================================================
   AFREGNING — the two transfers the month exists to produce.
   This is the first thing on the page because it is the only part anyone
   needs to act on: move this much to the budget account, that much to savings.
   ========================================================================== */

.settle {
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  padding: .8rem .9rem;
  margin-bottom: 1rem;
}
.settle.is-done { border-color: var(--line-strong); }

.settle-head {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin-bottom: .7rem;
}
.settle-head h2 {
  margin: 0; font-size: .95rem; font-weight: 700; letter-spacing: -.01em;
}

.settle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 46rem) { .settle-grid { grid-template-columns: 1fr; gap: .9rem; } }

.settle-card h3 {
  margin: 0 0 .3rem;
  font-size: .7rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent);
}
.settle-card table.ledger td { height: 1.9rem; line-height: 1.9rem; }
.settle-card td.big {
  font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em;
}
.settle-why {
  margin: .35rem 0 0; font-size: .74rem; line-height: 1.45; color: var(--muted);
}

.settle-close {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-top: .8rem; padding-top: .7rem;
  border-top: 1px solid var(--line);
}
.settle-close label { font-size: .74rem; font-weight: 600; color: var(--muted); }
.settle-close .inp-amount {
  max-width: 6.5rem; height: 1.7rem;
  border-color: var(--line-strong); background: var(--surface);
}
.settle-moved { font-size: .78rem; color: var(--muted); }
.settle-moved strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Year × month matrix: narrow numeric columns, first column pinned so the
   year stays readable while scrolling twelve months sideways. */
table.matrix td, table.matrix th { padding: .2rem .35rem; font-size: .76rem; }
table.matrix td:first-child, table.matrix th:first-child {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface);
  width: auto; min-width: 3.2rem;
  box-shadow: 1px 0 0 var(--line);
}
table.matrix tr.sum td:first-child { background: var(--surface-2); }
table.matrix td { min-width: 3.4rem; }

/* ---------- Responsive --------------------------------------------------- */

@media (max-width: 30rem) {
  .field-row { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.2rem; }
  .cat-nums { font-size: .85rem; }
  .table-txn td:nth-child(3),
  .table-txn th:nth-child(3) { display: none; }  /* hide Note; still in search */
}

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

@media print {
  .tabs, .topbar-right, .quick-actions, .form-actions, .foot, .btn-icon { display: none; }
  body { background: #fff; }
  .panel { break-inside: avoid; box-shadow: none; }
}
