/* Shared by index.html and budsjett.html. */
/* Layout: one calm column like a municipal report; ledger rows carry the detail, one Narvik-blue accent (#005fbe, from the coat of arms) marks the selected year and Narvik; red is kept for over budget and increases. */
:root {
  --paper: #f4f6f7;
  --surface: #ffffff;
  --ink: #17212b;
  --ink-2: #4c5966;
  --rule: #d9dfe4;
  --accent: #005fbe;
  --accent-soft: rgba(0, 95, 190, 0.10);
  --muted: #9aa6b1;
  --good: #2f7a52;
  --bad: #a3412a;
  --female: #a85a00; --female-bar: #e9a456; --male: #005fbe; --male-bar: #5a9be0;
  --font-display: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12181e; --surface: #1a222a; --ink: #e8edf1; --ink-2: #a4b0bb; --rule: #2c3741;
    --accent: #6aacf2; --accent-soft: rgba(106, 172, 242, 0.16); --muted: #6c7a87; --good: #6cc394; --bad: #e98a6f; --female: #f0b36a; --female-bar: #c98536; --male: #8fc0f5; --male-bar: #3f7fc4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12181e; --surface: #1a222a; --ink: #e8edf1; --ink-2: #a4b0bb; --rule: #2c3741;
  --accent: #6aacf2; --accent-soft: rgba(106, 172, 242, 0.16); --muted: #6c7a87; --good: #6cc394; --bad: #e98a6f; --female: #f0b36a; --female-bar: #c98536; --male: #8fc0f5; --male-bar: #3f7fc4;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.55;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 48px;
}
.wrap { max-width: 880px; margin: 0 auto; display: grid; gap: 56px; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 6vw, 3.1rem); line-height: 1.05; font-weight: 700; }
h2 { font-size: 1.5rem; line-height: 1.2; font-weight: 600; }
p { margin: 0; max-width: 65ch; }
.eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-2); font-weight: 600; }
.lead { color: var(--ink-2); font-size: 1.075rem; }
section { display: grid; gap: 20px; }
.section-head { display: grid; gap: 8px; }

/* site nav */
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: baseline; padding-top: 20px; border-bottom: 1px solid var(--rule); padding-bottom: 12px; }
.site-nav .brand { font: 700 1rem var(--font-display); color: var(--ink); text-decoration: none; margin-right: auto; }
.site-nav a:not(.brand) { font-size: 0.95rem; color: var(--ink-2); text-decoration: none; padding: 2px 0; border-bottom: 2px solid transparent; }
.site-nav a:not(.brand):hover { color: var(--ink); }
.site-nav a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
/* Two levels: the area (Økonomi, Befolkning) in .site-nav, and on economy pages its pages in .sub-nav right below. */
.site-head { display: grid; }
.site-head .site-nav:has(+ .sub-nav) { border-bottom: 0; padding-bottom: 8px; }
.sub-nav { display: flex; gap: 6px; padding: 10px 0 12px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.sub-nav a { flex: none; font-size: 0.9rem; color: var(--ink-2); text-decoration: none; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--rule); background: var(--surface); white-space: nowrap; }
.sub-sep { flex: none; width: 1px; margin: 4px 6px; background: var(--rule); }
.sub-nav a:hover { color: var(--ink); border-color: var(--ink-2); }
.sub-nav a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--paper); font-weight: 600; }
/* «Økonomi» on pages outside the area: a click menu (details), so it works the same with touch and keyboard. */
.nav-menu { position: relative; }
.nav-menu summary { list-style: none; cursor: pointer; font-size: 0.95rem; color: var(--ink-2); padding: 2px 0; display: flex; gap: 4px; align-items: center; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.nav-menu[open] summary::after { transform: translateY(1px) rotate(-135deg); }
.nav-menu summary:hover, .nav-menu[open] summary { color: var(--ink); }
.nav-menu summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-pop { position: absolute; right: 0; top: calc(100% + 10px); z-index: 10; width: 280px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); padding: 6px; display: grid; }
@media (max-width: 680px) { .nav-pop { left: 0; right: auto; } }
.site-nav .nav-pop a { display: grid; gap: 1px; padding: 9px 12px; border-radius: 6px; border: 0; color: var(--ink); }
.site-nav .nav-pop a:hover { background: var(--accent-soft); }
.nav-pop b { font-weight: 600; }
.nav-group { padding: 10px 12px 4px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.nav-group:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--rule); }
.nav-pop small { font-size: 0.82rem; color: var(--ink-2); }
.cross-link { font-size: 0.95rem; font-weight: 600; }

