:root {
  --bg: #0d1117;
  --panel: #151b24;
  --panel-2: #1b2330;
  --line: #273142;
  --text: #e6ebf2;
  --muted: #8b97a8;
  --accent: #d4a73a;
  --accent-ink: #1a1405;
  --blue: #4c8dff;
  --ok: #3fb97a;
  --warn: #e2a33b;
  --bad: #e5534b;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
small, .muted { color: var(--muted); }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* ---------- top bar ---------- */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; min-height: 58px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.brand-badge { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
/* Logo is white artwork; public/logo.png can be swapped for any size, it scales to fit. */
.brand-logo { height: 28px; width: auto; max-width: 56px; object-fit: contain; }
.login-logo { display: block; width: 100%; max-width: 260px; height: auto; margin: 0 auto 20px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--muted); padding: 7px 11px; border-radius: 7px; font-weight: 500; position: relative; }
.nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav a.on { color: var(--text); background: var(--panel-2); }
.nav .count { background: var(--bad); color: #fff; border-radius: 99px; font-size: .7rem; padding: 0 6px; margin-left: 4px; }
.user { display: flex; align-items: center; gap: 10px; }
.user img, .avatar-fallback { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); }
.user-name { font-size: .9rem; line-height: 1.2; }
.user-name small { display: block; }

/* ---------- layout ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 860px) { .grid-side { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card + .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- stats ---------- */
.stat { background: var(--panel-2); border-radius: 8px; padding: 12px 14px; }
.stat b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }

/* ---------- pills / badges ---------- */
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok, .pill.active, .pill.completed, .pill.synced { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.pill.warn, .pill.probation, .pill.requested, .pill.pending, .pill.loa { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.pill.bad, .pill.suspended, .pill.terminated, .pill.denied, .pill.failed, .pill.disciplinary { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.pill.gold, .pill.commendation, .pill.command { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.pill.blue, .pill.fto, .pill.supervisor { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 45%, transparent); background: color-mix(in srgb, var(--blue) 10%, transparent); }
.callsign { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.rank-row td { background: var(--panel-2); color: var(--accent); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; padding: 7px 10px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- progress ---------- */
.bar { height: 6px; border-radius: 99px; background: var(--panel-2); overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--ok); }

/* ---------- forms ---------- */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=number], select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 7px;
  padding: 9px 11px; font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: .88rem; min-height: 380px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--blue) 60%, transparent); outline-offset: 0; border-color: var(--blue); }
.field { margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .95rem; }
.check input { width: 16px; height: 16px; }

.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #04130b; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; padding: 12px 22px; font-size: 1rem; }
.inline { display: inline; }

/* ---------- flash ---------- */
.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.flash.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.flash.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.list > li:first-child { padding-top: 0; }
.empty { color: var(--muted); text-align: center; padding: 22px 10px; }
.announcement h3 { margin-bottom: 2px; }
.prose p { white-space: pre-wrap; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: .9rem; }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.on:hover { color: var(--accent-ink); }

/* ---------- tests ---------- */
.question { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.question h3 { font-weight: 600; white-space: pre-wrap; }
.question .qnum { color: var(--accent); font-weight: 700; margin-right: 6px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; margin-top: 7px; cursor: pointer; color: var(--text); font-size: .95rem; }
.option:hover { border-color: var(--muted); }
.option input { margin-top: 4px; }
.option:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.option.correct { border-color: var(--ok); }
.option.wrong { border-color: var(--bad); }
.timer { position: sticky; top: 70px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 14px; }
.timer b { font-variant-numeric: tabular-nums; font-size: 1.2rem; }
.timer.low b { color: var(--bad); }
.result-score { font-size: 3rem; font-weight: 800; line-height: 1; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { max-width: 420px; width: 100%; text-align: center; padding: 34px 26px; }
.login .brand-badge { width: 56px; height: 56px; font-size: 1.1rem; margin: 0 auto 16px; border-radius: 14px; }

.char-list { display: grid; gap: 10px; }
.char { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }

details summary { cursor: pointer; color: var(--blue); font-weight: 600; }
details[open] summary { margin-bottom: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
