:root {
  --bg: #0a0b0d;
  --bg-deep: #07080a;
  --surface: #101317;
  --surface-2: #161a1f;
  --border: #1c232a;
  --border-strong: #2a333d;
  --text: #e6e3da;
  --text-dim: #7b848e;
  --text-faint: #4a525a;
  --amber: #ffaa3a;
  --green: #9bd16a;
  --red: #e8645a;
  --cool: #6acdd1;
  --grid: rgba(255, 255, 255, 0.03);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  background-image:
    radial-gradient(ellipse 1200px 600px at 30% -10%, #131820 0%, transparent 60%),
    radial-gradient(ellipse 800px 400px at 80% 110%, #14110b 0%, transparent 60%);
  background-attachment: fixed;
}

/* ---- TOP BAR ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 22px 32px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: linear-gradient(180deg, rgba(10,11,13,0.92) 0%, rgba(10,11,13,0.78) 100%);
  backdrop-filter: blur(8px);
  z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand-mark {
  color: var(--amber);
  font-size: 16px;
  letter-spacing: -2px;
  transform: translateY(-1px);
}
.brand h1 {
  font-family: 'Instrument Serif', 'Times New Roman', serif;
  font-size: 28px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.3px;
  color: var(--text);
}
.brand-italic { color: var(--text-faint); margin-left: 1px; }

.status { display: flex; gap: 28px; }
.status-item { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.status-label {
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 9px;
  font-weight: 500;
}
.status-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.status-value em { font-style: normal; color: var(--text-faint); font-size: 10px; }
.status-value-row { display: flex; align-items: center; gap: 8px; }
.status-pip {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  transition: all 0.3s ease;
}
.status-pip.live {
  background: var(--green);
  box-shadow: 0 0 8px var(--green), 0 0 2px var(--green);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---- LAYOUT ---- */
main { padding: 22px 32px 56px; max-width: 1800px; margin: 0 auto; }

/* ---- CARD BASE ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,170,58,0.25), transparent);
  pointer-events: none;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 {
  font-family: 'Instrument Serif', 'Times New Roman', serif;
  font-size: 17px;
  font-weight: 400;
  font-style: italic;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

/* ---- MASTER CHART ---- */
.master { margin-bottom: 18px; }
.chart-wrap {
  position: relative;
  padding: 14px 20px 4px;
}
.master .chart-wrap { padding: 16px 20px 8px; }
#master-chart {
  display: block;
  width: 100%;
  height: 280px;
}
.chart-axis-y {
  position: absolute;
  top: 16px; right: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 280px;
  font-size: 9px;
  color: var(--text-faint);
  text-align: right;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.chart-foot {
  display: flex;
  align-items: center;
  padding: 0 20px 14px;
  font-size: 9px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.chart-foot-spacer { flex: 1; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; max-width: 60%; justify-content: flex-end; }
.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  transition: opacity 0.3s;
}
.legend-swatch {
  width: 10px; height: 2px;
  flex-shrink: 0;
}
.legend-item.offline { opacity: 0.35; text-decoration: line-through; }

/* ---- GRID ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 14px;
}

.empty {
  grid-column: 1 / -1;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: 4px;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.empty .blink {
  color: var(--amber);
  animation: blink 1.2s steps(2) infinite;
  margin-right: 8px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---- NODE CARD ---- */
.node {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  transition: border-color 0.3s, background 0.3s;
}
.node::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--node-color, var(--amber));
  opacity: 0.7;
}
.node.offline {
  background: linear-gradient(135deg, rgba(232,100,90,0.12) 0%, rgba(232,100,90,0.04) 100%);
  border-color: rgba(232,100,90,0.45);
}
.node.offline::before { background: var(--red); opacity: 1; }
.node.offline::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(232,100,90,0.025) 10px,
    rgba(232,100,90,0.025) 20px
  );
  pointer-events: none;
}

.node-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 12px 18px;
  border-bottom: 1px solid var(--border);
}
.node-name {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.8px;
}
.node-pip {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.node.offline .node-pip {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: pulse-red 1.6s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.node-status {
  font-size: 9px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 500;
}
.node.offline .node-status { color: var(--red); }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border);
}
.stat {
  background: var(--surface);
  padding: 12px 14px 14px;
  min-width: 0;
}
.stat-label {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 1.6px;
  margin-bottom: 6px;
  font-weight: 500;
}
.stat-value {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value .unit {
  font-size: 11px;
  color: var(--text-faint);
  margin-left: 2px;
  font-weight: 400;
}
.stat-sub {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-bar {
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
  margin-top: 8px;
  overflow: hidden;
}
.stat-bar > span {
  display: block;
  height: 100%;
  background: var(--node-color, var(--amber));
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.stat.warn .stat-bar > span { background: var(--amber); }
.stat.crit .stat-bar > span { background: var(--red); }
.stat.crit .stat-value { color: var(--red); }

.node.offline .stat-value { color: var(--text-dim); }
.node.offline .stat-bar > span { background: var(--red); opacity: 0.5; }

.node-chart {
  padding: 10px 14px 14px;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
}
.node-chart-head {
  display: flex; justify-content: space-between;
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 1.5px;
  margin-bottom: 6px;
}
.node-chart-head .down { color: var(--cool); }
.node-chart-head .up { color: var(--amber); }
.node-chart canvas {
  width: 100%;
  height: 70px;
  display: block;
}

@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px 20px; }
  .status { gap: 16px; flex-wrap: wrap; justify-content: flex-start; }
  .status-item { align-items: flex-start; }
  main { padding: 16px 20px 32px; }
  #master-chart { height: 200px; }
  .chart-axis-y { height: 200px; }
  .grid { grid-template-columns: 1fr; }
}
