:root {
  --bg: #080e17;
  --bg-elevated: rgba(12, 23, 38, 0.92);
  --panel: rgba(14, 22, 34, 0.95);
  --panel-strong: rgba(18, 28, 42, 0.98);
  --border: rgba(159, 176, 204, 0.12);
  --border-focus: rgba(106, 194, 255, 0.40);
  --text: #f5f7fb;
  --text-dim: #6b7d96;
  --muted: #9fb0cc;
  --accent: #6ac2ff;
  --accent-warm: #ffd166;
  --accent-green: #8dd3c7;
  --danger: #ff7b72;
  --warn: #f4b65f;
  --ok: #7fd4ae;
  --font-sans: "Suisse Int'l", "Avenir Next", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", "Menlo", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

body {
  min-height: 100vh;
}

/* ── Terminal Layout ── */

.terminalLayout {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  grid-template-rows: 1fr 28px;
  min-height: 100vh;
}

.terminalMain {
  padding: 16px 20px;
  padding-bottom: 36px;
  overflow-y: auto;
  grid-row: 1;
  grid-column: 2;
}

/* ── Rail Nav ── */

.railNav {
  grid-row: 1 / -1;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 0;
  gap: 2px;
  border-right: 1px solid var(--border);
  background: rgba(6, 10, 18, 0.95);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 100;
}

.railBrand {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  padding: 4px 12px 12px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
}

.railItems {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  flex: 1;
}

.railItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  border-left: 2px solid transparent;
  transition: color 120ms, border-color 120ms, background 120ms;
  cursor: pointer;
}

.railItem:hover {
  color: var(--text);
  background: rgba(106, 194, 255, 0.06);
}

.railItem.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.railKey {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  background: rgba(12, 20, 33, 0.6);
}

.railItem.active .railKey {
  color: var(--accent);
  border-color: rgba(106, 194, 255, 0.3);
}

.railLabel {
  opacity: 1;
}

/* ── Status Bar ── */

.statusBar {
  grid-row: 2;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 28px;
  border-top: 1px solid var(--border);
  background: rgba(6, 10, 18, 0.95);
  font-size: 11px;
  color: var(--text-dim);
  z-index: 100;
}

.statusLeft,
.statusCenter,
.statusRight {
  display: flex;
  align-items: center;
  gap: 8px;
}

.statusCenter {
  color: var(--muted);
}

/* ── Live Dot ── */

.liveDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.liveDotConnected {
  background: var(--ok);
  animation: dotPulse 2s ease-in-out infinite;
}

.liveDotDisconnected {
  background: var(--danger);
}

