/* DriftIQ – brand: dyb marineblå (#0e1f45) + signalblå (#2f6bff) til 'IQ', links og fokus.
   Layout: værktøjslayout – input i venstre kolonne (sticky), resultater til højre; én kolonne under 1080 px.
   Systemskrifttyper: hurtig indlæsning og ingen tredjepartskald (GDPR). */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --ink: #121826;
  --muted: #5a6478;
  --line: #e1e5ed;
  --input: #ffffff;
  --accent: #0e1f45;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefc;
  --brand-accent: #2f6bff;
  --logo-tile: #0e1f45;
  --wordmark: #0e1f45;
  --logo-line: #ffffff;
  --logo-dot: #5c9dff;
  --hero-bg: #0e1f45;
  --hero-ink: #ffffff;
  --hero-muted: #b8c4de;
  --focus: #2f6bff;
  --phone: #3d63dd;
  --chat: #0f9b7c;
  --email: #d98226;
  --good-bg: #e6f5ee; --good: #136c45;
  --warn-bg: #fff4dc; --warn: #8a5a00;
  --bad-bg: #fdeaea;  --bad: #a3242a;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(18 24 38 / 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --topbar-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1219; --surface: #161b24; --surface-2: #1b212c; --ink: #e7ebf3; --muted: #98a2b5;
    --line: #2a3140; --input: #11151d; --accent: #9db8ff; --accent-ink: #0c1530; --accent-soft: #1f2a44;
    --brand-accent: #7aa7ff; --wordmark: #f1f4fa; --logo-tile: #2a3d73; --logo-line: #ffffff; --logo-dot: #8fb8ff;
    --hero-bg: #121a2e; --hero-ink: #e7ebf3; --hero-muted: #9aa6c2;
    --focus: #9db8ff; --phone: #809dff; --chat: #3ccfa3; --email: #f2a654;
    --good-bg: #15301f; --good: #7fdcaa; --warn-bg: #352a12; --warn: #f2c66d; --bad-bg: #3a1c20; --bad: #ff9b9f;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1219; --surface: #161b24; --surface-2: #1b212c; --ink: #e7ebf3; --muted: #98a2b5;
  --line: #2a3140; --input: #11151d; --accent: #9db8ff; --accent-ink: #0c1530; --accent-soft: #1f2a44;
  --brand-accent: #7aa7ff; --wordmark: #f1f4fa; --logo-tile: #2a3d73; --logo-line: #ffffff; --logo-dot: #8fb8ff;
  --hero-bg: #121a2e; --hero-ink: #e7ebf3; --hero-muted: #9aa6c2;
  --focus: #9db8ff; --phone: #809dff; --chat: #3ccfa3; --email: #f2a654;
  --good-bg: #15301f; --good: #7fdcaa; --warn-bg: #352a12; --warn: #f2c66d; --bad-bg: #3a1c20; --bad: #ff9b9f;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 22px; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
p { margin: 0; }
a { color: var(--brand-accent); }
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 16px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner, .foot-inner {
  max-width: 1440px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.topbar-inner { height: var(--topbar-h); display: flex; align-items: center; gap: 14px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; flex: none; }
.logo-mark { width: 28px; height: 28px; flex: none; }
.logo-mark.sm { width: 20px; height: 20px; }
.lm-tile { fill: var(--logo-tile); }
.lm-line { fill: none; stroke: var(--logo-line); stroke-width: 2.6; stroke-linecap: round; }
.lm-dot { fill: var(--logo-dot); }
.wordmark { font-size: 20px; font-weight: 750; letter-spacing: -0.035em; color: var(--wordmark); line-height: 1; }
.wordmark span { color: var(--brand-accent); }
.product { font-size: 14px; color: var(--muted); padding-left: 14px; border-left: 1px solid var(--line); white-space: nowrap; }
.nav { display: flex; gap: 18px; font-size: 14px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--ink); }

