:root {
  color-scheme: light;
  --bg: #e8eee9;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --panel-soft: rgba(247, 249, 246, 0.96);
  --ink: #17221f;
  --muted: #64736f;
  --line: #d4dcd4;
  --line-strong: #aeb9b1;
  --green: #2f6f5e;
  --green-soft: #e6f0eb;
  --rust: #bd5a3f;
  --rust-soft: #f4e5df;
  --blue: #346c94;
  --blue-soft: #e2edf4;
  --gold: #b98224;
  --gold-soft: #f5ecd8;
  --shadow: 0 18px 48px rgba(25, 38, 34, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
  font-weight: 780;
}

h2 {
  font-size: 14px;
  line-height: 1.25;
  font-weight: 820;
}

h3 {
  font-size: 13px;
  line-height: 1.25;
  font-weight: 820;
}

.app-shell {
  height: 100vh;
  padding: 10px;
}

.app-header {
  height: 50px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px 10px;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--green);
  font-size: 11px;
  font-weight: 840;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.command-center {
  height: calc(100vh - 70px);
  min-height: 620px;
}

.map-canvas {
  position: relative;
  height: 100%;
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #dfe8e3;
  box-shadow: var(--shadow);
}

.map-engine,
.fallback-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-engine {
  display: none;
}

.map-engine.active {
  display: block;
}

.fallback-map {
  display: block;
}

.fallback-map.hidden {
  display: none;
}

.control-card,
.inspector-panel,
.portfolio-dock,
.insight-strip,
.metric-strip,
.map-tools {
  position: absolute;
  z-index: 2;
}

.control-card,
.inspector-panel,
.portfolio-dock,
.insight-card,
.metric,
.map-tools {
  border: 1px solid rgba(212, 220, 212, 0.94);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.control-card {
  top: 12px;
  left: 12px;
  width: 322px;
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 12px;
}

.metric-strip {
  top: 12px;
  left: 346px;
  right: 410px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
}

.metric {
  min-width: 0;
  padding: 9px 10px;
}

.metric span,
.summary-card span,
.insight-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  font-weight: 740;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 1;
}

.map-tools {
  top: 76px;
  left: 346px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.inspector-panel {
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 384px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px;
}

.portfolio-dock {
  left: 346px;
  bottom: 12px;
  width: min(360px, calc(100% - 770px));
  max-height: 320px;
  overflow: auto;
  padding: 11px;
}

.insight-strip {
  left: 720px;
  right: 410px;
  bottom: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.insight-card {
  width: 100%;
  color: var(--ink);
  padding: 10px;
  text-align: left;
  text-decoration: none;
}

.insight-card strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.25;
}

.insight-card em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
}

.header-actions,
.map-actions,
.tabs,
.inspector-tabs,
.segmented,
.layer-controls,
.map-legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.header-actions {
  justify-content: flex-end;
}

.source-link,
.tab-button,
.segmented button,
.layer-button,
.quiet-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--ink);
  padding: 6px 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  text-decoration: none;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.source-link:hover,
.tab-button:hover,
.segmented button:hover,
.layer-button:hover,
.quiet-button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.quiet-button {
  background: var(--panel-soft);
}

.tab-button.active,
.segmented button.active,
.layer-button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.layer-button[data-layer="plaza"].active {
  background: var(--green);
  border-color: var(--green);
}

.layer-button[data-layer="open_street"].active {
  background: var(--rust);
  border-color: var(--rust);
}

