/* bim.css — Budget Impact Model demonstrator */
.bim-shell {
  --ink: #172033; --muted: #5f6b7a; --border: #d9e0e8; --soft: #f6f8fb;
  --panel: #ffffff; --blue: #2f6fbd; --green: #2f8f6b; --red: #b24b4b; --amber: #b7791f;
  color: var(--ink);
  font-size: 0.94rem; line-height: 1.55;
  max-width: 1180px; margin: 0 auto;
}
.bim-shell *, .bim-shell *::before, .bim-shell *::after { box-sizing: border-box; }

/* ---- top bar ---- */
.bim-topbar {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem; margin-bottom: 1.2rem;
  background: var(--soft); border: 1px solid var(--border); border-radius: 10px;
  position: sticky; top: 0; z-index: 20;
}
.bim-topbar-left, .bim-topbar-right { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.bim-topbar-label { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.bim-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.bim-toggle-btn {
  border: 0; background: #fff; color: var(--muted); cursor: pointer;
  padding: 0.4rem 0.85rem; font-size: 0.86rem; font-family: inherit;
}
.bim-toggle-btn + .bim-toggle-btn { border-left: 1px solid var(--border); }
.bim-toggle-btn.active { background: var(--blue); color: #fff; font-weight: 600; }
.bim-headline { display: flex; align-items: baseline; gap: 0.5rem; }
.bim-headline span { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.bim-headline strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.bim-headline em { font-style: normal; color: var(--muted); font-size: 0.84rem; }
.bim-reset {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  border-radius: 8px; padding: 0.4rem 0.8rem; cursor: pointer; font-size: 0.82rem; font-family: inherit;
}
.bim-reset:hover { border-color: var(--blue); color: var(--blue); }

/* ---- panels ---- */
.bim-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.3rem 1.4rem; margin-bottom: 1.4rem;
}
.bim-panel-title { margin: 0 0 0.35rem; font-size: 1.06rem; letter-spacing: -0.01em; }
.bim-panel-note { margin: 0 0 1rem; color: var(--muted); font-size: 0.88rem; }
.bim-callout {
  margin: 1rem 0 0; padding: 0.75rem 0.9rem; background: var(--soft);
  border-left: 3px solid var(--blue); border-radius: 0 8px 8px 0;
  font-size: 0.86rem; color: var(--ink);
}
.bim-note-box {
  margin: 1.1rem 0 0; padding: 0.85rem 1rem; background: #fdfaf3;
  border: 1px solid #ecdcbb; border-radius: 8px; font-size: 0.85rem;
}
.bim-note-box strong { color: #7a5514; }

/* ---- provenance chips ---- */
.bim-src {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.68rem; letter-spacing: 0.02em;
  padding: 0.12rem 0.45rem; border-radius: 999px;
  border: 1px solid transparent; cursor: help; max-width: 100%;
}
.bim-src > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the table number is a locator, deliberately subordinate to the source */
.bim-src-at {
  font-size: 0.62rem; opacity: 0.72; padding-left: 0.3rem;
  border-left: 1px solid currentColor; white-space: nowrap; flex: none;
}
.bim-src-type { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.bim-src-loc  { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.bim-source-list { margin-top: 0.9rem; display: grid; gap: 0.9rem; }
.bim-source-group h5 { margin: 0 0 0.3rem; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); }
.bim-source-group p { margin: 0 0 0.3rem; font-size: 0.78rem; line-height: 1.5; }
.bim-source-group strong { color: var(--ink); }
.bim-source-group span { color: var(--muted); }
.bim-src-published  { background: #eaf1fa; color: #22548f; border-color: #cfe0f3; }
.bim-src-derived    { background: #eaf5f0; color: #1f6b50; border-color: #c9e6da; }
.bim-src-assumption { background: #fdf1e3; color: #8a5a12; border-color: #f0dcc0; }

/* ---- controls ---- */
.bim-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0.9rem 1.3rem; }
.bim-control label { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; font-size: 0.83rem; }
.bim-control-value { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--blue); }
.bim-control input[type="range"], .bim-share-row input[type="range"] { width: 100%; margin: 0.3rem 0 0.15rem; accent-color: var(--blue); }

/* ---- funnel ---- */
.bim-funnel { margin-top: 1.2rem; display: flex; flex-direction: column; gap: 0.15rem; }
.bim-fun-row {
  display: grid; grid-template-columns: 7.5rem 12rem 1fr 7rem;
  align-items: center; gap: 0.9rem;
  padding: 0.5rem 0.8rem; border-radius: 6px;
}
.bim-fun-row:nth-child(odd) { background: var(--soft); }
.bim-fun-start { background: #eef4fb !important; border-left: 3px solid var(--blue); }
.bim-fun-op { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bim-fun-gauge { min-width: 0; }
.bim-fun-track { height: 7px; background: #e3e9f0; border-radius: 4px; overflow: hidden; }
.bim-fun-fill { height: 100%; background: #2a78d6; border-radius: 4px; transition: width 90ms linear; }
.bim-fun-rate .bim-fun-fill { background: #1baf7a; }
.bim-fun-scale { display: flex; justify-content: space-between; font-size: 0.6rem; color: var(--muted); margin-top: 2px; }
.bim-fun-label { display: flex; flex-direction: column; min-width: 0; }
.bim-fun-name { font-size: 0.86rem; }
.bim-fun-note { font-size: 0.72rem; color: var(--muted); }
.bim-fun-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bim-fun-start .bim-fun-value { font-size: 1.05rem; }

/* ---- market share ---- */
.bim-share-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.1rem; }
.bim-share-col { background: var(--soft); border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem 0.9rem; }
.bim-share-head { margin: 0 0 0.1rem; font-size: 0.88rem; }
.bim-share-sub { margin: 0 0 0.35rem; font-size: 0.73rem; color: var(--muted); }
.bim-share-col > .bim-src {
  margin-bottom: 0.7rem;
  /* a narrow column must wrap this rather than clip it — the source is the point */
  align-items: flex-start; white-space: normal;
}
.bim-share-col > .bim-src > span:first-child { overflow: visible; white-space: normal; }
.bim-share-row { margin-bottom: 0.35rem; }
.bim-share-row label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; }
.bim-share-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bim-share-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.bim-swatch { width: 0.7rem; height: 0.7rem; border-radius: 3px; display: inline-block; flex: none; margin-right: 0.35rem; }
.bim-share-sum { margin-top: 0.6rem; font-size: 0.76rem; font-weight: 600; text-align: right; }
.bim-share-sum.ok { color: var(--green); }
.bim-share-sum.off { color: var(--red); }

/* ---- charts ---- */
.bim-chart { margin-top: 1.4rem; }
.bim-chart-title { margin: 0 0 0.2rem; font-size: 0.92rem; }
.bim-chart-sub { margin: 0 0 0.6rem; font-size: 0.8rem; color: var(--muted); }
.bim-svg { width: 100%; height: auto; display: block; overflow: visible; }
.bim-grid { stroke: var(--border); stroke-width: 1; }
.bim-zero { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 3; }
.bim-axis-label { font-size: 11px; fill: var(--muted); }
.bim-axis-sub { font-size: 10px; fill: var(--muted); }
.bim-tornado-label { font-size: 11.5px; fill: var(--ink); }
.bim-seg-label { font-size: 10.5px; font-weight: 600; pointer-events: none; }
.bim-net-line { stroke: #172033; stroke-width: 2.5; stroke-linecap: round; }
.bim-net-label { font-size: 11px; font-weight: 600; fill: #172033; font-variant-numeric: tabular-nums; }
.bim-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin-top: 0.6rem; font-size: 0.76rem; color: var(--muted); }
.bim-legend-item { display: inline-flex; align-items: center; }

/* ---- cards ---- */
.bim-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.8rem; margin-bottom: 1.2rem; }
.bim-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem 0.9rem; background: var(--soft); }
.bim-card.saving { border-left: 3px solid var(--green); }
.bim-card.impact { border-left: 3px solid var(--amber); }
.bim-card.total  { border-left: 3px solid var(--blue); background: #eef4fb; }
.bim-card-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.bim-card-value { font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; margin: 0.15rem 0; }
.bim-card-note { font-size: 0.75rem; color: var(--muted); }

/* ---- tables ---- */
.bim-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.bim-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; min-width: 640px; }
.bim-table th, .bim-table td { padding: 0.45rem 0.65rem; border-bottom: 1px solid var(--border); text-align: left; }
.bim-table th { background: var(--soft); font-weight: 600; font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.bim-table td.num, .bim-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bim-table td.strong { font-weight: 600; }
.bim-table tbody tr:last-child td { border-bottom: 0; }
.bim-table .impact-col { background: #fbfcfe; }
.bim-table td.pos { color: var(--green); }
.bim-table td.neg { color: var(--red); }
.bim-row-ven td { background: #fefaf2; }
.bim-row-total td { font-weight: 600; border-top: 2px solid var(--border); }
.bim-row-assumption td { background: #fdf9f3; }

/* ---- details ---- */
.bim-details { margin-top: 1rem; border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.9rem; }
.bim-details summary { cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--blue); }
.bim-build-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.9rem 1.2rem; margin-top: 0.9rem; }
.bim-build-item { min-width: 0; }
.bim-build-item h5 { margin: 0 0 0.3rem; font-size: 0.84rem; }
.bim-build-item code {
  display: block; font-size: 0.72rem; line-height: 1.45;
  background: var(--soft); padding: 0.45rem 0.55rem; border-radius: 6px; margin-bottom: 0.35rem;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.bim-build-item p { margin: 0; font-size: 0.78rem; color: var(--muted); }

/* ---- narrow screens ---- */
@media (max-width: 640px) {
  .bim-shell { font-size: 0.9rem; }
  .bim-topbar { position: static; flex-direction: column; align-items: flex-start; }
  .bim-panel { padding: 1rem 0.85rem; }
  .bim-share-grid { grid-template-columns: 1fr; }
  .bim-fun-row { grid-template-columns: 1fr auto; gap: 0.2rem 0.6rem; }
  .bim-fun-op { order: 1; }
  .bim-fun-value { order: 2; }
  .bim-fun-label { order: 3; }
  .bim-fun-gauge { order: 4; grid-column: 1 / -1; }
  .bim-headline strong { font-size: 1.15rem; }
}

/* ---- panel 3: efficacy, derivation, bridge ---- */
.bim-sub-title { margin: 1.6rem 0 0.4rem; font-size: 0.95rem; letter-spacing: -0.01em; }
.bim-sub-title:first-of-type { margin-top: 0.6rem; }
.bim-drives { font-size: 0.78rem; color: var(--muted); }
.bim-dir { font-size: 0.72rem; padding: 0.1rem 0.45rem; border-radius: 999px; white-space: nowrap; }
.bim-dir-up   { background: #fdeee6; color: #9c4318; }
.bim-dir-down { background: #e6f5ee; color: #14664a; }
.bim-dir-none { background: #eeeef1; color: #5f6b7a; }
.bim-row-unused td { background: #fafafb; color: var(--muted); font-style: italic; }
.bim-eff-dot, .bim-cal-dot {
  display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%;
  vertical-align: baseline;
}
.bim-eff-dot { background: #eda100; }
.bim-cal-dot { background: #4a3aa7; }

.bim-picker { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.7rem 0 1rem; }
.bim-pick-btn {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 0.3rem 0.75rem; font-size: 0.78rem;
  font-family: inherit; cursor: pointer;
}
.bim-pick-btn:hover { border-color: var(--blue); color: var(--blue); }
.bim-pick-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }

.bim-deriv { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 0.8rem; }
.bim-deriv-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.85rem; min-width: 0; }
.bim-deriv-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 0.4rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
.bim-deriv-name { font-size: 0.85rem; font-weight: 600; }
.bim-deriv-total { font-variant-numeric: tabular-nums; font-weight: 600; }
.bim-deriv-none { margin: 0; font-size: 0.76rem; color: var(--muted); font-style: italic; }
.bim-deriv-part { margin-bottom: 0.55rem; }
.bim-deriv-label { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.15rem; }

.bim-bridge-wrap { margin-top: 1.4rem; }
.bim-bridge-val { font-size: 11px; fill: var(--ink); font-variant-numeric: tabular-nums; }
.bim-bridge-cause { font-size: 9.5px; fill: var(--muted); font-style: italic; }
.bim-bridge-net-label { font-size: 12px; fill: var(--ink); font-weight: 700; }

@media (max-width: 640px) {
  .bim-deriv { grid-template-columns: 1fr; }
}

/* ---- derivation tables: one row per factor, provenance in full ---- */
.bim-deriv { grid-template-columns: 1fr; }
.bim-deriv-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem 0.95rem; }
.bim-deriv-part { margin-bottom: 0.9rem; }
.bim-deriv-part:last-child { margin-bottom: 0; }
.bim-deriv-label {
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.8rem;
  font-size: 0.76rem; font-weight: 600; color: var(--ink);
  margin-bottom: 0.25rem; padding-bottom: 0.2rem; border-bottom: 1px solid var(--border);
}
.bim-deriv-subtotal { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bim-deriv-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.bim-deriv-table td { padding: 0.22rem 0.4rem; border-bottom: 1px solid #eef1f5; vertical-align: baseline; }
.bim-deriv-table tr:last-child td { border-bottom: 0; }
.bim-deriv-table td.op   { width: 1.2rem; color: var(--muted); text-align: center; }
.bim-deriv-table td.fac  { color: var(--ink); }
.bim-deriv-table td.val  { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; width: 8rem; }
.bim-deriv-table td.val.strong { font-weight: 700; }
.bim-deriv-table td.prov { width: 46%; }
.bim-deriv-table tr.efficacy   { background: #fdfaf2; }
.bim-deriv-table tr.calibrated { background: #f6f4fc; }
.bim-kind {
  display: inline-block; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.05rem 0.35rem; border-radius: 3px; margin-right: 0.4rem; vertical-align: 1px;
}
.bim-kind-published { background: #eaf1fa; color: #22548f; }
.bim-kind-expert    { background: #eaf5f0; color: #14664a; }
.bim-kind-estimated { background: #f1eefb; color: #4a3aa7; }
.bim-kind-derived   { background: #f0f0f2; color: #55606e; }
.bim-prov-text { font-size: 0.7rem; color: var(--muted); }
@media (max-width: 720px) {
  .bim-deriv-table td.prov { display: block; width: auto; padding-left: 1.6rem; padding-top: 0; border: 0; }
  .bim-deriv-table td.val { width: auto; }
}

/* ---- model schematic ---- */
.bim-schematic { margin: 1.2rem 0 1.6rem; max-width: 900px; }
.bim-schematic svg { width: 100%; height: auto; display: block; }
.sch-f1 { fill: #e8a54a; }
.sch-f2 { fill: #f2c489; }
.sch-f3 { fill: #f8e0c2; }
.sch-box { stroke: #d9e0e8; stroke-width: 1; fill: #fff; }
.sch-now   { fill: #f6f8fb; }
.sch-new   { fill: #fdf6ec; stroke: #eccfa6; }
.sch-share { fill: #eaf5f0; stroke: #c9e6da; }
.sch-cost  { fill: #eef4fb; stroke: #cfe0f3; }
.sch-a { stroke: #8a93a0; stroke-width: 1.4; fill: none; }
.sch-h { font-size: 13px; font-weight: 600; fill: #172033; }
.sch-t { font-size: 12px; fill: #3d4855; }
.sch-em { font-weight: 600; fill: #8a5a12; }
.sch-cap { font-size: 11px; fill: #5f6b7a; font-style: italic; }
.sch-out { fill: #4a3aa7; }
.sch-out-t { font-size: 13.5px; font-weight: 600; fill: #ffffff; }
.sch-note { text-align: center; font-size: 0.78rem; color: #5f6b7a; margin: 0.5rem 0 0; }


.bim-seg-out { fill: #3d4855; }
.bim-seg-leader { stroke: #8a93a0; stroke-width: 1; }

.bim-pmpm-val { font-size: 10px; fill: #3d4855; font-variant-numeric: tabular-nums; }
.bim-pmpm-group { font-size: 11.5px; font-weight: 600; fill: #172033; }

/* ---- provenance hover card ---- */
.bim-tip {
  position: fixed; z-index: 999; pointer-events: none;
  background: #172033; color: #f2f5f9;
  font-size: 0.76rem; line-height: 1.45; white-space: pre-line;
  padding: 0.5rem 0.65rem; border-radius: 7px;
  box-shadow: 0 6px 20px rgba(23, 32, 51, 0.28);
  opacity: 0; transform: translateY(-2px); transition: opacity 80ms ease, transform 80ms ease;
}
.bim-tip.on { opacity: 1; transform: translateY(0); }
.bim-src { cursor: help; }
.bim-src:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) {
  .bim-tip { transition: none; transform: none; }
  .bim-tip.on { transform: none; }
}


.bim-pyr-sub { font-weight: 400 !important; font-size: 0.66rem !important; text-transform: none;
  letter-spacing: 0; font-style: italic; }
.bim-row-published td { color: var(--muted); border-bottom: 1.5px solid var(--border); }
