:root {
  color-scheme: light;
  --app-bg: #eef0ec;
  --surface: #ffffff;
  --surface-soft: #f5f6f3;
  --surface-raised: rgba(255, 255, 255, 0.96);
  --border: #d9ddd7;
  --border-strong: #b8c0b9;
  --text: #17201d;
  --text-muted: #56615c;
  --text-faint: #68736e;
  --accent: #17675f;
  --accent-strong: #0e514b;
  --accent-soft: #dcece8;
  --ok: #17675f;
  --insufficient: #875909;
  --no-data: #5f6964;
  --unavailable: #9b3038;
  --marker-ok: #17675f;
  --marker-no-data: #69736e;
  --school: #8a5b16;
  --mrt: #315e9c;
  --series-1: #17675f;
  --series-2: #315e9c;
  --series-3: #a45c18;
  --series-4: #7a4b9b;
  --series-5: #a63e57;
  --focus: #17675f;
  --shadow-sm: 0 1px 2px rgba(23, 32, 29, 0.08), 0 8px 24px rgba(23, 32, 29, 0.06);
  --shadow-lg: 0 24px 70px rgba(20, 31, 27, 0.2);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --app-bar-height: 64px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --app-bg: #111614;
  --surface: #1a211e;
  --surface-soft: #202824;
  --surface-raised: rgba(26, 33, 30, 0.96);
  --border: #34403a;
  --border-strong: #526159;
  --text: #f0f4f1;
  --text-muted: #b5c0ba;
  --text-faint: #9caaa3;
  --accent: #70c8bc;
  --accent-strong: #99ded4;
  --accent-soft: #233f3a;
  --ok: #70c8bc;
  --insufficient: #e0ad55;
  --no-data: #b2bdb7;
  --unavailable: #ff9aa0;
  --marker-ok: #70c8bc;
  --marker-no-data: #a5b1ab;
  --school: #e0ad55;
  --mrt: #85b7ff;
  --series-1: #70c8bc;
  --series-2: #85b7ff;
  --series-3: #f0ad62;
  --series-4: #d3a4f2;
  --series-5: #ff9fb2;
  --focus: #99ded4;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.22), 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--app-bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select,
[tabindex]:not([tabindex='-1']) {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

a {
  color: var(--accent-strong);
}

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

.skip-link {
  position: fixed;
  z-index: 3000;
  left: 12px;
  top: 12px;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.skip-link:focus {
  transform: translateY(0);
}

#app-shell {
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr) 0;
  grid-template-rows: var(--app-bar-height) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transition: grid-template-columns 180ms ease;
}

#app-shell[data-rail='closed'] {
  grid-template-columns: 0 minmax(0, 1fr) 0;
}

#app-shell[data-detail='open'] {
  grid-template-columns: 372px minmax(0, 1fr) 410px;
}

#app-shell[data-rail='closed'][data-detail='open'] {
  grid-template-columns: 0 minmax(0, 1fr) 410px;
}

#app-bar {
  position: relative;
  z-index: 1100;
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-width: 0;
  padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
  backdrop-filter: blur(18px);
}

.product-announcement {
  position: fixed;
  z-index: 1000;
  top: calc(var(--app-bar-height) + 12px);
  left: 50%;
  width: min(680px, calc(100vw - 48px));
  padding: 11px 14px;
  transform: translateX(-50%);
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border));
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
  backdrop-filter: blur(16px);
}

.brand-lockup,
.app-actions,
.section-heading-row,
.rail-heading,
.detail-header,
.analysis-header,
.list-header,
.combobox-wrap,
.transaction-heading,
.compare-heading {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
  min-width: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 740;
  letter-spacing: -0.02em;
}

.brand-tagline {
  padding-left: 12px;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.app-actions {
  justify-content: flex-end;
  gap: 6px;
}

.app-actions form {
  margin: 0;
}

.button,
.scope-mode button,
.window-buttons button,
.view-switch button,
.analysis-tabs button,
.search-results button,
.block-card,
.transaction-card,
.tabular-action {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  color: var(--text);
  background: transparent;
  font-weight: 650;
}

.button-quiet:hover,
.button-secondary:hover,
.button-surface:hover {
  background: var(--surface-soft);
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

:root[data-theme='dark'] .button-primary {
  color: #10201c;
}

.button-primary:not(:disabled):hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.button-secondary,
.button-surface {
  border-color: var(--border);
  background: var(--surface);
}

.button-surface {
  box-shadow: var(--shadow-sm);
}

.button-block {
  width: 100%;
}

.selection-rail {
  position: relative;
  z-index: 800;
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--surface);
  transition: transform 180ms ease, visibility 180ms ease;
}

#app-shell[data-rail='closed'] .selection-rail {
  visibility: hidden;
  transform: translateX(-100%);
}

