/* Sveisedok PWA — felt-UI. Samme designspraak som demoen, trimmet til M1-flyten. */
:root {
  --bg: #f5f7fa; --surface: #fff; --surface2: #eef2f7; --line: #dbe3ec;
  --ink: #16222e; --muted: #5b6b7a; --faint: #9aa7b4;
  --accent: #1a669e; --accent-soft: #e3eef7; --accent-text: #1a669e;
  --ok: #1f9d57; --warn: #c9821a; --danger: #c0392b; --info: #5b6b7a;
  --r: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.screen { padding: 14px 16px 90px; flex: 1; }
.svg-ic { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; }

/* topbar + nav */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.iconbtn { background: none; border: none; color: var(--ink); padding: 4px; cursor: pointer; display: inline-flex; }
.banner { background: #fff6e6; color: var(--warn); padding: 8px 14px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto; display: flex;
  background: var(--surface); border-top: 1px solid var(--line); }
.nav a { flex: 1; text-align: center; padding: 9px 0 11px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; text-decoration: none; }
.nav a.on { color: var(--accent); }
.nav a .svg-ic { width: 21px; height: 21px; }

/* typografi/utils */
.title { font-size: 22px; font-weight: 700; } .sub { color: var(--muted); }
.sm { font-size: 13px; } .muted { color: var(--muted); } .faint { color: var(--faint); }
.center { text-align: center; } .stack { display: flex; flex-direction: column; gap: 14px; }
.brand { width: 60px; height: 60px; border-radius: 16px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.brand .svg-ic { width: 30px; height: 30px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); font-size: 16px; color: var(--ink); font-family: inherit; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* knapper */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink);
  font-size: 15px; font-weight: 600; cursor: pointer; }
.btn.block { width: 100%; } .btn.sm { padding: 7px 11px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); cursor: pointer; text-decoration: none; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); }

/* kort/lister */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 13px;
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; }
.list { display: flex; flex-direction: column; gap: 8px; }
.lrow, .prow { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 12px; width: 100%; text-align: left; cursor: pointer; }
.prow.sel { border-color: var(--accent); background: var(--accent-soft); }
.lrow .l, .prow .l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lrow .t, .prow .t { font-weight: 600; display: block; } .lrow .d, .prow .d { font-size: 12px; color: var(--muted); display: block; }
.prow .st { display: flex; gap: 6px; flex-shrink: 0; }

/* segment-velger */
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { flex: 1; padding: 10px 0; background: var(--surface); border: none; border-right: 1px solid var(--line);
  font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--accent); color: #fff; }