.layer-button[data-layer="events"].active {
  background: var(--gold);
  border-color: var(--gold);
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-title-row.compact {
  margin-bottom: 9px;
}

.panel-kicker {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.search-box,
.select-field,
.filter-group {
  display: grid;
  gap: 7px;
}

.search-box,
.select-field {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.search-box input,
.select-field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

.search-box input:focus,
.select-field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(52, 108, 148, 0.14);
}

.filter-group {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.filter-group + .filter-group,
.filter-row,
.search-box + .filter-group {
  margin-top: 11px;
}

.filter-group legend,
.filter-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.borough-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 6px 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 720;
}

.borough-option input {
  width: 14px;
  height: 14px;
  accent-color: var(--green);
}

.borough-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segmented button,
.layer-button {
  flex: 1 1 auto;
}

.segmented button span {
  color: inherit;
  font-size: 11px;
  font-weight: 760;
  opacity: 0.72;
}

.map-legend {
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-swatch {
  width: 14px;
  height: 6px;
  border-radius: 2px;
}

.legend-swatch.plaza {
  background: var(--green);
}

.legend-swatch.open_street {
  background: var(--rust);
}

.legend-swatch.events {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
}

.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

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

.summary-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 9px;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  line-height: 1.15;
}

.chart-list,
.leaderboard-list,
.detail-list,
.source-list,
.qa-list,
.future-list,
.event-list {
  display: grid;
  gap: 8px;
}

.data-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.data-table-head,
.data-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 52px 62px 48px;
  gap: 7px;
  align-items: center;
  padding: 7px 8px;
  font-size: 11px;
}

.data-table-head {
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 820;
}

.data-table-row + .data-table-row {
  border-top: 1px solid var(--line);
}

.data-table-row strong {
  overflow-wrap: anywhere;
}

.bar-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.bar-track {
  height: 8px;
  background: #e8ece5;
  border-radius: 8px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  min-width: 3px;
  background: var(--blue);
}

.bar-fill.plaza,
.bar-fill.exact,
.bar-fill.high,
.bar-fill.confirmed,
.bar-fill.likely {
  background: var(--green);
}

.bar-fill.open_street,
.bar-fill.low,
.bar-fill.unmatched,
.bar-fill.rejected,
.bar-fill.needs_agency_data {
  background: var(--rust);
}

.bar-fill.medium,
.bar-fill.review {
  background: var(--gold);
}

.leaderboard-row,
.directory-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 9px;
  text-align: left;
}

.leaderboard-row.active,
.directory-row.active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.leaderboard-row strong,
.leaderboard-row span span,
.directory-name,
.directory-meta {
  display: block;
}

.leaderboard-row span span,
.directory-meta,
.row-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.leaderboard-row em {
  min-width: 28px;
  color: var(--green);
  font-style: normal;
  font-weight: 840;
  text-align: right;
}

.directory-list,
.source-list,
.qa-list,
.future-list,
.event-list {
  max-height: calc(100vh - 184px);
  overflow: auto;
  padding-right: 3px;
}

.directory-name {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 780;
}

.inspector-tabs {
  flex: 0 0 auto;
  margin-bottom: 10px;
}

.inspector-tabs .tab-button {
  flex: 1 1 0;
}

.inspector-section {
  display: none;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.inspector-section.active {
  display: block;
  flex: 1 1 auto;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 12px;
}

.empty-state strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.detail-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-section {
  display: grid;
  gap: 9px;
  border-top: 1px solid var(--line);
  padding-top: 11px;
  margin-top: 11px;
}

.profile-section h4 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 840;
  text-transform: uppercase;
}

.detail-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 9px;
  font-size: 13px;
  line-height: 1.42;
}

.detail-row span:first-child {
  color: var(--muted);
  font-size: 11px;
  font-weight: 820;
}

.type-pill,
.status-pill,
.severity-pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 820;
  line-height: 1;
}

.type-pill.plaza {
  color: #164235;
  background: var(--green-soft);
}

.type-pill.open_street {
  color: #77351f;
  background: var(--rust-soft);
}

.type-pill.event {
  color: #684814;
  background: var(--gold-soft);
}

.status-pill {
  color: #28435a;
  background: var(--blue-soft);
}

.status-pill.inactive {
  color: #6a4a17;
  background: var(--gold-soft);
}

.tabs {
  margin-bottom: 10px;
}

.source-row,
.qa-row,
.future-row,
.event-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-soft);
}

.source-row header,
.qa-row header,
.future-row header,
.event-row header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 5px;
}

.row-title {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.event-row.matched {
  border-color: #c8d9cf;
  background: #f4fbf7;
}

.event-row.candidate {
  border-color: #dfca98;
  background: #fffbef;
}

.event-row.reviewed {
  border-color: #ccd8df;
  background: #f7fbfd;
}

.event-list.compact {
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.event-row.compact {
  border: 0;
  border-radius: 0;
  padding: 0 0 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  width: 100%;
}

.event-row.compact.active {
  color: var(--blue);
}

.event-row.compact strong,
.event-row.compact span {
  display: block;
}

.event-row.compact span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.event-panel-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
}

.event-panel-summary strong {
  color: var(--ink);
  font-size: 20px;
}

.selected-event-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.selected-event-card strong {
  font-size: 14px;
}

.selected-event-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.review-actions,
.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.source-actions {
  margin: 0 0 10px;
}

.review-actions button,
.source-actions a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--ink);
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
}

