/* ============================================================================
   FLUXFORECAST — Carbon Edition
   Near-black base · Emerald accent · Zinc surfaces · Amber warnings
   ============================================================================ */

:root {
  color-scheme: dark;

  /* ── Surfaces ──────────────────────────────────────── */
  --bg:           #09090b;
  --surface-1:    rgba(255, 255, 255, 0.032);
  --surface-2:    rgba(255, 255, 255, 0.024);
  --surface-3:    rgba(255, 255, 255, 0.016);
  --surface-deep: rgba(0, 0, 0, 0.52);

  /* ── Borders ───────────────────────────────────────── */
  --border:        rgba(255, 255, 255, 0.09);
  --border-subtle: rgba(255, 255, 255, 0.055);
  --highlight:     rgba(255, 255, 255, 0.07);

  /* ── Text ──────────────────────────────────────────── */
  --t1: rgba(255, 255, 255, 0.93);
  --t2: rgba(255, 255, 255, 0.50);
  --t3: rgba(255, 255, 255, 0.26);
  --t4: rgba(255, 255, 255, 0.12);

  /* ── Accent: Emerald ───────────────────────────────── */
  --accent:        #34d399;
  --accent-lt:     #6ee7b7;
  --accent-dim:    rgba(52, 211, 153, 0.08);
  --accent-stroke: rgba(52, 211, 153, 0.28);
  --accent-glow:   rgba(52, 211, 153, 0.14);

  /* ── Status palette ────────────────────────────────── */
  --green:      #4ade80;
  --green-dim:  rgba(74, 222, 128, 0.08);
  --amber:      #fbbf24;
  --amber-lt:   #fde68a;
  --amber-dim:  rgba(251, 191, 36, 0.09);
  --red:        #f87171;
  --red-dim:    rgba(248, 113, 113, 0.09);
  --slate:      #94a3b8;
  --slate-dim:  rgba(148, 163, 184, 0.08);

  /* ── Elevation ─────────────────────────────────────── */
  --shadow-xs:    0 1px 3px  rgba(0,0,0,0.36);
  --shadow-sm:    0 4px 12px rgba(0,0,0,0.48);
  --shadow-md:    0 12px 28px rgba(0,0,0,0.56);
  --shadow-lg:    0 20px 56px rgba(0,0,0,0.68);
  --shadow-panel: 0 1px 0 var(--border-subtle) inset,
                  0 16px 40px rgba(0,0,0,0.44);

  /* ── Shape ─────────────────────────────────────────── */
  --r-xl: 22px;
  --r-lg: 18px;
  --r-md: 13px;
  --r-sm:  9px;
  --r-xs:  6px;

  /* ── Motion ────────────────────────────────────────── */
  --ease:   cubic-bezier(0.4, 0, 0.2, 1);
  --t:      180ms;
  --t-slow: 340ms;

  /* ── Type ──────────────────────────────────────────── */
  --sans: "Space Grotesk", "Inter", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, monospace;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--t1);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle noise texture */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.018;
  pointer-events: none;
  z-index: 0;
}

button, input { font: inherit; color: inherit; }
button { border: none; background: none; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── Layout ─────────────────────────────────────────── */
.fluxbridge {
  width: min(1280px, 96vw);
  margin: 24px auto 52px;
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 1;
}

/* ============================================================
   HEADER
   ============================================================ */
.fb-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 13px 20px;
  border-radius: var(--r-xl);
  border: 1px solid var(--border-subtle);
  background: var(--surface-1);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(24px) saturate(180%);
  position: relative;
  overflow: hidden;
}

.fb-header::before {
  content: "";
  position: absolute;
  top: 0; left: 20px; right: 20px; height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(52, 211, 153, 0.40) 28%,
    rgba(52, 211, 153, 0.22) 72%,
    transparent);
}

.fb-brand {
  display: flex;
  gap: 11px;
  align-items: center;
}

