:root {
  color-scheme: light;
  --bg: #eff4f8;
  --card: #ffffff;
  --line: #dbe4ee;
  --text: #102030;
  --muted: #627284;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --good: #0f766e;
  --warn: #b45309;
  --bad: #b91c1c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --card: #111827;
  --line: #273247;
  --text: #e5edf8;
  --muted: #9eb0c9;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --good: #34d399;
  --warn: #f59e0b;
  --bad: #f87171;
}

* { box-sizing: border-box; }
html,
body {
  background-color: var(--bg);
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background-image: linear-gradient(180deg, #f8fbfe 0%, var(--bg) 100%);
  background-repeat: no-repeat;
}

button, input, select { font: inherit; }
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

:root[data-theme="dark"] html,
:root[data-theme="dark"] body {
  background-color: var(--bg);
}
:root[data-theme="dark"] body {
  background-image: linear-gradient(180deg, #0f172a 0%, var(--bg) 100%);
}
:root[data-theme="dark"] .clear-search {
  background: #1f2937;
  color: var(--muted);
}
:root[data-theme="dark"] .clear-search:hover {
  background: #273449;
}
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .search-input-wrap input {
  background: #0f172a;
  color: var(--text);
  border-color: var(--line);
}
:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .detail,
:root[data-theme="dark"] .suggestions,
:root[data-theme="dark"] .summary-card,
:root[data-theme="dark"] .chart-card,
:root[data-theme="dark"] .map-mode,
:root[data-theme="dark"] .map-selection {
  background: #0f172a;
  border-color: var(--line);
}
:root[data-theme="dark"] .info-modal-panel {
  background: #0f172a;
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.62);
}
:root[data-theme="dark"] .result-none,
:root[data-theme="dark"] .history-none {
  background: #111827;
}
:root[data-theme="dark"] .result-good,
:root[data-theme="dark"] .history-good {
  background: rgba(16, 185, 129, 0.14);
}
:root[data-theme="dark"] .result-warn,
:root[data-theme="dark"] .history-warn {
  background: rgba(245, 158, 11, 0.14);
}
:root[data-theme="dark"] .result-bad,
:root[data-theme="dark"] .history-bad {
  background: rgba(248, 113, 113, 0.14);
}
:root[data-theme="dark"] .secondary-action {
  background: rgba(96, 165, 250, 0.14);
  color: var(--accent);
  border-color: rgba(96, 165, 250, 0.28);
}
:root[data-theme="dark"] .map-action-button {
  background: rgba(15, 23, 42, 0.52);
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.2);
}
:root[data-theme="dark"] .map-action-button:hover {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(96, 165, 250, 0.4);
}
:root[data-theme="dark"] .map-canvas-shell,
:root[data-theme="dark"] .map-toolbar {
  background: rgba(15, 23, 42, 0.82);
  border-color: rgba(148, 163, 184, 0.18);
}
:root[data-theme="dark"] .leaflet-layer,
:root[data-theme="dark"] .leaflet-control-zoom-in,
:root[data-theme="dark"] .leaflet-control-zoom-out,
:root[data-theme="dark"] .leaflet-control-attribution {
  filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}
:root[data-theme="dark"] .map-grade-pill {
  background: rgba(15, 23, 42, 0.42);
  border-color: rgba(148, 163, 184, 0.16);
  color: rgba(229, 237, 248, 0.62);
}
:root[data-theme="dark"] .map-grade-pill.active {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.3), rgba(37, 99, 235, 0.18));
  border-color: rgba(96, 165, 250, 0.55);
  color: var(--text);
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.32), inset 0 0 0 1px rgba(191, 219, 254, 0.18);
}
:root[data-theme="dark"] .map-grade-marker,
:root[data-theme="dark"] .map-cluster-badge {
  border-color: rgba(148, 163, 184, 0.16);
}
:root[data-theme="dark"] .map-cluster-badge {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
}
:root[data-theme="dark"] .leaflet-control-attribution,
:root[data-theme="dark"] .map-loading {
  background: rgba(15, 23, 42, 0.88) !important;
  color: var(--muted);
  border-color: rgba(148, 163, 184, 0.18);
}
:root[data-theme="dark"] .leaflet-container {
  background: #000;
}
:root[data-theme="dark"] .leaflet-control-attribution a {
  color: var(--text);
}
:root[data-theme="dark"] .grade-a,
:root[data-theme="dark"] .legend-a {
  background: rgba(16, 185, 129, 0.22);
}
:root[data-theme="dark"] .grade-b,
:root[data-theme="dark"] .legend-b {
  background: rgba(245, 158, 11, 0.22);
}
:root[data-theme="dark"] .grade-c,
:root[data-theme="dark"] .legend-c {
  background: rgba(248, 113, 113, 0.22);
}
:root[data-theme="dark"] .grade-n,
:root[data-theme="dark"] .grade-p {
  background: rgba(96, 165, 250, 0.22);
}
:root[data-theme="dark"] .grade-z {
  background: rgba(168, 85, 247, 0.24);
  color: #ddd6fe;
}
:root[data-theme="dark"] .grade-ungraded,
:root[data-theme="dark"] .grade-—,
:root[data-theme="dark"] .grade-null {
  background: rgba(148, 163, 184, 0.18);
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px;
}

