:root {
  --bg: #efefef;
  --panel: #ffffff;
  --teal: #16b8c9;
  --teal-dark: #0ea5b5;
  --line: #cfcfcf;
  --gray: #8c8c8c;
  --soft: #f6fbfc;
  --text: #222;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Cairo", Tahoma, sans-serif;
}
.dashboard-shell {
  width: min(1400px, 98vw);
  margin: 10px auto;
}
/* // Header  */
.topbar {
  display: grid;
  grid-template-columns: 220px 1fr 180px;
  align-items: center;
  gap: 20px;
  padding: 18px 28px;
  background: linear-gradient(180deg, #f8fafa 0%, #eef7f8 100%);
  border: 1px solid #d8e3e6;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  direction: rtl;
}

.header-side {
  display: flex;
  align-items: center;
}

.header-right-side {
  justify-content: flex-start;
}

.header-left-side {
  justify-content: flex-end;
}

.ea-logo {
  max-width: 200px;
  max-height: 100px;
  object-fit: contain;
}

.header-center {
  text-align: center;
}

.header-top-logos {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.vision-logo {
  max-width: 120px;
  max-height: 60px;
  object-fit: contain;
}

.bird-logo {
  max-width: 72px;
  max-height: 72px;
  object-fit: contain;
}

.header-center h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 800;
  color: #0b8ea0;
  line-height: 1.3;
}

.subtitle {
  font-size: 1rem;
  color: #6b7280;
  line-height: 1.6;
}

.update-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid #dbe7ea;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.update-label {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 4px;
}

.update-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #e74c3c;
}

