:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1b2422;
  --ink-2: #4d5957;
  --ink-3: #7c8785;
  --line: #e4e2dc;
  --line-2: #d3d0c8;
  --brand: #0f5e5a;
  --brand-ink: #ffffff;
  --brand-soft: #e3efed;
  --accent: #5fa89c;
  --warn: #a8591a;
  --warn-soft: #fbeedd;
  --bad: #a23b32;
  --bad-soft: #f8e4e1;
  --ok: #2e7550;
  --ok-soft: #e1f1e7;
  --shadow: 0 1px 2px rgba(20,30,28,.05), 0 4px 16px rgba(20,30,28,.05);
  --radius: 12px;
  --surface: #ffffff;
  --s1: #2a78d6; --s2: #1baf7a; --s3: #eb6834;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121615; --surface: #1a1f1e; --surface-2: #1f2524;
    --ink: #e8ecea; --ink-2: #b2bcb9; --ink-3: #85908d;
    --line: #2b3331; --line-2: #3a4442;
    --brand: #5fb5a9; --brand-ink: #0c1413; --brand-soft: #1d3330; --accent: #2f7a70;
    --warn: #e0a066; --warn-soft: #3a2a1a; --bad: #e88a80; --bad-soft: #3d2220;
    --ok: #7fcc9f; --ok-soft: #1d3326;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    --surface: #1a1f1e;
    --s1: #3987e5; --s2: #199e70; --s3: #d95926;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
--bg: #121615; --surface: #1a1f1e; --surface-2: #1f2524;
  --ink: #e8ecea; --ink-2: #b2bcb9; --ink-3: #85908d;
  --line: #2b3331; --line-2: #3a4442;
  --brand: #5fb5a9; --brand-ink: #0c1413; --brand-soft: #1d3330; --accent: #2f7a70;
  --warn: #e0a066; --warn-soft: #3a2a1a; --bad: #e88a80; --bad-soft: #3d2220;
  --ok: #7fcc9f; --ok-soft: #1d3326;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  --surface: #1a1f1e;
  --s1: #3987e5; --s2: #199e70; --s3: #d95926;
  color-scheme: dark;
}


* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 Figtree, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* Loader */
.loader { min-height: 100vh; display: grid; place-items: center; }
.loader span { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; }
.auth-card h1 { font-size: 22px; margin: 22px 0 4px; letter-spacing: -.01em; }
.auth-card p { margin: 0 0 18px; color: var(--ink-2); }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 14px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); outline: none; min-height: 40px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.seg { align-self: flex-start; display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg label { padding: 8px 14px; cursor: pointer; font-size: 14px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--brand); color: var(--brand-ink); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 14px; cursor: pointer; }
.chip-check:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); }
.chip-check input { accent-color: var(--brand); margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; min-height: 40px; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line-2)); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.msg { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.msg.err { background: var(--bad-soft); color: var(--bad); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }

/* Shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .brand { padding: 0 8px 22px; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.side-foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 8px; }
main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 2px 0 0; color: var(--ink-3); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); gap: 12px; }
  .side .brand { padding: 0; }
  .side .brand small { display: none; }
  .side { max-width: 100vw; }
  .nav { flex-direction: row; overflow-x: auto; gap: 2px; flex: 1; min-width: 0; scrollbar-width: none; }
  .nav a { padding: 7px 10px; white-space: nowrap; font-size: 14px; }
  .nav a svg, .nav .count { display: none; }
  .side-foot { margin: 0; padding: 0; border: 0; }
  .side-foot .who { display: none; }
  main { padding: 20px 16px 48px; }
}

/* Cards / KPIs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card h2 { font-size: 15px; margin: 0 0 14px; letter-spacing: -.005em; }
.card h2 .muted { font-weight: 500; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr; } }
.kpi { padding: 16px 18px; }
.kpi .label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--ink-3); }
.kpi.hero { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.kpi.hero .label, .kpi.hero .sub { color: color-mix(in srgb, var(--brand-ink) 78%, transparent); }
.grid-main { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-bottom: 14px; align-items: start; }
.grid-halves { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 1100px) { .grid-main, .grid-halves { grid-template-columns: 1fr; } }

.month-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 2px; }
.month-nav button { border: 0; background: none; width: 34px; height: 34px; border-radius: 6px; cursor: pointer; font-size: 16px; }
.month-nav button:hover { background: var(--surface-2); }
.month-nav span { min-width: 128px; text-align: center; font-weight: 600; text-transform: capitalize; }

/* Chart */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: inherit; }
.chart .grid { stroke: var(--line); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--bg); padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.45; z-index: 100; white-space: nowrap; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; background: var(--brand); border-radius: 5px; }
.bar-row .amount { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; text-align: right; min-width: 92px; }

