/* ============================================================================
   Kveo — arbeidsflatene (admin, kundeportal, innlogging, /agent)
   ----------------------------------------------------------------------------
   Krev public/css/system.css (lastast FØR denne fila). Ingen eigne
   fargeverdiar her — berre alias til systemtokena og komponentar.

   Fila er skriven på nytt (2026-11) i staden for å leggje endå eit lag
   oppå dei tre som overstyrte kvarandre med !important. Rekkjefølgja er:
     1. alias + element-standardar   5. tabellar, merke, varsel
     2. skal (sidemeny, toppline)    6. tråd, faner, detaljhovud
     3. sidehovud + seksjonar        7. dashboard, innstillingar
     4. knappar + skjema             8. portal, innlogging, agent, AI Ops
   Element-standardane brukar :where(), så éi klasse alltid vinn over dei.
   ========================================================================= */

/* ---------------------------------------------------------------- 1. ALIAS */

:root {
  /* Brukt av inline style="" i dei streng-bygde viewa — ikkje fjern. */
  --panel:       var(--surface);
  --panel-2:     var(--surface-2);
  --line-soft:   var(--line);
  --blue:        var(--accent);
  --blue-2:      var(--accent-hover);
  --blue-soft:   var(--accent-soft);
  --green:       var(--ok);      --green-soft: var(--ok-soft);
  --amber:       var(--warn);    --amber-soft: var(--warn-soft);
  --red:         var(--danger);  --red-soft:   var(--danger-soft);
  --border:      var(--line);
  --border-soft: var(--line);
  --text:        var(--ink);
  --text-muted:  var(--muted);
  --text-subtle: var(--faint);
  --bg:          var(--surface-2);
  --radius:      var(--r-xs);
  --radius-lg:   12px;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 60px;
  --page-max: 1240px;
  --card-r: 12px;
  --ctl-r: 8px;
}

.app-body,
.auth-body,
.agent-body {
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.5;
}

/* Element-standardar for streng-bygde view. Låg spesifisitet med vilje. */
:where(.app-body, .auth-body, .agent-body) :where(h1) { font-size: var(--t-2xl); font-weight: 650; line-height: 1.15; letter-spacing: -.02em; color: var(--ink); }
:where(.app-body, .auth-body, .agent-body) :where(h2) { font-size: var(--t-lg); font-weight: 650; line-height: 1.3; letter-spacing: -.01em; color: var(--ink); }
:where(.app-body, .auth-body, .agent-body) :where(h3) { font-size: var(--t-base); font-weight: 650; line-height: 1.35; color: var(--ink); }
:where(.app-body, .auth-body, .agent-body) :where(h4) { font-size: var(--t-sm); font-weight: 650; color: var(--ink); }
:where(.app-body, .agent-body) :where(p) { color: var(--ink-2); }
:where(.app-body, .auth-body, .agent-body) :where(a:not([class])) { color: var(--accent-ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
:where(.app-body, .auth-body, .agent-body) :where(a:not([class])):hover { text-decoration-color: currentColor; }
:where(.app-body, .auth-body, .agent-body) :where(hr) { border: 0; border-top: 1px solid var(--line); margin: var(--s-6) 0; }
:where(.app-body, .auth-body, .agent-body) :where(ul.list, ol) { padding-left: 1.25rem; }
:where(.app-body, .auth-body, .agent-body) :where(strong, b) { font-weight: 650; }

:where(.app-body, .auth-body, .agent-body) :where(label) {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 600;
}

:where(.app-body, .auth-body, .agent-body) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]), select, textarea),
.control {
  display: block;
  width: 100%;
  min-height: var(--control-h);
  padding: 8px 12px;
  border: 1px solid var(--line-strong);   /* Contrast verified by test/design-system.test.js. */
  border-radius: var(--ctl-r);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-base);               /* 16px hindrar zoom på iOS */
  line-height: 1.4;
  color-scheme: light dark;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
:where(.app-body, .auth-body, .agent-body) :where(textarea) { min-height: 112px; resize: vertical; line-height: var(--lh-body); }
:where(.app-body, .auth-body, .agent-body) :where(select) { padding-right: 32px; }
:where(.app-body, .auth-body, .agent-body) :where(input, select, textarea):hover { border-color: var(--ink-2); }
:where(.app-body, .auth-body, .agent-body) :where(input, select, textarea):focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
:where(.app-body, .auth-body, .agent-body) :where(input, select, textarea)::placeholder { color: var(--faint); }
:where(.app-body, .auth-body, .agent-body) :where(input[type="checkbox"], input[type="radio"]) { width: 16px; height: 16px; accent-color: var(--accent); vertical-align: -3px; }
:where(.app-body, .auth-body, .agent-body) :where(input:disabled, select:disabled, textarea:disabled) { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }

:where(.app-body, .auth-body, .agent-body) :where(code) {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: .86em;
  overflow-wrap: anywhere;
}
:where(.app-body, .auth-body, .agent-body) :where(pre) {
  padding: var(--s-4);
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--ctl-r);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  line-height: 1.6;
}
:where(.app-body, .auth-body, .agent-body) :where(pre code) { padding: 0; background: none; }

/* Tabellar utan klasse (mange view byggjer <table> rett i strengen). */
:where(.app-body, .agent-body) :where(table:not(.sr-only)) { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
:where(.app-body, .agent-body) :where(table:not(.sr-only) th) {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
:where(.app-body, .agent-body) :where(table:not(.sr-only) td) {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: middle;
}
:where(.app-body, .agent-body) :where(table:not(.sr-only) tbody tr:last-child td) { border-bottom: 0; }
:where(.app-body, .agent-body) :where(table:not(.sr-only) tbody tr:hover td) { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

.accent { color: var(--accent-ink); }

/* -------------------------------------------------------------- 2. SKAL */

/* Logoen finst i to fargar — vel rett variant etter løyst tema. */
.brand-wordmark { display: block; height: 24px; width: auto; }
.brand-wordmark-lg { display: block; height: 30px; width: auto; }
.brand-logo-light, .brand-logo-dark { display: block; height: 24px; width: auto; }
.brand-logo-dark, .brand-wordmark.brand-logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo-light { display: none; }
  :root:not([data-theme="light"]) .brand-logo-dark { display: block; }
}
:root[data-theme="dark"] .brand-logo-light { display: none; }
:root[data-theme="dark"] .brand-logo-dark { display: block; }

/* Kvadratisk merke når sidemenyen er falda saman: første bokstav i Kveo. */
.brand-mark {
  display: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--ctl-r);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--t-base);
  font-weight: 750;
  letter-spacing: -.02em;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
  transition: width .18s var(--ease), transform .22s var(--ease);
}

.sidebar-logo {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--topbar-h);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--line);
}
.sidebar-logo a { display: flex; align-items: center; gap: var(--s-3); color: var(--ink); }
.sidebar-logo small {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--t-micro);
  font-weight: 600;
  white-space: nowrap;
}

.sidebar-collapse-btn {
  position: absolute;
  top: 50%;
  right: -12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar-collapse-btn svg { width: 14px; height: 14px; transition: transform .18s var(--ease); }
.sidebar:hover .sidebar-collapse-btn,
.sidebar-collapse-btn:focus-visible { opacity: 1; }
.sidebar-collapse-btn:hover { color: var(--ink); }

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: var(--s-3) var(--s-3) var(--s-4);
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-group-label {
  margin: var(--s-4) var(--s-3) var(--s-1);
  color: var(--faint);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: .02em;
}
.nav-group-label:first-child { margin-top: var(--s-2); }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 5px 10px;
  border-radius: var(--ctl-r);
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 500;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-item .icon { display: grid; place-items: center; width: 18px; height: 18px; flex: none; color: var(--muted); }
.nav-item.active .icon, .nav-item:hover .icon { color: currentColor; }
.nav-item .icon svg { width: 18px; height: 18px; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: var(--surface);
  font-size: var(--t-micro);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.sidebar-footer {
  padding: var(--s-3) var(--s-5) var(--s-4);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--t-xs);
}
.sidebar-footer p { margin: 0 0 var(--s-2); color: var(--muted); font-size: var(--t-xs); }
.sidebar-footer p:last-child { margin-bottom: 0; }
.sidebar-footer a:not([class]) { color: var(--ink-2); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin: var(--s-3) 0; min-width: 0; }
.sidebar-user-text { min-width: 0; }
.sidebar-user-text strong,
.sidebar-user-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-text strong { color: var(--ink); font-size: var(--t-sm); font-weight: 600; }
.sidebar-user-text small { color: var(--muted); font-size: var(--t-micro); }
.btn-logout {
  width: 100%;
  min-height: var(--control-h-sm);
  border: 1px solid var(--line);
  border-radius: var(--ctl-r);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 600;
}
.btn-logout:hover { background: var(--surface-2); color: var(--ink); }

/* Samanfalda sidemeny (berre breie skjermar). */
html.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
html.sidebar-collapsed .admin-main { margin-left: var(--sidebar-w-collapsed); }
html.sidebar-collapsed .sidebar-logo { justify-content: center; padding: 0; }
html.sidebar-collapsed .sidebar-logo .brand-mark { display: grid; }
html.sidebar-collapsed .sidebar-logo .brand-wordmark,
html.sidebar-collapsed .sidebar-logo small,
html.sidebar-collapsed .nav-label,
html.sidebar-collapsed .nav-badge,
html.sidebar-collapsed .sidebar-footer { display: none; }
html.sidebar-collapsed .nav-group-label { height: 1px; margin: var(--s-3) var(--s-2); overflow: hidden; background: var(--line); color: transparent; }
html.sidebar-collapsed .nav-item { justify-content: center; padding: 0; min-height: 40px; }
html.sidebar-collapsed .nav-item.active::before { left: -12px; }
html.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
html.sidebar-collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  z-index: 60;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--canvas);
  font-size: var(--t-xs);
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity .12s ease;
}
html.sidebar-collapsed .nav-item:hover::after,
html.sidebar-collapsed .nav-item:focus-visible::after { opacity: 1; }

