/* ═══════════════════════════════════════════════════════════════════════════
   SGM Terminal — design system. Dark-only. No Bootstrap CSS on any page;
   Bootstrap JS (tabs, modal) relies on the structural rules in §7.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── §1 Tokens ── */
:root {
  --t-bg:        #0a0e12;
  --t-panel:     #0e141b;
  --t-panel-alt: #141b24;
  --t-border:    #1c2530;
  --t-text:      #dce3ec;
  --t-muted:     #5a6b80;
  --t-amber:     #e8b339;
  --t-green:     #26d97f;
  --t-green-dim: #1c6e48;
  --t-red:       #ff5c5c;
  --t-blue:      #4da3ff;
  --t-mono:      "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --t-display:   "Bebas Neue", var(--t-mono);
}

/* ── §2 Reset & base ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--t-bg);
  color: var(--t-text);
  font-family: var(--t-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6, p { margin: 0 0 0.75rem; font-weight: 500; }
a { color: var(--t-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
hr { border: none; border-top: 1px solid var(--t-border); margin: 1.5rem 0; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--t-bg); }
::-webkit-scrollbar-thumb { background: var(--t-border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--t-muted); }
::selection { background: rgba(232,179,57,0.25); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── §3 Layout ── */
.t-main { max-width: 1320px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }
.t-grid { display: grid; gap: 8px; }
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 12px; }
@media (max-width: 992px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.charts-row { display: grid; grid-template-columns: 3fr 2fr 2fr; gap: 8px; margin-bottom: 12px; }
@media (max-width: 992px) { .charts-row { grid-template-columns: 1fr; } }

/* ── §4 Labels & type helpers ── */
.t-label {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--t-muted);
}
.brand-mark {
  font-family: var(--t-display);
  font-size: 1.3rem;
  letter-spacing: 0.18em;
  color: var(--t-amber);
  line-height: 1;
}
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--t-green); }
.neg { color: var(--t-red); }
.text-muted { color: var(--t-muted) !important; }
.section-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t-muted);
  margin-bottom: 0.75rem;
}
.section-headline {
  font-family: var(--t-display);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  color: var(--t-text);
  margin-bottom: 0.75rem;
}
.section-sub { font-size: 0.78rem; color: var(--t-muted); margin-bottom: 0; }

/* ── §5 Components ── */
.kpi-card {
  background: var(--t-panel);
  border: 1px solid var(--t-border);
  padding: 12px 14px;
}
.kpi-label { font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--t-muted); }
.kpi-value { font-size: 1.35rem; font-weight: 600; margin-top: 4px; line-height: 1.2; }
.kpi-delta { font-size: 0.68rem; margin-top: 2px; color: var(--t-muted); }

.chart-panel {
  background: var(--t-panel);
  border: 1px solid var(--t-border);
  padding: 12px 14px;
  min-width: 0; /* allow canvas to shrink inside grid */
}
.panel-title {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--t-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.t-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.t-table th {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--t-muted);
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--t-border);
  white-space: nowrap;
}
.t-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--t-panel-alt);
  color: var(--t-text);
  vertical-align: middle;
}
.t-table tbody tr:hover { background: var(--t-panel-alt); }
.t-table th.num { text-align: right; }
.table-wrap { overflow-x: auto; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 10px;
  border: 1px solid var(--t-border);
  background: var(--t-panel);
  color: var(--t-muted);
  white-space: nowrap;
}
.status-pill::before { content: '●'; font-size: 0.55rem; }
.status-pill--ok    { color: var(--t-green); border-color: rgba(38,217,127,0.35); }
.status-pill--stale { color: var(--t-amber); border-color: rgba(232,179,57,0.35); }
.status-pill--error { color: var(--t-red);   border-color: rgba(255,92,92,0.35); }

.error-banner {
  background: var(--t-panel);
  border: 1px solid rgba(255,92,92,0.4);
  border-left: 3px solid var(--t-red);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.8rem;
}
.error-banner strong { color: var(--t-red); }
.error-banner code {
  background: var(--t-panel-alt);
  padding: 1px 6px;
  font-family: var(--t-mono);
  font-size: 0.75rem;
}

