/* Budget — mobil først, lys/mørk tema */
:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --ring: rgba(11, 11, 11, .10);
  --accent: #1c5cab;
  --accent-hover: #184f95;
  --accent-soft: #cde2fb;
  --on-accent: #fff;
  --inc: #2a78d6;          /* serie: indtægter (kategorisk blå) */
  --exp: #eb6834;          /* serie: udgifter (kategorisk orange) */
  --var: #eda100;          /* variable udgifter (kategorisk gul) */
  --good-text: #006300;
  --bad-text: #b42323;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --critical-soft: #fbe9e9;
  --good-soft: #e3f4e3;
  --info-soft: #e5effb;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
  --radius: 14px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --line: #2c2c2a;
    --line-strong: #383835;
    --ring: rgba(255, 255, 255, .10);
    --accent: #5598e7;
    --accent-hover: #6da7ec;
    --accent-soft: #184f95;
    --on-accent: #0b0b0b;
    --inc: #3987e5;
    --exp: #d95926;
    --var: #c98500;
    --good-text: #3fc23f;
    --bad-text: #f08080;
    --critical-soft: #3a1d1d;
    --good-soft: #17301a;
    --info-soft: #172a42;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422; --ink: #f0efec; --ink-2: #c3c2b7;
  --muted: #9a988f; --line: #2c2c2a; --line-strong: #383835; --ring: rgba(255, 255, 255, .10);
  --accent: #5598e7; --accent-hover: #6da7ec; --accent-soft: #184f95; --on-accent: #0b0b0b;
  --inc: #3987e5; --exp: #d95926; --var: #c98500; --good-text: #3fc23f; --bad-text: #f08080;
  --critical-soft: #3a1d1d; --good-soft: #17301a; --info-soft: #172a42; --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
/* Reservér altid plads til scrollbaren, så indholdet ikke hopper mellem korte og lange sider */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 650; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; justify-content: center; }
.strong { font-weight: 650; }
.neg { color: var(--bad-text) !important; }
.pos { color: var(--good-text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; }
.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; }

