:root {
  --bg: #0D0F12; --side: #111418; --surface: #14171C; --raised: #1E232A; --console: #0A0C0F;
  --border: #262B33; --border2: #2E343D; --track: #23282F;
  --text: #E7E9EC; --muted: #A0A7B1; --faint: #6F7782;
  --amber: #F0A63A; --amber-hi: #FFC46E; --amber-bg: #3A2A12; --amber-line: #4A3716;
  --green: #4CC38A; --green-bg: #15291F;
  --red: #F08A7E; --red-bg: #2A1614; --red-line: #5A2A26;
  --blue: #5B8DEF; --blue-fg: #8FB3F5; --blue-bg: #1E2A3F;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
a { color: var(--amber); }
a:hover { color: var(--amber-hi); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.good { color: var(--green); }
.warn { color: var(--amber); }
.bad { color: var(--red); }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.stack-tight { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- shell ---- */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 232px; background: var(--side); border-right: 1px solid var(--border); padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand b { display: block; font-size: 16px; letter-spacing: 0.04em; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.logo { width: 36px; height: 36px; border-radius: 8px; background: var(--amber); color: var(--bg); display: flex; align-items: center; justify-content: center; font: 600 13px var(--mono); flex: none; }
.logo.big { width: 56px; height: 56px; border-radius: 12px; font-size: 18px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); background: #171B20; }
.nav a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.active { background: var(--raised); color: var(--text); font-weight: 500; }
.nav a.active svg { stroke: var(--amber); }
.subnav { display: flex; flex-direction: column; gap: 2px; padding-left: 30px; }
.subnav a { min-height: 36px; font-size: 14px; justify-content: space-between; }
.subnav a.active { background: none; color: var(--amber-hi); }
.subnav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.subnav .dot.ok { background: var(--green); }
.subnav .dot.bad { background: var(--red); }
.hostbox { margin-top: auto; padding: 14px 12px; border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.hostbox:empty { display: none; }
main { flex: 999 1 560px; min-width: 0; padding: 32px clamp(16px, 3vw, 40px) 48px; display: flex; flex-direction: column; gap: 28px; }

/* ---- header ---- */
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.top-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.back { font-size: 13px; color: var(--muted); text-decoration: none; }
.conn { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.conn::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.conn.ok { color: var(--green); }
.conn.bad { color: var(--red); }
.user { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #2A3038; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }

/* ---- buttons / inputs ---- */
.btn { min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #3A414B; color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--bg); font-weight: 600; }
.btn.primary:hover { background: var(--amber-hi); border-color: var(--amber-hi); color: var(--bg); }
.btn.danger { background: var(--red-bg); border-color: var(--red-line); color: var(--red); }
.btn.go { background: var(--green-bg); border-color: #24503A; color: var(--green); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; min-height: 48px; font-size: 15px; }
.btn.grow { flex: 1 1 auto; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.input { min-height: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border2); background: var(--bg); color: var(--text); font-size: 14px; }
.input:focus { border-color: var(--amber); outline: none; }

/* ---- cards / tiles ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-title { font-size: 16px; }
.sec { display: flex; flex-direction: column; gap: 14px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.tile-value { font: 500 24px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 1.2em; }
.tiles.compact .tile { padding: 14px 16px; }
.tiles.compact .tile-value { font-size: 19px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--raised); color: var(--muted); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.warn { background: var(--amber-bg); color: var(--amber-hi); }
.badge.bad { background: var(--red-bg); color: var(--red); }

.server-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.kv { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kv-label { font-size: 12px; color: var(--muted); }
.kv > :last-child { font-size: 14px; }
.meter-wrap { display: flex; flex-direction: column; gap: 6px; }
.meter { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 3px; width: 1%; transition: width 0.4s ease; }
.meter-fill.amber { background: var(--amber); }
.meter-fill.blue { background: var(--blue); }
.meter-fill.good { background: var(--green); }
.meter-fill.warn { background: var(--amber); }
.meter-fill.bad { background: var(--red); }

.core-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.core { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.core.own { border-color: var(--amber-line); }
.core-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.core-head b { font: 600 14px var(--mono); }
.tag { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--raised); color: var(--muted); white-space: nowrap; }
.tag.own { background: var(--amber-bg); color: var(--amber-hi); }
.tag.iso { background: var(--blue-bg); color: var(--blue-fg); }
.thread { display: flex; flex-direction: column; gap: 5px; }
.thread-top { display: flex; justify-content: space-between; font: 12px var(--mono); color: var(--muted); }
.thread .meter { height: 5px; }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.list { display: flex; flex-direction: column; gap: 12px; }
.temp-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 52px; align-items: center; gap: 12px; font-size: 13px; }
.temp-row > span:last-child { font-family: var(--mono); text-align: right; }
.check-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.check-row > span:nth-child(2) { flex: 1 1 auto; }
.check-row > span:last-child { font: 12px var(--mono); color: var(--muted); text-align: right; }

/* ---- server page ---- */
.split { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.split > .main-col { flex: 3 1 520px; min-width: 0; }
.split > .side-col { flex: 2 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.console { background: var(--console); border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.console-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.console-head h2 { font-size: 15px; }
.log { height: 440px; overflow-y: auto; padding: 12px 16px; font: 13px/1.65 var(--mono); }
.log .line { white-space: pre-wrap; word-break: break-word; }
.log .cmd { color: var(--amber-hi); }
.log .good { color: var(--green); }
.log .bad { color: var(--red); }
.log .dim { color: var(--muted); }
.rcon-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.rcon-box { flex: 1 1 auto; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border2); background: var(--bg); min-width: 0; }
.rcon-box:focus-within { border-color: var(--amber); }
.rcon-box span { color: var(--amber); }
.rcon-box input { flex: 1 1 auto; min-width: 0; border: 0; outline: none; background: transparent; font: 14px var(--mono); }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.inline-form label { font-size: 14px; font-weight: 500; }
.inline-form .input { flex: 1 1 220px; }
.fps-chart { height: 120px; display: flex; align-items: flex-end; gap: 3px; }
.fps-bar { flex: 1 1 0; border-radius: 2px 2px 0 0; min-height: 2px; }
.fps-bar.good { background: var(--green); }
.fps-bar.warn { background: var(--amber); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--border); }
td { padding: 8px 6px; border-bottom: 1px solid #1E232A; }
td.num { font-family: var(--mono); }
td.act { text-align: right; }
.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.kv-line > :first-child { color: var(--muted); flex: none; }
.kv-line > :last-child { font-family: var(--mono); text-align: right; word-break: break-all; }
.cmdline { font: 12px/1.6 var(--mono); color: var(--muted); word-break: break-all; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }

/* ---- configs ---- */
.cfg-layout { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cfg-layout > .files { flex: 1 1 260px; }
.cfg-layout > .editor { flex: 3 1 560px; }
.file-group { display: flex; flex-direction: column; gap: 2px; }
.file-group-name { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 8px 6px; }
.file-link { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 0 10px; border-radius: 6px; text-decoration: none; font: 13px var(--mono); color: var(--muted); }
.file-link:hover { background: #171B20; color: var(--text); }
.file-link.active { background: var(--raised); color: var(--text); }
.file-link .missing { font: 11px var(--sans); color: var(--faint); }
.editor { min-width: 0; background: var(--console); border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.editor-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.editor-head h2 { font: 600 15px var(--mono); }
.editor-body { display: flex; height: 560px; }
.gutter { flex: none; width: 56px; padding: 12px 14px 12px 0; text-align: right; color: var(--faint); font: 13px/1.75 var(--mono); white-space: pre; overflow: hidden; user-select: none; border-right: 1px solid #1A1E24; }
.code { flex: 1 1 auto; min-width: 0; border: 0; outline: none; resize: none; background: transparent; padding: 12px 16px; font: 13px/1.75 var(--mono); white-space: pre; overflow: auto; tab-size: 4; }
.editor-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface); font-size: 12px; color: var(--muted); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---- toasts ---- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--raised); border: 1px solid var(--border2); font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.toast.bad { background: var(--red-bg); border-color: var(--red-line); color: #FFD3CD; }

/* ---- login ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 16px; }
.login-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 24px; }
.login-head { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.login-head h1 { font-size: 26px; }
.login-card { padding: 28px; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; font-weight: 500; }
.field .input { min-height: 46px; font-size: 15px; }
.otp { letter-spacing: 0.2em; font-size: 16px !important; }
.form-error { color: #FFD3CD; background: var(--red-bg); border: 1px solid var(--red-line); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