.t-btn {
  font-family: var(--t-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--t-muted);
  background: var(--t-panel);
  border: 1px solid var(--t-border);
  padding: 6px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.t-btn:hover { color: var(--t-text); border-color: var(--t-muted); }
.t-btn--primary { color: var(--t-amber); border-color: rgba(232,179,57,0.45); }
.t-btn--primary:hover { color: var(--t-amber); border-color: var(--t-amber); }
.t-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.t-input, .t-select {
  font-family: var(--t-mono);
  font-size: 0.78rem;
  color: var(--t-text);
  background: var(--t-panel-alt);
  border: 1px solid var(--t-border);
  padding: 6px 10px;
  outline: none;
}
.t-input:focus, .t-select:focus { border-color: var(--t-amber); }
.t-input::placeholder { color: var(--t-muted); }
.t-select { appearance: none; }

.range-pills { display: inline-flex; gap: 2px; }
.range-pill {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--t-muted);
  background: transparent;
  border: 1px solid transparent;
  padding: 2px 8px;
  cursor: pointer;
  font-family: var(--t-mono);
}
.range-pill:hover { color: var(--t-text); }
.range-pill.active { color: var(--t-amber); border-color: rgba(232,179,57,0.45); }

/* ── §6 Ticker strip ── */
.ticker {
  display: flex;
  gap: 22px;
  padding: 8px 1.5rem;
  border-bottom: 1px solid var(--t-border);
  font-size: 0.68rem;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.ticker::-webkit-scrollbar { display: none; }
.ticker-item { color: var(--t-text); flex-shrink: 0; }
.ticker-label { color: var(--t-muted); letter-spacing: 0.08em; margin-right: 5px; }
.degraded { opacity: 0.55; } /* stale/unreachable data: ticker, chart panels */

/* ── §7 Bootstrap JS structural support (CSS removed, JS kept) ── */
/* Tabs — markup keeps .nav-tabs/.nav-link/.tab-content/.tab-pane for bootstrap.bundle */
.nav-tabs { display: flex; gap: 18px; list-style: none; margin: 0 0 1.5rem; padding: 0; border-bottom: 1px solid var(--t-border); flex-wrap: wrap; }
.nav-tabs .nav-item { margin: 0; }
.nav-tabs .nav-link {
  display: block;
  font-family: var(--t-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--t-muted);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0.6rem 0.1rem;
  margin-bottom: -1px;
  cursor: pointer;
}
.nav-tabs .nav-link:hover { color: var(--t-text); text-decoration: none; }
.nav-tabs .nav-link.active { color: var(--t-amber); border-bottom-color: var(--t-amber); }
.tab-content > .tab-pane { display: none; }
.tab-content > .active { display: block; }
.fade { transition: opacity 0.15s linear; }
.fade:not(.show) { opacity: 0; }

/* Modal — minimal structural rules for bootstrap.bundle's Modal */
.modal { position: fixed; inset: 0; z-index: 1055; display: none; overflow-y: auto; }
.modal.show { display: block; }
.modal-dialog { max-width: 720px; margin: 6vh auto; padding: 0 16px; position: relative; }
.modal-lg { max-width: 900px; }
.modal-content {
  background: var(--t-panel);
  border: 1px solid var(--t-border);
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--t-border);
}
.modal-title { font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--t-muted); margin: 0; }
.modal-body { padding: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--t-border); }
.modal-backdrop { position: fixed; inset: 0; z-index: 1050; background: #000; }
.modal-backdrop.fade { opacity: 0; }
.modal-backdrop.show { opacity: 0.65; }
.modal-open { overflow: hidden; }
.btn-close {
  background: transparent;
  border: none;
  color: var(--t-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.btn-close::before { content: '✕'; }
.btn-close:hover { color: var(--t-red); }

/* ── §8 Bootstrap utility compat (only the classes templates keep) ── */
.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.ms-auto { margin-left: auto !important; }
.me-4 { margin-right: 1.5rem !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.flex-grow-1 { flex-grow: 1 !important; }

/* ── §9 Sortable table headers (carried over) ── */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable::after { content: ' ⇅'; opacity: 0.25; font-size: 0.75em; margin-left: 2px; }
th.sort-asc::after  { content: ' ▲'; opacity: 0.65; }
th.sort-desc::after { content: ' ▼'; opacity: 0.65; }
