/* ============================================================
   strategy.css — Strategy Lab (draw.io-style layout)
   ============================================================ */

.lab-page {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- header / toolbar ---------- */
.lab-header {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--card-border);
  background: rgba(10, 14, 26, 0.8);
  flex: none;
}
.lab-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  font-size: 1.05rem;
  white-space: nowrap;
}
.lab-brand img { display: block; width: 280px; height: auto; }

.lab-tools { display: flex; align-items: center; gap: 20px; flex: 1; flex-wrap: wrap; min-width: 0; }
.lab-primary-nav { display: flex; align-items: center; gap: 22px; flex: none; align-self: flex-start; margin-top: 13px; }
.lab-primary-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.lab-primary-nav a:hover,
.lab-primary-nav a:focus-visible,
.lab-primary-nav a[aria-current="page"] { color: var(--brand-green); }
.tool { display: flex; flex-direction: column; gap: 3px; }
.tool[hidden] { display: none; }   /* `display: flex` would otherwise win over [hidden] */
.tool > span {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-dim); font-weight: 700;
}
.tool > span b { color: var(--green); }
.tool select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  padding: 6px 10px;
  font-size: 0.85rem;
}
.tool input[type="range"] { width: 150px; margin-top: 6px; }

.tool-btns { display: flex; gap: 6px; }
.tool-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 8px;
  min-width: 34px;
  padding: 7px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.tool-btn:hover { background: rgba(255, 255, 255, 0.14); }
