/* ForeGlass Credit & Financing Radar — Nuanced comuvia.ai Light-First Optical Glass Styles
 * Grounded in frontends/comuvia/src/app/globals.css (cool-tinted #e9edf0 ground with
 * sky/teal/amber atmospheric corner washes + #f4f8f9 cool-frosted cards, NOT stark white),
 * with optional html[data-theme="dark"] secondary dark-glass support.
 */
:root {
  --bg-0: #e9edf0;
  --bg-1: #e9edf0;
  --bg-2: #e4eaee;
  --panel: rgba(244, 248, 249, 0.86);
  --panel-2: rgba(249, 252, 253, 0.94);
  --glass-inset: rgba(255, 255, 255, 0.88);
  --glass-shadow: 0 4px 16px rgba(15, 40, 60, 0.07);
  --border: #d6dee2;
  --teal: #0f766e;
  --emerald: #059669;
  --sky: #0369a1;
  --gold: #b45309;
  --amber: #d97706;
  --coral: #be123c;
  --white: #111111;
  --soft: #334155;
  --muted: #526273;
  --sub-bg: #eaf1f2;
  --gradient-accent: linear-gradient(135deg, #0369a1 0%, #0e7490 50%, #0f766e 100%);
  --canvas-bg:
    radial-gradient(520px 380px at 14% 12%, rgba(56, 189, 248, 0.11), transparent 65%),
    radial-gradient(500px 360px at 88% 84%, rgba(45, 212, 191, 0.10), transparent 62%),
    radial-gradient(circle at 50% 48%, #f8fbfc 0%, #edf3f5 62%, #e2eaee 100%);
  --mc-bg: #f8fbfc;
  --mono: ui-monospace, "SF Mono", Monaco, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

:root[data-theme="dark"] {
  --bg-0: #061629;
  --bg-1: #0a2340;
  --bg-2: #0e3256;
  --panel: rgba(11, 34, 60, 0.78);
  --panel-2: rgba(15, 44, 76, 0.88);
  --glass-inset: rgba(255, 255, 255, 0.14);
  --glass-shadow: 0 14px 36px rgba(2, 10, 22, 0.44);
  --border: rgba(115, 178, 230, 0.28);
  --teal: #5eead4;
  --emerald: #34d399;
  --sky: #38bdf8;
  --gold: #f4b95a;
  --amber: #fbbf24;
  --coral: #fb7185;
  --white: #f4f8fc;
  --soft: #c6daec;
  --muted: #8eb0ce;
  --sub-bg: rgba(7, 25, 46, 0.78);
  --canvas-bg: radial-gradient(circle at 50% 48%, rgba(16, 54, 92, 0.44), rgba(5, 18, 34, 0.90) 76%);
  --mc-bg: rgba(5, 19, 36, 0.82);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 600px at 6% -8%, rgba(56, 189, 248, 0.14), transparent 62%),
    radial-gradient(1000px 560px at 104% -2%, rgba(45, 212, 191, 0.13), transparent 58%),
    radial-gradient(820px 520px at 96% 116%, rgba(251, 146, 60, 0.07), transparent 60%),
    linear-gradient(180deg, color-mix(in srgb, #2dd4bf 5%, var(--bg-0)) 0%, var(--bg-0) 34%);
  background-repeat: no-repeat;
  color: var(--white);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(1200px 680px at 84% 12%, rgba(56, 189, 248, 0.10), transparent 64%),
    radial-gradient(960px 620px at 14% 88%, rgba(94, 234, 212, 0.08), transparent 62%),
    linear-gradient(135deg, var(--bg-0) 0%, var(--bg-1) 54%, var(--bg-2) 100%);
}

/* Nuanced comuvia.ai frosted header surface */
header.fg-site-header {
  background: color-mix(in srgb, #ffffff 90%, #f4f8f9);
  backdrop-filter: saturate(1.15) blur(10px);
  -webkit-backdrop-filter: saturate(1.15) blur(10px);
  border-bottom: 1px solid #d5e2e5;
  box-shadow: 0 1px 4px rgba(15, 35, 42, 0.06);
}

/* Keep ForeGlass shared site header crisp in Dark Preview mode too */
:root[data-theme="dark"] header.fg-site-header {
  background: rgba(6, 22, 41, 0.92);
  border-bottom-color: rgba(115, 178, 230, 0.24);
  color: #f4f8fc;
}
:root[data-theme="dark"] .fg-site-brand img { filter: invert(1) brightness(1.15); }
:root[data-theme="dark"] .fg-site-nav > a,
:root[data-theme="dark"] .fg-menu > summary,
:root[data-theme="dark"] .fg-mech-menu > summary,
:root[data-theme="dark"] .nav-dropdown__trigger { color: #dce9f5 !important; }
:root[data-theme="dark"] .fg-site-nav > a[aria-current="page"] { background: rgba(45, 212, 191, 0.16); color: #5eead4 !important; }

.brandline { height: 3px; background: var(--gradient-brandline); }

.card, .plan-hero, .g-card, .hud-footer, .radar-hero-bar {
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-inset);
}
@media (prefers-reduced-transparency: reduce) {
  .card, .plan-hero, .g-card, .hud-footer, .radar-hero-bar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px clamp(14px, 2.2vw, 28px) 28px;
  transition: max-width .25s ease;
}
body.clip-mode .wrap { max-width: 780px; }
body.clip-mode .hud-grid { grid-template-columns: 1fr 1fr; }
body.clip-mode .col-center { grid-column: 1 / -1; order: -1; }
body.clip-mode .flow-card { min-height: 0; }
body.clip-mode .flow-wrap { flex: 0 0 auto; height: 420px; min-height: 420px; }

/* Native foreglass.ai editorial hero strip */
.radar-hero-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 14px;
  background-image: var(--gradient-brandline);
  background-repeat: no-repeat;
  background-size: 100% 3px;
  background-position: top left;
}
.radar-hero-copy { max-width: 760px; }
.radar-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--teal);
  margin: 0 0 3px;
}
.radar-hero-copy h1 {
  margin: 0 0 3px;
  font-size: clamp(1.38rem, 2.3vw, 1.85rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.18;
  color: var(--white);
}
.radar-hero-copy h1 em { font-style: normal; color: var(--teal); }
.radar-hero-copy p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.radar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.nav-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--sub-bg);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.tab-btn {
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font: 600 0.78rem var(--sans);
  padding: 6px 12px;
  border-radius: 7px;
  transition: .14s;
}
.tab-btn:hover { color: var(--teal); }
.tab-btn.active {
  background: var(--gradient-accent);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 118, 110, 0.22);
}
:root[data-theme="dark"] .tab-btn.active {
  background: rgba(56, 189, 248, 0.20);
  color: #f4f8fc;
  box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.45);
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--sub-bg);
  font: 600 0.72rem var(--mono);
  color: var(--soft);
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px rgba(5, 150, 105, 0.55);
  display: inline-block;
  animation: blink 2s infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.util-btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--soft);
  font: 600 0.75rem var(--sans);
  padding: 6px 10px;
  border-radius: 8px;
  transition: .14s;
}
.util-btn:hover { border-color: var(--teal); color: var(--teal); }
.util-btn.active { background: #d8f3ee; border-color: #0f766e; color: #0f766e; }
:root[data-theme="dark"] .util-btn.active { background: rgba(244, 185, 90, 0.22); border-color: var(--gold); color: var(--gold); }

/* 3-Column Semantic Grid */
.hud-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.02fr) minmax(460px, 1.48fr) minmax(320px, 1.02fr);
  gap: 14px;
  align-items: stretch;
}
@media (max-width: 1220px) {
  .hud-grid { grid-template-columns: 1fr 1fr; }
  .col-center { grid-column: 1 / -1; order: -1; }
  .flow-card { min-height: 0; }
  .flow-wrap { flex: 0 0 auto; height: 446px; }
}
@media (max-width: 780px) { .hud-grid { grid-template-columns: 1fr; } }

