/* Illusive Admin – rent, moderne grensesnitt med dag- og nattmodus.
   Temaet styres av data-theme på <html> (settes av js/theme.js). Uten valg følger det systemet. */
:root {
  --bg: #f4f5fa; --surface: #ffffff; --surface-2: #eef0f8; --surface-solid: #ffffff;
  --border: #e3e5f0; --border-strong: #ccd0e2;
  --text: #14162b; --text-2: #484d6a; --muted: #737893;
  --accent: #5a3df0; --accent-strong: #4a2fd8; --accent-ink: #ffffff; --accent-soft: #ecebff;
  --good: #168a4f; --warn: #a16207; --serious: #c2410c; --crit: #c8283c; --pink: #a21caf;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 43, .05), 0 8px 28px rgba(20, 22, 43, .08);
  --shadow-lg: 0 24px 70px rgba(20, 22, 43, .22);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: var(--font);
  --sidebar: 256px;
  --scrim: rgba(20, 22, 43, .45);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0c18; --surface: #14162a; --surface-2: #1c1f38; --surface-solid: #171a30;
  --border: #262948; --border-strong: #363a62;
  --text: #eceefb; --text-2: #b6bad8; --muted: #8387a9;
  --accent: #9d89ff; --accent-strong: #8470f5; --accent-ink: #130d33; --accent-soft: #262352;
  --good: #5fd398; --warn: #f2b65c; --serious: #fb9a62; --crit: #ff8aa0; --pink: #ec9bf5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
  --scrim: rgba(3, 3, 12, .65);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c18; --surface: #14162a; --surface-2: #1c1f38; --surface-solid: #171a30;
    --border: #262948; --border-strong: #363a62;
    --text: #eceefb; --text-2: #b6bad8; --muted: #8387a9;
    --accent: #9d89ff; --accent-strong: #8470f5; --accent-ink: #130d33; --accent-soft: #262352;
    --good: #5fd398; --warn: #f2b65c; --serious: #fb9a62; --crit: #ff8aa0; --pink: #ec9bf5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
    --scrim: rgba(3, 3, 12, .65);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; transition: background .25s, color .25s; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: 26px; line-height: 1.2; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 16px; text-decoration: none; color: var(--text); }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #3b1d9e, #7c4dff 55%, #e063d6); box-shadow: 0 4px 14px rgba(124, 77, 255, .35); }
.brand-mark svg { width: 19px; height: 19px; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav-group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 16px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500; position: relative; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; font-size: 12px; font-weight: 600; background: var(--accent); color: var(--accent-ink); padding: 0 7px; min-width: 20px; text-align: center; border-radius: 99px; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.me:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: linear-gradient(135deg, #7c4dff, #e063d6); color: #fff; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { width: 100%; padding-left: 38px; background: var(--surface); }
.topbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); }
.btn.menu-btn { display: none; }
.content { padding: 28px 28px 64px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); max-width: 70ch; }

