:root {
  color-scheme: light;
  --surface-0: #f4f3f0; --surface-1: #fcfcfb; --surface-2: #efeeea;
  --text-primary: #1f1f1d; --text-secondary: #52514e; --text-muted: #7a7974;
  --hairline: #e4e3df;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --other: #a3a29c; --up: #2a78d6; --down: #e34948; --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211; --surface-1: #1a1a19; --surface-2: #242422;
    --text-primary: #ecebe6; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
    --hairline: #2e2e2b;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --other: #6b6a65; --up: #3987e5; --down: #e66767; --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211; --surface-1: #1a1a19; --surface-2: #242422;
  --text-primary: #ecebe6; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --hairline: #2e2e2b;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --other: #6b6a65; --up: #3987e5; --down: #e66767; --accent: #3987e5;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0; background: var(--surface-0); color: var(--text-primary);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
nav.top {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface-0) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--hairline);
}
nav.top .in { max-width: 1120px; margin: 0 auto; display: flex; gap: 4px; align-items: center; padding: 8px 16px; }
nav.top .nav-links { display: flex; gap: 2px; }
nav.top a[aria-current] { color: var(--text-primary); font-weight: 600; }
.more { position: relative; }
.more summary { list-style: none; cursor: pointer; font-size: 14px; color: var(--text-secondary); padding: 6px 10px; border-radius: 6px; white-space: nowrap; user-select: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary:hover, .more[open] summary { background: var(--surface-2); color: var(--text-primary); }
.more .menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; display: grid; padding: 6px;
  background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
nav.top .more .menu a { padding: 8px 12px; font-size: 15px; }
.more .menu a.p, .more .narrow { display: none; }
@media (max-width: 860px) {
  nav.top .nav-links, .more .wide { display: none; }
  .more .narrow { display: inline; }
  .more { margin-left: auto; }
  nav.top .theme { margin-left: 4px; }
  .more .menu a.p { display: block; }
  .more .menu a.p:last-of-type { border-bottom: 1px solid var(--hairline); margin-bottom: 4px; padding-bottom: 12px; }
}
nav.top a { color: var(--text-secondary); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
nav.top a:hover { background: var(--surface-2); color: var(--text-primary); }
nav.top .brand { font-weight: 700; color: var(--text-primary); margin-right: 8px; }
nav.top .theme { margin-left: auto; font: inherit; font-size: 13px; background: none; border: 1px solid var(--hairline); color: var(--text-secondary); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
main { max-width: 1120px; margin: 0 auto; padding: 0 16px 80px; }
section { padding: 56px 0 8px; }
h1 { font-size: clamp(28px, 4.2vw, 40px); line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 12px; font-weight: 650; }
h2 { font-size: clamp(21px, 2.6vw, 26px); letter-spacing: -0.01em; font-weight: 650; margin: 0 0 8px; line-height: 1.15; }
h3 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.lede { font-size: clamp(16px, 1.6vw, 18px); color: var(--text-secondary); max-width: 760px; margin: 0 0 24px; }
.muted { color: var(--text-muted); }
.small { font-size: 14px; }
.card { background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 16px; padding: 20px; }
.grid { display: grid; gap: 12px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tile .k { color: var(--text-secondary); font-size: 14px; }
.tile .v { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; margin-top: 2px; }
.tile .s { color: var(--text-muted); font-size: 14px; }
.hero-num { font-size: clamp(36px, 6vw, 60px); font-weight: 650; letter-spacing: -0.02em; line-height: 1; margin: 8px 0 4px; }
.hero-num small { font-size: .42em; font-weight: 600; letter-spacing: 0; color: var(--text-secondary); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 0; }
.chip { font: inherit; font-size: 14px; border: 1px solid var(--hairline); background: var(--surface-1); color: var(--text-primary); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
input[type="text"], input[type="search"], input[inputmode] {
  font: inherit; font-size: 16px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--hairline);
  background: var(--surface-1); color: var(--text-primary); width: 100%; max-width: 420px;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.field { display: block; font-weight: 600; margin-bottom: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two > * { min-width: 0; }
.two.search-row { grid-template-columns: auto 1fr; align-items: center; }
@media (max-width: 820px) { .two, .two.search-row { grid-template-columns: 1fr; } }

/* "for deg" */
.meg-grid { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .meg-grid { grid-template-columns: 1fr; } }
.meg-form { position: sticky; top: 64px; display: grid; gap: 18px; }
@media (max-width: 900px) { .meg-form { position: static; } }
.meg-form h3 { font-size: 15px; margin: 0 0 8px; color: var(--text-secondary); font-weight: 600; }
.chips.wrap { margin: 0; }
.chip.small { font-size: 13px; padding: 4px 10px; }
.kids { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; font-size: 15px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--hairline); border-radius: 8px; overflow: hidden; background: var(--surface-1); }
.stepper button { font: inherit; width: 34px; height: 32px; border: 0; background: none; color: var(--text-primary); cursor: pointer; font-size: 18px; }
.stepper button:hover { background: var(--surface-2); }
.stepper span { min-width: 26px; text-align: center; font-weight: 600; }
.money { display: grid; gap: 8px; }
.money label { font-size: 14px; color: var(--text-secondary); display: grid; gap: 4px; }
.money input, .money select { font-size: 16px; padding: 8px 12px; max-width: none; }
.adult { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tax-card { border-left: 4px solid var(--accent); }
.tax-big { font-size: clamp(24px, 3vw, 32px); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; margin: 4px 0; }
.facts { display: grid; gap: 10px; margin-top: 12px; }
.facts h3.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 18px 0 2px; }
.fact { background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 12px; padding: 14px 16px; }
.fact .top { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.fact h4 { margin: 0; font-size: 16px; line-height: 1.35; flex: 1; min-width: 200px; }
.fact p { margin: 6px 0 0; color: var(--text-secondary); font-size: 15px; }
.fact .amts { margin: 8px 0 0; display: grid; gap: 2px; font-size: 14px; }
.fact .amts b { font-weight: 650; }
.fact .meta { margin-top: 8px; font-size: 13px; color: var(--text-muted); }
.fact .meta a { color: var(--text-muted); }
.badge { font-size: 12.5px; font-weight: 650; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid currentColor; }
.badge.pluss { color: var(--up); } .badge.minus { color: var(--down); }
.badge.uendret, .badge.blandet { color: var(--text-muted); }
.same { display: grid; gap: 4px; margin-top: 6px; }
.same div { font-size: 14.5px; color: var(--text-secondary); padding: 6px 2px; border-bottom: 1px solid var(--hairline); }
.same b { color: var(--text-primary); font-weight: 600; }
.same a { color: var(--text-muted); font-size: 13px; }
.share { font: inherit; font-size: 14px; background: none; border: 1px solid var(--hairline); color: var(--text-secondary); border-radius: 8px; padding: 6px 12px; cursor: pointer; }

/* 100-kr bar */
.stack { display: flex; height: 44px; border-radius: 8px; overflow: hidden; gap: 2px; margin: 16px 0 8px; }
.stack div { min-width: 2px; cursor: pointer; transition: opacity .15s; }
.stack.focus div:not(.on) { opacity: .25; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }

/* receipt */
.receipt {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px;
  background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 4px;
  padding: 20px 18px; max-width: 520px; position: relative;
  -webkit-mask: radial-gradient(circle 6px at 50% 100%, #0000 98%, #000) 50% / 16px 100% repeat-x;
}
.receipt h3 { font-family: inherit; text-align: center; font-size: 15px; letter-spacing: .08em; margin-bottom: 2px; }
.receipt .c { text-align: center; color: var(--text-muted); margin-bottom: 12px; }
.receipt .row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.receipt .row.g { font-weight: 700; margin-top: 10px; cursor: pointer; }
.receipt .row.l { color: var(--text-secondary); padding-left: 14px; }
.receipt .row .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt .row > span:last-child { white-space: nowrap; }
.receipt .row .d { flex: 1; border-bottom: 1px dotted var(--hairline); margin: 0 4px 5px; min-width: 12px; }
.receipt hr { border: 0; border-top: 1px dashed var(--text-muted); margin: 12px 0; }
.receipt .tot { font-weight: 700; font-size: 16px; }

/* bars */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(140px, 260px) 1fr; gap: 12px; align-items: center; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 1fr; gap: 2px; } }
.bar-row .lab { font-size: 15px; }
.bar-row .lab b { font-weight: 600; }
.bar-track { position: relative; height: 26px; }
.bar-fill { position: absolute; top: 4px; bottom: 4px; left: 0; border-radius: 0 4px 4px 0; }
.bar-val { position: absolute; top: 0; line-height: 26px; font-size: 14px; color: var(--text-secondary); white-space: nowrap; }

/* treemap */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 12px 0; font-size: 15px; }
.crumbs button { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.crumbs button:last-child { color: var(--text-primary); font-weight: 650; cursor: default; }
.crumbs .sep { color: var(--text-muted); }
.treemap { position: relative; width: 100%; }
.treemap .cell { position: absolute; overflow: hidden; border-radius: 6px; padding: 8px 10px; color: #fff; cursor: pointer; transition: filter .12s; }
.treemap .cell:hover { filter: brightness(1.08); }
.treemap .cell.leaf { cursor: default; }
.treemap .cell .n { font-weight: 650; font-size: 14px; line-height: 1.25; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.treemap .cell .v { font-size: 13px; opacity: .92; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; margin-top: 12px; }
.tbl th, .tbl td { text-align: right; padding: 8px 8px; border-bottom: 1px solid var(--hairline); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { color: var(--text-secondary); font-weight: 600; font-size: 13px; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.pos { color: var(--up); } .neg { color: var(--down); }
.results { margin-top: 12px; display: grid; gap: 6px; }
.result { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-1); border: 1px solid var(--hairline); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.result:hover { border-color: var(--text-muted); }
.result .path { grid-column: 1 / -1; font-size: 13px; color: var(--text-muted); }
.result .amt { font-weight: 650; }

/* kommune */
.kom-head { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
svg { display: block; width: 100%; height: auto; overflow: visible; }
.axis text { fill: var(--text-muted); font-size: 12px; }
.axis line, .axis path { stroke: var(--hairline); }
.tip {
  position: fixed; pointer-events: none; z-index: 30; opacity: 0; transition: opacity .1s;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--hairline);
  border-radius: 8px; padding: 8px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.14); font-size: 14px; max-width: 300px;
}
details.gl { border-bottom: 1px solid var(--hairline); padding: 12px 0; }
details.gl summary { cursor: pointer; font-weight: 600; }
details.gl p { margin: 8px 0 0; color: var(--text-secondary); max-width: 760px; }
footer { border-top: 1px solid var(--hairline); margin-top: 48px; padding-top: 24px; font-size: 14px; color: var(--text-secondary); }
.note { font-size: 14px; color: var(--text-muted); max-width: 760px; }
.loading { padding: 80px 0; color: var(--text-muted); }

/* group colour slots: 0 = income, 1..7 = spending groups in display order, 8 = "Øvrige formål" */
:root {
  --g-0: var(--series-1); --g-1: var(--series-2); --g-2: var(--series-3); --g-3: var(--series-4); --g-4: var(--series-5);
  --g-5: var(--series-6); --g-6: var(--series-7); --g-7: var(--series-8); --g-8: var(--other);
}
.chip.check { display: inline-flex; align-items: center; gap: 6px; }
.chip.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip.check:has(input:checked) { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.chip.check:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
a.chip { text-decoration: none; display: inline-block; }
a.chip[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.kids input.kid { width: 72px; font: inherit; font-size: 16px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--surface-1); color: var(--text-primary); text-align: center; }
.treemap { position: relative; width: 100%; margin-bottom: 4px; }
.crumbs a { color: var(--accent); text-decoration: none; padding: 2px 4px; }
.crumbs a:hover { text-decoration: underline; }
.tbl td a { color: var(--text-primary); }
a.result { text-decoration: none; }
.receipt details summary { list-style: none; cursor: pointer; }
.receipt details summary::-webkit-details-marker { display: none; }
.receipt details summary .n::before { content: "▸ "; }
.receipt details[open] summary .n::before { content: "▾ "; }

.prompt { background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 12px; padding: 16px; max-width: 760px; white-space: pre-wrap; font-size: 14px; user-select: all; }
code { font-size: 0.92em; background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 4px; padding: 0 4px; }
.steps { margin: 8px 0 0; padding-left: 20px; color: var(--text-secondary); display: grid; gap: 6px; }

/* Pengestrømmen */
.flow-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.flow-head .chips { margin: 0; }
.flow-info {
  position: sticky; top: 52px; z-index: 5; min-height: 64px; margin: 12px 0 8px; padding: 10px 14px;
  background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 12px; font-size: 15px;
  display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 2px 12px;
}
.flow-info.on { border-color: var(--text-muted); }
.flow-info > div { grid-column: 1; }
.flow-info .t { font-weight: 650; }
.flow-info .sub { color: var(--text-secondary); font-size: 14px; }
.flow-info .share { grid-column: 2; grid-row: 1 / span 3; }
.hscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 12px; }
.hscroll svg { display: block; width: auto; max-width: none; }
.swipe { display: none; }
.hscroll.overflows + .swipe { display: block; }
.node-label { font-size: 12.5px; fill: var(--text-primary); paint-order: stroke; stroke: var(--surface-1); stroke-width: 3px; stroke-linejoin: round; }
.node-label .val { fill: var(--text-secondary); }
.node-label.big { font-size: 15px; font-weight: 650; }
.link { mix-blend-mode: multiply; transition: opacity .15s; cursor: pointer; }
:root[data-theme="dark"] .link { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .link { mix-blend-mode: screen; } }
.dim .link { opacity: .12 !important; }
.dim .link.hi { opacity: .8 !important; }
.hit { cursor: pointer; }
.zero { stroke: var(--text-muted); stroke-width: 1; }
.row-label { font-size: 13px; fill: var(--text-primary); }
.row-label.l1 { font-weight: 650; }
.row-label.l2 { fill: var(--text-secondary); }
.sec-label { font-size: 12px; font-weight: 650; fill: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.val-label { font-size: 12.5px; fill: var(--text-secondary); }
.row-hit { fill: transparent; }
.row-hit:hover { fill: var(--surface-0); }
.tbl .num { text-align: right; white-space: nowrap; }

/* inline help that works by tap as well as click */
details.help { margin: 0 0 10px; font-size: 14px; color: var(--text-secondary); }
details.help summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }
details.help summary::-webkit-details-marker { display: none; }
details.help summary span { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid currentColor; font-size: 12px; font-weight: 700; }
details.help p { margin: 8px 0 0; }
.money .who { grid-column: 1 / -1; font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
/* The Sankey's flows span at least 640 px (flyt.js KPX) plus 16 px margin; reserving that keeps the page from jumping when it draws */
#sankey { min-height: 656px; }

/* "Slik er skatten regnet" under the tax card */
details.calc { margin: 10px 0 0; font-size: 14px; }
details.calc summary { cursor: pointer; color: var(--accent); }
details.calc table { border-collapse: collapse; margin: 8px 0 0; width: 100%; max-width: 640px; }
details.calc caption { text-align: left; font-weight: 600; padding: 4px 0; }
details.calc td { padding: 3px 8px 3px 0; border-bottom: 1px solid var(--hairline); vertical-align: top; }
details.calc td:last-child { color: var(--text-muted); font-size: 13px; }
