:root {
  --bg: #0b1016; --panel: #121a23; --panel2: #18222d; --line: #243241; --text: #e6edf3; --muted: #8b9bab;
  --accent: #14b8a6; --accent-ink: #042f2b; --ok: #22c55e; --bad: #ef4444; --warn: #f59e0b; --info: #38bdf8;
  --radius: 10px; font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }

.layout { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 8px 16px; }
.brand .logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: white; font-weight: 800; }
.side .group { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 4px; }
.side a { color: var(--text); padding: 8px 10px; border-radius: 8px; display: block; }
.side a:hover { background: var(--panel2); }
.side a.active { background: rgba(20,184,166,.14); color: var(--accent); }
.side .foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.main { padding: 24px 28px 48px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 22px; }
.sub { color: var(--muted); margin-top: 4px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card .n { font-size: 28px; font-weight: 700; }
.card .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h2 { font-size: 15px; margin: 0 0 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.02); }
.table-wrap { overflow-x: auto; }

.btn { background: var(--panel2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--text); font-size: 13px; }
.check input { width: auto; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: rgba(34,197,94,.35); }
.badge.bad { color: var(--bad); border-color: rgba(239,68,68,.35); }
.badge.warn { color: var(--warn); border-color: rgba(245,158,11,.35); }
.badge.info { color: var(--info); border-color: rgba(56,189,248,.35); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.dot.offline { background: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 32px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-color: var(--accent); }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(720px, 100%); max-height: 92vh; overflow-y: auto; padding: 20px; }
.modal h3 { margin: 0 0 8px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

#toast { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; max-width: 380px; }
.toast.err { border-left-color: var(--bad); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 30% 20%, rgba(20,184,166,.12), transparent 50%), var(--bg); }
.login .box { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }

pre.config, pre.diff { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; max-height: 65vh; margin: 0; white-space: pre; }
pre.diff .add { color: var(--ok); }
pre.diff .del { color: var(--bad); }
pre.diff .hunk { color: var(--info); }
.terminal-page { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; }
.terminal-bar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 14px; display: flex; align-items: center; gap: 12px; }
.terminal-bar .rec { color: var(--bad); font-size: 12px; }
#term { flex: 1; padding: 6px; min-height: 0; }
.banner { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.35); color: var(--warn); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.copy { background: var(--bg); border: 1px solid var(--line); padding: 10px; border-radius: 8px; word-break: break-all; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .group, .side .foot { display: none; }
  .main { padding: 16px; }
  .grid2, .form-grid, .filters { grid-template-columns: 1fr; }
}