.hamburger {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--ctl-r);
  background: var(--surface);
}
.hamburger span { display: block; width: 18px; height: 2px; margin: 0 auto; border-radius: 2px; background: var(--ink); }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: color-mix(in srgb, var(--ink) 40%, transparent);
}

.admin-main {
  min-height: 100vh;
  margin-left: var(--sidebar-w);
  transition: margin-left .18s var(--ease);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: var(--topbar-h);
  padding: 0 var(--s-8);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
}
.app-topbar > div:first-child { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.workspace-label { color: var(--muted); font-size: var(--t-sm); white-space: nowrap; }
a.workspace-label:hover { color: var(--ink); }
.workspace-label span { margin-left: var(--s-2); color: var(--faint); }
.app-topbar strong {
  overflow: hidden;
  color: var(--ink);
  font-size: var(--t-sm);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: var(--s-2); flex: none; }

.topbar-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--ctl-r);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 600;
}
.topbar-link:hover { border-color: var(--line-strong); color: var(--ink); }

.topbar-icon-btn,
.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid transparent;
  border-radius: var(--ctl-r);
  background: transparent;
  color: var(--muted);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.topbar-icon-btn:hover,
.theme-toggle:hover { background: var(--surface-2); color: var(--ink); }
.topbar-icon-btn svg { width: 18px; height: 18px; }
.theme-toggle svg { width: 18px; height: 18px; display: none; }
.theme-toggle .ti-system { display: block; }
:root[data-theme-mode="light"] .theme-toggle .ti-system,
:root[data-theme-mode="dark"]  .theme-toggle .ti-system { display: none; }
:root[data-theme-mode="light"] .theme-toggle .ti-light  { display: block; }
:root[data-theme-mode="dark"]  .theme-toggle .ti-dark   { display: block; }

.content-stage {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s-8) var(--s-8) var(--s-12);
}

.preview-notice {
  margin-bottom: var(--s-6);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--ctl-r);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--t-xs);
}

/* Brukarmeny i topplinja. */
.user-menu { position: relative; }
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 36px;
  padding: 2px 6px 2px 2px;
  border-radius: var(--r-pill);
  transition: background-color var(--dur) var(--ease);
}
.user-chip:hover { background: var(--surface-2); }
.user-chip-text { display: none; }
.user-chip-caret {
  width: 7px;
  height: 7px;
  margin: 0 4px 0 2px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
}
.user-menu.open .user-chip-caret { transform: rotate(225deg) translate(-1px, -1px); }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: none;
  width: 268px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--card-r);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.user-menu.open .user-dropdown { display: block; }
.user-dropdown-head { display: flex; align-items: center; gap: 10px; padding: 10px; }
.user-dropdown-head > span:last-child { min-width: 0; }
.user-dropdown-head strong,
.user-dropdown-head small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown-head strong { color: var(--ink); font-size: var(--t-sm); font-weight: 600; }
.user-dropdown-head small { color: var(--muted); font-size: var(--t-xs); }
.user-dropdown-meta { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 500;
  text-align: left;
}
.user-dropdown-item:hover { background: var(--surface-2); color: var(--ink); }
.user-dropdown form { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.user-dropdown-danger { color: var(--danger); }
.user-dropdown-danger:hover { background: var(--danger-soft); color: var(--danger); }
.user-dropdown .phone-line { padding: 8px 10px 4px; margin: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: var(--t-micro);
  font-weight: 600;
}
.pill-soft { background: var(--surface-2); color: var(--muted); }

/* Avatarar: systemet har grunnforma, her berre flatefargen. */
.app-body .avatar { background: var(--surface-3); color: var(--ink); font-weight: 650; }
.avatar-dark { background: var(--surface-3); color: var(--ink); }

/* Kommandopalett (Ctrl+K). */
.cmdk-trigger {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 260px;
  min-height: 36px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--ctl-r);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--t-sm);
  transition: border-color var(--dur) var(--ease);
}
.cmdk-trigger:hover { border-color: var(--line-strong); color: var(--ink-2); }
.cmdk-trigger svg { width: 16px; height: 16px; flex: none; }
.cmdk-trigger > span:not(.cmdk-kbd-wrap) { flex: 1; text-align: left; }
.cmdk-kbd-wrap { display: inline-flex; gap: 3px; }
.cmdk-trigger kbd,
.cmdk-esc {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font);
  font-size: var(--t-micro);
  font-weight: 600;
}
.cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh var(--s-4) var(--s-4);
  background: color-mix(in srgb, var(--ink) 35%, transparent);
}
.cmdk-overlay.open { display: flex; }
.cmdk-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 580px;
  max-height: 64vh;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: cmdk-in .14s var(--ease);
}
@keyframes cmdk-in { from { opacity: 0; transform: translateY(-6px) scale(.985); } to { opacity: 1; transform: none; } }
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.cmdk-input-row svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.app-body .cmdk-input { flex: 1; min-height: 32px; padding: 0; border: 0; background: none; box-shadow: none; font-size: var(--t-base); }
.app-body .cmdk-input:focus-visible { box-shadow: none; }
.cmdk-list { overflow-y: auto; padding: 6px; }
.cmdk-group-label { margin: 10px 10px 4px; color: var(--faint); font-size: var(--t-micro); font-weight: 600; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--ctl-r); color: var(--ink-2); }
.cmdk-item .icon { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.cmdk-item .icon svg { width: 15px; height: 15px; }
.cmdk-item strong { display: block; color: var(--ink); font-size: var(--t-sm); font-weight: 600; }
.cmdk-item small { color: var(--muted); font-size: var(--t-xs); }
.cmdk-item.active, .cmdk-item:hover { background: var(--surface-2); }
.cmdk-item.active .icon, .cmdk-item:hover .icon { background: var(--surface); color: var(--ink); }
.cmdk-empty { padding: 28px 10px; color: var(--muted); font-size: var(--t-sm); text-align: center; }

/* Toast. */
.toast-stack {
  position: fixed;
  right: var(--s-5);
  bottom: var(--s-5);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  font-size: var(--t-sm);
  animation: toast-in .18s var(--ease);
}
.toast.leaving { animation: toast-out .16s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
.toast-dot { width: 8px; height: 8px; margin-top: 6px; flex: none; border-radius: 50%; background: var(--accent); }
.toast-success { border-color: var(--ok-line); }
.toast-success .toast-dot { background: var(--ok); }
.toast-error { border-color: var(--danger-line); }
.toast-error .toast-dot { background: var(--danger); border-radius: 1px; }
.toast-warning { border-color: var(--warn-line); }
.toast-warning .toast-dot { background: var(--warn); border-radius: 1px; transform: rotate(45deg); }
.toast-close { margin-left: auto; color: var(--faint); font-size: var(--t-base); line-height: 1; }
.toast-close:hover { color: var(--ink); }

/* ------------------------------------------------------ 3. SIDEHOVUD */

.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-3) var(--s-6);
  margin-bottom: var(--s-6);
}
.admin-header > div:first-child,
.admin-header > h1:first-child { flex: 1 1 360px; min-width: 0; }
.admin-header > .back-link,
.admin-header > .back-crumb { flex-basis: 100%; }
.admin-header h1 { margin: 0; font-size: var(--t-2xl); font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.admin-header p { max-width: 70ch; margin-top: 6px; color: var(--muted); font-size: var(--t-sm); line-height: 1.55; }
.admin-header > div:last-child:not(:first-child),
.admin-header > form,
.admin-header > a.btn-primary,
.admin-header > a.btn-sm,
.admin-header > .button-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }

.welcome-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 500;
}

.back-link,
.back-crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 500;
}
.back-link:hover, .back-crumb:hover { color: var(--ink); }
.link-small { color: var(--accent-ink); font-size: var(--t-sm); font-weight: 600; }
.link-small:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Seksjonar og kort. */
.admin-section,
.form-card,
.quick-actions,
.dash-card,
.yp-panel,
.yp-service,
.twofa-active {
  border: 1px solid var(--line);
  border-radius: var(--card-r);
  background: var(--surface);
}
.admin-section, .quick-actions { padding: var(--s-6); margin-bottom: var(--s-6); }
.form-card { padding: var(--s-6); }
.form-card + .form-card { margin-top: var(--s-4); }
.form-wrap { max-width: 760px; }

.panel-title,
.panel-h,
.admin-section > h2,
.quick-actions > h2 {
  margin: 0 0 var(--s-4);
  color: var(--ink);
  font-size: var(--t-base);
  font-weight: 650;
  letter-spacing: -.005em;
}
.panel-h-tight { margin-bottom: var(--s-1); }
.count-muted {
  margin-left: 6px;
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
p.count-muted { display: block; margin: 0 0 var(--s-4); font-size: var(--t-sm); line-height: 1.55; }

/* ----------------------------------------------- 4. KNAPPAR OG SKJEMA */

/* Views brukar .btn-primary / .btn-sm / .btn-danger utan .btn — dei må
   difor vere komplette knappar på eiga hand. */
.btn-primary,
.btn-sm,
.btn-secondary,
.action-btn,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--ctl-r);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-sm);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn-sm, .action-btn, .link-button { min-height: var(--control-h-sm); padding: 0 12px; }
.btn-sm:hover, .btn-secondary:hover, .action-btn:hover, .link-button:hover { background: var(--surface-2); border-color: var(--ink-2); }

.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); color: var(--on-accent); }
.btn-primary.full, .full { width: 100%; }

