:root {
  --bg: #0f1216;
  --bg-2: #151a20;
  --card: #1a2028;
  --card-2: #212934;
  --line: #2a3340;
  --text: #e6ebf1;
  --muted: #8b97a6;
  --accent: #4ade80;
  --accent-ink: #062b14;
  --blue: #60a5fa;
  --warn: #fbbf24;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.18);
  --radius: 14px;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f5f8; --bg-2: #e9edf2; --card: #ffffff; --card-2: #f4f6f9; --line: #dde3ea;
    --text: #17202b; --muted: #5d6b7c; --accent: #16a34a; --accent-ink: #ffffff;
    --blue: #2563eb; --warn: #b45309; --danger: #dc2626;
    --shadow: 0 1px 2px rgba(16,24,40,.06), 0 6px 18px rgba(16,24,40,.06);
    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;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
a { color: var(--blue); }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.success { color: var(--accent); }
.btn.warn { color: var(--warn); }
.btn.danger { color: var(--danger); }
.btn.danger.fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--card-2); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; }
input, select {
  height: 34px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text); font: inherit; min-width: 0;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: transparent; }
.small-input { width: 200px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.check input { height: auto; }

/* ---------- вход ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--bg); }
.login-card { width: min(380px, 100%); display: grid; gap: 16px; padding: 28px; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.login-card .btn { height: 40px; }

/* ---------- каркас ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px;
  padding: 18px 12px; background: var(--bg-2); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand b { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }
.brand.big b { font-size: 18px; }
.logo { width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #5bd16b 0 50%, #3a9d48 50%), #5bd16b;
  box-shadow: inset 0 -8px 0 #8b5a2b, inset 0 -10px 0 #3a9d48; }
nav { display: grid; gap: 2px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 500; }
nav a i { width: 20px; text-align: center; font-style: normal; opacity: .8; }
nav a:hover { background: var(--card); color: var(--text); }
nav a.active { background: var(--card); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px; }

main { min-width: 0; padding: 0 24px 32px; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 16px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.topbar h1 { flex: 1; }
.power { display: flex; gap: 8px; }
#menu-btn { display: none; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok::before { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.pill.warn::before { background: var(--warn); }
.pill.bad::before { background: var(--danger); }

.view { display: none; gap: 16px; }
.view.active { display: grid; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ---------- карточки ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 26px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.card .value small { font-size: 14px; color: var(--muted); font-weight: 500; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.bar { height: 6px; border-radius: 6px; background: var(--card-2); margin-top: 10px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; background: var(--accent); transition: width .4s; }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--danger); }

/* ---------- графики ---------- */
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--card-2); color: var(--text); box-shadow: var(--shadow); }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart { position: relative; min-width: 0; }
.chart .c-title { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.chart .c-title b { color: var(--text); font-variant-numeric: tabular-nums; }
.chart svg { display: block; width: 100%; height: 150px; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .grid text { fill: var(--muted); font-size: 10px; }
.chart .area { opacity: .16; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cursor { stroke: var(--muted); stroke-dasharray: 3 3; }
.tip { position: absolute; pointer-events: none; background: var(--card-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 9px; font-size: 12px; white-space: nowrap; box-shadow: var(--shadow); transform: translate(-50%, -110%); }

/* ---------- онлайн и инфо ---------- */
.online-list { display: grid; gap: 8px; }
.online { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: var(--card-2); }
.online img, .avatar { width: 28px; height: 28px; border-radius: 6px; image-rendering: pixelated; background: var(--bg-2); flex: none; }
.online .grow { flex: 1; min-width: 0; }
.online .grow small { display: block; color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }
.inline-form input { flex: 1; }

/* ---------- консоль ---------- */
.console-panel { display: flex; flex-direction: column; height: calc(100vh - 100px); min-height: 420px; }
.console { flex: 1; margin: 0; overflow: auto; background: #0a0d10; color: #cfd8e3; border-radius: 10px; padding: 12px 14px;
  font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; border: 1px solid var(--line); }
.console .w { color: #fbbf24; }
.console .e { color: #f87171; }
.console .j { color: #4ade80; }
.console .c { color: #93c5fd; }
.console .s { color: #64748b; }
.cmd { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.cmd span { font: 600 16px var(--mono); color: var(--accent); }
.cmd input { flex: 1; font-family: var(--mono); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: default; }
.table th[data-sort] { cursor: pointer; }
.table th[data-sort]:hover { color: var(--text); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: color-mix(in srgb, var(--card-2) 60%, transparent); }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.player-cell { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 600; margin-left: 4px;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line); }
.tag.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.tag.op { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.tag.ban { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px; background: var(--card-2); }
.list li .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list li small { color: var(--muted); display: block; font-size: 12px; }

/* ---------- настройки ---------- */
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px 18px; }
.prop { display: grid; grid-template-columns: minmax(0, 1fr) 180px; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.prop label { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.prop label small { display: block; font-family: system-ui, sans-serif; color: var(--muted); font-size: 12px; }
.prop input[type=text], .prop select { width: 100%; }
.prop.dirty label { color: var(--accent); }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; justify-self: end; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 22px; background: var(--card-2); border: 1px solid var(--line); cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; border-radius: 50%; background: var(--muted); transition: .2s; }
.switch input:checked + span { background: color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); background: var(--accent); }
.switch input:disabled + span { opacity: .5; cursor: default; }

/* ---------- модалка и уведомления ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.5); }
.modal-card { width: min(480px, 100%); max-height: 90vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { display: flex; align-items: center; gap: 10px; }
.actions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat-grid div { background: var(--card-2); border-radius: 10px; padding: 8px 10px; }
.stat-grid b { display: block; font-size: 16px; }
.stat-grid small { color: var(--muted); font-size: 11px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--card-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; box-shadow: var(--shadow); white-space: pre-wrap; overflow-wrap: anywhere; animation: tin .2s ease-out; }
.toast.err { border-left-color: var(--danger); }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }

/* ---------- мобильная вёрстка ---------- */
@media (max-width: 1000px) {
  .grid2, .charts { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 15; left: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  #menu-btn { display: inline-flex; }
  main { padding: 0 16px 24px; }
  .topbar { flex-wrap: wrap; }
  .power { width: 100%; }
  .power .btn { flex: 1; padding: 0 6px; font-size: 13px; }
  .small-input { width: 100%; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 12px; }
  .card .value { font-size: 21px; }
  .prop { grid-template-columns: 1fr; }
  .inline-form { flex-wrap: wrap; }
  .console-panel { height: calc(100vh - 150px); }
}
