:root {
  color-scheme: light dark;
  --bg: #f5f7fb;
  --panel-bg: #ffffff;
  --panel-border: #d8dce6;
  --accent: #0066cc;
  --accent-soft: rgba(0, 102, 204, 0.12);
  --text: #1a1d2b;
  --muted: #5f6377;
  --danger: #c0392b;
  --sidebar-width: clamp(280px, 24vw, 360px);
  --header-height: 96px;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Roboto", sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body.synthetic-active {
  overflow: hidden;
}

body.header-collapsed {
  --header-height: 0px;
}

body.header-collapsed .app-header {
  transform: translateY(-100%);
  padding: 0;
  border-bottom: 0;
  box-shadow: none;
  height: 0;
  min-height: 0;
  overflow: hidden;
}

body.header-collapsed .collapsed-brand {
  opacity: 1;
  transform: translateY(0);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1.75rem;
  gap: 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--panel-border);
  box-shadow: 0 4px 12px rgba(10, 21, 36, 0.05);
  transition: transform 0.3s ease, padding 0.3s ease, box-shadow 0.3s ease, border-bottom 0.3s ease;
}

.brand {
  *display: flex;
  *align-items: center;
  *gap: 1rem;
}

.brand-logo {
  width: 108px;
  *height: 64px;
  object-fit: contain;
}

.brand-logo-collapsed {
  width: 200px;
  object-fit: contain;
}

.brand-text {
  display: inline;
  *flex-direction: column;
  gap: 0.25rem;
}

.brand-text h1{
  margin: 0;
  color: #0f2440;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.header-toggle {
  align-self: flex-start;
}

.collapsed-brand {
  top: 1rem;
  left: 1.5rem;
  z-index: 1400;
  font-size: 2.4rem;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.synthetic-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  z-index: 1500;
}

.synthetic-overlay[hidden] {
  display: none;
}

.synthetic-card {
  background: none;
  border-radius: 0;
  width: min(1200px, 95vw);
  max-height: calc(100vh - 220px);
  padding: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.synthetic-map-wrapper {
  width: 100%;
  max-width: 1200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  box-shadow: none;
  border-radius: 0;
  overflow: auto;
}

.synthetic-map-wrapper .synthetic-svg {
  width: 100%;
  height: auto;
  display: block;
}

.synthetic-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.synthetic-actions .secondary {
  min-width: 180px;
  font-size: 0.95rem;
}

@media print {
  body * {
    visibility: hidden !important;
  }

  .synthetic-overlay,
  .synthetic-overlay * {
    visibility: visible !important;
  }

  .synthetic-overlay {
    position: static;
    inset: auto;
    background: none;
    backdrop-filter: none;
    padding: 0;
  }

  .synthetic-card {
    width: 100%;
    max-height: none;
    padding: 0;
  }

  .synthetic-actions {
    display: none;
  }
}

@media (max-width: 900px) {
  .synthetic-card {
    max-height: calc(100vh - 140px);
  }
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.mode-indicator {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

body.mode-public .mode-indicator {
  color: var(--accent);
}

.app-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.8rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding-right: 1.5rem;
}

.search-wrapper {
  position: relative;
  min-width: 400px;
  display: inline-flex;
  align-items: center;
}

#search_client {
  flex: 1 1 auto;
  width: 100%;
  padding: 0.55rem 2.2rem 0.55rem 0.85rem;
  border-radius: 0.6rem;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 1px 2px rgba(15, 30, 60, 0.08);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  color: var(--text);
}

#search_client:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #fff;
}

#search_client:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 0.6rem;
  transform: translateY(-50%);
  border: none;
  background: rgba(12, 32, 68, 0.12);
  color: #0f1a30;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.search-clear span {
  font-size: 1.05rem;
  line-height: 1;
}

.search-clear:hover,
.search-clear:focus {
  background: rgba(12, 32, 68, 0.2);
  color: #102a4c;
}

.search-clear[hidden] {
  display: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 0;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 0.75rem;
  box-shadow: 0 14px 28px rgba(15, 30, 60, 0.16);
  z-index: 1200;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 240px;
  max-width: clamp(240px, 48vw, 420px);
  width: min(100%, 420px);
}

.search-results[hidden] {
  display: none;
}