/* header */
header { display: grid; gap: 20px; padding-top: 24px; }
.years { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.years span { font-size: 0.85rem; color: var(--ink-2); margin-right: 6px; }
.years button {
  font: 600 0.95rem var(--font-body); font-variant-numeric: tabular-nums;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
}
.years button[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--paper); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* summary */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.stat { background: var(--surface); padding: 18px 20px; display: grid; gap: 4px; align-content: start; }
.stat .big { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat .big small { font-size: 1rem; font-weight: 500; color: var(--ink-2); }
.stat .sub { color: var(--ink-2); font-size: 0.9rem; }
.equation { font-size: 0.92rem; color: var(--ink-2); max-width: none; }
.equation b { color: var(--ink); font-weight: 600; }

/* hundrelapp */
.note-bar { display: flex; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--rule); background: var(--surface); }
.note-bar a { border: 0; padding: 0; cursor: pointer; border-right: 2px solid var(--surface); background: var(--accent); min-width: 0; display: flex; align-items: flex-end; justify-content: flex-start; color: var(--paper); font: 700 0.95rem var(--font-display); }
.note-bar a span { padding: 0 0 8px 8px; white-space: nowrap; }
.note-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 20px; margin: 0; padding: 0; list-style: none; }
.note-legend li { display: grid; grid-template-columns: 52px 1fr; gap: 8px; align-items: baseline; font-size: 0.95rem; }
.note-legend .kr { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* ledger */
.ledger { border-top: 2px solid var(--ink); }
.ledger-head, .row-btn { display: grid; grid-template-columns: minmax(0, 1fr) 150px 96px 96px 80px; gap: 16px; align-items: center; }
.ledger-head { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); font-weight: 600; padding: 10px 4px; border-bottom: 1px solid var(--rule); }
.ledger-head .r, .row-btn .r { text-align: right; }
.row { border-bottom: 1px solid var(--rule); }
.row-btn { width: 100%; box-sizing: border-box; background: none; border: 0; color: inherit; font: inherit; text-align: left; padding: 14px 4px; cursor: pointer; text-decoration: none; }
.row-btn:hover { background: var(--accent-soft); }
.row-name { display: grid; gap: 2px; min-width: 0; }
.row-name b { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.row-name b::after { content: "\203A"; color: var(--accent); font-weight: 700; }
.row-name small { color: var(--ink-2); font-size: 0.82rem; }
.share { display: grid; gap: 4px; }
.share-track { height: 8px; background: var(--rule); border-radius: 4px; overflow: hidden; }
.share-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.share small { font-size: 0.8rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chg.up { color: var(--bad); }
.chg.down { color: var(--good); }
.chg { font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.detail-scroll { overflow-x: auto; }
.offsets { display: grid; gap: 4px; }
.budget-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 96px 96px 80px; gap: 16px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--rule); }
.budget-row .r { text-align: right; }
.budget-row.total { font-weight: 600; border-bottom: 0; }
.budget-row .m-label { display: none; }
.dev { display: block; position: relative; height: 8px; background: var(--rule); border-radius: 4px; }
.dev::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--ink-2); }
.dev span { display: block; position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.dev .over { left: 50%; background: var(--bad); }
.dev .under { right: 50%; background: var(--good); }
.status-note { font-size: 0.9rem; color: var(--ink); background: var(--accent-soft); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 4px; max-width: none; }
.outlook { margin-top: 18px; display: grid; gap: 6px; }
.outlook p { margin: 0; }

/* charts */
.chart { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 16px 16px 8px; overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 560px; height: auto; }
.chart text { font-family: var(--font-body); }
.legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 0.88rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.caption { font-size: 0.82rem; color: var(--ink-2); }

/* notes */
.notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
.notes div { display: grid; gap: 6px; align-content: start; }
.notes h3 { font-size: 1.05rem; font-weight: 600; }
.notes p { font-size: 0.92rem; color: var(--ink-2); }
a { color: var(--accent); }
a.cta { display: inline-block; padding: 8px 18px; border-radius: 999px; background: var(--accent); color: var(--surface); text-decoration: none; font-weight: 600; }
a.cta:hover { filter: brightness(1.08); }
footer { border-top: 1px solid var(--rule); padding-top: 20px; font-size: 0.85rem; color: var(--ink-2); display: grid; gap: 6px; }

@media (max-width: 680px) {
  .site-nav .brand { flex-basis: 100%; }
  .ledger-head { display: none; }
  .row-btn { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name amt" "share share" "pc chg"; gap: 6px 12px; }
  .row-btn .c-name { grid-area: name; } .row-btn .c-amt { grid-area: amt; }
  .row-btn .c-share { grid-area: share; } .row-btn .c-pc { grid-area: pc; text-align: left; } .row-btn .c-chg { grid-area: chg; }
  .row-btn .c-pc::after { content: " per innb."; color: var(--ink-2); font-size: 0.82rem; }
  .budget-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name amt" "share share" "y1 chg"; gap: 6px 12px; }
  .budget-row .c-name { grid-area: name; } .budget-row .c-amt { grid-area: amt; }
  .budget-row .c-share { grid-area: share; } .budget-row .c-y1 { grid-area: y1; text-align: left; color: var(--ink-2); font-size: 0.88rem; } .budget-row .c-chg { grid-area: chg; }
  .budget-row .m-label { display: inline; }
  .note-bar a span { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .share-fill, .note-bar a { transition: width 0.35s ease, flex-basis 0.35s ease; }
}

/* omrade.html: area › service › cost type */
.drill { display: grid; gap: 40px; }
.drill > * { min-width: 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: baseline; font-size: 0.9rem; color: var(--ink-2); padding-top: 20px; }
.crumbs a { font-weight: 600; }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.drill-head { display: grid; gap: 14px; }
.drill-head h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.08; }
.years .chip { font: 600 0.95rem var(--font-body); font-variant-numeric: tabular-nums; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); padding: 6px 14px; border-radius: 999px; text-decoration: none; }
.years .chip[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.measures { margin: 4px 0 14px; }
.measures .chip { font-size: 0.85rem; padding: 6px 12px; }
.drill-sec { display: grid; gap: 14px; }
.drill-sec .lead { font-size: 0.98rem; }
.flow-bar { display: flex; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid var(--rule); background: var(--surface); }
.flow-bar.parts { height: 44px; }
.flow-seg { display: flex; align-items: center; padding: 0 12px; min-width: 0; white-space: nowrap; overflow: hidden; color: var(--paper); font-weight: 700; font-size: 0.92rem; border-right: 2px solid var(--surface); flex-grow: 0; flex-shrink: 0; }
.flow-seg.own { background: var(--accent); }
.flow-seg.inc { background: color-mix(in srgb, var(--good) var(--mix, 100%), var(--surface)); }
.flow-seg.cost { background: color-mix(in srgb, var(--accent) var(--mix, 100%), var(--surface)); }
.flow-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 0.85rem; color: var(--ink-2); }
.flow-legend li { display: flex; align-items: center; gap: 6px; }
.flow-legend i { width: 10px; height: 10px; border-radius: 2px; padding: 0; border: 0; }
.rank { border-top: 1px solid var(--rule); }
.rank-row { display: grid; grid-template-columns: minmax(0, 250px) minmax(60px, 1fr) 80px 64px 16px; gap: 14px; align-items: center; padding: 10px 4px; min-height: 44px; box-sizing: border-box; border-bottom: 1px solid var(--rule); color: inherit; text-decoration: none; }
a.rank-row:hover { background: var(--accent-soft); }
.rank-name { display: grid; gap: 1px; font-weight: 600; }
.rank-name small { font-weight: 400; font-size: 0.8rem; color: var(--ink-2); }
.rank-track { height: 14px; }
.rank-fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; min-width: 2px; }
.rank.income .rank-fill { background: var(--good); }
.rank-amt { text-align: right; font-weight: 600; }
.rank-note { text-align: right; font-size: 0.88rem; color: var(--ink-2); }
.rank-go { color: var(--accent); font-weight: 700; }
.rank.income .rank-go { color: var(--good); }
.bars5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; align-items: end; border-bottom: 1px solid var(--ink); padding: 0 6px; }
.bar5 { display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; color: var(--ink-2); font-size: 0.82rem; }
.bar5 i { display: block; width: 56%; background: var(--muted); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar5 b { font-weight: 400; margin-bottom: -26px; }
.bar5.sel { color: var(--ink); font-weight: 700; }
.bar5.sel i { background: var(--accent); }
.bar5.sel b { font-weight: 700; }
.bars5 + .caption { margin-top: 22px; }
.num-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; font-variant-numeric: tabular-nums; background: var(--surface); }
.num-table th, .num-table td { padding: 8px; border-bottom: 1px solid var(--rule); text-align: right; white-space: nowrap; }
.num-table th:first-child, .num-table td:first-child { text-align: left; white-space: normal; min-width: 160px; }
.num-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-2); font-weight: 600; }
.num-table .code { text-align: left; color: var(--ink-2); font-size: 0.78rem; }
.num-table .sel { background: var(--accent-soft); }
.num-table .sum td { font-weight: 700; border-top: 1px solid var(--ink-2); }
.num-table .derived td:first-child, .num-table .derived .code { font-style: italic; }
.all-numbers summary { cursor: pointer; font-weight: 600; color: var(--accent); min-height: 44px; display: flex; align-items: center; }
.source-box { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 20px 22px; display: grid; gap: 10px; }
.source-box p { font-size: 0.95rem; max-width: none; }
.source-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--ink); color: var(--paper); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.seg a { font-weight: 600; font-size: 0.85rem; background: var(--surface); color: var(--ink-2); padding: 0 14px; min-height: 42px; display: inline-flex; align-items: center; text-decoration: none; }
.seg a[aria-current] { background: var(--ink); color: var(--paper); }
.ssb-end { border: 1px dashed var(--muted); border-radius: 10px; padding: 16px 20px; display: grid; gap: 6px; }
.ssb-end p { font-size: 0.92rem; color: var(--ink-2); }
.source { border-top: 1px solid var(--rule); padding-top: 14px; max-width: none; }
.ledger { min-width: 0; }
@media (max-width: 680px) {
  .rank-row { grid-template-columns: minmax(0, 1fr) auto 16px; grid-template-areas: "name amt go" "track note go"; gap: 6px 12px; }
  .rank-name { grid-area: name; } .rank-amt { grid-area: amt; } .rank-track { grid-area: track; height: 8px; } .rank-note { grid-area: note; } .rank-go { grid-area: go; }
  .bars5 { gap: 6px; }
  .flow-seg { font-size: 0.8rem; padding: 0 8px; }
}