.btn-danger { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.btn-primary.btn-danger { border-color: var(--danger); background: var(--danger); color: var(--surface); }

.btn-primary:disabled, .btn-sm:disabled, .btn-secondary:disabled, .btn-danger:disabled,
.btn-sm.disabled, .app-body button[type="submit"]:disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

.button-row,
.action-links,
.actions:not(td) { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
/* Ei tabellcelle må få vere celle — barna ligg på line med litt luft. */
td.actions { white-space: nowrap; text-align: right; }
td.actions > * { display: inline-flex; vertical-align: middle; margin: 2px 0 2px 6px; }
td.actions > form { margin-block: 2px; }

.form-group { margin-bottom: var(--s-5); }
.form-group:last-child { margin-bottom: 0; }
.form-group small,
.form-hint { display: block; margin-top: 6px; color: var(--muted); font-size: var(--t-xs); line-height: 1.5; }
.form-group label code { margin-left: 4px; font-size: var(--t-micro); color: var(--muted); }
.form-card > form > button[type="submit"],
.form-card > form > .button-row { margin-top: var(--s-2); }

/* Filtrering over lister. */
.search-bar,
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.search-bar input, .filter-bar input { flex: 1 1 260px; max-width: 420px; }
.filter-bar select { flex: 0 1 200px; width: auto; }

.pagination { display: flex; align-items: center; justify-content: center; gap: var(--s-3); margin-top: var(--s-5); }
.pagination-info { color: var(--muted); font-size: var(--t-sm); }

/* -------------------------------------------- 5. TABELLAR, MERKE, VARSEL */

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--card-r);
  background: var(--surface);
}
.admin-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.admin-table th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.admin-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.admin-table td:first-child { color: var(--ink); font-weight: 500; }
.admin-table .link-small { color: var(--ink); font-weight: 600; }

/* Merke: farge frå --badge, form frå ::before (aldri berre farge). */
.badge,
.yp-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  min-height: 22px;
  padding: 1px 9px;
  border: 1px solid color-mix(in srgb, var(--badge, var(--muted)) 35%, transparent);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--badge, var(--muted)) 10%, var(--surface));
  color: var(--badge, var(--muted));
  font-size: var(--t-micro);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
p.status-pill, div.status-pill { white-space: normal; border-radius: var(--ctl-r); padding: 6px 10px; }
.badge::before,
.yp-badge::before,
.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  background: currentColor;
  border-radius: 50%;           /* standard: fylt sirkel */
}

.badge-open, .badge-waiting-open { --badge: var(--warn); }
.badge-answered, .badge-admin, .badge-ok { --badge: var(--ok); }
.badge-user, .badge-closed { --badge: var(--muted); }
.badge-danger { --badge: var(--danger); }
.badge-progress { --badge: var(--info); }
.badge-waiting { --badge: var(--accent-ink); }

/* Open / ventar -> rombe */
.badge-open::before { border-radius: 1px; transform: rotate(45deg); }
/* Svart / ok / aktiv -> fylt sirkel */
.badge-answered::before,
.badge-admin::before,
.badge-ok::before { border-radius: 50%; }
/* Feil / avbroten -> kvadrat */
.badge-danger::before { border-radius: 1px; }
/* Brukar / nøytral -> open ring */
.badge-user::before {
  background: none;
  border: 2px solid currentColor;
}
/* Support-statusane (utils/ticketStatus.js sin `state`). */
.badge-progress::before { border-radius: 1px; width: 10px; height: 4px; }
.badge-waiting::before  { background: none; border: 2px solid currentColor; }
.badge-closed::before   { border-radius: 1px; }

/* Varsel: form + farge + tekst. */
.flash,
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: var(--s-4);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--t-sm);
  line-height: 1.5;
}
.flash::before,
.alert::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 6px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}
.flash-success, .alert-success { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); }
.flash-error, .alert-error { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.flash-error::before, .alert-error::before { border-radius: 1px; }
.flash-warning, .alert-warning { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.flash-warning::before, .alert-warning::before { border-radius: 1px; transform: rotate(45deg); }
.alert-info { border-color: var(--info-line); background: var(--info-soft); color: var(--info); }
.alert-info::before { background: none; border: 2px solid currentColor; }
.alert > *, .flash > * { margin: 0; }

/* Tom tilstand. */
.empty,
.empty-state,
.yp-empty {
  padding: var(--s-8) var(--s-6);
  border: 1px dashed var(--line-strong);
  border-radius: var(--card-r);
  background: transparent;
  color: var(--muted);
  font-size: var(--t-sm);
  text-align: center;
}
.empty-state strong { display: block; color: var(--ink); font-weight: 600; }
.empty-state span { display: block; margin-top: 4px; }

/* ------------------------------------------ 6. TRÅD, FANER, DETALJHOVUD */

.message-view { max-width: 820px; }
.message-meta,
.thread-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: var(--t-xs); }
.message-body,
.reply-body,
.thread-msg {
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--card-r);
  background: var(--surface);
  color: var(--ink-2);
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.reply-body, .thread-admin { border-color: var(--accent-line); background: var(--accent-soft); }
.case-thread { display: flex; flex-direction: column; gap: var(--s-3); margin: var(--s-6) 0; }
.thread-msg { max-width: 86%; }
.thread-customer { align-self: flex-start; }
.thread-admin { align-self: flex-end; }
.thread-body { margin-top: 6px; white-space: pre-wrap; }

/* Faner (kundekortet). ARIA-mønsteret ligg i viewet. */
.cust-tabs {
  display: flex;
  gap: var(--s-1);
  margin-bottom: var(--s-6);
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.cust-tab-link {
  flex: none;
  margin-bottom: -1px;
  padding: 10px 12px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 500;
  white-space: nowrap;
}
.cust-tab-link:hover { color: var(--ink); }
.cust-tab-link.active,
.cust-tab-link[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
.cust-tab-panel { display: none; }
.cust-tab-panel.active { display: block; padding-bottom: var(--s-8); }
.cust-tab-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.detail-header h1 { margin: 6px 0 0; }
.detail-header-meta { margin: 4px 0 0; color: var(--muted); font-size: var(--t-sm); }
.detail-header-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); flex: none; }

/* 2FA. */
.twofa-active { padding: var(--s-8); text-align: center; }
.twofa-badge { margin-bottom: var(--s-2); color: var(--ok); font-size: var(--t-lg); font-weight: 650; }
.qr-code {
  display: block;
  width: 200px;
  height: 200px;
  margin: 0 auto var(--s-5);
  border: 8px solid var(--surface);
  border-radius: var(--card-r);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}
.secret-label {
  margin-bottom: var(--s-5);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--ctl-r);
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  word-break: break-all;
}
.code-input { font-family: var(--font-mono); letter-spacing: .3em; text-align: center; font-size: var(--t-xl); }

/* Kunde-/brukarredigering. */
.customer-editor { display: grid; grid-template-columns: minmax(200px, .55fr) minmax(0, 1.45fr); gap: var(--s-10); align-items: start; }
.editor-intro h2 { margin-bottom: var(--s-2); font-size: var(--t-base); }
.editor-intro p { color: var(--muted); font-size: var(--t-sm); line-height: 1.65; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); }
.editor-grid .form-group { margin: 0; }
.editor-grid .editor-wide { grid-column: 1 / -1; }
.editor-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; margin-top: var(--s-6); padding-top: var(--s-5); border-top: 1px solid var(--line); }

/* ------------------------------------------------------ 7. DASHBOARD */

.dash-greeting { margin-bottom: var(--s-6); }
.dash-greeting h1 { margin: 0; }

.dash-block { margin-bottom: var(--s-6); }
.dash-block-sm { margin-bottom: var(--s-4); }

.dash-section-h {
  margin-bottom: var(--s-3);
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 600;
}

.dash-card { overflow: hidden; }
.dash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: 52px;
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--line);
}
.dash-card-head h2 { margin: 0; font-size: var(--t-sm); font-weight: 650; }
.dash-card-head a { color: var(--muted); font-size: var(--t-xs); font-weight: 600; }
.dash-card-head a:hover { color: var(--ink); }
.dash-card-body { padding: var(--s-4) var(--s-5) var(--s-5); }
.dash-card-urgent { border-color: var(--warn-line); }
.dash-card-urgent .dash-card-head { background: var(--warn-soft); }
.dash-card-urgent .dash-card-head h2 { color: var(--warn); }

.count-chip {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--canvas);
  font-size: var(--t-micro);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  vertical-align: 1px;
}
.dash-card-urgent .count-chip { background: var(--warn); color: var(--surface); }

/* KPI-rad. */
.stats-grid,
.yp-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-6);
}
.stat-card,
.yp-stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--card-r);
  background: var(--surface);
  color: inherit;
  transition: border-color var(--dur) var(--ease);
}
a.stat-card:hover, a.yp-stat:hover { border-color: var(--line-strong); }
.stat-icon {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
}
.stat-icon svg { width: 16px; height: 16px; }
.stat-label,
.yp-stat span { order: -1; color: var(--muted); font-size: var(--t-sm); font-weight: 500; }
.stat-num,
.yp-stat strong {
  margin-top: 6px;
  color: var(--ink);
  font-size: 1.875rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.stat-card.accent .stat-num { color: var(--accent-ink); }
.stat-card.is-alert { border-color: var(--warn-line); }
.stat-card.is-alert .stat-num { color: var(--warn); }
.yp-stat small { color: var(--muted); font-size: var(--t-xs); }

/* Kompakte referansetal (innhald): rader, ikkje kort. */
.stats-grid-muted { display: block; margin: 0; }
.stats-grid-muted .stat-card {
  flex-direction: row;
  align-items: center;
  gap: var(--s-3);
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.stats-grid-muted .stat-card:last-child { border-bottom: 0; }
.stats-grid-muted .stat-icon { position: static; width: 24px; height: 24px; background: transparent; }
.stats-grid-muted .stat-label { order: 0; flex: 1; color: var(--ink-2); }
.stats-grid-muted .stat-num { order: 1; margin: 0; font-size: var(--t-base); font-weight: 600; }
.stats-grid-muted .stat-card:hover .stat-label { color: var(--ink); }

/* Dashboard-rutenett. */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: var(--s-5);
  align-items: start;
}
.dash-grid > div { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }
.dash-grid > div > * { margin-bottom: 0; }
.dashboard-health {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: var(--s-5);
  align-items: start;
  margin-bottom: var(--s-6);
}
.dashboard-health .dash-block { margin-bottom: 0; }
.dashboard-health > :only-child { grid-column: 1 / -1; }

/* Krev handling. */
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-5) var(--s-6); padding: var(--s-4) var(--s-5) var(--s-5); }
.action-group h3 { margin: 0 0 var(--s-2); color: var(--muted); font-size: var(--t-xs); font-weight: 600; }
.action-group ul { display: flex; flex-direction: column; gap: var(--s-2); }
.action-group li { display: flex; flex-direction: column; font-size: var(--t-sm); }
.action-group li a { color: var(--ink); font-weight: 600; }
.action-group li a:hover { text-decoration: underline; text-underline-offset: 3px; }
.action-group li span { color: var(--muted); font-size: var(--t-xs); }
.action-group .link-small { display: inline-block; margin-top: var(--s-2); }

