:root {
  --bg: #0b0d10;
  --panel: #12151a;
  --panel-2: #171b21;
  --line: #232831;
  --text: #e7eaef;
  --muted: #8a93a3;
  --faint: #5c6573;
  --orange: #f97316;
  --amber: #eab308;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #60a5fa;
  --brand: linear-gradient(135deg, #f97316, #eab308 58%, #16a34a);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

/* ── Login ──────────────────────────────────────────────── */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px;
}
.login .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login h1 { font-size: 18px; margin: 0; }
.login p.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--orange); }
.code-input { letter-spacing: 6px; font-family: var(--mono); font-size: 18px; text-align: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #3a414d; }
.btn.primary { background: var(--brand); border: 0; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }
.note { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ── Shell ──────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.side {
  border-right: 1px solid var(--line); background: var(--panel); padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.side .brand b { font-size: 15px; }
.side .brand small { display: block; color: var(--muted); font-size: 11px; }
.logo { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  text-decoration: none; color: var(--muted);
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--orange); }
.nav a.soon { pointer-events: none; opacity: .5; }
.nav a .tag { margin-left: auto; font-size: 10px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; color: var(--faint); }
.nav svg { width: 16px; height: 16px; flex: none; }
.side .me { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 8px 0; font-size: 13px; }
.side .me .who { display: flex; justify-content: space-between; align-items: center; }
.side .me small { color: var(--muted); }

.main { padding: 26px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input {
  padding: 7px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.toolbar label.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ── Cards ──────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 16px; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-body { padding: 16px 18px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(34,197,94,.14); }
.dot.warn { background: var(--amber); box-shadow: 0 0 0 4px rgba(234,179,8,.14); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 4px rgba(239,68,68,.14); }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--green); border-color: rgba(34,197,94,.35); }
.pill.bad { color: var(--red); border-color: rgba(239,68,68,.35); }
.pill.warn { color: var(--amber); border-color: rgba(234,179,8,.35); }
.ml-auto { margin-left: auto; }

.meters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.meter .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.meter .value { font-size: 18px; font-weight: 600; margin: 2px 0 6px; }
.meter .value small { font-size: 12px; color: var(--muted); font-weight: 400; }
.bar { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.bar i.warn { background: var(--amber); }
.bar i.bad { background: var(--red); }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 16px 0 8px; }
.proc { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.flags { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { border: 1px dashed var(--line); border-radius: 14px; padding: 36px; text-align: center; color: var(--muted); }
.err-box { color: var(--red); background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25); border-radius: 8px; padding: 10px 12px; font-size: 13px; }

/* ── Logs ───────────────────────────────────────────────── */
.logbox {
  background: #07090b; border: 1px solid var(--line); border-radius: 12px; padding: 12px 0;
  height: calc(100vh - 200px); min-height: 320px; overflow: auto; font: 12.5px/1.55 var(--mono);
}
.logline { padding: 0 14px; white-space: pre-wrap; word-break: break-word; }
.logline:hover { background: #0e1216; }
.logline.err { color: #fca5a5; }
.logline.warnl { color: #fde68a; }
.logline mark { background: rgba(249,115,22,.35); color: inherit; border-radius: 2px; }
.logmeta { color: var(--muted); font-size: 12px; margin: 8px 2px 0; }

/* ── Tables ─────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--panel); position: sticky; top: 0; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: auto; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 20px; z-index: 10; }
.modal { width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.modal h3 { margin: 0 0 4px; }
.modal p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel-2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; z-index: 20; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side .brand { padding-bottom: 4px; }
  .nav-label, .nav a.soon { display: none; }
  .side .me { width: 100%; margin-top: 8px; padding: 10px 8px 0; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .main { padding: 18px 16px 40px; }
  .grid { grid-template-columns: 1fr; }
  .meters { grid-template-columns: repeat(2, 1fr); }
}