/* status-piller */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill .svg-ic { width: 13px; height: 13px; }
.pill.ok { background: #e4f6ec; color: var(--ok); } .pill.open { background: var(--surface2); color: var(--muted); }
.pill.warn { background: #fbf0dd; color: var(--warn); } .pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.danger { background: #fbe7e4; color: var(--danger); }

/* toast */
.toast { position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .25s; max-width: 90%; text-align: center; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* pan/zoom på tegningen (felt) — #zoomstage transformeres; markørene (%-posisjonerte barn) følger med.
   aspect-ratio låser wrappens layout-fotavtrykk til tegningen ved 1x: sharpen() (app.js) vokser scenens
   LAYOUT-bredde/-høyde scale×, og uten låsen vokste kortet med og dyttet punktlista av skjermen (telefon). */
.zoomwrap { position: relative; overflow: hidden; border-radius: 8px; background: var(--surface);
  aspect-ratio: var(--teg-ar, 1.414);
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: grab; }
.zoomstage { position: relative; line-height: 0; transform-origin: 0 0; will-change: transform; }
.zoomstage.anim { transition: transform .22s ease; }
.mark { transform-origin: center center; }
.zoomreset { position: absolute; top: 8px; right: 8px; z-index: 6; display: none;
  background: rgba(20,24,30,.82); color: #fff; border: 0; border-radius: 999px; padding: 7px 13px;
  font-size: 12px; font-weight: 600; cursor: pointer; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.zoomwrap.zoomed .zoomreset { display: inline-block; }

/* #tegningpanel grupperer kontrollene under tegningen (se renderTegning). Flex-kolonne med samme
   14px-gap som .stack, så telefon-/portrett-spacingen er UENDRET; @media ≥900px overstyrer (to-panel). */
#tegningpanel { display: flex; flex-direction: column; gap: 14px; }

/* Kompakt header: tegningsnr/rev/instruks i topbaren (to-linjers venstre-kolonne ved siden av synk-chip) */
.tbar-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tsub { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tsub .tsub-help { color: var(--faint); font-size: 12px; }
.topbar:has(.tsub) { align-items: flex-start; }
/* tegningsbilde: base = full bredde, høyde følger aspekt (telefon uendret) */
.zoomimg { width: 100%; height: auto; display: block; border-radius: 8px; }
.panel-foot { display: flex; flex-direction: column; gap: 10px; }

/* ============================================================================
   TABLET / STORSKJERM / PC — responsiv layout. ALT additivt og bak min-width,
   så telefon (<600px) er bit-for-bit uendret. Bredde-basert (ikke enhets-basert):
   en PC-nettleser er ~alltid ≥900px og får derfor to-panel automatisk.
   To-panel-kontrollene er gruppert i #tegningpanel — barn-rekkefølge i
   #tegningbody (se renderTegning i app.js): 1=info-kort, 2=tegnings-kort, 3=#tegningpanel.
   ============================================================================ */
@media (min-width: 600px) {
  .app, .nav { max-width: 760px; }
  .screen { padding: 20px 24px 96px; }                  /* mer luft; behold ≥90px bunn-pad (fixed nav) */
  /* Tegninger-lista + Kø-lista flerkolonne (Kø scopet til #kvitbody så tegningens #plist forblir 1 kol) */
  #tegnliste { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px; align-content: start; }
  #tegnliste > .sm.muted { grid-column: 1 / -1; margin-bottom: 0; }   /* intro-linje full bredde */
  #kvitbody .list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px; }
  /* litt større bunn-nav på bred skjerm */
  .nav a { font-size: 12px; padding: 11px 0 13px; }
  .nav a .svg-ic { width: 23px; height: 23px; }
}

@media (min-width: 900px) {
  .app, .nav { max-width: 1100px; }
  .screen { padding: 22px 28px 96px; }

  /* === TEGNING-SKJERM: fast viewport-høyde, INGEN side-/dokumentscroll (liggende tablet/PC).
     Scopet til .scr-tegning så andre skjermer (lister) fortsatt scroller normalt. === */
  .scr-tegning { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }   /* vh-fallback før dvh */
  .app.scr-tegning { max-width: none; }                                              /* fyll bredden; to-panelet sentreres selv */
  .scr-tegning > .screen { flex: 1 1 auto; min-height: 0; overflow: hidden;
    display: flex; flex-direction: column; padding: 14px 28px; }
  .scr-tegning > .nav { position: static; width: min(100%, 1320px); margin: 0 auto; flex: 0 0 auto;
    padding-bottom: env(safe-area-inset-bottom, 0); }                       /* in-flow, sentrert tab-bar (cappet) → knapper over navet */

  /* TO-PANEL: tegning + smalt panel som ÉN sentrert flex-enhet. Tegningen fyller høyden (aspekt
     bevart); på smal skjerm krymper den så begge får plass (fyller bredden). Info-kortet er i topbaren. */
  .scr-tegning #tegningbody { display: flex; flex-direction: row; justify-content: center;
    align-items: stretch; gap: 16px; flex: 1 1 auto; min-height: 0; }
  .scr-tegning #tegningbody > .tegning-card { flex: 0 1 auto; min-width: 0; min-height: 0; overflow: hidden; display: flex; }
  .scr-tegning .zoomcell { flex: 1 1 auto; min-height: 0; min-width: 0;
    display: flex; align-items: center; justify-content: center; overflow: hidden; }   /* sentrer wrap, letterbox her */
  .scr-tegning #zoomwrap { aspect-ratio: var(--teg-ar, 1.414); max-width: 100%; max-height: 100%; margin: auto; }
  .scr-tegning #zoomstage, .scr-tegning .zoomimg { width: 100%; height: 100%; }
  .scr-tegning #tegningpanel { flex: 0 0 360px; min-height: 0;
    display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
  .scr-tegning .panel-top, .scr-tegning .panel-foot { flex: 0 0 auto; }
  .scr-tegning .panel-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 4px; }  /* kun KP-lista scroller */
  .scr-tegning .avvik-hint { display: none; }
}

@media (min-width: 1280px) {                             /* store PC-skjermer: mer plass til tegning + panel */
  .app, .nav { max-width: 1320px; }
}

/* ============================================================================
   DEMO-UTSTILLING — stiler for de demo-egne skjermene (#/dashboard, #/sak, #/skann)
   som ikke finnes i live-appen. Additivt; rører ikke kjerne-stilen over.
   Ekstra CSS-variabler (alias/soft-toner) som demo-klassene trenger:
   ============================================================================ */
:root {
  --text: var(--ink); --ok-soft: #e4f6ec; --warn-soft: #fbf0dd; --danger-soft: #fbe7e4;
  --r-lg: 14px; --pill: 999px;
}

/* kort-overskrift (sak-seksjoner) */
.card h3 { font-size: 15px; font-weight: 600; margin: 0 0 11px; display: flex; align-items: center; gap: 8px; }

/* badges (dashboard/sak status + kategori) */
.badge { font-size: 12px; padding: 3px 9px; border-radius: var(--r); display: inline-flex; align-items: center; gap: 5px; }
.badge .svg-ic { width: 13px; height: 13px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent-text); }

/* KPI-kort (dashboard) */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface2); border-radius: var(--r); padding: 13px; }
.kpi .k { font-size: 13px; color: var(--muted); } .kpi .v { font-size: 24px; font-weight: 600; margin-top: 3px; }

