:root {
  --bg0: #05070d;
  --bg1: #080c16;
  --panel: rgba(13, 19, 34, 0.66);
  --panel-solid: #0b1120;
  --panel-2: rgba(17, 25, 44, 0.72);
  --line: rgba(56, 189, 248, 0.12);
  --line-strong: rgba(56, 189, 248, 0.32);
  --txt: #e2eaf7;
  --muted: #8494b8;
  --faint: #5b6a8c;
  --cyan: #22d3ee;
  --cyan-dim: #0e7490;
  --magenta: #f471b5;
  --violet: #8b5cf6;
  --good: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --side-w: 248px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { min-height: 100%; }
body {
  margin: 0; color: var(--txt);
  font: 14px/1.6 var(--sans);
  background:
    radial-gradient(1100px 550px at 88% -10%, rgba(139, 92, 246, 0.13), transparent 60%),
    radial-gradient(900px 480px at 8% 0%, rgba(34, 211, 238, 0.09), transparent 55%),
    radial-gradient(760px 760px at 50% 112%, rgba(244, 113, 181, 0.05), transparent 60%),
    linear-gradient(var(--bg0), var(--bg1));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(56, 189, 238, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 238, 0.032) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, black 30%, transparent 100%);
}

/* ============ app shell ============ */
#appView { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ============ sidebar ============ */
#sidebar {
  width: var(--side-w); flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 20px 14px 16px;
  background: rgba(6, 9, 17, 0.72);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
  z-index: 20;
  transition: margin-left 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
body.side-collapsed #sidebar { margin-left: calc(-1 * var(--side-w)); }
.side-brand { padding: 4px 10px 18px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.side-brand .logo {
  font-family: var(--mono); font-weight: 800; font-size: 17px; letter-spacing: 2.5px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.side-sub { display: block; color: var(--muted); font-size: 10.5px; letter-spacing: 2.5px; text-transform: uppercase; margin-top: 3px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent;
  color: var(--muted); font: 500 13.5px var(--sans);
  cursor: pointer; text-align: left; width: 100%;
  transition: all 0.16s ease; letter-spacing: 0.2px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { color: var(--txt); background: rgba(34, 211, 238, 0.07); }
.nav-item.active {
  color: #fff; background: linear-gradient(135deg, rgba(34, 211, 238, 0.14), rgba(139, 92, 246, 0.14));
  border-color: var(--line-strong);
  box-shadow: 0 4px 18px rgba(34, 211, 238, 0.12), inset 0 1px 0 rgba(255,255,255,0.05);
}
.nav-item.active svg { color: var(--cyan); opacity: 1; }
.nav-badge { margin-left: auto; font-size: 14px; filter: saturate(0.7); }
.nav-dot {
  margin-left: auto; width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 8px var(--cyan);
  animation: pulse 1.6s infinite;
}

.side-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.brain-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(8, 13, 26, 0.6); border: 1px solid var(--line);
}
.brain-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); flex-shrink: 0; transition: all 0.3s; }
.brain-dot.on { background: var(--good); box-shadow: 0 0 10px var(--good); animation: pulse 2s infinite; }
.brain-dot.off { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.brain-name { font: 600 12px var(--mono); color: var(--txt); }
.brain-model { font-size: 10.5px; }

/* ============ main column ============ */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap;
  padding: 14px 26px; position: sticky; top: 0; z-index: 10;
  background: rgba(5, 8, 14, 0.72); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 12px; }
.tb-right { flex-wrap: wrap; justify-content: flex-end; }
#viewTitle { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: 0.2px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; padding: 0; flex-shrink: 0;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--txt); border-color: var(--line-strong); }
.palette-trigger {
  display: flex; align-items: center; gap: 8px;
  background: rgba(4, 8, 16, 0.7); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 7px 12px;
  color: var(--muted); font: 400 12.5px var(--sans); cursor: pointer;
}
.palette-trigger svg { width: 15px; height: 15px; }
.palette-trigger:hover { border-color: var(--line-strong); color: var(--txt); }
kbd {
  font: 500 10.5px var(--mono); color: var(--faint);
  background: rgba(255,255,255,0.06); border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 6px;
}
.auth-ok { color: var(--good); font-size: 11.5px; font-family: var(--mono); white-space: nowrap; }
.auth-ok::before { content: "◈ "; }
.pill {
  padding: 6px 14px; border-radius: 999px; font-size: 11.5px; font-family: var(--mono);
  border: 1px solid var(--line-strong); background: rgba(10, 16, 30, 0.6); white-space: nowrap;
}
.pill.unknown { color: var(--muted); }
.pill.ok { color: var(--good); border-color: rgba(52, 211, 153, 0.5); box-shadow: 0 0 14px rgba(52, 211, 153, 0.16); }
.pill.down { color: var(--bad); border-color: rgba(248, 113, 113, 0.5); box-shadow: 0 0 14px rgba(248, 113, 113, 0.16); }
.pill.partial { color: var(--warn); border-color: rgba(251, 191, 36, 0.5); box-shadow: 0 0 14px rgba(251, 191, 36, 0.16); }

