@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@300;400;500;600;700&display=swap');

/* ============================================================
   VARIÁVEIS E BASE
   ============================================================ */
:root {
  --bg: #07111f;
  --panel: rgba(14, 28, 47, 0.75);
  --panel-solid: #0e1c2f;
  --panel2: rgba(19, 38, 58, 0.75);
  --panel2-solid: #13263a;
  --panel3: rgba(26, 50, 78, 0.8);
  --border: rgba(41, 67, 92, 0.45);
  --border-solid: #29435c;
  --border2: rgba(28, 48, 73, 0.45);
  --text: #eaf2ff;
  --text2: #8fa8c3;
  --muted: #5d758f;
  --accent: #00b7ff;
  --accent2: #5cd3ff;
  --green: #35d07f;
  --red: #ef4444;
  --blue: #00b7ff;
  --purple: #9b7bff;
  --teal: #00d4c8;
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --radius: 8px;
  --radius-lg: 12px;
  --glass: blur(12px) saturate(180%);
  --glass-webkit: blur(12px) saturate(180%);
}

/* ==========================================================================
   STRUCTURAL LAYOUT SHELL
   Z-index scale:
   map 1, map controls 300, map panels 400, sidebar 500,
   bottom nav 700, header 800, modal/loading 1000+
   ========================================================================== */
:root {
  --layout-gap: 12px;
  --header-top: 12px;
  --header-height: 52px;
  --app-top: calc(var(--header-top) + var(--header-height) + var(--layout-gap));
  --bottom-nav-height: 58px;
  --bottom-safe-gap: 12px;
  --app-bottom: calc(
    var(--bottom-nav-height) + var(--bottom-safe-gap) + env(safe-area-inset-bottom, 0px)
  );
  --sidebar-width: 320px;
  --sidebar-left: var(--layout-gap);
  --sidebar-clear: calc(var(--sidebar-left) + var(--sidebar-width) + var(--layout-gap));
  --study-dock-width: 370px;
  --study-clear: calc(var(--layout-gap) + var(--study-dock-width) + var(--layout-gap));
  --map-control-gap: 12px;
  --z-map: 1;
  --z-map-controls: 300;
  --z-map-panels: 400;
  --z-sidebar: 500;
  --z-bottom-nav: 700;
  --z-header: 800;
  --z-modal: 1000;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

header {
  top: var(--header-top);
  left: var(--layout-gap);
  right: var(--layout-gap);
  height: var(--header-height);
  z-index: var(--z-header);
}

main,
.content,
.tab-panel {
  min-height: 0;
}

.content {
  z-index: var(--z-map);
}

.sidebar {
  top: var(--app-top);
  bottom: var(--app-bottom);
  left: var(--sidebar-left);
  width: var(--sidebar-width);
  z-index: var(--z-sidebar);
  padding-bottom: 10px;
  overscroll-behavior: contain;
}

.app-module {
  min-height: 0;
  padding-bottom: 14px;
}

.sidebar-primary-action {
  bottom: 0;
}

.tab-bar {
  left: var(--sidebar-clear);
  right: var(--layout-gap);
  bottom: calc(var(--bottom-safe-gap) + env(safe-area-inset-bottom, 0px));
  min-height: var(--bottom-nav-height);
  z-index: var(--z-bottom-nav);
  justify-content: center;
  padding: 8px 14px;
}

.tab-bar > .export-actions {
  display: none !important;
}

.tab-nav {
  justify-content: center;
  width: 100%;
}

.tab {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}

.tab-panel:not(#panel-map) {
  padding-left: var(--sidebar-clear);
  padding-top: var(--app-top);
  padding-right: var(--layout-gap);
  padding-bottom: calc(var(--app-bottom) + var(--layout-gap));
}

#panel-map {
  overflow: hidden;
}

#map {
  inset: 0 0 var(--app-bottom) 0;
  width: auto;
  height: auto;
  z-index: var(--z-map);
}

.ri-number-marker-shell {
  background: transparent;
  border: 0;
}

.ri-number-marker {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1.5px solid var(--ri-marker-color, var(--green));
  border-radius: 50%;
  background: rgba(7, 17, 29, 0.92);
  color: var(--text);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.32),
    0 0 0 2px rgba(234, 242, 255, 0.08);
  font-family: Inter, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    border-color 120ms ease;
}

.ri-number-marker-shell:hover .ri-number-marker {
  transform: scale(1.08);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.38),
    0 0 0 3px rgba(234, 242, 255, 0.12);
}

.municipal-office-marker-shell {
  background: transparent;
  border: 0;
}

.municipal-office-marker {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1.5px solid var(--accent2);
  border-radius: 50%;
  background: rgba(8, 34, 48, 0.94);
  color: var(--text);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.32),
    0 0 0 2px rgba(92, 211, 255, 0.1);
  font-family: Inter, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease;
}

.municipal-office-marker-shell:hover .municipal-office-marker {
  transform: scale(1.08);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.38),
    0 0 0 3px rgba(92, 211, 255, 0.16);
}

.urban-planning-marker-shell {
  background: transparent;
  border: 0;
}

.urban-planning-marker {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1.5px solid #ffd07a;
  border-radius: 7px;
  background: rgba(39, 26, 7, 0.94);
  color: var(--text);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.32),
    0 0 0 2px rgba(255, 208, 122, 0.1);
  font-family: Inter, system-ui, sans-serif;
  font-size: 9px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
  transform: rotate(45deg);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease;
}

.urban-planning-marker span {
  display: inline-flex;
  transform: rotate(-45deg);
}

.urban-planning-marker-shell:hover .urban-planning-marker {
  transform: rotate(45deg) scale(1.08);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.38),
    0 0 0 3px rgba(255, 208, 122, 0.16);
}

.extrajudicial-office-marker-shell {
  background: transparent;
  border: 0;
}

.extrajudicial-office-marker {
  width: 27px;
  height: 27px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1.5px solid #c7a4ff;
  border-radius: 6px;
  background: rgba(32, 20, 51, 0.94);
  color: var(--text);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.32),
    0 0 0 2px rgba(199, 164, 255, 0.1);
  font-family: Inter, system-ui, sans-serif;
  font-size: 9px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease;
}

.extrajudicial-office-marker.is-distribuidor {
  border-color: #ff8fb3;
  background: rgba(54, 18, 32, 0.94);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.32),
    0 0 0 2px rgba(255, 143, 179, 0.1);
}

.extrajudicial-office-marker.is-registro_civil_pessoas_naturais {
  border-color: #7ce0ff;
  background: rgba(8, 37, 52, 0.94);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.32),
    0 0 0 2px rgba(124, 224, 255, 0.1);
}

.extrajudicial-office-marker-shell:hover .extrajudicial-office-marker {
  transform: scale(1.08);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.38),
    0 0 0 3px rgba(199, 164, 255, 0.16);
}

.stats-bar {
  top: var(--app-top);
  right: var(--layout-gap);
  z-index: var(--z-map-panels);
  max-width: calc(100% - var(--sidebar-clear) - 420px);
  min-height: 46px;
  overflow: hidden;
}

.stat-card {
  min-width: 76px;
  padding: 5px 10px;
}

.stat-value {
  font-size: 13px;
}

.stat-value.area {
  font-size: 11px;
}

#topo-alert {
  top: calc(var(--app-top) + 54px);
  left: var(--sidebar-clear);
  right: var(--layout-gap);
  z-index: var(--z-map-panels);
}

.address-search-control,
.gis-toolbar,
.map-export-toolbar {
  left: var(--sidebar-clear);
  z-index: var(--z-map-controls);
}

.address-search-control {
  top: var(--app-top);
  width: min(360px, calc(100% - var(--sidebar-clear) - 440px));
  min-width: 250px;
}

.gis-toolbar {
  top: calc(var(--app-top) + 56px);
  max-width: calc(100% - var(--sidebar-clear) - var(--layout-gap));
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.map-export-toolbar {
  position: absolute;
  top: calc(var(--app-top) + 108px);
  right: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(560px, calc(100% - var(--sidebar-clear) - var(--layout-gap)));
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
}

.map-export-toolbar button {
  min-height: 28px;
  padding: 5px 9px;
  font-size: 10px;
}

.map-overlay-widget {
  z-index: var(--z-map-panels);
}

#map-layer-manager-widget {
  top: calc(var(--app-top) + 108px);
  right: var(--layout-gap);
  max-height: calc(100% - var(--app-top) - var(--app-bottom) - 128px);
}

#map-thematic-widget {
  right: 190px;
  bottom: 18px;
  max-height: min(550px, calc(100% - var(--app-top) - 42px));
}

#map-azimuth-widget,
#map-solar-widget {
  bottom: 18px;
}

.leaflet-control-container {
  position: relative;
  z-index: var(--z-map-controls);
}

.leaflet-top.leaflet-right {
  top: calc(var(--app-top) + 108px) !important;
  right: var(--layout-gap) !important;
}

.leaflet-bottom.leaflet-left {
  bottom: var(--map-control-gap) !important;
  left: var(--sidebar-clear) !important;
}

.leaflet-bottom.leaflet-right {
  bottom: var(--map-control-gap) !important;
  right: var(--layout-gap) !important;
}

.leaflet-bottom .leaflet-control,
.leaflet-control-attribution {
  margin-bottom: 0 !important;
}

.leaflet-control-attribution {
  max-width: min(52vw, 520px);
  white-space: normal;
  line-height: 1.2;
}

.leaflet-control-minimap {
  margin-right: 0 !important;
}

.study-dock {
  position: absolute;
  top: var(--app-top);
  bottom: var(--app-bottom);
  left: var(--layout-gap);
  width: var(--study-dock-width);
  min-width: var(--study-dock-width);
  max-width: var(--study-dock-width);
  height: auto;
  padding: 0;
  z-index: var(--z-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.study-dock #map-azimuth-widget.map-study-panel,
.study-dock #map-solar-widget.map-study-panel,
.study-dock #map-shadow-widget.map-study-panel,
.study-dock #map-overlap-widget.map-study-panel {
  min-height: 0;
}

.study-dock #map-azimuth-widget.map-study-panel .widget-body,
.study-dock #map-solar-widget.map-study-panel .widget-body,
.study-dock #map-shadow-widget.map-study-panel .widget-body,
.study-dock #map-overlap-widget.map-study-panel .widget-body {
  overflow-y: auto;
  padding-bottom: 18px;
}

body.state-studies .tab-bar,
body.state-coords .tab-bar,
body.state-memorial .tab-bar,
body.state-legislation .tab-bar {
  left: var(--layout-gap) !important;
}

body.state-studies .address-search-control,
body.state-studies .gis-toolbar,
body.state-studies .map-export-toolbar {
  left: var(--study-clear) !important;
  max-width: calc(100% - var(--study-clear) - var(--layout-gap));
}

body.state-studies .address-search-control {
  top: var(--app-top);
  width: min(330px, calc(100% - var(--study-clear) - 420px));
}

body.state-studies .gis-toolbar {
  top: calc(var(--app-top) + 56px);
}

body.state-studies .map-export-toolbar,
body.state-studies #map-layer-manager-widget {
  top: calc(var(--app-top) + 108px);
}

body.state-studies .stats-bar {
  max-width: calc(100% - var(--study-clear) - 370px);
}

body.state-studies #topo-alert {
  left: var(--study-clear) !important;
}

body.state-studies .leaflet-bottom.leaflet-left {
  left: var(--study-clear) !important;
}

body.state-coords .tab-panel:not(#panel-map),
body.state-memorial #panel-memorial.active,
body.state-legislation #panel-legislation.active {
  padding-left: var(--layout-gap) !important;
  padding-right: var(--layout-gap) !important;
  padding-top: 0 !important;
  padding-bottom: calc(var(--app-bottom) + var(--layout-gap)) !important;
}

body.state-coords .stats-bar,
body.state-memorial .stats-bar {
  margin-top: var(--app-top);
  margin-left: var(--layout-gap);
  margin-right: var(--layout-gap);
  max-width: none;
}

#loading-overlay {
  z-index: calc(var(--z-modal) + 10);
}

#toast-container {
  bottom: calc(var(--app-bottom) + 10px);
}

@media (max-width: 1366px) {
  .stats-bar {
    max-width: 430px;
  }

  .stat-card {
    min-width: 68px;
  }

  .stat-label {
    font-size: 7px;
  }
}

@media (max-width: 1100px) {
  body {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  main {
    height: 100%;
    overflow: hidden;
  }

  .content {
    height: 100%;
  }

  .header-sub {
    display: none;
  }

  .header-badges {
    overflow-x: auto;
    max-width: 62vw;
    scrollbar-width: none;
  }

  .sidebar {
    width: min(300px, calc(100% - 24px));
  }

  .stats-bar {
    max-width: 42px;
    min-height: 38px;
    padding: 0;
  }

  .stats-toggle-btn {
    display: inline-flex;
  }

  .stats-bar .stat-card {
    display: none;
  }

  .address-search-control {
    top: calc(var(--app-top) + 48px);
    width: min(330px, calc(100% - var(--sidebar-clear) - var(--layout-gap)));
    min-width: 0;
  }

  .gis-toolbar {
    top: calc(var(--app-top) + 104px);
  }

  .map-export-toolbar {
    top: calc(var(--app-top) + 158px);
  }

  #map-layer-manager-widget {
    top: calc(var(--app-top) + 158px);
    width: min(300px, calc(100% - var(--sidebar-clear) - 24px));
  }

  .gis-tool-btn {
    padding: 6px 8px;
  }

  body.state-studies .address-search-control {
    top: calc(var(--app-top) + 48px);
    width: min(310px, calc(100% - var(--study-clear) - var(--layout-gap)));
  }

  body.state-studies .gis-toolbar {
    top: calc(var(--app-top) + 104px);
  }

  body.state-studies .map-export-toolbar,
  body.state-studies #map-layer-manager-widget {
    top: calc(var(--app-top) + 158px);
  }
}

@media (max-width: 760px) {
  :root {
    --header-height: 58px;
    --sidebar-width: calc(100vw - 24px);
    --study-dock-width: calc(100vw - 24px);
    --bottom-nav-height: 66px;
  }

  header {
    padding: 8px 10px;
  }

  .header-badges {
    max-width: 100%;
  }

  .sidebar {
    right: var(--layout-gap);
  }

  .tab-bar,
  body.state-studies .tab-bar,
  body.state-coords .tab-bar,
  body.state-memorial .tab-bar {
    left: var(--layout-gap) !important;
    right: var(--layout-gap);
  }

  .tab-nav {
    justify-content: flex-start;
  }

  #map {
    inset: 0 0 var(--app-bottom) 0;
  }

  body.state-map .sidebar {
    bottom: calc(var(--app-bottom) + 48vh);
    max-height: calc(100dvh - var(--app-top) - var(--app-bottom));
  }

  .address-search-control,
  .gis-toolbar,
  .map-export-toolbar,
  body.state-studies .address-search-control,
  body.state-studies .gis-toolbar,
  body.state-studies .map-export-toolbar {
    left: var(--layout-gap) !important;
    right: var(--layout-gap);
    max-width: none;
    width: auto;
  }

  .address-search-control,
  body.state-studies .address-search-control {
    top: var(--app-top);
  }

  .gis-toolbar,
  body.state-studies .gis-toolbar {
    top: calc(var(--app-top) + 56px);
  }

  .map-export-toolbar,
  body.state-studies .map-export-toolbar {
    top: calc(var(--app-top) + 116px);
  }

  .study-dock {
    right: var(--layout-gap);
    width: auto;
    min-width: 0;
    max-width: none;
    bottom: calc(var(--app-bottom) + 38vh);
  }

  #map-layer-manager-widget,
  body.state-studies #map-layer-manager-widget {
    top: calc(var(--app-top) + 170px);
    left: var(--layout-gap);
    right: var(--layout-gap);
    width: auto;
    max-height: calc(100% - var(--app-top) - var(--app-bottom) - 188px);
  }

  #map-thematic-widget {
    left: var(--layout-gap);
    right: var(--layout-gap);
    width: auto;
    bottom: 84px;
  }

  .leaflet-bottom.leaflet-left,
  body.state-studies .leaflet-bottom.leaflet-left {
    left: var(--layout-gap) !important;
  }

  .leaflet-control-minimap {
    display: none !important;
  }

  .leaflet-control-attribution {
    max-width: calc(100vw - 24px);
  }
}

/* ==========================================================================
   PALETA COMPACTA DE FERRAMENTAS DO MAPA
   ========================================================================== */
.gis-toolbar {
  width: max-content !important;
  max-width: calc(100vw - var(--workspace-left) - var(--app-gap)) !important;
  gap: 3px !important;
  flex-wrap: nowrap !important;
  padding: 4px 6px !important;
  overflow: visible !important;
}

.gis-toolbar .gis-tool-group {
  display: contents;
}

.gis-toolbar .gis-tool-separator {
  display: none !important;
}

.gis-toolbar .gis-tool-btn {
  position: relative;
  width: 34px !important;
  height: 30px !important;
  min-width: 34px !important;
  min-height: 30px !important;
  flex: 0 0 34px !important;
  padding: 0 !important;
  gap: 0 !important;
  border-radius: 7px !important;
  font-size: 0 !important;
}

.gis-toolbar .gis-tool-btn svg {
  width: 16px !important;
  height: 16px !important;
  margin: 0 !important;
  vertical-align: initial !important;
}

.gis-toolbar .gis-tool-btn::after {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  z-index: 20;
  padding: 6px 8px;
  border: 1px solid rgba(143, 168, 195, 0.2);
  border-radius: 6px;
  color: var(--text);
  background: rgba(5, 14, 25, 0.96);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  content: attr(aria-label);
  font:
    650 9px/1 Inter,
    sans-serif;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -3px);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.gis-toolbar .gis-tool-btn:hover::after,
.gis-toolbar .gis-tool-btn:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

#tool-zoom-in {
  order: 1;
}

#tool-zoom-out {
  order: 2;
}

#tool-draw-poly {
  order: 3;
}

#tool-draw-line {
  order: 4;
}

#tool-draw-point {
  order: 5;
}

#tool-draw-text {
  order: 6;
}

#tool-edit-poly,
#tool-cancel-poly {
  order: 7;
}

#tool-delete-poly {
  order: 8;
}

#tool-layer-manager {
  order: 9;
}

#tool-history {
  order: 10;
}

#tool-street-view {
  order: 11;
}

/* Norte junto aos controles cartográficos da lateral direita. */
body.state-map .stats-bar,
body.state-studies .stats-bar {
  right: calc(var(--app-gap) + 64px) !important;
}

.map-north-indicator {
  top: var(--app-top) !important;
  right: calc(var(--app-gap) + 5px) !important;
}

