:root {
  /* Mørk base — sort med dyb rød undertone */
  --bg: #0d0203;
  --bg-soft: #160607;
  --bg2: #160607;                 /* alias */
  --panel: #1a0a0b;
  --panel-elevated: #220d0f;
  --panel-2: #220d0f;             /* alias */
  --panel-border: #3a1417;

  /* Dyb blank lakrød / vinrød accent */
  --accent: #9b0000;
  --accent-hover: #b30000;
  --accent2: #b30000;             /* alias til gradienter */
  --accent-soft: #3b0708;
  --accent-muted: #6f1114;
  --accent-glow: rgba(155, 0, 0, 0.35);
  --accent-rgb: 155, 0, 0;

  /* OK-status: diskret, neutral (IKKE grøn) */
  --ok: #c9a1a4;
  --ok-bg: #211012;
  --ok-border: #4a1a1d;

  --danger: #d4141a;
  --err: #d4141a;                 /* alias */
  --warn: #d88918;
  --warning: #d88918;

  --text: #f4eeee;
  --muted: #a89494;
  --text-muted: #a89494;

  --shadow: 0 16px 46px rgba(0, 0, 0, 0.62);
  --glow: 0 0 30px rgba(155, 0, 0, 0.38);
  --sheen: linear-gradient(180deg, var(--panel-elevated), var(--panel));
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 640px at 8% -12%, rgba(155, 0, 0, 0.26), transparent 60%),
    radial-gradient(1000px 560px at 100% -4%, rgba(120, 0, 0, 0.20), transparent 56%),
    radial-gradient(820px 520px at 50% 122%, rgba(155, 0, 0, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg-soft));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #d61a1a, var(--accent) 55%, #5e0000);
  box-shadow: 0 0 16px rgba(155, 0, 0, 0.85), inset 0 1px 2px rgba(255,255,255,0.25);
}

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
  background: rgba(13, 2, 3, 0.78);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.freshness { color: var(--muted); font-size: 13px; }
.freshness.stale { color: var(--warn); }

.btn-ghost {
  color: var(--text); text-decoration: none;
  border: 1px solid var(--panel-border); background: var(--panel);
  border-radius: 10px; padding: 7px 13px; font-size: 13px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: var(--panel-elevated); border-color: var(--accent); }

main { padding: 28px; max-width: 1280px; margin: 0 auto; }