.alerts { display: flex; flex-direction: column; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.alert:first-child { border-top: 0; padding-top: 0; }
.alert:hover .t { text-decoration: underline; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--warn); }
.dot.bad { background: var(--bad); }
.alert .t { font-weight: 600; font-size: 14px; }
.alert .d { font-size: 13px; color: var(--ink-3); }
.empty { color: var(--ink-3); font-size: 14px; padding: 6px 0; }

/* Toolbar + table */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1 1 220px; max-width: 340px; }
.toolbar select { width: auto; flex: 0 1 180px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; background: var(--surface-2); }
th:first-child { border-top-left-radius: var(--radius); }
th:last-child { border-top-right-radius: var(--radius); }
th.r, td.r { text-align: right; }
th .arr { opacity: .6; margin-left: 3px; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; border-top: 1px solid var(--line-2); border-bottom: 0; background: var(--surface-2); }
td .sub { display: block; color: var(--ink-3); font-size: 12.5px; }
.nowrap { white-space: nowrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* People cards */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.person { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.person-head { display: flex; align-items: center; gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.person-head .n { font-weight: 700; }
.person-head .r { font-size: 13px; color: var(--ink-3); }
.person-head .btn { margin-left: auto; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.stat b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-3); }
.caselist { font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; }
.caselist a { text-decoration: none; color: var(--ink); display: flex; gap: 8px; }
.caselist a:hover span:last-child { text-decoration: underline; }
.caselist .nr { color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 28px; }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(15,22,21,.45); display: flex; justify-content: center; align-items: flex-start; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 760px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.sm { max-width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px 22px 6px; }
.modal-foot { display: flex; gap: 8px; justify-content: space-between; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .right { display: flex; gap: 8px; margin-left: auto; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; margin: 6px 0 10px; }
.calc { background: var(--brand-soft); color: var(--brand); border-radius: 8px; padding: 10px 12px; font-weight: 600; margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-3); width: 36px; height: 36px; border-radius: 8px; }
.x:hover { background: var(--surface-2); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: .2s; pointer-events: none; z-index: 200; }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ===== Version 2 ===== */
button.card, button.kpi, button.bar-row, button.bar-group, button.alert, button.b-row, button.ring-wrap { font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%; }
button.kpi { display: block; }
button.kpi:hover { border-color: var(--line-2); box-shadow: 0 2px 10px rgba(20,30,28,.09); }
button.kpi.hero:hover { filter: brightness(1.06); }
.kpis.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .kpis.three { grid-template-columns: 1fr; } }
.value.pos { color: var(--ok); } .value.neg, .neg { color: var(--bad); } .pos { color: var(--ok); }
.kpi.hero .value.pos, .kpi.hero .value.neg { color: inherit; }
.warnc { color: var(--warn); }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 10px; overflow: hidden; border: 1px solid var(--line); }
.progress i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn-red { background: var(--bad); border-color: var(--bad); color: #fff; }
.count.warn { color: var(--warn); font-weight: 700; }

.chart text.sel { fill: var(--ink); font-weight: 700; }
.bar-hit { cursor: pointer; }
.bar-hit:hover rect:first-child { fill: var(--surface-2); }
.legend i.striped { background: color-mix(in srgb, var(--s1) 38%, transparent); border: 1px dashed var(--s1); }

.ring-wrap { display: flex; align-items: center; gap: 18px; background: none; border: 0; padding: 0; }
.ring { width: 130px; height: 130px; flex: none; }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--ok); stroke-width: 12; stroke-linecap: round; }
.ring-num { font-size: 24px; font-weight: 700; fill: var(--ink); font-family: inherit; }
.ring-lbl { font-size: 11px; fill: var(--ink-3); font-family: inherit; }
.ring-txt { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.linklike { color: var(--brand); font-weight: 600; margin-top: 6px; }

button.bar-row { background: none; border: 0; padding: 2px 0; border-radius: 6px; }
button.bar-row:hover .name { text-decoration: underline; }
.bar-group { background: none; border: 0; padding: 4px 0; display: flex; flex-direction: column; gap: 4px; }
.bg-head { display: flex; justify-content: space-between; font-size: 14px; }
.bar-group:hover .bg-head span { text-decoration: underline; }
.bar-track.thin { height: 8px; }

.alerts.cols { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }
@media (max-width: 860px) { .alerts.cols { grid-template-columns: 1fr; } }
button.alert { background: none; border: 0; border-top: 1px solid var(--line); padding: 10px 0; }
.alerts.cols button.alert:nth-child(-n+2) { border-top: 0; padding-top: 0; }

.tabs { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.tabs button span { font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
table.clean td { padding: 13px 14px; }

.person-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; border-top: 1px solid var(--line); padding-top: 12px; }
.person.inaktiv { opacity: .7; }

.budget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
@media (max-width: 480px) { .budget-grid { grid-template-columns: 1fr; } }
.budget { padding: 18px 20px; display: flex; flex-direction: column; }
.budget-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.budget-head h2 { margin: 0; font-size: 17px; }
.b-sec { padding: 10px 0; border-bottom: 1px solid var(--line); }
.b-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; margin-bottom: 6px; }
.b-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 6px; margin: 0 -6px; border: 0; background: none; border-radius: 6px; font-size: 14px; width: calc(100% + 12px) !important; }
.b-row:hover:not(.static) { background: var(--surface-2); }
.b-row .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.b-row .sub { display: block; font-size: 12px; color: var(--ink-3); }
.b-row.off { opacity: .5; }
.b-sum { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; padding-top: 6px; margin-top: 4px; border-top: 1px dashed var(--line); }
.b-result { display: flex; justify-content: space-between; font-weight: 700; font-size: 18px; padding-top: 12px; margin-top: auto; }
.addline { margin: 4px 0 2px -6px; }

