:root {
  --night: #0c1219;
  --harbor: #121c27;
  --panel: #172431;
  --panel-raised: #1d2c3a;
  --line: #2c3e4e;
  --ink: #e8f0f5;
  --muted: #91a5b5;
  --dim: #617587;
  --aqua: #63d5cc;
  --blue: #8aa9ff;
  --amber: #f4bd61;
  --red: #ff7373;
  --shadow: rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--night);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 72% -10%, rgba(99, 213, 204, .10), transparent 32rem),
    linear-gradient(160deg, #0b1118 0%, #0d151e 58%, #0a1016 100%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .17;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(430px, 100%);
  padding: 42px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(29, 44, 58, .95), rgba(18, 28, 39, .96));
  box-shadow: 0 28px 80px var(--shadow);
  border-radius: 6px;
}

.brand-mark {
  display: flex;
  align-items: end;
  gap: 4px;
  width: 48px;
  height: 34px;
  margin-bottom: 28px;
}

.brand-mark span {
  width: 10px;
  background: var(--aqua);
  border-radius: 2px 2px 0 0;
  box-shadow: 0 0 20px rgba(99, 213, 204, .22);
}

.brand-mark span:nth-child(1) { height: 45%; }
.brand-mark span:nth-child(2) { height: 100%; }
.brand-mark span:nth-child(3) { height: 68%; }
.brand-mark.compact { width: 36px; height: 28px; margin: 0; }
.brand-mark.compact span { width: 7px; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--aqua);
  font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .16em;
}

h1, h2, p { margin-top: 0; }

.login-card h1,
.topbar h1,
.section-heading h2 {
  margin-bottom: 0;
  font-family: "Arial Narrow", "Roboto Condensed", ui-sans-serif, sans-serif;
  font-stretch: condensed;
  letter-spacing: -.025em;
}

.login-card h1 { font-size: clamp(31px, 7vw, 45px); line-height: .98; }
.login-copy { margin: 18px 0 30px; color: var(--muted); line-height: 1.65; }

.login-card label { display: block; margin-top: 18px; }
.login-card label span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(6, 12, 18, .55);
  outline: none;
}
.login-card input:focus { border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(99, 213, 204, .12); }
.login-card button {
  width: 100%;
  margin-top: 18px;
  padding: 13px 18px;
  border: 0;
  border-radius: 3px;
  color: #071311;
  background: var(--aqua);
  font-weight: 800;
}
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--red); font-size: 13px; }

.app-shell { width: min(1680px, 100%); margin: 0 auto; padding: 24px 30px 36px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.identity, .topbar-actions, .clock-block, .legend, .history-controls, .range-switch { display: flex; align-items: center; }
.identity { gap: 15px; }
.topbar h1 { margin: 0; font-size: 24px; font-weight: 650; }
.topbar-actions { gap: 18px; }
.clock-block { gap: 8px; color: var(--muted); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.clock-block time { margin-left: 7px; color: var(--ink); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(244, 189, 97, .12); }
.live-dot.online { background: var(--aqua); box-shadow: 0 0 0 4px rgba(99, 213, 204, .12); }
.quiet-button {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
}
.quiet-button:hover, .quiet-button:focus-visible { color: var(--ink); border-color: var(--muted); }

.pulse-board,
.node-section,
.incident-section,
.history-section {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(18, 28, 39, .78);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .12);
}

.pulse-board { padding: 22px 24px 26px; overflow: hidden; }
.section-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; }
.section-heading h2 { font-size: 22px; }
.section-heading > p { margin: 0; color: var(--muted); font-size: 13px; }

.pulse-rail {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  min-height: 82px;
  margin-top: 22px;
}

.pulse-node {
  position: relative;
  display: grid;
  align-content: space-between;
  min-height: 82px;
  padding: 13px 15px 12px;
  overflow: hidden;
  border-left: 3px solid var(--aqua);
  background: linear-gradient(90deg, rgba(99, 213, 204, .11), rgba(99, 213, 204, .015));
}
.pulse-node::after {
  content: "";
  position: absolute;
  right: -40%;
  bottom: 0;
  width: 70%;
  height: 1px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  animation: sweep 3.6s linear infinite;
}
.pulse-node.warning { color: var(--amber); border-color: var(--amber); background: linear-gradient(90deg, rgba(244, 189, 97, .12), transparent); }
.pulse-node.critical { color: var(--red); border-color: var(--red); background: linear-gradient(90deg, rgba(255, 115, 115, .12), transparent); }
.pulse-node strong { color: var(--ink); font-size: 14px; }
.pulse-node span { color: currentColor; font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace; }

@keyframes sweep { from { transform: translateX(-130%); } to { transform: translateX(230%); } }