.card {
  background: var(--card);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 20px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.05);
}

.topbar {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}
.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.topbar-actions .theme-toggle {
  margin-left: 0;
}
.theme-toggle {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover {
  background: var(--accent-soft);
}

.info-toggle {
  font-size: 15px;
  font-weight: 700;
}
.info-close {
  flex: 0 0 auto;
}
.info-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
}
.info-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 20, 0.68);
  backdrop-filter: blur(8px) saturate(0.8);
  -webkit-backdrop-filter: blur(8px) saturate(0.8);
}
.info-modal-panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  padding: 14px;
  display: grid;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 72px rgba(2, 6, 23, 0.5);
}
.info-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}
.info-modal-body {
  display: grid;
  gap: 12px;
}
.info-section {
  display: grid;
  gap: 8px;
}
.info-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.35;
}
.info-list li + li {
  margin-top: 6px;
}
.info-legend {
  align-items: center;
}
body.modal-open {
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent);
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.25rem, 2.4vw, 2rem); line-height: 1.05; }
h2 { font-size: 1rem; }
h3 { font-size: 0.92rem; }
.topbar-copy, .muted { color: var(--muted); }
.topbar-copy { max-width: 34ch; }

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.sidebar, .detail {
  padding: 10px;
  background: var(--card);
}
.search-toolbar { display: grid; gap: 6px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 0.76rem; font-weight: 600; }
.field input, .field select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fbfdff;
}

.toolbar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 6px;
}

.primary, .back-button, .suggestion-item {
  border: none;
  cursor: pointer;
}

.primary {
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}
.secondary-action {
  background: rgba(37, 99, 235, 0.09);
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.16);
}
.location-row {
  grid-template-columns: repeat(2, auto) minmax(0, 1fr);
  align-items: center;
}
.location-row .muted {
  grid-column: 1 / -1;
  min-height: 1.25rem;
}

.search-field { position: relative; }
.search-input-wrap {
  position: relative;
}
.clear-search {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: #e9eef5;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.clear-search:hover { background: #dde6f2; }
.search-input-wrap input { padding-right: 34px; }
.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: grid;
  gap: 3px;
  padding: 4px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
  z-index: 30;
}
.suggestion-item {
  text-align: left;
  padding: 7px 9px;
  border-radius: 8px;
  background: transparent;
  display: grid;
  gap: 1px;
}
.suggestion-item:hover { background: var(--accent-soft); }
.suggestion-item span { color: var(--muted); font-size: 0.84rem; }
.hidden { display: none !important; }

.results-header, .section-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin: 8px 0 6px;
}
.results-list, .history-list { display: grid; gap: 4px; }