.col-stack { display: flex; flex-direction: column; gap: 14px; }
.card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--cap, var(--gradient-brandline));
}
.card.cap-gold { --cap: linear-gradient(90deg, #f59e0b, #fbbf24); }
.card.cap-teal { --cap: var(--gradient-brandline); }
.card.cap-coral { --cap: linear-gradient(90deg, #be123c, #f43f5e); }
.card.cap-sky { --cap: linear-gradient(90deg, #0ea5e9, #0f766e); }

.card-hdr { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.card-title { font: 650 0.86rem var(--sans); letter-spacing: -0.01em; color: var(--white); }
.badge {
  font: 700 0.68rem var(--mono);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #b8e2db;
  color: var(--teal);
  background: #d8f3ee;
}
.badge.warn { color: var(--gold); border-color: #f4d38b; background: #fef3c7; }
.badge.risk { color: var(--coral); border-color: #f6b8c6; background: #ffe4e8; }
:root[data-theme="dark"] .badge { border-color: var(--border); background: rgba(94, 234, 212, 0.10); }
:root[data-theme="dark"] .badge.warn { border-color: rgba(244, 185, 90, 0.45); background: rgba(244, 185, 90, 0.12); }
:root[data-theme="dark"] .badge.risk { border-color: rgba(251, 113, 133, 0.50); background: rgba(251, 113, 133, 0.14); }

/* Engine Stress Regime Switcher */
.regime-card { padding: 12px 15px; }
.regime-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.sc-btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--sub-bg);
  color: var(--soft);
  font: 600 0.74rem var(--sans);
  padding: 7px 9px;
  border-radius: 8px;
  text-align: left;
  transition: .14s;
  line-height: 1.28;
}
.sc-btn:hover { border-color: var(--teal); color: var(--teal); background: #eaf5f4; }
.sc-btn.active { border-color: #0f766e; background: #d8f3ee; color: #0b5c56; font-weight: 700; }
.sc-btn.active.danger { border-color: #be123c; background: #ffe4e8; color: #9f1239; }
:root[data-theme="dark"] .sc-btn:hover { background: rgba(56, 189, 248, 0.12); color: #f4f8fc; }
:root[data-theme="dark"] .sc-btn.active { border-color: var(--gold); background: rgba(244, 185, 90, 0.18); color: var(--gold); }
:root[data-theme="dark"] .sc-btn.active.danger { border-color: var(--coral); background: rgba(251, 113, 133, 0.18); color: var(--coral); }

/* Center Column: Live Tape + 3D Stage */
.flow-card { display: flex; flex-direction: column; justify-content: space-between; flex: 1; min-height: 620px; padding: 14px 15px; }
.center-ticker {
  display: flex;
  align-items: center;
  overflow: hidden;
  height: 34px;
  margin-bottom: 8px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid #bfdcdc;
}
:root[data-theme="dark"] .center-ticker { background: rgba(5, 19, 36, 0.94); border-color: rgba(94, 234, 212, 0.34); }
.ticker-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 10px;
  background: #d8f3ee;
  border-right: 1px solid #bfdcdc;
  font: 700 0.68rem var(--mono);
  letter-spacing: 0.06em;
  color: #0b5c56;
}
:root[data-theme="dark"] .ticker-badge { background: rgba(14, 50, 86, 0.96); border-right-color: rgba(94, 234, 212, 0.32); color: var(--teal); }
.ticker-viewport { flex: 1; overflow: hidden; position: relative; height: 100%; display: flex; align-items: center; }
.ticker-viewport::before, .ticker-viewport::after { content: ""; position: absolute; top: 0; bottom: 0; width: 20px; z-index: 2; pointer-events: none; }
.ticker-viewport::before { left: 0; background: linear-gradient(90deg, var(--panel-2), transparent); }
.ticker-viewport::after { right: 0; background: linear-gradient(270deg, var(--panel-2), transparent); }
.ticker-track { display: inline-flex; align-items: center; white-space: nowrap; will-change: transform; animation: tickerScroll 46s linear infinite; }
.center-ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes tickerScroll { 0% { transform: translate3d(0,0,0); } 100% { transform: translate3d(-50%,0,0); } }
.tk-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 12px;
  font: 600 0.72rem var(--mono);
  color: var(--soft);
  border-right: 1px solid var(--border);
}
.tk-item:hover { background: #eaf5f4; color: var(--white); }
:root[data-theme="dark"] .tk-item:hover { background: rgba(56, 189, 248, 0.16); }
.tk-sym { color: var(--white); font-weight: 700; }
.tk-val { color: var(--sky); }
.tk-up  { color: var(--coral); }
.tk-ok  { color: var(--teal); }
.tk-gd  { color: var(--gold); }
.tk-tag { font-size: 9px; padding: 1px 5px; border-radius: 4px; background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.tk-tag.risk { background: #ffe4e8; color: #be123c; border-color: #fecdd3; }
.tk-tag.warn { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.tk-tag.ok   { background: #d8f3ee; color: #0f766e; border-color: #a7dfd6; }
:root[data-theme="dark"] .tk-tag { background: rgba(56,189,248,0.14); color: var(--sky); border-color: rgba(56,189,248,0.35); }
:root[data-theme="dark"] .tk-tag.risk { background: rgba(251,113,133,0.16); color: var(--coral); border-color: rgba(251,113,133,0.45); }
:root[data-theme="dark"] .tk-tag.warn { background: rgba(244,185,90,0.15); color: var(--gold); border-color: rgba(244,185,90,0.45); }
:root[data-theme="dark"] .tk-tag.ok   { background: rgba(94,234,212,0.13); color: var(--teal); border-color: rgba(94,234,212,0.40); }
.ticker-pulse-btn {
  flex-shrink: 0;
  cursor: pointer;
  height: 100%;
  border: none;
  border-left: 1px solid #bfdcdc;
  background: #fef3c7;
  color: #92400e;
  padding: 0 10px;
  font: 700 0.68rem var(--mono);
}
.ticker-pulse-btn:hover { background: #fde68a; }
:root[data-theme="dark"] .ticker-pulse-btn { background: rgba(13,38,66,0.92); border-left-color: rgba(92,152,202,0.32); color: var(--gold); }

.flow-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  align-items: center;
  margin-bottom: 8px;
  font: 600 0.72rem var(--sans);
  color: var(--soft);
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--sub-bg);
  border: 1px solid var(--border);
}
.fl-item { display: flex; align-items: center; gap: 5px; }
.fl-line { display: inline-block; width: 15px; height: 3.5px; border-radius: 2px; }
.flow-wrap {
  position: relative;
  flex: 1;
  min-height: 446px;
  border-radius: 11px;
  overflow: hidden;
  background: var(--canvas-bg);
  border: 1px solid var(--border);
}
#flowCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.flow-inspector {
  margin-top: 9px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--sub-bg);
  border: 1px solid #c3dfdd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font: 500 0.76rem var(--sans);
  color: var(--soft);
}
:root[data-theme="dark"] .flow-inspector { border-color: rgba(94, 234, 212, 0.30); }
.flow-inspector strong { color: var(--teal); font-weight: 700; }
.flow-hint {
  position: absolute;
  bottom: 8px;
  right: 10px;
  pointer-events: none;
  font: 600 0.68rem var(--mono);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.88);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
:root[data-theme="dark"] .flow-hint { background: rgba(6, 22, 41, 0.84); }

/* Gauge & Treasury Sparkline */
.gauge-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: center; }
.gauge-box { position: relative; width: 110px; height: 94px; display: flex; align-items: center; justify-content: center; }
.gauge-val { position: absolute; bottom: 12px; text-align: center; }
.gauge-num { font: 700 25px var(--mono); color: var(--gold); line-height: 1; font-variant-numeric: tabular-nums; }
.gauge-lbl { font: 600 9px var(--mono); color: var(--muted); margin-top: 2px; }
.metric-list { display: flex; flex-direction: column; gap: 5px; }
.m-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.76rem; border-bottom: 1px dashed var(--border); padding-bottom: 3px; }
.m-row span:first-child { color: var(--muted); }
.m-row strong { font-family: var(--mono); color: var(--white); font-variant-numeric: tabular-nums; }
.spark-wrap { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.spark-hdr { display: flex; justify-content: space-between; font: 600 0.68rem var(--mono); color: var(--muted); margin-bottom: 3px; }
#treasuryCanvas { width: 100%; height: 64px; display: block; }

/* ForeGlass Engine MC Canvas */
#mcCanvas { width: 100%; height: 224px; display: block; border-radius: 9px; background: var(--mc-bg); border: 1px solid var(--border); cursor: crosshair; }
.mc-wrap { position: relative; }
.mc-bar { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.mc-modes { display: inline-flex; gap: 3px; background: var(--sub-bg); border: 1px solid var(--border); border-radius: 7px; padding: 2px; }
.mc-mbtn {
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  font: 600 0.70rem var(--sans);
  padding: 3px 8px;
  border-radius: 5px;
  transition: .14s;
}
.mc-mbtn.active { background: var(--gradient-accent); color: #ffffff; }
:root[data-theme="dark"] .mc-mbtn.active { background: rgba(94, 234, 212, 0.18); color: var(--teal); box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.42); }
.mc-info-btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--sky);
  font: 600 0.70rem var(--sans);
  padding: 3px 8px;
  border-radius: 6px;
}
.mc-info-btn:hover, .mc-info-btn.active { border-color: var(--sky); background: #e0f2fe; }
:root[data-theme="dark"] .mc-info-btn:hover, :root[data-theme="dark"] .mc-info-btn.active { background: rgba(56, 189, 248, 0.16); }
.mc-explain-pop {
  display: none;
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  z-index: 15;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--sky);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 28px rgba(15, 35, 42, 0.16);
  font-size: 0.74rem;
  color: var(--soft);
  line-height: 1.45;
}
.mc-explain-pop.open { display: block; }
.mc-explain-pop strong { color: var(--white); }
.mc-explain-pop .ep-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font: 700 0.72rem var(--mono); color: var(--sky); }
.mc-explain-pop ul { padding-left: 15px; margin: 4px 0 0; }
.mc-explain-pop li { margin-bottom: 4px; }
.mc-tooltip {
  display: none;
  position: absolute;
  z-index: 12;
  pointer-events: none;
  min-width: 196px;
  max-width: 245px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--gold);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 24px rgba(15, 35, 42, 0.16);
  font: 600 10px var(--mono);
  color: var(--white);
  line-height: 1.45;
}
.mc-tooltip.show { display: block; }
.mc-tooltip .mt-title { color: var(--gold); font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: 3px; margin-bottom: 4px; }
.mc-tooltip .mt-row { display: flex; justify-content: space-between; gap: 8px; }
.mc-tooltip .mt-note { font-family: var(--sans); font-size: 10px; color: var(--muted); margin-top: 4px; border-top: 1px dashed var(--border); padding-top: 3px; }
.mc-legend { display: flex; justify-content: space-between; gap: 6px; margin-top: 6px; font: 600 0.70rem var(--mono); color: var(--soft); flex-wrap: wrap; }

/* Right Column: SEC CDS Matrix & Dossier */
.hm-filters { display: flex; gap: 6px; margin-bottom: 7px; flex-wrap: wrap; align-items: center; }
.hm-btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--soft);
  font: 600 0.70rem var(--sans);
  padding: 4px 9px;
  border-radius: 6px;
  transition: .12s;
}
.hm-btn:hover { border-color: var(--teal); color: var(--teal); }
.hm-btn.active { border-color: #0e7490; color: #ffffff; background: var(--gradient-accent); }
:root[data-theme="dark"] .hm-btn.active { border-color: var(--teal); color: var(--teal); background: rgba(94, 234, 212, 0.12); }

.hm-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; max-height: 196px; overflow-y: auto; padding-right: 2px; }
.hm-groups { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; max-height: 204px; overflow-y: auto; padding-right: 2px; }
.hm-group-card {
  cursor: pointer;
  border-radius: 9px;
  padding: 8px 10px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  text-align: left;
  transition: transform .12s, box-shadow .12s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hm-group-card:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(15, 35, 42, 0.16); }
.hmg-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.hmg-name { font: 700 10.5px var(--sans); color: #fff; line-height: 1.2; }
.hmg-cnt { font: 700 9.5px var(--mono); padding: 1px 6px; border-radius: 99px; background: rgba(15, 23, 42, 0.65); color: #d8f3ee; flex-shrink: 0; }
.hmg-stats { display: flex; justify-content: space-between; align-items: baseline; font: 700 10px var(--mono); color: #ffffff; margin-top: 2px; }
.hmg-sub { display: flex; justify-content: space-between; font: 600 9px var(--mono); color: rgba(255, 255, 255, 0.90); }
.hm-crumb {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--sub-bg);
  border: 1px solid #b8e2db;
  font: 600 0.72rem var(--sans);
  color: var(--soft);
}
.hm-crumb.show { display: flex; }
.hm-crumb-path { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.hm-crumb-root { color: var(--teal); cursor: pointer; text-decoration: underline; }
.hm-crumb-cur { color: var(--gold); font-weight: 700; }
.drill-up-btn {
  cursor: pointer;
  border: 1px solid #0f766e;
  background: #d8f3ee;
  color: #0b5c56;
  font: 700 0.70rem var(--sans);
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.drill-up-btn:hover { background: #0f766e; color: #fff; }
.hm-cell {
  cursor: pointer;
  border-radius: 6px;
  padding: 5px 3px;
  text-align: center;
  border: 1px solid rgba(15, 23, 42, 0.10);
  font-family: var(--mono);
  transition: transform .1s, box-shadow .1s;
}
.hm-cell:hover, .hm-cell.selected { transform: translateY(-1px); border-color: #111111; box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.45); }
.hm-cell .ct { font-size: 10px; font-weight: 800; color: #fff; line-height: 1.1; }
.hm-cell .cb { font-size: 9px; color: rgba(255, 255, 255, 0.92); margin-top: 2px; }

.mode-switch { display: inline-flex; gap: 3px; background: var(--sub-bg); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.mode-pill {
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  font: 600 0.72rem var(--sans);
  padding: 3px 9px;
  border-radius: 6px;
  transition: .14s;
}
.mode-pill.active { background: var(--gradient-accent); color: #ffffff; }
.mode-pill.move-active { background: #b45309; color: #ffffff; }
:root[data-theme="dark"] .mode-pill.active { background: rgba(56, 189, 248, 0.22); color: #f4f8fc; }
:root[data-theme="dark"] .mode-pill.move-active { background: rgba(244, 185, 90, 0.22); color: var(--gold); }
.fi-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

.dossier {
  margin-top: 9px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--sub-bg);
  border: 1px solid var(--border);
}
:root[data-theme="dark"] .dossier { background: linear-gradient(135deg, rgba(8, 28, 52, 0.96), rgba(14, 42, 74, 0.92)); border-color: rgba(244, 185, 90, 0.42); }
.dos-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.dos-badges { display: inline-flex; align-items: center; gap: 6px; }
.dos-name { font: 700 0.86rem var(--sans); color: var(--white); }

/* Floating Optical-Glass Company Risk & Profile Pop-Up */
.co-popover {
  display: none;
  position: fixed;
  z-index: 120;
  width: 318px;
  max-width: calc(100vw - 24px);
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--teal);
  backdrop-filter: blur(14px) saturate(135%);
  -webkit-backdrop-filter: blur(14px) saturate(135%);
  box-shadow: 0 14px 34px rgba(15, 35, 58, 0.20), inset 0 1px 0 var(--glass-inset);
  color: var(--white);
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.45;
  pointer-events: none;
}
:root[data-theme="dark"] .co-popover {
  box-shadow: 0 16px 40px rgba(2, 10, 22, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.co-popover.show { display: block; }
.co-popover.pinned { pointer-events: auto; }
.cop-hdr { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.cop-title { font: 700 0.86rem var(--sans); color: var(--white); line-height: 1.25; }
.cop-title span { font-family: var(--mono); color: var(--gold); margin-right: 5px; }
.cop-meta { font: 600 0.68rem var(--mono); color: var(--muted); margin-top: 2px; }
.cop-risk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--sub-bg);
  border-left: 3px solid var(--teal);
  margin: 7px 0;
  font-size: 0.74rem;
}
.cop-risk.tier-q2 { border-left-color: var(--gold); }
.cop-risk.tier-q3 { border-left-color: var(--coral); }
.cop-risk strong { display: block; font-size: 0.74rem; color: var(--white); }
.cop-risk span { display: block; font-size: 0.71rem; color: var(--muted); }
.cop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin: 7px 0;
}
.cop-kv {
  background: var(--sub-bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 7px;
}
.cop-kv .k { font: 700 0.63rem var(--mono); color: var(--muted); text-transform: uppercase; }
.cop-kv .v { font: 700 0.76rem var(--mono); color: var(--white); margin-top: 1px; }
.cop-about { font-size: 0.75rem; color: var(--soft); margin: 6px 0; }
.cop-foot {
  margin-top: 7px;
  padding-top: 5px;
  border-top: 1px dashed var(--border);
  font: 600 0.66rem var(--mono);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.dos-name span { font-family: var(--mono); color: var(--gold); margin-right: 6px; }
.dos-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.dk { background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; padding: 5px 6px; text-align: center; }
.dk .k { font: 700 8.5px var(--mono); color: var(--muted); text-transform: uppercase; }
.dk .v { font: 700 12px var(--mono); color: var(--white); margin-top: 2px; }
.dos-bar-lbl { display: flex; justify-content: space-between; font: 600 9.5px var(--mono); color: var(--muted); margin-bottom: 4px; }
.dos-track { position: relative; height: 8px; border-radius: 99px; background: linear-gradient(90deg, #0f766e 0%, #0ea5e9 32%, #f59e0b 62%, #be123c 100%); }
.dos-pin { position: absolute; top: -4px; width: 4px; height: 16px; border-radius: 2px; background: #111111; border: 1px solid #ffffff; transform: translateX(-50%); transition: left .22s ease; }
:root[data-theme="dark"] .dos-pin { background: #ffffff; border-color: #061629; }
.dos-link-row { margin-top: 7px; display: flex; justify-content: space-between; align-items: center; font: 600 0.70rem var(--mono); color: var(--teal); gap: 8px; }

/* Live Feed */
.feed-list { display: flex; flex-direction: column; gap: 7px; max-height: 232px; overflow-y: auto; padding-right: 2px; }
.feed-item {
  background: var(--sub-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--sky);
  border-radius: 8px;
  padding: 7px 10px;
}
.feed-item.sev-risk { border-left-color: var(--coral); }
.feed-item.sev-warn { border-left-color: var(--gold); }
.feed-item.sev-teal { border-left-color: var(--teal); }
.fi-top { display: flex; justify-content: space-between; font: 700 9.5px var(--mono); color: var(--muted); margin-bottom: 2px; }
.fi-tag { color: var(--teal); }
.fi-msg { font-size: 0.76rem; color: var(--soft); line-height: 1.4; }

.hud-footer {
  margin-top: 14px;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font: 500 0.76rem var(--sans);
  color: var(--muted);
}
.hud-footer code, .hud-footer #footerSha { font-family: var(--mono); font-size: 0.74rem; }
.hud-footer a { color: var(--teal); text-decoration: underline; text-underline-offset: 2px; }

/* Guide & Terms Tab */
.guide-view { display: none; }
.guide-view.active { display: block; }
.hud-view.hidden { display: none; }
.plan-hero {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  margin-bottom: 16px;
  background-image: var(--gradient-brandline);
  background-repeat: no-repeat;
  background-size: 100% 3px;
}
.plan-hero h2 { font: 650 1.55rem var(--sans); letter-spacing: -0.02em; margin: 0 0 6px; color: var(--white); }
.plan-hero h2 span { color: var(--teal); }
.plan-hero p { color: var(--muted); font-size: 0.92rem; max-width: 920px; line-height: 1.55; margin: 0; }
.guide-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.guide-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.guide-pill {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--soft);
  font: 600 0.76rem var(--sans);
  padding: 6px 12px;
  border-radius: 99px;
  transition: .14s;
}
.guide-pill.active, .guide-pill:hover { border-color: #0f766e; color: #ffffff; background: #0f766e; }
.guide-search {
  min-width: 240px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--white);
  font: 500 0.82rem var(--sans);
  outline: none;
}
.guide-search:focus { border-color: var(--teal); }
.guide-sec-title { font: 650 1.2rem var(--sans); color: var(--white); margin: 18px 0 10px; display: flex; align-items: center; gap: 10px; }
.guide-sec-title span { font: 700 0.68rem var(--mono); color: var(--teal); letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; border: 1px solid #b8e2db; background: #d8f3ee; }
:root[data-theme="dark"] .guide-sec-title span { background: rgba(94,234,212,0.10); border-color: rgba(94,234,212,0.35); }
.formula-box { margin: 10px 0; padding: 10px 14px; border-radius: 9px; background: var(--sub-bg); border: 1px solid #e6cfa0; font: 700 0.76rem var(--mono); color: var(--gold); line-height: 1.5; }
.area-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1050px) { .area-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .area-grid { grid-template-columns: 1fr; } }
.glossary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 860px) { .glossary-grid { grid-template-columns: 1fr; } }
.g-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 15px 17px; position: relative; overflow: hidden; }
.g-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--cap, var(--gradient-brandline)); }
.g-card .gk { font: 700 0.68rem var(--mono); color: var(--cap, var(--teal)); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 4px; }
.g-card h3 { font: 650 0.96rem var(--sans); color: var(--white); margin: 0 0 6px; }
.g-card p { font-size: 0.84rem; color: var(--muted); line-height: 1.55; margin: 0; }
.g-card p strong { color: var(--white); }
.g-card.hidden-item { display: none; }
.spread-scale { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.ss-pill { padding: 8px 10px; border-radius: 8px; background: var(--sub-bg); border: 1px solid var(--border); font-family: var(--mono); }
.ss-pill .st { font-size: 10.5px; font-weight: 800; }
.ss-pill .sd { font-size: 11px; color: var(--muted); font-family: var(--sans); margin-top: 3px; line-height: 1.38; }