.metric-deck {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.metric-card {
  position: relative;
  min-height: 132px;
  padding: 19px 19px 17px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--harbor);
}
.metric-card.primary { background: linear-gradient(160deg, #1a303b, #14232e); }
.metric-card.primary::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: linear-gradient(90deg, var(--aqua), transparent 80%);
}
.metric-card p { margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; font: 700 clamp(24px, 2.25vw, 38px)/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.06em; }
.metric-card small { position: absolute; bottom: 15px; color: var(--dim); font-size: 11px; }
.account-card { padding-top: 15px; }
.account-card p { margin-bottom: 7px; }
.pool-account-list { display: grid; max-height: 79px; gap: 4px; padding-right: 3px; padding-bottom: 20px; overflow-y: auto; scrollbar-width: thin; }
.pool-account-item { display: flex; align-items: center; justify-content: space-between; gap: 7px; min-width: 0; }
.pool-account-item span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.pool-account-item strong { flex: 0 0 auto; color: var(--ink); font: 700 12px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.03em; }
.pool-account-empty { color: var(--dim); font-size: 11px; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(290px, 1fr); gap: 10px; }
.node-section, .incident-section, .history-section { padding: 22px 24px; }
.section-heading.inline { align-items: center; }
.legend { gap: 13px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 7px; height: 7px; border-radius: 50%; }
.legend .healthy { background: var(--aqua); }
.legend .warning { background: var(--amber); }
.legend .critical { background: var(--red); }

.node-list { display: grid; gap: 7px; margin-top: 20px; }
.node-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.45fr) repeat(6, minmax(75px, .75fr)) 85px;
  align-items: center;
  min-height: 66px;
  padding: 10px 13px;
  border: 1px solid transparent;
  border-bottom-color: rgba(44, 62, 78, .85);
  background: rgba(7, 13, 19, .18);
}
.node-row:hover { border-color: var(--line); background: rgba(29, 44, 58, .72); }
.node-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.state-pip { flex: 0 0 auto; width: 9px; height: 30px; border-radius: 2px; background: var(--aqua); }
.node-row.warning .state-pip { background: var(--amber); }
.node-row.critical .state-pip { background: var(--red); }
.node-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.node-name small, .node-cell small { display: block; margin-top: 5px; color: var(--dim); font-size: 10px; }
.node-cell strong { display: block; font: 650 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.node-state { justify-self: end; padding: 4px 7px; border: 1px solid currentColor; border-radius: 2px; color: var(--aqua); font-size: 10px; }
.warning .node-state { color: var(--amber); }
.critical .node-state { color: var(--red); }

.incident-count { display: grid; place-items: center; min-width: 28px; height: 28px; border-radius: 3px; color: var(--night); background: var(--amber); font: 800 13px ui-monospace, monospace; }
.incident-list { display: grid; gap: 8px; margin-top: 20px; }
.incident-item { padding: 13px 14px; border-left: 2px solid var(--amber); background: rgba(244, 189, 97, .07); }
.incident-item.critical { border-color: var(--red); background: rgba(255, 115, 115, .07); }
.incident-item strong { display: block; margin-bottom: 6px; font-size: 12px; }
.incident-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.empty-note, .empty-state { color: var(--dim); font-size: 12px; }
.empty-state { padding: 36px 0; text-align: center; }

.history-section { margin-top: 10px; }
.history-heading { align-items: center; }
.history-controls { gap: 10px; }
.history-controls select, .range-switch button {
  height: 32px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--night);
  font-size: 11px;
}
.history-controls select { min-width: 130px; padding: 0 30px 0 10px; }
.range-switch button { padding: 0 10px; border-right: 0; }
.range-switch button:last-child { border-right: 1px solid var(--line); }
.range-switch button.active { color: var(--night); background: var(--aqua); border-color: var(--aqua); font-weight: 750; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 20px; }
.chart-card { min-height: 230px; padding: 15px 16px; border: 1px solid var(--line); background: rgba(8, 14, 20, .28); }
.chart-card header { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.chart-card header strong { color: var(--ink); font: 700 12px ui-monospace, monospace; }
.chart { height: 170px; margin-top: 14px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: rgba(97, 117, 135, .20); stroke-width: 1; }
.chart .area { fill: url(#chartFade); }
.chart .line { fill: none; stroke: var(--aqua); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart.error .line { stroke: var(--red); }
.chart.ttft .line { stroke: var(--blue); }
.chart .empty-chart { display: grid; place-items: center; height: 100%; color: var(--dim); font-size: 11px; }

footer { display: flex; justify-content: space-between; padding: 16px 2px 0; color: var(--dim); font-size: 10px; }

button:focus-visible, select:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }

@media (max-width: 1180px) {
  .metric-deck { grid-template-columns: repeat(3, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .node-row { grid-template-columns: minmax(150px, 1.5fr) repeat(4, 1fr) 70px; }
  .node-row .hide-medium { display: none; }
}

@media (max-width: 720px) {
  .app-shell { padding: 16px; }
  .topbar { align-items: flex-start; }
  .clock-block span:not(.live-dot), .clock-block time { display: none; }
  .metric-deck { grid-template-columns: repeat(2, 1fr); }
  .metric-card { min-height: 118px; }
  .section-heading, .history-heading { align-items: flex-start; flex-direction: column; }
  .history-controls { width: 100%; align-items: stretch; flex-direction: column; }
  .range-switch { display: grid; grid-template-columns: repeat(4, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .node-row { grid-template-columns: 1.5fr 1fr 1fr; gap: 9px; }
  .node-row .hide-mobile, .node-state { display: none; }
  .legend { display: none; }
  footer { gap: 10px; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