@media (max-width: 992px) {
  .topbar {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .header-side,
  .header-right-side,
  .header-left-side {
    justify-content: center;
  }

  .header-center h1 {
    font-size: 1.5rem;
  }
}

.title-wrap {
  text-align: center;
}
.title-wrap h1 {
  margin: 0;
  color: #008c9e;
  font-size: 28px;
  line-height: 1.3;
}
.subtitle {
  font-size: 14px;
  color: #555;
}

.section-label {
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  padding: 6px 12px;
  margin: 6px 0 10px;
  font-size: 14px;
}
.main-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 12px;
}
.left-column,
.right-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel {
  background: var(--panel);
  border: 1px solid #c9c9c9;
  box-shadow: var(--shadow);
}
.panel-title {
  background: #bdbdbd;
  color: #222;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}
.panel-title.teal {
  background: var(--teal);
  color: #fff;
}
.panel-title.centered {
  text-align: center;
}
#map {
  height: 380px;
}
.pie-panel {
  padding: 8px;
}
.legend-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 12px;
  margin-bottom: 4px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.chart-box {
  height: 260px;
}
.chart-small {
  height: 250px;
  padding: 8px;
}
.chart-medium {
  height: 240px;
  padding: 8px;
}
.chart-large {
  height: 320px;
  padding: 8px;
}
.cards-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.cards-block {
  background: #fff;
  border: 1px solid #c9c9c9;
  box-shadow: var(--shadow);
  padding-bottom: 10px;
}
.block-header {
  background: #8d8d8d;
  color: #fff;
  font-weight: 800;
  padding: 7px 12px;
  text-align: center;
}
.summary-grid {
  display: grid;
  gap: 8px;
  padding: 10px;
}
.summary-grid.four {
  grid-template-columns: repeat(4, 1fr);
}
.stat-card {
  background: var(--teal);
  color: #fff;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 8px;
}
.stat-card.soft {
  background: #eaf8fb;
  color: #0d5560;
  border: 1px solid #9ad7de;
}
.stat-card span {
  font-size: 12px;
  line-height: 1.2;
}
.stat-card strong {
  font-size: 25px;
  line-height: 1.1;
}
.kpi-band {
  display: grid;
  grid-template-columns: 220px 220px 1fr;
  gap: 8px;
  padding: 0 10px 10px;
}
.kpi-band.current .kpi-total {
  background: #18b6c8;
}
.kpi-mini,
.kpi-total {
  background: #f7f7f7;
  border: 1px solid #ddd;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.kpi-mini strong {
  font-size: 24px;
}
.kpi-total {
  background: var(--teal);
  color: #fff;
}
.kpi-total strong {
  font-size: 40px;
  line-height: 1;
}
.controls-row {
  display: flex;
  justify-content: left;
  padding: 0 10px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #16b8c9, #0ea5b5);
  padding: 14px 20px;
  border-radius: 10px;
  color: #fff;
  margin: 10px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.section-title {
  font-size: 18px;
  font-weight: 800;
}

.section-actions {
  display: flex;
  align-items: center;
}

.theme-btn {
  background: #ffffff;
  color: #0b8ea0;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.3s;
}

.theme-btn:hover {
  background: #e6f7fa;
  transform: translateY(-1px);
}
button {
  border: none;
  background: #18b6c8;
  color: #fff;
  padding: 10px 18px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
}
.charts-grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.wide-panel {
  overflow: hidden;
}
body.dark {
  --bg: #1d2125;
  --panel: #252b31;
  --text: #f2f2f2;
  --soft: #2b363d;
  --line: #3a434b;
}
body.dark .topbar {
  background: #252b31;
  border-color: #39424b;
}
body.dark .section-label {
  background: #0f8391;
}
body.dark .panel-title {
  background: #57606a;
  color: #fff;
}
body.dark .cards-block {
  background: #252b31;
  border-color: #39424b;
}
body.dark .block-header {
  background: #57606a;
}
body.dark .kpi-mini {
  background: #2b363d;
  border-color: #3a434b;
  color: #fff;
}
body.dark .stat-card.soft {
  background: #2b363d;
  color: #e9fdff;
  border-color: #42606a;
}
@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .summary-grid.four {
    grid-template-columns: repeat(2, 1fr);
  }
  .charts-grid.two {
    grid-template-columns: 1fr;
  }
  .kpi-band {
    grid-template-columns: 1fr;
  }
  .topbar {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .brand-wrap {
    justify-content: center;
  }
}
.popup-card {
  direction: rtl;
  text-align: right;
  font-family: "Cairo", Tahoma, sans-serif;
  min-width: 170px;
}

.popup-card h3 {
  margin: 0 0 8px;
  color: #0b8ea0;
  font-size: 16px;
}

.popup-card p {
  margin: 4px 0;
  font-size: 13px;
}

/* ===== Legend upgrades ===== */
.map-legend {
  background: rgba(255, 255, 255, 0.96);
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  font-family: "Cairo", Tahoma, sans-serif;
  direction: rtl;
  min-width: 170px;
  border: 1px solid #d7e4e7;
  border-right: 4px solid #0b8ea0;
}
.legend-title {
  font-weight: 800;
  margin-bottom: 10px;
  color: #0b8ea0;
  text-align: center;
  font-size: 14px;
}
.map-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 13px;
  color: #222;
}
.map-legend .legend-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.legend-color.y2024 {
  background: #f06595;
}
.legend-color.y2026 {
  background: #20c997;
}

/* Leaflet layer control */
.leaflet-control-layers {
  direction: rtl;
  text-align: right;
  font-family: "Cairo", Tahoma, sans-serif;
  border-radius: 12px !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16) !important;
  overflow: hidden;
}

.leaflet-control-layers-expanded {
  padding: 12px 14px;
  min-width: 190px;
  background: #ffffff;
}

.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 13px;
  cursor: pointer;
}

.leaflet-control-layers-separator {
  margin: 10px 0 !important;
}

.legend-color.y2024 {
  background: #f06595;
}

.legend-color.y2026 {
  background: #20c997;
}

/* merged control + legend */
.leaflet-top.leaflet-right .leaflet-control {
  margin-top: 14px;
  margin-right: 14px;
}
.leaflet-control-layers {
  direction: rtl;
  text-align: right;
  font-family: "Cairo", Tahoma, sans-serif;
  border-radius: 16px !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18) !important;
  overflow: hidden;
  border: 0 !important;
}
.leaflet-control-layers-expanded {
  padding: 14px 16px;
  min-width: 215px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(4px);
}
.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 14px;
  cursor: pointer;
}
.leaflet-control-layers-separator {
  margin: 10px 0 !important;
}
.merged-legend-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #d9d9d9;
}
.merged-legend-title {
  color: #0b8ea0;
  font-weight: 800;
  font-size: 20px;
  text-align: center;
  margin-bottom: 10px;
}
.merged-legend-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin: 8px 0;
  font-size: 14px;
}
.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 14px;
}
.legend-color.y2024 {
  background: #f06595;
}
.legend-color.y2026 {
  background: #20c997;
}