@media (max-width: 760px) {
  .gis-toolbar {
    width: auto !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    scrollbar-width: none;
  }

  .gis-toolbar::-webkit-scrollbar {
    display: none;
  }

  body.state-map .stats-bar,
  body.state-studies .stats-bar {
    right: var(--app-gap) !important;
  }

  .map-north-indicator {
    top: calc(var(--app-top) + 48px) !important;
    right: calc(var(--app-gap) + 64px) !important;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

*:focus-visible {
  outline: 2px solid rgba(0, 183, 255, 0.85);
  outline-offset: 2px;
}

body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh; /* Altura fixa exatamente igual à tela */
  overflow: hidden; /* Elimina qualquer barra de rolagem global */
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  font-size: 13px;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 17, 29, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
#loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-text {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.05em;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 80px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 8888;
}
.toast {
  background: var(--panel3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 260px;
  max-width: 360px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideIn 0.25s ease;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.toast.ok {
  border-left-color: var(--green);
}
.toast.err {
  border-left-color: var(--red);
}
.toast.warn {
  border-left-color: var(--accent);
}
.toast.info {
  border-left-color: var(--blue);
}
.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}
.toast-msg {
  flex: 1;
}
.toast-title {
  font-weight: 700;
  margin-bottom: 2px;
}
.toast-body {
  color: var(--muted);
  font-size: 12px;
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================================
   HEADER
   ============================================================ */
header {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 1002;
  background: var(--panel);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 52px;
}
.header-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.header-left h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}
.header-left h1 span {
  color: var(--accent);
}
.header-sub {
  font-size: 10px;
  color: var(--text2);
  opacity: 0.8;
  margin: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.header-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.crs-summary {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid rgba(92, 211, 255, 0.28);
  border-radius: 7px;
  color: #dff7ff;
  background: rgba(0, 183, 255, 0.1);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.crs-summary::before {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 7px rgba(92, 211, 255, 0.6);
  content: '';
}

.crs-summary.is-valid {
  border-color: rgba(53, 208, 127, 0.3);
  background: rgba(53, 208, 127, 0.09);
}

.crs-summary.is-valid::before {
  background: var(--green);
  box-shadow: 0 0 7px rgba(53, 208, 127, 0.62);
}

.crs-summary.has-error {
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(239, 68, 68, 0.11);
}

.crs-summary.has-error::before {
  background: var(--red);
  box-shadow: 0 0 7px rgba(239, 68, 68, 0.62);
}

.badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-epsg {
  background: rgba(0, 183, 255, 0.12);
  border-color: rgba(0, 183, 255, 0.35);
  color: var(--blue);
}
.badge-datum {
  background: rgba(53, 208, 127, 0.12);
  border-color: rgba(53, 208, 127, 0.35);
  color: var(--green);
}
.badge-zone {
  background: rgba(245, 184, 75, 0.12);
  border-color: rgba(245, 184, 75, 0.35);
  color: #f5b84b;
}
.badge-topo {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--red);
}
.badge-topo.ok {
  background: rgba(53, 208, 127, 0.12);
  border-color: rgba(53, 208, 127, 0.35);
  color: var(--green);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
main {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1; /* Ocupa dinamicamente todo o espaço vertical restante */
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: absolute;
  top: 76px;
  left: 12px;
  bottom: 12px;
  width: 320px;
  z-index: 1001;
  background: var(--panel);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar {
  width: 3px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.s-section {
  border-bottom: 1px solid var(--border2);
  padding: 10px 14px; /* Mais compacto para evitar extrapolamento vertical */
}
.s-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px; /* Mais compacto */
  display: flex;
  align-items: center;
  gap: 6px;
}
.s-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 12px;
  background: var(--accent);
  border-radius: 2px;
}

.field {
  margin-bottom: 8px;
}
.field:last-child {
  margin-bottom: 0;
}
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}
input,
select,
textarea {
  width: 100%;
  background: #07111f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 183, 255, 0.15);
}
input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
select option {
  background: #0f1e30;
}
textarea {
  min-height: 110px; /* Reduzido de 180px para evitar extrapolamento vertical no sidebar */
  resize: vertical;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
}

/* ============================================================
   BOTÕES
   ============================================================ */
.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.btn-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}
button {
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.03em;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  font-family: inherit;
}
button:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}
button:active {
  transform: translateY(1px) scale(0.98);
}
button:disabled:active {
  transform: none;
}
.btn-primary {
  background: var(--accent);
  color: #07111f;
  box-shadow: 0 4px 12px rgba(0, 183, 255, 0.35);
}
.btn-primary:hover {
  background: var(--accent2);
  box-shadow: 0 6px 16px rgba(0, 183, 255, 0.45);
}
.btn-danger {
  background: #3d1515;
  color: var(--red);
  border: 1px solid #5a2020;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}
.btn-ghost {
  background: rgba(19, 38, 58, 0.45);
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: rgba(19, 38, 58, 0.75);
  border-color: var(--accent);
  color: var(--text);
}
.btn-green {
  background: #0e2e1e;
  color: var(--green);
  border: 1px solid #1a5030;
  box-shadow: 0 4px 12px rgba(53, 208, 127, 0.15);
}
.btn-blue {
  background: rgba(0, 183, 255, 0.1);
  color: var(--blue);
  border: 1px solid rgba(0, 183, 255, 0.3);
}
.btn-purple {
  background: #1a1535;
  color: var(--purple);
  border: 1px solid #2d2260;
}
.btn-teal {
  background: #0d2828;
  color: var(--teal);
  border: 1px solid #1a4545;
}
.btn-full {
  grid-column: 1 / -1;
}

/* ============================================================
   ÁREA DE CONTEÚDO
   ============================================================ */
.content {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ============================================================
   STATS BAR
   ============================================================ */
.stats-bar {
  position: absolute;
  top: 76px;
  right: 12px;
  z-index: 1001;
  background: var(--panel);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  gap: 0;
  padding: 4px 8px;
}
.stat-card {
  padding: 6px 14px;
  border-right: 1px solid var(--border2);
  min-width: 90px;
}
.stat-card:last-child {
  border-right: none;
}
.stat-label {
  font-family: 'Inter', sans-serif;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text2);
  opacity: 0.85;
}
.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 800;
  margin-top: 1px;
}
.stat-value.ok {
  color: var(--green);
}
.stat-value.err {
  color: var(--red);
}
.stat-value.accent {
  color: var(--accent);
}
.stat-value.blue {
  color: var(--blue);
}
.stat-value.area {
  font-size: 12px;
}
.stat-primary {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-secondary {
  margin-top: 1px;
  color: var(--text2);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
}

/* ============================================================
   TOPOLOGY ALERT
   ============================================================ */
#topo-alert {
  position: absolute;
  top: 76px;
  left: 344px;
  z-index: 1001;
  background: rgba(42, 14, 14, 0.85);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--red);
  display: none;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
}
#topo-alert.active {
  display: flex;
}

/* ============================================================
   CONTENT TABS
   ============================================================ */
.tab-bar {
  position: absolute;
  bottom: 18px;
  left: 344px;
  right: 12px;
  z-index: 1001;
  background: var(--panel);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 18px;
}
.tab-nav {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar {
  display: none;
}
.export-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  overflow-x: auto;
}
.tab {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition:
    color 0.15s,
    border-color 0.15s;
  text-transform: uppercase;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab.tab-disabled {
  color: rgba(143, 168, 195, 0.35);
  cursor: default;
}
.tab.tab-disabled:hover {
  color: rgba(143, 168, 195, 0.45);
}

/* ============================================================
   TAB PANELS
   ============================================================ */
.tab-panel {
  display: none;
  width: 100%;
  height: 100%;
  position: relative;
}
.tab-panel.active {
  display: flex;
}

.tab-panel:not(#panel-map) {
  padding-left: 344px;
  padding-top: 76px;
  padding-right: 12px;
  padding-bottom: 76px;
  overflow: hidden;
}

.study-dock {
  display: flex;
  width: 370px;
  min-width: 370px;
  max-width: 370px;
  background: rgba(15, 30, 48, 0.96);
  border-right: 1px solid var(--border);
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  flex-direction: column;
  z-index: 2;
  padding-top: 76px; /* Evita sobreposição do cabeçalho principal */
  padding-bottom: 86px; /* Evita sobreposição da barra de abas inferior */
}

.study-dock.collapsed {
  display: none;
}

.study-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 10px;
  background: linear-gradient(135deg, rgba(10, 24, 40, 0.98) 0%, rgba(15, 32, 64, 0.98) 100%);
  border-bottom: 1px solid var(--border);
  min-height: 58px;
}

.study-dock-head span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.study-dock-head strong {
  display: block;
  margin-top: 2px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.study-dock-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 17, 29, 0.38);
  max-height: 220px;
  overflow-y: auto;
}

.study-dock-tabs::-webkit-scrollbar {
  width: 4px;
}

.study-dock-tabs::-webkit-scrollbar-track {
  background: transparent;
}

.study-dock-tabs::-webkit-scrollbar-thumb {
  background: rgba(0, 183, 255, 0.25);
  border-radius: 4px;
}

.study-dock-tabs button {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(8, 17, 29, 0.55);
  color: var(--text2);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  min-height: 30px;
}

.study-dock-tabs button:hover {
  color: var(--text);
  border-color: rgba(74, 158, 255, 0.45);
}

.study-dock-tabs button.active {
  color: #07111d;
  border-color: var(--accent);
  background: var(--accent);
}

.study-future-panel {
  display: none;
  margin: 12px;
  padding: 14px;
  border: 1px dashed rgba(245, 166, 35, 0.45);
  border-radius: var(--radius);
  background: rgba(8, 17, 29, 0.5);
  color: var(--text2);
  font-size: 12px;
  line-height: 1.45;
}

.study-future-panel.active {
  display: block;
}

.study-future-panel strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.study-suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.study-suggestion-list span {
  border: 1px solid var(--border2);
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(21, 40, 64, 0.6);
  color: var(--text2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.study-card-grid {
  margin-top: 12px;
}

.study-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: rgba(7, 17, 29, 0.62);
}

.study-card-kicker {
  color: var(--accent2);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.study-card strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 14px;
}

.study-card p {
  margin: 7px 0 10px;
  color: var(--text2);
  font-size: 11px;
  line-height: 1.45;
}

.study-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

/* ============================================================
   MAPA
   ============================================================ */
#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
#coord-display {
  position: absolute;
  top: 12px;
  right: 78px;
  max-width: min(380px, calc(100% - 102px));
  background: rgba(8, 17, 29, 0.85);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 11px;
  font-family: 'Consolas', monospace;
  color: var(--teal);
  z-index: 700;
  pointer-events: none;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#map:has(.leaflet-control-layers-expanded) #coord-display {
  opacity: 0;
  visibility: hidden;
}

.address-search-control {
  position: absolute;
  top: 76px;
  left: 344px;
  width: min(380px, calc(100% - 740px));
  z-index: 1001;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
  overflow: hidden;
}

.address-search-row {
  display: grid;
  grid-template-columns: 26px 1fr auto 28px;
  align-items: center;
  gap: 6px;
  padding: 7px;
}

.address-search-icon {
  color: var(--accent);
  font-size: 18px;
  text-align: center;
  line-height: 1;
}

.address-search-row input {
  height: 34px;
  border-radius: 6px;
  background: #07111d;
  border-color: var(--border2);
  font-size: 12px;
}

.address-search-btn,
.address-search-clear {
  height: 34px;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 11px;
}

.address-search-btn {
  background: var(--accent);
  color: #08111d;
}

.address-search-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.address-search-clear {
  padding: 0;
  background: var(--panel2);
  color: var(--text2);
  border: 1px solid var(--border);
  font-size: 18px;
}

.address-search-status {
  display: none;
  padding: 0 12px 8px 39px;
  font-size: 11px;
  color: var(--text2);
}

.address-search-status:not(:empty) {
  display: block;
}
.address-search-status.ok {
  color: var(--green);
}
.address-search-status.warn {
  color: var(--accent2);
}
.address-search-status.err {
  color: var(--red);
}

.address-search-results {
  max-height: 232px;
  overflow-y: auto;
  border-top: 1px solid transparent;
}

.address-search-results:not(:empty) {
  border-top-color: var(--border2);
  background: rgba(14, 28, 47, 0.96);
}

.address-search-result {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  align-items: start;
  padding: 9px 12px;
  border-radius: 0;
  background: transparent;
  border-top: 1px solid var(--border2);
  color: var(--text);
  text-align: left;
  letter-spacing: 0;
}

.address-search-result:first-child {
  border-top: none;
}
.address-search-result:hover {
  background: rgba(245, 166, 35, 0.1);
}

.address-result-index {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 166, 35, 0.14);
  color: var(--accent2);
  font-size: 10px;
  font-weight: 800;
}

.address-result-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.address-result-body strong {
  font-size: 12px;
  line-height: 1.25;
  color: var(--text);
}

.address-result-body small {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.25;
}

.address-result-body em {
  font-size: 10px;
  color: var(--teal);
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.datumap-search-marker {
  width: 26px;
  height: 26px;
}

.datumap-search-marker span {
  position: relative;
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--accent);
  border: 2px solid #08111d;
  box-shadow:
    0 0 0 2px rgba(245, 166, 35, 0.35),
    0 4px 14px rgba(0, 0, 0, 0.45);
}

.datumap-search-marker span::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  left: 7px;
  top: 7px;
  border-radius: 50%;
  background: #08111d;
}

.search-popup {
  min-width: 190px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}

.search-popup-kicker {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-popup span {
  color: var(--text2);
}
.search-popup-coords {
  margin-top: 4px;
  color: var(--teal);
  font-family: 'Consolas', monospace;
}

.search-popup button {
  margin-top: 5px;
  padding: 6px 8px;
  border-radius: 5px;
  background: var(--panel2);
  color: var(--accent2);
  border: 1px solid var(--border);
}

/* ============================================================
   TABELAS
   ============================================================ */
.table-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  padding: 0 4px 16px 4px;
}
.table-panel::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
.table-panel::-webkit-scrollbar-track {
  background: transparent;
}
.table-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* TOOLBAR GERAL DE PAINÉIS TÉCNICOS */
.panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 14px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.panel-toolbar-left h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel-toolbar-left h2::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 13px;
  background: var(--accent);
  border-radius: 2px;
}
.panel-toolbar-sub {
  font-size: 10px;
  color: var(--text2);
  margin-top: 2px;
  opacity: 0.85;
}
.panel-toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.toolbar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.btn-group {
  display: flex;
  gap: 5px;
}
.btn-mini-toolbar {
  padding: 5px 10px !important;
  font-size: 11px !important;
  height: 28px !important;
}

/* GRID DE DUAS COLUNAS PARA COORDENADAS */
.coords-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  height: 100%;
}
.coords-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
.coords-col .table-title {
  margin-bottom: 8px;
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(15, 30, 48, 0.45);
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.table-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.table-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 10px;
  background: var(--accent);
  border-radius: 2px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  letter-spacing: -0.01em;
}
thead th {
  background: var(--panel2-solid);
  color: var(--text2);
  padding: 8px 12px;
  text-align: left;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 7px 12px;
  border-top: 1px solid var(--border2);
  color: var(--text);
  white-space: nowrap;
  transition: all 0.15s ease;
}
tbody tr:nth-child(even) td {
  background: rgba(14, 28, 47, 0.25);
}
tbody tr:hover td {
  background: rgba(0, 183, 255, 0.08);
  color: var(--text);
}
.ok {
  color: var(--green) !important;
  font-weight: 700;
}
.err {
  color: var(--red) !important;
  font-weight: 700;
}

/* ============================================================
   MEMORIAL PANEL
   ============================================================ */
#panel-memorial.active {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.memorial-panel-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0 4px 16px 4px;
  box-sizing: border-box;
  overflow: hidden;
}

.memorial-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.memorial-col-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
  height: 100%;
}
.memorial-col-form::-webkit-scrollbar {
  width: 3px;
}
.memorial-col-form::-webkit-scrollbar-track {
  background: transparent;
}
.memorial-col-form::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.memorial-form-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  flex-shrink: 0;
}
.memorial-form-section h3 {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border2);
  padding-bottom: 6px;
  margin-bottom: 12px;
}

.memorial-col-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

#panel-memorial #memorial-output {
  flex: 1 !important;
  background: #07111d !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  padding: 16px !important;
  font-family: 'Consolas', monospace !important;
  font-size: 11px !important;
  line-height: 1.6 !important;
  color: var(--text) !important;
  white-space: pre-wrap !important;
  overflow-y: auto !important;
  user-select: text !important;
  margin-bottom: 0 !important;
}

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

#frontName {
  border-left: 3px solid var(--blue);
}
#rightName {
  border-left: 3px solid var(--green);
}
#backName {
  border-left: 3px solid var(--accent);
}
#leftName {
  border-left: 3px solid var(--purple);
}

/* ============================================================
   LEAFLET CUSTOM THEMING
   ============================================================ */
.leaflet-control-layers {
  background: var(--panel) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  font-family: inherit !important;
  padding: 8px 12px !important;
}
.leaflet-control-layers-toggle {
  background-color: var(--panel2) !important;
}

/* Previne poluição global de 'label' e 'input' dentro do controle de camadas do Leaflet */
.leaflet-control-layers label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  width: auto !important;
  margin: 4px 0 !important;
  padding: 4px 6px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  color: var(--text) !important;
  text-transform: none !important;
  cursor: pointer !important;
  border-radius: 4px !important;
  transition: background-color 0.2s ease !important;
}

.leaflet-control-layers label:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

.leaflet-control-layers label span {
  white-space: nowrap !important;
}

.leaflet-control-layers input[type='radio'],
.leaflet-control-layers input[type='checkbox'] {
  width: 14px !important;
  height: 14px !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  accent-color: var(--accent) !important;
  display: inline-block !important;
}

/* Estilização para o cabeçalho customizado inserido via JS */
.layers-custom-section {
  border-top: 1px solid var(--border);
  margin: 10px 0 6px -6px;
  padding-top: 8px;
  font-weight: 700;
  color: var(--accent) !important;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.leaflet-control-layers-overlays > .layers-custom-section:first-child {
  border-top: none;
  margin-top: 4px;
  padding-top: 0;
}

.layers-custom-section-base {
  font-weight: 700;
  color: var(--red) !important;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  margin-left: 2px;
}

.leaflet-control-layers-separator {
  border-top: 1px solid var(--border) !important;
  margin: 8px 0 !important;
}
.leaflet-control-zoom a {
  background-color: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover {
  background-color: var(--panel2) !important;
}
.leaflet-bar a {
  background-color: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-bar a:hover {
  background-color: var(--panel2) !important;
}
.leaflet-draw-toolbar a {
  background-color: var(--panel) !important;
}
.leaflet-popup-content-wrapper {
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
}
.leaflet-popup-tip {
  background: var(--panel) !important;
}
.leaflet-control-minimap {
  border: 2px solid var(--border) !important;
  border-radius: 6px !important;
  /* Sobe o minimapa para não sobrepor a barra de atribuição do Leaflet. */
  position: relative !important;
  bottom: 40px !important;
}
.leaflet-control-scale-line {
  background: rgba(8, 17, 29, 0.75) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  font-size: 10px !important;
}

/* Reposicionamento dos containers do Leaflet para evitar sobreposição com painéis e estatísticas do Mini GIS */
.leaflet-top.leaflet-right {
  top: 138px !important;
  right: 12px !important;
}
.leaflet-bottom.leaflet-left {
  bottom: 76px !important;
  left: 344px !important;
}
.leaflet-bottom.leaflet-right {
  bottom: 76px !important;
  right: 12px !important;
}

/* Margem inferior extra para os controles inferiores para não sobrepor a barra de navegação */
.leaflet-bottom .leaflet-control {
  margin-bottom: 24px !important;
}
.leaflet-control-attribution {
  margin-bottom: 24px !important;
}

/* ============================================================
   SCROLLBAR GLOBAL
   ============================================================ */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }
  main {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .content {
    height: 70vh;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  header {
    padding: 12px 16px;
  }
  .tab-bar {
    align-items: stretch;
  }
  .export-actions {
    max-width: 44%;
  }
  .study-dock {
    width: 340px;
    min-width: 340px;
    max-width: 340px;
  }
}
@media (max-width: 700px) {
  .stats-bar {
    flex-wrap: wrap;
  }
  .stat-card {
    min-width: 50%;
    flex: none;
  }
  header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-badges {
    gap: 6px;
  }
  .badge {
    font-size: 10px;
    padding: 3px 7px;
  }
  .tab-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-right: 6px !important;
  }
  .tab-nav,
  .export-actions {
    max-width: none;
    width: 100%;
  }
  .export-actions {
    padding: 6px 8px;
    border-top: 1px solid var(--border2);
  }
  .content {
    height: 60vh;
  }
  #panel-map.active {
    flex-direction: column;
  }
  .study-dock {
    width: 100%;
    min-width: 0;
    max-width: none;
    max-height: 46%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .address-search-control {
    top: 54px;
    left: 8px;
    width: calc(100% - 72px);
  }
  .address-search-row {
    grid-template-columns: 22px 1fr 28px;
  }
  .address-search-btn {
    grid-column: 2 / 4;
    width: 100%;
  }
  .address-search-clear {
    grid-column: 3;
    grid-row: 1;
  }
}
/* ==========================================================================
   MÓDULOS DE APLICATIVO
   ========================================================================== */
.module-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 5px;
  background: rgba(7, 17, 29, 0.45);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 10px 10px 4px 10px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 20;
}

.mod-btn {
  text-align: center;
  padding: 6px 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text2);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.mod-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.mod-btn.active {
  color: #07111f;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 183, 255, 0.35);
}

.app-module {
  display: none;
  flex: 1;
  overflow-y: auto;
  flex-direction: column;
}

.app-module.active {
  display: flex;
}

.sidebar-primary-action {
  position: sticky;
  bottom: 0;
  z-index: 12;
  background: linear-gradient(180deg, rgba(15, 30, 48, 0.72) 0%, var(--panel) 24%);
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 22px rgba(0, 0, 0, 0.22);
}

.conversion-helper {
  border: 1px solid var(--border2);
  border-radius: 7px;
  padding: 9px;
  margin-bottom: 8px;
  background: rgba(21, 40, 64, 0.42);
}

.conversion-note {
  color: var(--text2);
  font-size: 11px;
  line-height: 1.5;
  padding: 9px 10px;
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  background: rgba(7, 17, 29, 0.72);
}

.confront-front-picker {
  flex: 1 0 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border2);
}

