/* geoStrat — design tokens ------------------------------------------------ */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #16191f;
  --muted: #667085;
  --primary: #1B4FA0;
  --primary-ink: #ffffff;
  --primary-soft: #E6EDF8;
  --danger: #d92d20;
  --ok: #12805c;
  --radius: 10px;
  --radius-s: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-l: 0 12px 40px rgba(16, 24, 40, .18);
  --topbar: 56px;
  --panel: 380px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--text); background: var(--bg);
       -webkit-font-smoothing: antialiased; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
b { font-weight: 600; }
kbd { font: 12px var(--font); padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px;
      border-radius: 4px; background: var(--surface); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.gap { gap: 12px; } .gap-s { gap: 6px; }

/* brand ------------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; letter-spacing: -.01em; white-space: nowrap; }
.brand b { font-weight: 700; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px;
  background: conic-gradient(from 200deg, #1B4FA0, #00b5e2, #ff5605, #ed1b2e, #1B4FA0); }
.brand-lg { font-size: 28px; }
.brand-lg .brand-mark { width: 30px; height: 30px; border-radius: 8px; }

/* controls ---------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-s); border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-weight: 500; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .input:focus-visible, .select:focus-visible, .tab:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #1749cc; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; cursor: pointer;
  font-size: 16px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.input, .select { height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); width: 100%; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input.small, .select.small { height: 30px; font-size: 12.5px; width: auto; }
.select { appearance: none; padding-right: 28px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23667085' stroke-width='1.5' fill='none'/%3E%3C/svg%3E") no-repeat right 10px center; }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin: 18px 0 6px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0; }
.field { display: block; margin: 14px 0; }
.field span { display: block; font-weight: 500; margin-bottom: 6px; }
.grid-form .select { height: 42px; }
.field input { height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-s); width: 100%; }
.alert { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; padding: 10px 12px; border-radius: var(--radius-s); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; margin: 8px 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 32px; height: 18px; border-radius: 9px; background: #cfd4dc; position: relative; transition: .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch.small { font-size: 12.5px; margin: 0; }

.seg-control { display: flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 3px; margin-bottom: 8px; }
.seg-control button { flex: 1; height: 32px; border: 0; background: transparent; border-radius: 7px; cursor: pointer;
  font-weight: 500; color: var(--muted); }
.seg-control button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg-control.small button { height: 28px; font-size: 12.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 15px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; font-size: 12.5px; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip.on { border-color: var(--text); background: var(--text); color: #fff; }
.chips.small .chip { height: 26px; padding: 0 9px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
  margin: 16px 0; display: grid; gap: 8px; }
.card.subtle { background: var(--surface-2); border-color: transparent; }
.summary { margin-top: 12px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list li { border: 1px solid var(--border); border-radius: var(--radius-s); padding: 9px 10px; background: var(--surface);
  display: flex; align-items: center; gap: 8px; }
.list li .grow { flex: 1; min-width: 0; }
.list li .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.empty { color: var(--muted); font-size: 12.5px; padding: 8px 0; }

/* picker (searchable combobox) ---------------------------------------------- */
.picker { position: relative; }
.picker .input { padding-right: 30px; }
.picker-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 340px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-l); padding: 4px; }
.picker-item { padding: 7px 9px; border-radius: 6px; cursor: pointer; }
.picker-item:hover, .picker-item.hl { background: var(--primary-soft); }
.picker-item .path { display: block; color: var(--muted); font-size: 11.5px; }
.picker-item mark { background: #fff1a8; color: inherit; border-radius: 2px; }
.picker-selected { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: #1640b3;
  border-radius: 6px; padding: 2px 4px 2px 8px; font-size: 12px; }
.tag button { border: 0; background: none; cursor: pointer; color: inherit; padding: 0 3px; }

/* layout -------------------------------------------------------------------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar); z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 0 14px; padding-top: env(safe-area-inset-top, 0px); background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-controls { display: flex; gap: 8px; flex: 1; min-width: 0; }
.topbar-controls .select { max-width: 340px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.user-btn:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: #1640b3; display: grid;
  place-items: center; font-weight: 700; font-size: 13px; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-l); padding: 6px; z-index: 40; }
.menu-list button, .menu-list .menu-link { display: block; color: inherit; text-decoration: none; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px;
  border-radius: 6px; cursor: pointer; }
.menu-list button:hover, .menu-list .menu-link:hover { background: var(--surface-2); }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: grid; }
#panel-toggle { display: none; }

.layout { position: fixed; inset: var(--topbar) 0 0 0; display: flex; }
.panel { width: var(--panel); flex: none; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 10; }
.tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--border); }
.tab { flex: 1; height: 38px; border: 0; background: none; cursor: pointer; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.tab-body { padding: 14px 16px 24px; overflow: auto; flex: 1; }
.sheet-handle { display: none; }

.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; }
.legend { position: absolute; left: 12px; bottom: 28px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 12px; max-width: 300px; font-size: 12px; z-index: 5; }
.legend .title { font-weight: 600; margin-bottom: 6px; font-size: 12.5px; }
.legend .ramp { display: flex; height: 10px; border-radius: 3px; overflow: hidden; }
.legend .ramp span { flex: 1; }
.legend .ticks { display: flex; justify-content: space-between; color: var(--muted); margin-top: 3px; }
.legend .items { display: grid; grid-template-columns: repeat(2, auto); gap: 3px 12px; }
.legend .items span { display: flex; align-items: center; gap: 5px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend .bigrid { display: grid; grid-template-columns: 16px 128px; grid-template-rows: 128px auto; gap: 4px 6px;
  justify-content: start; margin: 4px 0 2px; }
.legend .bigrid .cells { display: grid; width: 128px; height: 128px; border-radius: 4px; overflow: hidden; }
.legend .bigrid .ylab { writing-mode: vertical-rl; transform: rotate(180deg); color: var(--muted); font-size: 11.5px;
  text-align: center; align-self: stretch; white-space: nowrap; }
.legend .bigrid .xlab { grid-column: 2; color: var(--muted); font-size: 11.5px; text-align: center; white-space: nowrap; }
.legend .na { display: flex; align-items: center; gap: 5px; margin-top: 6px; color: var(--muted); }
.loading { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: var(--surface);
  border-radius: 20px; padding: 6px 12px; box-shadow: var(--shadow); z-index: 6; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff;
  border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow-l); z-index: 50; max-width: 90%; }
.map-tip { font: 12.5px var(--font); line-height: 1.4; }
.map-tip b { display: block; }
.mapboxgl-popup-content, .maplibregl-popup-content { border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow); }

/* detail drawer ------------------------------------------------------------- */
.drawer { position: absolute; top: calc(var(--topbar) + 12px); right: 12px; bottom: 12px; width: 360px; z-index: 15;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-l); overflow: auto; padding: 16px; }
.drawer-close { position: absolute; top: 8px; right: 8px; }
.drawer h3 { margin: 0 32px 2px 0; font-size: 17px; }
.drawer h4 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.kv span:nth-child(even) { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-row { display: grid; grid-template-columns: 1fr 52px; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.bar-row .name { display: flex; justify-content: space-between; gap: 8px; }
.bar-row .track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: -2px; }
.bar-row .fill { height: 100%; }
.bar-row .pct { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.badge.warn { background: #fff4e5; color: #9a5b00; }

/* workspace (correlations) -------------------------------------------------- */
.workspace { position: absolute; left: var(--panel); right: 0; bottom: 0; height: min(62vh, 640px); z-index: 12;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -8px 30px rgba(16,24,40,.12);
  display: flex; flex-direction: column; }
.workspace.full { left: 0; top: 0; height: 100%; z-index: 30; border-top: 0; box-shadow: none; }
.workspace.full .ws-body { padding-bottom: 16px; }
.workspace.full .scatter-card { width: 440px; }
.workspace.full #scatter { height: auto; flex: 1; min-height: 300px; }
#ws-full[aria-pressed="true"] { background: var(--primary-soft); color: #1640b3; }
.ws-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px 6px; flex-wrap: wrap; }
.ws-head h2 { margin: 0; font-size: 16px; }
.ws-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#ws-topics { padding: 0 14px 8px; }
.access-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: #fff8e6; border-top: 1px solid #f5e1a4; flex-wrap: wrap; }
.ws-body { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 0 14px 12px; }
#corr-table { flex: 1; min-width: 0; }
.scatter-card { width: 380px; flex: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; gap: 8px; overflow: auto; }
#scatter { width: 100%; height: 260px; }
.rcell { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.rcell .rb { height: 8px; border-radius: 2px; }
.topic-tag { color: var(--muted); font-size: 11px; display: block; }

/* Tabulator theming */
.tabulator { border: 1px solid var(--border); border-radius: var(--radius); font-size: 12.5px; background: var(--surface); }
.tabulator .tabulator-header { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tabulator .tabulator-header .tabulator-col { background: transparent; }
.tabulator-row { border-bottom: 1px solid #f0f2f5; }
.tabulator-row.tabulator-selectable:hover { background: var(--primary-soft); cursor: pointer; }
.tabulator-row.tabulator-selected { background: #dbe6ff; }

/* modal --------------------------------------------------------------------- */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(900px, 94vw); max-height: 88vh; box-shadow: var(--shadow-l); }
.modal::backdrop { background: rgba(16, 24, 40, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 20px 20px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; align-items: end; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
  padding: 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 8px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.table .select, .table .input { height: 30px; }
.secret { font-family: ui-monospace, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; user-select: all; }

/* login ---------------------------------------------------------------------- */
.login-page { display: grid; place-items: center; overflow: auto;
  background: radial-gradient(1200px 600px at 10% -10%, #e2eaff, transparent), radial-gradient(900px 500px at 110% 110%, #ffe9dc, transparent), var(--bg); }
.login-card { width: min(400px, 92vw); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-l); padding: 32px 28px; }
.login-card .muted { margin: 8px 0 18px; }

/* responsive: tablet & phone ----------------------------------------------- */
@media (max-width: 1100px) {
  :root { --panel: 340px; }
  .scatter-card { width: 320px; }
  .user-name { display: none; }
}
@media (max-width: 800px) {
  :root { --topbar: 52px; }
  .topbar { gap: 8px; padding: 0 8px; }
  .brand { font-size: 0; gap: 0; }
  .topbar-controls .select { font-size: 13px; padding: 0 22px 0 8px; background-position: right 7px center; }
  .ws-head { padding: 8px 10px 4px; }
  .ws-body { padding: 0 8px 8px; }
  #ws-topics { padding: 0 10px 6px; flex-wrap: nowrap; overflow-x: auto; }
  .legend { font-size: 11px; padding: 8px 10px; }
  #panel-toggle { display: inline-flex; }
  .layout { display: block; }
  .map-wrap { position: absolute; inset: 0; }
  /* panel becomes a bottom sheet with three heights */
  .panel { position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet-h, 42%);
    border-radius: 16px 16px 0 0; border: 0; box-shadow: 0 -8px 30px rgba(16,24,40,.18); transition: height .22s ease; }
  .panel.dragging { transition: none; }
  .panel.collapsed { --sheet-h: 104px; }
  .panel.expanded { --sheet-h: calc(100% - 12px); }
  .sheet-handle { display: block; height: 20px; flex: none; cursor: grab; touch-action: none; position: relative; }
  .sheet-handle::after { content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 4px; border-radius: 2px;
    background: #cfd4dc; transform: translateX(-50%); }
  .tabs { padding-top: 0; }
  .legend { bottom: calc(var(--sheet-h, 42%) + 12px); left: 8px; max-width: 70%; }
  .panel.collapsed ~ .map-wrap .legend { bottom: 116px; }
  .drawer { inset: auto 0 0 0; width: auto; top: auto; max-height: 75%; border-radius: 16px 16px 0 0; z-index: 25; }
  .workspace { left: 0; top: 0; height: 100%; z-index: 26; }
  .ws-body { flex-direction: column; overflow: auto; }
  #corr-table { min-height: 60%; }
  .scatter-card { width: auto; }
  .ws-tools .input { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

input[type=range] { width: 100%; accent-color: var(--primary); cursor: pointer; }

/* gap to trend */
.gap-head { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; }
.gap-head .dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; flex: none; }
.gap-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; background: #fdecea;
  border-radius: var(--radius-s); padding: 10px 12px; }
.gap-total b { font-size: 18px; color: #b2182b; white-space: nowrap; }
.gap-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; max-height: 320px; overflow: auto; }
.gap-list button { width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-s); padding: 7px 9px; cursor: pointer; display: grid; gap: 2px; font-size: 12.5px; }
.gap-list button:hover { border-color: var(--primary); background: var(--primary-soft); }
.gap-num { font-variant-numeric: tabular-nums; }

/* synthetic population query builder */
.synth-cond { border: 1px solid var(--border); border-radius: var(--radius-s); padding: 8px; margin-bottom: 8px; display: grid; gap: 6px; background: var(--surface); }
.synth-cond .head { display: flex; gap: 6px; align-items: center; }
.synth-cond .head .picker { flex: 1; }
.synth-vals { display: flex; flex-wrap: wrap; gap: 4px; max-height: 180px; overflow: auto; }
.synth-vals label { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); border-radius: 14px;
  padding: 3px 9px; font-size: 12px; cursor: pointer; background: var(--surface); }
.synth-vals input { margin: 0; accent-color: var(--primary); }
.synth-vals label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.synth-range { display: flex; gap: 6px; align-items: center; font-size: 12.5px; }
.synth-range .input { width: 110px; }
.synth-total { background: var(--primary-soft); border-radius: var(--radius-s); padding: 10px 12px; margin: 12px 0 6px; }
.synth-total b { font-size: 18px; }
.assoc-row { display: grid; grid-template-columns: 70px 1fr 64px; align-items: center; gap: 8px; font-size: 12.5px; margin: 3px 0; }
.assoc-row .bar { height: 8px; border-radius: 2px; }

.evo-total { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; background: var(--surface-2); border-radius: var(--radius-s);
  padding: 10px 12px; margin-top: 12px; font-size: 13px; }
.evo-total b { font-variant-numeric: tabular-nums; text-align: right; }
.evo-total .big { font-size: 17px; }

.model-row { border-top: 1px solid var(--border); padding: 8px 0; display: grid; gap: 4px; }
.model-row .head { display: grid; grid-template-columns: 1fr 96px auto; gap: 8px; align-items: center; }
.model-row .r2 { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.model-row .r2 span { display: block; height: 100%; }
.model-row .drivers { font-size: 12px; color: var(--muted); line-height: 1.35; }
.model-row .drivers b { color: var(--text); font-weight: 500; }

/* groups (ecological inference) */
.tabs .tab { font-size: 13px; }
.ei-group { border-top: 1px solid var(--border); padding: 10px 0; display: grid; gap: 5px; }
.ei-group .head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.ei-stack { display: flex; height: 16px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.ei-stack span { height: 100%; }
.ei-turnout { display: grid; grid-template-columns: 82px 1fr 92px; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.ei-turnout .track { height: 6px; background: var(--surface-2); border-radius: 3px; position: relative; }
.ei-turnout .fill { height: 100%; background: #5b3cc4; border-radius: 3px; }
.ei-turnout .ci { position: absolute; top: -3px; height: 12px; border-left: 1.5px solid #1d2433; border-right: 1.5px solid #1d2433; opacity: .5; }
.ei-top { font-size: 12px; color: var(--muted); }
.ei-top b { color: var(--text); font-weight: 600; }
.ei-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; margin: 8px 0; }
.ei-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.ei-table { font-size: 11.5px; }
.ei-table td, .ei-table th { padding: 4px 5px; }
@media (max-width: 1100px) { .tabs .tab { font-size: 12px; } }

/* flux (vote transfers) ------------------------------------------------------- */
.flux-ws { height: min(56vh, 640px); }
.fx-body { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr); gap: 14px 22px;
  padding: 6px 14px 16px; overflow: auto; height: calc(100% - 58px); }
.fx-main { min-width: 0; }
.fx-read { margin: 2px 0 8px; }
.fx-big { font-size: 15px; line-height: 1.5; }
.fx-big .n { font-size: 22px; }
.fx-big .dot, .fx-summary i, .fx-matrix i, .fx-curve .lab i { display: inline-block; width: 10px; height: 10px;
  border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--border); }
.fx-svg { width: 100%; height: auto; display: block; }
.fx-svg text { fill: var(--text); font-family: var(--font); }
.fx-svg text .muted, .fx-svg .muted { fill: var(--muted); }
.fx-band { cursor: pointer; transition: opacity .12s; }
.fx-band:hover { opacity: .75 !important; }
.fx-node { cursor: pointer; }
.fx-side { min-width: 0; }
.fx-curve { display: grid; grid-template-columns: 104px 1fr 64px; gap: 8px; align-items: center; padding: 4px 6px;
  border-radius: 8px; cursor: pointer; }
.fx-curve:hover, .fx-curve.on { background: var(--surface-2); }
.fx-curve svg { width: 100%; height: 46px; display: block; }
.fx-curve svg text { fill: var(--muted); font-family: var(--font); }
.fx-curve .lab { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-curve .val { text-align: right; line-height: 1.15; font-size: 12.5px; }
.fx-curve .val b { display: block; font-size: 15px; }
.fx-table { grid-column: 1 / -1; overflow-x: auto; }
.fx-matrix { font-size: 12.5px; }
.fx-matrix th, .fx-matrix td { padding: 5px 8px; white-space: nowrap; }
.fx-matrix td { cursor: pointer; border-radius: 4px; }
.fx-matrix td:hover, .fx-matrix td.on { background: var(--primary-soft); }
.fx-matrix td.weak { color: var(--muted); opacity: .6; }
.fx-matrix .sv { font-size: 11px; color: var(--muted); }
.fx-notes { grid-column: 1 / -1; }
.fx-summary .fx-line { display: flex; gap: 4px; padding: 6px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
  font-size: 13px; line-height: 1.4; }
.fx-summary .fx-line:hover { background: var(--surface-2); }
.fx-summary .fx-line i { flex: none; margin-top: 4px; }
@media (max-width: 900px) { .fx-body { grid-template-columns: minmax(0, 1fr); } }
.fx-who { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 12px; }
.who-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.who-head h3 { margin: 0; font-size: 18px; }
.who-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; margin-top: 8px; }
.who-grid h4 { margin: 10px 0 6px; font-size: 14px; }
.who-grid p { font-size: 13px; margin: 0 0 8px; }
.who-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.who-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.who-row { display: grid; grid-template-columns: 150px 1fr; gap: 8px; align-items: center; padding: 3px 0; font-size: 12.5px; }
.who-row .bars { display: grid; grid-template-columns: 1fr 38px; row-gap: 2px; align-items: center; }
.who-row .b { display: block; height: 8px; border-radius: 3px; }
.who-row .b.lo { background: var(--ink-soft, #98a2b3); }
.who-row .v { text-align: right; font-variant-numeric: tabular-nums; }
.who-card { border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 8px; cursor: pointer; }
.who-card:hover, .who-card.on { background: var(--surface-2); }
.who-card-head { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; }
.who-card-head .sw { flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.who-regions { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 4px; }
.who-traits { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
.who-traits .up::before { content: "▲ "; color: var(--ok); }
.who-traits .down::before { content: "▼ "; color: var(--danger); }
.who-traits em { color: var(--muted); font-style: normal; }
.who-survey { font-size: 12.5px; margin-top: 4px; }
@media (max-width: 900px) { .who-grid { grid-template-columns: minmax(0, 1fr); } }

/* fiche (section / riding profile) ------------------------------------------- */
.fiche-ws { height: min(74vh, 780px); }
.fi-body { overflow: auto; height: calc(100% - 58px); padding: 4px 14px 18px; }
.fi-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 24px; }
.fi-block { margin-bottom: 14px; }
.fi-block h3 { font-size: 14.5px; margin: 6px 0 8px; }
.fi-list { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.5; }
.fi-list li { margin: 3px 0; }
.fi-trait { display: grid; grid-template-columns: 150px 1fr 88px 150px; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.fi-trait .bar { position: relative; height: 10px; background: var(--surface-2); border-radius: 5px; }
.fi-trait .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); opacity: .75; border-radius: 5px; }
.fi-trait .bar em { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }
.fi-trait .bar em.r { background: #00a3cc; }
.fi-trait .val { text-align: right; font-variant-numeric: tabular-nums; }
.fi-trait .pct { font-size: 11.5px; }
.fi-level { margin-bottom: 10px; }
.fi-level-h { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 0 4px; }
.fi-el { display: grid; grid-template-columns: 52px 1fr 130px 40px; gap: 8px; align-items: center; font-size: 12.5px; padding: 2px 0; }
.fi-el.cur { font-weight: 600; }
.fi-el .stack { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.fi-el .stack i { display: block; height: 100%; }
.fi-el .to { text-align: right; }
.fi-trends, .fi-sim { font-size: 12.5px; }
.fi-trends td.up, .fi-cmp .up { color: var(--ok); font-weight: 600; }
.fi-trends td.down, .fi-cmp .down { color: var(--danger); font-weight: 600; }
.fi-cmps { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 4px 12px; margin: 6px 0 8px; }
.fi-cmp { display: grid; grid-template-columns: 44px 1fr 34px; gap: 6px; font-size: 12.5px; }
.fi-cmp span:last-child { text-align: right; }
.fi-sim tr[data-sim] { cursor: pointer; }
.fi-sim tr[data-sim]:hover { background: var(--surface-2); }
@media (max-width: 900px) { .fi-grid { grid-template-columns: minmax(0, 1fr); } .fi-trait { grid-template-columns: 110px 1fr 80px; } .fi-trait .pct { display: none; } }
.fi-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.fi-tile { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 1px; }
.fi-tile .l { font-size: 11.5px; color: var(--muted); }
.fi-tile b { font-size: 20px; font-variant-numeric: tabular-nums; }
.fi-tile .muted { font-size: 11.5px; }
.fi-tile.hi { border-left: 3px solid var(--ok); }
.fi-tile.lo { border-left: 3px solid var(--danger); }

/* public explorer ------------------------------------------------------------ */
a.brand { color: inherit; text-decoration: none; }
.public-nav { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.public-nav a { color: var(--text); text-decoration: none; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.public-nav a:hover { background: var(--surface-2); }
.public-nav .login-link { border: 1px solid var(--border); }
body.public #evo-why { display: none !important; }        /* leads to the correlations tab (logged-in only) */
@media (max-width: 760px) { .public-nav a:not(.login-link) { display: none; } }
.fx-who-sum { margin: 2px 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft, var(--surface-2)); font-size: 13.5px; line-height: 1.7; }
.fx-who-sum:empty { display: none; }
.fx-who-sum .chip { margin: 0 2px; }
/* while the flux workspace covers the bottom of the map, the legend goes to the top */
body:has(#flux-ws:not([hidden])) .legend { top: 12px; bottom: auto; }

/* census quick picks (themes of the original app) */
.quick { margin: 10px 0 4px; }
.quick-themes { display: flex; flex-wrap: wrap; gap: 5px; }
.quick-themes .chip { font-size: 12.5px; padding: 4px 10px; }
.quick-list { margin-top: 8px; max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.quick-group { font-size: 11px; font-weight: 700; color: var(--muted); padding: 8px 8px 3px; line-height: 1.3; }
.quick-item { display: block; width: 100%; text-align: left; font: inherit; font-size: 13px; padding: 5px 8px; border: 0; border-radius: 6px;
  background: none; color: var(--text); cursor: pointer; }
.quick-item:hover { background: var(--surface-2); }
.quick-item.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