.brand-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(52, 211, 153, 0.10);
  border: 1px solid rgba(52, 211, 153, 0.22);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand-icon svg path, .brand-icon svg circle { fill: rgba(255,255,255,0.85); }

.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 0.84rem; letter-spacing: 0.24em; text-transform: uppercase; font-weight: 600; }
.brand-copy span   { font-size: 0.56rem; letter-spacing: 0.17em; text-transform: uppercase; color: var(--t3); }

.fb-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.fb-meta::before, .fb-meta::after {
  content: "";
  display: block;
  width: 1px; height: 28px;
  background: linear-gradient(180deg, transparent, var(--border) 38%, var(--border) 62%, transparent);
  flex-shrink: 0;
}

.meta-chip {
  padding: 6px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  text-align: center; min-width: 120px;
  display: grid; gap: 1px;
  box-shadow: inset 0 1px 0 var(--highlight);
  transition: border-color var(--t) var(--ease);
}
.meta-chip:hover { border-color: var(--border); }
.meta-chip span   { font-size: 0.38rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--t3); }
.meta-chip strong { font-size: 0.63rem; color: var(--accent-lt); }

.fb-actions { display: flex; align-items: center; gap: 9px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.ghost-btn {
  display: inline-flex;
  align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase;
  text-decoration: none; color: var(--t2);
  box-shadow: inset 0 1px 0 var(--highlight);
  transition:
    background var(--t) var(--ease),
    border-color var(--t) var(--ease),
    color var(--t) var(--ease),
    transform var(--t) var(--ease);
}
.ghost-btn svg { width: 13px; height: 13px; fill: currentColor; flex-shrink: 0; }
.ghost-btn.small { padding: 5px 11px; font-size: 0.55rem; }
.ghost-btn:hover {
  background: rgba(52, 211, 153, 0.09);
  border-color: var(--accent-stroke);
  color: var(--accent-lt);
  transform: translateY(-1px);
}
.ghost-btn:active { transform: none; }
.ghost-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.primary-btn {
  display: inline-flex;
  align-items: center; justify-content: center; gap: 6px;
  padding: 9px 20px;
  border-radius: 999px; border: 1px solid rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.13);
  color: var(--accent-lt);
  font-size: 0.61rem; font-weight: 600; letter-spacing: 0.17em; text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(52,211,153,0.18);
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease),
              transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
  position: relative; overflow: hidden;
}
.primary-btn:hover  {
  background: rgba(52, 211, 153, 0.20);
  border-color: rgba(52, 211, 153, 0.55);
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(52,211,153,0.18), inset 0 1px 0 rgba(52,211,153,0.22);
}
.primary-btn:active { transform: none; }
.primary-btn:disabled { opacity: 0.34; cursor: not-allowed; transform: none; box-shadow: none; }

/* ============================================================
   STATUS CHIP
   ============================================================ */
.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  font-size: 0.56rem; letter-spacing: 0.17em; text-transform: uppercase;
  color: var(--t3);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 var(--highlight);
}
.status-chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--t4); flex-shrink: 0;
  transition: background var(--t), box-shadow var(--t);
}
.status-chip.live  { border-color: rgba(52,211,153,0.25); color: rgba(110,231,183,0.92); }
.status-chip.live .dot { background: var(--accent); animation: livePulse 2.4s ease-in-out infinite; }
.status-chip.error .dot { background: var(--red); box-shadow: 0 0 8px rgba(248,113,113,0.5); }

@keyframes livePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
    44%   { box-shadow: 0 0 8px 3px rgba(52,211,153,0.45); }
}

/* ============================================================
   MAIN GRID
   ============================================================ */
.fb-main {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 10px; align-items: stretch;
}

/* ============================================================
   PANEL BASE
   ============================================================ */
.panel {
  background: var(--surface-1);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-subtle);
  padding: 18px 20px;
  display: grid; gap: 13px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(24px) saturate(180%);
}