.factbox { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 2px; }
.factbox span { font-size: 13px; color: var(--ink-3); }
.mini-list { display: flex; flex-direction: column; }
.mini-list > div { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.mini-list > div:first-child { border-top: 0; }
.mini-list > div > :first-child { flex: 1; }
.cap { text-transform: capitalize; }
details.intern { margin: 4px 0 12px; }
details.intern summary { cursor: pointer; font-size: 13px; color: var(--ink-3); font-weight: 600; }
.seg { flex-wrap: wrap; }

/* Budget vs aktuelt + flyt linjer */
.b-cols { display: grid; grid-template-columns: 1fr 92px 92px; gap: 8px; align-items: baseline; }
.b-cols > span:not(:first-child) { text-align: right; }
.b-title.b-cols { margin-right: 30px; }
.b-sum.b-cols, .b-result.b-cols { margin-right: 30px; }
.b-line { display: flex; align-items: stretch; gap: 4px; }
.b-line .b-row { display: grid; grid-template-columns: 1fr 92px 92px; gap: 8px; align-items: baseline; flex: 1; width: auto !important; margin: 0 0 0 -6px; }
.b-line .b-row .num { text-align: right; }
.b-row .num.diff { color: var(--brand); font-weight: 700; }
.mv, .mv-spacer { display: flex; flex-direction: column; justify-content: center; width: 26px; flex: none; }
.mv button { border: 0; background: none; color: var(--ink-3); font-size: 10px; line-height: 1; padding: 3px 0; cursor: pointer; border-radius: 4px; }
.mv button:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.mv button:disabled { opacity: .25; cursor: default; }
.b-result .small-res { font-size: 14px; font-weight: 600; opacity: .7; }
.budget-grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
@media (max-width: 480px) { .b-cols, .b-line .b-row { grid-template-columns: 1fr 76px 76px; font-size: 13px; } }
@media (max-width: 860px) { .budget-grid { grid-template-columns: 1fr; } }

/* Tema-vælger */
.theme-pick { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.theme-pick button { border: 0; background: none; padding: 5px 9px; cursor: pointer; color: var(--ink-3); font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.theme-pick button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.theme-pick svg { width: 15px; height: 15px; }
@media (max-width: 860px) { .theme-pick { margin: 0; } .theme-pick button span { display: none; } .side-foot { display: flex; align-items: center; gap: 6px; } }

/* v4: kommende, dokumenter, historik */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .btn svg { margin-right: 2px; }
.agenda { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.ag-row { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.ag-row:hover { border-color: var(--line-2); }
.ag-date { display: flex; flex-direction: column; align-items: center; min-width: 34px; line-height: 1.1; }
.ag-date b { font-size: 18px; } .ag-date span { font-size: 11px; color: var(--ink-3); text-transform: uppercase; }
.ag-ico { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); flex: none; }
.ag-ico.slut { background: var(--warn-soft); color: var(--warn); } .ag-ico.faktura { background: var(--ok-soft); color: var(--ok); }
.ag-row .t { font-weight: 600; font-size: 14px; } .ag-row .d { font-size: 12.5px; color: var(--ink-3); }
.copybox { display: flex; gap: 6px; } .copybox input { font-size: 12px; }
.steps { padding-left: 18px; margin: 0 0 10px; } .steps li { margin-bottom: 4px; }
.doclist { display: flex; flex-direction: column; }
.doc { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.doc:first-child { border-top: 0; }
.doc-ico { font-size: 10px; font-weight: 800; color: var(--bad); background: var(--bad-soft); border-radius: 5px; padding: 6px 5px; min-width: 34px; text-align: center; }
.doc-main { flex: 1; min-width: 0; } .doc-main a { font-weight: 600; word-break: break-all; } .doc-main .sub { display: block; font-size: 12px; color: var(--ink-3); }
.upload { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; }
.upload label.btn { cursor: pointer; }
.clip { font-size: 12px; }
.hist-dag { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; margin: 18px 0 6px; }
.hist-dag:first-child { margin-top: 0; }
.hist { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.hist-tid { color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 42px; font-size: 13px; padding-top: 1px; }
.hist-main { flex: 1; min-width: 0; }
.hist-diff { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.hist-diff i { font-style: normal; color: var(--ink-3); } .hist-diff s { color: var(--ink-3); }
.hist-mini .hist:first-child { border-top: 0; }
@media (max-width: 480px) { .agenda { grid-template-columns: 1fr; } }

/* ===================== Mobilversion ===================== */
.mtop, .mbar { display: none; }
@media (max-width: 860px) {
  body { -webkit-tap-highlight-color: transparent; }
  .shell { display: block; }
  .side { display: none !important; }
  .mtop { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
  .mtop .brand-mark { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }
  .mtop b { font-size: 17px; }
  .mtop .muted { margin-left: auto; }
  main { padding: 14px 14px calc(92px + env(safe-area-inset-bottom)); }
  .mbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .mbar a, .mbar button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--ink-3); text-decoration: none; font-size: 11px; font-weight: 600; border: 0; background: none; font-family: inherit; cursor: pointer; }
  .mbar svg { width: 24px; height: 24px; }
  .mbar .on { color: var(--brand); }
  .mbar .dotn { position: absolute; top: 0; left: 50%; margin-left: 6px; background: var(--warn); color: #fff; font-style: normal; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 0 5px; line-height: 16px; min-width: 16px; text-align: center; }
  .mere-list { display: flex; flex-direction: column; margin-bottom: 8px; }
  .mere-list a { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; }
  .mere-list a svg { width: 20px; height: 20px; color: var(--ink-3); }
  .mere-list a span:nth-child(2) { flex: 1; }
  .theme-pick button span { display: inline; }

  /* Sidehoved */
  .page-head { margin-bottom: 12px; gap: 10px; align-items: center; }
  .page-head h1 { font-size: 22px; }
  .page-head p { display: none; }
  .page-head .month-nav { width: 100%; justify-content: space-between; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .month-nav span { min-width: 0; }

  /* Nøgletal: 2 x 2 */
  .kpis, .kpis.three { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
  .kpis.three > :first-child { grid-column: span 2; }
  .kpi { padding: 12px 14px; }
  .kpi .label { font-size: 12px; }
  .kpi .value { font-size: 20px; margin: 2px 0 0; }
  .kpi .sub { font-size: 11.5px; line-height: 1.35; }
  .grid-main, .grid-halves { gap: 10px; margin-bottom: 10px; }
  .card-pad { padding: 14px; }
  .card h2 { font-size: 15px; margin-bottom: 10px; }
  .card h2 .muted { display: block; font-size: 12px; margin-top: 2px; }
  .ring { width: 96px; height: 96px; }
  .ring-wrap { gap: 14px; }
  .bar-row { grid-template-columns: 96px 1fr auto; font-size: 13px; }
  .bar-row .amount { min-width: 0; font-size: 12px; }
  .chart text { font-size: 10px; }
  .card-head .btn { width: 100%; }

  /* Værktøjslinje */
  .toolbar { gap: 6px; }
  .toolbar input[type=search] { flex: 1 1 100%; max-width: none; }
  .toolbar select { flex: 1 1 45%; }
  .toolbar .btn { flex: 1 1 auto; }
  .toolbar > div[style*="flex:1"] { display: none; }
  .tabs { width: 100%; } .tabs button { flex: 1; }

  /* Tabeller bliver til kort */
  .table-wrap { overflow: visible; }
  table.clean thead { display: none; }
  table.clean, table.clean tbody, table.clean tfoot { display: block; }
  table.clean tr { display: grid; grid-template-columns: auto 1fr auto; column-gap: 10px; row-gap: 3px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: baseline; }
  table.clean tbody tr:last-child { border-bottom: 0; }
  table.clean td { display: block; padding: 0; border: 0; background: none !important; }
  table.clean td.c-nr { grid-column: 1; font-size: 12px; }
  table.clean td.c-main { grid-column: 2; min-width: 0; }
  table.clean td.c-amt { grid-column: 3; text-align: right; }
  table.clean td.c-meta { grid-column: 2 / 4; font-size: 13px; color: var(--ink-2); }
  table.clean td.c-meta .sub { display: inline; margin-left: 6px; }
  table.clean td.c-hide { display: none; }
  table.clean td.c-act { grid-column: 2 / 4; margin-top: 6px; }
  table.clean td.c-act .btn { width: 100%; }
  table.clean td.c-main .sub { white-space: normal; }
  table.clean td.c-kom { font-size: 12px; color: var(--ink-3); }
  .c-lbl { color: var(--ink-3); }
  table.clean tfoot tr { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
  table.clean td.empty { grid-column: 1 / 4; }

  /* Personer og budget */
  .people { grid-template-columns: 1fr; gap: 10px; }
  .person { padding: 14px; }
  .budget { padding: 14px; }
  .b-cols, .b-line .b-row { grid-template-columns: 1fr 72px 80px; font-size: 13px; gap: 6px; }
  .b-row .sub { font-size: 11px; }
  .b-result { font-size: 16px; }
  .agenda { grid-template-columns: 1fr; }

  /* Vinduer fylder hele skærmen, Gem altid synlig */
  .overlay { padding: 0; align-items: stretch; }
  .modal, .modal.sm { max-width: none; min-height: 100%; border-radius: 0; display: flex; flex-direction: column; }
  .modal > form { display: flex; flex-direction: column; min-height: 100%; flex: 1; }
  .modal-head { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
  .modal-head h2 { font-size: 16px; }
  .modal-body { padding: 16px 16px 8px; flex: 1; }
  .modal-foot { position: sticky; bottom: 0; z-index: 2; background: var(--surface); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 12px rgba(0,0,0,.06); }
  .modal-foot .right { flex: 1; }
  .modal-foot .right .btn { flex: 1; }
  .grid3 { grid-template-columns: 1fr 1fr; }

  /* Undgå at iPhone zoomer ind i felter */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], select, textarea { font-size: 16px; }
  .auth { padding-top: calc(24px + env(safe-area-inset-top)); }
}
@media (max-width: 860px) {
  .page-head h1 { display: none; }
  .page-head > div:first-child:not(.month-nav):not(.actions) { display: none; }
  table.clean td.c-nr, table.clean td.c-main, table.clean td.c-amt { grid-row: 1; }
  table.clean td.c-meta, table.clean td.c-act { grid-row: auto; }
  .modal-foot > div:first-child .btn { padding: 7px 12px; min-height: 36px; font-size: 13px; }
}

/* ---------- Kontrakt-scanner ---------- */
.btn-sm { padding: 6px 12px; font-size: 13px; cursor: pointer; }
.scanbox { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; background: var(--brand-soft); transition: border-color .15s, background .15s; }
.scanbox.over { border-color: var(--brand); border-style: solid; }
.scanbox.arbejder { opacity: .85; pointer-events: none; }
.scan-ikon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand); color: #fff; font-size: 18px; font-weight: 700; }
.scan-tekst { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scan-tekst b { color: var(--brand); }
.scan-stat { grid-column: 1 / -1; margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface); line-height: 1.5; }
.scan-stat.ok { background: var(--ok-soft); color: var(--ink); }
.scan-stat.fejl { background: var(--warn-soft); color: var(--ink); }
.scan-mangler { margin-top: 4px; color: var(--warn); font-weight: 600; }
.scan-noter { margin: 6px 0 0; padding-left: 18px; }
.scan-gem { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-weight: 500; cursor: pointer; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: scanspin .8s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes scanspin { to { transform: rotate(360deg); } }
.field.scannet input, .field.scannet select, .field.scannet .seg { background: color-mix(in srgb, #f2c94c 22%, var(--surface)); border-color: #d9a81e; }
@media (max-width: 860px) { .scanbox { grid-template-columns: auto 1fr; } .scanbox > label.btn { grid-column: 1 / -1; justify-self: start; } }

/* ---------- Indlæs vagtplan ---------- */
.budget-knap { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.vagt-tbl tbody tr { cursor: default; }
.vagt-tbl tbody tr:hover td { background: none; }
.vagt-tbl th.num, .vagt-tbl td.num { text-align: right; }
.vagt-tbl td { vertical-align: middle; padding: 8px 10px; }
.vagt-tbl .vagt-inp { width: 84px; text-align: right; padding: 6px 8px; }
.vagt-tbl tr.sum td { font-weight: 600; border-top: 1px solid var(--line-2); background: var(--surface-2); }
.vagt-tbl tr.sum .sub { display: block; font-weight: 500; color: var(--ink-3); font-size: 12px; }
@media (max-width: 860px) { .vagt-tbl th:nth-child(2), .vagt-tbl td:nth-child(2) { display: none; } .vagt-tbl .vagt-inp { width: 70px; } }

/* ---------- K · internt ---------- */
.k-tbl tr.grp td { background: var(--surface-2); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); cursor: default; padding: 8px 12px; }
.k-tbl tr.grp:hover td { background: var(--surface-2); }
.k-tbl td.c-amt .sub { font-weight: 400; }
@media (max-width: 860px) { .k-tbl tr.grp { display: block; } .k-tbl tr.grp td { display: block; } }
.ksats-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 18px; }
.ksats { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.ksats > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ksats .sub { display: block; color: var(--ink-3); font-size: 12px; }
.ksats input { width: 110px; flex: none; text-align: right; }
.kfelt { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.kfelt .kchk { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; white-space: nowrap; min-width: 46px; }
.kfelt .kchk input { width: 18px; height: 18px; margin: 0; }
.kfelt input[type=number] { width: 110px; text-align: right; }
.kfelt.off input[type=number], .kfelt.off .seg { opacity: .4; pointer-events: none; }
.seg.seg-sm label { padding: 6px 10px; font-size: 13px; }
.ksats .kfelt input[type=number] { width: 90px; }
@media (max-width: 860px) { .ksats { flex-wrap: wrap; } }
.ksats { flex-wrap: wrap; row-gap: 6px; }
.ksats > span { flex: 1 1 150px; }
.ksats .kfelt { margin-left: auto; }
.kfelt .seg { flex: none; flex-wrap: nowrap; }
.kfelt .seg label { white-space: nowrap; }