.confront-front-picker label {
  font-size: 9px;
  margin-bottom: 4px;
  color: var(--accent2);
}

.confront-front-picker select {
  height: 30px;
  padding: 5px 8px;
  font-size: 11px;
  border-radius: 5px;
}

#panel-charts,
#panel-thematic-maps {
  overflow-y: auto;
}

/* ==========================================================================
   PAINEL DE GRÁFICOS (CHARTS GRID)
   ========================================================================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  padding: 20px;
}

.chart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border2);
  padding-bottom: 8px;
}

.chart-card-title {
  font-weight: 700;
  color: var(--accent2);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chart-card-subtitle {
  font-size: 11px;
  color: var(--muted);
}

.chart-canvas-container {
  position: relative;
  height: 250px;
  width: 100%;
}

.chart-empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  background: rgba(8, 17, 29, 0.65);
  border-radius: 6px;
  text-align: center;
  padding: 20px;
  border: 1px dashed var(--border);
  z-index: 5;
}

.cut-profile-actions {
  display: grid;
  grid-template-columns: 1.2fr 0.7fr 0.7fr 0.8fr;
  gap: 8px;
}

.cut-profile-btn {
  min-height: 30px;
  padding: 7px 9px;
  font-size: 10px;
  letter-spacing: 0.02em;
}

.cut-profile-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.cut-profile-metrics div {
  min-width: 0;
  padding: 7px 8px;
  background: rgba(7, 17, 29, 0.48);
  border: 1px solid rgba(36, 61, 92, 0.65);
  border-radius: 6px;
}

.cut-profile-metrics span {
  display: block;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cut-profile-metrics strong {
  display: block;
  margin-top: 2px;
  color: var(--accent2);
  font-size: 11px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cut-coordinate-editor {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px 8px;
  align-items: end;
}

.cut-coordinate-editor label {
  margin: 0;
  font-size: 8px;
}

.cut-coordinate-editor input {
  height: 30px;
  padding: 6px 8px;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 10px;
}

.cut-coordinate-editor button {
  grid-row: 1 / span 2;
  grid-column: 3;
  height: 30px;
  align-self: end;
}

.cut-endpoint-marker {
  width: 22px;
  height: 22px;
  background: transparent;
  cursor: grab;
  pointer-events: auto;
  border: 0 !important;
}

.cut-endpoint-marker span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 2px solid #08111d;
  border-radius: 50%;
  background: #2ecc8e;
  box-shadow:
    0 0 0 2px rgba(0, 212, 200, 0.62),
    0 5px 12px rgba(0, 0, 0, 0.5);
  color: #08111d;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.cut-endpoint-marker.end span {
  background: #ffd07a;
  box-shadow:
    0 0 0 2px rgba(255, 208, 122, 0.62),
    0 5px 12px rgba(0, 0, 0, 0.5);
  color: #08111d;
}

.cut-endpoint-marker:active {
  cursor: grabbing;
}

.cut-endpoint-marker.editing {
  animation: cutEndpointPulse 1.1s ease-in-out infinite alternate;
}

.cut-probe-marker {
  width: 24px;
  height: 24px;
}

.cut-probe-marker span {
  display: block;
  width: 0;
  height: 0;
  margin: 2px auto 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 18px solid #ff5e5e;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.75));
  cursor: grab;
}

.cut-probe-marker:active span {
  cursor: grabbing;
}

.cut-probe-leaflet-tooltip {
  background: rgba(7, 17, 29, 0.92) !important;
  border: 1px solid rgba(255, 208, 122, 0.65) !important;
  border-radius: 6px !important;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45) !important;
  color: var(--text) !important;
  padding: 0 !important;
  pointer-events: none !important;
}

.cut-probe-leaflet-tooltip::before {
  border-top-color: rgba(255, 208, 122, 0.65) !important;
}

.cut-probe-tooltip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  line-height: 1.15;
}

.cut-probe-tooltip b {
  color: #ffd07a;
  font-size: 12px;
}

.cut-probe-tooltip span {
  color: var(--text2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.azimuth-hover-tooltip {
  background: rgba(7, 17, 29, 0.94) !important;
  border: 1px solid rgba(255, 208, 122, 0.7) !important;
  border-radius: 6px !important;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45) !important;
  color: #ffd07a !important;
  font-size: 11px !important;
  font-weight: 900 !important;
  letter-spacing: 0.02em;
  padding: 6px 8px !important;
}

.azimuth-hover-tooltip::before {
  border-top-color: rgba(255, 208, 122, 0.7) !important;
}

@keyframes cutEndpointPulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.18);
  }
}

/* ==========================================================================
   WIDGET FLUTUANTE DE CARTAS TEMÁTICAS (MAP OVERLAY)
   ========================================================================== */
.map-overlay-widget {
  position: absolute;
  z-index: 1000;
  background: rgba(15, 30, 48, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  overflow: hidden;
  transition:
    max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.2s ease;
  max-height: 300px; /* Altura padrão para os gráficos flutuantes */
}

#map-azimuth-widget {
  bottom: 45px;
  left: 12px;
  width: 270px;
}

#map-solar-widget {
  bottom: 45px;
  left: 294px;
  width: 360px;
  max-height: 640px;
}

#map-azimuth-widget.map-study-panel,
#map-solar-widget.map-study-panel,
#map-shadow-widget.map-study-panel,
#map-overlap-widget.map-study-panel {
  display: none;
  top: 0;
  bottom: auto;
  left: 0;
  z-index: 1100;
  max-height: calc(100% - 12px);
  border-radius: 0 0 var(--radius) 0;
  background: rgba(15, 30, 48, 0.94);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.study-dock #map-azimuth-widget.map-study-panel,
.study-dock #map-solar-widget.map-study-panel,
.study-dock #map-shadow-widget.map-study-panel,
.study-dock #map-overlap-widget.map-study-panel {
  position: static;
  width: auto;
  max-height: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: hidden;
  flex: 1;
}

#map-azimuth-widget.map-study-panel {
  width: 330px;
}

#map-solar-widget.map-study-panel {
  width: 370px;
}

#map-shadow-widget.map-study-panel {
  width: 370px;
}

#map-overlap-widget.map-study-panel {
  width: 370px;
}

#map-azimuth-widget.map-study-panel.study-panel-active,
#map-solar-widget.map-study-panel.study-panel-active,
#map-shadow-widget.map-study-panel.study-panel-active,
#map-overlap-widget.map-study-panel.study-panel-active {
  display: block;
}

.study-dock #map-azimuth-widget.map-study-panel.study-panel-active,
.study-dock #map-solar-widget.map-study-panel.study-panel-active,
.study-dock #map-shadow-widget.map-study-panel.study-panel-active,
.study-dock #map-overlap-widget.map-study-panel.study-panel-active {
  display: flex;
  flex-direction: column;
}

#map-azimuth-widget.map-study-panel.collapsed,
#map-solar-widget.map-study-panel.collapsed,
#map-shadow-widget.map-study-panel.collapsed,
#map-overlap-widget.map-study-panel.collapsed {
  max-height: calc(100% - 12px) !important;
}

#map-azimuth-widget.map-study-panel .widget-body,
#map-solar-widget.map-study-panel .widget-body,
#map-shadow-widget.map-study-panel .widget-body,
#map-overlap-widget.map-study-panel .widget-body {
  max-height: calc(100vh - 340px);
}

.study-dock #map-azimuth-widget.map-study-panel .widget-body,
.study-dock #map-solar-widget.map-study-panel .widget-body,
.study-dock #map-shadow-widget.map-study-panel .widget-body,
.study-dock #map-overlap-widget.map-study-panel .widget-body {
  max-height: none;
  flex: 1;
  padding: 10px;
}

.study-dock #map-azimuth-widget.map-study-panel .widget-header,
.study-dock #map-solar-widget.map-study-panel .widget-header,
.study-dock #map-shadow-widget.map-study-panel .widget-header,
.study-dock #map-overlap-widget.map-study-panel .widget-header {
  display: none;
}

#map-azimuth-widget.map-study-panel .widget-header,
#map-solar-widget.map-study-panel .widget-header,
#map-shadow-widget.map-study-panel .widget-header,
#map-overlap-widget.map-study-panel .widget-header {
  cursor: default;
}

#map-thematic-widget {
  bottom: 45px;
  right: 168px;
  width: 270px;
  max-height: 550px; /* Maior altura para comportar as 4 cartas temáticas */
}

#map-thematic-widget.thematic-study-widget {
  display: none;
}

#map-thematic-widget.thematic-study-widget.study-visible {
  display: block;
}

.map-overlay-widget.collapsed {
  max-height: 38px !important; /* Apenas o cabeçalho visível, override absoluto */
}

.map-overlay-widget.collapsed .widget-body {
  visibility: hidden;
  pointer-events: none;
}

.widget-header {
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(10, 24, 40, 0.95) 0%, rgba(15, 32, 64, 0.95) 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.widget-title {
  font-weight: 700;
  font-size: 10px;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.widget-toggle-icon {
  font-size: 9px;
  color: var(--muted);
  transition: transform 0.3s ease;
}

.widget-close {
  width: 22px;
  height: 22px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  font-size: 15px;
}

.widget-close:hover {
  color: var(--text);
  border-color: var(--border);
  background: rgba(74, 158, 255, 0.12);
}

.map-overlay-widget.collapsed .widget-toggle-icon {
  transform: rotate(-90deg);
}

.widget-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: calc(480px - 38px);
}

.widget-section {
  border-bottom: 1px solid var(--border2);
  padding-bottom: 10px;
  margin-bottom: 2px;
}

.widget-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ============================================================
   LAYER MANAGER (GERENCIADOR DE RASCUNHOS)
   ============================================================ */
#map-layer-manager-widget {
  top: 188px;
  right: 12px;
  width: 360px;
  max-height: 520px;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.layer-list::-webkit-scrollbar {
  width: 4px;
}
.layer-list::-webkit-scrollbar-track {
  background: transparent;
}
.layer-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(7, 17, 29, 0.45);
  border: 1px solid rgba(36, 61, 92, 0.3);
  border-radius: 5px;
  padding: 8px 10px;
  transition:
    background 0.2s,
    border-color 0.2s;
}

.layer-item.active {
  border-color: rgba(245, 166, 35, 0.75);
  background: rgba(245, 166, 35, 0.08);
}

.layer-item:hover {
  background: rgba(13, 27, 46, 0.65);
  border-color: rgba(60, 95, 138, 0.6);
}

.layer-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.layer-visible-check {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.layer-preview {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.layer-preview svg {
  width: 18px;
  height: 18px;
}

.layer-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.layer-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-meta {
  font-size: 10px;
  color: var(--muted);
}

.layer-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.layer-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text2);
  border-radius: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 12px;
  font-family: inherit;
}

.layer-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.layer-btn.delete:hover {
  background: rgba(255, 94, 94, 0.2);
  color: #ff5e5e;
  border-color: rgba(255, 94, 94, 0.4);
}

.layer-empty-state {
  text-align: center;
  padding: 20px 10px;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
}

.layer-select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
}

.layer-select-all input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.layer-bulk-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.layer-action-pill {
  height: 26px;
  padding: 0 10px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.layer-action-pill:hover {
  background: rgba(74, 158, 255, 0.16);
  color: var(--accent2);
}

.layer-action-pill.danger:hover {
  background: rgba(255, 94, 94, 0.18);
  color: var(--red);
  border-color: rgba(255, 94, 94, 0.35);
}

.layer-edit-panel {
  border-top: 1px solid var(--border2);
  padding-top: 10px;
}

.layer-edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layer-edit-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-edit-row label,
.layer-edit-grid label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.layer-edit-row input,
.layer-edit-row textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  background: rgba(7, 17, 29, 0.65);
  color: var(--text);
  border-radius: 5px;
  padding: 7px 8px;
  font: inherit;
  font-size: 12px;
}

.layer-edit-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
}

.layer-edit-grid input[type='color'] {
  display: block;
  width: 44px;
  height: 28px;
  padding: 0;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
}

.datumap-point-sketch-icon span {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.45);
}

.datumap-text-sketch-icon span {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  white-space: nowrap;
}

.widget-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.widget-section-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.widget-legend-container {
  margin-top: 8px;
  background: rgba(7, 17, 29, 0.45);
  border-radius: 5px;
  padding: 6px 8px;
  border: 1px solid rgba(36, 61, 92, 0.3);
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeIn 0.25s ease;
}

.legend-dot-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text2);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.solar-widget-body {
  gap: 9px;
  max-height: 590px;
}

.solar-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.solar-input-grid .field {
  margin-bottom: 0;
}

.solar-input-grid input,
.solar-input-grid select {
  height: 31px;
  padding: 6px 8px;
  font-size: 11px;
}

.solar-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 9px;
}

.solar-action-grid button,
.solar-quick-row button {
  min-height: 29px;
  padding: 6px 8px;
  font-size: 10px;
}

.solar-action-grid button {
  width: 100%;
  min-width: 0;
}

.solar-action-grid #solar-calculate {
  grid-column: 1 / -1;
}

.solar-quick-row {
  display: grid;
  gap: 5px;
}

.solar-date-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.solar-time-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.solar-quick-row button {
  background: rgba(21, 40, 64, 0.82);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 6px;
  min-width: 0;
  white-space: normal;
  line-height: 1.15;
}

.solar-quick-row button:hover {
  color: var(--accent2);
  border-color: var(--accent);
}

.solar-compass {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: radial-gradient(circle at center, rgba(26, 50, 82, 0.72), rgba(7, 17, 29, 0.88));
}

.solar-compass svg {
  width: 100%;
  max-width: 238px;
  height: auto;
}

.solar-ring {
  fill: none;
  stroke: rgba(255, 208, 122, 0.55);
  stroke-width: 1.6;
}

.solar-ring.inner {
  stroke: rgba(74, 158, 255, 0.22);
  stroke-width: 1;
}

.solar-spoke {
  stroke: rgba(160, 188, 216, 0.18);
  stroke-width: 1;
}

.solar-degree {
  fill: var(--muted);
  font-size: 8px;
  text-anchor: middle;
  dominant-baseline: middle;
}

.solar-cardinal {
  fill: var(--accent2);
  font-size: 12px;
  font-weight: 800;
  text-anchor: middle;
}

.solar-path {
  fill: none;
  stroke: #00d4c8;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 5px rgba(0, 212, 200, 0.35));
}

.solar-current {
  fill: var(--accent);
  stroke: #08111d;
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(245, 166, 35, 0.75));
}

.solar-current.below {
  fill: var(--red);
  opacity: 0.65;
}

.solar-sunrise {
  fill: #2ecc8e;
  stroke: #08111d;
  stroke-width: 2;
}

.solar-sunset {
  fill: #ff5e5e;
  stroke: #08111d;
  stroke-width: 2;
}

.solar-result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.solar-result-grid div {
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid var(--border2);
  border-radius: 7px;
  background: rgba(7, 17, 29, 0.62);
}

.solar-result-grid span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.solar-result-grid strong {
  display: block;
  margin-top: 2px;
  color: var(--accent2);
  font-size: 12px;
}

.solar-shadow-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 7px;
  align-items: end;
}

.solar-shadow-row label {
  margin-bottom: 0;
}

.solar-shadow-row input {
  height: 31px;
  padding: 6px 8px;
}

.solar-note {
  border: 1px solid rgba(245, 166, 35, 0.32);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  padding: 8px 9px;
  color: var(--text2);
  background: rgba(7, 17, 29, 0.66);
  font-size: 11px;
  line-height: 1.35;
}

.shadow-widget-body {
  gap: 10px;
}

.shadow-note,
.shadow-status {
  color: var(--text2);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  background: rgba(7, 17, 29, 0.72);
  padding: 9px 10px;
  font-size: 11px;
  line-height: 1.45;
}

.shadow-status.ok {
  border-left-color: var(--green);
  color: var(--text);
}
.shadow-status.warn {
  border-left-color: var(--accent);
  color: var(--accent2);
}
.shadow-status.err {
  border-left-color: var(--red);
  color: var(--red);
}

.shadow-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.shadow-advanced {
  border: 1px solid var(--border2);
  border-radius: 7px;
  padding: 8px 9px;
  background: rgba(21, 40, 64, 0.35);
}

.shadow-advanced summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.shadow-advanced[open] summary {
  margin-bottom: 8px;
  color: var(--accent2);
}

.shadow-legend {
  display: grid;
  gap: 5px;
  color: var(--text2);
  font-size: 11px;
}

.shadow-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.shadow-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.shadow-dot.obstacle {
  background: var(--accent);
}
.shadow-dot.shadow {
  background: rgba(7, 17, 29, 0.9);
  border: 1px solid var(--blue);
}
.shadow-dot.vector {
  background: var(--teal);
}

.shadow-result-grid strong {
  font-size: 12px;
}

.shadow-draw-helper {
  background: rgba(245, 166, 35, 0.12);
  border-color: rgba(245, 166, 35, 0.55) !important;
}

.solar-pick-mode {
  cursor: crosshair !important;
}

.solar-marker-tooltip {
  background: rgba(7, 17, 29, 0.88) !important;
  border: 1px solid rgba(255, 208, 122, 0.6) !important;
  border-radius: 6px !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.42) !important;
  color: var(--accent2) !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  letter-spacing: 0.02em;
  padding: 5px 7px !important;
  pointer-events: none !important;
}

.solar-marker-tooltip::before {
  border-top-color: rgba(255, 208, 122, 0.6) !important;
}

.altitude-label {
  pointer-events: none;
}

.altitude-label span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 17px;
  padding: 0 5px;
  border: 1px solid rgba(255, 208, 122, 0.55);
  border-radius: 4px;
  background: rgba(7, 17, 29, 0.82);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  color: #ffd07a;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* INTERRUPTOR DESLIZANTE (SWITCH SWITCHES) */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--panel2);
  border: 1px solid var(--border);
  transition: 0.25s ease;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: '';
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: var(--muted);
  transition: 0.25s ease;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: rgba(245, 166, 35, 0.15);
  border-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(22px);
  background-color: var(--accent);
}

/* ==========================================================================
   datumap.xyz COORDINATES INPUT AREA (UX REFINE)
   ========================================================================== */
.segmented-control {
  display: flex;
  position: relative;
  background: #060d16;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px;
  margin-bottom: 12px;
  user-select: none;
}

.segmented-control input[type='radio'] {
  display: none;
}

.segmented-control .segment-label {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  z-index: 2;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: color 0.25s ease;
  border-radius: 18px;
}

.segmented-control input[type='radio']:checked + .segment-label {
  color: #08111d; /* Dark contrast background */
}

.segmented-control .segmented-bg {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  background: var(--accent);
  border-radius: 18px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
  box-shadow: 0 2px 8px rgba(245, 166, 35, 0.3);
}

.segmented-control input[id='type-latlng']:checked ~ .segmented-bg {
  transform: translateX(100%);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(36, 61, 92, 0.1);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.toggle-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toggle-desc {
  font-size: 9px;
  color: var(--muted);
}

.textarea-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  padding-left: 2px;
}