.rail-heading {
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 15px;
  border-bottom: 1px solid var(--border);
}

.rail-heading h1,
.detail-header h2,
.analysis-header h2,
.list-header h2,
.current-scope h3 {
  margin: 0;
  font-weight: 720;
  letter-spacing: -0.025em;
}

.rail-heading h1 {
  font-size: 20px;
}

.eyebrow,
.scope-kind {
  margin: 0 0 3px;
  color: var(--accent-strong);
  font-size: 10.5px;
  font-weight: 760;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sheet-toggle {
  display: none;
}

.rail-content {
  height: calc(100% - 78px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.rail-section {
  padding: 17px 18px;
  border-bottom: 1px solid var(--border);
}

.compact-section {
  padding-top: 13px;
  padding-bottom: 13px;
}

.rail-section h2 {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 740;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

.section-heading-row {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.source-date,
.state-key {
  color: var(--text-faint);
  font-size: 11px;
  text-align: right;
}

.scope-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.scope-mode button,
.window-buttons button,
.view-switch button,
.analysis-tabs button {
  padding: 8px 10px;
  border-color: var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.scope-mode button[aria-checked='true'],
.window-buttons button[aria-pressed='true'],
.view-switch button[aria-pressed='true'],
.analysis-tabs button[aria-selected='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.search-field {
  position: relative;
  margin-top: 14px;
}

.search-field > label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.combobox-wrap {
  align-items: stretch;
  gap: 6px;
}

#scope-search {
  min-width: 0;
  min-height: 46px;
  flex: 1 1 auto;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
}

#scope-search::placeholder {
  color: var(--text-faint);
}

.search-results {
  position: absolute;
  z-index: 1300;
  top: calc(100% - 19px);
  left: 0;
  right: 0;
  max-height: min(310px, 42vh);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
}

.search-results li + li {
  margin-top: 2px;
}

.search-results button {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.search-results button:hover,
.search-results button[aria-selected='true'] {
  background: var(--accent-soft);
}

.search-result-title,
.search-result-meta {
  display: block;
}

.search-result-title {
  font-weight: 680;
}

.search-result-meta {
  color: var(--text-muted);
  font-size: 11.5px;
}

.field-help,
.window-note,
.current-scope p,
.empty-state p,
.loading-state p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.field-help {
  margin-top: 7px;
}

.current-scope {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.current-scope h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.window-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.window-note {
  margin: 11px 0 12px;
}

.notice {
  margin: 10px 0;
  padding: 10px 11px;
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-soft);
  font-size: 12px;
}

.notice-caution {
  border-color: var(--insufficient);
}

.notice-error {
  border-color: var(--unavailable);
}

.aggregate-list {
  min-height: 86px;
}

.aggregate-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.75fr) minmax(0, 1.35fr);
  gap: 12px;
  align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.aggregate-row:last-child {
  border-bottom: 0;
}

.aggregate-label {
  min-width: 0;
  font-size: 12.5px;
  font-weight: 720;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.aggregate-value-wrap {
  min-width: 0;
  text-align: right;
}

.aggregate-value,
.aggregate-state {
  display: block;
  font-size: 15px;
  font-weight: 740;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  overflow-wrap: break-word;
}

.aggregate-row[data-state='ok'] .aggregate-value {
  color: var(--ok);
}

.aggregate-row[data-state='insufficient'] .aggregate-state {
  color: var(--insufficient);
}

.aggregate-row[data-state='no_data'] .aggregate-state {
  color: var(--no-data);
}

.aggregate-row[data-state='unavailable'] {
  margin: 4px 0;
  padding: 10px;
  border-left: 3px solid var(--unavailable);
  background: color-mix(in srgb, var(--unavailable) 9%, transparent);
}

.aggregate-row[data-state='unavailable'] .aggregate-state {
  color: var(--unavailable);
}

.aggregate-meta,
.aggregate-provenance {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.aggregate-provenance {
  margin-top: 5px;
}

.aggregate-value-wrap .aggregate-meta,
.aggregate-value-wrap .aggregate-provenance {
  max-width: 100%;
  text-align: right;
  overflow-wrap: break-word;
  word-break: normal;
}

.view-switch {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.view-switch button {
  min-height: 38px;
  padding: 6px 12px;
  border: 0;
}

.exclusions {
  color: var(--text);
  font-size: 14px;
}

.provenance {
  color: var(--text-muted);
  font-size: 12px;
}

.exclusion-list,
.provenance-list,
.fact-list,
.nearby-list,
.comparison-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.exclusion-list li,
.provenance-item {
  padding: 9px 0 9px 11px;
  border-left: 2px solid var(--border-strong);
}

.exclusion-list li + li,
.provenance-item + .provenance-item {
  margin-top: 8px;
}

.exclusion-list strong,
.provenance-name,
.fact-label,
.nearby-name {
  color: var(--text);
  font-weight: 700;
}

.provenance-name,
.provenance-meta,
.provenance-id {
  display: block;
}

.provenance-id {
  margin-top: 3px;
  font: 10.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.rail-footer {
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
}

.independence-note {
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.independence-note strong {
  color: var(--text);
  font-weight: 700;
}

.independence-note a {
  font-weight: 700;
  text-underline-offset: 2px;
}

#workspace {
  position: relative;
  z-index: 1;
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--app-bg);
}

.map-surface,
.list-surface {
  position: absolute;
  inset: 0;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--app-bg);
}

.map-status {
  position: absolute;
  z-index: 600;
  top: 14px;
  left: 14px;
  max-width: min(440px, calc(100% - 180px));
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  backdrop-filter: blur(14px);
}

.map-status:empty {
  display: none;
}

.legend {
  position: absolute;
  z-index: 650;
  left: 14px;
  bottom: 28px;
  width: min(260px, calc(100% - 28px));
  max-height: min(460px, calc(100% - 92px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
}

#legend-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#legend-action {
  color: var(--accent-strong);
  font-size: 11px;
}

.legend.collapsed #legend-items {
  display: none;
}

#legend-items {
  margin: 0;
  padding: 2px 12px 12px;
  list-style: none;
  color: var(--text-muted);
  font-size: 12px;
}

#legend-items li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 7px 0;
}

#legend-items .legend-sub {
  margin-left: 19px;
  font-size: 11.5px;
}

#legend-items .legend-note {
  display: block;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  margin-top: 3px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.swatch.filled {
  background: currentColor;
}

.swatch.radius-500 {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.swatch.radius-1000 {
  border-style: dashed;
  border-color: var(--mrt);
  background: color-mix(in srgb, var(--mrt) 8%, transparent);
}

.swatch.mrt {
  border-color: var(--mrt);
}

.swatch.school {
  border-color: var(--school);
}

.map-actions {
  position: absolute;
  z-index: 650;
  top: 14px;
  right: 14px;
}

.leaflet-container {
  background: var(--app-bg);
  font: inherit;
}

.leaflet-bar a,
.leaflet-bar a:hover {
  width: 44px;
  height: 44px;
  line-height: 44px;
  border-color: var(--border) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  font-size: 21px;
}

.leaflet-control-zoom {
  margin-top: 66px !important;
  margin-left: 14px !important;
  border: 0 !important;
  box-shadow: var(--shadow-sm) !important;
}

.leaflet-control-attribution {
  background: var(--surface-raised) !important;
  color: var(--text-muted) !important;
  font-size: 11px !important;
}

.leaflet-control-attribution a {
  color: var(--accent-strong) !important;
}

.leaflet-control-attribution .onemap-attribution-logo {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 2px;
  vertical-align: middle;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--surface);
  color: var(--text);
}

.leaflet-popup-content-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
  margin: 13px 15px;
}

.popup-block h3 {
  margin: 0 0 5px;
  font-size: 14px;
}

.popup-block p {
  margin: 4px 0;
}

.popup-block button {
  width: 100%;
  min-height: 44px;
  margin-top: 9px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.list-surface {
  overflow: auto;
  padding: 26px;
  background: var(--surface-soft);
}

.list-header {
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 20px;
  max-width: 1040px;
}

.list-header h2 {
  font-size: 26px;
}

.block-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  max-width: 1040px;
  margin: 0 auto;
}

.block-card,
.transaction-card,
.tabular-action {
  width: 100%;
  padding: 14px;
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: 0 1px 1px rgba(23, 32, 29, 0.03);
}

.block-card:hover,
.transaction-card:hover,
.tabular-action:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.block-address,
.transaction-price {
  display: block;
  font-size: 14px;
  font-weight: 730;
}

.block-meta,
.transaction-meta,
.transaction-address {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.transaction-address {
  color: var(--text);
  font-weight: 670;
}

.detail-drawer {
  position: relative;
  z-index: 850;
  grid-column: 3;
  grid-row: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--surface);
  visibility: hidden;
  transform: translateX(100%);
  transition: transform 180ms ease, visibility 180ms ease;
}

#app-shell[data-detail='open'] .detail-drawer {
  visibility: visible;
  transform: translateX(0);
}

.detail-header,
.analysis-header {
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.detail-header h2 {
  font-size: 20px;
}

.detail-header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.detail-content {
  min-height: 0;
  padding: 0 18px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.detail-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.detail-section:last-child {
  border-bottom: 0;
}

.detail-section h3,
.analysis-panel h3,
.analysis-card h4 {
  margin: 0 0 10px;
  font-weight: 720;
  letter-spacing: -0.015em;
}

.detail-section h3 {
  font-size: 15px;
}

.radius-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
}

.radius-summary .field-help {
  flex: 1 1 100%;
  margin-top: 0;
}

.radius-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 720;
}

.radius-chip-500 {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.radius-chip-1000 {
  border-style: dashed;
  border-color: var(--mrt);
  color: var(--mrt);
}

.fact-list li,
.nearby-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.fact-list li:last-child,
.nearby-list li:last-child {
  border-bottom: 0;
}

.fact-value,
.nearby-distance {
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.catchment-counts {
  margin: 5px 0 4px;
  color: var(--text-muted);
  font-size: 11.5px;
}

.nearby-list li.within-500m {
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}

.nearby-list li.within-1km {
  border-left: 3px dashed var(--mrt);
  padding-left: 9px;
}

.transaction-list {
  display: grid;
  gap: 8px;
}

.scope-transaction-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0;
  margin: 14px 0 0;
  list-style: none;
}

.scope-transaction-list .transaction-card {
  height: 100%;
}

.transaction-page-summary {
  margin: 0;
  color: var(--text-muted);
}

.transaction-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.transaction-pagination > .notice,
.transaction-pagination > .field-help,
.transaction-pagination > div {
  flex: 1 1 100%;
  margin: 0;
}

.transaction-retry {
  margin-top: 12px;
}

.scope-transaction-detail .metric-grid {
  margin-top: 14px;
}

.transaction-block-action {
  margin-top: 20px;
}

.transaction-source-heading {
  margin: 18px 0 8px;
  font-size: 13px;
}

.transaction-source-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  margin-top: 4px;
  font-weight: 650;
}

.transaction-source-disclosure {
  margin-top: 18px;
  border-top: 1px solid var(--border);
}

.transaction-source-disclosure summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 680;
}