.liveDotConnecting {
  background: var(--text-dim);
  animation: dotPulse 1s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ── Page Structure ── */

.pageStack {
  display: grid;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
  font-family: var(--font-mono);
}

.sectionHeading h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sectionHeading p {
  display: none;
}

/* ── Metric Grid ── */

.metricGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.miniMetric {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 0;
}

.miniMetricLabel {
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.miniMetricValue {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Panel ── */

.panel {
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--panel);
  padding: 10px 12px;
}

.panelGrid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panelHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.panelHeader h3 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panelHeader p {
  color: var(--text-dim);
  font-size: 0.72rem;
  margin: 0;
  display: none;
}

/* ── Toolbar ── */

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toolbar select,
.terminalSelect {
  padding: 4px 8px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%236b7d96'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 20px;
}

.toolbar select option,
.terminalSelect option {
  background: #0c1421;
  color: var(--text);
}

.terminalSelect:focus,
.toolbar select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Status Badge ── */

.statusBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  border: 1px solid transparent;
}

.statusOk {
  color: var(--ok);
  background: rgba(127, 212, 174, 0.08);
  border-color: rgba(127, 212, 174, 0.25);
}

.statusWarn {
  color: var(--warn);
  background: rgba(244, 182, 95, 0.08);
  border-color: rgba(244, 182, 95, 0.25);
}

.statusError {
  color: var(--danger);
  background: rgba(255, 123, 114, 0.08);
  border-color: rgba(255, 123, 114, 0.25);
}

.statusNeutral {
  color: var(--muted);
  background: rgba(159, 176, 204, 0.06);
  border-color: rgba(159, 176, 204, 0.15);
}

.statusLive {
  color: var(--accent-green);
  background: rgba(141, 211, 199, 0.08);
  border-color: rgba(141, 211, 199, 0.25);
}

.statusPulse {
  animation: dotPulse 1.5s ease-in-out infinite;
}

/* ── Data Table ── */

.tableWrap {
  overflow: auto;
}

.dataTable {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.dataTable th,
.dataTable td {
  padding: 4px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(159, 176, 204, 0.06);
  font-size: 12px;
  font-family: var(--font-mono);
}

.dataTable th {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
}

.dataTable tbody tr {
  transition: background 80ms;
}

.dataTable tbody tr:hover {
  background: rgba(106, 194, 255, 0.04);
}

.dataTable tbody tr.rowActive {
  background: rgba(106, 194, 255, 0.08);
}

.dataTable tbody tr.rowClickable {
  cursor: pointer;
}

.emptyCell {
  color: var(--muted);
  text-align: center;
  padding: 16px 8px;
}

/* ── Lists ── */

.summaryList,
.datasetList,
.runList,
.playbookList {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0;
}

.summaryList li,
.datasetList li,
.runList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(159, 176, 204, 0.06);
  font-size: 12px;
}

.summaryList li span,
.datasetList li span,
.runList li span {
  color: var(--text-dim);
}

/* ── Playbook ── */

.playbookPanel {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.playbookSection {
  display: grid;
  gap: 4px;
}

.playbookList {
  margin-top: 0;
}

.playbookList li {
  color: var(--muted);
  line-height: 1.45;
  font-size: 12px;
}

/* ── Charts ── */

.chartGrid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.chartGrid > .panel {
  min-width: 0;
}

/* When 2 charts, show side by side */
.chartGrid:has(> :nth-child(2):last-child) {
  grid-template-columns: 1fr 1fr;
}

/* When 3+ charts, 2-col grid */
.chartGrid:has(> :nth-child(3)) {
  grid-template-columns: 1fr 1fr;
}

.chartEmpty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* ── Two Column Layout ── */

.twoCol {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.twoColNarrow {
  display: grid;
  gap: 12px;
}

.twoColWide {
  display: grid;
  gap: 12px;
}

/* ── Tab Bar ── */

.tabBar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.tabItem {
  padding: 6px 14px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 120ms, border-color 120ms;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tabItem:hover {
  color: var(--text);
}

.tabActive {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Command Palette ── */

.commandBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
}

.commandPalette {
  width: 480px;
  max-height: 400px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.commandInput {
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}

.commandInput::placeholder {
  color: var(--text-dim);
}

.commandList {
  overflow-y: auto;
  flex: 1;
}

.commandItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  transition: background 80ms, color 80ms;
}

.commandItem:hover,
.commandItemActive {
  background: rgba(106, 194, 255, 0.08);
  color: var(--text);
}

.commandItemType {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Keyboard Hint ── */

.kbdHint {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  color: var(--text-dim);
}

.kbdHint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: rgba(12, 20, 33, 0.5);
  color: var(--muted);
}

/* ── Misc ── */

.unstyledLink {
  text-decoration: none;
}

.fetchingIndicator {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--accent);
  letter-spacing: 0.06em;
  animation: fetchPulse 1.2s ease-in-out infinite;
}

@keyframes fetchPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.inlineSummary {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0;
}

.inlineSummary strong {
  color: var(--text);
  font-weight: 600;
}

.inlineSummary .sep {
  color: var(--text-dim);
}

/* ── Responsive ── */

.mobileNavToggle {
  display: none;
}

@media (max-width: 1200px) {
  .panelGrid {
    grid-template-columns: 1fr 1fr;
  }
  .twoCol {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 920px) {
  .terminalLayout {
    grid-template-columns: 1fr;
  }

  .railNav {
    display: none;
  }

  .mobileNavToggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 200;
    width: 36px;
    height: 36px;
    border-radius: 3px;
    border: 1px solid var(--border);
    background: var(--panel-strong);
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
  }

  .terminalMain {
    grid-column: 1;
    padding: 12px;
    padding-top: 52px;
  }

  .twoCol {
    grid-template-columns: 1fr;
  }

  .panelGrid {
    grid-template-columns: 1fr;
  }
}
