/* ==========================================================================
   EMT Pilot — Dedicated Insights Visualization & Research Exhibit System
   Loaded on /insights/* pages alongside /styles.css
   Zero CLS (explicit heights), Print-safe SVG, Institutional Editorial Palette
   ========================================================================== */

:root {
  --viz-navy: #0c1c28;
  --viz-orange: #d95300;
  --viz-orange-hi: #ff7a1f;
  --viz-blue: #0369a1;
  --viz-teal: #0f766e;
  --viz-amber: #b45309;
  --viz-slate: #475569;
  --viz-red: #b91c1c;
  --viz-border: #d4dde6;
  --viz-surface: #f8fafc;
}

/* ---------- Exhibit Header Flex & Micro-Toolbar ---------- */
.ins-exhibit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
}

.ins-exhibit-head-main {
  flex: 1 1 240px;
  min-width: 0;
}

.ins-exhibit-tools {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  max-width: 100%;
  margin-top: 2px;
}

.ins-tool-btn {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 5px 9px;
  cursor: pointer;
  line-height: 1.2;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.ins-tool-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #050f16;
}

.ins-tool-btn.is-active {
  background: var(--viz-navy);
  border-color: var(--viz-navy);
  color: #ffffff;
}

.ins-tool-btn.is-copied {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}

/* ---------- ECharts Visualization Stage (Zero CLS) ---------- */
.ins-viz-stage {
  position: relative;
  width: 100%;
  height: 360px;
  background: #ffffff;
  padding: 14px 16px 8px;
  box-sizing: border-box;
  overflow: visible;
}

.ins-viz-stage.is-compact {
  height: 290px;
}

.ins-viz-stage.is-tall {
  height: 410px;
}

.ins-viz-stage.is-gantt {
  height: 330px;
}

.ins-viz-canvas {
  width: 100%;
  height: 100%;
}

.ins-viz-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid #e2e8ee;
  background: #ffffff;
}

.ins-viz-grid-2 .ins-viz-panel {
  min-width: 0;
  position: relative;
}

.ins-viz-grid-2 .ins-viz-panel + .ins-viz-panel {
  border-left: 1px solid #e2e8ee;
}

.ins-viz-subhead {
  padding: 10px 18px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #475569;
}

.ins-viz-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #64748b;
  background: #ffffff;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.ins-viz-stage.is-ready .ins-viz-loading {
  opacity: 0;
  visibility: hidden;
}

/* ---------- Enhanced Spec Tables (4-Col Fix, Sort, Bars, Badges) ---------- */
.ins-prose .mcp-table.is-4col {
  table-layout: fixed;
}

.ins-prose .mcp-table.is-4col col.col-label {
  width: 17%;
}

.ins-prose .mcp-table.is-4col col.col-data {
  width: 27.66%;
}

.ins-prose .mcp-table thead th.is-sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 26px;
}

.ins-prose .mcp-table thead th.is-sortable::after {
  content: "↕";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: 0.45;
}

.ins-prose .mcp-table thead th.is-sort-asc::after {
  content: "↑";
  opacity: 1;
  color: var(--viz-orange);
}

.ins-prose .mcp-table thead th.is-sort-desc::after {
  content: "↓";
  opacity: 1;
  color: var(--viz-orange);
}

/* Status Pills inside tables & timelines */
.ins-pill {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 2px;
  vertical-align: middle;
  line-height: 1.4;
  margin-right: 5px;
}