.transaction-heading,
.compare-heading {
  justify-content: space-between;
  gap: 12px;
}

.transaction-price {
  color: var(--ok);
  font-size: 16px;
  text-align: right;
}

.loading-state,
.empty-state {
  padding: 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.loading-state strong,
.empty-state strong {
  display: block;
  margin-bottom: 4px;
}

.analysis-dialog {
  width: min(1180px, calc(100vw - 32px));
  height: min(820px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.analysis-dialog::backdrop {
  background: rgba(8, 14, 12, 0.56);
  backdrop-filter: blur(6px);
}

.analysis-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
}

.analysis-header {
  padding: 20px 22px;
}

.analysis-header-main {
  min-width: 0;
  flex: 1 1 auto;
}

.analysis-header h2 {
  font-size: 27px;
}

.analysis-header p:last-child {
  margin: 4px 0 0;
  color: var(--text-muted);
}

.analysis-filter {
  display: grid;
  gap: 5px;
  width: min(330px, 100%);
  margin-top: 14px;
}

.analysis-filter label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 720;
}

.analysis-filter select {
  min-height: 44px;
  padding: 8px 34px 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 680;
}

.analysis-filter .field-help {
  margin-top: 0;
}

.analysis-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 18px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.analysis-tabs button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.analysis-body {
  overflow-y: auto;
  background: var(--surface-soft);
}

.analysis-panel {
  max-width: 1060px;
  margin: 0 auto;
  padding: 24px;
}

.analysis-panel h3 {
  font-size: 22px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.analysis-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.analysis-card.full-width {
  grid-column: 1 / -1;
}

.analysis-card h4 {
  font-size: 15px;
}

.chart-wrap {
  min-height: 280px;
}

.trend-chart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 250px;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 3;
}

.chart-label {
  fill: var(--text-muted);
  font-size: 11px;
}

.population-chart {
  margin-top: 18px;
}

.population-chart h5 {
  margin: 0 0 4px;
  font-size: 14px;
}

.population-bars {
  display: grid;
  gap: 7px;
  padding: 0;
  margin: 16px 0 18px;
  list-style: none;
}

.population-bar-row {
  display: grid;
  grid-template-columns: 50px minmax(100px, 1fr) 64px;
  align-items: center;
  gap: 9px;
  font-size: 12px;
}

.population-bar-label,
.population-bar-value {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.population-bar-value {
  text-align: right;
}

.population-bar-track {
  display: block;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.population-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.census-disclosure {
  margin-top: 18px;
}

.census-disclosure summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--accent);
  cursor: pointer;
}

.comparison-trend-heading {
  margin-top: 22px;
}

.comparison-series {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.comparison-point {
  fill: var(--surface);
  stroke-width: 2.5;
}

.comparison-series-0 { stroke: var(--series-1); }
.comparison-series-1 { stroke: var(--series-2); }
.comparison-series-2 { stroke: var(--series-3); }
.comparison-series-3 { stroke: var(--series-4); }
.comparison-series-4 { stroke: var(--series-5); }

.comparison-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 0;
  margin: 10px 0 0;
  list-style: none;
  color: var(--text-muted);
  font-size: 12px;
}

.comparison-chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.comparison-legend-swatch {
  width: 20px;
  height: 3px;
  border-radius: 999px;
}

.comparison-series-bg-0 { background: var(--series-1); }
.comparison-series-bg-1 { background: var(--series-2); }
.comparison-series-bg-2 { background: var(--series-3); }
.comparison-series-bg-3 { background: var(--series-4); }
.comparison-series-bg-4 { background: var(--series-5); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}

.metric {
  padding: 13px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.metric-label,
.metric-meta {
  display: block;
  color: var(--text-muted);
  font-size: 11.5px;
}

.metric-value {
  display: block;
  margin: 3px 0;
  color: var(--ok);
  font-size: 19px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.caveat {
  padding: 13px;
  border-left: 3px solid var(--insufficient);
  background: color-mix(in srgb, var(--insufficient) 10%, transparent);
  font-weight: 650;
}

.comparison-list {
  display: grid;
  gap: 8px;
}

.comparison-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.comparison-results {
  margin-top: 14px;
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.comparison-table th {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

@media (max-width: 1100px) {
  #app-shell,
  #app-shell[data-rail='closed'],
  #app-shell[data-detail='open'],
  #app-shell[data-rail='closed'][data-detail='open'] {
    grid-template-columns: minmax(0, 1fr);
  }

  #workspace {
    grid-column: 1;
  }

  .selection-rail,
  .detail-drawer {
    position: fixed;
    top: var(--app-bar-height);
    bottom: 0;
    width: min(380px, calc(50vw - 12px));
    box-shadow: var(--shadow-lg);
  }

  .selection-rail {
    left: 0;
  }

  .detail-drawer {
    right: 0;
  }

  #app-shell[data-rail='closed'] .selection-rail {
    visibility: hidden;
    transform: translateX(-105%);
  }

  #app-shell[data-detail='closed'] .detail-drawer {
    visibility: hidden;
    transform: translateX(105%);
  }

  .analysis-dialog {
    width: calc(100vw - 24px);
    height: calc(100dvh - 24px);
  }
}

@media (max-width: 720px) {
  :root {
    --app-bar-height: 56px;
  }

  #app-bar {
    padding: 0 10px 0 14px;
  }

  .product-announcement {
    top: calc(var(--app-bar-height) + 8px);
    left: 10px;
    right: 10px;
    width: auto;
    transform: none;
    text-align: left;
  }

  .brand-tagline,
  #rail-toggle {
    display: none;
  }

  .app-actions {
    gap: 2px;
  }

  .app-actions #theme-toggle {
    display: none;
  }

  .app-actions .button {
    min-height: 44px;
    padding-inline: 10px;
    font-size: 12px;
  }

  .selection-rail {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: min(58dvh, 540px);
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
    transform: none;
    visibility: visible;
  }

  .selection-rail[data-mobile-snap='peek'] {
    height: 116px;
  }

  .selection-rail[data-mobile-snap='full'] {
    top: var(--app-bar-height);
    height: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  #app-shell[data-rail='closed'] .selection-rail {
    visibility: visible;
    transform: none;
  }

  .rail-heading {
    min-height: 74px;
    padding: 13px 14px;
  }

  .rail-heading h1 {
    font-size: 18px;
  }

  .sheet-toggle {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .selection-rail[data-mobile-snap='peek'] .rail-content {
    visibility: hidden;
    overflow: hidden;
  }

  .rail-content {
    height: calc(100% - 74px);
  }

  .rail-section {
    padding-inline: 14px;
  }

  .scope-mode {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-status {
    top: 12px;
    left: 66px;
    max-width: calc(100% - 148px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .map-actions {
    top: 64px;
    right: 10px;
  }

  .map-actions .button {
    padding-inline: 10px;
    font-size: 12px;
  }

  .leaflet-control-zoom {
    margin-top: 12px !important;
    margin-left: 10px !important;
  }

  .legend {
    top: 118px;
    bottom: auto;
    left: 10px;
    width: min(250px, calc(100% - 20px));
    max-height: 38dvh;
  }

  #app-shell[data-view='list'] .selection-rail {
    display: none;
  }

  .list-surface {
    padding: 16px 12px calc(20px + env(safe-area-inset-bottom));
  }

  .list-header {
    align-items: flex-start;
  }

  .list-header h2 {
    font-size: 21px;
  }

  .block-list {
    grid-template-columns: 1fr;
  }

  .scope-transaction-list {
    grid-template-columns: 1fr;
  }

  .detail-drawer {
    top: var(--app-bar-height);
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    border-left: 0;
    border-top: 1px solid var(--border);
    transform: translateY(105%);
  }

  #app-shell[data-detail='open'] .detail-drawer {
    transform: translateY(0);
  }

  .detail-header {
    padding: 12px 14px;
  }

  .detail-header-actions .button {
    padding-inline: 9px;
    font-size: 12px;
  }

  .analysis-dialog {
    width: 100vw;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .analysis-header {
    padding: 14px;
  }

  .analysis-filter {
    width: 100%;
  }

  .analysis-filter select {
    font-size: 16px;
  }

  .analysis-header h2 {
    font-size: 22px;
  }

  .analysis-tabs {
    padding-inline: 10px;
  }

  .analysis-panel {
    padding: 16px 12px calc(24px + env(safe-area-inset-bottom));
  }

  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .analysis-card.full-width {
    grid-column: auto;
  }
}

@media (max-width: 390px) {
  .brand-name {
    font-size: 15px;
  }

  .app-actions .button {
    padding-inline: 8px;
  }

  .window-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Access screen ---------------------------------------------------------- */

body.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: auto;
  background:
    radial-gradient(circle at 12% 12%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 34%),
    var(--app-bg);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 430px);
  padding: clamp(24px, 6vw, 40px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin: 0;
  font-size: clamp(26px, 6vw, 36px);
  letter-spacing: -0.035em;
}

.login-intro,
.login-footnote {
  color: var(--text-muted);
}

.login-intro {
  margin: 10px 0 22px;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.login-form input {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
}

.login-form .button {
  margin-top: 5px;
}

.login-footnote {
  margin: 18px 0 0;
  font-size: 12px;
}

.login-card .independence-note {
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
