:root {
  --bg: #0b0f17;
  --bg-elev: #121826;
  --bg-elev2: #182031;
  --line: #243049;
  --text: #e6ecf7;
  --text-dim: #93a2bd;
  --accent: #4da3ff;
  --ok: #37d399;
  --warn: #f5c14b;
  --crit: #ff6b6b;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
header.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 1.05rem; }
.brand span { color: var(--accent); }
nav.top { display: flex; gap: 1.1rem; flex: 1; flex-wrap: wrap; }
nav.top a { color: var(--text-dim); font-size: 0.92rem; }
nav.top a.active, nav.top a:hover { color: var(--text); text-decoration: none; }

main { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
main.wide { max-width: 1500px; }

h1 { font-size: 1.65rem; letter-spacing: -0.02em; margin: 0 0 0.35rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 0.75rem; }
.sub { color: var(--text-dim); margin: 0 0 1.75rem; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 1rem; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
}
.card h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.card p { margin: 0; color: var(--text-dim); font-size: 0.9rem; }

.stat { font-size: 1.9rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.stat-label { color: var(--text-dim); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; }

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge.ok { background: rgba(55,211,153,0.13); color: var(--ok); border-color: rgba(55,211,153,0.3); }
.badge.warn { background: rgba(245,193,75,0.13); color: var(--warn); border-color: rgba(245,193,75,0.3); }
.badge.crit { background: rgba(255,107,107,0.13); color: var(--crit); border-color: rgba(255,107,107,0.3); }
.badge.dim { background: var(--bg-elev2); color: var(--text-dim); border-color: var(--line); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); }
th { color: var(--text-dim); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
td.num { font-variant-numeric: tabular-nums; font-family: var(--mono); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev); }

/* ---------- forms ---------- */
input[type=text], input[type=password], textarea, select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button {
  padding: 0.6rem 1.1rem;
  background: var(--accent);
  color: #06121f;
  border: 0;
  border-radius: 7px;
  font-weight: 650;
  font-size: 0.92rem;
  cursor: pointer;
  font-family: inherit;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }

label { display: block; font-size: 0.85rem; color: var(--text-dim); margin: 0.9rem 0 0.3rem; }

/* ---------- docs ---------- */
.doc-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 860px) { .doc-layout { grid-template-columns: 1fr; } }
.doc-nav { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
.doc-nav .section { color: var(--text-dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; margin: 1rem 0 0.4rem; }
.doc-nav a { display: block; padding: 0.28rem 0.5rem; border-radius: 6px; color: var(--text-dim); font-size: 0.88rem; }
.doc-nav a:hover, .doc-nav a.active { background: var(--bg-elev2); color: var(--text); text-decoration: none; }
.doc-body { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem 1.9rem; overflow-x: auto; }
.doc-body pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem; overflow-x: auto; font-family: var(--mono); font-size: 0.85rem; }
.doc-body code { font-family: var(--mono); font-size: 0.87em; background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; }
.doc-body pre code { background: none; padding: 0; }
.doc-body table { margin: 1rem 0; }
.doc-body h1 { margin-top: 0; }
.doc-body h2, .doc-body h3 { margin-top: 1.8rem; }
.doc-body blockquote { border-left: 3px solid var(--accent); margin: 1rem 0; padding: 0.2rem 1rem; color: var(--text-dim); }

/* ---------- api ---------- */
.op { border: 1px solid var(--line); border-radius: 9px; margin-bottom: 0.65rem; background: var(--bg-elev); overflow: hidden; }
.op-head { display: flex; align-items: center; gap: 0.8rem; padding: 0.65rem 0.9rem; cursor: pointer; }
.op-head:hover { background: var(--bg-elev2); }
.method { font-family: var(--mono); font-size: 0.72rem; font-weight: 700; padding: 0.2rem 0.5rem; border-radius: 5px; min-width: 58px; text-align: center; }
.method.get { background: rgba(77,163,255,0.16); color: var(--accent); }
.method.post { background: rgba(55,211,153,0.16); color: var(--ok); }
.method.put, .method.patch { background: rgba(245,193,75,0.16); color: var(--warn); }
.method.delete { background: rgba(255,107,107,0.16); color: var(--crit); }
.op-path { font-family: var(--mono); font-size: 0.88rem; }
.op-sum { color: var(--text-dim); font-size: 0.85rem; margin-left: auto; }
.op-body { padding: 0.9rem 1.1rem; border-top: 1px solid var(--line); display: none; }
.op.open .op-body { display: block; }
.lock { font-size: 0.75rem; color: var(--text-dim); }

/* ---------- ops ---------- */
#trafficCanvas { width: 100%; height: 340px; display: block; border-radius: 10px; background: linear-gradient(180deg, #0d1320, #0b0f17); border: 1px solid var(--line); }
.spark { width: 100%; height: 38px; display: block; }
.inst-row td { font-size: 0.86rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.45rem; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(55,211,153,0.7); }
.dot.crit { background: var(--crit); box-shadow: 0 0 8px rgba(255,107,107,0.7); }
.issue { display: flex; gap: 0.8rem; align-items: flex-start; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); }
.issue:last-child { border-bottom: 0; }
.issue-title { font-weight: 600; font-size: 0.92rem; }
.issue-detail { color: var(--text-dim); font-size: 0.84rem; }
.muted { color: var(--text-dim); }
.right { text-align: right; }
.banner { padding: 0.7rem 1rem; border-radius: 8px; margin-bottom: 1.2rem; font-size: 0.9rem; }
.banner.warn { background: rgba(245,193,75,0.1); border: 1px solid rgba(245,193,75,0.35); color: var(--warn); }
