/* Wican Tools — KUN app-unik CSS, bygd på Wican «Nordisk»-tokens fra master.
   Delt chrome (topbar/brand/account/login/btn/alert/card/foot/switch/badge-tokens)
   bor i master (assets/nordisk.css), som lastes FØR denne fila. Rediger ALDRI
   delt chrome her — endre i master, bump .design-version, kjør scripts/sync-design.sh.

   Her: kun tool-unik chrome (sidebar-moduler, faner, ikonknapp, tidsplan,
   verktøyhode, totaler, XML-popup, skjemahjelp, debug-logg, statusmerker). */

:root {
  /* Eneste lokale token: «idle/nøytral» statusfarge (master har ok/warn/err). */
  --idle-fg: #787873;
}

/* ── layout: sidemeny + innhold (sidemeny-unntaket — mange moduler) ─────────── */
.layout { display: grid; grid-template-columns: 244px 1fr; min-height: calc(100vh - var(--nav-h, 60px)); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; }
.sidebar-label { color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .8px; margin: 4px 10px 10px; }
.sidebar nav a {
  display: block; padding: 9px 12px; border-radius: var(--radius, 0); color: var(--text);
  text-decoration: none; font-weight: 500; margin-bottom: 4px; cursor: pointer;
  border: 1px solid transparent;
}
.sidebar nav a:hover { background: var(--surface-2); }
.sidebar nav a.active { background: var(--surface-2); border-color: var(--border); }
.sidebar nav a small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }

.main { padding: 28px 32px; width: 100%; max-width: none; }

h1 { font-size: 21px; margin: 0 0 4px; font-weight: 600; color: var(--heading); }
.lead { color: var(--muted); margin: 0 0 20px; max-width: 70ch; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); margin: 24px 0 12px; font-weight: 600; }

/* ── faner ──────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tabs button {
  background: none; border: 0; color: var(--muted); padding: 11px 14px; cursor: pointer;
  font: inherit; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand-strong); border-bottom-color: var(--brand-strong); }

/* ── skjema-tillegg (master styrer input/label/.check; her kun layout-hjelpere) ── */
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 150px; }
.right { text-align: right; }
.spacer { height: 10px; }

/* ── statusmerker: flate «tekst + farget prikk» (panel.js skriver .statusmark) ──
   App-unik variant av master sin .badge (master har boksede piller; her flat
   tekst+prikk for tett tabellbruk). Variant → semantisk farge fra master-tokens. */
.statusmark.statusmark--text {
  min-width: 0; padding: 0; background: transparent; border: 0;
  font-weight: 500; font-size: 12px; letter-spacing: .005em;
  display: inline-flex; align-items: center; gap: 6px; vertical-align: middle;
}
.statusmark.statusmark--text::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto;
}
.statusmark.statusmark--success     { color: var(--ok-fg); }
.statusmark.statusmark--warning     { color: var(--warn-fg); }
.statusmark.statusmark--error       { color: var(--err-fg); }
.statusmark.statusmark--information { color: var(--brand); }
.statusmark.statusmark--muted,
.statusmark.statusmark--neutral     { color: var(--idle-fg); }

/* ── ikonknapp i toppbaren (oppdater-buffer) ─────────────────────────────────── */
.iconbtn {
  height: 30px; width: 30px; border-radius: var(--radius, 0);
  border: 1px solid var(--border); background: var(--surface); color: var(--brand);
  cursor: pointer; font-size: 16px; line-height: 1; display: inline-flex;
  align-items: center; justify-content: center; padding: 0; transition: background .15s, border-color .15s;
}
.iconbtn:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }
.iconbtn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.iconbtn.spin { animation: iconspin .8s linear infinite; }
@keyframes iconspin { to { transform: rotate(360deg); } }

/* ── tabeller (app-tetthet; master har basisstil) ───────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable::after { content: '↕'; opacity: .3; margin-left: 5px; font-size: 10px; }
th.sortable.sort-asc::after { content: '↑'; opacity: 1; color: var(--brand-strong); }
th.sortable.sort-desc::after { content: '↓'; opacity: 1; color: var(--brand-strong); }

/* ── kjøretotaler ─────────────────────────────────────────────────────────────── */
.totals { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 4px; }
.totals .stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius, 0);
  padding: 8px 14px; min-width: 88px; }
