:root {
  color-scheme: light;
  --navy-950: #071b2b;
  --navy-900: #0b2438;
  --navy-800: #14364d;
  --ink: #172430;
  --muted: #607181;
  --line: #d6dfe5;
  --surface: #ffffff;
  --canvas: #eef3f5;
  --teal: #2a9d8f;
  --teal-soft: #d8f0ed;
  --orange: #e76f51;
  --blue: #457b9d;
  --gold: #e9c46a;
  --red: #d7191c;
  --focus: #078a98;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.45;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(7, 138, 152, 0.35); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px clamp(18px, 3vw, 44px);
  color: white;
  background: var(--navy-950);
  border-bottom: 3px solid #1fb2aa;
}

.brand-mark {
  width: 44px;
  height: 44px;
  position: relative;
  border: 1px solid #32617a;
  border-radius: 12px;
  background: var(--navy-900);
  flex: 0 0 auto;
}

.brand-mark span { position: absolute; left: 9px; right: 9px; height: 3px; background: #65d2c7; }
.brand-mark span:first-child { top: 13px; }
.brand-mark span:nth-child(2) { top: 24px; }
.brand-mark i { position: absolute; top: 9px; bottom: 8px; width: 3px; background: #65d2c7; }
.brand-mark i:nth-of-type(1) { left: 15px; }
.brand-mark i:nth-of-type(2) { right: 15px; }

.eyebrow {
  margin: 0 0 2px;
  color: #638093;
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.topbar .eyebrow { color: #7ecbc5; }
.title-block h1 { margin: 0; font-size: clamp(1.12rem, 2vw, 1.55rem); line-height: 1.15; }

.analysis-meta {
  margin-left: auto;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.analysis-meta span {
  padding: 6px 9px;
  border: 1px solid #33546a;
  border-radius: 999px;
  color: #dce9ef;
  font-size: 0.8rem;
}

main { width: min(1820px, 100%); margin: 0 auto; padding: 16px clamp(14px, 2vw, 30px) 24px; }

.decision-flow {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 16px;
  color: white;
  background: linear-gradient(110deg, var(--navy-900), var(--navy-800));
  border-radius: 14px;
}

.decision-flow article { display: flex; align-items: center; gap: 10px; min-width: 155px; }
.decision-flow article div { display: flex; flex-direction: column; }
.decision-flow strong { font-size: 1.55rem; line-height: 1; font-variant-numeric: tabular-nums; }
.decision-flow small { margin-top: 4px; color: #c2d4de; font-size: 0.78rem; }
.decision-flow .step { color: #78d8cf; font-size: 0.72rem; font-weight: 800; }
.decision-flow .priority-step strong { color: #ff8e7d; }
.flow-arrow { color: #6d8a9b; font-size: 1.25rem; }
.decision-flow > p { margin: 0 0 0 auto; max-width: 390px; color: #d5e2e8; font-size: 0.86rem; text-align: right; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

.view-tabs {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  background: #dfe7eb;
  border-radius: 11px;
}

.tab {
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  color: #526574;
  background: transparent;
  font-size: 0.88rem;
  font-weight: 750;
}

.tab.is-active { color: var(--navy-900); background: white; box-shadow: 0 1px 4px rgba(15, 39, 55, 0.15); }

.search-box {
  position: relative;
  width: min(300px, 36vw);
  margin-left: auto;
}

.search-box svg { position: absolute; left: 12px; top: 50%; width: 18px; transform: translateY(-50%); fill: none; stroke: #657783; stroke-width: 1.8; }
.search-box input { width: 100%; min-height: 42px; padding: 8px 12px 8px 38px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 10px; }

.explorer-grid { display: grid; grid-template-columns: 255px minmax(500px, 1fr) 310px; gap: 12px; align-items: stretch; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 20px rgba(34, 58, 70, 0.055); }
.control-panel, .detail-panel { padding: 18px; }
.panel-heading, .shortlist-heading, .detail-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.panel-heading h2, .map-heading h2, .detail-panel h2 { margin: 0; color: var(--navy-900); font-size: 1.12rem; }
.text-button { padding: 4px; color: #187d82; background: transparent; border: 0; font-size: 0.82rem; font-weight: 750; }

.range-control { display: block; margin-top: 23px; }
.range-control > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.range-control b { font-size: 0.88rem; }
.range-control output { min-width: 43px; padding: 3px 7px; color: var(--navy-900); background: var(--teal-soft); border-radius: 6px; font-size: 0.83rem; font-weight: 800; text-align: center; }
.range-control input { width: 100%; margin: 13px 0 5px; accent-color: #138f91; }
.range-control small, .scenario-note { display: block; color: var(--muted); font-size: 0.74rem; line-height: 1.4; }

.threshold-note { margin: 20px 0; padding: 10px 11px; background: #f1f5f6; border-left: 3px solid #5f8599; border-radius: 4px 8px 8px 4px; }
.threshold-note span { color: #5d7180; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.threshold-note p { margin: 2px 0 0; font-size: 0.8rem; }

.legend-block { padding-top: 16px; border-top: 1px solid var(--line); }
.legend-block h3, .reason-box h3, .shortlist h3 { margin: 0 0 10px; font-size: 0.82rem; }
.legend { display: grid; gap: 8px; }
.legend-item { display: grid; grid-template-columns: 17px 1fr auto; align-items: center; gap: 8px; color: #435461; font-size: 0.75rem; }
.legend-item i { width: 17px; height: 13px; display: block; border: 1px solid #334651; border-radius: 2px; }
.legend-item b { color: var(--navy-900); font-variant-numeric: tabular-nums; }
.scenario-note { margin: 18px 0 0; }

.map-card { min-height: 640px; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.map-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.map-actions { display: flex; gap: 4px; }
.map-actions button, #close-detail { min-width: 34px; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; color: #2b4657; background: #f6f8f9; font-weight: 750; }
.map-actions #reset-map { font-size: 0.75rem; }

.map-stage { position: relative; min-height: 520px; overflow: hidden; background: #f8faf9; background-image: radial-gradient(circle at 1px 1px, #dce5e4 1px, transparent 0); background-size: 22px 22px; }
#map { width: 100%; height: 100%; display: block; touch-action: none; }
#map path { vector-effect: non-scaling-stroke; cursor: pointer; transition: opacity 120ms ease, fill 160ms ease; }
#map path:hover { opacity: 0.8; stroke-width: 2.2; }
#map path.is-selected { stroke: #071b2b !important; stroke-width: 3.2 !important; filter: drop-shadow(0 1px 1px rgba(4, 17, 27, 0.25)); }

.tooltip { position: absolute; z-index: 4; display: none; min-width: 180px; padding: 9px 11px; color: white; background: rgba(7, 27, 43, 0.94); border-radius: 8px; pointer-events: none; font-size: 0.77rem; box-shadow: 0 8px 20px rgba(7, 27, 43, 0.22); }
.tooltip.is-visible { display: block; }
.tooltip b { display: block; margin-bottom: 2px; }
.tooltip span { color: #bcd0db; }

.map-caption { display: flex; justify-content: space-between; gap: 10px; padding: 9px 14px; color: #697a86; background: #fbfcfc; border-top: 1px solid var(--line); font-size: 0.72rem; }

.detail-panel { min-height: 640px; display: flex; flex-direction: column; }
.empty-state { min-height: 240px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.empty-state > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 0.84rem; }
.locator-icon { width: 38px; height: 38px; display: block; margin-bottom: 16px; border: 7px solid #66bdb6; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
.detail-title-row #close-detail { font-size: 1.2rem; }
.status-pill { display: inline-block; margin-top: 9px; padding: 5px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0; }
.metrics div { padding: 10px; background: #f3f6f7; border-radius: 8px; }
.metrics dt { min-height: 32px; color: #6b7a84; font-size: 0.67rem; }
.metrics dd { margin: 4px 0 0; color: var(--navy-900); font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.reason-box { padding: 12px; background: #edf6f5; border-left: 3px solid #29978e; border-radius: 4px 9px 9px 4px; }
.reason-box p { margin: 0; color: #445761; font-size: 0.79rem; }

.shortlist { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); }
.shortlist-heading span { color: var(--muted); font-size: 0.72rem; }
#shortlist {
  max-height: 300px;
  overflow-y: auto;
  display: grid;
  gap: 4px;
  padding-right: 4px;
  scrollbar-color: #9bb2bd #edf2f3;
  scrollbar-width: thin;
}
.shortlist-heading { margin-bottom: 6px; }
.shortlist button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px; color: #3c4c58; background: transparent; border: 0; border-radius: 6px; font-size: 0.76rem; text-align: left; }
.shortlist button:hover { background: #f0f5f5; }
.shortlist button span:last-child { color: #8b99a2; }

.scenario-comparison, .priority-register { margin-top: 14px; padding: 20px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.section-heading h2 { margin: 0; color: var(--navy-900); font-size: 1.15rem; }
.section-heading > p, .register-heading > div > p:last-child { max-width: 610px; margin: 2px 0 0; color: var(--muted); font-size: 0.82rem; }

.comparison-grid {
  display: grid;
  grid-template-columns: minmax(170px, 220px) 90px minmax(170px, 220px) minmax(360px, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-top: 16px;
}

.scenario-card { padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #f5f8f9; }
.scenario-card > span { color: #617482; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.scenario-card strong { display: block; margin-top: 7px; color: var(--navy-900); font-size: 1.7rem; line-height: 1; font-variant-numeric: tabular-nums; }
.scenario-card p { margin: 3px 0 10px; color: #4d606c; font-size: 0.8rem; }
.scenario-card small { color: #6c7e89; font-size: 0.72rem; }
.current-card { background: #edf7f6; border-color: #a9d8d4; }

.net-change { display: flex; flex-direction: column; align-items: center; justify-content: center; color: #526773; }
.net-change strong { color: var(--navy-900); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.net-change span { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; }

.change-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.change-groups section { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.change-groups h3 { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 8px; color: #334954; font-size: 0.78rem; }
.change-groups h3 span { min-width: 24px; padding: 1px 6px; border-radius: 999px; background: #e9eff1; text-align: center; font-variant-numeric: tabular-nums; }
.change-list { max-height: 78px; overflow-y: auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; }
.change-list p { margin: 0; color: #7a8991; font-size: 0.74rem; }
.change-list button { padding: 4px 7px; border: 1px solid #cad6db; border-radius: 999px; color: #38505c; background: #f7f9fa; font-size: 0.7rem; }
.change-list button:hover { border-color: #6ea9a5; background: #edf7f6; }

.register-heading { align-items: flex-end; }
.register-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.register-actions input, .register-actions select, .export-button {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #304550;
  background: white;
  font-size: 0.78rem;
}
.register-actions input { width: 190px; }
.export-button { color: white; background: var(--navy-800); border-color: var(--navy-800); font-weight: 750; }
.export-button:hover { background: var(--navy-900); }
.export-status { min-width: 92px; color: #4c6b72; font-size: 0.7rem; }

.table-wrap { position: relative; max-height: 520px; margin-top: 16px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.table-wrap thead { position: sticky; top: 0; z-index: 2; color: white; background: var(--navy-800); }
.table-wrap th { padding: 10px 12px; text-align: left; white-space: nowrap; font-size: 0.7rem; letter-spacing: 0.02em; }
.table-wrap td { padding: 9px 12px; border-top: 1px solid #e2e8eb; color: #41535f; font-variant-numeric: tabular-nums; }
.table-wrap tbody tr:nth-child(even) { background: #f8fafb; }
.table-wrap tbody tr:hover { background: #edf6f5; }
.table-wrap td:first-child { color: #81909a; }
.row-link { padding: 0; border: 0; color: #0e6970; background: transparent; font-weight: 750; text-align: left; }
.row-link:hover { text-decoration: underline; }
.change-badge { display: inline-block; padding: 3px 7px; border-radius: 999px; background: #e8eff2; color: #526773; font-size: 0.68rem; font-weight: 750; }
.change-badge.added { color: #8a2f20; background: #fde8e3; }
.table-empty { padding: 28px; color: #687b87; text-align: center; font-size: 0.82rem; }

footer { position: relative; padding: 14px clamp(18px, 3vw, 44px) 24px; color: #657783; background: #e4ebee; font-size: 0.78rem; }
footer p { margin: 0; max-width: 1100px; }
footer button { position: absolute; top: 12px; right: clamp(18px, 3vw, 44px); color: #287478; background: transparent; border: 0; font-weight: 750; }
#method-note { max-width: 900px; margin-top: 10px; padding-top: 10px; border-top: 1px solid #cad5da; }

@media (max-width: 1180px) {
  .explorer-grid { grid-template-columns: 230px minmax(460px, 1fr); }
  .detail-panel { grid-column: 1 / -1; min-height: auto; display: grid; grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr); gap: 24px; }
  .shortlist { margin-top: 0; padding-top: 0; border-top: 0; border-left: 1px solid var(--line); padding-left: 24px; }
  #shortlist { max-height: 340px; }
  .comparison-grid { grid-template-columns: minmax(170px, 1fr) 80px minmax(170px, 1fr); }
  .change-groups { grid-column: 1 / -1; }
}

@media (max-width: 780px) {
  .topbar { align-items: flex-start; }
  .analysis-meta { display: none; }
  .decision-flow { overflow-x: auto; }
  .decision-flow > p { display: none; }
  .decision-flow article { min-width: 132px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .view-tabs { overflow-x: auto; }
  .tab { flex: 1 0 auto; }
  .search-box { width: 100%; }
  .explorer-grid { display: flex; flex-direction: column; }
  .control-panel { order: 2; }
  .map-card { order: 1; min-height: 550px; }
  .detail-panel { order: 3; display: flex; }
  .shortlist { margin-top: 18px; padding: 18px 0 0; border: 0; border-top: 1px solid var(--line); }
  .map-stage { min-height: 440px; }
  .map-caption span:first-child { display: none; }
  .section-heading, .register-heading { align-items: stretch; flex-direction: column; gap: 12px; }
  .comparison-grid { grid-template-columns: 1fr 70px 1fr; }
  .register-actions { justify-content: flex-start; }
  .table-wrap { max-height: 460px; }
  footer { padding-bottom: 60px; }
  footer button { top: auto; bottom: 18px; left: 18px; right: auto; }
}

@media (max-width: 460px) {
  .brand-mark { display: none; }
  .decision-flow { border-radius: 10px; }
  .flow-arrow { display: none; }
  .map-heading { align-items: flex-start; }
  .map-actions #reset-map { display: none; }
  .metrics { grid-template-columns: 1fr; }
  .scenario-comparison, .priority-register { padding: 15px; }
  .comparison-grid { grid-template-columns: 1fr 55px 1fr; }
  .scenario-card { padding: 12px; }
  .scenario-card strong { font-size: 1.4rem; }
  .scenario-card small { display: block; }
  .change-groups { grid-template-columns: 1fr; }
  .register-actions { display: grid; grid-template-columns: 1fr; }
  .register-actions input, .register-actions select, .export-button { width: 100%; }
  .export-status { min-width: 0; }
}