/* ---- summary ---- */
.summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 26px;
}
.stat {
  background: var(--sheen); border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow);
}
.stat-val { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.stat-note { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 8px; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat-online .stat-val { color: var(--ok); }
.stat-registering .stat-val { color: var(--warn); }
.stat-offline .stat-val { color: var(--danger); }

/* ---- grid ---- */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.card {
  background: var(--sheen); border: 1px solid var(--panel-border);
  border-radius: 18px; padding: 20px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent);
}
.card:hover { transform: translateY(-2px); border-color: var(--accent-muted); box-shadow: var(--shadow), var(--glow); }
.card-ok::before { background: linear-gradient(var(--ok-border), var(--ok-bg)); }
.card-warn::before { background: linear-gradient(var(--warn), #9c6312); }
.card-err::before { background: linear-gradient(var(--danger), #8f0e12); }
.card-muted::before { background: linear-gradient(var(--accent-muted), var(--accent-soft)); }

.card-top { display: flex; align-items: center; justify-content: space-between; }
.jbadge {
  font-weight: 700; font-size: 12px; letter-spacing: 0.06em;
  color: #d6a3a6; background: var(--accent-soft);
  border: 1px solid var(--accent-muted); border-radius: 8px; padding: 3px 9px;
}
.pill { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.pill-ok { color: var(--ok); background: var(--ok-bg); border: 1px solid var(--ok-border); }
.pill-warn { color: var(--warn); background: rgba(216,137,24,0.14); }
.pill-err { color: var(--danger); background: rgba(212,20,26,0.15); }
.pill-muted { color: var(--muted); background: rgba(168,148,148,0.12); }

.card-title { font-size: 15px; font-weight: 600; margin: 14px 0 8px; line-height: 1.3; }
.card-value { margin: 2px 0 8px; }
.big { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.big.actionable { color: var(--text); }
.big.clear { color: var(--ok); }
.big.muted { color: var(--muted); }
.card-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; line-height: 1.45; }
.card-detail {
  color: var(--muted); font-size: 12px; font-style: italic; margin: 10px 0 0;
  border-left: 2px solid var(--panel-border); padding-left: 10px; line-height: 1.45;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.chip {
  font-size: 11.5px; color: var(--muted);
  background: var(--accent-soft); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 3px 8px;
}
.chip b { color: var(--text); }

.drill { margin-top: 12px; }
.drill summary { cursor: pointer; color: #d6a3a6; font-size: 12.5px; user-select: none; }
.drill-scroll { max-height: 240px; overflow: auto; margin-top: 8px; }
.drill table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.drill th, .drill td {
  text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}
.drill th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--bg-soft); }

.footer { color: var(--muted); font-size: 12px; margin-top: 28px; text-align: center; }
.err-text { color: var(--danger); }
.empty { color: var(--muted); }
.empty code, .footer code { color: #d6a3a6; }

/* ---- page tag (Detaljer) ---- */
.page-tag {
  font-size: 12px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--panel-border); border-radius: 8px; padding: 3px 9px;
  background: var(--panel);
}

/* ---- forside: store stats ---- */
.bigstats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 18px;
}
.big-stat {
  background: var(--sheen); border: 1px solid var(--panel-border);
  border-radius: 18px; padding: 24px; box-shadow: var(--shadow);
}
.big-num { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1;
  text-shadow: 0 0 24px rgba(155, 0, 0, 0.30); }
.big-num.warn { color: var(--warn); }
.big-label { color: var(--muted); font-size: 14px; margin-top: 10px; }
.big-stat.clickable { cursor: pointer; transition: border-color .12s, transform .12s, box-shadow .12s; }
.big-stat.clickable:hover { border-color: var(--accent-muted); transform: translateY(-2px); box-shadow: var(--shadow), var(--glow); }
.caret { color: #d6a3a6; }

.drill-panel:empty { display: none; }
.drill-inner {
  background: var(--sheen); border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 16px 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.drill-head { color: var(--muted); font-size: 13px; margin-bottom: 10px; }

/* ---- forside: lagkager ---- */
.pies { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.pie-card {
  background: var(--sheen); border: 1px solid var(--panel-border);
  border-radius: 18px; padding: 22px; box-shadow: var(--shadow);
}
.pie-card h3 { margin: 0 0 16px; font-size: 15px; font-weight: 600; }
.pie-wrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.pie {
  width: 150px; height: 150px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 2px 12px rgba(255,255,255,0.08), inset 0 -8px 18px rgba(0,0,0,0.45), 0 8px 22px rgba(0,0,0,0.5);
}
.pie-hole {
  width: 96px; height: 96px; border-radius: 50%; background: var(--bg-soft);
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}
.pie-hole span { font-size: 26px; font-weight: 800; }
.pie-legend { font-size: 14px; line-height: 2; }
.pie-legend b { font-weight: 700; }
.pie-total { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 8px; }
.dot-a { background: var(--accent); }
.dot-b { background: rgba(255,255,255,0.18); }
.pie-na { color: var(--muted); font-size: 13px; padding: 40px 0; }

/* ---- forside: fordeling (bars) ---- */
.dist-card { grid-column: 1 / -1; }
.dist { display: flex; flex-direction: column; gap: 10px; }
.dist-row { display: grid; grid-template-columns: 90px 1fr 110px; align-items: center; gap: 12px; }
.dist-label { font-size: 13.5px; font-weight: 600; }
.dist-bar-wrap { background: rgba(0,0,0,0.4); border: 1px solid var(--panel-border); border-radius: 8px; height: 16px; overflow: hidden; }
.dist-bar {
  height: 100%; border-radius: 8px; min-width: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.18);
}
.dist-val { font-size: 13px; text-align: right; }
.dist-pct { color: var(--muted); font-size: 12px; margin-left: 4px; }

/* ---- login ---- */
.login-body { display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--sheen); border: 1px solid var(--panel-border);
  border-radius: 22px; padding: 40px 36px; width: 360px; box-shadow: var(--shadow), var(--glow);
  backdrop-filter: blur(10px); text-align: center; margin-top: 14vh;
}
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 14px; margin: 6px 0 22px; }
.code-input {
  width: 100%; padding: 13px 15px; font-size: 15px; margin-bottom: 14px;
  background: rgba(0,0,0,0.35); border: 1px solid var(--panel-border);
  border-radius: 12px; color: var(--text); outline: none;
}
.code-input:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%; padding: 13px; font-size: 15px; font-weight: 600; cursor: pointer;
  color: #fff; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-hover), var(--accent) 60%, #5e0000);
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.2), 0 6px 18px rgba(155,0,0,0.4);
  transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.12); }
.login-error { color: var(--danger); font-size: 13px; margin: 14px 0 0; }

@media (max-width: 720px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  main, .topbar { padding-left: 16px; padding-right: 16px; }
}