/* Driftstatus. */
.status-widget {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--ok-line);
  border-radius: var(--card-r);
  background: var(--ok-soft);
  color: var(--ok);
}
.status-widget.has-issues { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.status-widget-dot { position: relative; width: 10px; height: 10px; flex: none; border-radius: 50%; background: currentColor; }
.status-widget.has-issues .status-widget-dot { border-radius: 1px; transform: rotate(45deg); }
.status-widget-dot::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid currentColor;
  border-radius: inherit;
  opacity: .5;
  animation: status-pulse 2.4s ease-out infinite;
}
@keyframes status-pulse { from { transform: scale(.6); opacity: .6; } to { transform: scale(1.6); opacity: 0; } }
.status-widget strong { display: block; color: var(--ink); font-size: var(--t-sm); font-weight: 650; }
.status-widget span span { display: block; margin-top: 1px; color: var(--ink-2); font-size: var(--t-xs); }

.drift-stack { display: block; }
.drift-stack .status-widget { border-radius: var(--card-r) var(--card-r) 0 0; }
.drift-stack-body { padding: var(--s-4) var(--s-5); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--card-r) var(--card-r); background: var(--surface); }
.drift-stack-body .link-small { display: inline-block; margin-top: var(--s-3); }

/* Graf. */
.spark-wrap { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding: var(--s-4) var(--s-5) 0; }
.spark-bar { position: relative; display: flex; align-items: flex-end; flex: 1; height: 100%; }
.spark-bar > span { display: block; width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--accent); opacity: .8; transition: opacity .12s ease; }
.spark-bar:hover > span { opacity: 1; }
.spark-bar:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  z-index: 5;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--canvas);
  font-size: var(--t-micro);
  font-weight: 600;
  white-space: nowrap;
  transform: translateX(-50%);
}
.spark-axis { display: flex; justify-content: space-between; padding: 6px var(--s-5) var(--s-4); border-top: 1px solid var(--line); color: var(--faint); font-size: var(--t-micro); font-weight: 600; }
.spark-total { color: var(--muted); font-size: var(--t-xs); font-weight: 500; }

/* Tidslinje. */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; align-items: center; gap: var(--s-3); padding: 10px var(--s-5); border-bottom: 1px solid var(--line); color: inherit; }
.timeline-item:last-child { border-bottom: 0; }
a.timeline-item:hover { background: var(--surface-2); }
.timeline-dot { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: var(--t-xs); font-weight: 700; }
.timeline-dot svg { width: 14px; height: 14px; }
.timeline-dot.tl-msg { background: var(--info-soft); color: var(--info); }
.timeline-dot.tl-ticket { background: var(--warn-soft); color: var(--warn); }
.timeline-dot.tl-blog { background: var(--ok-soft); color: var(--ok); }
.timeline-body { min-width: 0; }
.timeline-body strong { display: block; overflow: hidden; color: var(--ink); font-size: var(--t-sm); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.timeline-body span { display: block; color: var(--muted); font-size: var(--t-xs); }
.dash-card > .empty-state { margin: var(--s-4) var(--s-5) var(--s-5); }

/* Snarvegar. */
.quick-actions { padding: 0; overflow: hidden; }
.quick-actions > h2 { margin: 0; padding: var(--s-3) var(--s-5); min-height: 52px; display: flex; align-items: center; border-bottom: 1px solid var(--line); font-size: var(--t-sm); }
.quick-actions .action-links { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
.quick-actions .action-btn {
  justify-content: space-between;
  min-height: 44px;
  padding: 0 var(--s-5);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-weight: 500;
}
.quick-actions .action-btn:last-child { border-bottom: 0; }
.quick-actions .action-btn::after { content: "+"; color: var(--muted); font-size: var(--t-base); font-weight: 400; }
.quick-actions .action-btn:hover { background: var(--surface-2); }
.quick-actions .stats-grid-muted { padding: 0 var(--s-5); }

.workspace-shortcuts { display: none; }

/* ------------------------------------------------- INNSTILLINGAR */

.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--s-8); align-items: start; }
.settings-nav {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s-6));
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - var(--topbar-h) - 48px);
  overflow-y: auto;
}
.settings-nav > span { margin: var(--s-3) 10px var(--s-1); color: var(--faint); font-size: var(--t-micro); font-weight: 600; }
.settings-nav > span:first-child { margin-top: 0; }
.settings-nav a {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--ctl-r);
  color: var(--ink-2);
  font-size: var(--t-sm);
}
.settings-nav a:hover { background: var(--surface-2); color: var(--ink); }
.settings-nav a.active,
.settings-nav a[aria-current="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.settings-layout .form-wrap { max-width: 760px; }
.settings-layout h2, .settings-section { scroll-margin-top: calc(var(--topbar-h) + 24px); }

/* Med JS: éin seksjon om gongen (data-sections i layout-skriptet). */
.js-sections [data-section][hidden] { display: none; }
.form-card .section-lede { margin: -8px 0 var(--s-5); color: var(--muted); font-size: var(--t-sm); line-height: 1.55; }
.state-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-bottom: var(--s-4); }
.inline-check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; color: var(--ink-2); }

/* Nyttige småklassar for viewa (erstattar inline style=""). */
.muted { color: var(--muted); }
.text-sm { font-size: var(--t-sm); }
.text-xs { font-size: var(--t-xs); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); } .mb-6 { margin-bottom: var(--s-6); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s-4); }
.stack-sm > * + * { margin-top: var(--s-2); }
.stack-md > * + * { margin-top: var(--s-4); }
.stack-lg > * + * { margin-top: var(--s-6); }
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px var(--s-6); font-size: var(--t-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.card-section { padding: var(--s-5) var(--s-6); border-top: 1px solid var(--line); }
.card-section:first-child { border-top: 0; }
.meter { height: 6px; overflow: hidden; border-radius: var(--r-pill); background: var(--surface-3); }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* -------------------------------------- 8. KUNDEPORTAL (yp-*) */

.yp-head { margin-bottom: var(--s-5); }
.yp-head h1 { margin: 2px 0 0; font-size: var(--t-2xl); font-weight: 650; line-height: 1.15; }
.yp-kicker { color: var(--muted); font-size: var(--t-sm); font-weight: 500; }
.yp-block, .yp-section, .yp-two-col { margin-bottom: var(--s-5); }
.yp-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.yp-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.yp-section-head h2 { margin: 0; font-size: var(--t-base); }
.yp-section-head a { color: var(--accent-ink); font-size: var(--t-sm); font-weight: 600; }
.yp-section-head span { color: var(--muted); font-size: var(--t-xs); }
.yp-service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--s-3); }
.yp-service, .yp-panel { padding: var(--s-5); }
.yp-service > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.yp-service h3 { margin-bottom: 4px; font-size: var(--t-base); }
.yp-service p { color: var(--muted); font-size: var(--t-sm); }
.yp-meter { height: 6px; margin: 6px 0 var(--s-3); overflow: hidden; border-radius: var(--r-pill); background: var(--surface-3); }
.yp-meter div { height: 100%; border-radius: inherit; background: var(--accent); }
.yp-meter-text { margin: -6px 0 var(--s-3); color: var(--muted); font-size: var(--t-xs); }
.yp-row, .yp-ticket {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
}
.yp-row:first-of-type, .yp-ticket:first-of-type { border-top: 0; }
.yp-row span, .yp-ticket span { display: flex; flex-direction: column; min-width: 0; }
.yp-row small, .yp-ticket small { color: var(--muted); font-size: var(--t-xs); }
a.yp-ticket:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.yp-refcard { margin-top: var(--s-5); }
.yp-refcard .yp-row strong { font-variant-numeric: tabular-nums; }

/* -------------------------------------------- INNLOGGING (auth-*) */

.auth-body { min-height: 100vh; display: grid; place-items: center; padding: var(--s-6); }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card {
  padding: var(--s-8);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s-6); color: var(--ink); font-size: var(--t-lg); font-weight: 650; }
.auth-card h1 { margin-bottom: var(--s-2); font-size: var(--t-xl); font-weight: 650; }
.auth-sub { margin-bottom: var(--s-5); color: var(--muted); font-size: var(--t-sm); }
.auth-back { display: block; margin-top: var(--s-5); color: var(--muted); font-size: var(--t-sm); font-weight: 500; text-align: center; }
.auth-back:hover { color: var(--ink); }
.auth-forgot { display: block; margin-top: 6px; color: var(--muted); font-size: var(--t-xs); font-weight: 500; text-align: right; }
.auth-forgot:hover { color: var(--ink); text-decoration: underline; }
.auth-body .form-group { margin-bottom: var(--s-4); }
.auth-body .btn-primary { width: 100%; min-height: 42px; }

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: 100%;
  max-width: 920px;
  min-height: 540px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.auth-visual {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--s-10);
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
}
.auth-visual-top, .auth-visual-bottom { position: relative; }
.auth-visual-logo { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.auth-visual h2 { max-width: 340px; margin: var(--s-10) 0 var(--s-6); font-size: 1.75rem; font-weight: 600; line-height: 1.2; letter-spacing: -.02em; }
.auth-visual-features { display: flex; flex-direction: column; gap: var(--s-3); }
.auth-feature { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: var(--t-sm); }
.auth-feature .icon { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 7px; background: var(--surface); color: var(--accent-ink); border: 1px solid var(--line); }
.auth-feature .icon svg { width: 15px; height: 15px; }
.auth-visual-quote { padding-top: var(--s-5); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--t-xs); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: var(--s-10) var(--s-8); }
.auth-panel-inner { width: 100%; max-width: 340px; }
.auth-panel .auth-logo { margin-bottom: var(--s-6); }
.auth-body-theme-toggle { position: fixed; top: var(--s-5); right: var(--s-5); z-index: 10; }

