:root {
  /* Base palette */
  --bg: #12181C;
  --panel: #1B242A;
  --panel-raised: #212C33;
  --border: #2C3940;
  --text: #E8EDEE;
  --text-dim: #8FA0A8;

  /* Severity signal colors */
  --ok: #4FD1C5;
  --ok-dim: #2E4A47;
  --warn: #E8A33D;
  --warn-dim: #4A3B22;
  --critical: #E85C4A;
  --critical-dim: #4A2622;

  --radius: 10px;
  --font-label: 'Space Grotesk', sans-serif;
  --font-data: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-label);
  min-height: 100vh;
}

.view { padding: 32px 40px 56px; max-width: 1180px; margin: 0 auto; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 6px;
}

.brand h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.nodes-online {
  font-family: var(--font-data);
  font-size: 14px;
  color: var(--text-dim);
  margin: 4px 0 0;
}

.fleet-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 8px;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-label);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: not-allowed;
  opacity: 0.55;
}

.ctrl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--critical);
  display: inline-block;
}
.ctrl-pause .ctrl-dot { background: var(--warn); }
.ctrl-dot-profile { background: var(--text-dim); }

.ctrl-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* ---------- Fleet summary line ---------- */

.fleet-summary {
  font-size: 14px;
  color: var(--text-dim);
  margin: 4px 0 28px;
  max-width: 70ch;
  line-height: 1.5;
}

/* ---------- Node grid ---------- */

.node-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 860px) {
  .node-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .node-grid { grid-template-columns: 1fr; }
  .view { padding: 24px 18px 48px; }
}

.node-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--ok);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font-family: inherit;
  transition: border-color 0.25s ease, transform 0.1s ease;
}

.node-card:hover { transform: translateY(-1px); }
.node-card:focus-visible { outline: 2px solid var(--ok); outline-offset: 2px; }

.node-card.severity-warn { border-left-color: var(--warn); }
.node-card.severity-critical { border-left-color: var(--critical); background: linear-gradient(180deg, rgba(232,92,74,0.08), transparent 60%); }
.node-card.offline { border-left-color: var(--text-dim); opacity: 0.55; }

.node-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.node-name { font-size: 16px; font-weight: 600; margin: 0; }

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-dim);
  flex-shrink: 0;
}
.severity-warn .status-dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-dim); }
.severity-critical .status-dot { background: var(--critical); box-shadow: 0 0 0 3px var(--critical-dim); }
.offline .status-dot { background: var(--text-dim); box-shadow: none; }

.node-metrics {
  font-family: var(--font-data);
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
  margin: 0 0 14px;
}
.node-metrics span { color: var(--text); }

.badge {
  display: inline-block;
  font-family: var(--font-label);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  width: 100%;
  text-align: center;
}
.badge-ok { background: var(--ok-dim); color: var(--ok); }
.badge-warn { background: var(--warn-dim); color: var(--warn); }
.badge-critical { background: var(--critical); color: #1A0D0A; }

/* ---------- Empty state ---------- */

.empty-state {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
  margin-top: 40px;
}
.empty-state code {
  font-family: var(--font-data);
  background: var(--panel);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ---------- Detail screen ---------- */

.back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-label);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  margin-bottom: 20px;
}
.back-btn:hover { color: var(--text); }

.detail-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 5px solid var(--ok);
  border-radius: 14px;
  padding: 28px 32px 32px;
}
.detail-panel.severity-warn { border-left-color: var(--warn); }
.detail-panel.severity-critical { border-left-color: var(--critical); background: linear-gradient(180deg, rgba(232,92,74,0.06), transparent 40%); }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.detail-header h2 { margin: 0; font-size: 24px; font-weight: 700; }

.detail-body {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 36px;
}
@media (max-width: 720px) {
  .detail-body { grid-template-columns: 1fr; }
}

.metric-list { margin: 0; }
.metric-list div { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); }
.metric-list dt { font-size: 13px; color: var(--text-dim); }
.metric-list dd { margin: 0; font-family: var(--font-data); font-size: 14px; font-weight: 500; }

.detail-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 0 0 14px;
}

#detail-chart {
  width: 100%;
  height: 140px;
  background: var(--panel-raised);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.chart-caption {
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--text-dim);
  margin: 8px 0 0;
  text-align: right;
}

.detail-action {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.action-label { font-size: 13px; color: var(--text-dim); margin: 0 0 8px; }
.detail-action .badge { width: auto; padding: 7px 16px; display: inline-block; }

/* Risk-score number tween target */
.risk-number { font-variant-numeric: tabular-nums; transition: color 0.3s ease; }