/* ---------- Skal og navigation ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(.5rem + env(safe-area-inset-top)) 1rem .5rem; background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.1rem; }
.brand:hover { color: var(--ink); }
.main { padding: 1rem 1rem calc(var(--tabbar-h) + 2rem + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar > a, .tabbar summary {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .7rem; color: var(--muted); text-decoration: none; cursor: pointer; list-style: none;
}
.tabbar summary::-webkit-details-marker { display: none; }
.tabbar > a.active { color: var(--accent); font-weight: 600; }
.tab-add { position: relative; display: flex; justify-content: center; }
.tab-add summary { height: 100%; }
.tab-add-btn {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 12px rgba(28, 92, 171, .35);
  transition: transform .15s;
}
.tab-add[open] .tab-add-btn { transform: rotate(45deg); }
.add-sheet {
  position: absolute; bottom: calc(100% + .5rem); left: 50%; transform: translateX(-50%);
  width: min(280px, calc(100vw - 2rem)); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); padding: .5rem;
}
.add-sheet a {
  display: flex; align-items: center; gap: .75rem; padding: .75rem; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; font-weight: 550;
}
.add-sheet a:hover { background: var(--surface-2); }
.add-sheet-title { margin: .4rem .75rem .1rem; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-inc { background: var(--inc); }
.dot-exp { background: var(--exp); }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 1.25rem; position: sticky; top: 0; height: 100vh;
    padding: 1.25rem 1rem; background: var(--surface); border-right: 1px solid var(--line);
  }
  .sidebar .brand { padding: .25rem .5rem; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav a {
    display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: var(--radius-sm);
    color: var(--ink-2); text-decoration: none; font-weight: 500;
  }
  .side-nav a:hover { background: var(--surface-2); color: var(--ink); }
  .side-nav a.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
  .side-actions { display: flex; flex-direction: column; gap: .5rem; }
  .side-user { margin-top: auto; padding: .75rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: .25rem; }
  .side-user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar, .tabbar, .mobile-only { display: none !important; }
  .main { padding: 2rem 2rem 3rem; }
}

/* ---------- Sidehoved ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head p { margin: .25rem 0 0; }
.back { display: inline-flex; align-items: center; gap: .25rem; font-size: .9rem; text-decoration: none; margin-bottom: .35rem; }
.period { display: flex; align-items: center; gap: .25rem; }
.period-label { min-width: 9.5rem; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.actions-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.push-right { margin-left: auto; }

/* ---------- Knapper ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px;
  padding: .5rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-inc::before, .btn-exp::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--inc); }
.btn-exp::before { background: var(--exp); }
.btn-inc .icon, .btn-exp .icon { display: none; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn-danger:hover { background: #b42323; color: #fff; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--bad-text); }
.btn-danger-ghost:hover { background: var(--critical-soft); color: var(--bad-text); }
.btn-sm { min-height: 34px; padding: .3rem .75rem; font-size: .875rem; }
.btn-lg { min-height: 48px; padding: .65rem 1.25rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn-danger:hover { background: var(--critical-soft); color: var(--bad-text); }
.link-btn { display: inline-flex; align-items: center; gap: .4rem; border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; font-size: .9rem; }
.link-btn:hover { color: var(--ink); }
.link-btn .icon { width: 16px; height: 16px; }

/* ---------- Kort ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); min-width: 0;
}
.card > h2 { margin-bottom: .75rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head-total { font-weight: 650; font-variant-numeric: tabular-nums; }
.card-flush { padding: 0; overflow: hidden; }
.card-head-pad { padding: 1rem 1rem 0; }
.card-pad-x { padding: .75rem 1rem 1rem; margin: 0; }
@media (min-width: 640px) { .card { padding: 1.25rem; } .card-head-pad { padding: 1.25rem 1.25rem 0; } }
.grid-2 { display: grid; gap: 0 1rem; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1fr 1fr; align-items: start; } }

.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--muted); }
.sw-inc { background: var(--inc); }
.sw-exp { background: var(--exp); }
.sw-var { background: var(--var); }
.dot-var { background: var(--var); }
.sw-mark { width: 14px; height: 2px; border-radius: 1px; background: var(--ink); }

/* ---------- Ligningen: indtægter − udgifter = til overs ---------- */
.equation { padding: 1.1rem 1rem; }
.eq-head { display: grid; grid-template-columns: 1fr auto; align-items: end; margin-bottom: .5rem; gap: .5rem; }
.eq-cols-head, .eq-row { display: grid; grid-template-columns: minmax(0, 1fr) 6.75rem 6.75rem; gap: .5rem; align-items: baseline; }
.eq-head .eq-cols-head { grid-template-columns: 6.75rem 6.75rem; }
.eq-cols-head span { text-align: right; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.eq-row { padding: .55rem 0; border-top: 1px solid var(--line); }
.eq-label { display: flex; align-items: center; gap: .5rem; color: var(--ink-2); min-width: 0; }
.eq-op { display: inline-block; width: .9rem; text-align: center; font-weight: 700; color: var(--muted); }
.eq-val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.eq-actual { font-weight: 600; }
.eq-total { border-top: 2px solid var(--ink); }
.eq-total .eq-label { color: var(--ink); font-weight: 700; }
.eq-total .eq-val { font-size: 1.15rem; font-weight: 750; }
.eq-meter { margin-top: .9rem; }
.eq-meter-label { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink-2); margin-bottom: .35rem; }
@media (max-width: 420px) {
  .eq-cols-head, .eq-row { grid-template-columns: minmax(0, 1fr) 5.6rem 5.6rem; gap: .35rem; }
  .eq-head .eq-cols-head { grid-template-columns: 5.6rem 5.6rem; }
  .eq-val { font-size: .9rem; }
  .eq-total .eq-val { font-size: 1rem; }
}
@media (min-width: 640px) {
  .equation { padding: 1.4rem 1.5rem; }
  .eq-cols-head, .eq-row { grid-template-columns: minmax(0, 1fr) 10rem 10rem; }
  .eq-head .eq-cols-head { grid-template-columns: 10rem 10rem; }
  .eq-total .eq-val { font-size: 1.4rem; }
}