.panel-choice { display: flex; flex-direction: column; gap: var(--s-2); }
.panel-choice-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 64px;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--card-r);
  background: var(--surface);
  color: var(--ink);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.panel-choice-item:hover { border-color: var(--line-strong); background: var(--surface-2); }
.panel-choice-item .icon { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 9px; background: var(--accent-soft); color: var(--accent-ink); }
.panel-choice-item .icon svg { width: 18px; height: 18px; }
.panel-choice-item strong { display: block; font-size: var(--t-sm); font-weight: 650; }
.panel-choice-item small { display: block; color: var(--muted); font-size: var(--t-xs); }
.panel-choice-item-arrow { margin-left: auto; color: var(--faint); }

/* Merkevare-unntak: Microsoft krev kvit flate og mørk tekst i begge tema. */
.btn-microsoft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--ctl-r);
  background: #ffffff;
  color: #1b1b1f;
  font-size: var(--t-sm);
  font-weight: 600;
  transition: box-shadow var(--dur) var(--ease);
}
.btn-microsoft:hover { box-shadow: var(--shadow-md); }
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin: var(--s-5) 0;
  color: var(--faint);
  font-size: var(--t-micro);
  font-weight: 600;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Teknisk support-telefon (tel:-lenke). */
.phone-line { margin: 0; font-size: var(--t-xs); line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.phone-line-label { color: var(--muted); }
.phone-line-link { color: var(--ink-2); font-weight: 600; white-space: nowrap; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.phone-line-link:hover { color: var(--ink); text-decoration-color: currentColor; }
.phone-line-note { display: block; }
.phone-line-auth { margin-top: var(--s-4); text-align: center; }

/* ------------------------------------------------ KVEO AI OPERATIONS */

.aiops-agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.aiops-agent-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--card-r); background: var(--surface); color: var(--ink); }
.aiops-agent-card:hover, .aiops-agent-card:focus-visible { border-color: var(--line-strong); }
.aiops-list { display: flex; flex-direction: column; gap: var(--s-2); margin: 0 0 var(--s-4); }
.aiops-list li { overflow-wrap: anywhere; font-size: var(--t-sm); }
.aiops-list progress { display: block; width: 100%; height: 6px; margin-top: 4px; accent-color: var(--accent); }
.aiops-pre { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.aiops-check, .app-body label.aiops-check { display: flex; align-items: baseline; gap: var(--s-2); margin: 0 0 var(--s-2); font-weight: 400; }
.aiops-check input { flex: none; }
.aiops-dash { display: flex; flex-direction: column; gap: var(--s-6); }
.aiops-dash > .alert, .aiops-dash .stats-grid, .aiops-dash .aiops-agent-grid { margin: 0; }
.aiops-dash .aiops-section > .panel-h { margin-bottom: var(--s-3); }
.aiops-dash .dash-card > :not(.dash-card-head) { margin: 0; padding: var(--s-4) var(--s-5) var(--s-5); }
.aiops-dash .dash-card .aiops-list { gap: var(--s-3); }
.aiops-note { margin: 0; color: var(--muted); font-size: var(--t-sm); line-height: 1.6; }
.aiops-msg { padding: var(--s-3) 0; border-top: 1px solid var(--line); }
.aiops-msg p { margin: 0; }
.aiops-check-row { display: flex; align-items: baseline; gap: var(--s-2); }
.app-body .aiops-instructions, .agent-body .aiops-instructions { min-height: 420px; font-family: var(--font-mono); font-size: var(--t-xs); line-height: 1.55; }

/* Agent-arbeidsplassen (/agent) for Grok-botane. Med vilje enkel: éi kolonne
   og vanlege skjema, så ein nettlesarstyrt bot kan lese og bruke alt. */
.agent-body { min-height: 100vh; }
.agent-bar { border-bottom: 1px solid var(--line); background: var(--surface); }
.agent-bar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-6); max-width: 1040px; margin: 0 auto; padding: var(--s-3) var(--s-4); }
.agent-bar-name { flex: 1 1 280px; margin: 0; }
.agent-nav { display: flex; flex-wrap: wrap; gap: var(--s-4); }
.agent-nav a { padding: var(--s-1) 0; border-bottom: 2px solid transparent; color: var(--ink); font-weight: 600; }
.agent-nav a.active, .agent-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.agent-main { display: flex; flex-direction: column; gap: var(--s-4); max-width: 1040px; margin: 0 auto; padding: var(--s-6) var(--s-4) var(--s-12); }
.agent-main > .alert { margin: 0; }
.agent-section { padding: var(--s-5) var(--s-6); border: 1px solid var(--line); border-radius: var(--card-r); background: var(--surface); }
.agent-section > h2 { margin: 0 0 var(--s-4); }
.agent-card { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4) 0; border-top: 1px solid var(--line); }
.agent-card:first-of-type { padding-top: 0; border-top: 0; }
.agent-card h3, .agent-card p { margin: 0; }
.agent-checkin fieldset { padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--ctl-r); }
.agent-login { max-width: 520px; margin: var(--s-12) auto 0; padding: var(--s-8) var(--s-6); border: 1px solid var(--line); border-radius: var(--card-r); background: var(--surface); }
.agent-live a { margin-left: var(--s-2); font-weight: 600; }
.inline-form { display: inline; margin: 0; }

/* ------------------------------------------------------ RESPONSIVT */

@media (max-width: 1180px) {
  .dash-grid, .dashboard-health { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 190px minmax(0, 1fr); gap: var(--s-6); }
  .cmdk-trigger { width: 200px; }
}

@media (max-width: 940px) {
  .hamburger { display: flex; }
  .sidebar,
  html.sidebar-collapsed .sidebar { width: 272px; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-collapse-btn { display: none; }
  .sidebar-overlay.open { display: block; }
  html.sidebar-collapsed .sidebar-logo { justify-content: flex-start; padding: 0 var(--s-5); }
  html.sidebar-collapsed .sidebar-logo .brand-mark { display: none; }
  html.sidebar-collapsed .sidebar-logo .brand-wordmark,
  html.sidebar-collapsed .nav-label,
  html.sidebar-collapsed .sidebar-footer { display: block; }
  html.sidebar-collapsed .sidebar-logo small { display: inline; }
  html.sidebar-collapsed .nav-badge { display: inline-grid; }
  html.sidebar-collapsed .nav-group-label { height: auto; margin: var(--s-5) var(--s-3) var(--s-1); background: none; color: var(--faint); }
  html.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 6px 10px; min-height: 36px; }
  html.sidebar-collapsed .nav-item::after { display: none; }
  .admin-main, html.sidebar-collapsed .admin-main { margin-left: 0; }
  .app-topbar { padding: 0 var(--s-4); }
  .app-topbar > div:first-child { gap: var(--s-3); }
  .content-stage { padding: var(--s-6) var(--s-4) var(--s-10); }
  .cmdk-trigger { width: 36px; padding: 0; justify-content: center; border-color: transparent; background: transparent; }
  .cmdk-trigger > span, .cmdk-trigger .cmdk-kbd-wrap { display: none; }
  .settings-layout, .customer-editor { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; max-height: none; gap: var(--s-1); padding-bottom: var(--s-3); border-bottom: 1px solid var(--line); }
  .settings-nav > span { flex-basis: 100%; margin: var(--s-2) 0 0; }
  .yp-two-col, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; max-width: 440px; min-height: 0; }
  .auth-visual { display: none; }
  .auth-panel { padding: var(--s-8) var(--s-6); }
}

@media (max-width: 600px) {
  .app-topbar > div:first-child .workspace-label { display: none; }
  .topbar-icon-btn { display: none; }
  .admin-header h1, .yp-head h1 { font-size: var(--t-xl); }
  .admin-header { align-items: stretch; }
  .stats-grid, .yp-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-num, .yp-stat strong { font-size: var(--t-xl); }
  .stat-icon { display: none; }
  .editor-grid { grid-template-columns: 1fr; }
  .form-card, .admin-section { padding: var(--s-5) var(--s-4); }
  .thread-msg { max-width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: var(--s-2); }
  .auth-card { padding: var(--s-6) var(--s-5); }
}

/* Nettstad-kortet på oversikta: teljarar over, snarvegar under. */
.quick-actions .stats-grid-muted + .action-links { border-top: 1px solid var(--line); }
.row > select, .row > input:not([type="checkbox"]):not([type="radio"]) { flex: 1 1 220px; width: auto; }
/* Finger: menypunkt og faner får full treffflate. */
@media (pointer: coarse) {
  .nav-item, .settings-nav a, .cust-tab-link, .user-dropdown-item { min-height: var(--tap-min); }
  .topbar-icon-btn, .theme-toggle, .cmdk-trigger, .hamburger { min-width: 40px; min-height: 40px; }
}

/* Tabellar på telefon: rader blir kort, kolonnenamnet står framfor verdien.
   Klassa og data-label blir sette av admin-layouten (JS); utan JS rullar
   tabellen sidelengs i .admin-table-wrap som før. */
@media (max-width: 600px) {
  table.stack-on-phone, table.stack-on-phone tbody, table.stack-on-phone tr, table.stack-on-phone td { display: block; width: 100%; }
  table.stack-on-phone thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .app-body table.stack-on-phone tr { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
  .app-body table.stack-on-phone tbody tr:last-child { border-bottom: 0; }
  .app-body table.stack-on-phone td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-4);
    min-height: 0;
    padding: 4px 0;
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }
  .app-body table.stack-on-phone td::before {
    content: attr(data-label);
    flex: none;
    max-width: 45%;
    color: var(--muted);
    font-size: var(--t-xs);
    font-weight: 600;
    text-align: left;
  }
  .app-body table.stack-on-phone td[data-label=""]::before,
  .app-body table.stack-on-phone td:not([data-label])::before { display: none; }
  .app-body table.stack-on-phone td:first-child { justify-content: flex-start; text-align: left; font-size: var(--t-base); font-weight: 600; color: var(--ink); }
  .app-body table.stack-on-phone td:first-child::before { display: none; }
  .app-body table.stack-on-phone td.actions,
  .app-body table.stack-on-phone td:last-child:has(> a, > form, > button) { justify-content: flex-start; flex-wrap: wrap; gap: var(--s-2); padding-top: var(--s-2); text-align: left; }
  .app-body table.stack-on-phone td.actions::before,
  .app-body table.stack-on-phone td:last-child:has(> a, > form, > button)::before { display: none; }
  .app-body table.stack-on-phone td.actions > * { margin: 0; }
  .app-body table.stack-on-phone tbody tr:hover td { background: transparent; }
  .admin-table-wrap:has(table.stack-on-phone) { overflow: visible; }
}

