:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232d;
  --line: #2a3340;
  --text: #e6e9ee;
  --muted: #8a96a6;
  --accent: #e8912d;
  --accent-ink: #1a1206;
  --good: #3fb950;
  --bad: #f05d5e;
  --warn: #d9a400;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
h1 { font-size: 30px; margin: 4px 0 2px; line-height: 1.15; }
h2 { font-size: 20px; margin: 0 0 6px; }
h3 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .06em; color: #c7cfda; }
.mt { margin-top: 18px; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 800; }
.status-pill { display: flex; align-items: center; gap: 8px; margin-left: auto; padding: 4px 12px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; max-width: 50vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status-pill.on .dot { background: var(--good); box-shadow: 0 0 8px var(--good); }
.status-pill.off .dot { background: var(--bad); }

.tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel); overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 12px 14px; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

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

/* layout */
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.live-grid { grid-template-columns: 1.4fr 1fr; }
.span2 { grid-column: 1 / -1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.spacer { flex: 1; }

/* forms */
label { display: block; margin-bottom: 12px; color: #c7cfda; font-size: 14px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
label.check { display: flex; align-items: center; gap: 8px; }
input, select { width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line); background: #0b0e13; color: var(--text); font: inherit; }
label.inline input, label.inline select { width: auto; margin: 0; }
input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input.num { width: 64px; }
.card > input { margin-bottom: 8px; }
.pw { display: flex; gap: 6px; align-items: center; }
.pw input { flex: 1; }
details summary { cursor: pointer; color: var(--muted); margin-bottom: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3d4856; background: #222b37; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: #5a2a2b; }
.btn.danger:hover { background: #2b1718; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; font-weight: 500; }

/* live */
.eyebrow { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.stats > div { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.stat { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.connect { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.connect code { background: #0b0e13; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); }
.offline { text-align: center; padding: 40px; margin-bottom: 16px; border-color: #5a2a2b; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid #202833; vertical-align: middle; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table .empty { text-align: center; color: var(--muted); padding: 22px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--panel-2); color: var(--muted); margin-left: 6px; vertical-align: 1px; }
.team-Red { color: #ff6b6b; } .team-Blue { color: #6ba8ff; } .team-Green { color: #6bd47a; } .team-Gold { color: #f2c94c; }
.say { margin-top: 14px; }
.say input, #consoleForm input { margin: 0; }

/* rotation */
.maplist { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow-y: auto; }
.maplist li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; margin-bottom: 4px; background: var(--panel-2); border: 1px solid transparent; border-radius: 7px; }
#rotList li { cursor: grab; counter-increment: rot; }
#rotList { counter-reset: rot; }
#rotList li::before { content: counter(rot); color: var(--muted); width: 22px; font-variant-numeric: tabular-nums; font-size: 13px; }
#rotList li.dragging { opacity: .4; }
#rotList li.over { border-color: var(--accent); }
.maplist li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.maplist li .acts { display: flex; gap: 4px; }
.available li { cursor: pointer; }
.available li:hover { border-color: #3d4856; }
.available li.in { opacity: .45; }
#rotSearch { margin: 0 0 10px; }

/* mutators */
.mutators { columns: 3 220px; column-gap: 24px; }
.mutators label { break-inside: avoid; margin-bottom: 8px; }
.mutators .order { color: var(--accent); font-size: 12px; margin-left: auto; }

/* console */
.console { background: #07090c; border: 1px solid var(--line); border-radius: 8px; padding: 12px; height: 58vh; overflow-y: auto; margin: 0 0 12px; white-space: pre-wrap; word-break: break-word; font: 13px/1.5 ui-monospace, Consolas, monospace; color: #cdd6e0; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; }
.login-card .brand { margin-bottom: 20px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 50; max-width: calc(100vw - 32px); }
.toast.err { border-color: var(--bad); color: #ffb4b4; }
.toast.ok { border-color: #2d6a3a; }

@media (max-width: 900px) {
  .grid.two, .grid.three, .live-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  main { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .brand-name { display: none; }
  .table th:nth-child(5), .table td:nth-child(5) { display: none; }
}