.result-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  background: #fff;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.result-item:hover, .result-item.active {
  border-color: rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(37, 99, 235, 0.06);
}
.result-good { background: rgba(15, 118, 110, 0.08); }
.result-warn { background: rgba(180, 83, 9, 0.08); }
.result-bad { background: rgba(185, 28, 28, 0.08); }
.result-none { background: #fff; }
.result-main, .detail-hero, .history-header {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: start;
}
.result-copy {
  min-width: 0;
  flex: 1;
}
.result-item h3 {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.82rem;
  line-height: 1.1;
}
.result-item p {
  line-height: 1.1;
}
.small { font-size: 0.72rem; margin-top: 1px; }
.title-grade-prefix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin-right: 3px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  border: 1px solid rgba(15, 23, 42, 0.06);
  flex: 0 0 auto;
}
.grade-a { background: rgba(15, 118, 110, 0.18); color: var(--good); }
.grade-b { background: rgba(180, 83, 9, 0.18); color: var(--warn); }
.grade-c { background: rgba(185, 28, 28, 0.18); color: var(--bad); }
.grade-n, .grade-p { background: rgba(37, 99, 235, 0.16); color: var(--accent); }
.grade-z { background: rgba(109, 40, 217, 0.16); color: #6d28d9; }
.grade-ungraded,
.grade-—, .grade-null { background: #eef2f7; color: var(--muted); }

.badge, .score-chip {
  min-width: 66px;
  border-radius: 10px;
  padding: 5px 6px;
  text-align: center;
  background: #eef4ff;
}
.badge-grade, .score-chip strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}
.badge-score {
  font-size: 0.68rem;
  margin-top: 2px;
  font-weight: 600;
}
.score-label { display: block; font-size: 0.62rem; color: var(--muted); }
.badge.good, .score-chip.good { background: rgba(15, 118, 110, 0.12); color: var(--good); }
.badge.warn, .score-chip.warn { background: rgba(180, 83, 9, 0.12); color: var(--warn); }
.badge.bad, .score-chip.bad { background: rgba(185, 28, 28, 0.12); color: var(--bad); }

.empty-state {
  min-height: 320px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.detail-view { display: grid; gap: 8px; }
.summary-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.summary-card {
  border: 1px solid #e7edf4;
  border-radius: 12px;
  background: #fafcff;
}
.summary-card.compact {
  padding: 8px 10px;
}
.summary-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}
.chart-card {
  padding: 8px 10px;
  border-radius: 12px;
  background: #fafcff;
  border: 1px solid #e7edf4;
}
#scoreChart { width: 100%; height: 110px; overflow: visible; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 3; }
.chart-dot { fill: white; stroke: var(--accent); stroke-width: 2; }
.chart-label { fill: var(--muted); font-size: 10px; }
.chart-axis-label { fill: var(--muted); font-size: 10px; }
.chart-grade-label { fill: var(--muted); font-size: 10px; font-weight: 700; }
.chart-axis { stroke: #94a3b8; stroke-width: 1.2; }
.chart-grid { stroke: #e2e8f0; stroke-width: 1; stroke-dasharray: 2 2; }
.grade-band { opacity: 0.5; }
.grade-band-a { fill: rgba(15, 118, 110, 0.12); }
.grade-band-b { fill: rgba(180, 83, 9, 0.12); }
.grade-band-c { fill: rgba(185, 28, 28, 0.12); }
.grade-legend {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid rgba(15, 23, 42, 0.06);
}
.legend-item strong { color: var(--text); }
.legend-item small { font-size: 0.68rem; }
.legend-a { background: rgba(15, 118, 110, 0.12); }
.legend-b { background: rgba(180, 83, 9, 0.12); }
.legend-c { background: rgba(185, 28, 28, 0.12); }

.history-item {
  border-top: 1px solid #ebf0f5;
  padding: 6px 7px;
  border-radius: 10px;
}
.history-item:first-child { border-top: none; padding-top: 6px; }
.history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}
.history-header > div {
  flex: 1 1 auto;
  min-width: 0;
}
.history-item h3 {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.88rem;
  line-height: 1.12;
}
.history-item .muted {
  font-size: 0.78rem;
}
.history-copy-button {
  flex: 0 0 auto;
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, color 0.18s ease;
}
.history-copy-button:hover {
  background: var(--accent-soft);
  border-color: rgba(37, 99, 235, 0.26);
  transform: translateY(-1px);
}
.history-copy-button.copied {
  background: rgba(15, 118, 110, 0.14);
  border-color: rgba(15, 118, 110, 0.3);
  color: var(--good);
}
:root[data-theme="dark"] .history-copy-button {
  background: rgba(15, 23, 42, 0.5);
  border-color: rgba(148, 163, 184, 0.18);
}
:root[data-theme="dark"] .history-copy-button:hover {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(96, 165, 250, 0.4);
}
:root[data-theme="dark"] .history-copy-button.copied {
  background: rgb(5, 150, 105);
  border-color: rgb(209, 250, 229);
  color: #ffffff;
  font-weight: 800;
}
.history-good { background: rgba(15, 118, 110, 0.08); }
.history-warn { background: rgba(180, 83, 9, 0.08); }
.history-bad { background: rgba(185, 28, 28, 0.08); }
.history-none { background: #fff; }
.history-action {
  margin-top: 3px;
  margin-bottom: 3px;
  font-size: 0.84rem;
  line-height: 1.2;
}
.violation-list {
  margin: 0;
  padding-left: 14px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.2;
}
.violation-list li { margin-bottom: 2px; }

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #eef4ff;
  color: var(--accent);
  font-weight: 700;
}
:root[data-theme="dark"] .back-button {
  background: #1f2937;
  color: var(--accent);
  border: 1px solid var(--line);
}

.map-mode {
  margin-top: 8px;
  padding: 10px;
  display: grid;
  gap: 10px;
}
.map-mode-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}
.map-mode-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.map-action-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.map-action-button:hover {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.28);
  transform: translateY(-1px);
}
.map-close-button {
  background: rgba(15, 23, 42, 0.04);
}
.map-toolbar {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  background: rgba(250, 252, 255, 0.9);
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}
.map-toolbar-copy {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  align-items: center;
}
.map-grade-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.map-grade-pill {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  color: rgba(98, 114, 132, 0.72);
  padding: 7px 10px;
  min-width: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.map-grade-pill.active {
  background: rgba(37, 99, 235, 0.1);
  color: var(--text);
  border-color: rgba(37, 99, 235, 0.56);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}
.map-grade-pill .title-grade-prefix {
  margin-right: 0;
}
.map-canvas-shell {
  position: relative;
  min-height: 620px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, rgba(248, 251, 255, 0.95), rgba(239, 244, 248, 0.92));
}
.map-canvas {
  min-height: 620px;
  width: 100%;
}
.map-loading {
  position: absolute;
  inset: 18px auto auto 18px;
  z-index: 450;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 12px 14px;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12);
}
.map-selection {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 450;
  padding: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.16);
}
.map-selection-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}
.map-selection-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}
.leaflet-container {
  font: inherit;
  background: #dce9f5;
}
.leaflet-control-attribution {
  border-radius: 10px 10px 0 0;
  padding: 3px 8px !important;
  background: rgba(255, 255, 255, 0.86) !important;
}
.map-marker-wrapper,
.map-cluster-wrapper {
  background: transparent;
  border: none;
}
.map-grade-marker,
.map-cluster-badge {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(10px);
}
.map-cluster-badge {
  min-width: 42px;
  width: auto;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}