.tool-btn.danger:hover { background: rgba(239, 68, 68, 0.25); border-color: #ef4444; }
.tool-btn:disabled { opacity: 0.35; cursor: default; }
.tool-btn:disabled:hover { background: rgba(255, 255, 255, 0.07); }

.lab-back {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 7px 14px;
  white-space: nowrap;
}
.lab-back:hover { color: var(--text); border-color: var(--green); }

/* ---------- 3-pane layout ---------- */
.lab {
  display: grid;
  grid-template-columns: 215px 1fr 265px;
  flex: 1;
  min-height: 0;
}

/* ---- mobile Strategy Lab ----
   A touch workflow built over the same graph: cards replace the canvas and
   routes replace drag-to-connect. It stays out of desktop flow entirely. */
.mobile-lab, .mobile-editor-modal { display: none; }
@media (max-width: 900px) {
  body.lab-page {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
  }
  .lab-header {
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 10px;
    padding: 9px 14px;
    align-items: flex-start;
  }
  .lab-brand { font-size: 0.94rem; }
  .lab-brand img { width: 230px; height: auto; }
  .lab-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
  }
  .lab-primary-nav {
    order: -1;
    width: 100%;
    justify-content: flex-end;
    gap: 14px;
    align-self: auto;
    margin-top: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .lab-primary-nav::-webkit-scrollbar { display: none; }
  .lab-primary-nav a { min-height: 36px; font-size: 0.72rem; }
  .lab-tools .tool { min-width: 0; }
  .lab-tools .tool:first-child { grid-column: 1 / -1; min-width: 130px; }
  .lab-tools .tool:first-child select { width: 100%; }
  .lab-tools .tool select { box-sizing: border-box; width: 100%; min-width: 0; }
  .tool input[type="range"] { width: 104px; }
  .tool-btns { display: none; }
  .lab-back { display: none; }
  .lab { display: none; }
  body.lab-page > .results { display: none; }

  .mobile-lab { display: block; padding: 12px 12px 28px; }
  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 14px;
  }
  .mobile-tab {
    min-height: 39px;
    border: 1px solid var(--card-border);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text-dim);
    font-weight: 800;
    font-size: 0.78rem;
    cursor: pointer;
  }
  .mobile-tab.active { color: var(--text); border-color: var(--violet); background: rgba(167, 139, 250, 0.14); }
  .mobile-panel { display: none; }
  .mobile-panel.active { display: block; }
  .mobile-section-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 2px 12px;
  }
  .mobile-section-head h2 { font-size: 0.95rem; margin: 0 0 3px; }
  .mobile-section-head p { margin: 0; color: var(--text-dim); font-size: 0.76rem; line-height: 1.4; }
  .mobile-chart-legend, .mobile-chart-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
  }
  .mobile-chart-legend .legend-chip { font-size: 0.67rem; }
  .mobile-chart-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-chart-stats .stat-lens { grid-column: 1 / -1; }
  .mobile-chart-stats > span {
    min-width: 0;
    padding: 7px 8px;
    border: 1px solid var(--card-border);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.025);
    font-size: 0.68rem;
    line-height: 1.4;
  }
  #mobile-growth-chart {
    width: 100%;
    height: 230px;
    display: block;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    background: #0b101d;
    margin-bottom: 14px;
  }
  #mobile-report-card .report-card { margin: 0; }
  .mobile-node-list, .mobile-flow-list { display: flex; flex-direction: column; gap: 8px; }
  .mobile-node-card, .mobile-flow-card, .mobile-flow-add {
    border: 1px solid var(--card-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
  }
  .mobile-node-card {
    width: 100%;
    display: grid;
    grid-template-columns: 5px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
  }
  .mobile-node-card:active { background: rgba(255, 255, 255, 0.07); }
  .mobile-node-color { align-self: stretch; border-radius: 4px; }
  .mobile-node-card b { display: block; font-size: 0.84rem; }
  .mobile-node-card small { display: block; margin-top: 3px; color: var(--text-dim); font-size: 0.7rem; line-height: 1.35; }
  .mobile-node-value { color: var(--green); font-size: 0.8rem; font-weight: 800; white-space: nowrap; }
  .mobile-flow-add { padding: 11px; margin-bottom: 12px; }
  .mobile-flow-add h3 { margin: 0 0 10px; font-size: 0.8rem; }
  .mobile-flow-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
  .mobile-flow-grid .wide { grid-column: 1 / -1; }
  .mobile-flow-grid label {
    display: block;
    color: var(--text-dim);
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .mobile-flow-grid input, .mobile-flow-grid select {
    box-sizing: border-box;
    width: 100%;
    margin-top: 4px;
    padding: 9px;
    border: 1px solid var(--card-border);
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.35);
    color: var(--text);
    font-size: 0.82rem;
  }
  .mobile-flow-save { width: 100%; margin-top: 10px; }
  .mobile-flow-card { display: grid; grid-template-columns: 1fr auto; gap: 9px; align-items: center; padding: 10px 11px; }
  .mobile-flow-card b { display: block; font-size: 0.82rem; }
  .mobile-flow-card small { display: block; margin-top: 3px; color: var(--text-dim); font-size: 0.7rem; }
  .mobile-flow-empty { color: var(--text-dim); font-size: 0.8rem; line-height: 1.5; padding: 14px 4px; }
  .mobile-editor-modal {
    position: fixed;
    z-index: 30;
    inset: 0;
    align-items: end;
    background: rgba(0, 0, 0, 0.62);
  }
  .mobile-editor-modal.open { display: flex; }
  .mobile-editor-sheet {
    box-sizing: border-box;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    border: 1px solid var(--card-border);
    border-radius: 10px 10px 0 0;
    background: #101728;
    padding: 0 14px 20px;
  }
  .mobile-editor-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--card-border);
    background: #101728;
  }
  .mobile-editor-head h2 { margin: 0; font-size: 0.95rem; }
  .mobile-editor-body { padding-bottom: 8px; }
  .mobile-editor-body .insp-field input, .mobile-editor-body .insp-field select { box-sizing: border-box; }
}

@media (max-width: 520px) {
  .lab-brand img { width: 190px; }
  .lab-brand { padding-top: 19px; }
}