.btn-mini {
  background: rgba(36, 61, 92, 0.2);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-mini:hover {
  background: var(--border);
  color: var(--accent2);
  border-color: var(--accent);
}

/* ==========================================================================
   HORIZONTAL GIS TOOLBAR (MAP OVERLAYS & LEAFLET HIDE)
   ========================================================================== */
/* Ocultar controles verticais nativos do Leaflet (substituídos pela barra horizontal) */
.leaflet-left .leaflet-control-zoom {
  display: none !important;
}
.leaflet-left .leaflet-draw {
  display: none !important;
}

.gis-toolbar {
  position: absolute;
  top: 124px;
  left: 344px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 4px 12px;
  box-shadow: var(--shadow);
  user-select: none;
  animation: fadeInDown 0.3s ease;
}

.gis-tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gis-tool-btn {
  background: transparent;
  border: none;
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
}

.gis-tool-btn:hover {
  background: rgba(0, 183, 255, 0.15);
  color: var(--accent2);
}

.gis-tool-btn.active {
  background: var(--accent);
  color: #07111f;
  box-shadow: 0 0 10px rgba(0, 183, 255, 0.4);
}

.gis-tool-separator {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   LAYOUT STATES OVERRIDES (Hiding Sidebar & Adjusting Overlays)
   ========================================================================== */
/* ==========================================================================
   LAYOUT STATES OVERRIDES (Hiding Sidebar & Adjusting Overlays)
   ========================================================================== */
body.state-coords .sidebar,
body.state-memorial .sidebar,
body.state-studies .sidebar,
body.state-legislation .sidebar {
  display: none !important;
}

body.state-legislation .stats-bar {
  display: none !important;
}

/* Painel de coordenadas em tela técnica */
body.state-coords .tab-panel:not(#panel-map) {
  padding-left: 12px !important;
  padding-right: 12px !important;
  padding-top: 0px !important;
  padding-bottom: 76px !important;
}

/* Painel de memorial descritivo */
body.state-memorial #panel-memorial.active {
  padding-left: 12px !important;
  padding-right: 12px !important;
  padding-top: 0px !important;
  padding-bottom: 76px !important;
}

/* Barra inferior de navegação */
body.state-coords .tab-bar,
body.state-memorial .tab-bar,
body.state-studies .tab-bar {
  left: 12px !important;
}

/* Topology Alert entra no fluxo vertical abaixo dos indicadores */
body.state-coords #topo-alert,
body.state-memorial #topo-alert {
  position: relative;
  top: auto;
  left: auto !important;
  margin: 0 12px 12px 12px;
  z-index: 1001;
  flex-shrink: 0;
  display: none;
}
body.state-coords #topo-alert.active,
body.state-memorial #topo-alert.active {
  display: flex;
}

/* Alerta normal no mapa mantém posição absoluta */
body.state-map #topo-alert,
body.state-studies #topo-alert {
  left: 344px !important;
}

/* Reposicionamento da barra de indicadores (stats-bar) nas abas técnicas */
body.state-coords .stats-bar,
body.state-memorial .stats-bar {
  position: relative;
  top: auto;
  right: auto;
  margin-top: 76px; /* Logo abaixo do header fixo */
  margin-left: 12px;
  margin-right: 12px;
  margin-bottom: 12px;
  z-index: 1001;
  flex-shrink: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
}

/* Responsividade de posições dos elementos Leaflet na aba de Estudos */
body.state-studies .leaflet-bottom.leaflet-left {
  left: 394px !important; /* Desvia os controles (escala/minimap) para não sobrepor o study-dock (370px) */
}

body.state-studies .address-search-control {
  left: 394px !important; /* Spacing for study-dock (370px width + 12px padding + 12px gap) */
}

body.state-studies .gis-toolbar {
  left: 394px !important; /* Spacing for study-dock */
}

/* BOTÃO DE COLAPSO DOS INDICADORES TÉCNICOS */
.stats-toggle-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  padding: 6px;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border2);
  border-radius: 0;
  width: 36px;
  height: 100%;
}
.stats-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 1100px) {
  .stats-toggle-btn {
    display: inline-flex;
  }
  .stats-bar.collapsed .stat-card {
    display: none !important;
  }
  .stats-bar.collapsed {
    padding: 0 !important;
    width: 36px !important;
    height: 36px !important;
    overflow: hidden !important;
  }

  .coords-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  .memorial-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  .memorial-col-form {
    width: 100% !important;
  }
  .memorial-col-preview {
    height: 400px;
    margin-top: 12px;
  }

  body.state-coords .stats-bar,
  body.state-memorial .stats-bar {
    margin-left: 12px !important;
  }
}

/* Final layout pass: keep this at the end so it wins over legacy absolute rules. */
header {
  top: var(--header-top) !important;
  left: var(--layout-gap) !important;
  right: var(--layout-gap) !important;
  height: var(--header-height) !important;
  z-index: var(--z-header) !important;
}

body {
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
}

main,
.content {
  height: 100% !important;
  overflow: hidden !important;
}

.sidebar {
  top: var(--app-top) !important;
  bottom: var(--app-bottom) !important;
  left: var(--sidebar-left) !important;
  width: var(--sidebar-width) !important;
  z-index: var(--z-sidebar) !important;
  overflow-y: auto !important;
  padding-bottom: 10px !important;
}

.app-module {
  min-height: 0 !important;
  padding-bottom: 14px !important;
}

.tab-bar {
  left: var(--sidebar-clear) !important;
  right: var(--layout-gap) !important;
  bottom: calc(var(--bottom-safe-gap) + env(safe-area-inset-bottom, 0px)) !important;
  min-height: var(--bottom-nav-height) !important;
  z-index: var(--z-bottom-nav) !important;
  justify-content: center !important;
  padding: 8px 14px !important;
}

.tab-bar > .export-actions {
  display: none !important;
}

.tab-nav {
  justify-content: center !important;
  width: 100% !important;
}

.tab-panel:not(#panel-map) {
  padding-left: var(--sidebar-clear) !important;
  padding-top: var(--app-top) !important;
  padding-right: var(--layout-gap) !important;
  padding-bottom: calc(var(--app-bottom) + var(--layout-gap)) !important;
}

#map {
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: auto !important;
  height: auto !important;
  z-index: var(--z-map) !important;
}

.stats-bar {
  top: var(--app-top) !important;
  right: var(--layout-gap) !important;
  z-index: var(--z-map-panels) !important;
  max-width: min(430px, calc(100% - var(--sidebar-clear) - 420px)) !important;
  min-height: 46px !important;
  overflow: hidden !important;
}

.stat-card {
  min-width: 68px !important;
  padding: 5px 10px !important;
}

.stat-label {
  font-size: 7px !important;
}

.stat-value {
  font-size: 13px !important;
}

.stat-value.area {
  font-size: 11px !important;
}

#topo-alert {
  top: calc(var(--app-top) + 54px) !important;
  left: var(--sidebar-clear) !important;
  right: var(--layout-gap) !important;
  z-index: var(--z-map-panels) !important;
}

.address-search-control {
  top: var(--app-top) !important;
  left: var(--sidebar-clear) !important;
  width: min(360px, calc(100% - var(--sidebar-clear) - 440px)) !important;
  min-width: 250px !important;
  z-index: var(--z-map-controls) !important;
}

.gis-toolbar {
  top: calc(var(--app-top) + 56px) !important;
  left: var(--sidebar-clear) !important;
  max-width: calc(100% - var(--sidebar-clear) - var(--layout-gap)) !important;
  z-index: var(--z-map-controls) !important;
  border-radius: var(--radius) !important;
  flex-wrap: wrap !important;
}

.map-export-toolbar {
  position: absolute !important;
  top: calc(var(--app-top) + 108px) !important;
  left: var(--sidebar-clear) !important;
  right: auto !important;
  z-index: var(--z-map-controls) !important;
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
  max-width: min(560px, calc(100% - var(--sidebar-clear) - var(--layout-gap))) !important;
  padding: 6px !important;
  background: var(--panel) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  backdrop-filter: var(--glass) !important;
  -webkit-backdrop-filter: var(--glass-webkit) !important;
}

.map-export-toolbar button {
  min-height: 28px !important;
  padding: 5px 9px !important;
  font-size: 10px !important;
}

.map-overlay-widget {
  z-index: var(--z-map-panels) !important;
}

#map-layer-manager-widget {
  top: calc(var(--app-top) + 108px) !important;
  right: var(--layout-gap) !important;
  width: 320px !important;
  max-height: calc(100% - var(--app-top) - var(--app-bottom) - 128px) !important;
}

#map-thematic-widget {
  right: 190px !important;
  bottom: 18px !important;
  max-height: min(550px, calc(100% - var(--app-top) - 42px)) !important;
}

.leaflet-control-container {
  position: relative !important;
  z-index: var(--z-map-controls) !important;
}

.leaflet-top.leaflet-right {
  top: calc(var(--app-top) + 108px) !important;
  right: var(--layout-gap) !important;
}

.leaflet-bottom.leaflet-left {
  bottom: var(--map-control-gap) !important;
  left: var(--sidebar-clear) !important;
}

.leaflet-bottom.leaflet-right {
  bottom: var(--map-control-gap) !important;
  right: var(--layout-gap) !important;
}

.leaflet-bottom .leaflet-control,
.leaflet-control-attribution {
  margin-bottom: 0 !important;
}

.leaflet-control-attribution {
  max-width: min(52vw, 520px) !important;
  white-space: normal !important;
  line-height: 1.2 !important;
}

.leaflet-control-layers-expanded {
  max-height: calc(100dvh - var(--app-top) - var(--app-bottom) - 150px) !important;
  overflow-y: auto !important;
}

.study-dock {
  position: absolute !important;
  top: var(--app-top) !important;
  bottom: var(--app-bottom) !important;
  left: var(--layout-gap) !important;
  width: var(--study-dock-width) !important;
  min-width: var(--study-dock-width) !important;
  max-width: var(--study-dock-width) !important;
  height: auto !important;
  padding: 0 !important;
  z-index: var(--z-sidebar) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
}

.study-dock #map-azimuth-widget.map-study-panel .widget-body,
.study-dock #map-solar-widget.map-study-panel .widget-body,
.study-dock #map-shadow-widget.map-study-panel .widget-body,
.study-dock #map-overlap-widget.map-study-panel .widget-body {
  overflow-y: auto !important;
  padding-bottom: 18px !important;
}

body.state-studies .tab-bar,
body.state-coords .tab-bar,
body.state-memorial .tab-bar,
body.state-legislation .tab-bar {
  left: var(--layout-gap) !important;
}

body.state-studies .address-search-control,
body.state-studies .gis-toolbar,
body.state-studies .map-export-toolbar {
  left: var(--study-clear) !important;
  max-width: calc(100% - var(--study-clear) - var(--layout-gap)) !important;
}

body.state-studies .address-search-control {
  width: min(330px, calc(100% - var(--study-clear) - 420px)) !important;
}

body.state-studies .stats-bar {
  max-width: min(390px, calc(100% - var(--study-clear) - 370px)) !important;
}

body.state-studies #topo-alert,
body.state-studies .leaflet-bottom.leaflet-left {
  left: var(--study-clear) !important;
}

body.state-coords .tab-panel:not(#panel-map),
body.state-memorial #panel-memorial.active,
body.state-legislation #panel-legislation.active {
  padding-left: var(--layout-gap) !important;
  padding-right: var(--layout-gap) !important;
  padding-top: 0 !important;
  padding-bottom: calc(var(--app-bottom) + var(--layout-gap)) !important;
}

body.state-coords .stats-bar,
body.state-memorial .stats-bar {
  margin-top: var(--app-top) !important;
  margin-left: var(--layout-gap) !important;
  margin-right: var(--layout-gap) !important;
  max-width: none !important;
}

#toast-container {
  bottom: calc(var(--app-bottom) + 10px) !important;
}

#loading-overlay {
  z-index: calc(var(--z-modal) + 10) !important;
}

@media (max-width: 1100px) {
  .header-sub {
    display: none !important;
  }

  .header-badges {
    overflow-x: auto !important;
    max-width: 62vw !important;
    scrollbar-width: none !important;
  }

  .stats-bar {
    max-width: 42px !important;
    min-height: 38px !important;
    padding: 0 !important;
  }

  .stats-toggle-btn {
    display: inline-flex !important;
  }

  .stats-bar .stat-card {
    display: none !important;
  }

  .address-search-control {
    top: calc(var(--app-top) + 48px) !important;
    width: min(330px, calc(100% - var(--sidebar-clear) - var(--layout-gap))) !important;
    min-width: 0 !important;
  }

  .gis-toolbar {
    top: calc(var(--app-top) + 104px) !important;
  }

  .map-export-toolbar,
  #map-layer-manager-widget {
    top: calc(var(--app-top) + 158px) !important;
  }

  .map-export-toolbar {
    max-width: calc(100% - var(--sidebar-clear) - 326px) !important;
  }

  body.state-studies .map-export-toolbar {
    max-width: calc(100% - var(--study-clear) - 326px) !important;
  }

  #map-layer-manager-widget {
    width: min(300px, calc(100% - var(--sidebar-clear) - 24px)) !important;
  }

  .gis-tool-btn {
    padding: 6px 8px !important;
  }

  body.state-studies .address-search-control {
    top: calc(var(--app-top) + 48px) !important;
    width: min(310px, calc(100% - var(--study-clear) - var(--layout-gap))) !important;
  }

  body.state-studies .gis-toolbar {
    top: calc(var(--app-top) + 104px) !important;
  }

  body.state-studies .map-export-toolbar,
  body.state-studies #map-layer-manager-widget {
    top: calc(var(--app-top) + 158px) !important;
  }
}

@media (max-width: 760px) {
  :root {
    --header-height: 58px;
    --sidebar-width: calc(100vw - 24px);
    --study-dock-width: calc(100vw - 24px);
    --bottom-nav-height: 66px;
  }

  header {
    padding: 8px 10px !important;
  }

  .tab-bar,
  body.state-studies .tab-bar,
  body.state-coords .tab-bar,
  body.state-memorial .tab-bar {
    left: var(--layout-gap) !important;
    right: var(--layout-gap) !important;
  }

  .tab-nav {
    justify-content: flex-start !important;
  }

  body.state-map .sidebar {
    bottom: calc(var(--app-bottom) + 48vh) !important;
    max-height: calc(100dvh - var(--app-top) - var(--app-bottom)) !important;
  }

  .address-search-control,
  .gis-toolbar,
  .map-export-toolbar,
  body.state-studies .address-search-control,
  body.state-studies .gis-toolbar,
  body.state-studies .map-export-toolbar {
    left: var(--layout-gap) !important;
    right: var(--layout-gap) !important;
    max-width: none !important;
    width: auto !important;
  }

  .address-search-control,
  body.state-studies .address-search-control {
    top: var(--app-top) !important;
  }

  .gis-toolbar,
  body.state-studies .gis-toolbar {
    top: calc(var(--app-top) + 56px) !important;
  }

  .map-export-toolbar,
  body.state-studies .map-export-toolbar {
    top: calc(var(--app-top) + 116px) !important;
  }

  .study-dock {
    right: var(--layout-gap) !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    bottom: calc(var(--app-bottom) + 38vh) !important;
  }

  #map-layer-manager-widget,
  body.state-studies #map-layer-manager-widget {
    top: calc(var(--app-top) + 170px) !important;
    left: var(--layout-gap) !important;
    right: var(--layout-gap) !important;
    width: auto !important;
    max-height: calc(100% - var(--app-top) - var(--app-bottom) - 188px) !important;
  }

  #map-thematic-widget {
    left: var(--layout-gap) !important;
    right: var(--layout-gap) !important;
    width: auto !important;
    bottom: 84px !important;
  }

  .leaflet-bottom.leaflet-left,
  body.state-studies .leaflet-bottom.leaflet-left {
    left: var(--layout-gap) !important;
  }

  .leaflet-control-minimap {
    display: none !important;
  }

  .leaflet-control-attribution {
    max-width: calc(100vw - 24px) !important;
  }
}

/* ==========================================================================
   datumap.xyz LAYOUT REGRESSION FIX
   Final pass intentionally keeps layout rules state-based instead of using
   large compensating margins.
   ========================================================================== */
:root {
  --app-gap: 12px;
  --app-header-top: 12px;
  --app-header-height: 52px;
  --app-top: calc(var(--app-header-top) + var(--app-header-height) + var(--app-gap));
  --bottom-nav-height: 52px;
  --bottom-nav-gap: 12px;
  --app-bottom: calc(
    var(--bottom-nav-height) + var(--bottom-nav-gap) + env(safe-area-inset-bottom, 0px)
  );
  --sidebar-width: 320px;
  --sidebar-clear: calc(var(--app-gap) + var(--sidebar-width) + var(--app-gap));
  --study-dock-width: 370px;
  --study-clear: calc(var(--app-gap) + var(--study-dock-width) + var(--app-gap));
  --z-map: 1;
  --z-leaflet-controls: 650;
  --z-map-overlays: 680;
  --z-sidebar: 500;
  --z-bottom-nav: 700;
  --z-header: 800;
  --z-modal: 1000;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
}

header {
  top: var(--app-header-top) !important;
  left: var(--app-gap) !important;
  right: var(--app-gap) !important;
  height: var(--app-header-height) !important;
  z-index: var(--z-header) !important;
}

main,
.content {
  height: 100dvh !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.content {
  display: flex !important;
  flex-direction: column !important;
}

.tab-bar {
  left: max(var(--sidebar-clear), calc(50vw - 270px)) !important;
  right: auto !important;
  bottom: calc(var(--bottom-nav-gap) + env(safe-area-inset-bottom, 0px)) !important;
  width: max-content !important;
  max-width: calc(100vw - var(--sidebar-clear) - var(--app-gap)) !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 7px !important;
  border-radius: 8px !important;
  background: var(--panel) !important;
  border: 1px solid rgba(92, 211, 255, 0.16) !important;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.34) !important;
  backdrop-filter: var(--glass) !important;
  -webkit-backdrop-filter: var(--glass-webkit) !important;
  z-index: var(--z-bottom-nav) !important;
}

body.state-studies .tab-bar,
body.state-coords .tab-bar,
body.state-memorial .tab-bar {
  left: 50% !important;
  transform: translateX(-50%) !important;
  max-width: calc(100vw - (var(--app-gap) * 2)) !important;
}

.tab-bar > .export-actions {
  display: none !important;
}

.tab-nav {
  width: max-content !important;
  max-width: 100% !important;
  justify-content: center !important;
  gap: 4px !important;
}

.tab {
  min-height: 32px !important;
  padding: 7px 12px !important;
  display: inline-flex !important;
  align-items: center !important;
  border: 1px solid transparent !important;
  border-radius: 6px !important;
  letter-spacing: 0 !important;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease !important;
}

.tab:hover {
  background: rgba(143, 168, 195, 0.09) !important;
  color: var(--text) !important;
}

.tab.active {
  background: rgba(0, 183, 255, 0.14) !important;
  border-color: rgba(0, 183, 255, 0.34) !important;
  color: var(--accent2) !important;
}

#map {
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: auto !important;
  height: auto !important;
  z-index: var(--z-map) !important;
}

.sidebar {
  top: var(--app-top) !important;
  left: var(--app-gap) !important;
  bottom: var(--app-bottom) !important;
  width: var(--sidebar-width) !important;
  z-index: var(--z-sidebar) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-bottom: 8px !important;
}

.app-module {
  min-height: 0 !important;
  padding-bottom: 10px !important;
}

.sidebar-primary-action {
  bottom: 0 !important;
}

.stats-bar {
  top: var(--app-top) !important;
  right: var(--app-gap) !important;
  z-index: var(--z-map-overlays) !important;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: stretch !important;
  max-width: min(760px, calc(100vw - var(--sidebar-clear) - 24px)) !important;
  min-height: 0 !important;
  padding: 4px 8px !important;
  overflow: visible !important;
}

.stat-card {
  flex: 0 0 auto !important;
  min-width: 74px !important;
  padding: 5px 10px !important;
}

.stat-card:nth-of-type(5),
.stat-card:nth-of-type(6) {
  min-width: 118px !important;
}

.stat-label {
  font-size: 7px !important;
  letter-spacing: 0.08em !important;
}

.stat-value {
  font-size: 13px !important;
}

.stat-value.area {
  font-size: 11px !important;
}

.stat-primary,
#stat-area,
#stat-perimeter {
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.stat-secondary {
  white-space: normal !important;
}

.stats-toggle-btn {
  flex: 0 0 34px !important;
}

/* Botão de minimizar/expandir estatísticas (📊) oculto em todo o app.
   Especificidade .stats-bar .stats-toggle-btn vence as regras !important de
   menor especificidade (inclusive dentro de media queries). */
.stats-bar .stats-toggle-btn,
.stats-toggle-btn {
  display: none !important;
}

/* Sem o botão, uma barra de estatísticas recolhida não tem como reaparecer:
   oculta a barra recolhida para não deixar uma faixa vazia. */