/* ---------- Nøgletal ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 1000px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .2rem; box-shadow: var(--shadow); min-width: 0; }
.tile-label { font-size: .8rem; color: var(--ink-2); }
.tile-value { font-size: 1.3rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { font-size: .75rem; color: var(--muted); }
@media (min-width: 640px) { .tile-value { font-size: 1.5rem; } }

/* ---------- Opsummering (budget/posteringer) ---------- */
.summary { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: .25rem .5rem; }
.summary-item { display: flex; flex-direction: column; min-width: 0; }
.summary-label { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--ink-2); }
.summary-value { font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-sub { font-size: .75rem; color: var(--muted); }
.summary-op { font-size: 1.4rem; color: var(--muted); font-weight: 300; }
.summary-total .summary-value { font-weight: 750; }
@media (min-width: 640px) { .summary-value { font-size: 1.4rem; } }
@media (max-width: 520px) {
  .summary { grid-template-columns: 1fr; gap: .6rem; }
  .summary-op { display: none; }
  .summary-item { flex-direction: row; justify-content: space-between; align-items: baseline; flex-wrap: wrap; column-gap: .75rem; }
  .summary-item .summary-sub { flex-basis: 100%; text-align: right; margin-top: -.2rem; }
  .summary-total { border-top: 2px solid var(--ink); padding-top: .6rem; }
}

/* ---------- Faneblade ---------- */
.tabs { display: flex; gap: .25rem; margin: 0 0 1rem; padding: 4px; background: var(--surface-2); border-radius: 12px; width: fit-content; max-width: 100%; }
.tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: .95rem; }
.tabs a.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.tabs .icon { width: 16px; height: 16px; }

