:root {
  --bg: #0b1020; --panel: #121a2e; --panel-2: #18223a; --line: #24304d; --text: #e6ebf5; --muted: #8b97b3;
  --accent: #3fb6fe; --accent-2: #00e0f0; --ok: #34d399; --warn: #fbbf24; --bad: #f87171; --purple: #a78bfa;
  --radius: 10px; --shadow: 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f5fa; --panel: #ffffff; --panel-2: #f0f3f9; --line: #dde3ee; --text: #111827; --muted: #5b6478;
    --shadow: 0 8px 24px rgba(15,23,42,.08); color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--accent); cursor: pointer; text-decoration: none; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; margin: 0; }
.hint { color: var(--muted); font-size: 12px; font-weight: normal; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--accent); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06121f; border: 0; font-weight: 600; }
button.danger { background: var(--bad); color: #1b0606; border: 0; font-weight: 600; }
button.warn { background: var(--warn); color: #1f1400; border: 0; font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
a.button { display: inline-block; border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 8px 14px; color: inherit; text-decoration: none; white-space: nowrap; }
a.button:hover { border-color: var(--accent); }
a.button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06121f; border: 0; font-weight: 600; }
a.button.ghost { background: transparent; }
a.button.small { padding: 4px 10px; font-size: 12px; }

.brand { display: flex; align-items: center; gap: 10px; letter-spacing: .08em; font-size: 13px; }
.brand small { display: block; color: var(--muted); letter-spacing: 0; font-size: 12px; }
.brand.big { font-size: 18px; margin-bottom: 8px; }
.logo { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; color: #06121f;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

.login { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% 10%, rgba(63,182,254,.15), transparent), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px;
  display: grid; gap: 14px; box-shadow: var(--shadow); }
.login-card label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
.login-card .pin { letter-spacing: .6em; font-size: 22px; text-align: center; }
.pw summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.pw input { width: 100%; }

.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; }
.side nav { display: grid; gap: 2px; }
.side nav a { color: var(--text); padding: 8px 10px; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; }
.side nav a:hover { background: var(--panel-2); }
.side nav a.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.me { margin-top: auto; display: grid; gap: 4px; font-size: 13px; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.pill.live { color: var(--accent-2); border-color: var(--accent-2); }
.pill.warn { background: var(--bad); color: #fff; border: 0; }

main { padding: 18px 22px 40px; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.top h1 { margin: 0; font-size: 20px; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--bad); }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.tile b { display: block; font-size: 28px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; min-width: 0; overflow-x: auto; }
.card h2 { font-size: 14px; margin: 0 0 10px; display: flex; gap: 8px; align-items: center; }
.card h3 { font-size: 13px; margin: 14px 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.row input { flex: 1 1 200px; }
.stack { display: grid; gap: 8px; }
.banner { background: rgba(251,191,36,.12); border: 1px solid var(--warn); color: var(--warn); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--panel-2); }
.table td.num { font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: currentColor; } .badge.warn { color: var(--warn); border-color: currentColor; }
.badge.bad { color: var(--bad); border-color: currentColor; } .badge.info { color: var(--accent); border-color: currentColor; }
.badge.staff { color: var(--purple); border-color: currentColor; }
.who { display: flex; align-items: center; gap: 8px; }
.who img { width: 22px; height: 22px; border-radius: 4px; image-rendering: pixelated; background: var(--panel-2); }
.list .item, .feed .item { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed { max-height: 340px; overflow: auto; }
.feed .item.new { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(248,113,113,.25); } to { background: transparent; } }

/* Map */
.map-view { display: grid; grid-template-columns: 240px 1fr; gap: 12px; height: calc(100vh - 90px); position: relative; }
.map-side { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow: auto; }
.map-side label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.map-side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 6px; }
.map-tools { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.plist .p { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.plist .p:hover, .plist .p.sel { background: var(--panel-2); }
.plist.dim .p { color: var(--muted); }
.map-stage { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #6f97cf; }
#map-canvas { position: absolute; inset: 0; }
.hud { position: absolute; left: 10px; bottom: 8px; font-size: 12px; pointer-events: none; text-shadow: 0 1px 2px #000; }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; color: var(--muted); pointer-events: none; }
.map-card { position: absolute; right: 12px; top: 12px; width: 280px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow); display: grid; gap: 8px; z-index: 5; }
.map-card .acts { display: flex; flex-wrap: wrap; gap: 6px; }
.label3d { font: 600 12px system-ui, sans-serif; color: #fff; background: rgba(8,12,24,.75); padding: 2px 6px; border-radius: 5px; white-space: nowrap;
  border: 1px solid rgba(255,255,255,.12); pointer-events: none; transform: translateY(-16px); }
.label3d.combat { border-color: var(--bad); }
.label3d .hp { color: #fca5a5; margin-left: 4px; font-weight: 400; }
.map-side label.check { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--text, inherit); font-size: 13px; }
.map-side input[type=range] { width: 100%; }
.hud.pointer { left: auto; right: 10px; bottom: 8px; color: #fff; background: rgba(8,12,24,.6); padding: 3px 8px; border-radius: 6px; }
.label3d.mob { font-weight: 500; font-size: 11px; background: rgba(8,12,24,.55); }
.label3d.alert { background: rgba(248,113,113,.85); }

/* Drawer */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; justify-content: flex-end; z-index: 20; }
.drawer-body { width: min(560px, 100%); height: 100%; overflow: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 18px; box-shadow: var(--shadow); }
.drawer-body h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.drawer-body h2 img { width: 40px; height: 40px; border-radius: 6px; image-rendering: pixelated; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13px; margin: 12px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.punish-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.punish-form textarea, .punish-form .full { grid-column: 1 / -1; }
.console { background: #05080f; color: #cbd5e1; border-radius: 8px; padding: 10px; height: 340px; overflow: auto; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: 10px 16px;
  border-radius: 10px; box-shadow: var(--shadow); z-index: 30; max-width: calc(100% - 32px); }
.toast.bad { border-color: var(--bad); color: var(--bad); }

@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .map-view { grid-template-columns: 1fr; height: auto; }
  .map-stage { height: 60vh; }
  .map-card { position: static; width: auto; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 10px; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
  .side nav a { padding: 5px 8px; font-size: 13px; }
  .me { margin: 0 0 0 auto; grid-auto-flow: column; align-items: center; gap: 8px; }
  main { padding: 14px 16px 30px; }
  .punish-form { grid-template-columns: 1fr; }
}

/* anticheat cases & evidence */
.clickable { cursor: pointer; }
.clickable:hover { background: rgba(127, 127, 127, .08); }
.charts { display: flex; flex-wrap: wrap; gap: 14px; }
.charts figure, figure { margin: 6px 0; }
figcaption { font-size: 12px; color: var(--muted, #889); margin-bottom: 4px; }
canvas { background: rgba(127, 127, 127, .06); border-radius: 8px; max-width: 100%; }
pre.raw { max-height: 420px; overflow: auto; font-size: 11px; white-space: pre-wrap; }
label.pick { display: block; padding: 4px 0; }
label.pick.inline { display: inline; font-size: 12px; font-weight: normal; margin-left: 8px; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }

/* live admin on the map */
.map-card { width: 330px; max-height: calc(100% - 24px); overflow: auto; }
.map-card .tabs { display: flex; gap: 6px; }
.map-card .case-row { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; display: grid; gap: 4px; cursor: pointer; }
.map-card .case-row:hover { border-color: var(--accent, #4facfe); }
.map-card .case-list { display: grid; gap: 6px; }
.map-card h4 { margin: 6px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted, #8a93a5); }
.map-card .logline { font-size: 12px; line-height: 1.35; word-break: break-word; }
.map-card .small { font-size: 12px; }
#map-acfeed { max-height: 220px; overflow: auto; }
#map-acfeed .p.feed { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; cursor: pointer; }
a.primary.sso { display: block; text-align: center; padding: .75rem 1rem; border-radius: 10px; background: #5865F2; color: #fff; font-weight: 600; text-decoration: none; margin: .5rem 0 1rem; }