.stats-bar.collapsed {
  display: none !important;
}

.address-search-control {
  top: var(--app-top) !important;
  left: var(--sidebar-clear) !important;
  width: min(380px, calc(100vw - var(--sidebar-clear) - 420px)) !important;
  min-width: 260px !important;
  z-index: 720 !important;
}

.gis-toolbar {
  top: calc(var(--app-top) + 56px) !important;
  left: var(--sidebar-clear) !important;
  max-width: calc(100vw - var(--sidebar-clear) - var(--app-gap)) !important;
  z-index: var(--z-map-overlays) !important;
  border-radius: 8px !important;
  flex-wrap: wrap !important;
}

.map-export-toolbar {
  top: calc(var(--app-top) + 108px) !important;
  left: var(--sidebar-clear) !important;
  right: auto !important;
  max-width: min(560px, calc(100vw - var(--sidebar-clear) - 340px)) !important;
  z-index: var(--z-map-overlays) !important;
}

body.state-studies .address-search-control,
body.state-studies .gis-toolbar,
body.state-studies .map-export-toolbar {
  left: var(--study-clear) !important;
}

body.state-studies .stats-bar {
  max-width: min(700px, calc(100vw - var(--study-clear) - 24px)) !important;
}

body.state-studies #topo-alert {
  left: var(--study-clear) !important;
}

.leaflet-control-container {
  position: relative !important;
  z-index: var(--z-leaflet-controls) !important;
}

.leaflet-top.leaflet-right {
  top: calc(var(--app-top) + 108px) !important;
  right: var(--app-gap) !important;
}

.leaflet-bottom.leaflet-left {
  left: var(--sidebar-clear) !important;
  bottom: var(--app-gap) !important;
}

body.state-studies .leaflet-bottom.leaflet-left {
  left: var(--study-clear) !important;
}

.leaflet-bottom.leaflet-right {
  right: var(--app-gap) !important;
  bottom: var(--app-gap) !important;
}

.leaflet-bottom .leaflet-control,
.leaflet-control-attribution {
  margin-bottom: 0 !important;
}

.leaflet-control-attribution {
  max-width: min(52vw, 560px) !important;
  white-space: normal !important;
  line-height: 1.2 !important;
}

.leaflet-control-layers-expanded {
  max-height: calc(100dvh - var(--app-top) - var(--app-bottom) - 130px) !important;
  overflow-y: auto !important;
}

#map-layer-manager-widget {
  top: calc(var(--app-top) + 108px) !important;
  right: var(--app-gap) !important;
  width: 320px !important;
  max-height: calc(100dvh - var(--app-top) - var(--app-bottom) - 132px) !important;
}

#map-thematic-widget {
  right: 190px !important;
  bottom: var(--app-gap) !important;
  max-height: calc(100dvh - var(--app-top) - var(--app-bottom) - 32px) !important;
}

.study-dock {
  position: absolute !important;
  top: var(--app-top) !important;
  bottom: var(--app-bottom) !important;
  left: var(--app-gap) !important;
  width: var(--study-dock-width) !important;
  min-width: var(--study-dock-width) !important;
  max-width: var(--study-dock-width) !important;
  height: auto !important;
  padding: 0 !important;
  z-index: var(--z-sidebar) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  overflow: hidden !important;
}

.study-dock #map-azimuth-widget.map-study-panel,
.study-dock #map-solar-widget.map-study-panel,
.study-dock #map-shadow-widget.map-study-panel,
.study-dock #map-overlap-widget.map-study-panel {
  min-height: 0 !important;
  overflow: hidden !important;
}

.study-dock #map-azimuth-widget.map-study-panel .widget-body,
.study-dock #map-solar-widget.map-study-panel .widget-body,
.study-dock #map-shadow-widget.map-study-panel .widget-body,
.study-dock #map-overlap-widget.map-study-panel .widget-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  padding-bottom: 14px !important;
}

.study-dock .solar-compass {
  min-height: 160px !important;
}

body.state-coords .content,
body.state-memorial .content {
  padding-top: var(--app-top) !important;
  padding-bottom: var(--app-bottom) !important;
  gap: 10px !important;
}

/* Páginas com efeito de vidro sobre o satélite: o mapa permanece renderizado ao
   fundo e o conteúdo da página recebe a coloração translúcida (--panel + --glass). */
body.state-coords #panel-map,
body.state-memorial #panel-map,
body.state-legislation #panel-map,
body.state-export #panel-map {
  display: flex !important;
  position: absolute !important;
  inset: 0 !important;
  z-index: 0 !important;
  pointer-events: none !important;
}

body.state-coords #panel-coords,
body.state-memorial #panel-memorial,
body.state-legislation #panel-legislation,
body.state-export #panel-export,
body.state-coords .stats-bar,
body.state-memorial .stats-bar,
body.state-legislation .stats-bar,
body.state-export .stats-bar {
  position: relative !important;
  z-index: 2 !important;
}

/* Camada de vidro full-screen sobre o satélite: cobre a tela inteira de forma
   uniforme (acima dos tiles, abaixo do conteúdo da página). */
body.state-coords #panel-map::after,
body.state-memorial #panel-map::after,
body.state-legislation #panel-map::after,
body.state-export #panel-map::after {
  content: '' !important;
  position: absolute !important;
  inset: 0 !important;
  z-index: 1 !important;
  background: var(--panel) !important;
  backdrop-filter: var(--glass) !important;
  -webkit-backdrop-filter: var(--glass-webkit) !important;
  pointer-events: none !important;
}

/* O conteúdo não tem fundo próprio: o vidro vem da camada full-screen acima. */
body.state-coords #panel-coords,
body.state-memorial #panel-memorial,
body.state-legislation #panel-legislation,
body.state-export #panel-export {
  background: transparent !important;
}

/* Nessas páginas o mapa é só pano de fundo: esconde TODOS os controles/toolbars
   do mapa (busca, ferramentas de desenho, Visualização, norte, minimapa, escala,
   atribuição), mantendo apenas os tiles do satélite (o pane do mapa). */
body.state-coords #panel-map .leaflet-container > *:not(.leaflet-pane),
body.state-memorial #panel-map .leaflet-container > *:not(.leaflet-pane),
body.state-legislation #panel-map .leaflet-container > *:not(.leaflet-pane),
body.state-export #panel-map .leaflet-container > *:not(.leaflet-pane) {
  display: none !important;
}

body.state-coords .stats-bar,
body.state-memorial .stats-bar {
  position: static !important;
  inset: auto !important;
  margin: 0 var(--app-gap) !important;
  max-width: none !important;
  width: auto !important;
  flex: 0 0 auto !important;
  border-radius: 8px !important;
}

body.state-coords .tab-panel:not(#panel-map),
body.state-memorial #panel-memorial.active {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 var(--app-gap) !important;
  overflow: hidden !important;
}

body.state-coords .table-panel,
body.state-memorial .memorial-panel-wrapper {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 4px !important;
  overflow: hidden !important;
}

body.state-coords .panel-toolbar,
body.state-memorial .panel-toolbar {
  margin-bottom: 10px !important;
  padding: 10px 14px !important;
  flex-shrink: 0 !important;
}

body.state-coords .coords-grid,
body.state-memorial .memorial-grid {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
}

body.state-coords .coords-col,
body.state-coords .table-wrap,
body.state-memorial .memorial-col-form,
body.state-memorial .memorial-col-preview,
body.state-memorial #memorial-output {
  min-height: 0 !important;
}

body.state-memorial .memorial-col-form,
body.state-memorial #memorial-output {
  overflow-y: auto !important;
}

#loading-overlay {
  z-index: calc(var(--z-modal) + 10) !important;
}

#toast-container {
  bottom: calc(var(--app-bottom) + 10px) !important;
}

@media (max-width: 1366px) {
  .stats-bar {
    max-width: min(620px, calc(100vw - var(--sidebar-clear) - 24px)) !important;
  }

  .stat-card {
    min-width: 70px !important;
  }

  .stat-card:nth-of-type(5),
  .stat-card:nth-of-type(6) {
    min-width: 110px !important;
  }
}

@media (max-width: 1100px) {
  .header-sub {
    display: none !important;
  }

  .header-badges {
    max-width: 64vw !important;
    overflow-x: auto !important;
  }

  .stats-toggle-btn {
    display: inline-flex !important;
  }

  body.state-map .stats-bar,
  body.state-studies .stats-bar {
    max-width: 42px !important;
    min-height: 38px !important;
    padding: 0 !important;
  }

  body.state-map .stats-bar .stat-card,
  body.state-studies .stats-bar .stat-card {
    display: none !important;
  }

  .address-search-control {
    top: calc(var(--app-top) + 48px) !important;
    width: min(330px, calc(100vw - var(--sidebar-clear) - var(--app-gap))) !important;
    min-width: 0 !important;
  }

  .gis-toolbar {
    top: calc(var(--app-top) + 104px) !important;
  }

  .map-export-toolbar,
  #map-layer-manager-widget {
    top: calc(var(--app-top) + 158px) !important;
  }

  .map-export-toolbar {
    max-width: calc(100vw - var(--sidebar-clear) - 326px) !important;
  }

  body.state-studies .map-export-toolbar {
    max-width: calc(100vw - var(--study-clear) - 326px) !important;
  }

  #map-layer-manager-widget {
    width: min(300px, calc(100vw - var(--sidebar-clear) - 24px)) !important;
  }

  body.state-studies .address-search-control {
    top: calc(var(--app-top) + 48px) !important;
    width: min(310px, calc(100vw - var(--study-clear) - var(--app-gap))) !important;
  }

  body.state-studies .gis-toolbar {
    top: calc(var(--app-top) + 104px) !important;
  }

  body.state-studies .map-export-toolbar,
  body.state-studies #map-layer-manager-widget {
    top: calc(var(--app-top) + 158px) !important;
  }

  body.state-coords .stats-bar,
  body.state-memorial .stats-bar {
    max-width: none !important;
  }

  body.state-coords .stats-bar .stat-card,
  body.state-memorial .stats-bar .stat-card {
    display: block !important;
  }
}

@media (max-width: 760px) {
  :root {
    --app-header-height: 58px;
    --bottom-nav-height: 56px;
    --sidebar-width: calc(100vw - 24px);
    --study-dock-width: calc(100vw - 24px);
  }

  header {
    padding: 8px 10px !important;
  }

  .tab-bar,
  body.state-studies .tab-bar,
  body.state-coords .tab-bar,
  body.state-memorial .tab-bar {
    left: var(--app-gap) !important;
    right: var(--app-gap) !important;
    width: auto !important;
    max-width: none !important;
    transform: none !important;
  }

  .tab-nav {
    width: 100% !important;
    justify-content: flex-start !important;
  }

  .address-search-control,
  .gis-toolbar,
  .map-export-toolbar,
  body.state-studies .address-search-control,
  body.state-studies .gis-toolbar,
  body.state-studies .map-export-toolbar {
    left: var(--app-gap) !important;
    right: var(--app-gap) !important;
    width: auto !important;
    max-width: none !important;
  }

  .address-search-control,
  body.state-studies .address-search-control {
    top: var(--app-top) !important;
  }

  .gis-toolbar,
  body.state-studies .gis-toolbar {
    top: calc(var(--app-top) + 56px) !important;
  }

  .map-export-toolbar,
  body.state-studies .map-export-toolbar {
    top: calc(var(--app-top) + 116px) !important;
  }

  .study-dock {
    right: var(--app-gap) !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .leaflet-bottom.leaflet-left,
  body.state-studies .leaflet-bottom.leaflet-left {
    left: var(--app-gap) !important;
  }

  .leaflet-control-minimap {
    display: none !important;
  }

  .leaflet-control-attribution {
    max-width: calc(100vw - 24px) !important;
  }

  body.state-coords .coords-grid,
  body.state-memorial .memorial-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Rascunhos: override final para vencer blocos antigos duplicados. */
#map-layer-manager-widget {
  width: min(360px, calc(100vw - 24px)) !important;
  max-height: calc(100dvh - var(--app-top) - var(--app-bottom) - 132px) !important;
}

/* Legislacao Regional */
.legislation-panel-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 0 4px 16px 4px;
  overflow: hidden;
}

body.state-legislation .legislation-panel-wrapper {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 4px !important;
  overflow: hidden !important;
}

body.state-legislation .panel-toolbar {
  margin-bottom: 10px !important;
  padding: 10px 14px !important;
  flex-shrink: 0 !important;
}

.legislation-scope {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid rgba(0, 183, 255, 0.32);
  border-radius: 5px;
  background: rgba(0, 183, 255, 0.1);
  color: var(--accent2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.legislation-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 12px;
}

body.state-legislation .legislation-grid {
  height: auto !important;
  min-height: 0 !important;
}

.legislation-sidebar,
.legislation-content {
  min-height: 0;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
}

.legislation-sidebar {
  padding: 12px;
}

.legislation-content {
  padding: 14px;
}

.legislation-search-box {
  margin-bottom: 10px;
}

.legislation-search-box input {
  width: 100%;
}

.legislation-municipality-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.legislation-city-option {
  width: 100%;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(19, 38, 58, 0.55);
  color: var(--text);
  text-align: left;
}

.legislation-city-option:hover,
.legislation-city-option.active {
  border-color: rgba(0, 183, 255, 0.58);
  background: rgba(0, 183, 255, 0.12);
}

.legislation-city-name {
  font-size: 12px;
  font-weight: 700;
}

.legislation-city-meta {
  color: var(--text2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

.legislation-empty-state {
  padding: 16px 10px;
  border: 1px dashed var(--border);
  border-radius: 7px;
  color: var(--text2);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}

.legislation-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border2);
}

.legislation-summary h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.legislation-summary p {
  margin: 4px 0 0;
  color: var(--text2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

.legislation-summary-badges,
.legislation-source-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.legislation-indicator-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.legislation-indicator-group small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legislation-status,
.legislation-trust,
.legislation-source-type,
.legislation-source-authority {
  min-height: 23px;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: rgba(19, 38, 58, 0.6);
  color: var(--text2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.legislation-source-authority.is-secondary {
  color: #f5b84b;
  border-color: rgba(245, 184, 75, 0.36);
  background: rgba(245, 184, 75, 0.11);
}

.legislation-source-authority.is-institutional_partner {
  color: var(--accent2);
  border-color: rgba(0, 183, 255, 0.36);
  background: rgba(0, 183, 255, 0.09);
}

.legislation-status.is-parcial,
.legislation-trust.is-media {
  color: #f5b84b;
  border-color: rgba(245, 184, 75, 0.36);
  background: rgba(245, 184, 75, 0.11);
}

.legislation-status.is-validada,
.legislation-status.is-complete,
.legislation-status.is-high,
.legislation-trust.is-alta,
.legislation-trust.is-confirmed {
  color: var(--green);
  border-color: rgba(53, 208, 127, 0.36);
  background: rgba(53, 208, 127, 0.11);
}

.legislation-status.is-em_revisao,
.legislation-status.is-under_review,
.legislation-status.is-outdated,
.legislation-trust.is-baixa,
.legislation-trust.is-undefined {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.36);
  background: rgba(239, 68, 68, 0.11);
}

.legislation-status.is-initial,
.legislation-status.is-partial,
.legislation-trust.is-approximate,
.legislation-trust.is-multiple,
.legislation-trust.is-manual {
  color: #f5b84b;
  border-color: rgba(245, 184, 75, 0.36);
  background: rgba(245, 184, 75, 0.11);
}

.legislation-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.legislation-metric {
  min-height: 60px;
  padding: 10px;
  border: 1px solid var(--border2);
  border-radius: 7px;
  background: rgba(7, 17, 29, 0.52);
}

.legislation-metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.legislation-metric strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 14px;
}

.legislation-note,
.legislation-disclaimer {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  background: rgba(7, 17, 29, 0.62);
  color: var(--text2);
  font-size: 11px;
  line-height: 1.45;
}

.legislation-disclaimer {
  border-left-color: #f5b84b;
}

.legislation-location-panel {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: rgba(7, 17, 29, 0.38);
}

.legislation-location-panel .legislation-section-title {
  margin-top: 0;
}

.legislation-location-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.legislation-location-copy {
  margin: 4px 0 0;
  color: var(--text2);
  font-size: 11px;
  line-height: 1.4;
}

.legislation-location-header .btn-ghost {
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.legislation-location-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.legislation-location-field {
  min-width: 0;
}

.legislation-inline-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.legislation-inline-action input {
  width: 100%;
}

.legislation-inline-action button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.legislation-location-status {
  min-height: 22px;
  margin-top: 8px;
  color: var(--text2);
  font-size: 11px;
  line-height: 1.4;
}

.legislation-location-status.ok {
  color: var(--green);
}

.legislation-location-status.warn {
  color: #f5b84b;
}

.legislation-location-status.err {
  color: var(--red);
}

.legislation-address-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.legislation-address-result {
  min-height: 58px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(19, 38, 58, 0.48);
  color: var(--text);
  text-align: left;
}

.legislation-address-result:hover {
  border-color: rgba(0, 183, 255, 0.58);
  background: rgba(0, 183, 255, 0.11);
}

.legislation-address-index {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--accent2);
  background: rgba(0, 183, 255, 0.12);
  font-size: 10px;
  font-weight: 800;
}

.legislation-address-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.legislation-address-body strong,
.legislation-address-body small {
  overflow-wrap: anywhere;
}

.legislation-address-body strong {
  font-size: 11px;
}

.legislation-address-body small {
  color: var(--text2);
  font-size: 10px;
}

.legislation-location-result {
  margin-top: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(53, 208, 127, 0.28);
  border-left: 3px solid var(--green);
  border-radius: 7px;
  background: rgba(53, 208, 127, 0.08);
}

.legislation-location-result strong,
.legislation-location-result span,
.legislation-location-result p {
  min-width: 0;
}

.legislation-location-result strong {
  color: var(--text);
  font-size: 12px;
}

.legislation-location-result span {
  color: var(--text2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

.legislation-location-result p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--text2);
  font-size: 11px;
  line-height: 1.45;
}

.legislation-map-button {
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.legislation-section-title {
  margin: 14px 0 8px;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.legislation-section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.legislation-section-header .legislation-section-title {
  margin: 0 0 8px;
}

.legislation-resource-filter {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}

.legislation-resource-filter span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.legislation-resource-filter select {
  min-height: 29px;
  padding: 4px 25px 4px 8px;
  border: 1px solid var(--border2);
  border-radius: 5px;
  background: rgba(19, 38, 58, 0.72);
  color: var(--text);
  font-size: 10px;
}

.legislation-resource-state {
  min-height: 18px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
}

.legislation-resource-state.is-review {
  color: #f5b84b;
}

#legislation-results-wrapper.is-loading {
  opacity: 0.62;
  pointer-events: none;
}

.legislation-source-link.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.legislation-source-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 10px;
}

.legislation-theme-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}

.legislation-theme-card {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--border2);
  border-radius: 7px;
  background: rgba(7, 17, 29, 0.48);
}

.legislation-theme-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.legislation-theme-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.legislation-theme-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.legislation-theme-meta span {
  min-height: 21px;
  display: inline-flex;
  align-items: center;
  padding: 3px 6px;
  border: 1px solid var(--border2);
  border-radius: 5px;
  color: var(--text2);
  background: rgba(19, 38, 58, 0.46);
  font-size: 10px;
  font-weight: 700;
}

.legislation-keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.legislation-keyword-list span {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  padding: 3px 6px;
  border-radius: 999px;
  color: var(--accent2);
  background: rgba(0, 183, 255, 0.09);
  font-size: 10px;
}

.legislation-theme-pending {
  margin: auto 0 0;
  padding-top: 7px;
  border-top: 1px dashed var(--border2);
  color: #f5b84b;
  font-size: 10px;
  line-height: 1.4;
}

.legislation-source-card {
  min-height: 168px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(19, 38, 58, 0.5);
}

.legislation-source-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.legislation-source-title-block {
  min-width: 0;
}

.legislation-source-title-block h3 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.legislation-source-title-block p,
.legislation-source-note {
  margin: 4px 0 0;
  color: var(--text2);
  font-size: 11px;
  line-height: 1.45;
}

.legislation-source-note {
  flex: 1 1 auto;
}

.legislation-source-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border2);
}

.legislation-source-footer span {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
}

