:root {
  --bg: #0b0f14;
  --bg-2: #0f1419;
  --bg-3: #141a22;
  --line: #1f2937;
  --line-strong: #334155;
  --text: #e6ebf2;
  --dim: #8b97a8;
  --gold: #ffc857;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #60a5fa;
  --warn: #f59e0b;
  --rad: 10px;
  --pad: 0.9rem;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.mono, code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, "Roboto Mono", monospace; }
.dim { color: var(--dim); }
.hidden { display: none !important; }

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 1.2rem;
  padding: 0.6rem 1rem;
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; }
.crest { font-size: 1.3rem; }
.brand-name { font-size: 1.05rem; }
.brand-ver { color: var(--dim); font-weight: 500; font-size: 0.78rem; padding: 0.1rem 0.4rem; background: rgba(255,255,255,0.05); border-radius: 4px; }
.tabs { display: flex; gap: 0.15rem; flex: 1; flex-wrap: wrap; }
.tab {
  appearance: none; border: none; background: transparent; color: var(--dim);
  padding: 0.45rem 0.85rem; cursor: pointer; border-radius: 6px;
  font: inherit; font-weight: 500;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tab.active { color: var(--gold); background: rgba(255,200,87,0.10); }
.meta { display: flex; align-items: center; gap: 0.6rem; }
.meta button { appearance: none; border: 1px solid var(--line-strong); background: var(--bg-3); color: var(--text); padding: 0.35rem 0.6rem; border-radius: 6px; cursor: pointer; font: inherit; }
.meta button:hover { background: var(--bg-2); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-ok   { background: var(--green); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.dot-warn { background: var(--warn);  box-shadow: 0 0 8px rgba(245,158,11,0.5); }
.dot-err  { background: var(--red);   box-shadow: 0 0 8px rgba(239,68,68,0.5); }

/* ---- Layout ---- */
main { padding: 1.2rem; max-width: 1400px; margin: 0 auto; }
.pane { display: grid; gap: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: var(--pad);
}
.card h2 { margin: 0 0 0.65rem 0; font-size: 0.9rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.card h2 small { font-size: 0.78rem; color: var(--line-strong); margin-left: 0.35rem; text-transform: none; letter-spacing: 0; }

/* ---- Stat cards ---- */
.stat { display: flex; flex-direction: column; gap: 0.15rem; }
.stat-label { font-size: 0.74rem; letter-spacing: 0.10em; color: var(--dim); text-transform: uppercase; }
.stat-value { font-size: 1.85rem; font-weight: 700; line-height: 1.1; }
.stat-sub   { font-size: 0.78rem; color: var(--dim); }
.stat .big  { padding: 0.6rem 1rem; border-radius: 8px; font-weight: 600; cursor: pointer; }
button.big {
  appearance: none; border: 1px solid var(--gold); background: linear-gradient(180deg, #ffd97e, #ffc04a);
  color: #2a1f00; font: inherit; font-weight: 700;
}
button.big:hover { filter: brightness(1.05); }

/* ---- Tables ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.tbl th, .tbl td { text-align: left; padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--dim); font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; font-size: 0.72rem; }
.tbl tbody tr:hover { background: rgba(255,255,255,0.025); cursor: pointer; }
.tbl td.actions button { font-size: 0.72rem; padding: 0.2rem 0.5rem; margin-right: 0.25rem; }

/* ---- Pre / log ---- */
pre { background: var(--bg-3); border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.7rem; overflow: auto; font-size: 0.78rem; max-height: 300px; }
pre.log { max-height: 480px; }

/* ---- Service list ---- */
.svc-list { list-style: none; padding: 0; margin: 0; }
.svc-list li {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.6rem; align-items: center;
  padding: 0.5rem 0.2rem; border-bottom: 1px solid var(--line);
}
.svc-list li:last-child { border-bottom: 0; }
.svc-list .svc-state { font-size: 0.7rem; padding: 0.1rem 0.45rem; border-radius: 4px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.svc-list .svc-state.active   { background: rgba(34,197,94,0.13); color: #b8f7c8; }
.svc-list .svc-state.inactive { background: rgba(239,68,68,0.13); color: #fca5a5; }
.svc-list .svc-state.activating { background: rgba(245,158,11,0.13); color: #fcd34d; }
.svc-list .svc-name { font-weight: 600; }
.svc-list .svc-host { color: var(--dim); font-size: 0.78rem; }

/* ---- Event list ---- */
.event-list { list-style: none; padding: 0; margin: 0; max-height: 300px; overflow: auto; }
.event-list.big { max-height: none; }
.event-list li { display: grid; grid-template-columns: auto auto 1fr; gap: 0.5rem; padding: 0.32rem 0.25rem; border-bottom: 1px solid var(--line); font-size: 0.82rem; }
.event-list li:last-child { border-bottom: 0; }
.event-list .ev-time { color: var(--dim); font-size: 0.74rem; min-width: 5.5rem; font-family: ui-monospace; }
.event-list .ev-type { color: var(--gold); font-weight: 600; min-width: 9rem; font-size: 0.74rem; }
.event-list .ev-data { color: var(--text); overflow-wrap: anywhere; }

/* ---- Forms ---- */
.inline-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.inline-form input {
  background: var(--bg-3); border: 1px solid var(--line-strong); color: var(--text);
  padding: 0.35rem 0.55rem; border-radius: 6px; font: inherit; min-width: 9rem;
}
.inline-form button {
  appearance: none; border: 1px solid var(--line-strong); background: var(--bg-3); color: var(--text);
  padding: 0.4rem 0.85rem; border-radius: 6px; cursor: pointer; font: inherit;
}
.inline-form button[data-action="inject"] { border-color: var(--green); color: #b8f7c8; }
.inline-form button[data-action="drain"]  { border-color: var(--red);   color: #fca5a5; }

/* ---- Login ---- */
.login {
  position: fixed; inset: 0; background: rgba(11,15,20,0.95); display: flex; align-items: center; justify-content: center; z-index: 100;
}
.login-card { background: var(--bg-2); border: 1px solid var(--line); padding: 1.6rem; border-radius: 12px; width: min(440px, 90vw); }
.login-card h1 { margin: 0 0 0.4rem 0; }
.login-card p { color: var(--dim); margin: 0 0 1rem 0; }
.login-card input {
  width: 100%; background: var(--bg-3); border: 1px solid var(--line-strong); color: var(--text);
  padding: 0.55rem 0.65rem; border-radius: 6px; font: inherit; font-family: ui-monospace; margin-bottom: 0.6rem;
}
.login-card button {
  appearance: none; width: 100%; background: var(--gold); color: #2a1f00;
  border: none; padding: 0.55rem; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 700;
}
.login-error { color: var(--red); font-size: 0.85rem; margin-top: 0.5rem; }

/* ---- Toast ---- */
.toast { position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%) translateY(20px); background: var(--bg-3); border: 1px solid var(--line-strong); padding: 0.5rem 0.9rem; border-radius: 6px; opacity: 0; transition: all 0.2s ease; pointer-events: none; z-index: 200; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