/* Government final polish */
.leaflet-control-layers-expanded {
  min-width: 230px;
  background: rgba(255, 255, 255, 0.97);
}

.merged-legend-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #d8d8d8;
}

.merged-legend-title {
  color: #0b8ea0;
  font-weight: 800;
  font-size: 18px;
  text-align: center;
  margin-bottom: 10px;
}

.merged-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 14px;
}

.merged-legend-empty {
  text-align: center;
  color: #666;
  font-size: 13px;
  padding: 6px 0 2px;
}

.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label {
  font-weight: 600;
}

.leaflet-control-layers-separator {
  border-top: 1px solid #d7d7d7 !important;
}

#map {
  position: relative;
}

.panel.map-panel {
  overflow: hidden;
  border-radius: 6px;
}

.panel-title.teal {
  font-size: 16px;
  font-weight: 800;
}

/* Custom collapsible legend */

.merged-legend-title {
  color: #0b8ea0;
  font-weight: 800;
  font-size: 18px;
  text-align: center;
  margin-bottom: 10px;
}

.merged-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 14px;
}

.merged-legend-empty {
  text-align: center;
  color: #666;
  font-size: 13px;
  padding: 6px 0 2px;
}

.legend-color.y2024 {
  background: #f06595;
}

.legend-color.y2026 {
  background: #20c997;
}

/* Layer control symbols */
.layer-item-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.layer-symbol {
  width: 11px;
  height: 11px;
  display: inline-block;
  flex: 0 0 11px;
}

.layer-2024-marker {
  border-radius: 50%;
  background: #f06595;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  opacity: 0.9;
}

.layer-2026-marker {
  border-radius: 50%;
  background: #20c997;
  border: 2px solid #0f5132;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  opacity: 0.95;
}

.base-osm {
  border-radius: 4px;
  background: linear-gradient(135deg, #88c057 0%, #4caf50 45%, #d9c27a 100%);
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.base-sat {
  border-radius: 4px;
  background: linear-gradient(
    135deg,
    #5c4b3b 0%,
    #9c7b5a 35%,
    #2f6f7e 70%,
    #163d57 100%
  );
  border: 1px solid rgba(0, 0, 0, 0.18);
}

/* Compact layer control */
.leaflet-control-layers {
  border-radius: 12px !important;
}

.leaflet-control-layers-expanded {
  min-width: 165px !important;
  padding: 10px 12px !important;
}

.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label {
  gap: 6px !important;
  margin: 6px 0 !important;
  font-size: 11px !important;
}

.leaflet-control-layers-separator {
  margin: 8px 0 !important;
}

/* ===== Wilaya filter ===== */
.section-actions {
  gap: 10px;
  flex-wrap: wrap;
}
.filter-label {
  font-size: 13px;
  font-weight: 800;
}
.wilaya-filter {
  min-width: 170px;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-family: "Cairo", Tahoma, sans-serif;
  font-weight: 700;
  color: #0b8ea0;
  background: #fff;
  outline: none;
}
.header-top-logos .bird-logo {
  max-width: 105px;
  max-height: 105px;
}
.header-top-logos .vision-logo {
  max-width: 190px;
  max-height: 85px;
}
body.dark .wilaya-filter,
body.dark .theme-btn {
  background: #2b363d;
  color: #e9fdff;
}

/* ===== Final map control styling: one clean layer menu only ===== */
.leaflet-control-layers {
  direction: rtl;
  text-align: right;
  font-family: "Cairo", Tahoma, sans-serif;
  border-radius: 16px !important;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18) !important;
}

.leaflet-control-layers-expanded {
  min-width: 210px !important;
  padding: 14px 16px !important;
  background: rgba(255, 255, 255, 0.96) !important;
  backdrop-filter: blur(6px);
}

.leaflet-control-layers label {
  font-size: 14px !important;
  font-weight: 700;
  margin: 8px 0 !important;
}

.leaflet-control-layers-selector {
  accent-color: #0b8ea0;
}

.map-panel #map {
  height: 420px;
}

.leaflet-bottom.leaflet-left .legend {
  display: none !important;
}