.legislation-source-link {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

@media (max-width: 980px) {
  .legislation-grid,
  body.state-legislation .legislation-grid {
    grid-template-columns: 1fr !important;
    overflow: auto;
  }

  .legislation-sidebar,
  .legislation-content {
    overflow: visible;
  }

  .legislation-municipality-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }

  .legislation-source-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .legislation-summary,
  .legislation-source-header,
  .legislation-source-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .legislation-summary-badges,
  .legislation-source-badges {
    justify-content: flex-start;
  }

  .legislation-section-header,
  .legislation-resource-filter {
    align-items: stretch;
    flex-direction: column;
  }

  .legislation-metrics {
    grid-template-columns: 1fr;
  }

  .legislation-location-header,
  .legislation-location-grid,
  .legislation-location-result {
    grid-template-columns: 1fr;
  }

  .legislation-inline-action {
    grid-template-columns: 1fr;
  }
}

#map-layer-manager-widget.force-open {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  position: fixed !important;
  top: 260px !important;
  right: 24px !important;
  left: auto !important;
  width: min(360px, calc(100vw - 48px)) !important;
  max-height: min(520px, calc(100vh - 290px)) !important;
  z-index: 5000 !important;
}

#map-layer-manager-widget.force-open .widget-body {
  visibility: visible !important;
  pointer-events: auto !important;
}

/* ────────────────────────────────────────────────────────────────
   DIAGNÓSTICO E PARÂMETROS URBANÍSTICOS (Fases 04, 05, 06)
   ──────────────────────────────────────────────────────────────── */
.legislation-diagnosis-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: rgba(10, 25, 41, 0.65);
  backdrop-filter: blur(10px);
}

.legislation-diagnosis-header {
  border-bottom: 1px solid var(--border2);
  padding-bottom: 10px;
}

.zone-info-block h3 {
  margin: 0 0 8px 0;
  color: var(--accent2);
  font-size: 14px;
  font-weight: 700;
}

.zone-info-block .legislation-trust,
.zone-info-block .legislation-status {
  margin-right: 6px;
  padding: 4px 8px;
  font-size: 9px;
  font-weight: 800;
}

.legislation-warning-alert {
  padding: 10px 12px;
  border-left: 4px solid #f5b84b;
  border-radius: 4px;
  background: rgba(245, 184, 75, 0.08);
  color: #f5b84b;
  font-size: 11px;
  line-height: 1.45;
}

.legislation-diagnosis-area-input {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: rgba(19, 38, 58, 0.3);
}

.legislation-diagnosis-area-input label {
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
}

.legislation-terrain-area-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legislation-diagnosis-area-input input {
  width: 100%;
  max-width: 200px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  background: var(--bg);
  font-size: 12px;
}

.legislation-diagnosis-params-card {
  padding: 14px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: rgba(19, 38, 58, 0.45);
}

.legislation-diagnosis-params-card h4 {
  margin: 0 0 10px 0;
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
}

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

@media (min-width: 600px) {
  .params-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.param-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border2);
  font-size: 11px;
}

.param-row span {
  color: var(--text2);
}

.param-row strong {
  color: var(--text);
}

.text-params {
  margin-top: 12px;
  border-top: 1px solid var(--border2);
  padding-top: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text2);
}

.text-params p {
  margin: 4px 0;
}

.text-params strong {
  color: var(--text);
}

.legislation-diagnosis-source {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: rgba(7, 17, 29, 0.4);
  font-size: 11px;
  color: var(--text2);
}

.legislation-diagnosis-source strong {
  color: var(--text);
}

.legislation-diagnosis-disclaimer {
  color: var(--muted);
  font-size: 10px;
  font-style: italic;
  line-height: 1.4;
}

.legislation-diagnosis-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 6px;
}

.legislation-diagnosis-actions button {
  min-height: 36px;
  padding: 8px 16px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

/* Bento-style calculation cards */
.legislation-diagnosis-calc-results {
  margin-bottom: 6px;
}

.legislation-diagnosis-calc-results h4 {
  margin: 0 0 10px 0;
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.calc-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(53, 208, 127, 0.28);
  border-radius: 6px;
  background: rgba(53, 208, 127, 0.05);
}

.calc-card span {
  color: var(--text2);
  font-size: 10px;
  font-weight: 700;
}

.calc-card strong {
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
}

.calc-card small {
  color: var(--muted);
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
}

/* Banner de alerta para base em revisão */
.legislation-alert-banner {
  padding: 12px 16px;
  margin-bottom: 16px;
  border-left: 4px solid #ff5e5e;
  border-radius: var(--radius);
  background: rgba(255, 94, 94, 0.08);
  color: #ff5e5e;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
}

/* ────────────────────────────────────────────────────────────────
   ÁREAS DE INTERESSE E ALERTAS (Fase 08)
   ──────────────────────────────────────────────────────────────── */
.legislation-alerts-panel {
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: rgba(10, 25, 41, 0.45);
}

.alerts-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 768px) {
  .alerts-dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.dashboard-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sub-section-title {
  margin: 0 0 4px 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  border-bottom: 1px solid var(--border2);
  padding-bottom: 6px;
}

.saved-areas-list,
.alerts-notifications-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.empty-list-msg {
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
  padding: 12px 0;
  text-align: center;
}

/* Saved area card */
.saved-area-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: rgba(19, 38, 58, 0.35);
}

.saved-area-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.saved-area-info strong {
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-area-info small {
  color: var(--text2);
  font-size: 10px;
}

.saved-area-actions {
  display: flex;
  gap: 6px;
}

.saved-area-actions button {
  min-height: 24px;
  padding: 4px 8px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.btn-danger {
  color: #ff5e5e !important;
}
.btn-danger:hover {
  background: rgba(255, 94, 94, 0.15) !important;
}

/* Alert Notification Card */
.alert-notification-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border2);
  border-left: 4px solid var(--border);
  border-radius: 6px;
  background: rgba(19, 38, 58, 0.35);
}

.alert-notification-card.priority-alta {
  border-left-color: #ff5e5e;
  background: rgba(255, 94, 94, 0.03);
}

.alert-notification-card.priority-media {
  border-left-color: #f5b84b;
  background: rgba(245, 184, 75, 0.03);
}

.alert-notification-card.status-lido {
  opacity: 0.65;
  border-left-color: var(--text2);
  background: rgba(19, 38, 58, 0.15);
}

.alert-notification-card.status-em_revisao {
  border-left-color: #f5b84b;
  background: rgba(245, 184, 75, 0.08);
}

.alert-notification-card strong {
  color: var(--text);
  font-size: 11px;
  padding-right: 80px; /* space for read button */
}

.alert-notification-card p {
  margin: 0;
  color: var(--text2);
  font-size: 10.5px;
  line-height: 1.4;
}

.alert-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9px;
  color: var(--muted);
}

.priority-badge {
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 850;
}

.priority-badge.is-alta {
  color: #ff5e5e;
  background: rgba(255, 94, 94, 0.12);
}

.priority-badge.is-media {
  color: #f5b84b;
  background: rgba(245, 184, 75, 0.12);
}

.alert-notification-card .read-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 22px;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 750;
  text-transform: uppercase;
}

/* EXPLORADOR DE FONTES MUNICIPAIS (FASE 11) */
.legislation-integration-level {
  min-height: 23px;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: rgba(19, 38, 58, 0.6);
  color: var(--text2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.legislation-integration-level.is-automatica {
  color: var(--green);
  border-color: rgba(53, 208, 127, 0.36);
  background: rgba(53, 208, 127, 0.11);
}
.legislation-integration-level.is-parcial {
  color: #f5b84b;
  border-color: rgba(245, 184, 75, 0.36);
  background: rgba(245, 184, 75, 0.11);
}
.legislation-integration-level.is-manual {
  color: #00bcff;
  border-color: rgba(0, 188, 255, 0.36);
  background: rgba(0, 188, 255, 0.11);
}
.legislation-integration-level.is-indisponivel {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.36);
  background: rgba(239, 68, 68, 0.11);
}

.legislation-source-tech-spec {
  margin-top: 10px;
  padding: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 10px;
  font-family: monospace;
  color: var(--text2);
  line-height: 1.4;
}
.legislation-source-tech-spec div {
  margin-bottom: 2px;
}

/* ==========================================================================
   UX REFACTORING — FASE 1
   Entrada > Conversões > Estudos > Mapa > Coordenadas > Memorial > Exportar
   ========================================================================== */
:root {
  --app-header-height: 48px;
  --app-top: calc(var(--app-header-top) + var(--app-header-height) + 10px);
  --sidebar-width: 304px;
  --sidebar-clear: calc(var(--app-gap) + var(--sidebar-width) + var(--app-gap));
  --bottom-nav-height: 64px;
  --bottom-nav-gap: 10px;
  --app-bottom: calc(
    var(--bottom-nav-height) + var(--bottom-nav-gap) + env(safe-area-inset-bottom, 0px)
  );
}

header {
  background: linear-gradient(135deg, rgba(9, 22, 38, 0.94), rgba(11, 28, 46, 0.84)) !important;
  border-color: rgba(92, 211, 255, 0.13) !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22) !important;
}

.sidebar {
  display: block !important;
  border-color: rgba(92, 211, 255, 0.13) !important;
  background: linear-gradient(180deg, rgba(10, 24, 41, 0.94), rgba(8, 20, 35, 0.91)) !important;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.3) !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(92, 211, 255, 0.28) transparent;
}

.module-selector {
  top: 0 !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 3px !important;
  margin: 8px 8px 5px !important;
  padding: 4px !important;
  background: rgba(5, 14, 25, 0.72) !important;
  border-color: rgba(92, 211, 255, 0.1) !important;
  backdrop-filter: blur(18px);
}

.mod-btn {
  min-height: 34px !important;
  padding: 7px 4px !important;
  border: 1px solid transparent !important;
  border-radius: 6px !important;
  color: #7892ad !important;
  font-size: 9px !important;
  letter-spacing: 0.075em !important;
}

.mod-btn:hover {
  color: var(--text) !important;
  background: rgba(255, 255, 255, 0.045) !important;
}

.mod-btn.active {
  color: #dff7ff !important;
  background: linear-gradient(180deg, rgba(0, 183, 255, 0.19), rgba(0, 128, 190, 0.13)) !important;
  border-color: rgba(92, 211, 255, 0.28) !important;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.08),
    0 5px 16px rgba(0, 151, 214, 0.12) !important;
}

.app-module.active {
  display: flex !important;
  flex: 0 0 auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  padding-bottom: 10px !important;
}

.conversion-module.active + .conversion-module.active {
  padding-top: 2px !important;
  border-top: 1px solid rgba(92, 211, 255, 0.1);
}

.module-context {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 10px 3px;
  padding: 10px;
  border: 1px solid rgba(92, 211, 255, 0.1);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(0, 183, 255, 0.08), rgba(0, 212, 200, 0.025));
}

.module-context > span {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  border-radius: 7px;
  background: rgba(0, 183, 255, 0.12);
  color: var(--accent2);
  font:
    700 10px/1 'JetBrains Mono',
    monospace;
}

.module-context div {
  min-width: 0;
}

.module-context strong,
.module-context small {
  display: block;
}

.module-context strong {
  color: var(--text);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.module-context small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.s-section {
  padding-left: 12px !important;
  padding-right: 12px !important;
}

.s-title {
  color: #a9c0d8 !important;
  letter-spacing: 0.07em !important;
}

.workflow-section-note {
  margin: -2px 0 9px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.conversion-scope-list {
  display: grid;
  gap: 5px;
  margin: 4px 10px 8px;
}

.conversion-scope-list span {
  padding: 7px 9px;
  border-left: 2px solid rgba(92, 211, 255, 0.5);
  border-radius: 0 5px 5px 0;
  color: var(--text2);
  background: rgba(0, 183, 255, 0.045);
  font-size: 9px;
}

.conversion-category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 10px;
}

.conversion-category-grid button {
  min-height: 37px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 7px 8px;
  border: 1px solid rgba(143, 168, 195, 0.12);
  border-radius: 6px;
  color: var(--text2);
  background: rgba(18, 36, 56, 0.48);
  font:
    700 9px/1.2 Inter,
    sans-serif;
  cursor: pointer;
}

.conversion-category-grid button:hover,
.conversion-category-grid button.active {
  color: var(--accent2);
  border-color: rgba(92, 211, 255, 0.3);
  background: rgba(0, 183, 255, 0.1);
}

.conversion-category-grid button small {
  color: var(--muted);
  font-size: 7.5px;
  font-weight: 500;
}

/* Estudos passam a viver no painel esquerdo, mantendo os controles existentes. */
#module-studies {
  width: 100%;
}

#module-studies .study-dock,
#module-studies .study-dock.collapsed {
  display: block !important;
  position: static !important;
  inset: auto !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 4px 8px 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: none !important;
  border: 1px solid rgba(92, 211, 255, 0.12) !important;
  border-radius: 9px !important;
  background: rgba(7, 18, 31, 0.64) !important;
  box-shadow: none !important;
}

#module-studies .study-dock-head {
  min-height: 50px;
  padding: 10px 11px !important;
  background: rgba(12, 29, 48, 0.72);
}

#module-studies .study-dock-tabs {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  padding: 8px !important;
  overflow-y: auto !important;
  max-height: 420px !important;
  background: transparent !important;
}

#module-studies .study-dock-tabs button {
  min-height: 54px !important;
  display: flex !important;
  flex-direction: column;
  align-items: flex-start !important;
  justify-content: center;
  gap: 5px;
  padding: 8px 9px !important;
  border: 1px solid rgba(143, 168, 195, 0.12) !important;
  border-radius: 7px !important;
  color: var(--text2) !important;
  background: rgba(18, 36, 56, 0.52) !important;
  font-size: 9px !important;
  text-align: left;
}

#module-studies .study-dock-tabs button:hover {
  color: var(--text) !important;
  border-color: rgba(92, 211, 255, 0.25) !important;
  background: rgba(0, 183, 255, 0.08) !important;
}

#module-studies .study-dock-tabs button.active {
  color: var(--accent2) !important;
  border-color: rgba(0, 183, 255, 0.36) !important;
  background: linear-gradient(135deg, rgba(0, 183, 255, 0.15), rgba(0, 212, 200, 0.06)) !important;
}

.study-tab-icon {
  color: var(--accent2);
  font-size: 15px;
  line-height: 1;
}

.study-category-accordion {
  border-bottom: 1px solid rgba(92, 211, 255, 0.08);
  padding: 2px 0;
}
.study-category-accordion:last-child {
  border-bottom: none;
}

.study-category-accordion summary {
  list-style: none;
  outline: none;
}
.study-category-accordion summary::-webkit-details-marker {
  display: none;
}

.study-category-accordion summary.study-dock-tab-header {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  pointer-events: auto !important;
  user-select: none;
  margin: 4px 0;
  padding: 8px 10px;
  background: rgba(0, 183, 255, 0.04);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background 0.2s ease;
}

.study-category-accordion summary.study-dock-tab-header:hover {
  background: rgba(0, 183, 255, 0.08);
  color: var(--text);
}

.study-category-accordion summary.study-dock-tab-header::after {
  content: '▼';
  font-size: 8px;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.study-category-accordion[open] summary.study-dock-tab-header::after {
  transform: rotate(-180deg);
  color: var(--accent2);
}

.study-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px 4px;
}

.study-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 183, 255, 0.08);
  border: 1px solid rgba(0, 183, 255, 0.2);
  color: var(--accent2);
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.study-back-btn:hover {
  background: rgba(0, 183, 255, 0.16);
  border-color: var(--accent);
  color: var(--text);
}

/* Hide back button when no study is active */
#study-dock:not(:has(.study-panel-active)) .study-back-btn {
  display: none !important;
}

/* When a study is active, hide the selector tabs list to maximize space */
#study-dock:has(.study-panel-active) .study-dock-tabs {
  display: none !important;
}

.study-description-note {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.45;
  margin: 0 0 12px 0;
  padding: 8px 10px;
  background: rgba(0, 183, 255, 0.03);
  border-left: 2px solid rgba(0, 183, 255, 0.3);
  border-radius: 3px;
}

#module-studies .map-overlay-widget,
#module-studies .map-study-panel {
  position: static !important;
  inset: auto !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  margin: 0 !important;
  border: 0 !important;
  border-top: 1px solid rgba(92, 211, 255, 0.1) !important;
  border-radius: 0 0 8px 8px !important;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}

#module-studies .map-study-panel:not(.study-panel-active) {
  display: none !important;
}

#module-studies .map-study-panel.study-panel-active {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

#module-studies .map-study-panel .widget-header {
  display: none !important;
}

#module-studies .map-study-panel .widget-body {
  width: 100%;
  max-height: none !important;
  overflow: visible !important;
  padding: 10px !important;
}

/* Dock inferior: compacto, iconográfico e com ampliação progressiva. */
.tab-bar,
body.state-studies .tab-bar,
body.state-coords .tab-bar,
body.state-memorial .tab-bar,
body.state-legislation .tab-bar,
body.state-export .tab-bar {
  left: calc(var(--sidebar-clear) + ((100vw - var(--sidebar-clear)) / 2)) !important;
  right: auto !important;
  bottom: calc(var(--bottom-nav-gap) + env(safe-area-inset-bottom, 0px)) !important;
  width: max-content !important;
  max-width: calc(100vw - var(--sidebar-clear) - 16px) !important;
  min-height: 0 !important;
  padding: 7px 9px !important;
  transform: translateX(-50%) !important;
  border: 1px solid rgba(132, 204, 235, 0.18) !important;
  border-radius: 17px !important;
  background: var(--panel) !important;
  box-shadow:
    0 18px 45px rgba(0, 0, 0, 0.4),
    inset 0 1px rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: var(--glass) !important;
  -webkit-backdrop-filter: var(--glass-webkit) !important;
  overflow: visible !important;
}

.tab-nav {
  gap: 7px !important;
  overflow: visible !important;
}

.tab[data-workflow='map'] {
  margin-left: 6px;
}

.tab {
  position: relative;
  width: 42px !important;
  height: 42px !important;
  min-height: 42px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 42px !important;
  padding: 0 !important;
  border: 1px solid rgba(143, 168, 195, 0.12) !important;
  border-radius: 12px !important;
  color: #8ca6bf !important;
  background: rgba(21, 42, 64, 0.66) !important;
  font-size: 0 !important;
  transform-origin: center bottom;
  transition:
    transform 180ms cubic-bezier(0.2, 0.75, 0.25, 1.25),
    opacity 160ms ease,
    color 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease !important;
}

.tab svg {
  width: 19px !important;
  height: 19px !important;
  margin: 0 !important;
}

.tab::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
  transform: translateX(-50%);
}

.tab::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  padding: 5px 8px;
  border: 1px solid rgba(143, 168, 195, 0.16);
  border-radius: 6px;
  color: var(--text);
  background: rgba(5, 14, 25, 0.94);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  font-size: 9px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 5px);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.tab-nav:hover .tab {
  transform: translateY(1px) scale(0.94);
  opacity: 0.78;
}

.tab-nav .tab:hover {
  z-index: 3;
  color: #dff8ff !important;
  border-color: rgba(92, 211, 255, 0.42) !important;
  background: linear-gradient(180deg, rgba(0, 183, 255, 0.24), rgba(0, 117, 173, 0.2)) !important;
  transform: translateY(-9px) scale(1.24) !important;
  opacity: 1;
}

.tab-nav .tab:has(+ .tab:hover),
.tab-nav .tab:hover + .tab {
  transform: translateY(-4px) scale(1.08) !important;
  opacity: 0.94;
}

.tab:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tab.active {
  color: var(--accent2) !important;
  border-color: rgba(92, 211, 255, 0.32) !important;
  background: rgba(0, 183, 255, 0.14) !important;
}

.tab.active::before {
  background: var(--accent2);
  box-shadow: 0 0 8px rgba(92, 211, 255, 0.8);
}

/* Central única de saída. */
body.state-export .content {
  padding-top: var(--app-top) !important;
  padding-bottom: var(--app-bottom) !important;
  gap: 10px !important;
}

body.state-export .stats-bar {
  position: static !important;
  inset: auto !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 var(--app-gap) !important;
  flex: 0 0 auto !important;
  border-radius: 8px !important;
}

#panel-export.active {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  padding: 0 var(--app-gap) 0 var(--sidebar-clear) !important;
  overflow-y: auto !important;
}