.panel::before {
  content: "";
  position: absolute;
  top: 0; left: 20px; right: 20px; height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(52, 211, 153, 0.28) 35%,
    rgba(52, 211, 153, 0.14) 65%,
    transparent);
}

.panel.monitor  { grid-column: span 12; }
.panel.insights { grid-column: span 12; }
.panel.history  { grid-column: span 12; }

.panel header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel header .section-intro { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.panel header .section-intro h2 {
  margin: 0; font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.24em; color: var(--t2); font-weight: 500;
}
.panel header .section-intro p { margin: 0; font-size: 0.54rem; color: var(--t3); line-height: 1.65; max-width: 50ch; }

/* ============================================================
   MONITOR PANEL — merged telemetry + controls
   ============================================================ */
.monitor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.monitor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── Stream indicator pills ─────────────────────────── */
.stream-indicators { display: flex; flex-wrap: wrap; gap: 5px; }
.stream-indicators .pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; font-size: 0.49rem;
  letter-spacing: 0.13em; text-transform: uppercase; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border-subtle);
  color: var(--t3);
  box-shadow: inset 0 1px 0 var(--highlight);
  transition: background var(--t), border-color var(--t), color var(--t);
}
.stream-indicators .pill.live  { background: var(--green-dim); border-color: rgba(74,222,128,0.22); color: rgba(134,239,172,0.92); }
.stream-indicators .pill.alert { background: var(--amber-dim); border-color: rgba(251,191,36,0.22); color: rgba(253,211,77,0.92); }

/* ── Stream control buttons ─────────────────────────── */
.stream-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.stream-buttons .primary-btn,
.stream-buttons .ghost-btn { justify-content: center; }

/* ── Telemetry Stage ────────────────────────────────── */
.telemetry-stage {
  position: relative;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-deep);
  padding: 10px 10px 4px;
  min-height: 260px; display: grid;
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.6);
}

/* Fine dot-grid */
.telemetry-stage::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none; border-radius: inherit;
  z-index: 0;
}

#telemetryCanvas {
  width: 100%; height: 320px;
  border-radius: calc(var(--r-md) - 4px);
  position: relative; z-index: 1;
}

.telemetry-overlay {
  position: absolute; inset: 10px;
  border-radius: calc(var(--r-md) - 6px);
  display: grid; place-items: center;
  background: rgba(3,4,6,0.92);
  backdrop-filter: blur(16px); z-index: 2;
}
.telemetry-overlay.hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.36s ease, visibility 0s linear 0.36s;
}

.skeleton-chart {
  width: 84%; height: 60%; border-radius: 14px;
  background: rgba(255,255,255,0.03);
  position: relative; overflow: hidden;
}
.skeleton-chart::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.07) 44%, transparent 80%);
  transform: translateX(-100%);
  animation: shimmer 2s ease-in-out infinite;
}
@keyframes shimmer { 0%{transform:translateX(-100%)} 100%{transform:translateX(100%)} }

/* ── Legend ─────────────────────────────────────────── */
.telemetry-legend {
  display: flex; justify-content: space-between;
  flex-wrap: wrap; gap: 6px 16px;
  padding: 0 2px;
  font-size: 0.48rem; letter-spacing: 0.11em; text-transform: uppercase; color: var(--t3);
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 16px; height: 2.5px; border-radius: 999px; flex-shrink: 0; }
.swatch.primary        { background: rgba(226, 232, 240, 0.80); }
.swatch.actual         { background: rgba(52, 211, 153, 0.88); }
.swatch.threshold-low  { background: rgba(100, 116, 139, 0.65); }
.swatch.threshold-high { background: rgba(100, 116, 139, 0.65); }
.swatch.warning        { background: rgba(251, 191, 36, 0.88); }

