:root {
  color-scheme: light;
  --bg: #f4f7f2;
  --panel: #ffffff;
  --panel-alt: #f7faf5;
  --text: #13251a;
  --muted: #58665d;
  --line: #d7e1d6;
  --line-strong: #b8c7b5;
  --accent: #005826;
  --accent-strong: #003f1b;
  --accent-secondary: #688a3a;
  --accent-soft: #e8f2e6;
  --accent-warm: #f7c600;
  --focus: #1d70b8;
  --warning: #b7791f;
  --gov-gray: #808285;
  --shadow: 0 12px 30px rgba(19, 37, 26, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  text-rendering: optimizeLegibility;
}

.map-shell {
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(340px, 0.72fr) minmax(620px, 1.28fr);
  align-items: center;
  gap: 18px;
  min-height: 92px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(19, 37, 26, 0.05);
  position: relative;
  z-index: 30;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-secondary) 72%, var(--accent-warm) 100%);
}

.brand-block {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  width: 76px;
  height: 58px;
  object-fit: contain;
  display: block;
}

.brand-copy {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  color: var(--text);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: 0;
  max-width: 520px;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(220px, 1.2fr) minmax(150px, 0.8fr);
  align-items: end;
  gap: 9px;
  padding: 10px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-field {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.filter-field label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.point-source-filter,
.uf-filter,
.pmsb-filter {
  min-width: 0;
}

.Select-control {
  min-height: 36px;
  border-color: var(--line) !important;
  border-radius: 6px !important;
  box-shadow: none !important;
}

.Select.is-focused > .Select-control,
.Select-control:hover {
  border-color: var(--accent) !important;
}

.Select-placeholder,
.Select-value,
.Select-input {
  font-size: 13px;
}

.Select-menu-outer {
  border-color: var(--line) !important;
  border-radius: 0 0 7px 7px !important;
  box-shadow: var(--shadow) !important;
  z-index: 20 !important;
}

.search-field input {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 0 10px;
}

.search-field input:focus {
  border-color: var(--accent);
  outline: 0;
}

button {
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-strong);
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.map-workspace {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
}

#main-tabs-parent {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

#main-tabs {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #eef5ec;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 10;
}

.content-tab {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 112px;
  height: 34px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line) !important;
  border-radius: 6px !important;
  background: #ffffff !important;
  color: var(--muted) !important;
  font-weight: 800 !important;
  padding: 0 18px !important;
  position: relative;
  z-index: 11;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.content-tab:hover {
  border-color: var(--accent) !important;
  color: var(--accent-strong) !important;
}

#main-tabs-parent > .tab-content {
  min-height: 0;
  flex: 1;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.content-tab.selected {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #ffffff !important;
  box-shadow: 0 5px 14px rgba(0, 88, 38, 0.18);
}

.content-tab.selected:hover {
  background: var(--accent-strong) !important;
  color: #ffffff !important;
}

.map-panel,
.map-loading,
.municipality-map {
  min-height: 0;
  height: 100%;
}

.map-panel {
  min-width: 0;
  background: #d7e5e7;
}

.detail-panel {
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding: 14px 16px;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.table-workspace {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  overflow: hidden;
}

.table-workspace > * {
  min-width: 0;
}

.table-controls {
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(120px, 0.6fr) minmax(190px, 0.9fr) minmax(130px, 0.65fr) minmax(240px, 1.25fr);
  gap: 10px;
  align-items: end;
  position: relative;
  z-index: 35;
  padding: 10px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-field .dash-dropdown-wrapper,
.filter-field .dash-dropdown {
  width: 100%;
  min-width: 0;
}

.filter-field .dash-dropdown {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  box-shadow: none;
}

.filter-field .dash-dropdown:hover,
.filter-field .dash-dropdown:focus,
.filter-field .dash-dropdown[data-state="open"] {
  border-color: var(--accent);
  outline: 0;
}

.filter-field .dash-dropdown-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-field .dash-dropdown-content {
  width: var(--radix-popover-trigger-width) !important;
  min-width: var(--radix-popover-trigger-width) !important;
  max-width: min(var(--radix-popover-trigger-width), calc(100vw - 28px)) !important;
  z-index: 1000 !important;
}

.filter-field .dash-dropdown-options {
  width: 100% !important;
  max-height: 240px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow: auto;
}

.filter-field .dash-dropdown-option {
  min-height: 30px;
  color: var(--text);
  font-size: 13px;
}

.filter-field .dash-dropdown-option:hover,
.filter-field .dash-dropdown-option[aria-selected="true"] {
  background: var(--accent-soft);
}

.table-summary {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  position: relative;
  z-index: 2;
  padding-left: 2px;
}

.table-convention-detail {
  max-height: 260px;
  overflow: auto;
  padding: 10px 12px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 7px;
}

.table-convention-detail > p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.table-convention-detail h2 {
  margin: 0;
  color: var(--text);
  font-size: 17px;
}

.table-convention-detail > .detail-block {
  padding-bottom: 0;
}

.dash-table-container {
  min-height: 0;
  position: relative;
  z-index: 1;
}

.dash-table-container .dash-spreadsheet-container {
  border-radius: 7px;
}

.dash-table-container .previous-next-container {
  margin-top: 8px;
}

.dash-table-container .page-number {
  color: var(--text);
  font-weight: 700;
}

.dash-table-container button {
  min-width: 34px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
}

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

.metric {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 7px;
}

.metric span,
.detail-row span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  text-transform: uppercase;
}

.metric strong {
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
}

.detail-content h2 {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  line-height: 1.18;
  letter-spacing: 0;
}

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

.detail-block {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.detail-block h3 {
  margin: 0 0 9px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
}

.convention-list {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
  max-height: 340px;
  overflow: auto;
  padding: 0 6px 0 0;
  list-style: none;
}

.convention-item {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.convention-summary {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  cursor: pointer;
  list-style: none;
}

.convention-summary::-webkit-details-marker {
  display: none;
}

.convention-summary:hover {
  background: var(--accent-soft);
}

.convention-summary:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: -3px;
}

.convention-toggle {
  color: var(--accent-strong);
  font-size: 20px;
  line-height: 1;
  transition: transform 0.16s ease;
}

.convention-item details[open] .convention-toggle {
  transform: rotate(90deg);
}

.convention-summary-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.convention-summary-text strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.convention-summary-text small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.convention-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.convention-body {
  padding: 5px 11px 8px 33px;
  border-top: 1px solid var(--line);
}

.convention-body .detail-row {
  padding: 4px 0;
}

.table-convention-detail .convention-list {
  max-height: none;
  overflow: visible;
}

.detail-row {
  display: grid;
  gap: 4px;
  padding: 6px 0;
}

.detail-row strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.link-list {
  display: grid;
  gap: 7px;
  margin: 2px 0 0;
  max-height: 340px;
  overflow: auto;
  padding-left: 18px;
  padding-right: 6px;
}

.link-list li::marker {
  color: var(--accent);
}

.link-list a {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.link-list a:hover {
  color: var(--focus);
}

.link-list strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
