:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --flate: #ffffff;
  --flate-2: #f1f1ee;
  --kant: #e4e4df;
  --kant-svak: #ededea;
  --kant-sterk: #d0d0ca;
  --tekst: #0b0b0b;
  --tekst-2: #52514e;
  --aksent: #2a78d6;
  --aksent-trykk: #1f66bd;
  --aksent-svak: #e6f0fc;
  --aksent-tekst: #1c5cab;
  --god: #0f6b36;
  --god-svak: #e3f4ea;
  --varsel: #8a5800;
  --varsel-svak: #fdf2dc;
  --varsel-tekst: #5c3b00;
  --kritisk: #b3322a;
  --kritisk-svak: #fbe7e5;
  --noytral-svak: #ededea;
  --valgt: #f4f8fd;
  --skygge: 0 1px 2px rgba(0,0,0,.05), 0 6px 24px rgba(0,0,0,.06);
  --r: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --topp: env(safe-area-inset-top, 0px);
  --bunn: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110; --flate: #1a1a19; --flate-2: #222220; --kant: #2e2e2b; --kant-svak: #262624; --kant-sterk: #3d3d39;
    --tekst: #ffffff; --tekst-2: #b9b8ae;
    --aksent: #3987e5; --aksent-trykk: #2f78d2; --aksent-svak: #1a2b42; --aksent-tekst: #86b6ef;
    --god: #6fd398; --god-svak: #15301f; --varsel: #e8b450; --varsel-svak: #33280f; --varsel-tekst: #f1d39a;
    --kritisk: #f08a80; --kritisk-svak: #3a1a17; --noytral-svak: #2b2b29; --valgt: #16212e;
    --skygge: 0 1px 2px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--tekst); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--aksent-tekst); }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
[hidden] { display: none !important; }
.tall { font-variant-numeric: tabular-nums; }
.svak { color: var(--tekst-2); }
.liten { font-size: 13px; }

/* ---------- knapper ---------- */
.knapp { height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--kant-sterk); background: var(--flate);
  font-size: 15px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; color: var(--tekst); }
.knapp:active { background: var(--flate-2); }
.knapp.hoved { background: var(--aksent); border-color: var(--aksent); color: #fff; font-weight: 600; }
.knapp.hoved:active { background: var(--aksent-trykk); }
.knapp.stor { height: 64px; border-radius: 14px; font-size: 17px; width: 100%; }
.knapp.middels { height: 52px; border-radius: 12px; width: 100%; }
.knapp.liten { height: 34px; padding: 0 12px; border-radius: 8px; font-size: 14px; }
.knapp.fare { color: var(--kritisk); }
.knapp:disabled { opacity: .5; cursor: default; }
.knapp svg { flex-shrink: 0; }
.ikonknapp { width: 44px; height: 44px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--tekst-2); cursor: pointer; border-radius: 10px; }
.lenke { background: none; border: 0; padding: 0; color: var(--aksent-tekst); cursor: pointer; font-size: 14px; text-decoration: none; }

.merke { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; white-space: nowrap; background: var(--noytral-svak); color: var(--tekst-2); }
.merke.tolker, .merke.godkjent { background: var(--aksent-svak); color: var(--aksent-tekst); }
.merke.sjekk, .merke.feil { background: var(--varsel-svak); color: var(--varsel); }
.merke.klar { background: var(--god-svak); color: var(--god); }

