:root {
  --bg: #0b0b10;
  --panel: #13131b;
  --panel-2: #1a1a25;
  --panel-3: #222230;
  --line: #2a2a3a;
  --text: #ececf2;
  --muted: #9b9bb0;
  --faint: #6c6c82;
  --accent: #7c5cff;
  --accent-2: #a28dff;
  --accent-soft: rgba(124, 92, 255, 0.16);
  --danger: #ff4d61;
  --danger-soft: rgba(255, 77, 97, 0.15);
  --ok: #2fd18f;
  --warn: #ffb020;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
p { margin: 0; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
code, .mono { font-family: var(--mono); font-size: 12px; }
[hidden] { display: none !important; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s; }
.btn:hover { background: var(--panel-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #8d71ff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 15px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn.block { width: 100%; }
.btn svg { flex: none; }

/* inputs */
input[type=text], input[type=password], input[type=email], input[type=number], input[type=url], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; height: 36px; padding: 0 11px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; outline: none;
}
textarea { height: auto; min-height: 90px; padding: 10px 11px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
label.field > span { font-weight: 550; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.gap-s { gap: 6px; }
.gap-l { gap: 18px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] { width: 36px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }

/* switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; user-select: none; font-size: 13px; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 99px; background: var(--panel-3); border: 1px solid var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }

/* segmented control */
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button { height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--panel-3); color: var(--text); }

/* cards & lists */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.pad-l { padding: 22px; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel-3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: rgba(47, 209, 143, .14); color: var(--ok); }
.badge.warn { background: rgba(255, 176, 32, .14); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.dot.live { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); animation: pulse 1.4s infinite; }
.dot.ok { background: var(--ok); }
@keyframes pulse { 50% { opacity: .5; } }
.empty { padding: 30px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.progress { height: 6px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { flex: none; height: 38px; padding: 0 12px; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 550; cursor: pointer; border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 6px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); }

/* toasts */
#toasts { position: fixed; top: 14px; right: 14px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 28px)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 13px; animation: slidein .2s ease-out; display: flex; gap: 10px; align-items: flex-start; }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast.ok { border-left-color: var(--ok); }
.toast b { display: block; margin-bottom: 2px; }
.toast button { margin-left: auto; }
@keyframes slidein { from { transform: translateY(-6px); opacity: 0; } }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(5, 5, 10, .66); backdrop-filter: blur(3px); z-index: 900; display: grid; place-items: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.modal .body { padding: 10px 18px 6px; display: grid; gap: 14px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px 18px; }
.modal.wide { width: min(820px, 100%); }

/* app shell (dashboard) */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; font-weight: 700; font-size: 16px; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: url(/favicon.svg) center/cover; flex: none; }
.nav { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 550; cursor: pointer; border: 0; background: none; font: inherit; text-align: left; }
.nav:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav.on { background: var(--panel-2); color: var(--text); }
.main { padding: 26px 32px 60px; max-width: 1240px; width: 100%; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-head:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.thumb { aspect-ratio: 16/9; border-radius: var(--radius-sm); background: var(--panel-2) center/cover no-repeat; display: grid; place-items: center; color: var(--faint); overflow: hidden; }
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > .item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.list > .item:last-child { border-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .brand { padding: 0 8px 0 0; width: 100%; }
  .main { padding: 18px 16px 60px; }
}

/* centred auth/lobby pages */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