.map-grade-a { background: rgba(15, 118, 110, 0.92); color: white; }
.map-grade-b { background: rgba(180, 83, 9, 0.92); color: white; }
.map-grade-c { background: rgba(185, 28, 28, 0.92); color: white; }
.map-grade-n,
.map-grade-p { background: rgba(37, 99, 235, 0.92); color: white; }
.map-grade-z { background: rgba(109, 40, 217, 0.92); color: white; }
.map-grade-ungraded { background: rgba(148, 163, 184, 0.92); color: white; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .topbar { align-items: start; flex-direction: row; }
  .topbar > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
  }
  .topbar-actions {
    margin-left: auto;
    width: auto;
    justify-content: flex-end;
    align-self: flex-start;
  }
  .detail { order: -1; }
  .detail:not(.mobile-active) .detail-view,
  .detail:not(.mobile-active) .back-button {
    display: none !important;
  }
  .detail.mobile-active .empty-state {
    display: none !important;
  }
  .detail:not(.mobile-active) {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
  }
  .detail.no-selection {
    display: none;
  }
  .detail.mobile-active {
    padding: 14px;
    background: var(--card);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 20px;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.05);
  }
  .map-mode-header,
  .map-toolbar-copy,
  .map-selection-header {
    flex-direction: column;
  }
  .map-mode-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .map-canvas-shell,
  .map-canvas {
    min-height: 72vh;
  }
  .map-selection {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
}

@media (max-width: 640px) {
  .app-shell { padding: 8px; }
  .info-modal-panel { padding: 12px; }
  .topbar, .sidebar, .detail.mobile-active { padding: 8px; }
  .toolbar-row, .summary-strip, .location-row { grid-template-columns: 1fr; }
  .result-main, .detail-hero { flex-direction: column; }
  .history-header {
    flex-direction: row;
    align-items: flex-start;
  }
  .empty-state { min-height: 160px; }
  .results-list, .history-list { gap: 3px; }
  .result-item, .history-item { padding-top: 6px; padding-bottom: 6px; }
  .map-mode { padding: 8px; }
  .map-toolbar { padding: 8px 10px; }
  .map-grade-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .map-canvas-shell,
  .map-canvas {
    min-height: 68vh;
  }
  .map-grade-pill {
    min-width: 0;
    width: 100%;
    padding: 7px 8px;
    justify-content: center;
  }
  .map-grade-pill:last-child {
    grid-column: 1 / -1;
  }
}