/* chip-knapper (sak: disposisjon + statusflyt) */
.chipbtn { padding: 10px 12px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); cursor: pointer; }
.chipbtn.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }

/* layout-hjelpere brukt av sak */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.ghost { background: none; }

/* tabell (sak: kontroll etter utbedring) */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 0 6px 7px; }
td { padding: 8px 6px; border-top: 1px solid var(--line); }

/* tidslinje (sak: behandling) */
.tl { display: flex; flex-direction: column; gap: 12px; }
.tl .e { display: flex; gap: 10px; font-size: 13px; align-items: flex-start; }

/* foto-galleri (sak) */
.fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { position: relative; height: 74px; border-radius: var(--r); overflow: hidden; background: var(--surface2); border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge { position: absolute; bottom: 4px; left: 4px; font-size: 10px; padding: 1px 6px; }
.thumb .del { position: absolute; top: 3px; right: 3px; width: 23px; height: 23px; border-radius: 50%; border: none; background: rgba(20,30,40,.6); color: #fff; display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.addfoto { height: 74px; border: 1px dashed var(--line); border-radius: var(--r); background: var(--surface2); color: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font: inherit; font-size: 11px; font-weight: 500; cursor: pointer; }

/* QR-skanner (skann) */
.scanner { position: relative; height: 150px; background: var(--surface2); border-radius: var(--r-lg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
.corner { position: absolute; width: 22px; height: 22px; border: 2px solid var(--accent); }

/* ---- 3D-modell fullskjerm-overlay (avvik: ta bilde + frihånds-merk) ---- */
.modell-overlay { position: fixed; inset: 0; z-index: 50; background: #0f1722; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0); padding-bottom: env(safe-area-inset-bottom, 0); }
.mo-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #16222e; border-bottom: 1px solid #243240; }
.mo-status { flex: 1; color: #cfe0ee; font-size: 13px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mo-btn { border: 1px solid #2c3e4f; background: #1e2c39; color: #e7eef5; border-radius: 999px; padding: 9px 16px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.mo-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.mo-btn:disabled { opacity: .5; }
.mo-stage { flex: 1; position: relative; min-height: 0; overflow: hidden; }
.mo-merke { display: flex; align-items: center; justify-content: center; touch-action: none; }
.mo-merke canvas { max-width: 100%; max-height: 100%; touch-action: none; -webkit-user-select: none; user-select: none; }

/* --- UI-paritet 2026-07-03: PIN-modal, rød login-feil, fase-chips, material --- */
.err { color: var(--danger) !important; font-weight: 600; }
.pinov { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 34, .55);
  display: flex; align-items: center; justify-content: center; padding: 18px; }
.pinov .pinbox { width: 100%; max-width: 380px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); }
.fasechips { margin-top: 8px; }
.fasechips button { font-size: 13px; padding: 7px 0; }
.matform { display: flex; }
.matform input { border: 1px solid var(--line); border-radius: var(--r); padding: 9px 10px;
  font-size: 15px; min-width: 0; }