/* lopende.html: the year so far */
.used { display: grid; gap: 4px; }
.used-track { position: relative; height: 8px; background: var(--rule); border-radius: 4px; }
.used-fill { display: block; height: 100%; border-radius: 4px; }
.used-fill.over { background: var(--bad); }
.used-fill.under { background: var(--good); }
.used-track i { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink); }
.used small { font-size: 0.8rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.reg-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; max-width: 65ch; }
.chart { position: relative; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px; font-size: 0.85rem; display: grid; gap: 2px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); font-variant-numeric: tabular-nums; }
.legend span { display: inline-flex; align-items: center; }
#summary { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (max-width: 680px) { .budget-row .c-amt .m-label, .budget-row .c-chg .m-label { color: var(--ink-2); font-size: 0.82rem; font-weight: 400; } }

/* index.html: Narvik against one comparison region, area by area */
.cmp-pick { flex-wrap: wrap; border-radius: 12px; justify-self: start; }
.cmp-pick button { font: 600 0.85rem var(--font-body); background: var(--surface); color: var(--ink-2); padding: 0 14px; min-height: 42px; border: 0; border-right: 1px solid var(--rule); cursor: pointer; }
.cmp-pick button:last-child { border-right: 0; }
.cmp-pick button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.cmp-list { border-top: 2px solid var(--ink); }
.cmp-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 80px 150px 72px; gap: 16px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--rule); color: inherit; text-decoration: none; }
.cmp-row .r { text-align: right; }
a.cmp-row:hover { background: var(--accent-soft); }
a.cmp-row .c-name { font-weight: 600; }
a.cmp-row .c-name::after { content: " \203A"; color: var(--accent); font-weight: 700; }
.cmp-row .c-n { font-weight: 600; }
.cmp-row .c-r { color: var(--ink-2); }
.cmp-head { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); font-weight: 600; padding: 10px 4px; }
.cmp-row.total { font-weight: 700; border-bottom: 0; }
.dev .more { left: 50%; background: var(--accent); }
.dev .less { right: 50%; background: var(--muted); }
@media (max-width: 680px) {
  .cmp-head { display: none; }
  .cmp-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name d" "dev dev" "n r"; gap: 6px 12px; }
  .cmp-row .c-name { grid-area: name; } .cmp-row .c-d { grid-area: d; font-weight: 600; } .cmp-row .c-dev { grid-area: dev; }
  .cmp-row .c-n { grid-area: n; text-align: left; font-weight: 400; } .cmp-row .c-r { grid-area: r; }
  .cmp-row .c-n::before { content: "Narvik "; color: var(--ink-2); }
  .cmp-row .c-r::before { content: "mot "; }
  .cmp-row .c-d::after { content: " kr"; color: var(--ink-2); font-weight: 400; }
}
/* omrade.html: one area against the comparison regions */
.cmp-bars .rank-fill { background: var(--muted); }
.cmp-bars .me .rank-fill { background: var(--accent); }
.cmp-bars .me .rank-name, .cmp-bars .me .rank-amt { color: var(--accent); }
.cmp-bars .rank-row { grid-template-columns: minmax(0, 250px) minmax(60px, 1fr) 80px 116px 0; }
.cmp-bars .rank-note { white-space: nowrap; }
@media (max-width: 680px) { .cmp-bars .rank-row { grid-template-columns: minmax(0, 1fr) auto 0; } }

