/* ──────────────────────────────────────────────────────────────
   vigil console · base
   Shared by both faces of the console. The home page is black and
   phosphor green; the management page is sky blue and white grey.
   The theme tokens live on :root and are overridden per page, so a
   component never has to know which page it is on.
   ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #04070a;
  --bg-2: #070d10;
  --panel: rgba(9, 20, 17, .72);
  --panel-solid: #0a1714;
  --line: rgba(57, 255, 156, .16);
  --line-strong: rgba(57, 255, 156, .34);
  --text: #d6f5e6;
  --text-2: #8fb8a8;
  --muted: #5f7d72;
  --accent: #39ff9c;
  --accent-2: #16d98a;
  --danger: #ff4d5e;
  --warn: #ffcc55;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 48px rgba(0, 0, 0, .55);
  --glow: 0 0 22px rgba(57, 255, 156, .22);
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --topbar-h: 62px;
}

html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.home {
  background:
    radial-gradient(1200px 620px at 50% -12%, rgba(20, 90, 66, .38) 0%, rgba(0, 0, 0, 0) 62%),
    radial-gradient(900px 520px at 88% 8%, rgba(14, 70, 90, .26) 0%, rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, #04070a 0%, #050a0c 42%, #03060a 100%);
  background-attachment: fixed;
}

/* Faint CRT scanlines: the difference between a dashboard and an
   operations console. Kept at 3% so text stays perfectly readable. */
.scanlines {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background: repeating-linear-gradient(180deg,
    rgba(255, 255, 255, .022) 0px, rgba(255, 255, 255, .022) 1px,
    rgba(0, 0, 0, 0) 1px, rgba(0, 0, 0, 0) 3px);
  mix-blend-mode: overlay;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
table { border-collapse: collapse; width: 100%; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, .03); }
::-webkit-scrollbar-thumb {
  background: rgba(57, 255, 156, .22);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(57, 255, 156, .38); }

/* ── top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 0 clamp(14px, 3vw, 30px);
  background: linear-gradient(180deg, rgba(5, 12, 10, .94), rgba(5, 12, 10, .72));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(140%);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .mark { color: var(--accent); display: flex; filter: drop-shadow(0 0 10px rgba(57, 255, 156, .55)); }
.brand .title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand .title b {
  font-family: var(--mono); font-size: 19px; letter-spacing: .18em;
  color: #eafff4; text-shadow: 0 0 18px rgba(57, 255, 156, .55);
}
.brand .title i { color: var(--accent); font-style: normal; opacity: .7; }
.brand .title span { color: var(--text-2); font-size: 13.5px; white-space: nowrap; }
.host-chip {
  font-family: var(--mono); font-size: 11.5px; color: var(--accent);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 3px 11px; background: rgba(57, 255, 156, .07);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw;
}
.topright { display: flex; align-items: center; gap: 14px; }
.live { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.live .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: breathe 2.4s ease-in-out infinite;
}
.live.offline .dot { background: var(--danger); box-shadow: 0 0 10px var(--danger); animation: none; }
@keyframes breathe { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.82); } }
.clock { font-family: var(--mono); font-size: 13px; color: var(--text-2); letter-spacing: .06em; }
.ghost-btn {
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 7px 15px; font-size: 13px; color: var(--accent);
  background: rgba(57, 255, 156, .06);
  transition: background .18s, transform .18s, box-shadow .18s;
  white-space: nowrap;
}
.ghost-btn:hover {
  background: rgba(57, 255, 156, .16);
  box-shadow: 0 0 20px rgba(57, 255, 156, .28);
  transform: translateY(-1px);
}

/* ── panels ──────────────────────────────────────────────── */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
}
.panel::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(57, 255, 156, .5), transparent);
  opacity: .7;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 13px 16px 11px;
  border-bottom: 1px solid rgba(57, 255, 156, .10);
}
.panel-head h2 {
  font-size: 13.5px; letter-spacing: .06em; color: #cfeee0;
  display: flex; align-items: center; gap: 9px;
}
.head-note { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.led {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 9px var(--accent); flex: none;
}
.led.red { background: var(--danger); box-shadow: 0 0 9px var(--danger); }
.led.green { background: var(--accent); }
.led.amber { background: var(--warn); box-shadow: 0 0 9px var(--warn); }

/* ── generic bits ────────────────────────────────────────── */
.divider { height: 1px; background: rgba(57, 255, 156, .10); margin: 10px 14px; }
.empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 18px 8px; }