/* Innlogging: luft under overskrifta, og juridiske lenkjer som ei lita linje. */
.auth-card h1, .auth-panel h1 { margin-bottom: var(--s-5); }
.auth-card h1:has(+ .auth-sub), .auth-panel h1:has(+ .auth-sub) { margin-bottom: var(--s-1); }
.auth-legal { margin-top: var(--s-4); color: var(--faint); font-size: var(--t-xs); text-align: center; }
.auth-legal a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.auth-legal a:hover { color: var(--ink); }

/* ── customers ── */
/* Kundekortet (views/admin/customers/view.ejs). Berre systemtoken, ingen
   fargeverdiar. Overskrift/ingress brukar :where() så verktøyklassane
   (.mb-0, .mt-6 …) i admin.css framleis vinn. */

:where(.cust-sub) {
  margin: 0 0 var(--s-3);
  color: var(--ink);
  font-size: var(--t-sm);
  font-weight: 650;
}
:where(.cust-lede) {
  max-width: 70ch;
  margin: calc(-1 * var(--s-2)) 0 var(--s-5);
  color: var(--muted);
  font-size: var(--t-sm);
  line-height: 1.55;
}
.cust-head { margin-bottom: var(--s-4); }
.cust-head + .cust-lede { margin-top: 0; }
.cust-label { margin: 0 0 var(--s-1); color: var(--ink-2); font-size: var(--t-sm); font-weight: 600; }

/* Underflate i ein seksjon: skjema for «legg til», ei teneste, ein førespurnad. */
.cust-box {
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--ctl-r);
  background: var(--surface-2);
}
.cust-box-warn { border-color: var(--warn-line); }

/* Skjema på line: felt med synleg etikett, knappen på linje med felta. */
.cust-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3) var(--s-4); }
.cust-field { flex: 1 1 200px; min-width: 0; }
.cust-field-wide { flex: 2 1 260px; }
.cust-field-sm { flex: 0 1 170px; }
.cust-field .form-hint { font-weight: 400; }
.cust-form > button { flex: none; min-height: var(--control-h); }

/* Status-skjemaet inne i tenestetabellen. */
.cust-inline { display: flex; align-items: center; gap: var(--s-2); }
.cust-inline > select { flex: 0 1 150px; width: auto; min-width: 120px; }

/* Oversikt og celler. */
.cust-notes { margin: 0; color: var(--ink-2); font-size: var(--t-sm); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.cust-stats { margin-bottom: var(--s-4); }
.cust-cell-meta { display: block; margin-top: 2px; color: var(--muted); font-size: var(--t-xs); font-weight: 400; }
.cust-error { max-width: 320px; color: var(--danger); overflow-wrap: anywhere; }
.cust-config { max-width: 320px; overflow-wrap: anywhere; }
.cust-scopes-cell { min-width: 180px; }
.cust-chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* Tilgangsveljaren for service-token. */
.cust-scope-grid { gap: var(--s-3); }
.cust-scope-group {
  min-width: 0;
  margin: 0;
  padding: var(--s-3) var(--s-4) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--ctl-r);
  background: var(--surface);
}
.cust-scope-legend {
  float: left;               /* legg legend inne i ramma i staden for på kanten */
  width: 100%;
  padding: 0;
  color: var(--ink);
  font-size: var(--t-xs);
  font-weight: 650;
}
.cust-scope-legend + * { clear: both; }
.app-body .cust-check {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  margin: 0;
  padding-top: var(--s-3);
  font-weight: 400;
  cursor: pointer;
}
.cust-check > input { flex: none; margin-top: 3px; }
.cust-check-title { display: block; color: var(--ink); font-size: var(--t-sm); font-weight: 600; }
.cust-check-desc { display: block; color: var(--muted); font-size: var(--t-xs); line-height: 1.45; }
.cust-check code { display: inline-block; margin-top: 2px; color: var(--muted); }

/* Utfellbar token-rad. */
.cust-token-cell { padding: var(--s-4); background: var(--surface-2); }
.app-body .admin-table tbody tr.cust-token-panel:hover td { background: var(--surface-2); }
.cust-token-cell > div + div { margin-top: var(--s-4); }
.cust-token-value {
  display: block;
  flex: 1 1 260px;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: var(--t-xs);
  word-break: break-all;
}

/* Aktivitetslogg. */
.cust-log { margin: 0; padding: 0; list-style: none; }
.cust-log li {
  display: flex;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: var(--t-sm);
  overflow-wrap: anywhere;
}
.cust-log li:first-child { padding-top: 0; border-top: 0; }
.cust-log-time { flex: none; color: var(--muted); font-size: var(--t-xs); white-space: nowrap; }

@media (max-width: 600px) {
  .cust-box { padding: var(--s-4) var(--s-3); }
  .cust-form { flex-direction: column; align-items: stretch; }
  .cust-form > .cust-field { flex: none; }
  .cust-form > button { width: 100%; }
  .cust-inline { flex-wrap: wrap; }
  .cust-error, .cust-config { max-width: none; }
  .cust-log li { flex-direction: column; gap: 2px; }
  /* Den utfellbare token-rada er éi celle, ikkje etikett + verdi. */
  .app-body table.stack-on-phone td.cust-token-cell {
    display: block;
    padding: var(--s-3);
    color: var(--ink-2);
    font-size: var(--t-sm);
    font-weight: 400;
    text-align: left;
  }
}

/* ── billing ── */
/* Beløp: høgrejustert med tabulære siffer, så kolonna kan lesast nedover. */
.billing-page th.num,
.billing-page td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.billing-page td.num strong { color: var(--ink); font-weight: 600; }

/* Kort i rutenett: rutenettet eig avstanden, ikkje korta. */
.billing-grid > .admin-section { margin-bottom: 0; }

/* Fakturahistorikk: tittel over tabellen, same luft som kort. */
.billing-history { margin-bottom: var(--s-6); }
.billing-history > .panel-h { margin-bottom: var(--s-3); }

.billing-block-link { display: inline-block; }

/* Abonnement: rader med skiljeline. */
.billing-list { margin: 0; padding: 0; list-style: none; }
.billing-list > li { padding: var(--s-3) 0; border-top: 1px solid var(--line); }
.billing-list > li:first-child { padding-top: 0; border-top: 0; }
.billing-list > li:last-child { padding-bottom: 0; }
.billing-list .row-between { margin-bottom: 2px; }

/* Treff frå Fiken-søket. */
.billing-results { overflow: hidden; border: 1px solid var(--line); border-radius: var(--ctl-r); }
.billing-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--line);
}
.billing-result:first-child { border-top: 0; }
.billing-result-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.billing-result-text strong { color: var(--ink); font-size: var(--t-sm); }

/* «Send»-skjemaet i fakturatabellen: liten select ved sida av knappen. */
.row.billing-send { flex-wrap: nowrap; gap: var(--s-1); }
.row.billing-send > select { flex: 0 1 auto; width: auto; min-height: var(--control-h-sm); padding-block: 0; }

.billing-page .pagination { flex-wrap: wrap; }

@media (max-width: 600px) {
  .billing-result { flex-wrap: wrap; }
  .billing-page .admin-header > .button-row { width: 100%; }
}

/* ── monitoring ── */
/* Drift → Overvaking (views/admin/monitoring/*). Berre token, ingen fargeverdiar. */

/* Varsel som er lenkje (opne hendingar). */
a.alert.mon-alert-link { font-weight: 600; text-decoration: none; }
a.alert.mon-alert-link:hover { border-color: currentColor; }
.alert a:not([class]) { color: inherit; text-decoration-color: currentColor; }

/* Tilbake-lenkje rett under fanene. */
.mon-back { margin: calc(-1 * var(--s-3)) 0 var(--s-4); }

/* Overskrift over ei gruppe KPI-kort. */
.mon-group-h { margin: 0 0 var(--s-3); color: var(--muted); font-size: var(--t-sm); font-weight: 600; }
.mon-footnote { margin: calc(-1 * var(--s-3)) 0 var(--s-6); color: var(--muted); font-size: var(--t-xs); }
.stat-card .stat-label .status-pill { font-size: var(--t-xs); }
.stat-card .mon-stat-badge { margin-top: 10px; }
.stat-sub { color: var(--muted); font-size: var(--t-xs); font-weight: 500; letter-spacing: 0; }

/* Større statusmerke for tilstanden øvst på ei detaljside. */
.status-pill.mon-pill-lg { min-height: 28px; padding: 2px 12px; font-size: var(--t-sm); }

/* Kort-rutenett (to kolonner, éi på smal skjerm). */
.mon-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4);
  align-items: start;
  margin-bottom: var(--s-6);
}
.mon-cards > .form-card,
.mon-cards > .dash-card { margin: 0; }

/* Lister med rader: hendingar, SMS, vakt, kundekontaktar. */
.mon-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.mon-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-3);
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: inherit;
  font-size: var(--t-sm);
}
.mon-list > .mon-item:first-child { border-top: 0; padding-top: 0; }
.mon-list > .mon-item:last-child { padding-bottom: 0; }
.dash-card-body > .mon-list > .mon-item:first-child { padding-top: 0; }
a.mon-item { text-decoration: none; }
a.mon-item:hover .mon-item-title { text-decoration: underline; text-underline-offset: 3px; }
.mon-item-main { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.mon-item-title { color: var(--ink); font-weight: 600; }
.mon-item-meta { display: block; margin-top: 2px; color: var(--muted); font-size: var(--t-xs); }
.mon-item-meta.row { display: flex; margin-top: 4px; }
.mon-item .button-row { flex: none; }

/* Skjema i rutenett (ny monitor, monitor-innstillingar, overvakingsinnstillingar). */
.mon-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-4);
}
.mon-form-grid > label,
.mon-inline-form > label:not(.inline-check) { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.mon-form-grid .form-hint { margin-top: 0; font-weight: 400; }
.mon-span-all { grid-column: 1 / -1; }
.mon-checks { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-6); }
.mon-fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.mon-fieldset legend { margin-bottom: 6px; padding: 0; color: var(--ink-2); font-size: var(--t-sm); font-weight: 600; }
.mon-fieldset .inline-check { display: flex; margin-bottom: var(--s-1); }

