:root {
  --bg: #0f1216; --panel: #181d24; --panel2: #1f2630; --line: #2a333f;
  --text: #e6eaf0; --muted: #8b97a8; --accent: #4caf50; --accent2: #2e7d32;
  --danger: #e5484d; --warn: #f5a524; --info: #4c9aff;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 18px; font-size: 13px; }

header { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-size: 16px; white-space: nowrap; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 8px; cursor: pointer; font: inherit; white-space: nowrap; }
nav button:hover { color: var(--text); background: var(--panel2); }
nav button.active { color: #fff; background: var(--accent2); }
.who { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); display: inline-block; }
.dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.wait { background: var(--warn); }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 4px; word-break: break-word; }
.stat .sub { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row + .row { margin-top: 10px; }
.spacer { flex: 1; }

.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.danger { background: #3a1a1c; border-color: #6b2529; color: #ff9a9d; }
.btn.small { padding: 4px 10px; font-size: 13px; }

input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; min-width: 0; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.form .wide { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); }

.rules { display: grid; gap: 6px 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.rule { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.rule small { color: var(--muted); display: block; }
.rule input[type=number] { width: 90px; padding: 4px 8px; }
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 22px; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { left: 21px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
.tablewrap { overflow-x: auto; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; margin-right: 4px; background: var(--panel2); color: var(--muted); }
.badge.on { background: #173d1a; color: #7ee084; }
.badge.op { background: #3d3317; color: #f5c860; }
.badge.ban { background: #3a1a1c; color: #ff9a9d; }
.badge.wl { background: #17303d; color: #7cc4f0; }

.log { background: #0a0c0f; border: 1px solid var(--line); border-radius: 8px; padding: 10px; height: 55vh; overflow: auto;
  font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.log .warn { color: var(--warn); } .log .error { color: #ff7b7f; } .log .me { color: var(--info); }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card label { text-align: left; }
.logo { font-size: 40px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal .card { width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; margin: 0; }
.modal h3 { margin: 16px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; white-space: pre-wrap; word-break: break-word; }
.toast.bad { border-left-color: var(--danger); }

@media (max-width: 600px) { main { padding: 10px; } .stat .value { font-size: 18px; } }

/* на узких экранах вкладки идут отдельной строкой под шапкой */
@media (max-width: 820px) {
  header { gap: 8px 12px; }
  .who { margin-left: auto; }
  nav { order: 3; flex: 1 0 100%; }
}