/* ── Telemetry Meta Strip ───────────────────────────── */
.telemetry-meta { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.telemetry-meta div {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm); padding: 9px 11px;
  display: grid; gap: 4px;
  box-shadow: inset 0 1px 0 var(--highlight);
  transition: border-color var(--t);
}
.telemetry-meta div:hover { border-color: var(--border); }
.telemetry-meta span   { font-size: 0.42rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--t3); }
.telemetry-meta strong { font-family: var(--mono); font-size: 0.88rem; color: var(--t1); letter-spacing: -0.01em; }

/* ── Monitor Bottom Bar ─────────────────────────────── */
.monitor-bottom {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  box-shadow: inset 0 1px 0 var(--highlight);
}

.monitor-interval {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.56rem;
  color: var(--t2);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.monitor-interval input[type="range"] { width: 130px; accent-color: var(--accent); cursor: pointer; }
.monitor-interval output {
  font-family: var(--mono); font-size: 0.68rem; color: var(--accent-lt);
  background: var(--accent-dim);
  border: 1px solid rgba(52,211,153,0.18);
  border-radius: 999px; padding: 2px 9px;
  min-width: 44px; text-align: center;
}

.monitor-bottom .sep {
  width: 1px; align-self: stretch;
  background: var(--border-subtle);
  flex-shrink: 0;
}

/* ── Dataset Loader ─────────────────────────────────── */
.dataset-loader {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.dataset-loader .dataset-status {
  font-size: 0.50rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--t3);
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dataset-loader .ghost-btn { white-space: nowrap; flex-shrink: 0; }

/* helper text */
.helper-copy { font-size: 0.51rem; color: var(--t3); line-height: 1.65; margin: 0; }

/* ============================================================
   INSIGHT CARDS
   ============================================================ */
.insight-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }

.insight-card {
  background: var(--surface-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  padding: 16px 16px 14px;
  display: grid; gap: 7px;
  position: relative; overflow: hidden;
  box-shadow: inset 0 1px 0 var(--highlight);
  transition: border-color var(--t) var(--ease);
}
.insight-card:hover { border-color: var(--border); }

.insight-card::after {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 36px;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: linear-gradient(180deg, rgba(52,211,153,0.06), transparent);
  pointer-events: none;
}
.insight-card.actual::after  { background: linear-gradient(180deg, rgba(74,222,128,0.05), transparent); }
.insight-card.error::after   { background: linear-gradient(180deg, rgba(251,191,36,0.05), transparent); }
.insight-card.latency::after { background: linear-gradient(180deg, rgba(148,163,184,0.05), transparent); }
.insight-card.verdict::after { background: linear-gradient(180deg, rgba(52,211,153,0.07), transparent); }

.insight-card span   { font-size: 0.44rem; letter-spacing: 0.19em; text-transform: uppercase; color: var(--t3); position: relative; z-index: 1; }
.insight-card strong { font-size: 1.10rem; font-family: var(--mono); letter-spacing: -0.02em; position: relative; z-index: 1; }
.insight-card small  { font-size: 0.52rem; color: var(--t3); position: relative; z-index: 1; }

.insight-card.verdict { border-color: rgba(52,211,153,0.18); background: rgba(52,211,153,0.05); }
.insight-card.verdict strong { font-size: 1.14rem; letter-spacing: 0; transition: color 0.22s ease; }
.insight-card.verdict[data-status="low"]  { background: var(--slate-dim); border-color: rgba(148,163,184,0.22); }
.insight-card.verdict[data-status="low"] strong  { color: var(--slate); }
.insight-card.verdict[data-status="high"] { background: var(--amber-dim); border-color: rgba(251,191,36,0.24); }
.insight-card.verdict[data-status="high"] strong { color: var(--amber-lt); }

/* ============================================================
   EXPLANATION — pressure values
   ============================================================ */
.explanation {
  border: 1px solid var(--border-subtle); border-radius: var(--r-md);
  background: var(--surface-2); padding: 14px 16px 12px;
  display: grid; gap: 10px;
  box-shadow: inset 0 1px 0 var(--highlight);
}
.explanation header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.explanation h3 { margin: 0; font-size: 0.60rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--t2); }
.reading-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.reading-list li {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 9px; padding: 7px 11px;
  border-radius: var(--r-xs);
  background: var(--surface-3); border: 1px solid var(--border-subtle);
  font-family: var(--mono); font-size: 0.65rem; color: var(--t2);
  box-shadow: inset 0 1px 0 var(--highlight);
  transition: border-color var(--t);
}
.reading-list li:hover { border-color: var(--border); }

/* ============================================================
   HISTORY TABLE
   ============================================================ */
.history-table { border-radius: var(--r-md); border: 1px solid var(--border-subtle); background: var(--surface-deep); overflow: hidden; display: grid; }
.table-header {
  background: var(--surface-2); border-bottom: 1px solid var(--border-subtle);
  font-size: 0.47rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--t3);
  box-shadow: inset 0 1px 0 var(--highlight);
}
.table-header [role="row"] { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; padding: 9px 15px; }
.table-body { display: grid; gap: 3px; max-height: 240px; overflow: auto; padding: 7px 9px 10px; }
.table-body::-webkit-scrollbar { width: 3px; }
.table-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 999px; }
.table-body [role="row"] {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 10px; padding: 8px 9px;
  border-radius: var(--r-xs);
  background: var(--surface-3); border: 1px solid var(--border-subtle);
  font-size: 0.58rem; font-family: var(--mono); color: var(--t2);
  box-shadow: inset 0 1px 0 var(--highlight);
  transition: background var(--t), border-color var(--t);
}
.table-body [role="row"]:hover { background: rgba(255,255,255,0.03); border-color: var(--border); }
.table-body [role="row"].warning      { background: var(--amber-dim); border-color: rgba(251,191,36,0.18); }
.table-body [role="row"].warning.low  { background: var(--slate-dim); border-color: rgba(148,163,184,0.18); }
.table-body [role="row"].warning.high { background: var(--amber-dim); border-color: rgba(251,191,36,0.18); }