/* Skjema på éi line som brest om (legg til vakt, test-SMS). */
.mon-inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); margin-top: var(--s-4); }
.mon-inline-form > label:not(.inline-check) { flex: 1 1 160px; min-width: 0; }
.mon-inline-form > .inline-check { min-height: var(--control-h); }
.mon-inline-form > button,
.mon-filter > button { min-height: var(--control-h); }

/* Ny monitor: utfaldbart kort. */
.mon-details > summary {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--control-h-sm);
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
.mon-details > summary::-webkit-details-marker { display: none; }
.mon-details > summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--dur) var(--ease);
}
.mon-details[open] > summary::before { transform: rotate(45deg); }
.mon-details[open] > summary { margin-bottom: var(--s-4); }

/* Periodeval for historikk. */
.mon-range .btn-sm[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

/* Sjekk-historikk: ein stolpe per sjekk. Høg = oppe, låg = feil (form, ikkje berre farge). */
.mon-beats { display: flex; align-items: flex-end; gap: 2px; height: 40px; overflow: hidden; }
.mon-beat { flex: 1; min-width: 3px; border-radius: 1px; }
.mon-beat.is-up { height: 100%; background: var(--ok); }
.mon-beat.is-down { height: 55%; background: var(--danger); }

/* Nøkkeltal på ei hending. */
.mon-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--s-4) var(--s-6);
  margin: 0;
}
.mon-facts dt { color: var(--muted); font-size: var(--t-xs); font-weight: 600; }
.mon-facts dd { margin: 2px 0 0; color: var(--ink); font-size: var(--t-sm); overflow-wrap: anywhere; }

.mon-pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Tidsline. */
.mon-timeline { margin: 0; padding: 0; list-style: none; }
.mon-timeline > li {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: var(--s-3);
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: var(--t-sm);
}
.mon-timeline > li:first-child { border-top: 0; padding-top: 0; }
.mon-timeline time { color: var(--muted); font-size: var(--t-xs); font-variant-numeric: tabular-nums; }
.mon-event-detail { display: block; margin-top: 2px; color: var(--muted); overflow-wrap: anywhere; }
.mon-event-detail.is-note { color: var(--ink); white-space: pre-wrap; }

/* Tilleggsliner i tabellceller. */
.mon-cell-sub { display: block; margin-top: 4px; color: var(--muted); font-size: var(--t-xs); }
.mon-cell-error { display: block; margin-top: 4px; color: var(--danger); font-size: var(--t-xs); }
.mon-text-danger { color: var(--danger); }
.mon-break { overflow-wrap: anywhere; word-break: break-word; }

@media (max-width: 940px) {
  .mon-cards { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .mon-form-grid,
  .mon-facts { grid-template-columns: 1fr; }
  .mon-inline-form > label:not(.inline-check) { flex-basis: 100%; }
  .mon-inline-form > button { flex: 1 1 100%; }
  .mon-filter > input,
  .mon-filter > select { flex: 1 1 140px; max-width: none; }
  .mon-timeline > li { grid-template-columns: 1fr; gap: 2px; }
  .mon-item .button-row { width: 100%; }
}

/* ── infra ── */
/* Kontokort (Gigahost/Cloudflare): namn + statusmerke, detaljar under.
   Eiga klasse fordi .form-card + .form-card gir margin-top som skeiplar eit rutenett. */
.infra-cards { margin-bottom: var(--s-6); }
.infra-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  min-width: 0;
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--card-r);
  background: var(--surface);
}
.infra-card.is-error { border-color: var(--danger-line); }
.infra-card h2 { margin: 0; font-size: var(--t-base); font-weight: 650; overflow-wrap: anywhere; }
.infra-card p { margin: 0; color: var(--muted); font-size: var(--t-sm); overflow-wrap: anywhere; }
.infra-card .row-between { margin-bottom: var(--s-1); }

/* Seksjonar under kvarandre på infra-sidene. */
.infra-block { margin-bottom: var(--s-8); }
.infra-block:last-child { margin-bottom: 0; }

/* Lange verdiar (DNS-innhald, regeluttrykk) blir korta av på brei skjerm. */
.infra-trunc { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Brytar (proxy, regel på/av): statusmerket er sjølve knappen. */
.infra-toggle { cursor: pointer; min-height: 28px; transition: border-color var(--dur) var(--ease); }
.infra-toggle:hover { border-color: currentColor; }
.infra-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Skjema i tabellceller (reversdns) og ny DNS-record. */
.infra-inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0; }
.infra-inline-form input[type="text"] { flex: 1 1 180px; width: auto; min-width: 0; }
.infra-dns-form {
  display: grid;
  grid-template-columns: minmax(96px, 120px) minmax(0, 1fr) minmax(0, 1.4fr) minmax(72px, 96px) auto auto;
  gap: var(--s-3);
  align-items: end;
}
.infra-dns-form .form-group { margin: 0; min-width: 0; }
.infra-dns-form .inline-check { min-height: var(--control-h); }

/* Backup: skjema i «Testrestore / restore» og lister i tabellceller. */
.infra-details-form { margin: var(--s-2) 0; }
.infra-cell-list { margin: 0; padding-left: 1.1rem; }
.admin-table details summary { cursor: pointer; color: var(--ink-2); font-weight: 600; }

@media (max-width: 940px) {
  .infra-dns-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .infra-dns-form { grid-template-columns: 1fr; }
  .infra-dns-form .btn-primary { width: 100%; }
  .infra-trunc { max-width: none; white-space: normal; overflow-wrap: anywhere; }
  .infra-inline-form { width: 100%; }
  .infra-block { margin-bottom: var(--s-6); }
}
@media (pointer: coarse) {
  .infra-toggle { min-height: var(--tap-min); }
}

/* ============================================================================
   ARBEIDSFLYT (2026-11) — felles mønster for admin og kundeportal
   ----------------------------------------------------------------------------
   Éin måte å gjere kvar ting på, uansett side:
     .seg-tabs       filtrer ei liste på status (med tal), eitt klikk
     .row-clickable  heile rada opnar saka/kunden (views/_app-behaviors.ejs)
     .cell-main/sub  to liner i éi celle i staden for ei ekstra kolonne
     .detail-grid    innhald til venstre, eigenskapar og handlingar til høgre
     .composer       svarfelt med «send» + «send og merk løyst»
     .tabbar         fast botnlinje på telefon
   Berre systemtoken (system.css) — ingen fargeverdiar her.
   ========================================================================== */

/* ---- Skjult når JS tek over (filter som sender seg sjølve) ---- */
.js .js-hide { display: none; }

/* ---- Sidemeny: grupper som kan faldast saman ---- */
.nav-group { margin-top: var(--s-3); }
.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - var(--s-2));
  min-height: 28px;
  margin: 0 var(--s-1) 2px;
  padding: 0 var(--s-2);
  border-radius: var(--ctl-r);
  text-align: left;
  cursor: pointer;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.nav-group-toggle > span:first-child { flex: 1; }
.nav-group-toggle:hover { background: var(--surface-2); color: var(--ink); }
.nav-group-caret { display: grid; place-items: center; width: 14px; height: 14px; transition: transform .16s var(--ease); transform: rotate(-90deg); }
.nav-group-caret svg { width: 12px; height: 12px; }
.nav-group.closed .nav-group-caret { transform: rotate(180deg); }
.nav-group.closed .nav-group-items { display: none; }
/* Noko i ei samanfalda gruppe krev merksemd: rombe, ikkje berre farge. */
.nav-group-dot { display: none; width: 7px; height: 7px; border-radius: 1px; background: var(--danger); transform: rotate(45deg); }
.nav-group.closed .nav-group-dot { display: block; }
html.sidebar-collapsed .nav-group-toggle { height: 1px; min-height: 0; width: auto; margin: var(--s-3) var(--s-2); padding: 0; overflow: hidden; background: var(--line); color: transparent; pointer-events: none; }
html.sidebar-collapsed .nav-group.closed .nav-group-items { display: block; }

/* ---- «Ny»-menyen i topplinja ---- */
.quick-new { position: relative; }
.quick-new > summary { list-style: none; cursor: pointer; gap: 6px; min-height: 36px; padding: 0 12px 0 10px; }
.quick-new > summary::-webkit-details-marker { display: none; }
.quick-new-btn svg { width: 16px; height: 16px; }
.quick-new-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--card-r);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.quick-new-menu a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--ctl-r);
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 500;
}
.quick-new-menu a:hover, .quick-new-menu a:focus-visible { background: var(--surface-2); color: var(--ink); }
.topbar-cta { min-height: 36px; }

/* ---- Statusfaner over lister ---- */
.seg-tabs {
  display: flex;
  gap: var(--s-1);
  margin-bottom: var(--s-4);
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  margin-bottom: -1px;
  padding: 10px 12px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 500;
  white-space: nowrap;
}
.seg-tab:hover { color: var(--ink); }
.seg-tab.active { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
.seg-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--t-micro);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.seg-tab.active .seg-count { background: var(--accent-soft); color: var(--accent-ink); }

.search-bar input[type="search"], .filter-bar input[type="search"] { flex: 1 1 260px; max-width: 420px; }

/* ---- Lister: klikkbare rader, to liner i ei celle ---- */
tr.row-clickable { cursor: pointer; }
.cell-main { display: block; }
.cell-plain { color: var(--ink-2); font-weight: 500; }
.cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: var(--t-xs); font-weight: 400; overflow-wrap: anywhere; }
.cell-preview { max-width: 46ch; color: var(--muted); }
/* Rada ventar på oss: tjukk kantlinje + feit tittel (form, ikkje berre farge). */
.admin-table tr.row-attention > td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.admin-table tr.row-attention .cell-main { font-weight: 700; }
a.badge, a.status-pill { text-decoration: none; }
a.badge:hover, a.status-pill:hover { border-color: currentColor; }