/* «Bak tallene»: facts from the kommune's own reports */
.fact-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.fact { background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: 6px; padding: 14px 18px; display: grid; gap: 6px; }
.fact p { max-width: none; }
.fact-quote { margin: 4px 0 0; padding: 8px 0 0 14px; border-left: 2px solid var(--rule); display: grid; gap: 4px; }
.fact-quote p { font-style: italic; color: var(--ink-2); font-size: 0.95rem; }
.fact-src { margin-top: 2px; }
details .fact-list { margin-top: 4px; }
.fact-groups { display: grid; gap: 24px; }
.fact-group { display: grid; gap: 10px; }
.fact-group h3 { font-size: 1.05rem; font-weight: 600; }

/* tiltak.html: savings in the budget and what happened to them */
.tiltak-top { display: flex; gap: 16px; justify-content: space-between; align-items: baseline; }
.tiltak-name { font-weight: 600; }
.tiltak-amt { font-weight: 700; white-space: nowrap; }
.tiltak.t-good { border-left-color: var(--good); }
.tiltak.t-bad { border-left-color: var(--bad); }
.tiltak.t-none { border-left-color: var(--muted); }
.badge { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); }
.badge.good { background: color-mix(in srgb, var(--good) 16%, transparent); }
.badge.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); }
.badge.none { background: var(--rule); color: var(--ink-2); }
.tiltak-notes { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.tiltak-notes .caption { display: inline; }
.tiltak details summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 0.9rem; min-height: 32px; display: flex; align-items: center; }
.tiltak details p { font-size: 0.92rem; color: var(--ink-2); margin-top: 6px; }
.fact-group h3 .caption { font-family: var(--font-body); font-weight: 400; }
#areas, #fix, #bridge, .fact-groups > *, .fact-list > * { min-width: 0; }
.tiltak { overflow-wrap: anywhere; }
.tiltak-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }

/* befolkning.html */
.stats3, #summary.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.mini-bars { display: flex; gap: 4px; align-items: flex-end; height: 40px; margin-top: 4px; }
.mini-bars span { flex: 1; display: grid; gap: 2px; justify-items: stretch; font-size: 0.65rem; color: var(--ink-2); text-align: center; }
.mini-bars i { display: block; background: var(--accent-soft); border-radius: 2px 2px 0 0; }
.mini-bars span:last-child i { background: var(--accent); }
.tag { display: inline-block; font-size: 0.75rem; font-weight: 500; color: var(--ink-2); border: 1px solid var(--muted); border-radius: 4px; padding: 0 5px; vertical-align: 1px; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 18px 20px; display: grid; gap: 14px; }
.pyr-top { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; }
.pyr-year { font: 700 2.4rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.pyr-kind { font-size: 0.8rem; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); margin-bottom: 4px; }
.pyr-kind.proj { border-color: var(--muted); color: var(--ink); background: var(--paper); }
.pyr-total { margin-left: auto; font-size: 0.95rem; color: var(--ink-2); }
.pyr-total b { color: var(--ink); }
.pyr-ctl { display: flex; gap: 14px; align-items: center; }
.pyr-play { flex: none; width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--accent); background: var(--surface); color: var(--accent); cursor: pointer; display: grid; place-items: center; }
.pyr-slider { flex: 1; display: grid; gap: 2px; }
.pyr-slider input { width: 100%; accent-color: var(--accent); height: 28px; margin: 0; }
.pyr-ticks { position: relative; height: 18px; font-size: 0.75rem; color: var(--ink-2); }
.pyr-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.pyr-ticks span:first-child { transform: none; } .pyr-ticks span:last-child { transform: translateX(-100%); }
.pyr-ticks .now { color: var(--ink); font-weight: 600; }
@media (max-width: 680px) { .pyr-ticks span:first-child { visibility: hidden; } }
.pyr { display: grid; gap: 3px; font-variant-numeric: tabular-nums; }
.pyr-row { display: grid; grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1fr); gap: 8px; align-items: center; }
.pyr-row.head { font-size: 0.88rem; font-weight: 600; padding-bottom: 4px; }
.pyr-row.head .f { text-align: right; color: var(--female); } .pyr-row.head .m { color: var(--male); }
.pyr-age { text-align: center; font-size: 0.8rem; color: var(--ink-2); }
.pyr-side { position: relative; height: 16px; }
.pyr-side i { position: absolute; top: 0; bottom: 0; transition: width 0.25s; }
.pyr-side.f i { right: 0; background: var(--female-bar); border-radius: 2px 0 0 2px; }
.pyr-side.m i { left: 0; background: var(--male-bar); border-radius: 0 2px 2px 0; }
.pyr.proj .pyr-side i { opacity: 0.5; }
.pyr-side span { position: absolute; top: -1px; font-size: 0.75rem; color: var(--ink-2); }
.pyr-side.f span { left: 0; } .pyr-side.m span { right: 0; }
.ptable { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; overflow-x: auto; font-variant-numeric: tabular-nums; }
.ptable table { width: 100%; border-collapse: collapse; min-width: 640px; font-size: 0.95rem; }
.ptable th, .ptable td { padding: 9px 14px; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.ptable th:first-child, .ptable td:first-child { text-align: left; white-space: normal; }
.ptable thead th { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); background: var(--paper); vertical-align: bottom; white-space: normal; }
#cmp-table td:first-child { white-space: nowrap; }
.ptable tbody tr:last-child td { border-bottom: 0; }
.ptable tr.me td { background: var(--accent-soft); font-weight: 600; }
.ptable tr.total td { font-weight: 600; background: var(--paper); border-top: 1px solid var(--rule); }
.ptable .muted { color: var(--ink-2); font-weight: 400; font-size: 0.85em; }
.ptable .hi { color: var(--accent); font-weight: 600; }
.ptable .hi-old { color: var(--bad); font-weight: 600; }
.ptable .pos { color: var(--good); } .ptable .neg { color: var(--bad); }
.ptable button.expand { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; text-align: left; }
.ptable button.expand::before { content: "\203A"; color: var(--accent); font-weight: 700; transition: transform 0.15s; }
.ptable button.expand[aria-expanded="true"]::before { transform: rotate(90deg); }
.ptable tr.krets td { font-size: 0.88rem; color: var(--ink-2); background: var(--paper); padding-top: 6px; padding-bottom: 6px; }
.ptable tr.krets td:first-child { padding-left: 34px; }
.chg-bar { display: inline-grid; grid-template-columns: 1fr 1fr; width: 90px; height: 10px; vertical-align: middle; margin-left: 10px; }
.chg-bar span:first-child { display: flex; justify-content: flex-end; }
.chg-bar span:last-child { border-left: 1px solid var(--muted); }
.chg-bar i { display: block; height: 10px; }
.chg-bar .neg i { background: var(--bad); border-radius: 2px 0 0 2px; } .chg-bar .pos i { background: var(--good); border-radius: 0 2px 2px 0; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.two h3 { font-size: 1.05rem; font-weight: 600; }
.col-chart { display: flex; gap: 8px; align-items: flex-end; height: 170px; font-variant-numeric: tabular-nums; }
.col-chart span { flex: 1; display: grid; gap: 4px; justify-items: center; align-content: end; height: 100%; font-size: 0.75rem; color: var(--ink-2); }
.col-chart b { font-weight: 500; color: var(--ink); }
.col-chart i { display: block; width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; }
.hbars { display: grid; gap: 8px; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.hbars .hb { display: grid; grid-template-columns: 100px minmax(0, 1fr) 48px 64px; gap: 10px; align-items: center; }
.hbars .hb.wide { grid-template-columns: minmax(130px, 220px) minmax(0, 1fr) 64px 64px; }
.hbars .hb.head { font-size: 0.75rem; color: var(--ink-2); }
.hbars .r { text-align: right; }
.hbars .track { position: relative; height: 14px; }
.hbars .track i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 0 2px 2px 0; }
.hbars .track u { position: absolute; top: -3px; bottom: -3px; border-left: 2px solid var(--ink); }
.line-chart svg { min-width: 480px; }
.line-chart .grid { stroke: var(--rule); }
.line-chart .line { stroke: var(--accent); fill: none; stroke-width: 2.5; }
.line-chart .dot { fill: var(--accent); }
.line-chart text { fill: var(--ink-2); font-size: 12px; }
.line-chart text.v { fill: var(--ink); }
.later { border: 1px dashed var(--muted); border-radius: 10px; padding: 18px 20px; display: grid; gap: 6px; }
.later h3 { font-size: 1rem; font-weight: 600; }
.later p { font-size: 0.92rem; color: var(--ink-2); }
@media (max-width: 900px) and (min-width: 681px) { #summary.stats3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 680px) {
  #summary.stats3 { grid-template-columns: repeat(2, 1fr); }
  .pyr-row { grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr); gap: 4px; }
  .pyr-side span { display: none; }
  .hbars .hb.wide { grid-template-columns: minmax(0, 1fr) 56px 56px; }
  .hbars .hb.wide .track { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 680px) {
  .ptable { background: none; border: 0; border-radius: 0; overflow: visible; }
  .ptable table.stack { min-width: 0; display: block; }
  .ptable table.stack thead { display: none; }
  .ptable table.stack tbody { display: grid; gap: 8px; }
  .ptable table.stack tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 12px 14px; align-items: end; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
  .ptable table.stack tr[hidden] { display: none; }
  .ptable table.stack td { display: block; padding: 0; border: 0; text-align: left; white-space: normal; background: none; }
  .ptable table.stack td:first-child { grid-column: 1 / -1; font-weight: 600; }
  .ptable table.stack td.empty { display: none; }
  #cmp-table table.stack tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ptable table.stack .chg-bar { display: none; }
  .ptable table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 0.72rem; font-weight: 500; color: var(--ink-2); }
  .ptable table.stack tr.me { background: var(--accent-soft); }
  .ptable table.stack tr.total { background: var(--paper); }
  .ptable table.stack tr.krets { background: var(--paper); margin-left: 16px; padding: 8px 12px; }
  .ptable table.stack tr.krets td:first-child { padding-left: 0; font-weight: 500; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* inntekter.html and gjeld.html: the income note bar uses spans, not links, and year columns around a zero line. */
.note-bar > span { min-width: 0; display: flex; align-items: flex-end; border-right: 2px solid var(--surface); color: var(--paper); font: 700 0.95rem var(--font-display); }
.note-bar > span span { padding: 0 0 8px 8px; white-space: nowrap; }
@media (max-width: 680px) { .note-bar > span span { display: none; } }
.chart-box { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 16px 18px; display: grid; gap: 14px; min-width: 0; }
.chart-box h3 { font-size: 0.95rem; font-weight: 600; }
.cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; font-variant-numeric: tabular-nums; }
.col { display: grid; grid-template-rows: calc(var(--up) + 20px) calc(var(--down) + 20px) auto; justify-items: center; font-size: 0.78rem; color: var(--ink-2); }
.col .up { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; width: 100%; border-bottom: 1px solid var(--ink-2); }
.col .down { display: flex; flex-direction: column; justify-content: flex-start; align-items: center; gap: 3px; width: 100%; }
.col i { display: block; width: 62%; background: var(--muted); border-radius: 3px 3px 0 0; min-height: 1px; }
.col .down i { border-radius: 0 0 3px 3px; background: var(--bad); opacity: 0.55; }
.col b { font-weight: 500; white-space: nowrap; }
.col.sel { color: var(--ink); font-weight: 700; }
.col.sel .up i { background: var(--accent); }
.col.sel .down i { opacity: 1; }
.col.sel b { font-weight: 700; }
.col small { font-size: 0.78rem; margin-top: 4px; }
.sub-h { margin: 28px 0 12px; font-size: 1rem; font-weight: 600; }
.rank.inv .rank-row { grid-template-columns: minmax(0, 280px) minmax(60px, 1fr) 70px 64px 0; }
.rank.inv .rank-fill { background: var(--muted); }
.rank.inv .rank-row.total { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 700; }
.rank.inv .rank-row.total .rank-name { font-weight: 700; }
@media (max-width: 680px) { .rank.inv .rank-row { grid-template-columns: minmax(0, 1fr) auto 0; } }
.rank.inv .rank-row.rest .rank-fill { background: var(--rule); }