.search-results-empty {
  margin: 0;
  padding: 0.5rem 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.search-result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  border: none;
  border-radius: 0.65rem;
  padding: 0.55rem 0.75rem;
  text-align: left;
  background: rgba(245, 247, 251, 0.65);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.search-result strong {
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f1524;
}

.search-result span {
  font-size: 0.8rem;
  color: var(--muted);
}

.search-result:hover,
.search-result:focus {
  background: rgba(0, 102, 204, 0.14);
  transform: translateY(-1px);
  outline: none;
}

.file-button {
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.file-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.secondary {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--muted);
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size:1.2rem
}

.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.secondary.ghost {
  border-style: dashed;
  opacity: 0.85;
}

.secondary.ghost:hover,
.secondary.ghost:focus {
  opacity: 1;
}

.layout {
  --layout-sidebar-width: var(--sidebar-width);
  display: grid;
  grid-template-columns: var(--layout-sidebar-width) 1fr;
  height: calc(100vh - var(--header-height));
  position: relative;
  transition: grid-template-columns 0.3s ease;
}

.sidebar {
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 12px 20px rgba(15, 23, 42, 0.06);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.panel p {
  margin: 0;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.filters label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  border-radius: 0.35rem;
}

.filters label:hover {
  background: var(--accent-soft);
}

#quick-nav .hint {
  width: 100%;
}

.marker-list {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.marker-list li {
  margin: 0.15rem 0;
}

.marker-warning {
  display: block;
  margin-top: 0.35rem;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
}

.city-marker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.7rem 0.28rem 0.5rem;
  background: rgba(14, 64, 108, 0.92);
  color: #ffffff;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(12, 32, 68, 0.22);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  white-space: nowrap;
}

.city-marker::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  pointer-events: none;
}

.city-marker__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.city-marker__label {
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.city-marker--fallback {
  background: rgba(49, 97, 139, 0.85);
}

.city-marker--alert {
  background: rgba(178, 18, 35, 0.92);
}

.anomaly-marker-icon {
  background: transparent;
  border: none;
}

.anomaly-marker-icon .anomaly-marker-dot {
  display: block;
  width: 18px;
  height: 18px;
  margin: 3px auto 0;
  border-radius: 50%;
  background: #e63946;
  border: 2px solid #b31217;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), 0 6px 10px rgba(0, 0, 0, 0.3);
  position: relative;
}

.anomaly-marker-icon .anomaly-marker-dot::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 9px solid #b31217;
}

#stats-region {
  display: grid;
  gap: 0.25rem;
  font-size: 0.9rem;
  max-height:50vh;
  overflow-y: scroll;
  padding-right:10px;
}

.stat-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.45rem;
  border-radius: 0.35rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.stat-entry:nth-child(odd) {
  background: rgba(0, 0, 0, 0.04);
}

.stat-entry strong {
  font-weight: 600;
}

.stat-entry:hover,
.stat-entry:focus {
  background: rgba(0, 102, 204, 0.14);
  outline: none;
}

body.sidebar-collapsed .layout {
  --layout-sidebar-width: 0px;
  grid-template-columns: 0 1fr;
}

body.sidebar-collapsed .sidebar {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-24px);
}

.sidebar-toggle {
  position: absolute;
  top: 40%;
  left: 0;
  width: 38px;
  height: 88px;
  border-radius: 0 16px 16px 0;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  z-index: 900;
  transition: transform 0.25s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.25s ease;
}

.sidebar-toggle::before {
  content: "◀";
  font-size: 1.2rem;
  line-height: 1;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus {
  color: var(--accent);
  background: rgba(0, 102, 204, 0.18);
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.22);
  outline: none;
}

body.sidebar-collapsed .sidebar-toggle {
  transform: translate(-50%, -50%);
}

body.sidebar-collapsed .sidebar-toggle::before {
  content: "▶";
}

.map-area {
  position: relative;
  display: flex;
  flex-direction: column;
}

#map {
  position: relative;
  flex: 1 1 auto;
  min-height: 420px;
}

.quick-nav-bar {
  bottom: 0;
  z-index: 500;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(245, 247, 251, 0) 0%, rgba(245, 247, 251, 0.75) 40%, rgba(245, 247, 251, 0.98) 100%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.quick-nav-bar h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-buttons {
  --nav-count: 1;
  --nav-columns: 2;
  display: grid;
  grid-template-columns: repeat(var(--nav-columns), minmax(0px, 1fr));
  gap: 0.6rem;
  width: 100%;
  padding-bottom: 0.25rem;
}

.nav-buttons .hint,
.nav-buttons .nav-hint {
  grid-column: 1 / -1;
  margin: 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.nav-button {
  width: 100%;
  min-width: 0;
  height: 55px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, rgba(35, 108, 177, 0.16), rgba(14, 64, 108, 0.45));
  color: #0f2440;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  letter-spacing: 0.02em;
  text-transform: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  box-shadow: 0 14px 30px rgba(15, 30, 60, 0.14);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  position: relative;
  overflow: hidden;
}

.nav-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
}