.export-panel-wrapper {
  width: min(100%, 1120px);
  min-height: 100%;
  margin: 0 auto;
  padding: 0 4px 18px;
}

.export-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.export-group {
  min-height: 188px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border: 1px solid rgba(143, 168, 195, 0.14);
  border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(19, 38, 58, 0.88), rgba(9, 23, 39, 0.88)),
    radial-gradient(circle at top right, rgba(0, 183, 255, 0.1), transparent 42%);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.2);
}

.export-group-primary {
  grid-row: span 2;
  justify-content: flex-end;
  background:
    radial-gradient(circle at 78% 14%, rgba(0, 183, 255, 0.18), transparent 34%),
    linear-gradient(145deg, rgba(15, 44, 67, 0.96), rgba(7, 22, 38, 0.95));
}

.export-group-icon {
  width: 64px;
  height: 76px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: auto;
  padding-bottom: 12px;
  border: 1px solid rgba(92, 211, 255, 0.35);
  border-radius: 8px 8px 12px 12px;
  color: var(--accent2);
  background: rgba(0, 183, 255, 0.1);
  font:
    800 13px/1 Inter,
    sans-serif;
  box-shadow: 0 12px 28px rgba(0, 183, 255, 0.12);
}

.export-group-copy > span {
  color: var(--accent2);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.export-group-copy h3 {
  margin: 6px 0;
  color: var(--text);
  font-size: 17px;
}

.export-group-copy p {
  margin: 0;
  color: var(--text2);
  font-size: 11px;
  line-height: 1.55;
}

.export-panel-action {
  align-self: flex-start;
  min-width: 150px;
}

.export-format-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

/* O mapa fica livre dos antigos botões de saída flutuantes. */
.map-export-toolbar,
.tab-bar > .export-actions {
  display: none !important;
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: min(304px, calc(100vw - 24px));
  }

  .export-panel-grid {
    grid-template-columns: 1fr;
  }

  .export-group-primary {
    grid-row: auto;
  }
}

@media (max-width: 760px) {
  .tab-bar,
  body.state-studies .tab-bar,
  body.state-coords .tab-bar,
  body.state-memorial .tab-bar,
  body.state-legislation .tab-bar,
  body.state-export .tab-bar {
    left: 50% !important;
    right: auto !important;
    width: max-content !important;
    max-width: calc(100vw - 16px) !important;
    transform: translateX(-50%) !important;
  }

  .tab-nav {
    width: max-content !important;
    gap: 4px !important;
  }

  .tab {
    width: 34px !important;
    height: 36px !important;
    min-height: 36px !important;
    flex-basis: 34px !important;
  }

  .tab svg {
    width: 16px !important;
    height: 16px !important;
  }

  .tab-nav .tab:hover,
  .tab-nav .tab:has(+ .tab:hover),
  .tab-nav .tab:hover + .tab {
    transform: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tab,
  .tab::after {
    transition: none !important;
  }
}

/* ==========================================================================
   MAP-FIRST SHELL E RESTAURAÇÃO DOS CONTROLES CARTOGRÁFICOS
   ========================================================================== */
body {
  --workspace-left: var(--app-gap);
}

body.sidebar-open {
  --workspace-left: var(--sidebar-clear);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo {
  width: 36px;
  height: 36px;
  display: block;
  flex: 0 0 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.32));
}

header {
  background: linear-gradient(135deg, rgba(9, 22, 38, 0.78), rgba(11, 28, 46, 0.7)) !important;
  backdrop-filter: blur(14px) saturate(145%) !important;
  -webkit-backdrop-filter: blur(14px) saturate(145%) !important;
}

.module-selector {
  display: none !important;
}

.sidebar {
  background: linear-gradient(180deg, rgba(10, 24, 41, 0.78), rgba(8, 20, 35, 0.74)) !important;
  backdrop-filter: blur(16px) saturate(145%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(145%) !important;
  transition:
    transform 180ms ease,
    opacity 160ms ease,
    visibility 160ms ease !important;
}

body.sidebar-closed .sidebar {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateX(calc(-100% - var(--app-gap))) !important;
}

body.sidebar-open .sidebar {
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateX(0) !important;
}

.module-context,
#module-studies .study-dock,
.export-group {
  background-color: rgba(11, 29, 48, 0.54) !important;
}

.address-search-control {
  left: var(--workspace-left) !important;
  width: clamp(330px, calc(100vw - var(--workspace-left) - 624px), 760px) !important;
  min-width: 260px !important;
  background: rgba(11, 27, 45, 0.72) !important;
  backdrop-filter: blur(16px) saturate(150%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(150%) !important;
  transition:
    left 180ms ease,
    width 180ms ease !important;
}

.gis-toolbar {
  left: var(--workspace-left) !important;
  max-width: calc(100vw - var(--workspace-left) - var(--app-gap)) !important;
  background: rgba(11, 27, 45, 0.72) !important;
  backdrop-filter: blur(16px) saturate(150%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(150%) !important;
  transition: left 180ms ease !important;
}

.stats-bar {
  max-width: min(520px, calc(100vw - var(--workspace-left) - 420px)) !important;
  background: rgba(11, 27, 45, 0.72) !important;
  backdrop-filter: blur(16px) saturate(150%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(150%) !important;
}

.tab-bar,
body.state-studies .tab-bar,
body.state-coords .tab-bar,
body.state-memorial .tab-bar,
body.state-legislation .tab-bar,
body.state-export .tab-bar {
  left: calc(var(--workspace-left) + ((100vw - var(--workspace-left)) / 2)) !important;
  max-width: calc(100vw - var(--workspace-left) - 16px) !important;
  transition: left 180ms ease !important;
}

.street-view-tool {
  color: #f5a623 !important;
}

.street-view-tool:hover {
  color: #ffd36b !important;
  background: rgba(245, 166, 35, 0.15) !important;
}

.street-view-tool.active {
  color: #1a1203 !important;
  background: #f5a623 !important;
  box-shadow: 0 0 12px rgba(245, 166, 35, 0.45) !important;
}

.street-view-pegman {
  flex: 0 0 auto;
  fill: currentColor;
}

#map.street-view-selection-active,
#map.street-view-selection-active .leaflet-interactive {
  cursor: crosshair !important;
}

.leaflet-control-container {
  position: absolute !important;
  inset: 0 !important;
  z-index: var(--z-leaflet-controls) !important;
  pointer-events: none;
}

.leaflet-control {
  pointer-events: auto;
}

.leaflet-bottom.leaflet-left {
  left: var(--workspace-left) !important;
  bottom: calc(var(--app-bottom) + var(--app-gap)) !important;
  transition: left 180ms ease !important;
}

.leaflet-control-scale {
  margin: 0 !important;
  padding: 0 4px 2px !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.leaflet-control-scale-line {
  height: 18px !important;
  margin: 0 !important;
  padding: 2px 4px 0 !important;
  border: 0 !important;
  border-top: 2px solid rgba(234, 242, 255, 0.92) !important;
  border-left: 2px solid rgba(234, 242, 255, 0.92) !important;
  border-right: 2px solid rgba(234, 242, 255, 0.92) !important;
  background: transparent !important;
  color: #eaf2ff !important;
  font-family: 'JetBrains Mono', Consolas, monospace !important;
  font-size: 9px !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75) !important;
}

#coord-display,
.map-north-indicator {
  border: 1px solid rgba(234, 242, 255, 0.14);
  background: rgba(5, 10, 17, 0.54);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(12px) saturate(145%);
  -webkit-backdrop-filter: blur(12px) saturate(145%);
  z-index: var(--z-leaflet-controls);
}

#coord-display {
  top: auto !important;
  right: auto !important;
  bottom: calc(var(--app-bottom) + var(--app-gap)) !important;
  left: calc(var(--workspace-left) + 198px) !important;
  width: 250px !important;
  min-height: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 7px;
  color: #7ce7d4;
  font:
    750 9px/1.25 'JetBrains Mono',
    Consolas,
    monospace;
  transition: left 180ms ease !important;
}

.map-north-indicator {
  position: absolute;
  top: var(--app-top);
  right: calc(var(--app-gap) + 540px);
  width: 42px;
  height: 51px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  /* Mesma cor de vidro dos demais menus (--panel + --glass). */
  background: var(--panel) !important;
  backdrop-filter: var(--glass) !important;
  -webkit-backdrop-filter: var(--glass-webkit) !important;
  /* Captura o clique para não vazar para o limite IBGE (popup) atrás. */
  pointer-events: auto;
}

.map-north-icon {
  width: 28px;
  height: 42px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.leaflet-top.leaflet-right {
  top: calc(var(--app-top) + 58px) !important;
  right: var(--app-gap) !important;
}

.leaflet-control-layers {
  padding: 7px 10px !important;
}

.leaflet-control-layers-toggle {
  width: 48px !important;
  height: 48px !important;
  background-image: url('../assets/icone-camada-mapas.png?v=2') !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: 48px 48px !important;
  cursor: pointer !important;
  transition:
    background-color 0.2s ease,
    opacity 0.2s ease !important;
}

.leaflet-control-layers-toggle:hover {
  background-color: var(--border) !important;
}

/* Garante que o botão continue visível no canto superior direito quando o menu está expandido */
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
  display: block !important;
  position: absolute !important;
  top: 8px !important;
  right: 12px !important;
  width: 20px !important;
  height: 20px !important;
  background-size: 20px 20px !important;
  background-color: transparent !important;
  opacity: 0.7 !important;
}

.leaflet-control-layers-expanded .leaflet-control-layers-toggle:hover {
  opacity: 1 !important;
  background-color: transparent !important;
}

.leaflet-control-minimap,
.leaflet-control-attribution {
  opacity: 0.76;
}

.leaflet-control-attribution {
  box-sizing: border-box !important;
  padding: 3px 8px !important;
  border-radius: 4px !important;
  line-height: 1.15 !important;
}

@media (min-width: 1101px) {
  body.state-map .leaflet-bottom.leaflet-right .leaflet-control-attribution {
    position: fixed !important;
    left: var(--map-attribution-left, calc(100vw - 460px)) !important;
    right: auto !important;
    bottom: calc(var(--bottom-nav-gap) + 15px) !important;
    width: var(--map-attribution-width, 420px) !important;
    max-width: var(--map-attribution-width, 420px) !important;
    margin-bottom: 0 !important;
  }
}

#map-history-widget {
  top: calc(var(--app-top) + 108px) !important;
  left: calc(var(--workspace-left) + 352px) !important;
  right: auto !important;
  width: min(520px, calc(100vw - var(--workspace-left) - 386px)) !important;
  max-height: none !important;
  padding: 0 !important;
  transform: none !important;
  background: rgba(11, 27, 45, 0.82);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass-webkit);
}

#map-history-widget.force-open {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 740 !important;
}

.history-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px 9px !important;
}

.history-main-row,
.history-slider-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.history-title {
  color: var(--accent2);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.history-date-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-width: 100px;
}

.history-label,
.history-year {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

.history-source {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--text2);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-toggle-btn,
.history-step-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  background: var(--panel2);
  color: var(--text2);
  cursor: pointer;
  font-family: inherit;
  font-weight: 850;
}

.history-toggle-btn {
  height: 23px;
  padding: 0 10px;
  font-size: 9px;
}

.history-step-btn {
  width: 24px;
  height: 22px;
  flex: 0 0 24px;
  padding: 0;
  font-size: 16px;
}

.history-year {
  width: 32px;
  text-align: center;
}

#history-slider {
  flex: 1;
  min-width: 120px;
  accent-color: var(--accent);
}

.history-status {
  overflow: hidden;
  color: var(--text2);
  font-size: 9px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-status.ok {
  color: var(--green);
}

.history-status.loading {
  color: var(--accent2);
}

.history-status.error {
  color: var(--red);
}

@media (max-width: 1100px) {
  .map-north-indicator {
    top: calc(var(--app-top) + 48px);
    right: var(--app-gap);
    width: 40px;
    height: 38px;
  }

  #coord-display {
    left: calc(var(--workspace-left) + 128px) !important;
    width: min(250px, calc(100vw - var(--workspace-left) - 150px)) !important;
  }
}

@media (max-width: 760px) {
  .header-logo {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .address-search-control,
  .gis-toolbar {
    left: var(--app-gap) !important;
    right: var(--app-gap) !important;
    width: auto !important;
    max-width: none !important;
  }

  #coord-display {
    left: var(--app-gap) !important;
    right: var(--app-gap) !important;
    bottom: calc(var(--app-bottom) + var(--app-gap) + 44px) !important;
    width: auto !important;
  }

  #map-history-widget {
    top: calc(var(--app-top) + 182px) !important;
    left: 50% !important;
    width: min(460px, calc(100vw - 24px)) !important;
    transform: translateX(-50%) !important;
  }
}

/* ==========================================================================
   AUDITORIA DE LAYOUT DO MAPA — 2026-06-18
   Mantém os overlays cartográficos em âncoras estáveis entre os workflows.
   ========================================================================== */
:root {
  --map-stats-width: 480px;
  --map-bottom-control-height: 24px;
}

/* Título e subtítulo compartilham o mesmo eixo após o logotipo. */
.header-left {
  display: grid !important;
  grid-template-columns: 36px max-content;
  grid-template-rows: auto auto;
  column-gap: 8px !important;
  row-gap: 0 !important;
  align-items: center !important;
}

.header-brand {
  display: contents !important;
}

.header-logo {
  grid-column: 1;
  grid-row: 1 / 3;
}

.header-left h1 {
  grid-column: 2;
  grid-row: 1;
  line-height: 1.1;
}

.header-sub {
  grid-column: 2;
  grid-row: 2;
  line-height: 1.2;
}

/* O dock é ancorado ao viewport; abrir a lateral não deve deslocá-lo. */
.tab-bar,
body.state-studies .tab-bar,
body.state-coords .tab-bar,
body.state-memorial .tab-bar,
body.state-legislation .tab-bar,
body.state-export .tab-bar {
  left: 50% !important;
  right: auto !important;
  max-width: calc(100vw - (var(--app-gap) * 2)) !important;
  transform: translateX(-50%) !important;
  transition: none !important;
}

/* Indicadores do mapa em uma única linha, sem empurrar o controle de camadas. */
body.state-map .stats-bar,
body.state-studies .stats-bar {
  width: var(--map-stats-width) !important;
  max-width: var(--map-stats-width) !important;
  min-height: 0 !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  overflow: hidden !important;
}

body.state-map .stats-bar .stat-card,
body.state-studies .stats-bar .stat-card {
  flex: 0 0 62px !important;
  width: 62px !important;
  min-width: 62px !important;
  padding: 5px 8px !important;
}

body.state-map .stats-bar .stat-card:nth-of-type(5),
body.state-map .stats-bar .stat-card:nth-of-type(6),
body.state-studies .stats-bar .stat-card:nth-of-type(5),
body.state-studies .stats-bar .stat-card:nth-of-type(6) {
  flex-basis: 108px !important;
  width: 108px !important;
  min-width: 108px !important;
}

.map-north-indicator {
  right: calc(var(--app-gap) + var(--map-stats-width) + var(--app-gap)) !important;
}

/* Escala e coordenadas formam um único conjunto no canto inferior esquerdo. */
.leaflet-control-scale {
  min-width: 70px !important;
  height: var(--map-bottom-control-height) !important;
  display: flex !important;
  align-items: center !important;
  margin: 0 !important;
  padding: 3px 7px !important;
  border: 1px solid rgba(234, 242, 255, 0.14) !important;
  border-radius: 7px !important;
  background: rgba(5, 10, 17, 0.58) !important;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18) !important;
  backdrop-filter: blur(12px) saturate(145%) !important;
  -webkit-backdrop-filter: blur(12px) saturate(145%) !important;
}

.leaflet-control-scale-line {
  height: 15px !important;
  padding-top: 2px !important;
}

#coord-display {
  min-height: var(--map-bottom-control-height) !important;
  height: var(--map-bottom-control-height) !important;
  bottom: calc(var(--app-bottom) + var(--app-gap)) !important;
}

#map:has(.leaflet-control-layers-expanded) #coord-display {
  opacity: 1 !important;
  visibility: visible !important;
}

@media (min-width: 761px) {
  #coord-display {
    /* Afasta as coordenadas da régua de escala (que vai até ~100px) para não
       haver sobreposição em escalas como 300 m. */
    left: calc(var(--workspace-left) + 124px) !important;
    width: 280px !important;
  }
}

@media (min-width: 1101px) {
  .leaflet-bottom.leaflet-left {
    bottom: var(--app-gap) !important;
  }

  #coord-display {
    bottom: var(--app-gap) !important;
    width: 220px !important;
  }
}

/* O botão recolhido de camadas ocupa somente o espaço do ícone. */
.leaflet-control-layers:not(.leaflet-control-layers-expanded) {
  width: 52px !important;
  height: 52px !important;
  padding: 1px !important;
  overflow: hidden !important;
  border-radius: 10px !important;
}

.leaflet-control-layers-expanded {
  margin-top: 48px !important;
  max-height: calc(100dvh - var(--app-top) - var(--app-bottom) - 168px) !important;
  width: 300px !important;
  min-width: 300px !important;
}

@media (max-width: 1100px) {
  :root {
    --map-stats-width: 42px;
  }

  body.state-map .stats-bar,
  body.state-studies .stats-bar {
    width: 42px !important;
    max-width: 42px !important;
    height: 38px !important;
    padding: 0 !important;
  }

  .map-north-indicator {
    right: calc(var(--app-gap) + 64px) !important;
  }

  .leaflet-top.leaflet-right {
    top: calc(var(--app-top) + 159px) !important;
  }

  body.sidebar-open .leaflet-top.leaflet-right {
    top: calc(var(--app-top) + 207px) !important;
  }

  .leaflet-control-layers-expanded {
    margin-top: 10px !important;
    max-height: calc(100dvh - var(--app-top) - var(--app-bottom) - 260px) !important;
  }
}

@media (max-width: 760px) {
  #coord-display {
    left: var(--app-gap) !important;
    right: var(--app-gap) !important;
    bottom: calc(var(--app-bottom) + var(--app-gap) + 44px) !important;
    width: auto !important;
    max-width: none !important;
  }

  .leaflet-bottom.leaflet-right {
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Âncora final: norte à direita dos indicadores e acima do botão de camadas. */
@media (min-width: 1101px) {
  body.state-map .stats-bar,
  body.state-studies .stats-bar {
    right: calc(var(--app-gap) + 64px) !important;
  }

  .map-north-indicator {
    top: var(--app-top) !important;
    right: calc(var(--app-gap) + 15px) !important;
  }
}

/* Escala e coordenadas pertencem ao mapa e não acompanham a abertura da lateral. */
body.state-map .leaflet-bottom.leaflet-left,
body.state-studies .leaflet-bottom.leaflet-left {
  left: var(--app-gap) !important;
  transition: none !important;
}

body.state-map #coord-display,
body.state-studies #coord-display {
  /* +124px afasta as coordenadas da régua de escala (até ~100px) no canto
     inferior esquerdo, evitando sobreposição em escalas como 300 m. */
  left: calc(var(--app-gap) + 124px) !important;
  transition: none !important;
}

@media (max-width: 760px) {
  body.state-map #coord-display,
  body.state-studies #coord-display {
    left: var(--app-gap) !important;
  }
}

/* ==========================================================================
   PAINEL DE VISUALIZAÇÃO / CAMADAS
   Estado controlado por JS, sem deslocamentos geométricos durante a abertura.
   ========================================================================== */
.leaflet-control-layers.datumap-layers-control {
  box-sizing: border-box !important;
  position: relative !important;
  z-index: calc(var(--z-leaflet-controls) + 1) !important;
  pointer-events: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  /* Mesmo vidro dos demais menus, também no estado recolhido. */
  backdrop-filter: var(--glass) !important;
  -webkit-backdrop-filter: var(--glass-webkit) !important;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease !important;
}

.leaflet-control-layers.datumap-layers-control:not(.leaflet-control-layers-expanded) {
  width: 52px !important;
  min-width: 52px !important;
  height: 52px !important;
  margin-top: 0 !important;
  padding: 1px !important;
  overflow: hidden !important;
}

.datumap-layers-control .leaflet-control-layers-toggle {
  display: block !important;
  box-sizing: border-box !important;
  border-radius: 8px !important;
  outline-offset: 2px;
  /* Fundo transparente para revelar o vidro (--panel + --glass) do container. */
  background-color: transparent !important;
}

