@import url("tokens.css");
@import url("responsive.css");

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--surface-muted);
  color: var(--text-primary);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(11, 94, 166, 0.24);
  outline-offset: 2px;
}

.map-shell {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.app-header {
  position: relative;
  z-index: 100000;
  background: var(--surface);
  border-top: none;
  box-shadow: 0 2px 14px rgba(23, 43, 58, 0.08);
}

.app-header.topbar-parent {
  width: 100%;
  height: auto;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
}

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
}

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

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

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

.title-bar {
  min-width: 0;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
}

.title-bar h1 {
  margin: 0;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 750;
  line-height: 1.12;
}

.topbar h1 {
  margin: 0;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 750;
  line-height: 1.12;
  letter-spacing: 0;
}

.brand-subtitle {
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.3;
}

.header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.about-data-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--funasa-blue-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.about-data-button:hover,
.about-data-button:focus-visible {
  border-color: var(--funasa-blue);
  background: var(--funasa-blue-soft);
  outline: 0;
}

.about-data-icon,
.filter-scope-info {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: inline-grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.view-switch {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: #edf2f5;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.view-switch label {
  min-width: 92px;
  height: 34px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  padding: 0 14px;
  border-radius: 5px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.view-switch label:has(input:checked) {
  background: var(--surface);
  color: var(--funasa-blue-dark);
  box-shadow: 0 2px 7px rgba(23, 43, 58, 0.12);
}

.view-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.filter-disclosure {
  min-width: 0;
  grid-column: 1 / -1;
  background: var(--surface);
}

.filter-disclosure-summary {
  width: 100%;
  display: none;
  border: 0;
  background: var(--surface);
}

.filter-disclosure > .toolbar {
  display: grid !important;
}

.filter-disclosure > .table-controls {
  display: grid !important;
}

.toolbar {
  grid-template-columns: repeat(16, minmax(0, 1fr));
  grid-template-areas:
    "municipality municipality municipality search search search source source source region region uf uf pmsb pmsb pmsb"
    "year year status status status program program program transfergov transfergov transfergov action action action clear clear";
  align-items: end;
  gap: 8px;
  padding: 8px 14px 10px;
}

.map-search-field,
.table-search-field {
  grid-area: search;
}

.municipality-field {
  grid-area: municipality;
}

.source-field {
  grid-area: source;
}

.region-field {
  grid-area: region;
}

.uf-field {
  grid-area: uf;
}

.year-field {
  grid-area: year;
}

.convention-status-field {
  grid-area: status;
}

.program-field {
  grid-area: program;
}

.transfergov-program-field {
  grid-area: transfergov;
}

.action-field {
  grid-area: action;
}

.pmsb-field {
  grid-area: pmsb;
}

.filter-actions,
.table-filter-actions {
  grid-area: clear;
}

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

.filter-field label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}

.filter-field label > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-field label > span:first-child {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.filter-scope-info {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
  color: var(--funasa-blue-dark);
  cursor: help;
}

.filter-field .dash-dropdown-wrapper,
.filter-field .dash-dropdown,
.point-source-filter,
.uf-filter,
.year-filter,
.convention-status-filter,
.program-filter,
.transfergov-program-filter,
.action-filter,
.pmsb-filter {
  width: 100%;
  min-width: 0;
}

.filter-field .dash-dropdown,
.Select-control {
  min-height: 36px;
  border: 1px solid var(--border) !important;
  border-radius: 5px !important;
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: none !important;
}

.filter-field .dash-dropdown:hover,
.filter-field .dash-dropdown:focus,
.filter-field .dash-dropdown[data-state="open"],
.Select.is-focused > .Select-control,
.Select-control:hover {
  border-color: var(--funasa-blue) !important;
}

.Select-placeholder,
.Select-value,
.Select-input,
.filter-field .dash-dropdown-value,
.filter-field .dash-dropdown-option {
  font-size: 13px;
}

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

.Select-menu-outer,
.filter-field .dash-dropdown-options {
  border: 1px solid var(--border) !important;
  border-radius: 5px !important;
  background: var(--surface);
  box-shadow: var(--shadow-lg) !important;
  z-index: 1000 !important;
}

.filter-field .VirtualizedSelectOption {
  min-width: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.program-field .Select-menu-outer {
  right: 0;
  left: auto;
  width: min(560px, calc(100vw - 28px));
  min-width: 100%;
}

.program-field .VirtualizedSelectOption {
  display: -webkit-box;
  padding-top: 6px;
  padding-bottom: 6px;
  line-height: 18px;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.transfergov-program-field .Select-menu-outer {
  right: 0;
  left: auto;
  width: min(680px, calc(100vw - 28px));
  min-width: 100%;
}

.transfergov-program-field .VirtualizedSelectOption,
.action-field .VirtualizedSelectOption {
  display: -webkit-box;
  width: 100% !important;
  max-width: 100%;
  box-sizing: border-box;
  padding-top: 6px;
  padding-bottom: 6px;
  line-height: 18px;
  overflow-wrap: anywhere;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.transfergov-program-field .Select-menu,
.transfergov-program-field .ReactVirtualized__Grid,
.action-field .Select-menu,
.action-field .ReactVirtualized__Grid {
  overflow-x: hidden !important;
}

.action-field .Select-menu-outer {
  right: 0;
  left: auto;
  width: min(560px, calc(100vw - 28px));
  min-width: 100%;
}

.program-field .Select-value-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.convention-status-field .Select-menu-outer {
  width: min(360px, calc(100vw - 28px));
  min-width: 100%;
}

.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: 260px;
  overflow: auto;
}

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

.search-field input {
  width: 100%;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
}

.search-field input:hover,
.search-field input:focus {
  border-color: var(--funasa-blue);
  outline: 0;
}

.filter-actions {
  display: flex;
  align-items: end;
}

.reset-filters {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--funasa-blue-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.reset-filters:hover {
  border-color: var(--funasa-blue);
  background: var(--funasa-blue-soft);
}

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

#main-tabs {
  display: none !important;
}

#main-tabs-parent > .tab-content {
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  flex: 1;
  overflow: hidden;
}

.map-view {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.metric-grid {
  min-height: 64px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  margin: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.metric {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 9px 18px;
  border-right: 1px solid var(--border);
  border-top: 2px solid transparent;
}

.metric:first-child {
  border-top-color: var(--funasa-red);
}

.metric:last-child {
  border-right: 0;
}

.metric span,
.detail-row span {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
}

.metric strong {
  min-width: 0;
  color: var(--funasa-blue-dark);
  font-size: 22px;
  font-weight: 750;
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

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

.map-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #dce8ed;
}

.map-context-bar {
  min-width: 0;
  min-height: 42px;
  display: grid;
  gap: 4px;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--border);
}

.map-context-main {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.map-result-label {
  flex: 0 0 auto;
  color: var(--funasa-blue-dark);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.map-legend {
  min-width: 0;
  display: flex;
  position: static;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  overflow: hidden;
}

.map-legend-item {
  min-width: max-content;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.source-swatch {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  display: inline-block;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(23, 43, 58, 0.12);
}

.municipality-data-swatch {
  width: 11px;
  height: 9px;
  flex: 0 0 11px;
  display: inline-block;
  border: 1px solid #9bafbd;
  border-radius: 2px;
  background: #dcecf5;
}

.multi-source-swatch {
  width: 11px;
  height: 11px;
  flex-basis: 11px;
  background: var(--funasa-blue-dark);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--funasa-blue-dark);
}

.map-marker-note {
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.3;
}

.about-data-layer {
  position: fixed;
  inset: 0;
  z-index: 100100;
  display: grid;
  place-items: center;
  visibility: hidden;
  pointer-events: none;
}

.about-data-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(23, 43, 58, 0.46);
  opacity: 0;
  cursor: default;
  transition: opacity 140ms ease;
}

.about-data-dialog {
  width: min(760px, calc(100vw - 48px));
  max-height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  position: relative;
  z-index: 1;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 64px rgba(23, 43, 58, 0.28);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.about-data-layer.is-open {
  visibility: visible;
  pointer-events: auto;
}

.about-data-layer.is-open .about-data-backdrop,
.about-data-layer.is-open .about-data-dialog {
  opacity: 1;
}

.about-data-layer.is-open .about-data-dialog {
  transform: translateY(0);
}

.about-data-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.about-data-header h2 {
  margin: 0;
  color: var(--funasa-blue-dark);
  font-size: 20px;
  line-height: 1.2;
}

.about-data-close {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--funasa-red);
  font-size: 22px;
  cursor: pointer;
}

.about-data-close:hover,
.about-data-close:focus-visible {
  border-color: var(--funasa-red);
  background: var(--funasa-red-soft);
  outline: 0;
}

.about-data-content {
  overflow: auto;
  padding: 16px 20px 20px;
  color: var(--text-primary);
}

.about-data-content > p:first-child {
  margin-top: 0;
  color: var(--funasa-blue-dark);
  font-size: 14px;
  font-weight: 600;
}

.about-data-content section {
  padding: 15px 0;
  border-top: 1px solid var(--border);
}

.about-data-content h3 {
  margin: 0 0 7px;
  color: var(--funasa-blue-dark);
  font-size: 14px;
}

.about-data-content p,
.about-data-content li,
.about-data-content dd {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.about-data-content p {
  margin: 6px 0;
}

.about-data-content ul {
  display: grid;
  gap: 6px;
  margin: 7px 0 0;
  padding-left: 20px;
}

.about-source-list strong,
.about-source-list small {
  display: block;
}

.about-source-list strong {
  color: var(--text-primary);
}

.about-source-list small {
  margin-top: 2px;
  color: var(--funasa-blue-dark);
  font-size: 11px;
}

.about-definitions {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.about-definitions > summary {
  padding: 13px 0;
  color: var(--funasa-blue-dark);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.about-definitions dl {
  margin: 0;
}

.about-definition-row {
  display: grid;
  grid-template-columns: minmax(145px, 0.34fr) minmax(0, 1fr);
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.about-definition-row dt {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.4;
}

.about-definition-row dd {
  display: grid;
  gap: 3px;
  margin: 0;
}

.about-definition-row small {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}

.about-loaded-at {
  margin: 13px 0 0 !important;
  color: var(--funasa-blue-dark) !important;
  font-size: 12px !important;
  font-weight: 700;
}

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

.maplibregl-canvas:focus {
  outline: 2px solid rgba(11, 94, 166, 0.72);
  outline-offset: -2px;
}

.detail-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: block;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.detail-sheet-handle {
  display: none;
}

.detail-panel-body {
  display: block;
  height: 100%;
  overflow: auto;
  padding: 20px 20px 24px;
  position: relative;
}

.clear-selection {
  width: 32px;
  height: 32px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--funasa-red);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
}

.clear-selection:hover {
  border-color: var(--funasa-red);
  background: var(--funasa-red-soft);
}

.detail-content {
  min-width: 0;
}

.detail-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--funasa-red);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
}

.detail-content h2 {
  max-width: calc(100% - 38px);
  margin: 0;
  color: var(--funasa-blue-dark);
  font-size: 22px;
  font-weight: 750;
  line-height: 1.16;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.detail-content p {
  margin: 6px 0 16px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.overview-source-list {
  display: grid;
  border-top: 1px solid var(--border);
}

.overview-source-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
}

.overview-source-row > span:nth-child(2) {
  min-width: 0;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.overview-source-row strong {
  color: var(--funasa-blue-dark);
  font-size: 15px;
}

.overview-source-values {
  min-width: 92px;
  display: grid;
  justify-items: end;
  gap: 1px;
  text-align: right;
}

.overview-source-values > span {
  color: var(--text-primary);
  font-size: 11px;
  line-height: 1.25;
}

.overview-source-values > small {
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.25;
}

.overview-section-title {
  margin: 20px 0 8px;
  color: var(--funasa-blue-dark);
  font-size: 14px;
  line-height: 1.3;
}

.overview-linkage {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.overview-linkage > div {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px 8px;
}

.overview-linkage > div:nth-child(even) {
  border-left: 1px solid var(--border);
}

.overview-linkage > div:nth-child(n + 3) {
  border-top: 1px solid var(--border);
}

.overview-linkage span {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.3;
}

.overview-linkage strong {
  color: var(--funasa-blue-dark);
  font-size: 17px;
}

.overview-linkage-note {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}

.municipality-heading {
  padding-right: 34px;
}

.action-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 16px;
}

.action-tag {
  max-width: 100%;
  padding: 5px 7px;
  border: 1px solid color-mix(in srgb, var(--tag-color) 42%, white);
  border-left: 3px solid var(--tag-color);
  border-radius: 4px;
  background: color-mix(in srgb, var(--tag-color) 8%, white);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.municipality-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.municipality-metric {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-alt);
}

.municipality-metric span {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.municipality-metric strong {
  color: var(--funasa-blue-dark);
  font-size: 17px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.evidence-title {
  margin: 0 0 7px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 750;
}

.detail-load-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 47px;
  padding: 10px 2px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
}

.detail-load-status.is-error {
  color: var(--funasa-red);
}

.detail-load-spinner {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border: 2px solid var(--border);
  border-top-color: var(--funasa-blue);
  border-radius: 50%;
  animation: detail-load-spin 700ms linear infinite;
}

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

.source-detail-section {
  border-top: 1px solid var(--border);
}

.source-detail-section:last-child {
  border-bottom: 1px solid var(--border);
}

.source-detail-summary {
  min-height: 47px;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 9px;
  padding: 8px 2px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

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

.source-detail-summary:hover,
.convention-summary:hover {
  background: var(--funasa-blue-soft);
}

.source-detail-toggle {
  color: var(--funasa-blue);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  text-align: center;
  transition: transform 140ms ease;
}

.source-detail-section[open] .source-detail-toggle {
  transform: rotate(45deg);
}

.source-detail-body {
  padding: 0 2px 10px 20px;
}

.detail-block {
  padding: 7px 0;
}

.detail-block h3 {
  margin: 0 0 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 750;
}

.detail-row {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 5px 0;
}

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

.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: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.convention-item.is-filter-match {
  border-color: var(--funasa-blue);
  box-shadow: inset 3px 0 0 var(--funasa-blue);
}

.convention-item.is-filter-nonmatch {
  background: #f7f9fa;
}

.convention-filter-summary {
  display: grid;
  gap: 3px;
  margin: 9px 0 4px;
  padding: 9px 10px;
  border-left: 3px solid var(--funasa-blue);
  background: var(--funasa-blue-soft);
}

.convention-filter-summary strong {
  color: var(--funasa-blue-dark);
  font-size: 12px;
}

.convention-filter-summary span {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}

.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-toggle {
  color: var(--funasa-blue);
  font-size: 20px;
  line-height: 1;
  transition: transform 140ms ease;
}

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

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

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

.convention-match-badge {
  width: fit-content;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--funasa-blue);
  color: #fff !important;
  font-size: 9px !important;
  font-weight: 750;
  line-height: 1.3 !important;
}

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

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

.convention-program-preview {
  color: var(--funasa-blue-dark) !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

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

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

.link-list a {
  color: var(--funasa-blue-dark);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

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

.table-workspace {
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 8px;
  padding: 12px 14px 14px;
  background: var(--surface-alt);
  overflow: hidden;
  position: relative;
}

.table-controls {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  grid-template-areas:
    "municipality municipality municipality search search search source source source region region uf uf pmsb pmsb pmsb"
    "year year status status status program program program transfergov transfergov transfergov action action action clear clear";
  gap: 8px;
  align-items: end;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  position: relative;
  z-index: 35;
}

.table-filter-actions {
  display: flex;
  align-items: flex-end;
}

.table-reset-filters {
  min-height: 36px;
  white-space: nowrap;
}

.table-view-bar {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.table-view-switch {
  min-width: max-content;
  display: flex;
  align-items: center;
  padding: 3px;
  position: relative;
}

.table-view-switch label {
  min-height: 34px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  padding: 0 14px;
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.table-view-switch label:last-child {
  border-right: 0;
}

.table-view-switch label:has(input:checked) {
  background: var(--funasa-blue-soft);
  color: var(--funasa-blue-dark);
  box-shadow: inset 0 -2px 0 var(--funasa-blue);
}

.table-view-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.table-result-toolbar {
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 3px 0;
}

.table-summary {
  min-width: 0;
  color: var(--funasa-blue-dark);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-result-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.table-page-size-control {
  display: flex;
  align-items: center;
  gap: 7px;
}

.table-page-size-control label {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.table-page-size-control .dash-dropdown,
.table-page-size-control .Select-control {
  width: 74px;
  min-height: 34px;
  border-color: var(--border) !important;
  border-radius: 5px !important;
  box-shadow: none !important;
}

.table-export-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--funasa-blue);
  border-radius: 5px;
  background: var(--surface);
  color: var(--funasa-blue-dark);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.table-export-primary {
  background: var(--funasa-blue);
  color: #fff;
}

.table-export-button:hover:not(:disabled) {
  border-color: var(--funasa-red);
  color: var(--funasa-red);
}

.table-export-primary:hover:not(:disabled) {
  background: var(--funasa-red);
  color: #fff;
}

.table-export-button:disabled {
  opacity: 0.42;
  cursor: default;
}

.export-icon {
  font-size: 15px;
  line-height: 1;
}

.table-loading,
.table-loading-shell,
.table-loading-shell > div,
.table-loading-shell > div > div,
.table-loading .dash-spinner-container {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.table-results {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.table-results.is-hidden {
  display: none;
}

.desktop-table-shell {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.dash-table-container {
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.dash-table-container .dash-spreadsheet-container {
  min-height: 0;
  height: 100%;
  border-radius: 6px;
}

.dash-table-container .dash-spreadsheet-inner table {
  width: 100%;
}

.dash-table-container .dash-cell div {
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-table-container .dash-cell.column-3 .dash-cell-value,
.dash-table-container .dash-cell[data-dash-column="acoes_presentes"] .dash-cell-value {
  overflow: hidden;
}

.dash-table-container .dash-cell[data-dash-column="acoes_presentes"] p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-action-source {
  display: inline;
  margin-right: 8px;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.dash-table-container .dash-cell.focused {
  border-color: var(--funasa-blue) !important;
  background: var(--funasa-blue-soft) !important;
  box-shadow: inset 0 0 0 1px var(--funasa-blue);
}

.dash-table-container .dash-spreadsheet-inner tbody tr:hover td {
  background: #f3f8fb !important;
}

.dash-table-container .previous-next-container {
  min-height: 42px;
  margin: 6px 0 0;
  padding: 0 2px;
}

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

.dash-table-container button {
  min-width: 34px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--funasa-blue);
  border-radius: 5px;
  background: var(--funasa-blue);
  color: white;
  cursor: pointer;
}

.dash-table-container button:disabled {
  opacity: 0.42;
  cursor: default;
}

.table-mobile-list,
.table-mobile-pagination {
  display: none;
}

.table-empty-state {
  display: none;
}

.table-empty-state.is-visible {
  min-height: 260px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  text-align: center;
}

.table-empty-state strong {
  color: var(--text-primary);
  font-size: 17px;
}

.table-empty-state p {
  margin: 5px 0 15px;
}

.table-detail-layer {
  position: absolute;
  inset: 0;
  z-index: 70;
  overflow: hidden;
  pointer-events: none;
}

.table-detail-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: rgba(23, 43, 58, 0.18);
  opacity: 0;
  cursor: pointer;
  transition: opacity 160ms ease;
}

.table-detail-drawer {
  width: min(470px, 94%);
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  position: absolute;
  inset: 0 0 0 auto;
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: -16px 0 36px rgba(23, 43, 58, 0.2);
  transform: translateX(102%);
  transition: transform 190ms ease;
}

.table-detail-opening {
  position: absolute;
  inset: 52px 0 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 24px;
  color: var(--text-secondary);
  background: var(--surface);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.table-detail-layer.is-pending .table-detail-content {
  visibility: hidden;
}

.table-detail-layer.is-pending .table-detail-opening {
  display: flex;
}

.table-detail-layer.is-open {
  pointer-events: auto;
}

.table-detail-layer.is-open .table-detail-backdrop {
  opacity: 1;
}

.table-detail-layer.is-open .table-detail-drawer {
  transform: translateX(0);
}

.table-detail-header {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px 8px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--funasa-blue-dark);
}

.table-detail-header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-detail-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--funasa-red);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.table-detail-content {
  min-height: 0;
  padding: 18px;
  overflow: auto;
}

/* ============================================================
   LOADER INSTITUCIONAL FUNASA — padrão do dashboard INEP
   ============================================================ */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background: rgba(245, 247, 250, 0.34);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-overlay.loading-done {
  opacity: 0;
  pointer-events: none;
}

/* Loader institucional em mosaico, compartilhado com o dashboard INEP. */
.funasa-loader-v3 {
  position: relative;
  z-index: 2147483647;
  width: 242px;
  height: 110px;
  overflow: visible;
}

.funasa-loader-v3 img {
  display: block;
  width: 242px;
  height: 110px;
  object-fit: contain;
}

.funasa-loader-v3__base {
  position: absolute;
  inset: 0;
  filter: grayscale(1);
  opacity: 0.16;
}

.funasa-loader-v3__tiles,
.funasa-loader-v3__tile,
.funasa-loader-v3__tile img {
  position: absolute;
  inset: 0;
}

.funasa-loader-v3__tile {
  opacity: 0;
  transform: translate3d(0, 9px, 0);
  animation: funasa-mosaic-v3 2.65s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  will-change: opacity, transform;
}

/* As divisões acompanham os espaços da assinatura para não cortar letras. */
.funasa-loader-v3__tile--1 { clip-path: inset(0 71% 0 0); }
.funasa-loader-v3__tile--2 { animation-delay: 0.09s; clip-path: inset(0 56% 0 29%); }
.funasa-loader-v3__tile--3 { animation-delay: 0.18s; clip-path: inset(0 39% 0 44%); }
.funasa-loader-v3__tile--4 { animation-delay: 0.27s; clip-path: inset(0 21% 0 61%); }
.funasa-loader-v3__tile--5 { animation-delay: 0.36s; clip-path: inset(0 0 0 79%); }

@keyframes funasa-mosaic-v3 {
  0%, 10% { opacity: 0; transform: translate3d(0, 9px, 0); }
  34%, 76% { opacity: 1; transform: translate3d(0, 0, 0); }
  100% { opacity: 0; transform: translate3d(0, -7px, 0); }
}

@media (max-width: 575.98px) {
  .funasa-loader-v3,
  .funasa-loader-v3 img {
    width: 190px;
    height: 86px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .funasa-loader-v3__tile {
    animation-duration: 4s;
    transform: none;
  }
}

/* ── Bottom Navigation (Mobile) ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: none;
  justify-content: space-around;
  align-items: center;
  padding: 0.5rem 0;
  padding-bottom: env(safe-area-inset-bottom, 0.5rem);
  z-index: 1100;
  height: 60px;
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.25rem;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
}

.bottom-nav__item--active {
  color: var(--funasa-blue);
}

@media (max-width: 767px) {
  .bottom-nav {
    display: flex;
  }
}