#content { flex: 1; padding: 24px 26px; max-width: 1220px; width: 100%; margin: 0 auto; }
.view { display: none; flex-direction: column; gap: 18px; animation: rise 0.35s ease both; }
.view.active { display: flex; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ panels ============ */
.panel {
  background: var(--panel); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel h2 {
  margin: 0; font-size: 13.5px; font-weight: 650; letter-spacing: 1.6px; text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
}
.panel h2::before {
  content: ""; width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 0 10px var(--cyan);
}
.muted { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ============ stats ============ */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; position: relative; overflow: hidden; backdrop-filter: blur(12px);
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.stat:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.stat::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent); opacity: 0.65;
}
.stat .num {
  font-family: var(--mono); font-size: 30px; font-weight: 700; color: #fff;
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.4); line-height: 1.15;
}
.stat .lbl { color: var(--txt); font-size: 11px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; margin-top: 5px; }
.stat-sub { font-size: 11px; margin-top: 2px; }
.stat.live .num { color: var(--good); text-shadow: 0 0 18px rgba(52, 211, 153, 0.4); }

/* ============ health bar ============ */
.hbar {
  height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line); overflow: hidden; margin: 2px 0 8px;
}
.hbar > div {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan), var(--good));
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.5);
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ============ topology ============ */
.topo-wrap {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background-color: rgba(4, 7, 14, 0.6);
  background-image: radial-gradient(rgba(120, 180, 255, 0.12) 1px, transparent 1.5px);
  background-size: 22px 22px;
}
#topo { display: block; width: 100%; height: auto; }
.tnode { cursor: pointer; }
.tnode rect { transition: filter 0.15s; }
.tnode:hover rect { filter: brightness(1.55); }
.legend { display: flex; gap: 18px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.lg { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.up { background: var(--good); box-shadow: 0 0 8px var(--good); animation: pulse 2s infinite; }
.dot.down { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes dashflow { to { stroke-dashoffset: -28; } }
.spoke-flow { stroke-dasharray: 5 9; animation: dashflow 0.9s linear infinite; }

/* ============ agent grid ============ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 10px; }
.card {
  position: relative; border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 14px 13px 16px; cursor: pointer; overflow: hidden;
  background: rgba(8, 13, 26, 0.55);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--bad); opacity: 0.85; transition: all 0.2s;
}
.card.is-up::before { background: var(--good); box-shadow: 0 0 8px var(--good); }
.card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 8px 24px rgba(34, 211, 238, 0.1); }
.card.sel { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 8px 28px rgba(34, 211, 238, 0.2); background: rgba(10, 22, 36, 0.85); }
.card .t { font-family: var(--mono); font-weight: 700; font-size: 13px; color: #fff; }
.card .d { color: var(--muted); font-size: 11px; margin-top: 2px; min-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .st { font-size: 11px; margin-top: 7px; font-family: var(--mono); letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; }
.st.up { color: var(--good); } .st.down { color: var(--bad); }
.st.up::before, .st.down::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.st.up::before { background: var(--good); box-shadow: 0 0 8px var(--good); animation: pulse 2s infinite; }
.st.down::before { background: var(--bad); box-shadow: 0 0 8px var(--bad); }

/* ============ consoles ============ */
.console-bar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; align-items: stretch; }
.console-bar input[type=text]:not(#modelExtra) { flex: 1; min-width: 180px; }
#modelExtra { flex: 1; min-width: 200px; font-family: var(--mono); font-size: 12px; }
#modelPrompt { margin-bottom: 12px; }
.out { display: flex; flex-direction: column; gap: 10px; max-height: 460px; overflow-y: auto; padding-right: 4px; }
.out:empty { display: none; }
.result {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  background: rgba(6, 10, 20, 0.72); animation: rise 0.3s ease both;
}
.result .rt { font-weight: 700; color: var(--cyan); font-family: var(--mono); font-size: 12.5px; }
.result .score { color: var(--muted); font-size: 11px; margin-left: 8px; font-family: var(--mono); }
.result pre {
  white-space: pre-wrap; margin: 10px 0 0; font-size: 12.5px; font-family: var(--mono);
  color: #c9d6ec; line-height: 1.65; word-break: break-word;
}
.memrow {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  background: rgba(6, 10, 20, 0.72); animation: rise 0.3s ease both;
}
.memrow .k { font-weight: 700; font-family: var(--mono); font-size: 12.5px; color: #fff; word-break: break-all; }
.memrow .tags { color: var(--magenta); font-size: 11px; font-family: var(--mono); }
.memrow pre { white-space: pre-wrap; margin: 6px 0 0; font-size: 12.5px; color: #c9d6ec; font-family: var(--mono); word-break: break-word; }
.typing-cursor::after { content: "▍"; color: var(--cyan); animation: pulse 0.9s infinite; }

/* ============ activity feed ============ */
.feed { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.fev {
  display: flex; gap: 10px; align-items: baseline;
  font-family: var(--mono); font-size: 12px;
  border-left: 2px solid var(--line-strong); padding: 6px 12px;
  background: rgba(6, 10, 20, 0.55); border-radius: 0 8px 8px 0;
  animation: rise 0.25s ease both;
}
.fev .ts { color: #8b9bbf; flex-shrink: 0; }
.fev.ok { border-left-color: var(--good); }
.fev.warn { border-left-color: var(--warn); }
.fev.err { border-left-color: var(--bad); }
.fev.info { border-left-color: var(--cyan); }

/* ============ forms ============ */
input, select, textarea {
  background: rgba(4, 8, 16, 0.85); border: 1px solid var(--line); color: var(--txt);
  border-radius: var(--radius-sm); padding: 10px 13px; font: 400 13px var(--sans); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.14); }
textarea { width: 100%; min-height: 110px; resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; }
select { font-family: var(--mono); font-size: 12px; max-width: 240px; cursor: pointer; }
button {
  background: linear-gradient(135deg, var(--cyan-dim), #155e75);
  border: 1px solid rgba(34, 211, 238, 0.4);
  color: #eafcff; border-radius: var(--radius-sm); padding: 10px 20px;
  font: 600 13px var(--sans); letter-spacing: 0.3px; cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
button:hover { filter: brightness(1.22); box-shadow: 0 4px 20px rgba(34, 211, 238, 0.32); transform: translateY(-1px); }
button:active { transform: none; }
button:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }
button.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 500;
  width: 100%; justify-content: flex-start; padding: 9px 12px;
}
button.ghost svg { width: 16px; height: 16px; }
button.ghost:hover { border-color: rgba(248, 113, 113, 0.5); color: var(--bad); box-shadow: none; filter: none; transform: none; }
button.primary { min-width: 110px; }
.del {
  background: transparent; border: 1px solid rgba(248, 113, 113, 0.45); color: var(--bad);
  padding: 6px 13px; font-size: 12px; flex-shrink: 0;
}
.del:hover { background: rgba(248, 113, 113, 0.1); box-shadow: none; filter: none; transform: none; }
.err { color: var(--bad); font-family: var(--mono); font-size: 12.5px; }

/* ============ command palette ============ */
.palette {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 5, 10, 0.6); backdrop-filter: blur(6px);
  display: flex; justify-content: center; align-items: flex-start; padding-top: 14vh;
  animation: fadein 0.15s ease both;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.palette-box {
  width: min(560px, calc(100vw - 40px));
  background: rgba(10, 15, 28, 0.96); border: 1px solid var(--line-strong);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.7), 0 0 50px rgba(34, 211, 238, 0.1);
  animation: pop 0.18s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(0.98); } to { opacity: 1; transform: none; } }
#paletteInput {
  width: 100%; border: none; border-bottom: 1px solid var(--line);
  border-radius: 0; padding: 16px 20px; font-size: 15px; background: transparent;
}
#paletteInput:focus { box-shadow: none; border-bottom-color: var(--cyan); }
.palette-list { max-height: 340px; overflow-y: auto; padding: 8px; }
.palette-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: 8px; background: transparent; border: none;
  color: var(--txt); font: 500 13px var(--sans); cursor: pointer; text-align: left;
}
.palette-item .pid { font-family: var(--mono); font-size: 12px; color: var(--cyan); min-width: 130px; }
.palette-item .ptitle { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pdot { width: 8px; height: 8px; border-radius: 50%; margin-left: auto; flex-shrink: 0; }
.palette-item .pdot.up { background: var(--good); box-shadow: 0 0 6px var(--good); }
.palette-item .pdot.down { background: var(--bad); }
.palette-item.sel, .palette-item:hover { background: rgba(34, 211, 238, 0.1); filter: none; box-shadow: none; transform: none; }
.palette-empty { padding: 20px; text-align: center; }

/* ============ toasts ============ */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 120; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 44px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  background: rgba(10, 15, 28, 0.95); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 12px 16px; font-size: 12.5px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
  animation: toastin 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes toastin { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastout 0.25s ease both; }
@keyframes toastout { to { opacity: 0; transform: translateX(20px); } }
.toast.ok { border-left: 3px solid var(--good); }
.toast.err { border-left: 3px solid var(--bad); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast.info { border-left: 3px solid var(--cyan); }

/* ============ skeleton ============ */
.skel {
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  min-height: 14px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============ login ============ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; z-index: 1; }
#stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.login-card {
  background: rgba(10, 15, 28, 0.82); backdrop-filter: blur(20px);
  border: 1px solid var(--line-strong); border-radius: 20px;
  padding: 40px 38px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.65), 0 0 70px rgba(34, 211, 238, 0.09);
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
  position: relative; overflow: hidden; text-align: center;
}
.login-glow {
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--magenta), var(--cyan));
  background-size: 300% 100%; animation: slide 6s linear infinite;
}
@keyframes slide { to { background-position: 300% 0; } }
.login-card .logo { font-family: var(--mono); font-weight: 800; font-size: 27px; letter-spacing: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-sub { color: var(--muted); font-size: 12px; letter-spacing: 3px; text-transform: uppercase; }
.login-desc { color: var(--muted); font-size: 13px; margin: 0; line-height: 1.6; }
.login-card input { width: 100%; text-align: center; font-family: var(--mono); letter-spacing: 1px; padding: 13px; font-size: 14px; }
.login-card button { padding: 13px; font-size: 14px; width: 100%; }
.login-card button kbd { color: #bff3ff; background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.2); }
.login-card .small { font-size: 11px; color: var(--faint); line-height: 1.65; }
#loginErr { min-height: 18px; }

/* ============ footer ============ */
footer { padding: 22px 26px 26px; }
footer .sig { font-family: var(--mono); font-size: 10.5px; color: var(--muted); letter-spacing: 0.8px; text-align: center; }
footer .sig b { color: var(--cyan); font-weight: 600; }
footer .sig a { color: var(--cyan); text-decoration: none; }
footer .sig a:hover { text-decoration: underline; }

/* ============ scrollbars ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(34, 211, 238, 0.22); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(34, 211, 238, 0.42); }

/* ============ roster toolbar ============ */
.roster-bar { display: flex; gap: 10px; margin-bottom: 12px; }
.roster-bar input { flex: 1; min-width: 140px; }
.roster-bar select { max-width: 170px; }
.mono { font-family: var(--mono); }
#sweepIn { font-size: 11px; white-space: nowrap; }

/* latency color scale — shared by cards, topology, stats */
.lat-ok { color: var(--good); }
.lat-warn { color: var(--warn); }
.lat-bad { color: var(--bad); }
.lat-na { color: var(--faint); }

/* health bar fill shifts hue with the live ratio — no green-washing a sick swarm */
#healthFill.hf-crit { background: linear-gradient(90deg, #7f1d1d, var(--bad)); box-shadow: 0 0 12px rgba(248, 113, 113, 0.5); }
#healthFill.hf-warn { background: linear-gradient(90deg, #92400e, var(--warn)); box-shadow: 0 0 12px rgba(251, 191, 36, 0.5); }

/* ============ login password toggle ============ */
.pass-wrap { position: relative; width: 100%; }
.pass-wrap input { width: 100%; text-align: center; font-family: var(--mono); letter-spacing: 1px; padding: 13px 64px 13px 13px; font-size: 14px; }
.pass-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--faint);
  font: 600 11px var(--mono); padding: 6px 10px; letter-spacing: 0.5px;
}
.pass-toggle:hover { color: var(--cyan); box-shadow: none; filter: none; transform: translateY(-50%); }