.datumap-layers-control .leaflet-control-layers-toggle:focus-visible {
  outline: 2px solid var(--accent) !important;
}

.leaflet-control-layers-expanded.datumap-layers-control {
  width: min(320px, calc(100vw - (var(--app-gap) * 2))) !important;
  min-width: min(300px, calc(100vw - (var(--app-gap) * 2))) !important;
  max-height: calc(100vh - 120px) !important;
  max-height: min(
    calc(100vh - 120px),
    calc(100dvh - var(--app-top) - var(--app-bottom) - 76px)
  ) !important;
  margin-top: 0 !important;
  padding: 14px 12px 12px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  /* Mesma transparência de vidro dos demais menus do app (--panel + --glass). */
  background: var(--panel) !important;
  backdrop-filter: var(--glass) !important;
  -webkit-backdrop-filter: var(--glass-webkit) !important;
  border-color: rgba(92, 211, 255, 0.24) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34) !important;
}

.leaflet-control-layers-expanded.datumap-layers-control .leaflet-control-layers-toggle {
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  width: 40px !important;
  height: 40px !important;
  background-size: 26px 26px !important;
  background-color: rgba(255, 255, 255, 0.035) !important;
  opacity: 0.82 !important;
}

.leaflet-control-layers-expanded.datumap-layers-control .leaflet-control-layers-toggle:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
  opacity: 1 !important;
}

.datumap-layers-control .layers-main-title {
  min-height: 34px;
  margin-right: 42px !important;
  padding: 4px 0 10px !important;
}

.datumap-layers-control:not(.leaflet-control-layers-expanded) .layers-main-title {
  display: none !important;
}

.datumap-layers-control .leaflet-control-layers-list {
  min-width: 0;
  margin: 0 !important;
}

.datumap-layers-control label,
.datumap-layers-control label span {
  min-width: 0;
}

.datumap-layers-control label span {
  white-space: normal !important;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .leaflet-control-layers-expanded.datumap-layers-control {
    position: fixed !important;
    top: calc(var(--app-top) + var(--app-gap)) !important;
    right: var(--app-gap) !important;
    bottom: calc(var(--app-bottom) + var(--app-gap)) !important;
    left: auto !important;
    width: min(360px, calc(100vw - (var(--app-gap) * 2))) !important;
    min-width: 0 !important;
    max-height: calc(100dvh - var(--app-top) - var(--app-bottom) - (var(--app-gap) * 2)) !important;
    margin: 0 !important;
    border-radius: 12px !important;
  }
}

/* ============================================================
   ESTUDOS TÉCNICOS 2.0 DYNAMIC UI
   ============================================================ */
.studies-catalog {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px;
  overflow-y: auto;
  max-height: calc(100% - 70px);
}

.studies-cat-section h4 {
  font-size: 11px;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.studies-cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.study-card-btn {
  background: rgba(14, 28, 47, 0.45);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  white-space: normal;
}

.study-card-btn:hover {
  background: rgba(26, 50, 78, 0.6);
  border-color: var(--accent);
}

.study-card-btn strong {
  font-size: 12px;
  color: var(--text);
  display: block;
  margin-bottom: 4px;
}

.study-card-btn p {
  font-size: 10px;
  color: var(--text2);
  margin: 0;
  line-height: 1.3;
}

/* Dynamic Parameters Form */
.dynamic-study-params-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.dynamic-study-params-container .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dynamic-study-params-container label {
  font-size: 10px;
  color: var(--text2);
}

.dynamic-study-params-container input,
.dynamic-study-params-container select {
  background: rgba(7, 17, 29, 0.45);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 11px;
}

/* Dynamic Results Rendering */
.dynamic-study-results-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.study-results-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}

.study-results-table th,
.study-results-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px;
}

.study-results-table th {
  color: var(--text2);
  font-weight: 500;
}

.study-results-table td strong {
  color: var(--accent2);
}

.study-classification-block {
  background: rgba(0, 183, 255, 0.08);
  border: 1px solid rgba(0, 183, 255, 0.25);
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text);
}

.study-error-block,
.study-warning-block,
.study-alert-block {
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 10.5px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.study-error-block {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ff9e9e;
}

.study-warning-block {
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.25);
  color: #ffe0b2;
}

.study-alert-block {
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid rgba(244, 67, 54, 0.3);
  color: #ff8a80;
}

/* ============================================================
   ESTUDOS TÉCNICOS 2.0 CATEGORY HEADERS & PLACEHOLDER
   ============================================================ */
.study-dock-tab-header {
  grid-column: 1 / -1;
  font-size: 9px;
  color: var(--accent2);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 12px 0 4px;
  padding: 4px 6px;
  background: rgba(0, 183, 255, 0.05);
  border-left: 2px solid var(--accent);
  border-radius: 2px;
  pointer-events: none;
}

.study-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  margin: 12px 10px;
  padding: 20px 16px;
  border: 1px dashed rgba(0, 183, 255, 0.2);
  border-radius: 8px;
  background: rgba(14, 28, 47, 0.2);
  color: var(--text2);
  font-size: 11px;
  line-height: 1.5;
}

.study-placeholder .placeholder-icon {
  font-size: 24px;
  color: var(--accent2);
}

.study-placeholder strong {
  font-size: 13px;
  color: var(--text);
  margin-top: 4px;
}

.study-placeholder p {
  margin: 0;
}

.study-placeholder .btn-load-example {
  margin-top: 8px;
  background: rgba(0, 183, 255, 0.12);
  border: 1px solid rgba(0, 183, 255, 0.25);
  color: var(--accent2);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.study-placeholder .btn-load-example:hover {
  background: rgba(0, 183, 255, 0.2);
  border-color: var(--accent);
  color: var(--text);
}

/* Hide empty state placeholder when any study is active */
#study-dock:has(.study-panel-active) #study-dock-placeholder {
  display: none !important;
}

.study-config-section {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.study-config-section h5,
.study-results-subtitle {
  margin: 0;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.study-repeater {
  display: grid;
  gap: 7px;
}

.study-repeater-row {
  display: grid;
  grid-template-columns: minmax(90px, 1.3fr) minmax(72px, 1fr) minmax(64px, 0.8fr);
  gap: 6px;
  align-items: center;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(8, 20, 34, 0.35);
  font-size: 10px;
}

.study-repeater-row input,
.study-repeater-row select {
  width: 100%;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  background: rgba(9, 25, 41, 0.9);
}

.study-repeater-row small {
  display: block;
  margin-top: 2px;
  color: var(--text2);
}

.study-check,
.study-segment-choice {
  cursor: pointer;
}

.study-check {
  display: flex;
  gap: 5px;
  align-items: center;
}

.study-check input,
.study-segment-choice > input {
  width: auto;
}

.study-surface-editor .study-repeater-row {
  grid-template-columns: minmax(95px, 1.4fr) minmax(68px, 0.8fr) 56px minmax(74px, 0.8fr);
}

.study-boundary-editor .study-repeater-row {
  grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr);
}

.study-setback-editor .study-repeater-row,
.study-frontage-editor .study-repeater-row {
  grid-template-columns: minmax(82px, 0.8fr) minmax(105px, 1fr) minmax(90px, 1fr);
}

.study-restrictions-editor .study-repeater-row {
  grid-template-columns: minmax(110px, 1fr) minmax(85px, 0.7fr) 30px;
}

.study-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.study-inline-actions button,
.study-run-button,
.study-config-section > button {
  min-height: 32px;
  padding: 7px 9px;
  border: 1px solid rgba(39, 194, 255, 0.45);
  border-radius: 6px;
  color: var(--accent);
  background: rgba(39, 194, 255, 0.08);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.study-run-button {
  width: 100%;
  margin-top: 12px;
  background: rgba(39, 194, 255, 0.16);
}

.study-interaction-status {
  margin: 0;
  color: var(--text2);
  font-size: 10px;
  line-height: 1.45;
}

.study-conclusion-block {
  margin-top: 10px;
  padding: 9px;
  border: 1px solid rgba(46, 204, 142, 0.35);
  border-radius: 6px;
  color: #8be7bc;
  background: rgba(46, 204, 142, 0.08);
  font-size: 10px;
}

@media (max-width: 720px) {
  .study-surface-editor .study-repeater-row,
  .study-setback-editor .study-repeater-row,
  .study-frontage-editor .study-repeater-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   ABA EXPORTAR — redesenho (cabeçalho, estado vazio, resumo,
   cards equilibrados, estados de botão, dock e acessibilidade).
   Bloco final: prevalece no cascade sobre as regras anteriores.
   ============================================================ */

/* Layout do painel: conteúdo alinhado ao topo, largura equilibrada e
   recuo simétrico (a lateral fica oculta na aba Exportar). */
#panel-export.active {
  padding: 0 var(--app-gap) 8px var(--app-gap) !important;
}

.export-panel-wrapper {
  width: min(100%, 1180px);
  min-height: 0;
  margin: 0 auto;
  padding: 2px 2px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Cabecalho */
.export-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.export-head-text h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.export-head-sub {
  margin: 4px 0 0;
  max-width: 640px;
  color: var(--text2);
  font-size: 12.5px;
  line-height: 1.5;
}

.export-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 7px 13px;
  border: 1px solid rgba(143, 168, 195, 0.22);
  border-radius: 999px;
  background: rgba(11, 27, 45, 0.6);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.export-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.export-status[data-state='ready'] {
  border-color: rgba(53, 208, 127, 0.4);
  color: #9be9c1;
}

.export-status[data-state='ready'] .export-status-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(53, 208, 127, 0.18);
}

.export-status[data-state='empty'] .export-status-dot {
  background: #c9a13b;
  box-shadow: 0 0 0 3px rgba(201, 161, 59, 0.16);
}

/* Banner de estado vazio */
.export-empty {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  border: 1px dashed rgba(143, 168, 195, 0.3);
  border-radius: var(--radius-lg);
  background: rgba(11, 27, 45, 0.5);
}

.export-empty[hidden] {
  display: none;
}

.export-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid rgba(143, 168, 195, 0.22);
  background: rgba(0, 183, 255, 0.08);
  color: var(--accent2);
}

.export-empty-body h3 {
  margin: 0 0 5px;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
}

.export-empty-body p {
  margin: 0 0 12px;
  max-width: 560px;
  color: var(--text2);
  font-size: 12.5px;
  line-height: 1.5;
}

.export-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.export-empty-actions button {
  min-width: 0;
}

/* Resumo da poligonal ativa */
.export-summary {
  padding: 14px 18px;
  border: 1px solid rgba(53, 208, 127, 0.26);
  border-radius: var(--radius-lg);
  background: rgba(13, 37, 32, 0.42);
}

.export-summary[hidden] {
  display: none;
}

.export-summary-tag {
  display: inline-block;
  margin-bottom: 10px;
  color: #9be9c1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.export-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px 22px;
}

.export-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.export-summary-item strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.1;
}

.export-summary-item span {
  color: var(--text2);
  font-size: 11px;
}

.export-summary-item-wide {
  grid-column: span 2;
}

/* Regiao viva de mensagens */
.export-live {
  margin: 0;
  min-height: 0;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.4;
}

.export-live:empty {
  display: none;
}

/* Grid principal: PDF (esq, 2 linhas) + CSV/GIS (dir) */
.export-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.export-group {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border: 1px solid rgba(143, 168, 195, 0.16);
  border-radius: var(--radius-lg);
  background-image: none;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

/* PDF e CSV dividem a linha de cima; ambos com a mesma altura.
   grid-row: auto sobrescreve a regra antiga (span 2) anterior no arquivo. */
.export-group-primary {
  grid-row: auto;
  grid-column: auto;
  justify-content: flex-start;
  background-image: none;
}

/* "Arquivos geoespaciais" ocupa a base inteira (linha de baixo). */
.export-group-wide {
  grid-column: 1 / -1;
}

.export-group-cat {
  color: var(--accent2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.export-group h3 {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
}

.export-group-desc {
  margin: 0;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.55;
}

/* Corpo dos cards de exportação: miniatura/ícone à esquerda + lista de
   conteúdo à direita. Reutilizado pelo card de PDF e pelo card de CSV. */
.export-card-body {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-top: 2px;
}

.export-pdf-preview {
  flex: 0 0 88px;
  width: 88px;
  height: 116px;
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border: 1px solid rgba(143, 168, 195, 0.22);
  border-radius: 6px;
  background: linear-gradient(180deg, #f6f9fd, #e8eef6);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.export-pdf-bar {
  height: 7px;
  width: 60%;
  border-radius: 2px;
  background: #21487f;
}

.export-pdf-line {
  height: 3px;
  border-radius: 2px;
  background: #b9c6d8;
}

.export-pdf-line-title {
  width: 80%;
  background: #8aa0bd;
}

.export-pdf-line.short {
  width: 55%;
}

.export-pdf-map {
  height: 34px;
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, #cdd9e8, #cdd9e8 4px, #dde6f1 4px, #dde6f1 8px);
  border: 1px solid #b3c2d6;
}

.export-pdf-table {
  margin-top: auto;
  height: 20px;
  border-radius: 3px;
  background: repeating-linear-gradient(#d4deeb, #d4deeb 4px, #eef3f9 4px, #eef3f9 7px);
}

.export-includes-list {
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.export-includes-list li {
  position: relative;
  padding-left: 20px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.export-includes-list li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 4px;
  width: 9px;
  height: 6px;
  border-left: 2px solid var(--accent2);
  border-bottom: 2px solid var(--accent2);
  transform: rotate(-45deg);
}

/* Ícone do card CSV: mesma largura/alinhamento da miniatura do PDF. */
.export-csv-icon {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(63, 191, 127, 0.3);
  background: linear-gradient(160deg, rgba(63, 191, 127, 0.14), rgba(13, 37, 32, 0.42));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.export-csv-icon svg {
  width: 46px;
  height: 46px;
}

/* Lista de formatos GIS/CAD: card largo na base → uma única linha. */
.export-format-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.export-format-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 11px 13px;
  text-align: left;
  border: 1px solid rgba(143, 168, 195, 0.18);
  border-radius: 9px;
  background: rgba(21, 42, 64, 0.5);
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    transform 120ms ease;
}

.export-format-item:hover:not(:disabled) {
  border-color: rgba(92, 211, 255, 0.4);
  background: rgba(0, 183, 255, 0.1);
}

.export-format-item:active:not(:disabled) {
  transform: translateY(1px);
}

.export-format-item .ef-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.export-format-item .ef-use {
  color: var(--text2);
  font-size: 11px;
  line-height: 1.3;
}

/* Acoes com icone e estados (processando/sucesso/erro) */
.export-action {
  position: relative;
}

.btn-primary.export-action,
.btn-blue.export-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  align-self: flex-start;
  min-width: 190px;
  margin-top: auto;
}

.export-action-icon {
  display: inline-flex;
  align-items: center;
}

.export-action[data-state='processing'] {
  pointer-events: none;
}

.export-action[data-state='processing'] .export-action-icon {
  display: none;
}

.export-action[data-state='processing']::before {
  content: '';
  width: 13px;
  height: 13px;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: export-spin 0.6s linear infinite;
  flex: 0 0 auto;
}

.btn-primary.export-action[data-state='processing'],
.btn-blue.export-action[data-state='processing'] {
  justify-content: center;
}

.export-action[data-state='success'] {
  border-color: rgba(53, 208, 127, 0.55) !important;
  box-shadow: 0 0 0 1px rgba(53, 208, 127, 0.35) inset;
}

.export-action[data-state='error'] {
  border-color: rgba(239, 68, 68, 0.6) !important;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.4) inset;
}

.export-format-item[data-state='processing'] {
  opacity: 0.85;
  pointer-events: none;
}

.export-format-item[data-state='success'] {
  border-color: rgba(53, 208, 127, 0.5);
  background: rgba(53, 208, 127, 0.1);
}

.export-format-item[data-state='error'] {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.1);
}

/* Estado desabilitado: legivel, com cursor e dica explicativos */
.export-action:disabled,
.export-action[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.export-format-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

/* Dock inferior: foco visivel */
.tab:focus-visible {
  outline: 2px solid var(--accent2) !important;
  outline-offset: 2px !important;
  z-index: 4;
}

.export-action:focus-visible,
.export-format-item:focus-visible,
.export-empty-actions button:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* Responsividade */
@media (max-width: 980px) {
  .export-panel-grid {
    grid-template-columns: 1fr;
  }

  .export-group-wide {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .export-head {
    flex-direction: column;
  }

  .export-card-body {
    flex-direction: column;
  }

  .export-summary-item-wide {
    grid-column: auto;
  }

  .export-format-list {
    grid-template-columns: 1fr;
  }

  .btn-primary.export-action,
  .btn-blue.export-action {
    width: 100%;
    min-width: 0;
  }
}

/* Movimento reduzido */
@media (prefers-reduced-motion: reduce) {
  .export-action[data-state='processing']::before {
    animation: none;
  }

  .export-format-item,
  .export-status,
  .export-action {
    transition: none !important;
  }
}

/* ============================================================
   ABOUT DRAWER
   ============================================================ */
.about-trigger {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(92, 211, 255, 0.22);
  border-radius: 7px;
  color: #dff7ff;
  background: rgba(3, 12, 24, 0.54);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease;
}

.about-trigger-icon {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.about-trigger:hover,
.about-trigger:focus-visible,
body.about-open .about-trigger {
  color: #ffffff;
  border-color: rgba(92, 211, 255, 0.62);
  background: rgba(0, 183, 255, 0.18);
  box-shadow:
    0 0 0 1px rgba(92, 211, 255, 0.18) inset,
    0 12px 28px rgba(0, 183, 255, 0.16);
}

.about-trigger:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

.about-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) - 1);
  background: rgba(3, 8, 15, 0.46);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.about-overlay[hidden] {
  display: none;
}

.about-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  width: min(390px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(14, 28, 47, 0.96), rgba(10, 20, 35, 0.98)), var(--panel-solid);
  border-left: 1px solid rgba(92, 211, 255, 0.2);
  box-shadow: -28px 0 56px rgba(0, 0, 0, 0.38);
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition:
    transform 0.24s ease,
    visibility 0.24s ease;
}

body.about-open .about-drawer {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.about-drawer-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(92, 211, 255, 0.16);
}

.about-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.about-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 8px;
}

.about-brand h2 {
  margin: 0;
  color: #ffffff;
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: 0;
}

.about-brand p {
  margin: 4px 0 0;
  color: var(--accent2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.about-close {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(92, 211, 255, 0.16);
  border-radius: 7px;
  color: var(--text2);
  background: rgba(255, 255, 255, 0.04);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.about-close:hover,
.about-close:focus-visible {
  color: #ffffff;
  border-color: rgba(92, 211, 255, 0.5);
  background: rgba(0, 183, 255, 0.13);
}

.about-close:focus-visible,
.about-social-link:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

.about-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
}

.about-description {
  margin: 0;
  color: var(--text2);
  font-size: 14px;
  line-height: 1.58;
}

.about-section {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid rgba(92, 211, 255, 0.14);
}

.about-section-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.about-section h3 {
  margin: 0;
  color: #ffffff;
  font-size: 18px;
  letter-spacing: 0;
}

.about-socials {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.about-social-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid rgba(92, 211, 255, 0.22);
  border-radius: 7px;
  color: #dff7ff;
  background: rgba(0, 183, 255, 0.09);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.about-social-link:hover {
  color: #ffffff;
  border-color: rgba(92, 211, 255, 0.56);
  background: rgba(0, 183, 255, 0.16);
}

.about-footer {
  padding: 16px 20px 18px;
  border-top: 1px solid rgba(92, 211, 255, 0.14);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 640px) {
  header {
    flex-direction: row !important;
    align-items: center !important;
    overflow: visible !important;
  }

  .header-left {
    min-width: 0;
    flex: 1 1 auto;
  }

  .header-badges {
    flex: 0 1 auto;
    align-self: center;
  }

  .about-trigger {
    width: 30px;
    height: 30px;
  }

  .about-drawer {
    width: min(420px, calc(100vw - 16px));
  }

  .about-drawer-header {
    padding: 16px;
  }

  .about-drawer-body {
    padding: 20px 16px;
  }

  .about-footer {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .about-trigger,
  .about-drawer {
    transition: none !important;
  }
}