.totals .stat b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; color: var(--heading); }
.totals .stat span { color: var(--muted); font-size: 11px; }

details { border: 1px solid var(--border); border-radius: var(--radius, 0); margin-bottom: 8px; background: var(--surface); }
details summary { padding: 11px 14px; cursor: pointer; font-weight: 500; }
details[open] summary { border-bottom: 1px solid var(--border); }
details .inner { padding: 4px 6px 10px; overflow-x: auto; }

/* ── status-prikk i sidemeny-nav ─────────────────────────────────────────────── */
.navdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 9px; vertical-align: middle; }
.navdot.on { background: var(--ok); }
.navdot.off { background: var(--bad); }

/* ── verktøyhode med av/på-bryter + tidsplan ─────────────────────────────────── */
.toolhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; }
.toolhead > div:first-child { flex: 1 1 auto; min-width: 0; }
.toolhead .lead { max-width: none; }
.toolctl { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.sched { display: flex; align-items: center; gap: 8px; }
.sched label { margin: 0; font-size: 12px; color: var(--muted); }
.sched input[type=time] { width: auto; padding: 6px 9px; }
.sched .muted { font-size: 11px; }

.empty, .loading { color: var(--muted); padding: 18px 4px; }

/* ── skjemahjelp (f.eks. valuta-import) — strukturert, skannbar ──────────────── */
.fieldhelp dl {
  margin: 10px 0; display: grid; grid-template-columns: max-content 1fr;
  gap: 7px 16px; align-items: start;
}
.fieldhelp dt { font-weight: 600; color: var(--text); }
.fieldhelp dd { margin: 0; }
.fieldhelp ul { margin: 0; padding-left: 16px; }
.fieldhelp li { margin: 2px 0; }
.fieldhelp p { margin: 0 0 8px; }
.fieldhelp p:first-child { margin-top: 0; }
.fieldhelp p:last-child { margin-bottom: 0; }
.fieldhelp b { color: var(--text); }
@media (max-width: 640px) { .fieldhelp dl { grid-template-columns: 1fr; gap: 2px 0; } .fieldhelp dd { margin: 0 0 8px; } }

/* ── debug-logg (spørringer/svar fra API-et) ─────────────────────────────────── */
pre.log {
  margin: 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius, 0); font-family: var(--mono);
  font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto; color: var(--text);
}

/* ── feilmeldingsfeed på forsiden ────────────────────────────────────────────── */
.erritem { padding: 12px 0; border-bottom: 1px solid var(--border); }
.erritem:last-child { border-bottom: 0; padding-bottom: 0; }
.erritem:first-child { padding-top: 0; }
.errhead { margin-bottom: 7px; }
.tool-row td:first-child { font-weight: 500; }

/* ── klikkbar dok.nr-lenke som åpner XML-popupen ─────────────────────────────── */
a.xml-link { color: var(--brand-strong); text-decoration: none; border-bottom: 1px dashed currentColor; cursor: pointer; }
a.xml-link:hover { color: var(--brand); }

/* ── XML-popup ───────────────────────────────────────────────────────────────── */
.xml-overlay {
  position: fixed; inset: 0; z-index: 50; display: none;
  background: rgba(16,32,43,.45); align-items: center; justify-content: center; padding: 24px;
}
.xml-overlay.open { display: flex; }
.xml-modal {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius, 0);
  box-shadow: 0 12px 40px rgba(16,32,43,.28); width: min(900px, 100%); max-height: 88vh;
  display: flex; flex-direction: column;
}
.xml-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.xml-modal-head h3 { margin: 0; font-size: 15px; color: var(--heading); word-break: break-all; }
.xml-modal-body {
  margin: 0; padding: 14px 18px; overflow: auto; flex: 1;
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; color: var(--text);
}
