:root {
  --bg: #0f1216;
  --bg-soft: #161b22;
  --bg-card: #1a2029;
  --line: #2a3240;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #4da3ff;
  --ok: #3fb950;
  --warn: #d29922;
  --crit: #f85149;
  --info: #58a6ff;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }
a { color: var(--accent); }

/* ---------- auth ---------- */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card p.sub { margin: 0 0 20px; color: var(--muted); }
.secret {
  font-family: var(--mono);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  word-break: break-all;
  user-select: all;
}
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font-family: var(--mono); }

.field-block { margin: 0 0 14px; }
.field-block input { width: 100%; letter-spacing: 0.06em; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.qr-box { background: #fff; padding: 8px; border-radius: 8px; display: inline-block; margin-top: 6px; line-height: 0; }
.qr-box svg { display: block; }

/* ---------- shell ---------- */
header.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 600; font-size: 16px; }
.host-meta { color: var(--muted); font-size: 12px; display: flex; gap: 14px; flex-wrap: wrap; }
.spacer { flex: 1; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.crit { background: var(--crit); }

nav.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  overflow-x: auto;
}
nav.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}
nav.tabs button:hover { color: var(--text); }
nav.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
nav.tabs button .badge { margin-left: 6px; }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* ---------- blocks ---------- */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 15px; }
.card h3 { color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }
.stat { font-size: 26px; font-weight: 600; }
.stat small { font-size: 13px; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; }
.section-title h2 { margin: 0; font-size: 17px; }

canvas.chart { width: 100%; height: 64px; display: block; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: #1f2731; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }

/* ---------- controls ---------- */
button.btn, a.btn {
  background: #222b36;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button.btn:hover, a.btn:hover { border-color: var(--accent); }
button.btn.primary { background: #1f4d80; border-color: #2a6aa8; }
button.btn.danger { background: #4a1f1f; border-color: #7a2b2b; }
button.btn.ghost { background: transparent; }
button.btn:disabled { opacity: 0.5; cursor: default; }
button.btn.sm { padding: 3px 8px; font-size: 12px; }

input, select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
label.field input, label.field select { width: 100%; }
textarea { width: 100%; min-height: 320px; font-family: var(--mono); line-height: 1.45; }
input[type=checkbox] { width: auto; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--line);
  background: #1d242e;
  color: var(--muted);
}
.badge.ok { color: #7ee787; border-color: #2c5c33; background: #12261a; }
.badge.warn { color: #e3b341; border-color: #6b5220; background: #2a2113; }
.badge.crit { color: #ff7b72; border-color: #6e2b26; background: #2a1414; }
.badge.info { color: #79c0ff; border-color: #274b73; background: #12233a; }

.problem { border-left: 3px solid var(--line); padding: 8px 12px; background: #171d25; border-radius: 6px; margin-bottom: 8px; }
.problem.critical { border-left-color: var(--crit); }
.problem.warning { border-left-color: var(--warn); }
.problem.info { border-left-color: var(--info); }
.problem .t { font-weight: 600; }
.problem .d { color: var(--muted); font-size: 12px; }

.tree { border-left: 1px dashed var(--line); margin-left: 8px; padding-left: 12px; }
.chain { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.chain .arrow { color: var(--muted); }

/* ---------- modal & toasts ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 520px; }
.modal-card h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: 420px; }
.toast { background: var(--bg-card); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,0.4); }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.crit { border-left-color: var(--crit); }

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #2a2113;
  border: 1px solid #6b5220;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

code.inline { font-family: var(--mono); background: var(--bg); padding: 1px 5px; border-radius: 5px; }