.ins-pill.is-live {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.ins-pill.is-warn {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.ins-pill.is-info {
  background: #f0f9ff;
  color: #075985;
  border: 1px solid #bae6fd;
}

.ins-pill.is-danger {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Inline Score / Progress Bar inside Table Cells */
.ins-sbar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.ins-sbar-track {
  flex: 1 1 80px;
  height: 7px;
  background: #e2e8f0;
  border-radius: 1px;
  overflow: hidden;
  min-width: 60px;
}

.ins-sbar-fill {
  height: 100%;
  background: var(--viz-navy);
  border-radius: 1px;
}

.ins-sbar-fill.is-orange { background: var(--viz-orange); }
.ins-sbar-fill.is-teal   { background: var(--viz-teal); }
.ins-sbar-fill.is-blue   { background: var(--viz-blue); }
.ins-sbar-fill.is-red    { background: var(--viz-red); }

.ins-sbar-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 700;
  color: #0c1c28;
  white-space: nowrap;
}

/* ---------- Timeline Polish (Visual Nodes & Badges) ---------- */
.ins-tl-body {
  position: relative;
}

.ins-tl-body::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid #64748b;
  box-sizing: border-box;
}

.ins-tl-item.is-upcoming .ins-tl-body::before {
  border-color: var(--viz-orange);
  background: #fff7ed;
  box-shadow: 0 0 0 3px rgba(255, 122, 31, 0.16);
}

/* ---------- Interactive Collapsible Mindmap Engine ---------- */
.ins-mm-wrap {
  position: relative;
  background: #fbfcfd;
  background-image: radial-gradient(#dce4ec 1px, transparent 1px);
  background-size: 18px 18px;
  border-top: 0;
}

.ins-mm-viewport {
  position: relative;
  width: 100%;
  height: 410px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
}

.ins-mm-viewport.is-dragging {
  cursor: grabbing;
}

.ins-mm-viewport svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ins-mm-link {
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  opacity: 0.72;
  transition: opacity 150ms ease;
}

.ins-mm-node {
  cursor: pointer;
}

.ins-mm-node rect.mm-box {
  rx: 4;
  ry: 4;
  transition: filter 150ms ease, stroke-width 150ms ease;
}

.ins-mm-node:hover rect.mm-box {
  filter: drop-shadow(0 2px 6px rgba(5, 15, 22, 0.12));
}

.ins-mm-node text.mm-label {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  fill: #0c1c28;
  pointer-events: none;
}

.ins-mm-node.is-root text.mm-label {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  fill: #ffffff;
}

.ins-mm-node.is-depth-1 text.mm-label {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 700;
}

.ins-mm-node text.mm-sub {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  fill: #475569;
  pointer-events: none;
}

.ins-mm-node.is-root text.mm-sub {
  fill: #cbd5e1;
}

.ins-mm-badge circle {
  fill: #ffffff;
  stroke-width: 1.75;
}

.ins-mm-badge text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.ins-mm-hint {
  position: absolute;
  left: 14px;
  bottom: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.88);
  padding: 3px 8px;
  border: 1px solid #e2e8f0;
  pointer-events: none;
}

/* Outline fallback / SEO-readable DOM tree */
.ins-mm-source {
  padding: 16px 24px 18px;
  background: #ffffff;
  font-size: 14.5px;
  line-height: 1.55;
  color: #1d2f3e;
}

.ins-mm-wrap.is-enhanced .ins-mm-source {
  display: none;
}

.ins-mm-wrap.is-outline .ins-mm-viewport,
.ins-mm-wrap.is-outline .ins-mm-hint {
  display: none;
}

.ins-mm-wrap.is-outline .ins-mm-source {
  display: block;
}

.ins-mm-source ul {
  margin: 6px 0 6px 20px;
  padding-left: 14px;
  border-left: 1.5px solid #cbd5e1;
}

.ins-mm-source > ul {
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
  list-style: none;
}

.ins-mm-source li {
  margin: 5px 0;
}

.ins-mm-source strong {
  color: var(--viz-navy);
}

/* ---------- Responsive Breakpoints ---------- */
@media (max-width: 820px) {
  .ins-viz-grid-2 {
    grid-template-columns: 1fr;
  }

  .ins-viz-grid-2 .ins-viz-panel + .ins-viz-panel {
    border-left: 0;
    border-top: 1px solid #e2e8ee;
  }

  .ins-viz-stage {
    height: 320px;
    padding: 10px 8px 6px;
  }

  .ins-viz-stage.is-tall {
    height: 360px;
  }

  .ins-mm-viewport {
    height: 360px;
  }

  .ins-prose .mcp-table.is-4col {
    table-layout: auto;
  }

  .ins-prose .mcp-table.is-4col col {
    width: auto !important;
  }

  .ins-prose .mcp-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 600px) {
  .ins-tool-btn {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 10.5px;
  }

  .ins-viz-stage {
    height: 300px;
    padding: 8px 4px 6px;
  }

  .ins-viz-stage.is-compact {
    height: 270px;
  }

  .ins-viz-stage.is-tall {
    height: 340px;
  }

  .ins-viz-subhead {
    padding: 8px 12px 0;
    font-size: 10px;
  }

  .ins-mm-viewport {
    height: 320px;
    touch-action: none;
  }

  .ins-mm-hint {
    left: 8px;
    right: 8px;
    bottom: 8px;
    font-size: 9.5px;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
    padding: 4px 8px;
  }

  .ins-mm-source {
    padding: 14px 14px 16px;
    font-size: 13.5px;
    line-height: 1.5;
  }

  .ins-mm-source ul {
    margin: 5px 0 6px 12px;
    padding-left: 12px;
  }

  .ins-mm-source > ul > li > strong {
    display: inline-block;
    font-size: 14.5px;
    margin-bottom: 4px;
  }
}