/* Sticky resultatlinje – kun på smalle skærme, hvor resultater ligger under input */
.resultbar {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); z-index: 15;
  display: flex; gap: 20px; justify-content: center; flex-wrap: wrap;
  padding: 8px 16px; font-size: 14px; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.resultbar b { color: var(--ink); font-size: 16px; }
.resultbar span:first-child b { color: var(--accent); }

/* ---------- Hero ---------- */
.hero { background: var(--hero-bg); color: var(--hero-ink); }
.hero-inner {
  max-width: 1440px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 26px 28px;
  display: grid; gap: 6px;
}
.eyebrow { font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--logo-dot); }
.hero h1 { font-size: clamp(22px, 3.2vw, 32px); letter-spacing: -0.025em; max-width: 42ch; }
.hero-lede { color: var(--hero-muted); font-size: 15px; max-width: 70ch; }
.inputs-title { font-size: 13px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ---------- Layout ---------- */
.layout {
  max-width: 1440px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 32px;
  display: grid; gap: 20px;
}
.inputs, .results { display: grid; gap: 14px; align-content: start; min-width: 0; }
.inputs-head { display: grid; gap: 4px; padding: 0 2px 4px; }
.lede { color: var(--muted); font-size: 14px; }

@media (min-width: 720px) and (max-width: 1079.98px) {
  .inputs { grid-template-columns: 1fr 1fr; }
  .inputs-head { grid-column: 1 / -1; }
}
@media (min-width: 1080px) {
  .layout { grid-template-columns: minmax(340px, 380px) minmax(0, 1fr); align-items: start; }
  .inputs {
    position: sticky; top: calc(var(--topbar-h) + 20px);
    max-height: calc(100vh - var(--topbar-h) - 40px); overflow-y: auto;
    padding-right: 6px; margin-right: -6px; scrollbar-width: thin;
  }
  .resultbar { display: none; }
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; min-width: 0; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; margin-bottom: 12px; flex-wrap: wrap; }
.note { color: var(--muted); font-size: 13px; margin-bottom: 12px; max-width: 80ch; }

/* ---------- Felter ---------- */
.fields { display: grid; gap: 12px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.span-2 { grid-column: 1 / -1; }
label { display: block; font-size: 13px; color: var(--muted); min-width: 0; }
label > input, label > select, label > .suffix { margin-top: 4px; }
label > input, label > select { display: block; }
input[type="number"], input[type="text"], select {
  font: inherit; font-size: 16px; /* 16px undgår auto-zoom på iOS */
  color: var(--ink); background: var(--input);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%; min-width: 0; height: 40px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s;
}
input:hover, select:hover { border-color: color-mix(in srgb, var(--line), var(--ink) 25%); }
input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
select.compact { width: auto; height: 34px; padding: 4px 8px; font-size: 14px; }
.suffix { position: relative; display: block; }
.suffix input { padding-right: 52px; }
.suffix em { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: 13px; pointer-events: none; }

.hint {
  display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font: 700 11px/1 var(--font); cursor: help; vertical-align: 1px; margin-left: 2px;
}
.tip {
  position: absolute; z-index: 40; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--surface); font-size: 13px; line-height: 1.45;
  padding: 8px 10px; border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; user-select: none; }
.switch input { appearance: none; margin: 0; width: 36px; height: 20px; border-radius: 20px; background: var(--line); position: relative; cursor: pointer; transition: background 0.15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: transform 0.15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.channel.off .fields, .channel.off .subpanel { opacity: 0.4; pointer-events: none; }
.subpanel { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); display: grid; gap: 10px; }
.subpanel .switch { font-size: 13px; }
label.off { opacity: 0.5; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dot.phone { background: var(--phone); }
.dot.chat { background: var(--chat); }
.dot.email { background: var(--email); }

/* ---------- Knapper ---------- */
.btn, .btn-link { font: inherit; font-size: 14px; cursor: pointer; border-radius: 8px; white-space: nowrap; }
.btn { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); padding: 7px 12px; font-weight: 550; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn-link { background: none; border: 0; color: var(--accent); padding: 4px 6px; }
.btn-link:hover { text-decoration: underline; }
.btn-link.sm { font-size: 12px; padding: 2px 4px; }
.btn-link.danger { color: var(--bad); }
.btn-row, .toolbar { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- KPI'er ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 899.98px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; background: var(--surface); min-width: 0; }
.kpi.accent { background: var(--accent-soft); border-color: transparent; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.kpi-value { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.kpi.accent .kpi-value { color: var(--accent); }
.kpi-sub { font-size: 12.5px; color: var(--muted); }

.explain { margin-top: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.explain summary { cursor: pointer; padding: 9px 12px; font-size: 14px; font-weight: 550; color: var(--accent); }
.explain > div { padding: 0 12px 12px; display: grid; gap: 8px; font-size: 13.5px; max-width: 95ch; }

.warnings { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.warnings:empty { display: none; }
.warnings li { font-size: 13.5px; padding: 8px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: baseline; }
.warnings li.info { background: var(--surface-2); border: 1px solid var(--line); }
.warnings li.warn { background: var(--warn-bg); color: var(--warn); }
.wtag { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; flex: none; opacity: 0.8; min-width: 62px; }

.channel-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin-top: 12px; }
.ch-card { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; position: relative; overflow: hidden; }
.ch-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--line); }
.ch-card.phone::before { background: var(--phone); }
.ch-card.chat::before { background: var(--chat); }
.ch-card.email::before { background: var(--email); }
.ch-title { display: flex; align-items: center; gap: 8px; font-weight: 650; flex-wrap: wrap; }
.ch-badges { margin-left: auto; display: inline-flex; gap: 4px; }
.ch-big { margin: 6px 0 8px; font-size: 14px; color: var(--muted); }
.ch-big b { font-size: 24px; color: var(--ink); font-variant-numeric: tabular-nums; }
.ch-card dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin: 0; font-size: 13px; }
.ch-card dt { color: var(--muted); }
.ch-card dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 20px; white-space: nowrap; letter-spacing: 0.01em; }
.badge.queue { background: var(--accent-soft); color: var(--accent); }
.badge.work { background: var(--good-bg); color: var(--good); }
.badge.est { background: var(--warn-bg); color: var(--warn); }
.pill { font-size: 11px; font-weight: 600; background: var(--good); color: var(--surface); padding: 1px 6px; border-radius: 10px; margin-left: 4px; }

/* ---------- Diagram ---------- */
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart { width: 100%; }
.svg { width: 100%; height: auto; display: block; overflow: visible; }
.svg .grid { stroke: var(--line); stroke-width: 1; }
.svg .ax { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.svg .bar.phone { fill: var(--phone); }
.svg .bar.chat { fill: var(--chat); }
.svg .bar.email { fill: var(--email); }
.svg .hit { fill: transparent; }
.svg .hit:hover { fill: var(--ink); fill-opacity: 0.06; }

/* ---------- Tabeller ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 9px; }
.table-wrap.tall { max-height: 560px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-weight: 600; color: var(--muted); font-size: 12px; position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
tbody th { font-weight: 500; }
th.g-phone { box-shadow: inset 0 -2px var(--phone); }
th.g-chat { box-shadow: inset 0 -2px var(--chat); }
th.g-email { box-shadow: inset 0 -2px var(--email); }
td.b { font-weight: 650; }
td.neg { color: var(--bad); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tr.peak th { box-shadow: inset 3px 0 var(--accent); }
tfoot th, tfoot td { font-weight: 650; border-top: 2px solid var(--line); border-bottom: 0; background: var(--surface-2); position: sticky; bottom: 0; }
input.w { width: 76px; height: 30px; padding: 3px 6px; font-size: 13px; text-align: right; display: inline-block; }
#scenario tr.rec { background: var(--good-bg); }
#scenario tr.bad { background: var(--bad-bg); }
#scenario tr.bad td { color: var(--bad); }
#scenario tr.warn { background: var(--warn-bg); }

.save-form { display: flex; gap: 6px; flex-wrap: wrap; }
.save-form input { width: 220px; height: 36px; font-size: 14px; }
#saveMsg { color: var(--good); font-weight: 600; }
.compare th.cur { color: var(--accent); }
.compare thead th { vertical-align: top; text-align: right; }
.compare thead th:first-child { text-align: left; }
.col-actions { display: flex; justify-content: flex-end; gap: 2px; margin-top: 2px; }
.compare tr.inp th, .compare tr.inp td { color: var(--muted); font-size: 12px; }
.compare tr.inp:last-of-type th, .compare tr.inp:last-of-type td { border-bottom: 2px solid var(--line); }
.delta { font-size: 11.5px; font-weight: 650; margin-left: 4px; }
.delta.up { color: var(--bad); }
.delta.down { color: var(--good); }

/* ---------- Metode ---------- */
.method h2 { font-size: 17px; margin-bottom: 6px; }
.model-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 18px; }
.model-types > div { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; display: grid; gap: 6px; align-content: start; }
.model-types p { font-size: 13px; color: var(--muted); }
.model-types .badge { justify-self: start; }
.method dl { margin: 0; display: grid; grid-template-columns: minmax(160px, max-content) minmax(0, 1fr); gap: 16px 24px; }
.method dt { font-weight: 650; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.method dd { margin: 0; display: grid; gap: 6px; font-size: 14px; max-width: 78ch; }
.method .limits { color: var(--muted); font-size: 13px; }
.method code { white-space: normal; }
@media (max-width: 640px) {
  .method dl { grid-template-columns: 1fr; gap: 4px; }
  .method dd { margin-bottom: 14px; }
  .kpi-value { font-size: 26px; }
  .cols-2 { grid-template-columns: 1fr 1fr; }
  .save-form, .save-form input { width: 100%; }
  .save-form input { flex: 1; }
  .nav { gap: 12px; }
}

.foot { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12.5px; padding-block: 20px calc(24px + env(safe-area-inset-bottom, 0px)); }
.foot-inner { display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; align-items: center; }
.foot-brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13.5px; }
.foot-note { grid-column: 1 / -1; }
@media (max-width: 640px) { .foot-inner { grid-template-columns: 1fr; } .product { display: none; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Udskrift / PDF ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f6f7f9; --shadow: none; }
  body { font-size: 11pt; }
  .topbar, .resultbar, .toolbar, .foot-links, .save-form, .btn-row, .hint, .skip, .tip, .col-actions, #scenarioChannel, .foot .nav { display: none !important; }
  .layout { display: block; padding: 0; }
  .hero { background: none; color: #000; border-bottom: 2px solid #0e1f45; margin-bottom: 12px; }
  .hero-inner { padding: 0 0 8px; }
  .hero-lede { color: #444; }
  .eyebrow { color: #2f6bff; }
  .inputs { position: static; max-height: none; overflow: visible; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .inputs-head { grid-column: 1 / -1; }
  .panel { break-inside: avoid; border-color: #ccc; padding: 10px; }
  .results { display: block; }
  .results > .panel { margin-bottom: 10px; }
  .table-wrap, .table-wrap.tall { max-height: none; overflow: visible; }
  thead th, tfoot th, tfoot td { position: static; }
  input { border: 0 !important; padding: 0 !important; height: auto !important; background: none !important; }
  .switch input { display: none; }
  .channel.off { display: none; }
  .method { break-before: page; }
}

/* ---------- Tekstsider (privatliv, 404) ---------- */
.prose { max-width: 760px; margin: 0 auto; display: grid; gap: 10px; padding: 24px; }
.prose h1 { font-size: 26px; margin-bottom: 4px; }
.prose h2 { font-size: 16px; margin-top: 10px; }
.prose p { max-width: 68ch; }
.prose .btn { display: inline-block; text-decoration: none; margin-top: 8px; }