/* palette */
.palette {
  border-right: 1px solid var(--card-border);
  padding: 14px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.02);
}
.palette h2, .inspector h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  margin-bottom: 4px;
}
.palette-hint { font-size: 0.72rem; color: var(--text-dim); margin-bottom: 12px; }
#palette-groups h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 14px 0 6px;
}
/* collapsible shelves inside a palette group — the node list is long enough
   that everything open at once is unusable */
.palette-sub { margin: 0 0 4px; }
.palette-sub > summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 5px 6px 5px 16px;
  border-radius: 7px;
  position: relative;
  user-select: none;
}
.palette-sub > summary::-webkit-details-marker { display: none; }
.palette-sub > summary:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.palette-sub > summary::before {
  content: '';
  position: absolute;
  left: 4px; top: 50%;
  width: 0; height: 0;
  border-left: 4px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transform: translateY(-50%);
  transition: transform 0.15s;
}
.palette-sub[open] > summary::before { transform: translateY(-50%) rotate(90deg); }
.palette-sub > summary b {
  float: right;
  font-weight: 600;
  opacity: 0.5;
}

.palette-card {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: grab;
  text-align: left;
  transition: all 0.15s;
}
.palette-card:hover { border-color: rgba(255, 255, 255, 0.3); transform: translateX(2px); }
.palette-icon {
  width: 26px; height: 26px;
  border-radius: 8px;
  padding: 3px;
  flex: none;
}

/* canvas */
.canvas-wrap { position: relative; min-width: 0; background: #0b101d; }
#flow-canvas { width: 100%; height: 100%; display: block; cursor: default; touch-action: none; }
.canvas-bg { cursor: grab; }

/* inspector */
.inspector {
  border-left: 1px solid var(--card-border);
  padding: 14px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.02);
}
.insp-hint { font-size: 0.78rem; color: var(--text-dim); line-height: 1.5; margin-bottom: 10px; }
.insp-field { margin-bottom: 12px; }
.insp-field label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 5px;
}
.insp-field label .info-dot { margin-left: 5px; }
.insp-field select {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 10px;
  outline: none;
  cursor: pointer;
}
.insp-field select:focus { border-color: var(--green); }
.insp-field input[type="text"],
.insp-field input[type="number"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 10px;
  outline: none;
}
.insp-field input:focus { border-color: var(--green); }
.pct-row { display: flex; align-items: center; gap: 10px; }
.pct-row input[type="range"] { flex: 1; margin-top: 0; }
.pct-row span { font-weight: 800; color: var(--green); min-width: 42px; text-align: right; }
.route-amount-row { display: flex; align-items: center; gap: 8px; }
.route-amount-row input { min-width: 0; flex: 1; }
.route-amount-row span { color: var(--text-dim); font-size: 0.75rem; white-space: nowrap; }