/* ---------- Komponenter ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stat .label { font-size: 13px; font-weight: 500; color: var(--text-2); display: flex; align-items: center; gap: 9px; }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 8px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat .ico svg { width: 16px; height: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 550; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { border-color: color-mix(in srgb, var(--crit) 45%, transparent); color: var(--crit); background: color-mix(in srgb, var(--crit) 8%, var(--surface)); }
.btn.danger:hover { background: color-mix(in srgb, var(--crit) 15%, var(--surface)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }
.icon-btn { padding: 8px; }
.theme-toggle { width: 38px; height: 38px; padding: 0; border-radius: 50%; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; } .theme-toggle .moon { display: block; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; } :root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-toggle .sun { display: block; } :root:not([data-theme="light"]) .theme-toggle .moon { display: none; } }

input, select, textarea { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px; outline: none; width: 100%; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { min-height: 110px; resize: vertical; }
select option { background: var(--surface-solid); color: var(--text); }
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 550; color: var(--text-2); }
.form { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 10px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.nodot::before { display: none; }
.badge.good { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.badge.serious { color: var(--serious); background: color-mix(in srgb, var(--serious) 15%, transparent); }
.badge.crit { color: var(--crit); background: color-mix(in srgb, var(--crit) 14%, transparent); }
.badge.pink { color: var(--pink); background: color-mix(in srgb, var(--pink) 14%, transparent); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 13px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 550; }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar input { max-width: 280px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td .sub { display: block; font-size: 12.5px; color: var(--muted); }

.list { display: grid; }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 13px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--accent); flex: none; }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }

.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.col { background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius); padding: 12px; min-height: 200px; }
.col.drop { border-color: var(--accent); background: var(--accent-soft); }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 10px; font-weight: 600; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; cursor: grab; box-shadow: var(--shadow); }
.task:active { cursor: grabbing; }
.task h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding: 0 2px; border-bottom: 1px solid var(--border); position: relative; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.bar { width: 100%; max-width: 34px; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 2px; transition: filter .15s; }
.bar-col:hover .bar { filter: brightness(1.15); }
.bar-col .tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 4px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 2; }
.bar-col:hover .tip { opacity: 1; }
.bar-labels { display: flex; gap: 8px; padding: 6px 2px 0; }
.bar-labels span { flex: 1; text-align: center; font-size: 11.5px; color: var(--muted); }
.hbar { display: grid; grid-template-columns: 110px 1fr 40px; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 99px; }

.thread { display: grid; gap: 12px; max-height: 46vh; overflow-y: auto; padding: 4px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: var(--surface-2); }
.msg.staff { margin-left: auto; background: var(--accent-soft); border-radius: 16px 16px 4px 16px; }
.msg .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }

.modal-bg { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(4px); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: min(620px, 100%); max-height: 92vh; overflow-y: auto; background: var(--surface-solid); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 24px; animation: pop .18s; }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: grid; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500; animation: pop .2s; }
.toast.err { background: var(--crit); color: #fff; }

.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); cursor: pointer; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius); background: color-mix(in srgb, var(--warn) 13%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); margin-bottom: 18px; font-size: 14px; }
.banner.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.banner > svg { width: 20px; height: 20px; flex: none; color: var(--accent); }
.wiki-body { white-space: pre-wrap; color: var(--text-2); line-height: 1.7; max-width: 75ch; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.empty svg, .list-item svg { width: 18px; height: 18px; }

/* Innlogging */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; background: radial-gradient(900px 500px at 85% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%), radial-gradient(700px 500px at -5% 105%, color-mix(in srgb, #e063d6 14%, transparent), transparent 70%), var(--bg); }
.login .theme-toggle { position: absolute; top: 16px; right: 16px; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 34px; box-shadow: var(--shadow-lg); }
.login-card .brand { justify-content: center; padding-bottom: 4px; }
.login-card .brand-name { font-size: 28px; }
.login-tag { text-align: center; color: var(--text-2); font-size: 15px; margin: 0 0 24px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 18px 0 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.err-msg { color: var(--crit); font-size: 13px; font-weight: 500; min-height: 18px; }

.mobile-nav { display: none; } .scrim { display: none; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 60; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .app.open .sidebar { transform: none; }
  .app.open .scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 50; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 96px; }
  h1 { font-size: 22px; }
  .g2, .kanban { grid-template-columns: 1fr; }
  .toolbar input { max-width: none; }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; padding: 6px 4px; background: var(--surface); }
  table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 7px 10px; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; }
  table.responsive td:first-child { text-align: left; display: block; font-weight: 600; }
  table.responsive td:first-child::before { display: none; }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .mobile-nav a { display: grid; justify-items: center; gap: 2px; font-size: 11px; font-weight: 550; color: var(--muted); text-decoration: none; padding: 6px 0; }
  .mobile-nav a.active { color: var(--accent); }
  .mobile-nav svg { width: 21px; height: 21px; }
  .toast-wrap { bottom: 84px; left: 16px; right: 16px; }
  .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 480px) { .g4 { grid-template-columns: 1fr 1fr; gap: 10px; } .stat .value { font-size: 24px; } .card { padding: 15px; } }