.btn {
  border: 1px solid var(--line-strong); background: rgba(57, 255, 156, .08);
  color: var(--accent); border-radius: var(--radius-sm);
  padding: 8px 15px; font-size: 13px; cursor: pointer;
  transition: background .16s, transform .16s, opacity .16s;
}
.btn:hover { background: rgba(57, 255, 156, .18); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); color: #03130c; border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #5bffb0; }
.btn.danger { border-color: rgba(255, 77, 94, .55); color: #ffbcc2; background: rgba(255, 77, 94, .12); }
.btn.danger:hover { background: rgba(255, 77, 94, .24); }
.btn.ghost { background: transparent; color: var(--text-2); border-color: rgba(255, 255, 255, .16); }
.btn.ghost:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.btn.small { padding: 5px 11px; font-size: 12px; }

.chip {
  border: 1px solid var(--line); background: rgba(57, 255, 156, .05);
  color: var(--text-2); border-radius: 999px; padding: 4px 12px;
  font-size: 11.5px; cursor: pointer; font-family: var(--mono);
  transition: all .16s;
}
.chip:hover { color: var(--accent); border-color: var(--line-strong); background: rgba(57, 255, 156, .14); }
.chip.active { color: #03130c; background: var(--accent); border-color: transparent; }

.bar { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, .07); overflow: hidden; margin: 9px 0 7px; }
.bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 12px rgba(57, 255, 156, .6);
  border-radius: 4px; transition: width .5s ease, background .4s;
}
.bar i.warn { background: linear-gradient(90deg, #ffb347, var(--warn)); box-shadow: 0 0 12px rgba(255, 204, 85, .5); }
.bar i.danger { background: linear-gradient(90deg, #ff6b6b, var(--danger)); box-shadow: 0 0 12px rgba(255, 77, 94, .55); }

/* ── toast + modal ───────────────────────────────────────── */
.toast-host {
  position: fixed; right: 18px; bottom: 18px; z-index: 10000;
  display: flex; flex-direction: column; gap: 9px; align-items: flex-end;
}
.toast {
  padding: 11px 16px; border-radius: var(--radius-sm); font-size: 13px;
  background: rgba(8, 21, 17, .96); color: var(--text);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px) scale(.98);
  transition: opacity .24s, transform .24s; max-width: min(420px, 84vw);
}
.toast.in { opacity: 1; transform: none; }
.toast-error { border-color: rgba(255, 77, 94, .6); color: #ffd6da; }
.toast-ok { border-color: rgba(57, 255, 156, .55); }

.modal-host {
  position: fixed; inset: 0; z-index: 10001; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(2, 6, 8, .72); backdrop-filter: blur(4px);
}
.modal {
  width: min(520px, 92vw); max-height: 86vh; overflow: auto;
  background: var(--panel-solid); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 20px 22px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .7);
  opacity: 0; transform: translateY(12px) scale(.98);
  transition: opacity .2s, transform .2s;
}
.modal.in { opacity: 1; transform: none; }
.modal h3 { font-size: 16px; margin-bottom: 10px; }
.modal p { color: var(--text-2); font-size: 13.5px; line-height: 1.65; margin: 0 0 12px; }
.modal-detail {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  background: rgba(0, 0, 0, .35); border-radius: 8px; padding: 10px 12px;
  max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-all;
  border: 1px solid rgba(255, 255, 255, .06); margin: 0 0 14px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ── footer ──────────────────────────────────────────────── */
.foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 22px clamp(14px, 3vw, 30px) 34px;
  color: var(--muted); font-size: 11.5px; font-family: var(--mono);
}
.dot-sep { opacity: .45; }

@media (max-width: 720px) {
  .brand .title span { display: none; }
  .clock { display: none; }
  .toast-host { left: 14px; right: 14px; align-items: stretch; }
}

/* ── self-check banner ───────────────────────────────────── */
/* Shown only when the page's own wiring check fails. It is loud on
   purpose: a console with no data and no complaint is the one failure
   mode nobody notices until they need the data. */
.vigil-warn {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10002;
  padding: 11px 18px; font-size: 13px; line-height: 1.55;
  background: #7f1d28; color: #ffe3e6;
  border-top: 1px solid rgba(255, 255, 255, .25);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .35);
  font-family: var(--mono);
  word-break: break-word;
}
.vigil-warn code {
  background: rgba(255, 255, 255, .14); padding: 1px 6px; border-radius: 5px;
}