/* ---------- innlogging ---------- */
.inngang { position: fixed; inset: 0; background: #111110; color: #fff; overflow: hidden; }
.inngang .terreng { position: absolute; left: 0; right: 0; top: 0; height: 72vh;
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent); mask-image: linear-gradient(to bottom, #000 60%, transparent); }
.inngang .terreng svg { width: 100%; height: 100%; display: block; }
.inngang .kurver { fill: none; stroke: #34342f; stroke-width: 1; vector-effect: non-scaling-stroke; }
.inngang .tun-kurve { fill: none; stroke: #3987e5; stroke-width: 1.5; stroke-opacity: .9; vector-effect: non-scaling-stroke; }
.inngang .tun-ring { fill: none; stroke: #3987e5; stroke-width: 1.5; stroke-opacity: .45; }
.inngang .tun { fill: #3987e5; }
.inngang .innhold { position: absolute; left: 24px; right: 24px; bottom: calc(40px + var(--bunn)); display: flex; flex-direction: column; gap: 28px; max-width: 420px; margin: 0 auto; }
.inngang .dato { font-size: 13px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: #a3a29b; }
.inngang .navn { font-size: 44px; font-weight: 700; letter-spacing: -0.035em; line-height: 1; margin-top: 8px; }
.inngang .knapp.hoved { height: 56px; border-radius: 14px; font-size: 16px; background: #3987e5; border-color: #3987e5; }
.inngang .fot { font-size: 13px; color: #a3a29b; text-align: center; }
.inngang .feil { font-size: 14px; color: #f1b3ad; text-align: center; }
.inngang input { height: 48px; border-radius: 12px; border: 1px solid #3d3d39; background: #1a1a19; padding: 0 14px; color: #fff; }
@media (min-width: 700px) {
  .inngang .terreng { left: 50%; width: 720px; margin-left: -360px; height: 78vh; }
  .inngang .innhold { left: 50%; width: 380px; margin-left: -190px; right: auto; }
}

/* ---------- ramme ---------- */
.topp { position: sticky; top: 0; z-index: 5; background: var(--flate); border-bottom: 1px solid var(--kant); padding-top: var(--topp); }
.topp .rad { max-width: 1360px; margin: 0 auto; padding: 0 16px 0 20px; min-height: 56px; display: flex; align-items: center; gap: 24px; }
.merkenavn { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--tekst); text-decoration: none; }
.merkenavn span { font-weight: 500; color: var(--tekst-2); }
.hovedmeny { display: flex; gap: 4px; flex-grow: 1; }
.hovedmeny a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--tekst-2); font-size: 14px; }
.hovedmeny a[aria-current="page"] { color: var(--tekst); background: var(--flate-2); font-weight: 600; }
.macstatus { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--tekst-2); }
.prikk { width: 8px; height: 8px; border-radius: 999px; background: var(--god); flex-shrink: 0; }
.prikk.gammel { background: var(--varsel); }
.menyknapp { display: none; margin-left: auto; }
.mobilmeny { display: none; }

.side { max-width: 1360px; margin: 0 auto; padding: 24px 24px calc(40px + var(--bunn)); display: flex; flex-direction: column; gap: 18px; }

@media (max-width: 899px) {
  body { background: var(--bg); }
  .topp { background: var(--bg); border-bottom: 0; }
  .topp .rad { padding: 0 8px 0 20px; }
  .hovedmeny, .topp .macstatus { display: none; }
  .menyknapp { display: inline-flex; }
  .mobilmeny { display: flex; flex-direction: column; padding: 4px 12px 12px; gap: 2px; }
  .mobilmeny a, .mobilmeny button { padding: 12px; border-radius: 10px; text-decoration: none; color: var(--tekst); background: none; border: 0; text-align: left; font-size: 16px; cursor: pointer; }
  .mobilmeny a[aria-current="page"] { background: var(--flate-2); font-weight: 600; }
  .side { padding: 8px 20px calc(24px + var(--bunn)); gap: 20px; }
}

/* ---------- fangst ---------- */
.fangst { max-width: 520px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.kort { background: var(--flate); border: 1px solid var(--kant); border-radius: var(--r); }
.naa { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.etikett { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--tekst-2); }
.naa .tittel { font-weight: 600; }
.handlinger { display: flex; flex-direction: column; gap: 10px; }
.to { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.seksjon-topp { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 8px; }
.seksjon-topp h2 { font-size: 13px; font-weight: 600; color: var(--tekst-2); }
.liste { display: flex; flex-direction: column; }
.liste .rad { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--kant-svak); text-decoration: none; color: inherit; }
.liste .rad:last-child { border-bottom: 0; }
.liste .rad .hoved { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.liste .rad .hoved > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste .rad .hoved > :first-child { font-weight: 500; }
.liste .rad .hoyre { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tom { padding: 24px 16px; text-align: center; color: var(--tekst-2); font-size: 14px; }
.fotstatus { font-size: 13px; color: var(--tekst-2); display: flex; align-items: center; gap: 8px; }

/* ---------- skann ---------- */
.ark { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.ark .innhold { background: var(--flate); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 20px 20px calc(20px + var(--bunn)); display: flex; flex-direction: column; gap: 16px; }
.sider { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.sider img { height: 120px; border-radius: 8px; border: 1px solid var(--kant); flex-shrink: 0; }

/* ---------- gjennomgang ---------- */
.gj-topp { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.gj-topp h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.filtre { display: flex; flex-wrap: wrap; gap: 6px; }
.filtre button { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--kant-sterk); background: var(--flate); font-size: 13px; cursor: pointer; }
.filtre button[aria-pressed="true"] { background: var(--tekst); border-color: var(--tekst); color: var(--bg); font-weight: 500; }
.arbeidsflate { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.tabell { flex: 999 1 600px; min-width: 0; overflow-x: auto; }
.tabell .indre { min-width: 720px; }
.trad { display: grid; grid-template-columns: 112px 84px minmax(0, 1.3fr) 96px minmax(0, 1.4fr); gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--kant-svak); align-items: start; text-decoration: none; color: inherit; font-size: 14px; }
.trad.hode { font-size: 12px; font-weight: 600; color: var(--tekst-2); border-bottom-color: var(--kant); padding: 10px 16px; }
.trad:last-child { border-bottom: 0; }
.trad[aria-current="true"] { background: var(--valgt); box-shadow: inset 3px 0 0 var(--aksent); }
.trad .to-linjer { display: flex; flex-direction: column; min-width: 0; }
.trad .to-linjer > :first-child { font-weight: 500; }
.trad .to-linjer > :last-child { font-size: 12px; color: var(--tekst-2); }
.trad .h { text-align: right; font-weight: 500; }
.panel { flex: 1 1 360px; max-width: 460px; position: sticky; top: 72px; }
@media (max-width: 899px) {
  .panel { position: static; max-width: none; }
}

/* ---------- detalj ---------- */
.detalj { display: flex; flex-direction: column; }
.detalj .blokk { padding: 16px; border-bottom: 1px solid var(--kant-svak); display: flex; flex-direction: column; gap: 12px; }
.detalj .blokk:last-child { border-bottom: 0; }
.hode-kvittering { display: flex; gap: 14px; align-items: flex-start; }
.miniatyr { width: 96px; height: 132px; flex-shrink: 0; border-radius: 6px; border: 1px solid var(--kant); background: var(--flate-2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--tekst-2); text-align: center; padding: 6px; cursor: zoom-in; overflow: hidden; }
.miniatyr img { width: 100%; height: 100%; object-fit: cover; }
.belop { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.grunner { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.grunner div { display: flex; gap: 8px; align-items: flex-start; }
.grunner svg { flex-shrink: 0; margin-top: 3px; color: var(--god); }
.advarsel { background: var(--varsel-svak); color: var(--varsel-tekst); border-radius: 10px; padding: 10px 12px; font-size: 14px; display: flex; flex-direction: column; gap: 10px; }
.feilboks { background: var(--kritisk-svak); color: var(--kritisk); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.segment { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: rgba(0,0,0,.06); border-radius: 10px; padding: 3px; }
.segment button { height: 38px; border: 0; border-radius: 8px; background: transparent; font-size: 14px; color: inherit; cursor: pointer; }
.segment button[aria-pressed="true"] { background: var(--flate); color: var(--tekst); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.skjema { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.felt { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.felt.hel { grid-column: 1 / -1; }
.felt > span { font-size: 12px; font-weight: 600; color: var(--tekst-2); }
.felt input, .felt select { height: 40px; border: 1px solid var(--kant-sterk); border-radius: 9px; padding: 0 10px; background: var(--flate); font-size: 15px; width: 100%; min-width: 0; }
.felt input:focus, .felt select:focus { outline: 2px solid var(--aksent); outline-offset: -1px; border-color: transparent; }
.knapperad { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 16px; }
.knapperad .knapp.hoved { min-width: 140px; }
@media (max-width: 899px) {
  .knapperad { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--kant); padding: 12px 0 calc(12px + var(--bunn)); }
  .knapperad .knapp { height: 52px; }
  .knapperad .knapp.hoved { flex-grow: 1; }
  .detalj.kort { border: 0; background: transparent; }
  .detalj .blokk { padding: 16px 0; }
}
.tilbake { display: inline-flex; align-items: center; gap: 4px; height: 44px; text-decoration: none; font-size: 16px; margin-left: -4px; }
.forhandsvisning { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--topp)) 16px calc(16px + var(--bunn)); cursor: zoom-out; }
.forhandsvisning img, .forhandsvisning iframe { max-width: 100%; max-height: 100%; border-radius: 6px; background: #fff; }
.forhandsvisning iframe { width: min(900px, 100%); height: 100%; border: 0; }

/* ---------- enheter ---------- */
.smal { max-width: 640px; width: 100%; }
.lenkeboks { font-family: var(--mono); font-size: 13px; word-break: break-all; background: var(--flate-2); border-radius: 8px; padding: 10px 12px; }

#melding { position: fixed; left: 50%; bottom: calc(24px + var(--bunn)); transform: translateX(-50%); z-index: 40; background: var(--tekst); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); }
#melding.vis { opacity: 1; }