.severity-pill.info {
  color: #28435a;
  background: var(--blue-soft);
}

.severity-pill.success {
  color: #164235;
  background: var(--green-soft);
}

.severity-pill.warning {
  color: #6a4a17;
  background: var(--gold-soft);
}

.severity-pill.error {
  color: #762c26;
  background: #f3ddd9;
}

.map-status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: min(420px, calc(100% - 24px));
  z-index: 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px;
}

.maplibregl-ctrl-attrib {
  font-size: 10px;
}

.realm-tooltip .maplibregl-popup-content {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 36px rgba(28, 40, 36, 0.2);
  padding: 10px 11px;
  color: var(--ink);
}

.tooltip-card {
  display: grid;
  gap: 4px;
  min-width: 190px;
  max-width: 260px;
}

.tooltip-card strong {
  font-size: 13px;
  line-height: 1.25;
}

.tooltip-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.base-borough {
  fill: #f8faf5;
  stroke: #b7c4bd;
  stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
}

.borough-label {
  fill: #4d5b56;
  font-size: 14px;
  font-weight: 800;
  pointer-events: none;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(248, 250, 245, 0.9);
  stroke-width: 4px;
}

.map-feature {
  vector-effect: non-scaling-stroke;
  transition:
    opacity 140ms ease,
    stroke-width 140ms ease,
    filter 140ms ease;
}

.map-feature:hover,
.map-feature.active {
  filter: drop-shadow(0 4px 8px rgba(27, 37, 35, 0.22));
}

.map-feature.plaza {
  fill: rgba(47, 111, 94, 0.5);
  stroke: var(--green);
  stroke-width: 1.4;
}

.map-feature.plaza.point {
  fill: var(--green);
  stroke: #fff;
  stroke-width: 1.7;
}

.map-feature.open_street {
  fill: none;
  stroke: var(--rust);
  stroke-width: 3;
  stroke-linecap: round;
}

.map-feature.event {
  fill: var(--gold);
  stroke: #fff;
  stroke-width: 1.5;
}

.map-label {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 750;
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.84);
  stroke-width: 3px;
}

@media (max-width: 1400px) {
  .metric-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    right: 410px;
  }

  .map-tools {
    top: 136px;
  }

  .portfolio-dock {
    display: none;
  }

  .insight-strip {
    left: 346px;
    grid-template-columns: 1fr;
    max-width: 360px;
  }
}

@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    padding: 8px;
  }

  .app-header {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .command-center,
  .map-canvas {
    height: auto;
    min-height: 0;
  }

  .map-canvas {
    display: grid;
    gap: 8px;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .map-engine,
  .fallback-map {
    position: relative;
    height: 68vh;
    min-height: 460px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    overflow: hidden;
  }

  .control-card,
  .inspector-panel,
  .portfolio-dock,
  .insight-strip,
  .metric-strip,
  .map-tools {
    position: static;
    width: auto;
    max-width: none;
    max-height: none;
  }

  .metric-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .portfolio-dock {
    display: block;
  }

  .insight-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .inspector-panel {
    min-height: 520px;
  }

  .directory-list,
  .source-list,
  .qa-list,
  .future-list,
  .event-list {
    max-height: 440px;
  }
}

@media (max-width: 720px) {
  h1 {
    font-size: 21px;
  }

  .metric-strip,
  .checkbox-grid,
  .dashboard-summary,
  .confidence-summary,
  .insight-strip {
    grid-template-columns: 1fr;
  }

  .map-engine,
  .fallback-map {
    height: 62vh;
    min-height: 420px;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .bar-row {
    grid-template-columns: 86px minmax(0, 1fr) 32px;
  }

  .data-table-head,
  .data-table-row {
    grid-template-columns: minmax(0, 1fr) 42px 54px 42px;
  }
}