/* ============================================================
   FOOTER
   ============================================================ */
.fb-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; border-radius: var(--r-lg);
  border: 1px solid var(--border-subtle);
  background: var(--surface-1);
  box-shadow: inset 0 1px 0 var(--highlight);
  font-size: 0.48rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--t3);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-stack { position: fixed; right: 22px; bottom: 22px; display: grid; gap: 9px; z-index: 80; }
.toast {
  padding: 11px 16px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: rgba(9,9,11,0.96); color: var(--t1);
  font-size: 0.68rem; box-shadow: var(--shadow-lg), inset 0 1px 0 var(--highlight);
  backdrop-filter: blur(20px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.toast[data-variant="error"] { border-color: rgba(248,113,113,0.24); background: rgba(14,4,4,0.97); }

/* ============================================================
   LOADING
   ============================================================ */
.loading-overlay { position: fixed; inset: 0; display: none; place-items: center; background: rgba(4,4,6,0.92); backdrop-filter: blur(20px); z-index: 120; }
.loading-overlay.visible { display: grid; }
.loading-overlay[hidden]  { display: none !important; }

.loading-card {
  border-radius: var(--r-xl);
  background: var(--surface-1); border: 1px solid var(--border);
  padding: 30px 38px; display: grid; gap: 18px;
  text-align: center; max-width: 320px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 var(--highlight);
  backdrop-filter: blur(24px); position: relative; overflow: hidden;
}
.loading-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(52,211,153,0.55), transparent);
}
.loading-icon svg   { display: block; margin: 0 auto; }
.loading-icon .halo { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 1.5; }
.loading-icon .pulse {
  fill: none; stroke: var(--accent); stroke-width: 2.2;
  stroke-linecap: round; stroke-dasharray: 6 8;
  animation: pulseWave 1.4s ease-in-out infinite;
}
@keyframes pulseWave { 0%{stroke-dashoffset:0} 100%{stroke-dashoffset:-60} }
.loading-copy strong { display: block; font-size: 0.80rem; letter-spacing: 0.18em; text-transform: uppercase; }
.loading-copy span   { display: block; font-size: 0.63rem; color: var(--t2); line-height: 1.65; margin-top: 4px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-shell { position: fixed; inset: 0; z-index: 130; display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity 0.28s ease; }
.modal-shell[hidden] { display: none !important; }
.modal-shell.open    { opacity: 1; pointer-events: auto; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,3,4,0.82); backdrop-filter: blur(16px); }
.modal-card {
  position: relative;
  width: min(580px, 90vw); max-height: 80vh;
  border-radius: var(--r-xl);
  border: 1px solid var(--border); background: rgba(9,9,11,0.98);
  padding: 22px 24px; display: grid; gap: 14px; overflow: hidden;
  box-shadow: var(--shadow-lg), inset 0 1px 0 var(--highlight);
  backdrop-filter: blur(24px);
}
.modal-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(52,211,153,0.50), transparent);
}
.modal-card header { display: flex; justify-content: space-between; align-items: center; }
.modal-card h2 { margin: 0; font-size: 0.72rem; letter-spacing: 0.22em; text-transform: uppercase; }
.modal-close {
  width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface-2);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 var(--highlight);
  transition: background var(--t), border-color var(--t);
}
.modal-close:hover  { background: rgba(52,211,153,0.10); border-color: var(--accent-stroke); }
.modal-close svg    { width: 13px; height: 13px; stroke: var(--t2); stroke-width: 1.8; }
.modal-body         { display: grid; gap: 11px; font-size: 0.68rem; color: var(--t2); }
.sequence-scroll {
  border-radius: var(--r-md); border: 1px solid var(--border-subtle);
  background: var(--surface-deep); max-height: 46vh; overflow: auto;
  padding: 13px 15px; display: grid; gap: 5px;
  font-family: var(--mono); font-size: 0.63rem;
}
.sequence-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 999px; }
.sequence-scroll pre { margin: 0; white-space: pre-wrap; word-break: break-word; color: var(--t2); }
.modal-card footer { display: flex; justify-content: flex-end; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .monitor-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .monitor-toolbar { justify-content: flex-start; }
  .telemetry-meta { grid-template-columns: repeat(3, 1fr); }
  .insight-grid { grid-template-columns: repeat(3, 1fr); }
  .table-header [role="row"], .table-body [role="row"] { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .fb-header { grid-template-columns: 1fr; text-align: center; gap: 14px; }
  .fb-meta   { order: 3; justify-content: center; flex-wrap: wrap; }
  .fb-meta::before, .fb-meta::after { display: none; }
  .fb-actions { justify-content: center; flex-wrap: wrap; }
  .telemetry-meta { grid-template-columns: repeat(2, 1fr); }
  .insight-grid { grid-template-columns: repeat(2, 1fr); }
  .table-header [role="row"], .table-body [role="row"] { grid-template-columns: repeat(2, 1fr); }
  .monitor-bottom { flex-direction: column; align-items: stretch; }
  .monitor-bottom .sep { width: auto; height: 1px; }
}

/* ============================================================
   GLOBAL
   ============================================================ */
::-webkit-scrollbar           { width: 4px; height: 4px; }
::-webkit-scrollbar-track     { background: transparent; }
::-webkit-scrollbar-thumb     { background: rgba(255,255,255,0.08); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover{ background: rgba(255,255,255,0.16); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent; }
::selection      { background: rgba(52,211,153,0.22); color: var(--t1); }
::-moz-selection { background: rgba(52,211,153,0.22); color: var(--t1); }

input, textarea, select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--t1);
  padding: 7px 11px; font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--t3); }
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
