:root {
  --ink: #1b2233;
  --paper: #f7f8f5;
  --surface: #ffffff;
  --slate: #121a26;
  --emerald: #0e9f6e;
  --emerald-dark: #087a55;
  --copper: #c2703d;
  --line: rgba(27, 34, 51, 0.14);
  --muted: rgba(27, 34, 51, 0.62);
  --danger: #9a3f30;
  --shadow: 0 18px 55px rgba(18, 26, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }
[hidden] { display: none !important; }

.eyebrow { margin: 0 0 8px; font: 600 0.72rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.button { min-height: 42px; border: 1px solid var(--line); border-radius: 5px; padding: 0 17px; background: var(--surface); font-weight: 650; cursor: pointer; transition: background 150ms ease, border-color 150ms ease, color 150ms ease; }
.button:hover { border-color: rgba(27, 34, 51, 0.34); }
.button:disabled { cursor: wait; opacity: 0.58; }
.button-primary { border-color: var(--emerald); background: var(--emerald); color: white; }
.button-primary:hover { background: var(--emerald-dark); border-color: var(--emerald-dark); }
.button-quiet { background: transparent; }
.button-full { width: 100%; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 5px; background: transparent; font-size: 1.45rem; cursor: pointer; }

.oep-symbol { display: block; flex: 0 0 auto; color: var(--ink); }
.oep-symbol-header { width: 29px; height: 29px; }
.oep-symbol-login { width: 58px; height: 58px; }
.oep-lockup, .login-lockup { display: flex; align-items: center; gap: 12px; }
.oep-wordmark { display: flex; flex-direction: column; line-height: 1; }
.oep-wordmark strong { font-size: 1.08rem; letter-spacing: -.035em; }
.oep-wordmark small { margin-top: 4px; color: var(--muted); font-size: .51rem; font-weight: 650; letter-spacing: .17em; text-transform: uppercase; white-space: nowrap; }
.brand-divider { width: 1px; height: 24px; background: rgba(27,34,51,.23); }
.product-lockup { display: flex; flex-direction: column; line-height: 1; }
.product-lockup strong { font-size: .91rem; letter-spacing: -.02em; }
.product-lockup small { margin-top: 4px; color: var(--muted); font: 600 .55rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; text-transform: uppercase; }

.login-body { display: grid; place-items: center; padding: 24px; background: var(--paper); }
.login-body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .7; background-image: linear-gradient(rgba(27,34,51,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(27,34,51,.035) 1px, transparent 1px); background-size: 48px 48px; }
.login-shell { position: relative; width: min(100%, 480px); }
.login-panel { padding: clamp(30px, 7vw, 52px); background: rgba(255,255,255,.95); border: 1px solid var(--line); border-top: 3px solid var(--ink); box-shadow: 0 24px 80px rgba(18,26,38,.12); }
.login-lockup { margin-bottom: 48px; }
.login-panel h1 { margin: 0; font-size: clamp(2.2rem, 8vw, 3.65rem); line-height: 0.95; letter-spacing: -0.055em; }
.login-copy { max-width: 34ch; margin: 18px 0 34px; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.login-form label { display: block; margin-bottom: 9px; font-size: 0.88rem; font-weight: 650; }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.login-form input[type="email"], .password-row input { width: 100%; min-width: 0; height: 46px; border: 1px solid var(--line); border-radius: 5px; padding: 0 13px; background: white; font-size: 1rem; }
.form-error { min-height: 22px; margin: 8px 0; color: var(--danger); font-size: 0.84rem; line-height: 1.4; }
.login-hint { margin: 6px 0 18px; color: var(--muted); font-size: 0.78rem; line-height: 1.4; }
.login-note { margin: 24px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }

.app-header { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 9px 28px; border-bottom: 1px solid var(--line); background: rgba(247,248,245,.96); backdrop-filter: blur(14px); }
.header-brand { display: flex; align-items: center; gap: 13px; }
.header-actions { display: flex; align-items: center; gap: 18px; }
.snapshot-date { color: var(--muted); font: 0.74rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.app-layout { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: calc(100vh - 58px); }
.side-nav { position: sticky; top: 58px; align-self: start; height: calc(100vh - 58px); padding: 27px 16px; border-right: 1px solid var(--line); background: #f1f3ef; overflow-y: auto; }
.nav-label { margin: 0 10px 10px; color: var(--muted); font: 600 0.8rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; }
.nav-label-secondary { margin-top: 30px; }
.nav-item { display: grid; grid-template-columns: 25px 1fr; gap: 7px; width: 100%; min-height: 44px; margin: 2px 0; padding: 10px; border: 0; border-radius: 5px; background: transparent; text-align: left; font-size: 0.86rem; line-height: 1.3; cursor: pointer; }
.nav-item span { color: var(--muted); font: 0.69rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.nav-item:hover { background: rgba(27,34,51,.055); }
.nav-item.is-active { background: var(--ink); color: white; }
.nav-item.is-active span { color: #82e0bd; }
.side-note { margin: 32px 10px 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.75rem; line-height: 1.5; }
.workspace { min-width: 0; padding: clamp(25px, 4vw, 58px); }
.workspace-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; max-width: 1220px; margin: 0 auto 34px; }
.workspace-heading h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.7rem); line-height: 0.98; letter-spacing: -0.055em; }
.workspace-heading > div > p:last-child { max-width: 760px; margin: 15px 0 0; color: var(--muted); font-size: 1rem; line-height: 1.55; }

.builder, .result-panel, .quality-banner, .source-list, .notes-grid, .summary-grid { max-width: 1220px; margin-left: auto; margin-right: auto; }
.builder { margin-bottom: 26px; padding: clamp(20px, 3vw, 34px); border: 1px solid var(--line); border-top: 3px solid var(--emerald); background: var(--surface); box-shadow: var(--shadow); }
.builder-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.builder h2, .result-panel h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.035em; }
.control-grid { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: 15px; }
.control-grid label, .control-label { color: var(--muted); font-size: 0.78rem; font-weight: 650; }
.control-label { display: block; }
.control-grid input, .control-grid select { display: block; width: 100%; min-height: 42px; margin-top: 7px; border: 1px solid var(--line); border-radius: 4px; padding: 9px 10px; background: var(--paper); color: var(--ink); }
.control-grid select[multiple] { min-height: 132px; }
.control-help { display: block; margin-top: 5px; color: var(--muted); font-size: 0.7rem; font-weight: 400; }
.region-picker { position: relative; margin-top: 7px; }
.region-picker-trigger { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); text-align: left; cursor: pointer; }
.region-picker-trigger:hover, .region-picker-trigger[aria-expanded="true"] { border-color: rgba(27,34,51,.48); background: white; }
.picker-chevron { color: var(--muted); font-size: 1rem; transition: transform 150ms ease; }
.region-picker-trigger[aria-expanded="true"] .picker-chevron { transform: rotate(180deg); }
.region-picker-panel { position: absolute; z-index: 40; top: calc(100% + 7px); left: 0; width: min(390px, calc(100vw - 46px)); padding: 14px; border: 1px solid var(--ink); background: var(--surface); box-shadow: 0 20px 50px rgba(18,26,38,.18); }
.region-picker-head label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .68rem; letter-spacing: .07em; text-transform: uppercase; }
.region-picker-head input { margin: 0; background: var(--surface); }
.region-picker-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0 9px; border-bottom: 1px solid var(--line); }
.region-picker-actions button { padding: 0; border: 0; background: transparent; color: var(--emerald-dark); font-size: .73rem; font-weight: 700; cursor: pointer; }
.region-picker-actions span { color: var(--muted); font: .66rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.region-options { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; max-height: 265px; padding: 10px 0; overflow-y: auto; }
.region-option { display: flex !important; align-items: flex-start; gap: 8px; min-width: 0; padding: 8px 7px; border-radius: 3px; color: var(--ink) !important; font-size: .75rem !important; font-weight: 520 !important; line-height: 1.25; cursor: pointer; }
.region-option:hover { background: #f1f3ef; }
.region-option input { flex: 0 0 auto; width: 15px !important; min-height: 15px !important; height: 15px; margin: 0 !important; padding: 0 !important; accent-color: var(--emerald); }
.region-option span { min-width: 0; }
.region-picker-footer { display: flex; justify-content: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.region-picker-footer .button { min-height: 36px; }
.indicator-fieldset, .view-fieldset { margin: 25px 0 0; padding: 0; border: 0; }
.indicator-fieldset legend, .view-fieldset legend { margin-bottom: 10px; font-size: 0.82rem; font-weight: 700; }
.indicator-fieldset legend span { margin-left: 8px; color: var(--muted); font-weight: 400; }
.indicator-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.indicator-option { display: flex; align-items: flex-start; gap: 9px; min-height: 48px; padding: 11px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); font-size: 0.8rem; line-height: 1.35; }
.indicator-option input { margin-top: 2px; accent-color: var(--emerald); }
.indicator-option small { display: block; margin-top: 3px; color: var(--muted); font-size: .69rem; font-weight: 400; }
.indicator-option.is-disabled { opacity: .46; }
.cross-label { margin: 18px 0 10px; font-size: 0.82rem; font-weight: 700; }
.cross-label span { margin-left: 8px; color: var(--muted); font-weight: 400; }
.cross-groups details { margin-top: 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }
.cross-groups summary { padding: 10px 12px; font-size: 0.8rem; font-weight: 650; cursor: pointer; }
.cross-groups summary small { margin-left: 6px; color: var(--muted); font-weight: 400; }
.cross-groups .indicator-options { padding: 0 10px 10px; }
.per-capita-toggle { align-self: end; font-size: 0.8rem; }
.control-grid .per-capita-toggle input { display: inline-block; width: auto; min-height: 0; margin: 0 6px 0 0; padding: 0; vertical-align: -2px; accent-color: var(--emerald); }
.per-capita-toggle > span:first-child { color: var(--ink); }
#countries { width: 100%; }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: grid; place-items: center; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); font-size: 0.78rem; font-weight: 650; cursor: pointer; }
.segmented input:checked + span { border-color: var(--ink); background: var(--ink); color: white; }
.segmented input:focus-visible + span { outline: 2px solid var(--emerald); outline-offset: 2px; }
.segmented label.is-disabled span { opacity: .4; cursor: not-allowed; }
.builder-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.builder-actions .form-error { margin: 0; }
.quality-banner-below { margin-top: 20px; }
.quality-banner { margin-bottom: 20px; padding: 14px 17px; border-left: 3px solid var(--copper); background: #fff5ee; color: #6f4229; font-size: .82rem; line-height: 1.45; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 20px; border: 1px solid var(--line); background: var(--surface); }
.summary-card { min-height: 122px; padding: 21px; border-right: 1px solid var(--line); }
.summary-card:last-child { border-right: 0; }
.summary-card span { display: block; color: var(--muted); font-size: .72rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.summary-card strong { display: block; margin-top: 12px; font-size: clamp(1.7rem, 3vw, 2.55rem); line-height: 1; letter-spacing: -.03em; }
.summary-card small { display: block; margin-top: 8px; color: var(--muted); font-size: .74rem; }
.result-panel { padding: clamp(20px, 3vw, 34px); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; max-width: 50%; color: var(--muted); font-size: .72rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; }
.loading-state, .empty-state { min-height: 310px; display: grid; place-items: center; padding: 28px; color: var(--muted); text-align: center; line-height: 1.55; }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--ink); font-size: 1.1rem; }
.chart { min-height: 340px; overflow-x: auto; }
.chart-panel + .chart-panel { margin-top: 36px; padding-top: 26px; border-top: 1px solid var(--line); }
.bar-chart { display: grid; gap: 11px; min-width: 650px; }
.bar-row { display: grid; grid-template-columns: 190px minmax(260px, 1fr) 90px; align-items: center; gap: 12px; }
.bar-label { overflow: hidden; color: var(--muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; height: 24px; background: #edf0ec; }
.bar-fill { height: 100%; min-width: 1px; background: var(--emerald); }
.bar-value { text-align: right; font: .75rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.series-svg, .scatter-svg { display: block; width: 100%; min-width: 680px; height: 360px; overflow: visible; }
.axis-line { stroke: rgba(27,34,51,.18); stroke-width: 1; }
.grid-line { stroke: rgba(27,34,51,.08); stroke-width: 1; }
.series-label { fill: rgba(27,34,51,.62); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.map-grid { display: grid; grid-template-columns: repeat(5, minmax(115px, 1fr)); gap: 8px; max-width: 860px; margin: 0 auto; }
.map-cell { min-height: 72px; display: flex; flex-direction: column; justify-content: space-between; padding: 11px; border: 1px solid rgba(27,34,51,.08); border-radius: 4px; color: #10221c; }
.map-cell strong { font-size: .76rem; }
.map-cell span { font: .73rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .79rem; }
.data-table th { padding: 11px 10px; border-bottom: 2px solid var(--ink); text-align: right; white-space: nowrap; }
.data-table th:first-child { text-align: left; }
.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.data-table td:first-child { text-align: left; font-weight: 600; }
.source-line { margin: 24px 0 0; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font: .7rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.notes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 18px; }
.note-card { padding: 18px; border: 1px solid var(--line); background: transparent; }
.note-card strong { display: block; margin-bottom: 7px; font-size: .82rem; }
.note-card p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.source-status-legend { display: flex; flex-wrap: wrap; gap: 20px; max-width: 1220px; margin: -13px auto 22px; color: var(--muted); font-size: .78rem; }
.source-status-legend span { display: inline-flex; align-items: center; gap: 7px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-active { background: var(--emerald); }.dot-catalogued { background: #d39a31; }.dot-pending { background: var(--copper); }
.source-list { border-top: 1px solid var(--ink); }
.source-item { display: grid; grid-template-columns: 1.1fr .7fr .65fr 1.3fr; gap: 20px; padding: 19px 0; border-bottom: 1px solid var(--line); }
.source-item h2 { margin: 0 0 5px; font-size: .92rem; }
.source-item a:hover { color: var(--emerald-dark); }
.source-item p, .source-item dd { margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.source-item dt { margin-bottom: 5px; font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.source-state { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.source-identity { display: grid; grid-template-columns: 46px 1fr; align-items: start; gap: 12px; }
.source-mark, .institution-mark { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border: 1px solid rgba(27,34,51,.3); background: transparent; color: var(--ink); font: 750 .62rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.02em; text-align: center; }
.source-mark[data-tone="emerald"], .institution-mark { border-color: rgba(14,159,110,.48); color: var(--emerald-dark); }
.source-mark[data-tone="copper"] { border-color: rgba(194,112,61,.55); color: #9a512a; }

.judicial-roadmap { max-width: 1220px; margin: 18px auto 0; padding: clamp(20px, 3vw, 34px); border: 1px solid var(--line); border-top: 3px solid var(--ink); background: var(--surface); }
.roadmap-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.roadmap-heading h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.035em; }
.research-stamp { color: var(--muted); font: .68rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
.judicial-source-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); border-top: 1px solid var(--ink); }
.judicial-source-grid article { display: flex; gap: 14px; min-height: 162px; padding: 20px 18px 20px 0; border-bottom: 1px solid var(--line); }
.judicial-source-grid article:nth-child(odd) { padding-right: 24px; border-right: 1px solid var(--line); }
.judicial-source-grid article:nth-child(even) { padding-left: 24px; }
.judicial-source-grid strong { display: block; margin: 1px 0 7px; font-size: .88rem; }
.judicial-source-grid p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.judicial-source-grid button { margin-top: 10px; }
.module-sources { margin-top: 18px; border-top: 1px solid var(--ink); }
.module-sources h3 { margin: 16px 0 4px; font-size: .9rem; }
.module-sources > p { margin: 0 0 6px; color: var(--muted); font-size: .78rem; }
.module-source { padding: 10px 0; border-bottom: 1px solid var(--line); }
.module-source strong { display: block; margin-bottom: 6px; font-size: .8rem; }
.module-source-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 4px 0; font-size: .78rem; }
.module-source-row small { color: var(--emerald-dark); font: 600 .68rem ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.module-source-row p { margin: 2px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.45; }
@media (max-width: 640px) { .module-source-row { grid-template-columns: 1fr auto; } .module-source-row button { grid-column: 1 / -1; justify-self: start; } }
.judicial-source-grid small { display: block; margin-top: 10px; color: var(--emerald-dark); font: 600 .65rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.verification-rule { display: grid; grid-template-columns: 160px 1fr; gap: 22px; margin-top: 22px; padding: 17px 0 0; border-top: 1px solid var(--ink); }
.verification-rule strong { font-size: .77rem; letter-spacing: .04em; text-transform: uppercase; }
.verification-rule span { color: var(--muted); font-size: .78rem; line-height: 1.55; }

@media (max-width: 980px) {
  .app-layout { grid-template-columns: 1fr; }
  .side-nav { position: static; display: flex; height: auto; padding: 9px 14px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .nav-label, .side-note { display: none; }
  .nav-item { flex: 0 0 auto; width: auto; grid-template-columns: 22px auto; }
  .control-grid { grid-template-columns: repeat(2, 1fr); }
  .indicator-options { grid-template-columns: repeat(2, 1fr); }
  .source-item { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .app-header { padding: 11px 15px; }
  .header-actions { gap: 8px; }
  .snapshot-date { display: none; }
  .workspace { padding: 25px 15px 44px; }
  .workspace-heading { align-items: flex-start; flex-direction: column; gap: 18px; }
  .workspace-heading .button { width: 100%; }
  .control-grid, .indicator-options, .summary-grid, .notes-grid, .source-item { grid-template-columns: 1fr; }
  .summary-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-card:last-child { border-bottom: 0; }
  .result-heading { flex-direction: column; }
  .legend { justify-content: flex-start; max-width: none; }
  .map-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .source-item { gap: 12px; }
  .builder-actions { align-items: stretch; flex-direction: column; }
  .oep-wordmark small, .brand-divider { display: none; }
  .header-brand { gap: 9px; }
  .judicial-source-grid { grid-template-columns: 1fr; }
  .judicial-source-grid article, .judicial-source-grid article:nth-child(odd), .judicial-source-grid article:nth-child(even) { padding: 18px 0; border-right: 0; }
  .roadmap-heading, .verification-rule { grid-template-columns: 1fr; flex-direction: column; gap: 10px; }
  .research-stamp { text-align: left; }
  .region-picker-panel { position: fixed; inset: auto 15px 18px; width: auto; max-height: min(72vh, 560px); }
  .region-options { grid-template-columns: 1fr; max-height: min(45vh, 330px); }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* ---------- Chart layer (charts.js). Chart ink follows the dataviz reference roles. ---------- */
.view-tabs { margin: 18px 0 12px; }
.view-tabs span { min-height: 34px; padding: 0 12px; }
.result-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.view-options { display: flex; flex-wrap: wrap; gap: 16px; color: #52514e; font-size: .78rem; }
.view-options label { display: inline-flex; align-items: center; gap: 6px; }
.view-options select { min-height: 32px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); padding: 0 8px; }
.export-actions { display: flex; gap: 6px; }
.button-ghost { min-height: 32px; padding: 0 12px; font-size: .76rem; background: transparent; }
.button-ghost:hover { background: var(--paper); }
.view-hint { margin: 0 0 12px; padding: 10px 12px; border-left: 2px solid #2a78d6; background: #f4f8fe; color: #52514e; font-size: .78rem; }
.chart.is-refreshing, #profile-view.is-refreshing .chart { opacity: .45; transition: opacity 120ms ease; }
.viz-figure { margin: 0; }
.viz-svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-map { max-height: 560px; }
.viz-svg text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.viz-axis { fill: #898781; font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-axis-title { fill: #52514e; font-size: 12px; }
.viz-direct { fill: #52514e; font-size: 11.5px; }
.viz-direct-value, .viz-direct-strong { fill: #0b0b0b; font-weight: 700; }
.viz-tile-label { font-weight: 650; }
.viz-tile-value { font-weight: 600; opacity: .92; }
.viz-mark { cursor: default; outline: none; }
.viz-mark:focus-visible rect, .viz-mark:focus-visible circle:last-of-type, .viz-region:focus-visible { stroke: #0b0b0b; stroke-width: 2; }
.viz-mark.is-hover rect, .viz-mark.is-hover circle:last-of-type, .viz-region.is-hover { filter: brightness(1.08); }
.viz-region.is-hover { stroke: #0b0b0b; stroke-width: 1.6; }
.viz-bump:not(.is-strong):hover path { stroke: #52514e; }
.viz-caption { margin: 10px 0 0; color: #52514e; font-size: .75rem; line-height: 1.45; }
.viz-legend-scale { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; color: #52514e; font-size: .74rem; }
.viz-legend-scale span { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.viz-tooltip { position: fixed; z-index: 50; min-width: 150px; max-width: 280px; padding: 9px 11px; border-radius: 6px; background: #fcfcfb; box-shadow: 0 0 0 1px rgba(11,11,11,.10), 0 8px 24px rgba(11,11,11,.12); color: #0b0b0b; font-size: .76rem; pointer-events: none; }
.viz-tooltip-title { margin-bottom: 6px; color: #52514e; font-weight: 600; }
.viz-tooltip-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.viz-tooltip-row i { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.viz-tooltip-row strong { font-variant-numeric: tabular-nums; }
.viz-tooltip-row span { color: #52514e; }
/* ---------- Perfil regional ---------- */
.profile-controls { display: flex; gap: 10px; align-items: end; }
.profile-controls label { display: grid; gap: 4px; color: var(--muted); font-size: .74rem; font-weight: 650; }
.profile-controls select, .profile-controls input { min-height: 40px; border: 1px solid var(--line); border-radius: 4px; padding: 0 10px; background: var(--surface); }
.profile-controls input { width: 84px; }
.profile-kpis { grid-template-columns: repeat(3, 1fr); }
.profile-kpis .summary-card { border-bottom: 1px solid var(--line); }
.kpi-rank { color: #0b0b0b !important; font-weight: 600; }
.profile-story p { max-width: 72ch; margin: 0 0 10px; font-size: .95rem; line-height: 1.6; }
.profile-story cite { margin-left: 4px; color: #898781; font-size: .72rem; font-style: normal; text-transform: uppercase; letter-spacing: .04em; }
.profile-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin: 20px 0; }
/* OEC-style sections: the sentences that read a chart sit beside it. */
.profile-section { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 2.2fr); gap: clamp(20px, 3vw, 40px); align-items: start; }
.profile-section .profile-story p { font-size: .92rem; }
.profile-hl { color: var(--emerald-dark); font-weight: 650; }
.profile-note { margin-top: 14px; }
.ask-form { margin-top: 14px; max-width: 720px; }
.ask-form label { display: block; font-size: .78rem; font-weight: 650; margin-bottom: 6px; }
.ask-form div { display: flex; gap: 8px; }
.ask-form input { flex: 1; min-width: 0; }
.profile-section .data-table td, .profile-section .data-table th { text-align: left; }
.profile-section .data-table td:last-child, .profile-section .data-table th:last-child { text-align: right; }
#profile-recent td:first-child { white-space: nowrap; }
.profile-section .data-table tr.is-emphasis td { font-weight: 650; }
.map-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .map-compare { grid-template-columns: 1fr; } }
.profile-grid .chart { min-height: 0; }
#profile-view .result-panel + .result-panel { margin-top: 20px; }
.bar-row.is-emphasis .bar-label, .bar-row.is-emphasis .bar-value { color: #0b0b0b; font-weight: 700; }

/* ---------- Radar de inversión regional ---------- */
#attraction-view.is-refreshing { opacity: .55; transition: opacity 120ms ease; }
.attraction-heading { align-items: end; }
.attraction-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 340px); gap: 30px; margin-bottom: 20px; }
.attraction-scope { align-self: start; display: grid; gap: 7px; padding: 16px; border-left: 3px solid var(--emerald); background: color-mix(in srgb, var(--emerald) 7%, var(--surface)); font-size: .82rem; line-height: 1.5; }
.attraction-scope span { color: var(--muted); }
.attraction-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 20px 0; }
.attraction-pillar { padding: 22px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 7px 24px rgba(11,11,11,.035); }
.pillar-head { display: flex; justify-content: space-between; gap: 14px; }
.pillar-head h2 { margin: 8px 0 0; font-size: 1.12rem; }
.attraction-pillar > p { min-height: 42px; margin: 12px 0 18px; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.research-status { display: inline-flex; width: fit-content; padding: 4px 7px; border-radius: 999px; font: 650 .65rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; text-transform: uppercase; }
.status-live { background: color-mix(in srgb, var(--emerald) 15%, var(--surface)); color: var(--emerald-dark); }
.status-proxy, .status-next { background: color-mix(in srgb, #c8783e 14%, var(--surface)); color: var(--copper); }
.status-validate { background: color-mix(in srgb, #2a78d6 13%, var(--surface)); color: #2a78d6; }
.attraction-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.attraction-value { display: grid; align-content: start; gap: 4px; min-width: 0; padding: 16px 12px; border-right: 1px solid var(--line); }
.attraction-value:last-child { border-right: 0; }
.attraction-value > span { min-height: 30px; color: var(--muted); font-size: .7rem; font-weight: 650; line-height: 1.35; text-transform: uppercase; letter-spacing: .035em; }
.attraction-value strong { overflow-wrap: anywhere; font-size: 1.38rem; font-variant-numeric: tabular-nums; }
.attraction-value small, .attraction-value i { color: var(--muted); font-size: .68rem; line-height: 1.35; }
.attraction-value i { margin-top: 3px; font-style: normal; font-weight: 700; text-transform: uppercase; }
.attraction-value.is-missing strong { color: var(--muted); font-size: 1rem; }
.pillar-gap { display: grid; grid-template-columns: 78px 1fr; gap: 10px; margin-top: 16px; font-size: .76rem; line-height: 1.45; }
.pillar-gap span { color: var(--muted); }
.research-backlog { margin-top: 20px; }
.research-backlog[hidden] { display: none; }
.research-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--line); }
.research-grid article { padding: 20px; background: var(--surface); }
.research-grid h3 { margin: 10px 0 8px; font-size: .98rem; }
.research-grid p { margin: 0 0 12px; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.research-grid a { color: var(--emerald-dark); font-size: .76rem; font-weight: 700; }
@media (max-width: 900px) {
  .profile-grid, .profile-kpis, .profile-section { grid-template-columns: 1fr; }
  .profile-controls { flex-wrap: wrap; }
  .attraction-intro, .attraction-grid { grid-template-columns: 1fr; }
  .result-tools { align-items: flex-start; }
}
@media (max-width: 620px) {
  .attraction-values, .research-grid { grid-template-columns: 1fr; }
  .attraction-value { border-right: 0; border-bottom: 1px solid var(--line); }
  .attraction-value:last-child { border-bottom: 0; }
  .attraction-value > span { min-height: 0; }
}
@media (forced-colors: active) { .viz-svg rect, .viz-svg path, .viz-svg circle { forced-color-adjust: none; } }
.result-headline { max-width: 70ch; margin: 8px 0 0; color: #52514e; font-size: .95rem; line-height: 1.45; }

/* Theme tokens shared by the interface and chart text. */
:root { color-scheme: light; --chart-ink: #0b0b0b; --chart-secondary: #52514e; --chart-muted: #898781; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef3fa; --paper: #101923; --surface: #172331; --slate: #101923;
  --emerald: #0b805b; --emerald-dark: #64d8b2; --copper: #eaa476;
  --line: #39495b; --muted: #bdc8d6; --danger: #ffaaa1;
  --shadow: 0 18px 55px rgba(0,0,0,.18);
  --chart-ink: #eef3fa; --chart-secondary: #bdc8d6; --chart-muted: #a6b1bf;
}
.theme-toggle { white-space: nowrap; }
.login-theme-toggle { display: block; margin: -12px 0 20px auto; font-size: .76rem; }
.view-options, .viz-caption, .viz-legend-scale, .result-headline, .viz-tooltip-title, .viz-tooltip-row span { color: var(--chart-secondary); }
.viz-axis { fill: var(--chart-muted); }
.viz-axis-title, .viz-direct { fill: var(--chart-secondary); }
.viz-direct-value, .viz-direct-strong { fill: var(--chart-ink); }
.kpi-rank, .bar-row.is-emphasis .bar-label, .bar-row.is-emphasis .bar-value { color: var(--chart-ink) !important; }
.viz-tooltip { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.view-options select, .profile-controls select, .profile-controls input { color: var(--ink); }
[data-theme="dark"] .app-header { background: rgba(16,25,35,.97); }
[data-theme="dark"] .side-nav { background: #14202c; }
[data-theme="dark"] .nav-item.is-active, [data-theme="dark"] .segmented input:checked + span { background: #bdc8d6; color: #101923; }
[data-theme="dark"] .nav-item.is-active span { color: #224d40; }
[data-theme="dark"] .button:hover, [data-theme="dark"] .region-picker-trigger:hover, [data-theme="dark"] .region-picker-trigger[aria-expanded="true"] { border-color: #a6b1bf; background: #273442; }
[data-theme="dark"] .button-primary:hover { background: #096b4c; border-color: #096b4c; }
[data-theme="dark"] .login-panel, [data-theme="dark"] .login-form input[type="email"], [data-theme="dark"] .password-row input { background: var(--surface); color: var(--ink); }
[data-theme="dark"] .brand-divider { background: var(--line); }
[data-theme="dark"] .nav-item:hover, [data-theme="dark"] .region-option:hover, [data-theme="dark"] .bar-track { background: #273442; }
[data-theme="dark"] .quality-banner { background: #302820; color: #f0c1a1; }
[data-theme="dark"] .view-hint { background: #202f43; color: var(--muted); border-color: #79b5ff; }
[data-theme="dark"] .source-mark[data-tone="copper"] { color: #eaa476; }
[data-theme="dark"] .axis-line { stroke: #738499; }
[data-theme="dark"] .grid-line { stroke: #354659; }
[data-theme="dark"] .series-label { fill: var(--muted); }
[data-theme="dark"] .viz-region.is-hover { stroke: var(--ink); }
[data-theme="dark"] .viz-mark:focus-visible rect, [data-theme="dark"] .viz-mark:focus-visible circle:last-of-type, [data-theme="dark"] .viz-region:focus-visible { stroke: var(--ink); }
[data-theme="dark"] .viz-bump:not(.is-strong):hover path { stroke: var(--muted); }
.profile-story cite { color: var(--chart-muted); }
.chart-toolbar { background: var(--surface); }
@media (max-width: 680px) {
  .app-header { flex-wrap: wrap; gap: 8px; }
  .header-actions { margin-left: auto; }
  .header-actions .button { min-height: 36px; padding: 0 9px; font-size: .75rem; }
  .chart-toolbar {
    position: sticky; top: var(--header-height, 58px); z-index: 15;
    margin: 0 -12px 14px; padding: 8px 12px 0;
    border-bottom: 1px solid var(--line); box-shadow: 0 5px 12px rgba(0,0,0,.08);
  }
  .chart-toolbar .view-tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0 0 8px; padding: 3px 2px; }
  .chart-toolbar .view-tabs label { flex: 0 0 auto; }
  .chart-toolbar .result-tools { margin-bottom: 8px; gap: 8px; }
  .chart-toolbar .view-options { gap: 8px; }
  .chart-toolbar .view-hint { max-height: 72px; overflow-y: auto; margin-bottom: 8px; }
  .viz-mark, .data-table { scroll-margin-top: calc(var(--header-height) + 150px); }
}

/* Browse economic variables without opening the cross-source builder. */
.module-variable { display: grid; gap: 7px; width: min(100%, 490px); margin-top: 18px; color: var(--ink); font-size: .78rem; font-weight: 650; }
.module-variable select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); font: inherit; }
.module-variable .control-help { margin-top: 0; line-height: 1.45; }
.pillar-notes { margin: 12px 0 0; padding-left: 16px; font-size: .72rem; line-height: 1.45; color: var(--muted); }
.pillar-notes li + li { margin-top: 4px; }
.attraction-value .attraction-compare { color: var(--muted); font-style: italic; }
.occupation-table { margin-top: 14px; font-size: .78rem; }
.occupation-table summary { cursor: pointer; font-weight: 600; }
.occupation-table table { margin-top: 8px; width: 100%; }
.occupation-table .muted { color: var(--muted); }
