/* Economic Models Lab — extends the existing research-terminal language. */
#economic-models-app { --model-blue: #79aee6; --model-gold: #d1b36d; --model-red: #d98166; --model-cyan: #78c5c7; }
.model-selector { display: grid; gap: 1px; border: 1px solid var(--line); background: var(--line); }
.model-selector-group { display: flex; align-items: stretch; gap: 1px; overflow-x: auto; background: #0b0e12; }
.model-selector-label { display: grid; place-items: center; flex: 0 0 105px; padding: .55rem; color: #697580; font-size: .6875rem; font-weight: 700; letter-spacing: .06em; }
.model-tab { flex: 1 0 auto; min-height: 42px; padding: .55rem .7rem; border: 0; border-left: 1px solid var(--line); background: #101419; color: #9aa3ac; font: inherit; font-size: .72rem; cursor: pointer; }
.model-tab:hover, .model-tab:focus-visible { color: #dce8f5; background: #141a21; outline: 1px solid #466991; outline-offset: -2px; }
.model-tab.is-active { color: #dcecff; background: #17212b; box-shadow: inset 0 -2px var(--model-blue); }
.model-toolbar, .model-scenario-bar { display: flex; align-items: center; gap: .4rem; padding: .6rem .7rem; border: 1px solid var(--line); border-top: 0; background: #0d1115; overflow-x: auto; }
.model-toolbar button, .model-scenario-bar button { min-height: 34px; padding: .42rem .65rem; border: 1px solid #343d47; border-radius: 3px; background: #12171d; color: #aeb7c0; font: inherit; font-size: .7rem; white-space: nowrap; cursor: pointer; }
.model-toolbar button:hover, .model-toolbar button.is-active, .model-scenario-bar button:hover { border-color: #547ca8; color: #e1edf9; background: #17212b; }
.model-scenario-bar { justify-content: flex-start; border-top: 1px solid var(--line-soft); }
.model-scenario-label { display: flex; align-items: center; gap: .5rem; color: #75818c; font-size: .7rem; }
.model-scenario-select { min-width: 220px; min-height: 34px; padding: .35rem .55rem; border: 1px solid #343d47; border-radius: 3px; background: #0e1318; color: #d8dfe6; font: inherit; font-size: .72rem; }
.model-preset-note { color: #6e7882; font-size: .65rem; text-transform: uppercase; letter-spacing: .05em; }
.remove-protection { margin-left: auto; border-color: #766440 !important; color: #d9c18e !important; }
.models-lab { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, .65fr); gap: 1px; margin-top: .75rem; border: 1px solid var(--line); background: var(--line); align-items: start; }
.model-graph-side, .model-controls { min-width: 0; background: var(--panel); }
.model-graph-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem .85rem; border-bottom: 1px solid var(--line-soft); }
.model-graph-head h3 { color: #e2e7eb; font-size: .95rem; font-weight: 600; }
.simulation-label { flex: 0 0 auto; padding: .25rem .4rem; border: 1px solid #5c5137; color: #c7b47d; font-size: .62rem; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; }
.model-graph { min-height: 480px; overflow-x: auto; background: radial-gradient(circle at 50% 35%, #121922 0, #0c1014 68%); }
.model-graph svg { display: block; min-width: 700px; width: 100%; height: auto; }
.model-axis { stroke: #71808d; stroke-width: 1.2; }
.model-axis-label { fill: #7e8994; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.model-curve { fill: none; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; transition: d .22s ease, opacity .2s ease; }
.model-curve.demand { stroke: var(--model-blue); }
.model-curve.supply { stroke: var(--model-gold); }
.model-curve.supply.shifted { stroke: #e0c57d; stroke-dasharray: 8 4; }
.model-curve.capacity { stroke: var(--model-cyan); }
.model-curve.old { stroke: #66727e; stroke-width: 1.5; stroke-dasharray: 5 5; opacity: .38; }
.model-curve-label, .model-equilibrium-label, .model-note-label { fill: #cbd5df; font-size: 11px; font-weight: 700; }
.model-note-label { fill: #9fb0c0; }
.model-guide { stroke: #677480; stroke-width: 1; stroke-dasharray: 3 5; opacity: .65; }
.model-zero { stroke: #626f7c; stroke-width: 1; stroke-dasharray: 4 4; }
.model-equilibrium { fill: #e2edf8; stroke: #5383b4; stroke-width: 3; }
.model-point { fill: #9fc5e9; stroke: #31577c; stroke-width: 2; }
.model-point.outside { fill: #151a20; stroke: #c78b72; stroke-dasharray: 3 2; }
.model-policy-line { stroke: #d1b36d; stroke-width: 2; stroke-dasharray: 8 4; }
.model-world-line { stroke: #87a4c1; stroke-width: 1.5; }
.model-gap { stroke: #ca8e73; stroke-width: 3; }
.model-bar { transition: y .2s ease, height .2s ease; }
.model-bar.positive { fill: #5f91c2; }
.model-bar.negative { fill: #b87961; }
.model-bar-label { fill: #7c8792; font-size: 9px; }
.welfare-area { stroke-width: 1; opacity: .46; }
.welfare-area.loss { fill: #b36f594d; stroke: #b97a63; }
.welfare-area.revenue { fill: #6085aa55; stroke: #7ba7d9; }
.welfare-area.rent { fill: #b4955255; stroke: #c3a866; }
.model-graph-toggles { display: flex; flex-wrap: wrap; gap: .4rem; padding: .55rem .7rem; border-top: 1px solid var(--line-soft); background: #0d1115; }
.model-mini-toggle { display: flex; align-items: center; gap: .35rem; color: #929da7; font-size: .67rem; cursor: pointer; }
.model-mini-toggle input { accent-color: #6f9fcf; }
.model-results { display: grid; grid-template-columns: repeat(5, minmax(110px, 1fr)); gap: 1px; border-top: 1px solid var(--line); background: var(--line); overflow-x: auto; }
.model-result { min-width: 110px; padding: .55rem .65rem; background: #0e1318; }
.model-result span { display: block; color: #707c87; font-size: .62rem; text-transform: uppercase; letter-spacing: .035em; }
.model-result strong { display: block; margin-top: .2rem; color: #dbe3ea; font-family: "SFMono-Regular", Consolas, monospace; font-size: .75rem; font-weight: 600; }
.model-controls { max-height: 730px; overflow-y: auto; padding: .8rem; }
.model-controls h3 { margin: .1rem 0 .7rem; color: #dce2e8; font-size: .9rem; }
.model-control-group { display: grid; gap: .62rem; margin: 0 0 .85rem; padding: .7rem; border: 1px solid var(--line-soft); }
.model-control-group legend { padding: 0 .25rem; color: #718194; font-size: .65rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.model-control-row { display: grid; gap: .32rem; color: #adb6bf; font-size: .72rem; }
.model-control-row.is-check { display: flex; align-items: center; }
.model-control-head { display: flex; justify-content: space-between; gap: .5rem; }
.model-control-head output { color: #9cc8ff; font-family: "SFMono-Regular", Consolas, monospace; font-size: .68rem; }
.model-control-row input[type="range"] { width: 100%; accent-color: #6e9dcc; }
.model-control-row select { width: 100%; min-height: 34px; padding: .35rem; border: 1px solid #333c46; background: #0c1116; color: #d6dde3; }
.model-compare, .model-analysis-section, .model-observed, .model-hsc, .model-theory { margin-top: .75rem; padding: .85rem; border: 1px solid var(--line); background: var(--panel); }
.model-compare[hidden], .model-analysis-section[hidden], .model-observed[hidden], .model-hsc[hidden], .model-theory[hidden] { display: none; }
.model-compare h3, .model-analysis-section h3, .model-observed h3, .model-hsc h3, .model-theory h3 { margin-top: .15rem; color: #dce3e9; font-size: .95rem; }
.model-compare-grid { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 1px; margin-top: .7rem; background: var(--line); overflow-x: auto; }
.model-compare-col { min-width: 170px; padding: .65rem; background: #0d1217; }
.model-compare-col h4 { color: #91b9e2; font-size: .75rem; }
.model-compare-col p { display: flex; justify-content: space-between; gap: .5rem; margin-top: .4rem; color: #78838e; font-size: .66rem; }
.model-compare-col strong { color: #c9d2da; font-family: "SFMono-Regular", Consolas, monospace; font-weight: 500; }
.universal-chain { display: grid; grid-template-columns: repeat(5, minmax(155px, 1fr)); gap: 1px; margin-top: .7rem; background: var(--line); overflow-x: auto; }
.universal-step { position: relative; min-width: 155px; min-height: 110px; padding: .65rem; background: #0d1217; }
.universal-step:not(:last-child)::after { content: "→"; position: absolute; right: -.42rem; top: 45%; z-index: 2; color: #6d94be; }
.universal-step > span { color: #637080; font-family: "SFMono-Regular", Consolas, monospace; font-size: .62rem; }
.universal-step p { margin-top: .35rem; color: #b7c1ca; font-size: .72rem; line-height: 1.5; }
.objectives-title { margin-top: 1rem !important; }
.model-objectives { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 1px; margin-top: .55rem; background: var(--line); }
.model-objectives article { padding: .6rem; background: #0d1217; }
.model-objectives h4 { color: #839fc0; font-size: .65rem; text-transform: uppercase; letter-spacing: .04em; }
.model-objectives p { margin-top: .25rem; color: #aeb8c2; font-size: .71rem; line-height: 1.45; }
.model-hsc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: .65rem; background: var(--line); }
.model-hsc-grid > div { padding: .65rem; background: #0d1217; }
.model-hsc-grid dt { color: #7593b5; font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.model-hsc-grid dd { margin: .3rem 0 0; color: #b8c1ca; font-size: .73rem; line-height: 1.55; }
.model-hsc-grid > div:last-child { grid-column: 1 / -1; border-left: 2px solid #5e88b4; }
.model-theory-grid, .observed-data-grid { display: grid; grid-template-columns: repeat(3, minmax(170px, 1fr)); gap: 1px; margin-top: .65rem; background: var(--line); }
.model-theory-grid article, .observed-data-grid article { padding: .65rem; background: #0d1217; }
.model-theory-grid h4 { color: #89a8c8; font-size: .68rem; }
.model-theory-grid p { margin-top: .3rem; color: #9ca6af; font-size: .71rem; line-height: 1.5; }
.observed-data-grid span, .observed-data-grid small { display: block; color: #7d8995; font-size: .65rem; }
.observed-data-grid strong { display: block; margin: .25rem 0; color: #d9e4ef; font-family: "SFMono-Regular", Consolas, monospace; font-size: .82rem; }
.model-data-caveat, .observed-scatter p { margin-top: .6rem; color: #7e8993; font-size: .68rem; line-height: 1.5; }
.observed-scatter { margin-top: .65rem; border: 1px solid var(--line-soft); background: #0d1217; }
.observed-scatter svg { display: block; width: 100%; max-height: 300px; }
.observed-dot { fill: #83b6e8; stroke: #234b72; stroke-width: 1.5; opacity: .8; }

@media (max-width: 1100px) {
  .models-lab { grid-template-columns: minmax(0, 1fr); }
  .model-controls { max-height: none; }
  .model-results { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
  .universal-chain { grid-template-columns: repeat(5, minmax(190px, 1fr)); }
}
@media (max-width: 700px) {
  .model-selector-label { flex-basis: 72px; }
  .model-toolbar, .model-scenario-bar { align-items: stretch; flex-wrap: wrap; }
  .model-scenario-label { width: 100%; align-items: stretch; flex-direction: column; }
  .model-scenario-select { min-width: 0; width: 100%; }
  .remove-protection { margin-left: 0; }
  .model-graph-head { align-items: flex-start; flex-direction: column; }
  .model-graph { min-height: 390px; }
  .model-results { grid-template-columns: repeat(2, minmax(145px, 1fr)); }
  .model-objectives, .model-hsc-grid, .model-theory-grid, .observed-data-grid { grid-template-columns: minmax(0, 1fr); }
  .model-hsc-grid > div:last-child { grid-column: auto; }
}
