:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #5d6875;
  --border: #d8dee6;
  --accent: #2364a2;
  --accent-dark: #164b7d;
  --county-fill: #3f8fc5;
  --county-line: #1f5f8b;
  --warning: #8a5b00;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

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

a {
  color: var(--accent-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  height: 100vh;
  min-height: 620px;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding: 20px;
  z-index: 500;
}

.brand {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.05;
  margin: 0 0 4px;
}

.brand p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  margin: 0;
}

.panel-section {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.panel-section-compact {
  padding-bottom: 10px;
}

.panel-section-compact .select-row select {
  min-height: 32px;
  padding: 4px 10px;
}

.panel-section h2 {
  font-size: 13px;
  letter-spacing: 0;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.panel-section-compact h2 {
  margin-bottom: 6px;
}

.admin-cache-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.county-boundary-section {
  background: #f8fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
}

.county-boundary-header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.county-boundary-label {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.admin-form-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.checkbox-group {
  align-items: center;
  display: flex !important;
  gap: 16px;
  grid-template-columns: unset;
}

.admin-cache-actions .admin-help-text {
  margin: 0;
}

.layer-group {
  padding: 4px 0;
}

.layer-group + .layer-group {
  border-top: 1px solid var(--border);
  margin-top: 2px;
  padding-top: 6px;
}

.layer-group-label {
  color: var(--muted);
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
  padding: 0 8px;
  text-transform: uppercase;
}

summary.layer-group-label {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

summary.layer-group-label::-webkit-details-marker {
  display: none;
}

summary.layer-group-label::after {
  content: "▸";
  float: right;
  font-size: 11px;
  opacity: 0.5;
}

details[open] > summary.layer-group-label::after {
  content: "▾";
}

.layer-group-help {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  margin: 0 0 4px;
  padding: 0 8px;
}

.toggle-row-planned span {
  color: var(--muted);
}

.toggle-row:has(input:disabled) {
  cursor: default;
  opacity: 0.55;
}

.toggle-row:has(input:disabled):hover {
  background: transparent;
}

.toggle-row {
  align-items: center;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  line-height: 1.25;
  min-height: 34px;
  padding: 6px 8px;
}

.toggle-row:hover {
  background: #eef3f7;
}

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

.toggle-row span {
  font-size: 14px;
}

.select-row {
  align-items: center;
  display: flex;
  gap: 8px;
}

.select-row span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.select-row select {
  appearance: none;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.select-row select:focus {
  border-color: var(--accent);
  outline: 2px solid #c9dceb;
  outline-offset: 1px;
}

.notice-section div {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  padding: 2px 0;
}

.local-context-section {
  display: grid;
  gap: 6px;
}

.local-context-button {
  justify-self: start;
}

.county-details {
  font-size: 14px;
  line-height: 1.45;
}

.county-details h3 {
  font-size: 20px;
  margin: 0 0 10px;
}

.detail-links {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}

.detail-links a {
  background: #f0f6fc;
  border: 1px solid #c4d8ea;
  border-radius: 6px;
  color: var(--accent-dark);
  display: block;
  padding: 8px 10px;
  text-decoration: none;
}

.detail-links a::after {
  content: " ↗";
  font-size: 11px;
  opacity: 0.6;
}

.detail-links a:hover {
  background: #e4eef8;
  border-color: var(--accent);
}

.detail-links span {
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  display: block;
  font-size: 12px;
  padding: 8px 10px;
}

.advisory {
  background: #edf4fa;
  border: 1px solid #c9dceb;
  border-radius: 6px;
  color: #24485f;
  font-size: 13px;
  margin-top: 12px;
  padding: 10px;
}

.sources-list {
  display: grid;
  gap: 9px;
}

.source-item {
  font-size: 13px;
  line-height: 1.35;
}

.source-status {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.search-form {
  display: flex;
  gap: 6px;
}

.search-form input {
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  flex: 1;
  font: inherit;
  min-height: 36px;
  padding: 6px 10px;
}

.search-form input:focus {
  border-color: var(--accent);
  outline: 2px solid #c9dceb;
  outline-offset: 1px;
}

.search-form button {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  padding: 6px 12px;
  white-space: nowrap;
}

.search-form button:hover {
  background: var(--accent-dark);
}

.search-form button:disabled {
  background: var(--muted);
  border-color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}

.utility-context-section {
  margin-bottom: 4px;
}

.row-context-section {
  margin-bottom: 4px;
}

.site-section {
  background: #f8fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  margin-top: 8px;
  padding: 10px 12px;
}

.site-section-label {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 10px;
  font-weight: 700;
  gap: 6px;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.badge {
  border-radius: 10px;
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 1px 7px;
  text-transform: uppercase;
  vertical-align: middle;
}

.badge-found {
  background: #e6f4ea;
  color: #2d6a37;
}

.badge-planned {
  background: #fef3cd;
  color: #7a5200;
}

.badge-muted {
  background: #eff1f3;
  color: #5d6875;
}

.badge-info {
  background: #e8f0fb;
  color: #1a4a7a;
}

.row-context-item {
  margin-bottom: 6px;
}

.row-context-label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
}

.row-context-value {
  display: block;
  font-size: 13px;
}

.row-context-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: 8px 0 0;
}

.nearby-road-context-header {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.nearby-road-context-header .site-section-label {
  margin: 0;
}

.small-action-button {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 5px 8px;
  white-space: nowrap;
}

.small-action-button:hover {
  background: #f0f6fc;
  border-color: var(--accent);
}

.small-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.address-result-section {
  margin-bottom: 4px;
}

.site-county-section {
  margin-bottom: 4px;
}

.next-checks-section {
  margin-bottom: 4px;
}

.next-checks-list {
  list-style: none;
  margin: 6px 0 0;
  padding-left: 0;
}

.next-checks-list li {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 6px;
  padding-left: 16px;
  position: relative;
}

.next-checks-list li:last-child {
  margin-bottom: 0;
}

.next-checks-list li::before {
  color: var(--accent);
  content: "›";
  font-size: 15px;
  font-weight: 700;
  left: 0;
  line-height: 1.2;
  position: absolute;
}

.address-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
}

.address-coords {
  color: var(--muted);
  font-size: 12px;
}

.disclaimer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: auto;
}

.text-button {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  cursor: pointer;
  display: block;
  font: inherit;
  margin: 10px 0 0;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.text-button:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.map-wrap {
  height: 100%;
  min-width: 0;
  min-height: 100%;
  position: relative;
  width: 100%;
}

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

.leaflet-popup-content {
  font-size: 13px;
}

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

path.leaflet-interactive:focus,
svg path:focus {
  outline: none;
}

.popup-note {
  border-top: 1px solid var(--border);
  color: var(--muted);
  margin-top: 8px;
  padding-top: 8px;
}

.identify-popup {
  display: grid;
  gap: 10px;
  min-width: 220px;
}

.identify-section {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

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

.identify-section h3 {
  font-size: 13px;
  margin: 0 0 5px;
  text-transform: uppercase;
}

.identify-section p {
  margin: 4px 0;
}

.identify-more {
  color: var(--muted);
  font-size: 12px;
}

.modal-backdrop {
  align-items: center;
  background: rgba(23, 33, 43, 0.42);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 1200;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(23, 33, 43, 0.28);
  max-height: min(760px, calc(100vh - 40px));
  max-width: 720px;
  overflow: hidden;
  width: min(100%, 720px);
}

.modal-header {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 16px 18px;
}

.modal-header h2 {
  font-size: 20px;
  margin: 0;
}

.icon-button {
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  min-height: 34px;
  min-width: 34px;
}

.modal-content {
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 18px;
}

.modal-content h3 {
  font-size: 14px;
  margin: 0 0 7px;
  text-transform: uppercase;
}

.modal-content p,
.modal-content ul {
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
}

.modal-content ul {
  padding-left: 18px;
}

.admin-body {
  height: auto;
  min-height: 100%;
}

.admin-shell {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px;
}

.admin-header {
  align-items: start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.admin-header h1 {
  font-size: 30px;
  margin: 0 0 6px;
}

.admin-header p {
  color: var(--muted);
  margin: 0;
}

.admin-tabs {
  display: flex;
  gap: 8px;
}

.admin-tab,
.admin-actions button,
.admin-section-header button,
.inline-form button {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  min-height: 36px;
  padding: 8px 12px;
}

.admin-tab {
  background: #ffffff;
  color: var(--accent-dark);
}

.admin-tab.is-active {
  background: var(--accent);
  color: #ffffff;
}

.admin-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.admin-section-header {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.admin-section-header h2 {
  font-size: 22px;
  margin: 0 0 5px;
}

.admin-section-header p {
  color: var(--muted);
  margin: 0;
}

.admin-section-header input {
  min-width: 220px;
}

.admin-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
}

.admin-list {
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 620px;
  overflow-y: auto;
}

.county-link-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

.county-link-counts {
  color: var(--muted);
  font-size: 12px;
  min-width: 140px;
}

.county-link-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.county-filter-btn {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 3px 8px;
}

.county-filter-btn:hover {
  background: #eef3f7;
  border-color: var(--accent);
}

.county-filter-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.county-ind {
  border-radius: 3px;
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-left: 4px;
  padding: 1px 4px;
  text-transform: uppercase;
  vertical-align: middle;
}

.county-ind-gis {
  background: #e8f0fb;
  color: #1a4a7a;
}

.county-ind-rec {
  background: #e6f4ea;
  color: #2d6a37;
}

.admin-list button {
  background: #ffffff;
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  cursor: pointer;
  display: block;
  font: inherit;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.admin-list button:hover {
  background: #eef3f7;
}

.admin-list button.is-selected {
  background: #eef3f7;
  font-weight: 600;
}

.admin-list span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.admin-form label,
.inline-form {
  display: grid;
  gap: 6px;
}

.admin-form input,
.admin-form select,
.admin-form textarea,
.admin-section-header input,
.inline-form input {
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
  width: 100%;
}

.checkbox-row {
  align-items: center;
  display: flex !important;
  gap: 8px;
}

.checkbox-row input {
  width: auto;
}

.admin-actions {
  display: flex;
  gap: 10px;
}

.admin-actions .danger-button {
  background: #ffffff;
  border-color: #a43d3d;
  color: #8c2828;
}

.admin-inspector {
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-top: 18px;
}

.admin-inspector h3 {
  margin: 0 0 6px;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 12px 0;
}

#inspect-result {
  background: #17212b;
  border-radius: 6px;
  color: #f4f6f8;
  font-size: 12px;
  margin: 0;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-header-actions .text-button {
  margin: 0;
}

.admin-help-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 8px 0;
}

.admin-highlight-box {
  background: #fdf6e3;
  border-left: 4px solid #b58900;
  color: #657b83;
  font-family: monospace;
  font-size: 12px;
  padding: 8px 12px;
}


.small-button {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
}

.small-button:hover {
  background: #f8fafb;
  border-color: var(--accent);
}

.admin-status {
  color: var(--muted);
  min-height: 22px;
}

.admin-status.is-error {
  color: #8c2828;
}

.muted {
  color: var(--muted);
}

.details-panel {
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 20px rgba(23, 33, 43, 0.14);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  position: absolute;
  right: 0;
  top: 0;
  width: 320px;
  z-index: 600;
}

.details-panel[hidden] {
  display: none;
}

.details-panel-header {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.details-panel-title {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.details-panel-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

#copy-summary {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#copy-summary:hover {
  color: var(--accent-dark);
}

#copy-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.details-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.details-identify {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 12px;
}

.details-identify:empty {
  display: none;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 360px minmax(420px, 1fr);
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    border-bottom: 1px solid var(--border);
    border-right: 0;
    grid-row: 2;
    max-height: none;
  }

  .map-wrap {
    grid-row: 1;
  }

  .admin-header,
  .admin-section-header {
    display: grid;
  }

  .admin-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .details-panel {
    width: min(100%, 300px);
  }
}