/* ---------- Rækker ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-top: 1px solid var(--line); min-height: 56px; }
.rows > .row:first-child { border-top: 0; }
.row.is-inactive { opacity: .55; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--ink); text-decoration: none; }
a.row-main:hover .row-title { text-decoration: underline; }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-amounts { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.row-actions { display: flex; align-items: center; }
.row-actions form { margin: 0; }
.row form { margin: 0; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.amount-inc { color: var(--good-text); }
@media (max-width: 639px) { .row-actions { display: none; } }

.group + .group { margin-top: .75rem; }
.group-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem .75rem; background: var(--surface-2); border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; }
.group-head > span:first-child { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.group .rows { padding: 0 .25rem; }

.day + .day { margin-top: .5rem; }
.day-head { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 600; color: var(--ink-2); padding: .5rem 0 .25rem; border-bottom: 1px solid var(--line); }
.day .rows > .row:first-child { border-top: 0; }
.list-count { margin-bottom: .25rem; }

.tag { display: inline-block; vertical-align: 1px; margin-left: .35rem; padding: 0 .4rem; border-radius: 6px; font-size: .68rem; font-weight: 650; letter-spacing: .02em; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.eq-row-1 { grid-template-columns: minmax(0, 1fr) auto !important; }
.eq-note { margin: .75rem 0 0; font-size: .88rem; }
.pots { list-style: none; margin: 0; padding: 0; }
.pot { padding: .8rem 0; border-top: 1px solid var(--line); }
.pot:first-child { border-top: 0; padding-top: .25rem; }
.pot-top { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; margin-bottom: .4rem; }
.pot-name { display: flex; align-items: center; gap: .5rem; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pot-vals { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pot-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; margin-top: .45rem; flex-wrap: wrap; }
.pot-left { display: flex; align-items: center; gap: .3rem; font-size: .88rem; color: var(--ink-2); padding-top: .4rem; }
.pot-add { margin-left: auto; }
.pot-add summary { list-style: none; }
.pot-add summary::-webkit-details-marker { display: none; }
.pot-add[open] { flex-basis: 100%; }
.pot-add[open] summary { display: none; }
.pot-form { display: grid; grid-template-columns: 1fr; gap: .5rem; margin-top: .1rem; }
@media (min-width: 560px) { .pot-form { grid-template-columns: 9rem 1fr auto; } }
.pot-entries { margin-top: .4rem; font-size: .85rem; }
.pot-entries summary { cursor: pointer; color: var(--accent); width: fit-content; }
.pot-entries ul { list-style: none; margin: .35rem 0 0; padding: 0; }
.pot-entries li { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) auto 32px; align-items: center; gap: .5rem; padding: .15rem 0; }
.pot-entry-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.pot-entries form { margin: 0; }
.icon-btn-sm { width: 32px; height: 32px; }
.pick-list { display: grid; gap: .4rem; }
@media (min-width: 560px) { .pick-list { grid-template-columns: 1fr 1fr; } }
.pick { position: relative; cursor: pointer; }
.pick input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pick-body { display: flex; flex-direction: column; gap: .1rem; padding: .7rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); min-height: 56px; }
.pick-name { display: flex; align-items: center; gap: .5rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-left { font-size: .82rem; color: var(--muted); padding-left: 1.1rem; }
.pick input:checked + .pick-body { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.pick input:focus-visible + .pick-body { outline: 2px solid var(--accent); outline-offset: 2px; }
.pw-rules { list-style: none; margin: .15rem 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .75rem; font-size: .82rem; color: var(--muted); }
.pw-rules li { display: flex; align-items: center; gap: .35rem; }
.pw-rules .icon { opacity: .35; }
.pw-rules li.is-met { color: var(--good-text); }
.pw-rules li.is-met .icon { opacity: 1; }
.check-card { align-items: flex-start; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.check-card input { margin-top: .15rem; }
.check-card > span { display: flex; flex-direction: column; gap: .15rem; }
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .25rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge-good { background: var(--good-soft); color: var(--good-text); }

/* ---------- Sammenligning og målere ---------- */
.sub-head { margin: .5rem 0 .25rem; color: var(--ink-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.compare { list-style: none; margin: 0 0 .5rem; padding: 0; }
.compare li { padding: .55rem 0; border-top: 1px solid var(--line); }
.compare li:first-child { border-top: 0; }
.compare-top { display: flex; justify-content: space-between; gap: .75rem; margin-bottom: .35rem; font-size: .92rem; }
.compare-name { display: flex; align-items: center; gap: .5rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-vals { white-space: nowrap; font-variant-numeric: tabular-nums; }
.compare-note { display: flex; align-items: center; gap: .3rem; font-size: .78rem; margin-top: .3rem; }
.meter { height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter.is-near span { background: var(--warning); }
.meter.is-over { background: var(--critical-soft); }
.meter.is-over span { background: var(--critical); }
.meter.is-good span { background: var(--good); }
.status { display: flex; align-items: center; gap: .4rem; font-size: .88rem; font-weight: 550; margin: .75rem 0 0; }
.status-critical { color: var(--bad-text); }

/* ---------- Søjlediagram ---------- */
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; list-style: none; padding: 0; margin: 0 0 .75rem; font-size: .82rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: .4rem; }
.chart-bars { position: relative; height: 230px; padding-left: 3.1rem; margin-bottom: .25rem; }
.cb-ticks { position: absolute; inset: 0 0 1.6rem 0; pointer-events: none; }
.cb-tick { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.cb-tick:last-child { border-top-color: var(--line-strong); }
.cb-tick span { position: absolute; left: 0; top: -.55rem; font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; width: 2.9rem; text-align: right; padding-right: .35rem; }
.cb-cols { position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); height: 100%; }
.cb-col { position: relative; display: flex; flex-direction: column; outline: none; cursor: default; }
.cb-plot { flex: 1; display: flex; justify-content: center; border-radius: 6px; }
.cb-col:hover .cb-plot, .cb-col:focus .cb-plot { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.cb-col.is-current .cb-label { color: var(--ink); font-weight: 700; }
.cb-pair { display: flex; gap: 2px; width: 72%; max-width: 38px; height: 100%; }
.cb-slot { position: relative; flex: 1; display: flex; align-items: flex-end; }
.cb-bar { display: block; width: 100%; border-radius: 4px 4px 0 0; min-height: 0; }
.cb-inc { background: var(--inc); }
.cb-exp { background: var(--exp); }
.cb-mark { position: absolute; left: -2px; right: -2px; height: 2px; background: var(--ink); border-radius: 1px; transform: translateY(1px); box-shadow: 0 0 0 1px var(--surface); }
.cb-label { height: 1.6rem; display: flex; align-items: center; justify-content: center; font-size: .72rem; color: var(--muted); text-transform: capitalize; }
.cb-tip {
  display: none; position: absolute; z-index: 5; bottom: calc(100% - 1rem); left: 50%; transform: translateX(-50%);
  min-width: 13rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16); padding: .6rem .75rem; font-size: .8rem; pointer-events: none;
}
.cb-col:nth-child(-n+3) .cb-tip { left: 0; transform: none; }
.cb-col:nth-last-child(-n+3) .cb-tip { left: auto; right: 0; transform: none; }
.cb-col:hover .cb-tip, .cb-col:focus .cb-tip { display: flex; flex-direction: column; gap: .2rem; }
.cb-tip span { display: flex; align-items: center; gap: .4rem; white-space: nowrap; color: var(--ink-2); }
.cb-tip b { margin-left: auto; padding-left: .75rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.cb-tip .tip-net { border-top: 1px solid var(--line); padding-top: .25rem; margin-top: .1rem; color: var(--ink); font-weight: 600; }
.cb-tip .tip-bud { color: var(--muted); font-size: .75rem; }
.chart-foot { margin: .5rem 0 0; font-size: .85rem; }
.chart-foot a { display: inline-flex; align-items: center; gap: .35rem; }
.chart-foot .icon { width: 16px; height: 16px; }
@media (min-width: 640px) { .chart-bars { height: 280px; } }

/* ---------- Fordeling ---------- */
.dist-bar { display: flex; gap: 2px; height: 22px; border-radius: 6px; overflow: hidden; margin-bottom: 1rem; }
.dist-bar .seg { display: block; min-width: 3px; flex-basis: 0; }
.dist-legend { list-style: none; margin: 0; padding: 0; }
.dist-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 3rem; align-items: center; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line); font-size: .92rem; }
.dist-legend li:first-child { border-top: 0; }
.dist-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.dist-pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Årsoversigt-tabel ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: .75rem; }
.matrix { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .85rem; font-variant-numeric: tabular-nums; }
.matrix th, .matrix td { padding: .5rem .6rem; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.matrix thead th { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: var(--surface); }
.matrix .sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 550; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 var(--line); }
.matrix th.sticky .sw { margin-right: .45rem; vertical-align: 0; }
.matrix .matrix-section th { background: var(--surface-2); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.matrix .matrix-sum th, .matrix .matrix-sum td { font-weight: 700; border-bottom: 2px solid var(--line-strong); }
.matrix .matrix-net th, .matrix .matrix-net td { font-weight: 750; background: var(--surface-2); }
.matrix .matrix-acc th, .matrix .matrix-acc td { color: var(--ink-2); }
.matrix .is-current { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ---------- Formularer ---------- */
.form { display: flex; flex-direction: column; gap: 1rem; }
/* Formularkort har samme bredde som alle andre kort; selve felterne holdes i læsebredde */
.form-card .form { max-width: 720px; }
.field { display: flex; flex-direction: column; gap: .35rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { font-weight: 600; font-size: .92rem; padding: 0; }
.field-row { display: grid; gap: 1rem; }
@media (min-width: 560px) { .field-row { grid-template-columns: 1fr 1fr; } }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: 46px; padding: .6rem .8rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 1rem; appearance: none; -webkit-appearance: none;
}
select {
  padding-right: 2.25rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
[aria-invalid="true"] { border-color: var(--critical) !important; }
.field-error { color: var(--bad-text); font-size: .85rem; margin: 0; font-weight: 550; }
.hint { color: var(--muted); font-size: .82rem; margin: 0; }
.input-unit { position: relative; }
.input-unit input { padding-right: 3rem; font-variant-numeric: tabular-nums; }
.input-unit span { position: absolute; right: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-unit-lg input { font-size: 1.25rem; font-weight: 600; }
.check { display: flex; align-items: center; gap: .6rem; font-size: .92rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; padding-top: .25rem; }
@media (max-width: 559px) { .form-actions .btn { flex: 1 1 100%; } }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span { display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px; border-radius: 9px; font-weight: 600; color: var(--ink-2); }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.segmented .seg-inc input:checked + span { box-shadow: inset 0 -3px 0 var(--inc), 0 1px 3px rgba(0, 0, 0, .12); }
.segmented .seg-exp input:checked + span { box-shadow: inset 0 -3px 0 var(--exp), 0 1px 3px rgba(0, 0, 0, .12); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.month-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
@media (min-width: 560px) { .month-grid { grid-template-columns: repeat(6, 1fr); } }
.month-chip { position: relative; cursor: pointer; }
.month-chip input { position: absolute; opacity: 0; }
.month-chip span { display: flex; align-items: center; justify-content: center; min-height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-weight: 550; font-size: .9rem; }
.month-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.month-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.swatches { display: flex; flex-wrap: wrap; gap: .5rem; }
.swatch-pick { position: relative; cursor: pointer; }
.swatch-pick input { position: absolute; opacity: 0; }
.swatch-pick span:first-of-type { display: block; width: 38px; height: 38px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.swatch-pick input:checked + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
.swatch-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 5px; }

details.more summary { cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--accent); padding: .25rem 0; }
details.more[open] summary { margin-bottom: .5rem; }
details.more .field-row { margin-top: .75rem; }
.preview { margin: 0; padding: .75rem 1rem; background: var(--info-soft); border-radius: var(--radius-sm); font-size: .92rem; }
.danger-zone { margin: 0 0 1rem; }
.danger-card h2 { color: var(--bad-text); }
.danger-card details summary { list-style: none; display: inline-flex; margin-bottom: .75rem; }
.danger-card details summary::-webkit-details-marker { display: none; }
[hidden], [data-hidden] { display: none !important; }

/* ---------- Filtre ---------- */
.filters { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr; padding: .75rem; }
.filter-search { position: relative; grid-column: 1 / -1; }
.filter-search .icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filter-search input { padding-left: 2.3rem !important; }
.filter-links { grid-column: 1 / -1; display: flex; gap: 1rem; font-size: .88rem; }
@media (min-width: 860px) {
  .filters { grid-template-columns: 2fr 1fr 1fr auto; align-items: center; }
  .filter-search { grid-column: auto; }
  .filter-links { grid-column: auto; }
}

/* ---------- Beskeder ---------- */
.flash { display: flex; align-items: flex-start; gap: .6rem; padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 500; background: var(--info-soft); }
.flash > span { flex: 1; }
.flash-success { background: var(--good-soft); }
.flash-success .icon { color: var(--good-text); }
.flash-error { background: var(--critical-soft); }
.flash-error .icon { color: var(--bad-text); }
.flash-close { border: 0; background: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 .25rem; }

/* ---------- Tom tilstand og onboarding ---------- */
.empty { text-align: center; padding: 2rem 1rem; }
.empty h1, .empty h2 { justify-content: center; margin-bottom: .5rem; }
.empty-code { font-size: 3rem; font-weight: 800; color: var(--muted); margin: 0; }
.onboarding { background: linear-gradient(135deg, var(--info-soft), var(--surface)); }
.onboarding > p { color: var(--ink-2); margin-top: .5rem; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: .5rem; }
@media (min-width: 860px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps li { counter-increment: step; }
.steps a { display: flex; flex-direction: column; gap: .2rem; height: 100%; padding: .9rem 1rem .9rem 3.2rem; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; }
.steps a::before { content: counter(step); position: absolute; left: 1rem; top: .85rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.steps a:hover { border-color: var(--accent); }
.steps span { font-size: .85rem; color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 0; }
.stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.stats dt { font-size: .78rem; color: var(--muted); }
.stats dd { margin: 0; font-weight: 650; font-size: 1.1rem; }
.link-list { padding: .25rem 1rem; }
.link-list a { display: flex; align-items: center; gap: .75rem; padding: .85rem 0; color: var(--ink); text-decoration: none; border-top: 1px solid var(--line); font-weight: 550; }
.link-list a:first-child { border-top: 0; }
.link-list a span { flex: 1; }

/* ---------- Login ---------- */
.auth-body { background: radial-gradient(1200px 500px at 50% -10%, var(--info-soft), var(--page)); }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-brand { display: flex; align-items: center; gap: .75rem; font-size: 1.5rem; font-weight: 750; margin-bottom: 1.25rem; }
.auth-card { width: 100%; max-width: 420px; padding: 1.5rem; }
.auth-card h1 { margin-bottom: .35rem; }
.auth-switch { text-align: center; margin: 1.25rem 0 0; font-size: .95rem; }
.auth-foot { color: var(--muted); font-size: .85rem; margin-top: 1rem; text-align: center; }

@media (forced-colors: active) {
  .cb-bar, .seg, .meter span, .sw { forced-color-adjust: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .sidebar, .topbar, .tabbar, .actions-bar, .row-actions, .filters, .btn { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}