.insp-note {
  font-size: 0.78rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
  line-height: 1.45;
}
.insp-note b { color: var(--text); }
.insp-warn { display: block; color: #fbbf24; font-weight: 700; margin-top: 4px; }
/* a whole note that IS the warning, rather than a warning line inside one */
.insp-note.insp-warn { color: #fbbf24; font-weight: 400; margin-top: 0; border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.07); }
.insp-note.insp-warn b { color: #fde68a; }

/* how a node counts toward net worth — colour-coded so a debt never reads
   like an asset at a glance */
.insp-worth { border-left-width: 3px; }
.insp-worth-liability { border-left-color: #f87171; background: rgba(248, 113, 113, 0.07); }
.insp-worth-liability b { color: #fca5a5; }
.insp-worth-spent { border-left-color: #94a3b8; background: rgba(148, 163, 184, 0.08); }
.insp-worth-spent b { color: #cbd5e1; }
.insp-note .ok { color: var(--green); font-weight: 700; }
.insp-note .bad { color: #f87171; font-weight: 700; }
.insp-summary-static .pos { color: var(--green); }
.insp-summary-static .neg { color: #f87171; }

.insp-eq {
  margin-bottom: 12px;
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(167, 139, 250, 0.06);
}
.insp-eq-title {
  display: block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--violet);
  font-weight: 800;
  margin-bottom: 6px;
}
.insp-eq code {
  display: block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.72rem;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}
.insp-delete {
  width: 100%;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #f87171;
  border-radius: 8px;
  padding: 8px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}
.insp-delete:hover { background: rgba(239, 68, 68, 0.25); }

/* ---------- SVG diagram styles ---------- */
.node { cursor: grab; }
.node-body {
  fill: #131a2c;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.45));
}
.node.selected .node-body { stroke: #60a5fa; stroke-width: 1.6; }
.node.drop-target .node-body { stroke: var(--green); stroke-width: 2; }
.node-title { fill: #e8ecf6; font: 700 13px -apple-system, sans-serif; }
.node-sub { fill: #8b94ad; font: 600 10.5px -apple-system, sans-serif; }
.node-final { font: 700 10.5px -apple-system, sans-serif; }

.port {
  fill: #0b101d;
  stroke: #60a5fa;
  stroke-width: 1.5;
  opacity: 0;
  cursor: crosshair;
  transition: opacity 0.15s;
}
.node:hover .port, .node.selected .port { opacity: 1; }
.port:hover { fill: #60a5fa; }

.edge-line { stroke-width: 2; opacity: 0.9; }
.edge-hit { stroke: transparent; stroke-width: 16; cursor: pointer; }
.edge.selected .edge-line { stroke-width: 3.2; opacity: 1; }
.edge-label rect { fill: rgba(10, 14, 26, 0.92); stroke: rgba(255, 255, 255, 0.18); }
.edge.selected .edge-label rect { stroke: #60a5fa; }
.edge-label text { fill: #e8ecf6; font: 700 10.5px -apple-system, sans-serif; }
.edge-temp { stroke: #60a5fa; stroke-width: 2; stroke-dasharray: 6 5; pointer-events: none; }
.pulse { opacity: 0.9; pointer-events: none; }

/* ---------- results panel ---------- */
.results {
  flex: none;
  border-top: 1px solid var(--card-border);
  background: rgba(10, 14, 26, 0.8);
  padding: 10px 18px 8px;
  height: auto;
  min-height: 268px;
  display: flex;
  flex-direction: column;
}
.mc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.mc-toggle input[type=checkbox] { accent-color: #a78bfa; cursor: pointer; }
.results-toggles {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.rt-pct {
  width: 46px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 2px 5px;
  text-align: right;
}
.rt-pct:disabled { opacity: 0.4; }
#btn-expand-chart { font-size: 0.72rem; padding: 4px 10px; }
.stat-lens {
  color: #fbbf24;
  font-style: italic;
  font-weight: 700;
  font-size: 0.72rem;
  align-self: center;
}
.lab-disclaimer {
  font-size: 0.66rem;
  color: var(--text-dim);
  opacity: 0.85;
  text-align: center;
  margin-top: 5px;
  flex: none;
}
.lab-disclaimer a { color: var(--text-dim); }
.mobile-lab-disclaimer {
  margin: -4px 0 12px;
  color: var(--text-dim);
  font-size: 0.7rem;
  line-height: 1.45;
  text-align: center;
}
.lab-footer {
  flex: none;
  min-height: 28px;
  padding: 7px 18px 6px;
  border-top: 1px solid var(--card-border);
  border-bottom: 0;
  background: rgba(10, 14, 26, 0.8);
}
.lab-footer.compact-footer { border-top: 1px solid var(--card-border); }
@media (max-width: 900px) {
  .lab-footer { padding: 9px 12px calc(9px + env(safe-area-inset-bottom)); }
}
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
#chart-legend { display: flex; gap: 8px; flex-wrap: wrap; }
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 3px 10px;
}
.legend-chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend-chip b { color: var(--text); }
.legend-chip.total { border-color: rgba(255, 255, 255, 0.35); }
#chart-stats { display: flex; gap: 18px; font-size: 0.78rem; color: var(--text-dim); }
#chart-stats b { color: var(--text); font-size: 0.88rem; }
#chart-stats b.pos { color: var(--green); }
#chart-stats b.neg { color: #f87171; }
.flywheel-metrics {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  gap: 6px;
  margin: 2px 0 8px;
}
.flywheel-metric {
  min-width: 0;
  padding: 7px 8px;
  border-top: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.018);
}
.flywheel-metric span,
.flywheel-metric small { display: block; color: var(--text-dim); }
.flywheel-metric span {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.flywheel-metric .info-dot {
  width: 13px;
  height: 13px;
  margin-left: 3px;
  padding: 0;
  vertical-align: -1px;
  font-size: 8px;
  line-height: 11px;
}
.flywheel-metric b {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flywheel-metric small { margin-top: 1px; font-size: 0.56rem; }
.flywheel-metric.stage { border-top-width: 2px; }
.flywheel-metric.stage.push { border-top-color: #94a3b8; }
.flywheel-metric.stage.acquisition { border-top-color: #60a5fa; }
.flywheel-metric.stage.compound { border-top-color: #facc15; }
.flywheel-metric.stage.self-sustaining { border-top-color: #4ade80; }
@media (max-width: 900px) {
  .mobile-flywheel-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 12px; }
  .mobile-flywheel-metrics .flywheel-metric.stage { grid-column: 1 / -1; }
  .mobile-flywheel-metrics .flywheel-metric { padding: 8px; }
}
#growth-chart { flex: 1 0 88px; width: 100%; min-height: 88px; touch-action: pan-y; }
#mobile-growth-chart { touch-action: pan-y; }

/* expanded chart: the results section takes over the viewport so a diagram
   with many node lines has room to breathe */
body.chart-expanded .results {
  position: fixed;
  inset: 0;
  z-index: 200;
  height: auto;
  background: #0b101d;
  padding: 16px 22px 12px;
}
body.chart-expanded .lab,
body.chart-expanded .lab-header { filter: blur(1px); }
body.chart-expanded #growth-chart { flex: 1 1 auto; min-height: 0; height: auto; }
#btn-expand-chart { position: relative; z-index: 201; }

.tool-btn.accent {
  background: rgba(60, 181, 60, 0.16);
  border-color: rgba(60, 181, 60, 0.55);
  color: #3cb53c;
}
.tool-btn.accent:hover { background: rgba(60, 181, 60, 0.3); }

.lab-flash {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--green);
  margin-right: 12px;
}

/* ---------- report card ---------- */
.rc { display: flex; flex-direction: column; gap: 9px; }
.rc-row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 9px 10px;
}
.rc-body { min-width: 0; }
.rc-body b { display: block; font-size: 0.8rem; color: var(--text); }
.rc-body small { display: block; font-size: 0.72rem; color: var(--text-dim); line-height: 1.45; margin-top: 2px; }
.rc-badge {
  flex: none;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  border-radius: 6px;
  padding: 3px 6px;
  margin-top: 1px;
}
.rc-badge.pass { background: rgba(74, 222, 128, 0.15); color: var(--green); border: 1px solid rgba(74, 222, 128, 0.4); }
.rc-badge.fail { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.45); }
.rc-badge.warn { background: rgba(250, 204, 21, 0.12); color: #facc15; border: 1px solid rgba(250, 204, 21, 0.4); }
.rc-badge.na { background: rgba(139, 148, 173, 0.1); color: var(--text-dim); border: 1px solid var(--card-border); }

/* ---------- compare modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(5, 7, 15, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #101628;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  width: min(1060px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--card-border);
}
.modal-head h2 { font-size: 1.05rem; }
.cmp-body {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 18px;
  padding: 16px 20px 20px;
  overflow: auto;
  min-height: 0;
}
.cmp-side { display: flex; flex-direction: column; gap: 8px; }
.cmp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
}
.cmp-row input { accent-color: #a78bfa; }
.cmp-row small { color: var(--text-dim); display: block; font-size: 0.68rem; }
.cmp-del {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
}
.cmp-del:hover { color: #f87171; }
.cmp-run-btn {
  margin-top: 6px;
  background: linear-gradient(135deg, var(--green), #22c55e);
  border: none;
  color: #06130a;
  border-radius: 10px;
  padding: 10px;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
}
.cmp-run-btn:hover { filter: brightness(1.08); }
.cmp-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
#cmp-chart { width: 100%; height: 240px; background: rgba(0, 0, 0, 0.25); border-radius: 12px; }
.cmp-table { border-collapse: collapse; width: 100%; }
.cmp-table th, .cmp-table td {
  text-align: left;
  padding: 7px 10px 7px 0;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  white-space: nowrap;
}
.cmp-table th { color: var(--text-dim); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; }
.cmp-table td b { color: var(--green); }
.cmp-table small { color: var(--text-dim); }
.cmp-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.cmp-note { font-size: 0.7rem; color: var(--text-dim); }

@media (max-width: 900px) {
  .lab { grid-template-columns: 180px 1fr; }
  .inspector { display: none; }
  .cmp-body { grid-template-columns: 1fr; }
}

/* ---------- LP payoff mini-chart ---------- */
.payoff-wrap { margin-top: 10px; }
#lp-payoff {
  width: 100%;
  height: 118px;
  display: block;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--card-border);
  border-radius: 9px;
}
.payoff-legend {
  display: flex;
  gap: 10px;
  margin-top: 5px;
  font-size: 0.64rem;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.payoff-legend i { display: inline-block; width: 8px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* ---------- Uniswap v3 position simulator panel ---------- */
.insp-simbtn {
  width: 100%;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.14), rgba(167, 139, 250, 0.14));
  border: 1px solid rgba(167, 139, 250, 0.55);
  color: var(--text);
  border-radius: 8px;
  padding: 9px;
  font-weight: 800;
  font-size: 0.84rem;
  cursor: pointer;
  margin-bottom: 12px;
}
.insp-simbtn span { color: var(--violet); }
.insp-simbtn:hover { border-color: var(--green); }

.usim-panel {
  width: min(1240px, 96vw);
  height: min(860px, 94vh);
  background: #0e1424;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.usim-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--card-border);
}
.usim-head h2 { font-size: 1.02rem; }
.usim-sub { font-size: 0.72rem; color: var(--text-dim); flex: 1; }
.usim-close {
  background: none;
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 8px;
  width: 30px; height: 30px;
  font-size: 1.1rem;
  cursor: pointer;
  align-self: center;
}
.usim-close:hover { border-color: #f87171; color: #f87171; }
.usim-body {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 14px;
  padding: 14px 18px;
  overflow-y: auto;
  align-items: start;
}
/* the settings column now holds every pool parameter, so it scrolls on its
   own rather than stretching the panel and pushing the charts off-screen */
.usim-controls {
  position: sticky;
  top: 0;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  padding-right: 4px;
}
.usim-controls label {
  display: block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 10px;
}
.usim-controls input, .usim-controls select {
  width: 100%;
  margin-top: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 7px 9px;
  outline: none;
}
.usim-controls input:focus, .usim-controls select:focus { border-color: var(--green); }
.usim-stats { margin-top: 6px; }
.usim-stat {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 6px 9px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.03);
}
.usim-stat small {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
}
.usim-stat b { font-size: 0.85rem; }
.usim-stat b.pos { color: var(--green); }
.usim-stat b.insp-warn { display: inline; margin-top: 0; }
.usim-stats-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.usim-stats-row .usim-stat { margin-bottom: 0; }

.usim-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-content: start;
}
.usim-span2 { grid-column: 1 / -1; }
.usim-chart-block {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
}
.usim-chart-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.usim-note { font-weight: 500; font-size: 0.66rem; }
.usim-chart-block canvas { width: 100%; height: 190px; display: block; }
.usim-span2 > canvas#usim-chart-value { height: 240px; cursor: ew-resize; }
.usim-bt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.usim-bt-grid canvas { height: 180px; }
.usim-toggle button {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 9px;
  cursor: pointer;
}
.usim-toggle button:first-child { border-radius: 6px 0 0 6px; }
.usim-toggle button:last-child { border-radius: 0 6px 6px 0; }
.usim-toggle button.on { color: var(--green); border-color: var(--green); }
.usim-inline-select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 6px;
  outline: none;
}
@media (max-width: 980px) {
  .usim-body { grid-template-columns: 1fr; }
  .usim-charts { grid-template-columns: 1fr; }
  .usim-bt-grid { grid-template-columns: 1fr; }
  .usim-stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* collapsible monthly-update block */
.insp-eq summary.insp-eq-title { cursor: pointer; margin-bottom: 0; list-style: none; }
.insp-eq summary.insp-eq-title::before { content: '▸ '; color: var(--violet); }
.insp-eq details[open] summary.insp-eq-title::before { content: '▾ '; }
.insp-eq details[open] summary.insp-eq-title { margin-bottom: 6px; }
.insp-eq summary::-webkit-details-marker { display: none; }

/* fee-APR field shown as a computed output (auto fee source) */
.insp-input-computed {
  opacity: 0.6;
  cursor: not-allowed;
  background: rgba(199, 209, 234, 0.04);
}
.insp-field-hint {
  margin-top: 3px;
  font-size: 10px;
  color: #8b94ad;
  font-style: italic;
}

/* IL calculator (position simulator) */
.usim-ilcalc { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.usim-ilcalc-inputs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.usim-ilcalc-inputs label {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 700;
}
.usim-ilcalc-inputs input {
  width: 100%;
  margin-top: 5px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 7px 9px;
  outline: none;
}
.usim-ilcalc-inputs input:focus { border-color: var(--violet); }
.usim-apply {
  align-self: flex-start;
  background: var(--violet);
  color: #0b101d;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 9px 16px;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}
.usim-apply:hover { filter: brightness(1.08); }
.usim-apply:disabled { opacity: 0.4; cursor: not-allowed; }
@media (max-width: 720px) {
  .usim-ilcalc-inputs { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- collapsible inspector param groups ---------- */
.insp-group {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.insp-group > summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 10px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  user-select: none;
}
.insp-group > summary::-webkit-details-marker { display: none; }
.insp-group > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 7px;
  transition: transform 0.15s ease;
}
.insp-group[open] > summary::before { transform: rotate(90deg); }
.insp-group > summary:hover { color: var(--text); }
.insp-group > .insp-field { padding: 0 10px; }
.insp-group > .insp-field:last-child { padding-bottom: 10px; }

/* ---------- report card: scope banner + actionable fixes ---------- */
.rc-scope {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.5;
  background: rgba(96, 165, 250, 0.08);
  border: 1px solid rgba(96, 165, 250, 0.25);
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 10px;
}
.rc-scope b { color: var(--text); }
.rc-fix {
  display: block;
  font-size: 0.71rem;
  color: #9fb3d9;
  line-height: 1.45;
  margin-top: 5px;
  padding-left: 9px;
  border-left: 2px solid rgba(159, 179, 217, 0.35);
}

/* ---------- template brief ---------- */
.tpl-brief {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 11px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.03);
}
.tpl-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tpl-title > b { font-size: 0.82rem; color: var(--text); }
.tpl-kind {
  flex: none;
  color: #c4b5fd;
  border: 1px solid rgba(196, 181, 253, 0.28);
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tpl-brief p {
  font-size: 0.73rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 6px 0 0;
}
.tpl-tag {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #9fb3d9;
  background: rgba(159, 179, 217, 0.12);
  border-radius: 5px;
  padding: 1px 5px;
  margin-right: 5px;
}
.tpl-tag.warn { color: #fbbf24; background: rgba(251, 191, 36, 0.12); }
.tpl-note { font-style: italic; opacity: 0.75; }

/* stats bar: an unmeasured range must not look like a measured one */
.stat-muted { color: var(--text-dim); font-style: italic; }
.stat-sub { color: var(--text-dim); font-size: 0.76rem; font-weight: 600; }

/* ---------- pool simulator: schema-rendered settings form ---------- */
/* The panel now hosts every pool parameter, so it reuses the inspector's
   field and collapsible-group styling inside its own control column. */
.usim-params .insp-field { margin-bottom: 10px; }
.usim-params .insp-field label {
  display: block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 4px;
}
.usim-params .insp-field input,
.usim-params .insp-field select {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 7px 9px;
  outline: none;
}
.usim-params .insp-field input:focus,
.usim-params .insp-field select:focus { border-color: var(--green); }
.usim-params .insp-group { margin-bottom: 10px; }
.usim-params .insp-group > summary { font-size: 0.64rem; padding: 7px 9px; }
.usim-params .insp-group > .insp-field { padding: 0 9px; }
.usim-params .insp-group > .insp-field:last-child { padding-bottom: 9px; }
.usim-params .insp-input-computed { opacity: 0.72; cursor: not-allowed; }
.usim-params .insp-field-hint { margin-top: 3px; font-size: 10px; color: #8b94ad; font-style: italic; }

/* a classic full-range pool has no bounds to plot — hide the v3-only charts
   rather than render them empty, and let the settings column breathe */
.usim-classic .usim-chart-block:not(.usim-ilcalc-block) { display: none; }
.usim-classic .usim-body { grid-template-columns: minmax(260px, 340px) 1fr; }

/* ---------- inspector: read-only mirror of the pool simulator ---------- */
.insp-readout {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  padding: 9px 10px;
  margin-bottom: 12px;
}
.insp-readout-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.insp-readout-head span {
  font-size: 0.58rem;
  letter-spacing: 0.05em;
  color: #8b94ad;
  background: rgba(139, 148, 173, 0.14);
  border-radius: 5px;
  padding: 1px 5px;
}
.insp-readout-group {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7b85a0;
  margin: 9px 0 3px;
}
.insp-readout-group:first-of-type { margin-top: 0; }
.insp-readout-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.74rem;
  line-height: 1.5;
  padding: 1px 0;
}
.insp-readout-row span { color: var(--text-dim); min-width: 0; }
.insp-readout-row b { color: var(--text); white-space: nowrap; font-weight: 700; }
.insp-readout-edit {
  width: 100%;
  margin-top: 10px;
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.45);
  color: #c7b7f7;
  border-radius: 8px;
  padding: 7px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}
.insp-readout-edit:hover { background: rgba(167, 139, 250, 0.22); }

/* ---------- inspector: collapsible month-by-month node summary ---------- */
.insp-summary { margin-bottom: 12px; }
.insp-summary-body { padding: 4px 2px 2px; }
.insp-summary-static { margin-bottom: 8px; }
.insp-summary-static > div {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 0.74rem; line-height: 1.6; padding: 1px 0;
}
.insp-summary-static span { color: var(--text-dim); }
.insp-summary-static b { color: var(--text); font-weight: 700; text-align: right; }
.insp-summary-scrub { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.insp-summary-scrub input[type="range"] { flex: 1; margin: 0; }
.nsum-lbl { font-size: 0.7rem; font-weight: 700; color: var(--green); white-space: nowrap; min-width: 96px; text-align: right; }
.insp-summary-grid { display: flex; flex-direction: column; gap: 3px; }
.nsum-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 0.78rem; }
.nsum-row > span { color: var(--text-dim); }
.nsum-row > b { color: var(--text); font-weight: 700; white-space: nowrap; }
.nsum-row .pos { color: var(--green); }
.nsum-row .neg { color: #f87171; }
.nsum-sub { color: var(--text-dim); font-weight: 600; font-size: 0.72rem; }
