:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e9ef;
  --muted: #8d96a8;
  --accent: #4f9cf9;
  --ok: #37c98b;
  --warn: #e8b64c;
  --err: #f2685f;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: baseline; gap: .5rem; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); display: inline-block;
  align-self: center;
}
.brand-name { font-weight: 650; letter-spacing: .01em; }
.brand-sub { color: var(--muted); font-size: .78rem; }

.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav-link {
  padding: .35rem .7rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: .9rem;
}
.nav-link:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--panel-2); color: var(--text); }

.user { margin-left: auto; display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.who { color: var(--muted); }
.role {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 20px; padding: .1rem .5rem; font-size: .72rem; color: var(--muted);
}
.inline { display: inline; margin: 0; }

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
.lede { color: var(--muted); margin: 0 0 1.25rem; font-size: .9rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.1rem;
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem;
}
.panel-head h2 { font-size: 1rem; margin: 0; }
.panel-note { color: var(--muted); font-size: .82rem; }

/* ---------- stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  margin-bottom: 1.1rem;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: .8rem .9rem;
}
.stat-ok { border-left-color: var(--ok); }
.stat-warn { border-left-color: var(--warn); }
.stat-err { border-left-color: var(--err); }
.stat-accent { border-left-color: var(--accent); }
.stat-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.55rem; font-weight: 650; margin-top: .15rem; }
.stat-note { color: var(--muted); font-size: .78rem; margin-top: .2rem; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--panel-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }
.cmd { color: var(--muted); word-break: break-word; max-width: 34rem; }
.table-scroll { overflow-x: auto; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 20px;
  font-size: .74rem; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  white-space: nowrap;
}
.badge-ok { color: var(--ok); border-color: rgba(55,201,139,.35); background: rgba(55,201,139,.1); }
.badge-warn { color: var(--warn); border-color: rgba(232,182,76,.35); background: rgba(232,182,76,.1); }
.badge-err { color: var(--err); border-color: rgba(242,104,95,.35); background: rgba(242,104,95,.1); }
.badge-accent { color: var(--accent); border-color: rgba(79,156,249,.35); background: rgba(79,156,249,.1); }

/* ---------- chart ---------- */
.chart { width: 100%; height: 190px; }
.chart-bar { fill: var(--accent); }
.chart-bar.is-zero { fill: var(--line); }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 10px; }

/* ---------- forms ---------- */
.field { margin-bottom: .85rem; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.field input {
  width: 100%; max-width: 22rem; padding: .5rem .65rem;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 7px; color: var(--text); font-size: .95rem;
}
.field input:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-block; padding: .45rem .9rem; border-radius: 7px;
  border: 1px solid var(--accent); background: var(--accent); color: #07121f;
  font-size: .88rem; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.alert { padding: .6rem .85rem; border-radius: 8px; margin-bottom: .9rem; font-size: .88rem; }
.alert-err { background: rgba(242,104,95,.12); border: 1px solid rgba(242,104,95,.35); color: #ffb3ac; }
.alert-ok { background: rgba(55,201,139,.12); border: 1px solid rgba(55,201,139,.35); color: #9fe4c2; }

/* ---------- login ---------- */
.login-wrap { max-width: 340px; margin: 6rem auto; }
.login-wrap .panel { padding: 1.4rem; }

/* ---------- docs ---------- */
.docs { max-width: 60rem; }
.docs h2 { font-size: 1.05rem; margin: 1.6rem 0 .5rem; }
.docs h3 { font-size: .95rem; margin: 1.1rem 0 .4rem; color: var(--text); }
.docs p, .docs li { color: #c3cad8; font-size: .92rem; }
.docs code {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px;
  padding: .05rem .35rem; font-size: .84rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.docs pre {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: .8rem; overflow-x: auto; font-size: .82rem; color: #c3cad8;
}
.docs pre code { background: none; border: none; padding: 0; }
.docs table { margin: .6rem 0 1rem; }
.docs .toc { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; }
.docs .toc ol { margin: .3rem 0 0; padding-left: 1.2rem; }
.docs .toc li { margin: .15rem 0; }

/* ---------- footer ---------- */
.foot {
  border-top: 1px solid var(--line);
  padding: 1.1rem 1.25rem 2.2rem;
  max-width: 1180px; margin: 0 auto;
  font-size: .78rem; color: var(--muted);
}
.foot p { margin: .25rem 0; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: .88rem; padding: .8rem 0; }

@media (max-width: 640px) {
  .topbar { gap: .6rem; }
  .user { margin-left: 0; width: 100%; }
  .cmd { max-width: 14rem; }
  .wrap { padding: 1rem .85rem 2.5rem; }
}

/* ---------- filters & forms in panels ---------- */
.filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.filters select, .filters input[type="number"] {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: .4rem .55rem; font-size: .85rem;
}
.filters input[type="number"].num-input { width: 5.5rem; }
.filters select:focus, .filters input:focus { outline: none; border-color: var(--accent); }
.inline-label { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); }
.inline-label input[type="checkbox"] { accent-color: var(--accent); }