/* ============ palette footer ============ */
.palette-foot {
  display: flex; gap: 16px; justify-content: center;
  padding: 10px; border-top: 1px solid var(--line); font-size: 11px;
}
.palette-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ============ focus visibility (a11y) ============ */
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
.card:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }

/* ============ reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .spoke-flow { animation: none; stroke-dasharray: none; }
  html { scroll-behavior: auto; }
}

/* ============ responsive ============ */
/* ============ topology nodes (keyboard-focusable) ============ */
.tnode { cursor: pointer; }
.tnode:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ============ mobile sidebar scrim ============ */
#scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(2, 4, 9, 0.62); backdrop-filter: blur(2px);
  animation: fadein 0.15s ease both;
}

@media (max-width: 800px) {
  #sweepIn { display: none; }
}
@media (max-width: 1024px) {
  #sidebar { position: fixed; left: 0; z-index: 50; box-shadow: 24px 0 60px rgba(0,0,0,0.5); }
  body:not(.side-collapsed) #sidebar { margin-left: 0; }
  body.side-collapsed #sidebar { margin-left: calc(-1 * var(--side-w)); }
  #content { padding: 18px 16px; }
  #topbar { padding: 12px 16px; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .num { font-size: 23px; }
  .console-bar { flex-direction: column; }
  .console-bar input, .console-bar select, .console-bar button { width: 100%; max-width: none; }
  .auth-ok { display: none; }
  .palette-trigger .muted, .palette-trigger kbd { display: none; }
  #viewTitle { font-size: 15px; }
}
