:root {
  --bg: #111214;
  --panel: #1a1b1f;
  --panel2: #222329;
  --line: #2e3038;
  --text: #f1f1f3;
  --muted: #9a9ca6;
  --accent: #c91616;
  --accent-hover: #e02020;
  --ok: #2fbf71;
  --warn: #f0a500;
  --bad: #ff4d4d;
  --off: #6b6e78;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
a { color: var(--text); }
button, input, select { font: inherit; color: inherit; }

/* ---------- Header ---------- */
header.top { background: #0b0b0d; border-bottom: 3px solid var(--accent); }
header.top .inner { max-width: 1280px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
header.top img { height: 22px; display: block; }
header.top .tag { background: var(--accent); color: #fff; font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 4px; letter-spacing: .5px; }
header.top nav { display: flex; gap: 4px; margin-left: 12px; }
header.top nav button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 6px; cursor: pointer; font-weight: 600; }
header.top nav button.active, header.top nav button:hover { color: var(--text); background: var(--panel2); }
header.top .user { margin-left: auto; color: var(--muted); display: flex; gap: 10px; align-items: center; }

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

/* ---------- Buttons / inputs ---------- */
.btn { background: var(--panel2); border: 1px solid var(--line); padding: 7px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #4a4d58; background: #2a2b32; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.link { background: none; border: 0; color: var(--muted); padding: 4px 6px; }
.btn.link:hover:not(:disabled) { color: var(--text); background: none; }
.btn.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
input[type=text], input[type=password], input[type=search], select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid rgba(201,22,22,.5); border-color: var(--accent); }
select { cursor: pointer; }

/* ---------- Summary ---------- */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; text-align: left; }
.stat.active { border-color: var(--accent); }
.stat .n { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.ok .n { color: var(--ok); } .stat.warn .n { color: var(--warn); } .stat.bad .n { color: var(--bad); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }
.toolbar .muted { margin-left: auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- PC cards ---------- */
.pcs { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.pc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; border-top: 3px solid var(--off); }
.pc.ok { border-top-color: var(--ok); } .pc.warn { border-top-color: var(--warn); } .pc.bad { border-top-color: var(--bad); }
.pc.offline { opacity: .8; }
.pc .head { padding: 12px 14px 8px; display: flex; gap: 10px; align-items: flex-start; }
.pc .head .t { flex: 1; min-width: 0; }
.pc .head h3 { margin: 0; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc .head .sub { color: var(--muted); font-size: 12.5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--off); display: inline-block; flex: none; margin-top: 6px; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(47,191,113,.15); }
.dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.problems { margin: 0 14px 8px; padding: 0; list-style: none; }
.problems li { font-size: 12.5px; padding: 4px 8px; border-radius: 6px; margin-bottom: 4px; }
.problems li.bad { background: rgba(255,77,77,.12); color: #ff9c9c; }
.problems li.warn { background: rgba(240,165,0,.12); color: #ffd27a; }
.screens { border-top: 1px solid var(--line); }
.screen { display: grid; grid-template-columns: 74px 1fr auto; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.screen:last-child { border-bottom: 0; }
.screen .num { font-weight: 700; }
.screen .num .res { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }
.screen .game { min-width: 0; }
.screen .game .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen .game select { width: 100%; }
.state { font-size: 12px; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--off); }
.state.ok { color: var(--ok); } .state.ok::before { background: var(--ok); }
.state.warn { color: var(--warn); } .state.warn::before { background: var(--warn); }
.state.bad { color: var(--bad); } .state.bad::before { background: var(--bad); }
.screen .acts { display: flex; gap: 4px; }
.pc .foot { padding: 10px 14px; display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: auto; background: rgba(0,0,0,.15); border-radius: 0 0 var(--radius) var(--radius); }
.pc .foot .right { margin-left: auto; display: flex; gap: 4px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h3 { color: var(--text); margin-top: 0; }

/* ---------- Tables / settings ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0 0 12px; color: var(--muted); }
.key { font: 600 18px/1.3 Consolas, "Courier New", monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 10px 14px; display: inline-block; letter-spacing: 1px; user-select: all; }
pre.config { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 12px; overflow-x: auto; font-size: 12.5px; color: #d7d7dc; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
td.time { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Toast / dialog ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #26272e; border: 1px solid var(--line); border-left: 4px solid var(--ok); padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.4); display: none; max-width: calc(100% - 32px); z-index: 10; }
#toast.err { border-left-color: var(--bad); }
#toast.show { display: block; }
.conn { position: fixed; top: 0; left: 0; right: 0; background: var(--bad); color: #fff; text-align: center; padding: 6px; font-weight: 600; display: none; z-index: 11; }
.conn.show { display: block; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius); padding: 28px; }
.login img { height: 24px; display: block; margin-bottom: 6px; }
.login h1 { font-size: 17px; margin: 10px 0 18px; font-weight: 600; color: var(--muted); }
.login label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.login input { width: 100%; }
.login .btn { width: 100%; margin-top: 18px; padding: 10px; }
.login .error { color: var(--bad); font-size: 13px; margin-top: 12px; min-height: 18px; }
.login .note { font-size: 13px; color: var(--muted); }

@media (max-width: 760px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .pcs { grid-template-columns: 1fr; }
  header.top nav { margin-left: 0; order: 3; width: 100%; }
  .screen { grid-template-columns: 60px 1fr; }
  .screen .acts { grid-column: 1 / -1; justify-content: flex-end; }
}
