:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #20242a;
  --muted: #68727f;
  --line: #d9dee5;
  --accent: #1f7a6b;
  --accent-2: #315f9a;
  --warn: #a65f00;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

.parcel-tooltip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.parcel-value-label {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}

.parcel-value-label-zoomed {
  font-weight: 800;
  text-shadow: 0 0 4px #fff, 0 0 5px #fff, 0 0 6px #fff;
}

.leaflet-interactive:focus {
  outline: none;
}

.leaflet-container img.leaflet-tile {
  /* Leaflet/Chromium workaround for 1px anti-aliased tile seams. */
  mix-blend-mode: plus-lighter;
}

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

.shell {
  min-height: 100vh;
  padding: 12px;
}

.layout,
.chart-section,
.table-section,
.data-source-section {
  max-width: 1440px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 760;
}

h2 {
  font-size: 15px;
  font-weight: 760;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.controls label {
  min-width: 240px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

select {
  min-width: 150px;
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

input[list] {
  min-width: 320px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 12px;
  font-weight: 500;
  outline: none;
}

input[list]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(31, 122, 107, 0.15);
}

input[list]::placeholder {
  color: var(--muted);
  font-weight: 500;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
}

.map-panel {
  position: relative;
  height: calc(100vh - 28px);
  min-height: 400px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

#map {
  width: 100%;
  height: 100%;
}

.leaflet-bottom.leaflet-right {
  right: 14px;
  bottom: 14px;
}

.leaflet-right .leaflet-control {
  margin-right: 0;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 0;
}

.leaflet-control-zoom {
  border: 1px solid #b7c0cc !important;
  border-radius: 4px !important;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  font-size: 20px !important;
}

.map-title {
  position: absolute;
  z-index: 500;
  left: 14px;
  top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  padding: 8px 11px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}

.map-title h1 {
  font-size: 22px;
}

.map-title p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.map-empty {
  position: absolute;
  z-index: 500;
  left: 18px;
  bottom: 18px;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  padding: 12px 14px;
  color: var(--muted);
  font-size: 14px;
}

.map-scope {
  display: none;
}

.map-status {
  position: absolute;
  z-index: 500;
  left: 14px;
  top: 64px;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: min(440px, calc(100% - 110px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.source-badge {
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: #f3f4f6;
  color: #475467;
}

.source-badge[data-source="authoritative"] {
  background: #e8f5ef;
  color: #166534;
  border-color: #a7d8c0;
}

.source-badge[data-source="mirror"] {
  background: #edf4ff;
  color: #1d4f91;
  border-color: #bcd3f7;
}

.source-badge[data-source="snapshot"] {
  background: #fff4e5;
  color: #9a4d00;
  border-color: #f0c182;
}

.source-badge[data-source="cache"] {
  background: #eef2ff;
  color: #3f3f95;
  border-color: #cfd5f7;
}

.source-badge[data-source="unavailable"] {
  background: #fdecec;
  color: #a12828;
  border-color: #f3b4b4;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #98a2b3;
}

.map-status[data-state="ready"] .status-dot {
  background: var(--accent);
}

.map-status[data-state="blocked"] .status-dot {
  background: var(--warn);
}

.map-status[data-state="error"] .status-dot {
  background: #c0392b;
}

.map-status[data-state="loading"] .status-dot {
  border: 2px solid #c7d7f2;
  border-top-color: var(--accent-2);
  background: transparent;
  animation: status-spin 0.8s linear infinite;
}

@keyframes status-spin {
  to { transform: rotate(360deg); }
}

.map-zoom {
  position: absolute;
  z-index: 500;
  left: 14px;
  bottom: 14px;
  min-width: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  padding: 5px 8px;
  color: var(--muted);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.map-legend {
  position: absolute;
  z-index: 500;
  right: 14px;
  top: 14px;
  display: grid;
  gap: 7px;
  max-width: min(320px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
}

.map-home,
.map-clear,
.map-network {
  position: absolute;
  z-index: 500;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #b7c0cc;
  border-radius: 4px;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
  padding: 0;
}

.map-home {
  right: 14px;
  bottom: 124px;
  color: var(--ink);
}

.map-home.locating {
  color: var(--accent-2);
  background: #eef5ff;
}

.map-home:hover {
  background: #f4f6f8;
}

.map-home svg,
.map-clear svg,
.map-network svg {
  width: 18px;
  height: 18px;
}

.map-clear {
  right: 14px;
  bottom: 164px;
  color: var(--danger, #c0392b);
}

.map-clear:hover {
  background: #fdf0ef;
}

.map-network {
  right: 14px;
  bottom: 204px;
  color: var(--accent-2, #3b82f6);
}

.map-network:hover { background: #eff6ff; }
.map-network:disabled { opacity: 0.6; cursor: default; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.legend-item span {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 999px;
}

.side-panel {
  position: relative;
  display: grid;
  gap: 10px;
  align-content: start;
}

.side-collapse {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

.side-collapse svg {
  width: 17px;
  height: 17px;
}

.layout.panel-collapsed {
  grid-template-columns: minmax(0, 1fr) 42px;
}

.layout.panel-collapsed .side-panel section {
  display: none;
}

.layout.panel-collapsed .side-collapse {
  position: sticky;
  top: 12px;
  right: auto;
}

.side-panel section,
.chart-section,
.table-section,
.data-source-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.side-panel section {
  padding: 14px;
}

.map-controls-panel h2 {
  margin-bottom: 8px;
}

.control-group {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.layer-list,
.filter-grid {
  display: grid;
  gap: 8px;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.filter-grid select {
  width: 100%;
}

.filter-grid [hidden] {
  display: none;
}

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

.note code {
  color: var(--ink);
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 11px;
}

.firm-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.firm {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.firm header {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.firm strong {
  flex: 1;
  font-size: 14px;
}

.pill {
  border-radius: 999px;
  background: #e9f4f1;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  padding: 4px 8px;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric {
  display: grid;
  gap: 2px;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metric b {
  font-size: 14px;
}

.subject {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.subject-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  font-size: 13px;
}

.subject-row span:first-child {
  color: var(--muted);
}

.chart-section,
.table-section,
.data-source-section {
  margin-top: 14px;
  overflow: hidden;
}

.data-source-section {
  padding: 14px;
}

.data-source-section p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
}

.section-heading p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.chart-wrap {
  padding: 12px 14px 16px;
  overflow-x: auto;
}

#assessedChart {
  display: block;
  width: 100%;
  min-width: 780px;
  height: auto;
}

.gridline {
  stroke: #e7ebf0;
  stroke-width: 1;
}

.zero-line {
  stroke: #99a3af;
  stroke-width: 1.5;
  stroke-dasharray: 4 5;
}

.axis-label,
.chart-legend,
.chart-empty {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-legend {
  fill: var(--ink);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  background: #fbfcfd;
}

tr.subject-hit td {
  background: #f0f7f5;
}

@media (max-width: 980px) {
  .topbar {
    display: grid;
  }

  .controls {
    align-items: stretch;
  }

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

  .map-panel,
  #map {
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 10px;
  }

  .controls {
    display: grid;
  }

  h1 {
    font-size: 22px;
  }
}

.sv-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}
.sv-link:hover {
  text-decoration: underline;
}

.comps-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--accent-2);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.comps-btn:hover { opacity: 0.85; }
.comps-btn:disabled { opacity: 0.6; cursor: default; }
.comps-btn-gp { background: #6c757d; }
.comps-btn-detail { background: #2d6a4f; }
.comps-btn-sales { background: #b5651d; }
.comps-btn-protest { background: #8b0000; }
.comps-btn-subject { background: #1a5276; }
.comps-btn-addcomp { background: #196f3d; }
.comps-btn-link { background: #5a4fcf; text-decoration: none; }

.comps-table table { border-collapse: collapse; }
.comps-table th,
.comps-table td { padding: 2px 5px; text-align: left; border-bottom: 1px solid var(--line); }
.comps-table .comp-row { font-weight: 600; }
.comps-table .sale-row { color: var(--muted); }

.detail-panel table { border-collapse: collapse; }
.detail-panel th,
.detail-panel td { padding: 2px 5px; text-align: left; border-bottom: 1px solid var(--line); }

.sales-panel table { border-collapse: collapse; }
.sales-panel th,
.sales-panel td { padding: 2px 5px; text-align: left; border-bottom: 1px solid var(--line); }

.finding-card {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  border-left: 3px solid var(--line);
}
.finding-card.high { border-left-color: #d7191c; background: #fef2f2; }
.finding-card.medium { border-left-color: #f59e0b; background: #fffbeb; }
.finding-card.info { border-left-color: #3b82f6; background: #eff6ff; }
.finding-type { font-weight: 700; font-size: 10px; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.finding-desc { color: var(--ink); }
