/* ── Lab design system ────────────────────────────────────────────────────────
   Mørkt tema · GitHub Dark-paletten
   Bruk: <link rel="stylesheet" href="lab.css">
   ──────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens ── */
:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface-2: #21262d;
  --border:    #30363d;
  --text:      #e6edf3;
  --muted:     #8b949e;

  --green:  #3fb950;
  --yellow: #d29922;
  --red:    #f85149;
  --blue:   #58a6ff;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 12px;
}

/* ── Reset ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Typografi ── */
h1 { font-size: 24px; font-weight: 700; color: #fff; }
h2 { font-size: 18px; font-weight: 600; color: #fff; }
h3 { font-size: 14px; font-weight: 600; color: #fff; }

.text-muted  { color: var(--muted); }
.text-green  { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red    { color: var(--red); }
.text-blue   { color: var(--blue); }

/* ── Layout ── */
main { padding: 24px; max-width: 1440px; margin: 0 auto; }

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.5px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.header-right { display: flex; align-items: center; gap: 16px; }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 32px 24px 24px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 48px;
}
footer a { color: var(--muted); }
footer a:hover { color: var(--text); }

/* ── Knapper ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--border); text-decoration: none; }

.btn-primary {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: #388bfd; border-color: #388bfd; }

.btn-danger {
  background: rgba(248,81,73,.15);
  border-color: rgba(248,81,73,.4);
  color: var(--red);
}
.btn-danger:hover { background: rgba(248,81,73,.25); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Statusprikk ── */
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.dot.online  { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.dot.offline { background: var(--red); }
.dot.alert   { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
}
.badge-green  { background: rgba(63,185,80,.15);  color: var(--green); }
.badge-yellow { background: rgba(210,153,34,.15); color: var(--yellow); }
.badge-red    { background: rgba(248,81,73,.15);  color: var(--red); }
.badge-blue   { background: rgba(88,166,255,.15); color: var(--blue); }
.badge-muted  { background: var(--surface-2);     color: var(--muted); }

/* ── Varselsbanner ── */
#alert-banner {
  background: rgba(248,81,73,.10);
  border-bottom: 1px solid rgba(248,81,73,.30);
  padding: 12px 24px;
  display: none;
}
#alert-banner.visible { display: block; }
#alert-banner h3 { font-size: 13px; color: var(--red); margin-bottom: 6px; }
.alert-item { font-size: 13px; padding: 2px 0; }

/* ── Feilmelding / Infoboks ── */
.error, .info-box {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.error {
  background: rgba(248,81,73,.12);
  border: 1px solid rgba(248,81,73,.35);
  color: var(--red);
}
.info-box {
  background: rgba(88,166,255,.10);
  border: 1px solid rgba(88,166,255,.30);
  color: var(--blue);
}

/* ── Oppsummeringsfliser ── */
.summary { display: flex; gap: 14px; margin-bottom: 28px; flex-wrap: wrap; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 22px;
  min-width: 110px;
}
.stat .val { font-size: 30px; font-weight: 700; line-height: 1; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ── Kort ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color .15s, box-shadow .15s;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.card.alerting { border-color: var(--yellow); }
.card.offline  { opacity: .55; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

/* ── Metrikk-rader ── */
.metric { margin-bottom: 11px; }
.metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.metric-row .val { color: var(--text); font-weight: 500; }
.bar-track { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; transition: width .4s; }
.bar-fill.ok   { background: var(--green); }
.bar-fill.warn { background: var(--yellow); }
.bar-fill.crit { background: var(--red); }

/* ── Tabell ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ── Skjemaelementer ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 80px; }

/* ── Modal ── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h2 { font-size: 16px; }
.close-btn {
  background: none; border: none;
  color: var(--muted); font-size: 20px;
  cursor: pointer; padding: 2px 6px; line-height: 1;
}
.close-btn:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Hjelpe-klasser ── */
.placeholder { text-align: center; color: var(--muted); padding: 64px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Kode-blokk ── */
pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
}
pre code { background: none; padding: 0; border-radius: 0; color: var(--text); }

code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--muted);
}

.log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-y: auto;
  max-height: 280px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.8;
}
.log-line       { color: var(--muted); }
.log-line.ok    { color: var(--green); }
.log-line.warn  { color: var(--yellow); }
.log-line.err   { color: var(--red); }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 13px;
  min-width: 220px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  pointer-events: auto;
  animation: toast-in .18s ease;
}
.toast.success { border-color: rgba(63,185,80,.45);  }
.toast.error   { border-color: rgba(248,81,73,.45);  }
.toast.warning { border-color: rgba(210,153,34,.45); }
.toast-icon.success { color: var(--green); }
.toast-icon.error   { color: var(--red); }
.toast-icon.warning { color: var(--yellow); }
.toast-icon.info    { color: var(--blue); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 8px 16px;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Checkbox & Radio ── */
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.check input[type="checkbox"],
.check input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s, border-color .12s;
  position: relative;
}
.check input[type="radio"] { border-radius: 50%; }
.check input[type="checkbox"]:checked,
.check input[type="radio"]:checked { background: var(--blue); border-color: var(--blue); }
.check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}
.check input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #fff;
}
.check input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.check input:disabled { opacity: .4; cursor: not-allowed; }
.check:has(input:disabled) { opacity: .4; cursor: not-allowed; }

/* ── Toggle ── */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.toggle input { display: none; }
.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  position: relative;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.toggle-track::after {
  content: "";
  position: absolute;
  left: 2px; top: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s, background .15s;
}
.toggle input:checked + .toggle-track {
  background: rgba(88,166,255,.20);
  border-color: var(--blue);
}
.toggle input:checked + .toggle-track::after {
  transform: translateX(16px);
  background: var(--blue);
}
.toggle:has(input:disabled) { opacity: .4; cursor: not-allowed; }

/* ── Responsiv ── */
@media (max-width: 600px) {
  main { padding: 14px; }
  .grid { grid-template-columns: 1fr; }
  .summary { gap: 10px; }
}