/* ---- Detaljside: innhald + sidefelt ---- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s-6); align-items: start; }
.detail-main { min-width: 0; }
.detail-main > .case-thread { margin-top: 0; }
.detail-aside { position: sticky; top: calc(var(--topbar-h) + var(--s-4)); display: flex; flex-direction: column; gap: var(--s-4); }
.aside-card { padding: var(--s-5); border: 1px solid var(--line); border-radius: var(--card-r); background: var(--surface); }
.aside-h { margin: 0 0 var(--s-3); color: var(--muted); font-size: var(--t-xs); font-weight: 600; }
.aside-sub { margin: var(--s-4) 0 var(--s-2); color: var(--muted); font-size: var(--t-xs); font-weight: 600; }
.aside-strong { margin: 0; color: var(--ink); font-weight: 600; }
.aside-strong a, .detail-header-meta a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.aside-strong a:hover, .detail-header-meta a:hover { color: var(--ink); text-decoration-color: currentColor; }
.aside-line { margin: 2px 0 var(--s-3); font-size: var(--t-sm); overflow-wrap: anywhere; }
.aside-line:last-child { margin-bottom: 0; }
.aside-fields .form-group { margin-bottom: var(--s-3); }
.aside-fields label { display: block; margin-bottom: 4px; color: var(--ink-2); font-size: var(--t-xs); font-weight: 600; }
.aside-fields select { width: 100%; }
.aside-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--line); }
.aside-list { display: flex; flex-direction: column; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
.aside-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px var(--s-2); font-size: var(--t-sm); }
.aside-list a { color: var(--ink); font-weight: 500; }
.aside-list a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- Svarfelt ---- */
.composer textarea { min-height: 112px; resize: vertical; }
.composer-actions { gap: var(--s-2) var(--s-3); }
.kbd-hint { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; color: var(--muted); font-size: var(--t-xs); }
.kbd-hint kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: inherit;
  font-size: var(--t-micro);
  font-weight: 600;
}
@media (pointer: coarse) { .kbd-hint { display: none; } }
.empty-state .inline-form { display: block; margin-top: var(--s-3); }

/* ---- Oppsummering øvst på kundekortet ---- */
.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin-bottom: var(--s-6); }
.summary-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--card-r);
  background: var(--surface);
  color: var(--ink-2);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.summary-tile:hover { border-color: var(--line-strong); background: var(--surface-2); }
.summary-tile strong { color: var(--ink); font-size: var(--t-xl); font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.summary-tile span { font-size: var(--t-sm); font-weight: 500; }
.summary-tile small { color: var(--muted); font-size: var(--t-xs); }
.summary-tile-attention { border-color: var(--warn-line); box-shadow: inset 3px 0 0 var(--warn); }
.summary-tile-attention small { color: var(--warn); font-weight: 600; }

/* ---- Oppmoding med éi handling ---- */
.callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border: 1px solid var(--line);
  border-radius: var(--card-r);
  background: var(--surface);
}
.callout > div { flex: 1 1 280px; min-width: 0; }
.callout .cust-lede { margin: 0; }
.callout-attention { border-color: var(--warn-line); background: var(--warn-soft); box-shadow: inset 3px 0 0 var(--warn); }
.callout-attention h2 { color: var(--warn); }
.callout-list { margin: 6px 0 0; padding: 0; list-style: none; font-size: var(--t-sm); }
.callout-list a { color: var(--ink); font-weight: 500; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

/* ---- Kundeportal ---- */
.yp-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3); }
.yp-ticket { padding-inline: var(--s-2); margin-inline: calc(var(--s-2) * -1); border-radius: var(--ctl-r); transition: background-color var(--dur) var(--ease); }
a.yp-ticket:hover { background: var(--surface-2); }
.yp-ticket strong { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.yp-ticket-attention { box-shadow: inset 3px 0 0 var(--warn); padding-left: var(--s-3); }
.yp-ticket-attention strong { font-weight: 700; }
.next-step { margin: 0 0 var(--s-5); padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--ctl-r); background: var(--surface); color: var(--ink-2); font-size: var(--t-sm); }
.next-step-attention { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); font-weight: 600; box-shadow: inset 3px 0 0 var(--warn); }
.compose { padding: 0; }
.compose > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--s-3); padding: var(--s-5); cursor: pointer; list-style: none; }
.compose > summary::-webkit-details-marker { display: none; }
.compose > summary::before { content: "+"; display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--ink); font-weight: 600; line-height: 1; }
.compose[open] > summary::before { content: "–"; }
.compose > summary h2 { margin: 0; font-size: var(--t-base); }
.compose > summary span { color: var(--muted); font-size: var(--t-sm); }
.compose > form { padding: 0 var(--s-5) var(--s-5); }

/* ---- Fast botnlinje på telefon ---- */
.tabbar { display: none; }

@media (max-width: 1180px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  /* Smal skjerm: tråden og svarfeltet først, eigenskapane under. */
  .detail-aside { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 940px) {
  .tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 35;
    display: flex;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
  }
  .tabbar-item {
    position: relative;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 52px;
    border-radius: var(--ctl-r);
    color: var(--muted);
    font-size: var(--t-micro);
    font-weight: 600;
  }
  .tabbar-item .icon { display: grid; place-items: center; width: 22px; height: 22px; }
  .tabbar-item .icon svg { width: 22px; height: 22px; }
  .tabbar-item.active { color: var(--ink); }
  .tabbar-item.active .icon { color: var(--accent-ink); }
  .tabbar-item.active::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: var(--accent); }
  .tabbar-badge {
    position: absolute;
    top: 4px;
    left: calc(50% + 6px);
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--r-pill);
    background: var(--danger);
    color: var(--surface);
    font-size: var(--t-micro);
    font-weight: 700;
    line-height: 1;
  }
  /* Botnlinja erstattar hamburgaren; innhaldet får luft under seg. */
  .app-body .hamburger { display: none; }
  .content-stage { padding-bottom: calc(var(--s-10) + 64px + env(safe-area-inset-bottom, 0px)); }
  .toast-stack { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .quick-new-btn span { display: none; }
  .quick-new > summary { padding: 0; width: 36px; justify-content: center; }
}

@media (max-width: 600px) {
  .summary-strip { gap: var(--s-2); }
  .summary-tile { padding: var(--s-3) var(--s-4); }
  .detail-header-actions { width: 100%; }
  .composer-actions > button { flex: 1 1 auto; }
  .aside-actions > *, .aside-actions .btn-sm { flex: 1 1 auto; justify-content: center; }
  .aside-actions form { display: flex; }
  .aside-actions form > button { flex: 1; }
  .callout { padding: var(--s-4); }
  .callout > .btn-primary, .callout > form, .callout > form > button { width: 100%; }
  .cell-preview { max-width: none; }
  /* Kort på telefon: tittelcella har to liner, så ho må stable seg. */
  .app-body table.stack-on-phone td:first-child:has(.cell-sub) { display: block; }
  .app-body table.stack-on-phone tr.row-attention { box-shadow: inset 3px 0 0 var(--warn); }
  .admin-table tr.row-attention > td:first-child { box-shadow: none; }
}

@media (pointer: coarse) {
  .seg-tab { min-height: var(--tap-min); }
  .quick-new-menu a, .nav-group-toggle { min-height: var(--tap-min); }
}

@media (prefers-reduced-motion: reduce) {
  .nav-group-caret, .summary-tile, .yp-ticket { transition: none; }
}

/* ---- Finpuss ---- */
.cell-stack { display: block; }
/* Filveljaren: same knapp som resten, ikkje nettlesaren sin grå standard. */
.app-body input[type="file"] { max-width: 100%; color: var(--muted); font-size: var(--t-sm); }
.app-body input[type="file"]::file-selector-button {
  min-height: var(--control-h-sm);
  margin-right: var(--s-3);
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--ctl-r);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: 600;
  cursor: pointer;
}
.app-body input[type="file"]::file-selector-button:hover { background: var(--surface-2); border-color: var(--ink-2); }
@media (max-width: 600px) {
  .kbd-hint { display: none; }
  .cell-stack { text-align: right; }
  /* Tomme verdiar («—», «Ingen») tek berre plass på eit telefonkort. */
  .app-body table.stack-on-phone td.cell-empty { display: none; }
}

/* Statusmerke i portalrader: forma og teksten skal stå på line, ikkje stablast
   (.yp-row span gjer alle span til kolonner). */
.yp-row .status-pill, .yp-ticket .status-pill, .yp-row .yp-badge, .yp-ticket .yp-badge { display: inline-flex; flex-direction: row; flex: none; }
.yp-ticket > span:first-child { flex: 1; }

/* ---- Driftsmeldingar i kundeportalen ---- */
.notice-list { display: flex; flex-direction: column; gap: var(--s-3); }
.notice { padding: var(--s-4) var(--s-5); border: 1px solid var(--line); border-radius: var(--card-r); background: var(--surface); box-shadow: inset 3px 0 0 var(--line-strong); }
.notice-feil { border-color: var(--danger-line); background: var(--danger-soft); box-shadow: inset 3px 0 0 var(--danger); }
.notice-advarsel { border-color: var(--warn-line); background: var(--warn-soft); box-shadow: inset 3px 0 0 var(--warn); }
.notice-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-3); }
.notice-head strong { color: var(--ink); font-weight: 650; }
.notice-head small { color: var(--muted); font-size: var(--t-xs); }
.notice p { margin: 6px 0 0; color: var(--ink-2); font-size: var(--t-sm); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- «Avansert»: sjeldan brukte felt bak eitt klikk ---- */
.cust-advanced > summary { display: inline-flex; align-items: center; min-height: var(--control-h-sm); color: var(--muted); font-size: var(--t-xs); font-weight: 600; cursor: pointer; }
.cust-advanced > summary:hover { color: var(--ink); }
.cust-advanced[open] > summary { margin-bottom: var(--s-2); }
.cust-advanced code { display: block; overflow-wrap: anywhere; }
.notice { display: block; }
.notice > p { display: block; }
.notice-head { width: 100%; }
