/* Economy panel and its charts. Same tokens as style.css; the data is the only loud thing. */
.modal.wide { width: min(1240px, 100%); }
.modal-body.eco-body { padding: 0; gap: 0; display: block; }
.eco { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100%; }
.eco-nav {
  position: sticky; top: 0; align-self: start; max-height: calc(100dvh - 120px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: var(--s4) var(--s3); border-right: 1px solid var(--line);
}
.eco-nav-btn {
  display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); font-size: 13.5px; font-weight: 500; text-align: left; cursor: pointer;
}
.eco-nav-btn span { font-size: 11.5px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.eco-nav-btn:hover { background: var(--panel-2); }
.eco-nav-btn.on { background: var(--ink); color: #fff; font-weight: 600; }
.eco-nav-btn.on span { color: #d8c6a8; }
.eco-main { min-width: 0; padding: var(--s5) var(--s6) var(--s6); display: flex; flex-direction: column; gap: 28px; }
.eco-head { display: flex; flex-direction: column; gap: 6px; padding-bottom: var(--s4); border-bottom: 1px solid var(--line); }
.eco-kicker { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.eco-head h3 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.eco-head p { font-size: 16px; color: var(--ink-2); max-width: 70ch; }
.eco-sec { display: flex; flex-direction: column; gap: var(--s3); }
.eco-sec > h4 { font-size: 16px; font-weight: 700; }
.eco-p, .eco-lead { max-width: 78ch; }
.eco-lead { font-size: 16px; color: var(--ink-2); }
.eco-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; max-width: 80ch; }
.eco-main table.t td { white-space: normal; vertical-align: top; min-width: 72px; line-height: 1.45; }
.eco-main table.t td:first-child { font-weight: 600; min-width: 120px; }
.eco-main table.t th { white-space: normal; min-width: 64px; vertical-align: bottom; }
.eco-pager { display: flex; justify-content: space-between; gap: var(--s3); padding-top: var(--s4); border-top: 1px solid var(--line); }
.eco-pager .btn { white-space: normal; text-align: left; }
.eco-fig { margin: 0; display: flex; flex-direction: column; gap: var(--s2); }
.eco-fig figcaption { font-size: 13px; color: var(--ink-2); max-width: 90ch; }
.eco-badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2);
  font-size: 11.5px; font-weight: 700; color: var(--ink-2); vertical-align: 1px; white-space: nowrap; flex: 0 0 auto;
}
.eco-badge.ok { background: var(--ok-bg); border-color: #bbe5c8; color: var(--ok); }
.formula {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; line-height: 1.7; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--ink-2); border-radius: var(--radius-sm);
  padding: var(--s3) var(--s4); overflow-x: auto; white-space: pre;
}
.eco-callout {
  display: flex; flex-direction: column; gap: 6px; padding: var(--s4); border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); border-left: 3px solid var(--ink-2);
}
.eco-callout b { font-size: 14.5px; }
.eco-callout.key { border-left-color: var(--brand); background: #f6f1ff; border-color: #e2d6fb; }
.eco-callout.warn { border-left-color: var(--warn); background: var(--warn-bg); border-color: #f6dfa3; color: #5b2c06; }
.eco-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--s3); }
.eco-col { padding: var(--s4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); display: flex; flex-direction: column; gap: var(--s2); }
.eco-col h5 { margin: 0; font-size: 14px; font-weight: 700; padding-left: 10px; border-left: 3px solid var(--ink-2); }
.eco-col.ok h5 { border-left-color: var(--ok); }
.eco-col.bad h5 { border-left-color: var(--bad); }
.eco-col.warn h5 { border-left-color: var(--warn); }
.eco-num-list {
  margin: 0; padding: 0; list-style: none; counter-reset: n;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--s3) var(--s5);
}
.eco-num-list li { counter-increment: n; display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 10px; }
.eco-num-list li::before {
  content: counter(n); grid-row: span 2; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--ink);
  display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700;
}
.eco-num-list b { font-size: 14.5px; }
.eco-num-list span { color: var(--ink-2); font-size: 14px; }
.eco-stats { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: var(--s2); }
@media (max-width: 700px) { .eco-stats { grid-template-columns: repeat(min(var(--cols, 3), 2), minmax(0, 1fr)); } }
.eco-stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 0; }
.eco-stat > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.eco-stat > b { font-size: 19px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.eco-stat > small { font-size: 12px; color: var(--ink-2); }
.eco-split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--s5); align-items: center; }
.eco-controls { display: flex; flex-direction: column; gap: var(--s3); }
.eco-row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--s3) var(--s5); align-items: end; }
.eco-mitig { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: var(--s2); }
.eco-mit { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); display: flex; flex-direction: column; gap: 4px; }
.eco-mit > div { display: flex; justify-content: space-between; gap: var(--s2); align-items: baseline; }
.eco-mit p { font-size: 13.5px; color: var(--ink-2); }
.eco-mit.off { background: transparent; border-style: dashed; }
.eco-scen { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--s2); }
.eco-scen > div { display: grid; grid-template-columns: 14px auto; column-gap: 8px; align-items: center; }
.eco-scen i { width: 14px; height: 3px; border-radius: 2px; }
.eco-scen span { grid-column: 2; font-size: 13px; color: var(--ink-2); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); width: fit-content; max-width: 100%; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(43, 29, 18, .15); }
.seg.small button { padding: 6px 10px; font-size: 12.5px; }
.eco-slider { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.eco-slider > span { display: flex; justify-content: space-between; gap: var(--s2); }
.eco-slider b { color: var(--ink); font-variant-numeric: tabular-nums; }
.eco-range { width: 100%; accent-color: var(--ink); height: 24px; }

/* ------------------------------------------------------------------ charts */
.viz-tip {
  position: fixed; z-index: 400; display: none; pointer-events: none; min-width: 120px; max-width: 280px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 12, 4, .18);
  padding: 8px 10px; font-size: 12.5px; color: var(--ink);
}
.viz-tip .tt { font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.viz-tip .tr { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.viz-tip .tr i { width: 12px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.viz-tip .tr b { font-weight: 700; font-variant-numeric: tabular-nums; }
.viz-tip .tr span { color: var(--ink-2); }

.donut { display: grid; grid-template-columns: auto minmax(0, 440px); justify-content: start; gap: var(--s6); align-items: center; width: 100%; }
.donut-fig { position: relative; flex: 0 0 auto; }
.donut-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.donut-svg .arc { transition: opacity .15s; cursor: pointer; outline: none; }
.donut-svg .arc.dim { opacity: .25; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; padding: 0 22%; }
.donut-center b { font-size: 22px; font-weight: 800; line-height: 1.1; }
.donut-center span { font-size: 12px; color: var(--ink-2); line-height: 1.3; }
.legend-list { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.legend-row {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 52px; align-items: center; gap: 10px; width: 100%;
  padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; cursor: default; font-size: 13.5px;
}
.legend-row.nopct { grid-template-columns: 12px minmax(0, 1fr) auto; }
.legend-row:hover, .legend-row.on, .legend-row:focus-visible { background: var(--panel-2); }
.legend-row .sw { width: 12px; height: 12px; border-radius: 3px; }
.legend-row .lb { display: flex; flex-direction: column; min-width: 0; }
.legend-row .lb small { color: var(--ink-2); font-size: 12px; }
.legend-row b { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.legend-row em { font-style: normal; color: var(--ink-2); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.legend-inline { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: 13px; color: var(--ink-2); }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline i { width: 14px; height: 3px; border-radius: 2px; }

.line-chart { display: flex; flex-direction: column; gap: var(--s2); }
.line-box { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none; min-height: 60px; }
.line-box:focus-visible { box-shadow: 0 0 0 2px rgba(43, 29, 18, .35); }
.line-box svg { display: block; }
.line-box text.ax { font-size: 11.5px; fill: #8a735b; font-family: var(--font); font-variant-numeric: tabular-nums; }
.line-box text.ref { fill: var(--ink-2); font-weight: 600; }

.hbars { display: flex; flex-direction: column; gap: 6px; padding: var(--s3) var(--s4); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.hb-row { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); gap: var(--s3); align-items: center; padding: 3px 0; border-radius: 6px; outline: none; }
.hb-row:hover, .hb-row:focus-visible { background: var(--panel-2); }
.hb-label { font-size: 13.5px; display: flex; flex-direction: column; line-height: 1.3; }
.hb-label small { font-size: 11.5px; color: var(--ink-2); }
.hb-track { position: relative; height: 22px; margin-right: 92px; }
.hb-track i { position: absolute; left: 0; top: 4px; display: block; height: 14px; border-radius: 0 4px 4px 0; }
.hb-track b {
  position: absolute; top: 2px; padding: 0 4px; line-height: 18px; background: var(--card); border-radius: 4px; z-index: 1;
  font-size: 12.5px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.hb-row:hover .hb-track b, .hb-row:focus-visible .hb-track b { background: var(--panel-2); }
.hb-track u { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 1px solid var(--ink-2); }
.hb-cap { display: flex; align-items: center; gap: 8px; }
.hb-cap i { width: 0; height: 12px; border-left: 1px solid var(--ink-2); }

.cols {
  display: flex; align-items: stretch; gap: var(--s3); padding: var(--s3) var(--s4) 36px; position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); box-sizing: content-box;
}
.col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; min-width: 0; outline: none; position: relative; }
.cols::before { content: ""; position: absolute; left: var(--s4); right: var(--s4); bottom: 36px; border-top: 1px solid #d9c49f; }
.col-plot { flex: 1 1 auto; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.col-plot b { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.col-plot i { display: block; width: min(24px, 60%); border-radius: 4px 4px 0 0; transition: opacity .15s; }
.col > span { position: absolute; bottom: -30px; font-size: 12px; color: var(--ink-2); text-align: center; white-space: nowrap; }
.col.off .col-plot i { opacity: .3; }
.col.on > span { color: var(--ink); font-weight: 700; }

.range { display: flex; flex-direction: column; gap: 4px; padding: var(--s3) var(--s4); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.rg-row, .rg-axis { display: grid; grid-template-columns: 120px minmax(0, 1fr) 96px; gap: var(--s3); align-items: center; }
.rg-row { padding: 5px 0; border-radius: 6px; outline: none; }
.rg-row:hover, .rg-row:focus-visible { background: var(--panel-2); }
.rg-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.rg-label .sw { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.rg-track { position: relative; height: 18px; }
.rg-track u { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid #efe3cb; }
.rg-line { position: absolute; top: 8px; height: 2px; border-radius: 1px; }
.rg-dot { position: absolute; top: 5px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; box-shadow: 0 0 0 2px #fffaf0; }
.rg-dot.mid { top: 3px; width: 12px; height: 12px; margin-left: -6px; }
.rg-val { font-size: 13.5px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; line-height: 1.2; }
.rg-val small { font-size: 11.5px; font-weight: 500; color: var(--ink-2); }
.rg-axis > div { position: relative; height: 16px; }
.rg-axis > div span { position: absolute; transform: translateX(-50%); font-size: 11.5px; color: #8a735b; font-variant-numeric: tabular-nums; }

.flow-outer { display: flex; flex-direction: column; gap: 4px; }
.flow-hint { display: none; font-size: 12px; color: var(--ink-2); }
@media (max-width: 760px) { .flow-hint { display: block; } }
.flow-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s3); }
.flow-svg { display: block; width: 100%; height: auto; font-family: var(--font); }
.flow-svg .edge { stroke-opacity: .42; transition: stroke-opacity .15s; cursor: default; outline: none; }
.flow-svg .edge:hover, .flow-svg .edge:focus-visible { stroke-opacity: .8; }
.flow-svg .edge.back { stroke-opacity: .7; }
.flow-svg .edge.dim { stroke-opacity: .08; }
.flow-svg .edge-tag { font-size: 11.5px; font-weight: 700; fill: var(--ink-2); paint-order: stroke; stroke: #fffaf0; stroke-width: 4px; stroke-linejoin: round; }
.flow-svg .node { cursor: pointer; outline: none; }
.flow-svg .node rect:first-child { fill: #fff; stroke: #dcc8a6; stroke-width: 1; }
.flow-svg .node:hover rect:first-child, .flow-svg .node:focus-visible rect:first-child, .flow-svg .node.sel rect:first-child { stroke: var(--ink); stroke-width: 1.5; }
.flow-svg .node-src rect:first-child { fill: #fbf3e4; }
.flow-svg .node-vault rect:first-child { stroke-width: 1.5; stroke: #b9a27f; }
.flow-svg .n-title { font-size: 13px; font-weight: 700; fill: var(--ink); }
.flow-svg .n-sub { font-size: 11.5px; fill: var(--ink-2); }
.flow-svg .n-num { font-size: 12px; font-weight: 800; fill: #fff; }
.steps-svg .node-step { cursor: default; }
.flow-info { padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; display: flex; flex-direction: column; gap: 4px; min-height: 76px; }
.flow-info p { color: var(--ink-2); font-size: 14px; max-width: 90ch; }

@media (max-width: 900px) {
  .eco { grid-template-columns: minmax(0, 1fr); }
  .eco-nav {
    position: sticky; top: 0; z-index: 3; flex-direction: row; overflow-x: auto; max-height: none; gap: 4px;
    padding: var(--s2) var(--s3); border-right: 0; border-bottom: 1px solid var(--line); background: var(--panel); scrollbar-width: none;
  }
  .eco-nav::-webkit-scrollbar { display: none; }
  .eco-nav-btn { width: auto; flex: 0 0 auto; white-space: nowrap; padding: 7px 10px; }
  .eco-main { padding: var(--s4); gap: 24px; }
  .eco-head h3 { font-size: 22px; }
  .eco-split, .donut { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .donut .legend-list { width: 100%; }
}
@media (max-width: 560px) {
  .rg-row, .rg-axis { grid-template-columns: 84px minmax(0, 1fr) 64px; gap: var(--s2); }
  .hb-row { grid-template-columns: minmax(96px, 40%) minmax(0, 1fr); }
  .eco-pager { flex-direction: column; }
  .eco-pager .btn { width: 100%; justify-content: center; }
  .cols { gap: var(--s2); padding-left: var(--s2); padding-right: var(--s2); }
  .col > span { white-space: normal; font-size: 11px; line-height: 1.2; }
}

/* Claude Design "Economy" look: cream chapter rail, dark current chapter with a
   gold number, purple kicker, outlined key callout, dashed dividers. */
.eco-nav { gap: 4px; padding: 16px; background: var(--panel-2); border-right: 2px solid var(--line); }
.eco-nav-btn { align-items: center; min-height: 40px; padding: 6px 10px; border-radius: 10px; font-size: 14px; font-weight: 700; }
.eco-nav-btn span { flex: none; width: 26px; font-size: 12px; font-weight: 800; }
.eco-nav-btn:hover { background: var(--line-2); }
.eco-nav-btn.on { background: var(--ink); color: var(--panel); font-weight: 700; }
.eco-nav-btn.on span { color: var(--gold); }
.eco-main { padding: 24px; gap: 22px; }
.eco-head { gap: 4px; padding-bottom: var(--s4); border-bottom: 2px dashed var(--line); }
.eco-kicker { font-size: 12px; font-weight: 800; letter-spacing: .6px; color: var(--brand-2); }
.eco-head h3 { font-size: 28px; font-weight: 800; letter-spacing: 0; }
.eco-head p { font-size: 15px; color: var(--ink-3); }
.eco-sec > h4 { font-size: 18px; font-weight: 800; }
.eco-callout { gap: 4px; padding: 16px 18px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); }
.eco-callout b { font-size: 16px; font-weight: 800; }
.eco-callout.key { border: 3px solid var(--ink); background: var(--card); }
.eco-callout.warn { border: 2px solid #f2d27a; background: var(--warn-bg); color: var(--ink); }
.eco-col { border: 2px solid var(--line); border-radius: 14px; }
.eco-badge { border: 0; background: var(--line-2); color: var(--ink-3); font-weight: 800; }
.eco-badge.ok { background: var(--ok-bg); color: #166534; }
.formula { border: 2px solid var(--line); border-left: 4px solid var(--brand); border-radius: 12px; }
.eco-pager { padding-top: 14px; border-top: 2px dashed var(--line); }
@media (max-width: 720px) { .eco-nav { border-right: 0; border-bottom: 2px solid var(--line); } }