.nav-button span {
  position: relative;
  z-index: 1;
  display: block;
  line-height: 1.2;
}

.nav-button:hover,
.nav-button:focus {
  transform: translateY(-6px);
  box-shadow: 0 22px 46px rgba(15, 30, 60, 0.2);
  outline: none;
}

.nav-button:active {
  transform: translateY(-3px);
}

.status-error {
  color: var(--danger);
}

.status-success {
  color: #1b7b36;
}

.status-info {
  color: var(--accent);
}

.status-warning-actions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.status-warning-actions[hidden] {
  display: none;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.link-button[hidden] {
  display: none;
}

.link-button:hover,
.link-button:focus {
  color: var(--primary);
  outline: none;
}

.status-warnings {
  margin-top: 0.75rem;
  padding-left: 1.2rem;
  color: var(--danger);
  font-size: 0.85rem;
  line-height: 1.4;
  list-style: disc;
}

.status-warnings[hidden] {
  display: none;
}

.status-warning-item {
  margin-top: 0.25rem;
}

.status-warning-item:first-child {
  margin-top: 0;
}

.status-warning-item--clickable {
  cursor: pointer;
  text-decoration: underline;
}

.status-warning-item--clickable:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.status-warning-item--active {
  font-weight: 600;
  color: var(--accent);
}

.leaflet-control-attribution {
  font-size: 11px;
}

body.mode-public #status-panel {
  display: none;
}


body.mode-public .import-actions .file-button,
body.mode-public .import-actions #reset-db,
body.mode-public .import-actions #activate-public {
  display: none;
}


body.mode-public .layout {
  height: 100vh;
}

.choropleth-label {
  pointer-events: none;
  text-align: center;
  color: #0a1b3d;
  font-weight: 700;
  font-size: 0.85rem;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.9), 0 0 8px rgba(255, 255, 255, 0.7);
}

.choropleth-label span {
  display: inline-block;
  background: rgba(255, 255, 255, 0.7);
  padding: 2px 6px;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(10, 15, 40, 0.25);
}

.leaflet-marker-icon.marker-highlight,
.leaflet-marker-shadow.marker-highlight + .leaflet-marker-icon {
  transform: scale(1.18);
  filter: drop-shadow(0 0 10px rgba(0, 102, 204, 0.55));
  z-index: 1200 !important;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: minmax(240px, 280px) 1fr;
    height: calc(100vh - var(--header-height));
  }

  .sidebar {
    padding: 1rem;
  }

  .quick-nav-bar {
    padding: 1rem 1.5rem 1.75rem;
  }

  .nav-button {
    flex: 0 0 150px;
  }
}
.nav-button[data-accent="metropole"] {
  background: linear-gradient(135deg, rgba(22, 44, 73, 0.18), rgba(14, 64, 108, 0.5));
}

.nav-button[data-accent="ARA"],
.nav-button[data-accent="BFC"],
.nav-button[data-accent="BRE"],
.nav-button[data-accent="CVL"],
.nav-button[data-accent="COR"],
.nav-button[data-accent="GES"],
.nav-button[data-accent="HDF"],
.nav-button[data-accent="NOR"],
.nav-button[data-accent="NAQ"],
.nav-button[data-accent="OCC"],
.nav-button[data-accent="PDL"],
.nav-button[data-accent="PAC"] {
  background: linear-gradient(135deg, rgba(35, 108, 177, 0.18), rgba(22, 44, 73, 0.48));
}

.nav-button[data-accent="GLP"],
.nav-button[data-accent="MTQ"],
.nav-button[data-accent="GUF"],
.nav-button[data-accent="REU"],
.nav-button[data-accent="MYT"],
.nav-button[data-accent="SPM"],
.nav-button[data-accent="BLM"],
.nav-button[data-accent="WLF"],
.nav-button[data-accent="PYF"],
.nav-button[data-accent="NCL"],
.nav-button[data-accent="CLP"] {
  background: linear-gradient(135deg, rgba(49, 97, 139, 0.18), rgba(35, 108, 177, 0.36));
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
