:root {
  --green-900: #1d4d3a;
  --green-700: #2e7d5b;
  --green-500: #4caf7d;
  --green-100: #e6f2ec;
  --earth-500: #b07d4f;
  --earth-100: #f6efe6;
  --blue-500: #4a90c2;
  --blue-100: #e8f1f8;
  --amber-500: #d9a441;
  --amber-100: #fbf3e2;
  --red-500: #c96a5e;
  --red-100: #f9ece9;
  --ink-900: #26332d;
  --ink-600: #5c6b64;
  --ink-300: #b9c4be;
  --surface: #f7faf8;
  --card: #ffffff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(31, 61, 48, 0.07);
  --shadow-hover: 0 6px 20px rgba(31, 61, 48, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink-900);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--green-700);
  color: #fff;
  padding: 10px 16px;
  z-index: 9999;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  left: 0;
}

.container-wide {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 40px;
}

.app-nav {
  background: linear-gradient(135deg, var(--green-700), var(--green-900));
  box-shadow: 0 2px 12px rgba(29, 77, 58, 0.25);
}

.app-nav .nav-wrapper {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
}

.app-nav .brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  position: static;
  transform: none;
  padding-left: 0;
  height: 100%;
}

.brand-mark {
  width: 155px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-mark i {
  font-size: 24px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-text small {
  font-size: 11.5px;
  opacity: 0.78;
  font-weight: 400;
}

.season-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.16);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}

.season-chip i {
  font-size: 16px;
}

.filter-bar {
  background: #ffffff;
  border-bottom: 1px solid #e6ece9;
  box-shadow: 0 2px 8px rgba(31, 61, 48, 0.05);
  position: sticky;
  top: 0;
  z-index: 900;
}

.filter-bar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 20px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}

.filter-bar-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--green-700);
  padding-bottom: 9px;
  white-space: nowrap;
}

.filter-bar-title i {
  font-size: 17px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 140px;
  max-width: 190px;
}

.filter-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-600);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: static;
  pointer-events: auto;
}

.filter-field select {
  width: 100%;
  height: 38px;
  border: 1px solid #dbe5e0;
  border-radius: var(--radius-sm);
  background-color: #fcfefd;
  color: var(--ink-900);
  font-family: inherit;
  font-size: 13px;
  padding: 0 30px 0 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235c6b64'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 20px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-field select:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(76, 175, 125, 0.18);
}

.filter-field select:hover {
  border-color: var(--green-500);
}

.filter-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  color: var(--ink-600);
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 0 12px;
  margin-bottom: 0;
  margin-left: auto;
}

.offline-banner[hidden],
.filter-empty[hidden] {
  display: none !important;
}

.filter-reset:hover {
  background: var(--green-100);
  color: var(--green-700);
}

.filter-reset i {
  font-size: 17px;
}

.filter-active {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(46, 125, 91, 0.25);
  background: var(--green-100);
  color: var(--green-900);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.filter-chip:hover {
  background: #d6ebe0;
}

.filter-chip i {
  font-size: 15px;
  color: var(--green-700);
}

.filter-active-empty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-300);
}

.filter-active-empty i {
  font-size: 15px;
}

.filter-empty {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--amber-100);
  border: 1px solid rgba(217, 164, 65, 0.35);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 20px;
}

.filter-empty i {
  font-size: 30px;
  color: var(--amber-500);
}

.filter-empty strong {
  display: block;
  font-size: 14px;
  color: var(--ink-900);
}

.filter-empty p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ink-600);
}

.sidenav {
  background: #fff;
}

.sidenav .user-view {
  background: linear-gradient(135deg, var(--green-700), var(--green-900));
  padding: 24px 22px;
}

.sidenav-head {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}

.sidenav-head i {
  font-size: 34px;
  opacity: 0.9;
}

.sidenav-head .name {
  display: block;
  font-weight: 600;
  font-size: 15px;
}

.sidenav-head .email {
  display: block;
  font-size: 12px;
  opacity: 0.8;
}

.sidenav li > a {
  color: var(--ink-600);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 14px;
}

.sidenav li > a i {
  color: var(--ink-300);
  margin: 0;
}

.sidenav li > a.active,
.sidenav li > a:hover {
  color: var(--green-700);
  background: var(--green-100);
}

.sidenav li > a.active i {
  color: var(--green-700);
}

.section-block {
  padding: 28px 0 8px;
  scroll-margin-top: 190px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.section-sub {
  margin: 0;
  color: var(--ink-600);
  font-size: 13.5px;
}

.refresh-btn {
  color: var(--green-700);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.refresh-btn.spinning i {
  animation: spin 0.8s linear infinite;
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(46, 125, 91, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent, var(--green-500));
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: 12.5px;
  color: var(--ink-600);
  font-weight: 500;
  line-height: 1.3;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft, var(--green-100));
  color: var(--accent, var(--green-700));
  flex: 0 0 auto;
}

.kpi-icon i {
  font-size: 19px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi-value .unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-600);
  margin-left: 3px;
}

.kpi-foot {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-600);
  display: flex;
  align-items: center;
  gap: 5px;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
}

.trend i {
  font-size: 15px;
}

.trend.up {
  color: var(--green-700);
}

.trend.down {
  color: var(--red-500);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 20px;
}

.kpi-grid > *,
.chart-grid > *,
.split-grid > *,
.map-layout > * {
  min-width: 0;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(46, 125, 91, 0.06);
  margin: 0;
}

.card .card-content {
  padding: 20px;
}

.card .card-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink-900);
  display: block;
  margin-bottom: 2px;
}

.card-hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--ink-600);
}

.chart-box {
  position: relative;
  height: 260px;
  width: 100%;
  overflow: hidden;
}

.chart-box canvas {
  max-width: 100% !important;
}

.chart-box.tall {
  height: 320px;
}

.table-card {
  margin-bottom: 20px;
}

.table-scroll {
  overflow-x: auto;
}

table.highlight {
  font-size: 13.5px;
}

table.highlight thead th {
  color: var(--ink-600);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  border-bottom: 1px solid #e6ece9;
}

table.highlight tbody td {
  padding: 12px 10px;
  white-space: nowrap;
}

table.highlight tbody tr:hover {
  background: var(--green-100);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge.alta {
  background: var(--red-100);
  color: var(--red-500);
}

.badge.media {
  background: var(--amber-100);
  color: #9a6f16;
}

.badge.baja {
  background: var(--blue-100);
  color: var(--blue-500);
}

.alert-list {
  border: none;
  margin: 4px 0 0;
}

.alert-list .collection-item {
  border-radius: var(--radius-sm);
  border: 1px solid #eef3f0;
  margin-bottom: 8px;
  padding: 12px 14px;
  background: #fcfefd;
}

.alert-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
}

.alert-item-head i {
  font-size: 18px;
}

.alert-item-head .spacer {
  flex: 1;
}

.alert-item-desc {
  color: var(--ink-600);
  font-size: 12.5px;
  margin-top: 4px;
}

.alert-item-meta {
  color: var(--ink-300);
  font-size: 11.5px;
  margin-top: 6px;
}

.map-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
}

.map-panel {
  align-self: start;
}

.map-panel .card-title {
  margin-bottom: 14px;
}

.layer-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.layer-switch .lever {
  margin: 0;
  flex: 0 0 auto;
}

.layer-switch .layer-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-600);
  font-weight: 500;
}

.layer-switch input:checked ~ .layer-label {
  color: var(--green-700);
}

.layer-switch input[type="checkbox"].filled-in:checked + span:not(.lever):after {
  background: var(--green-700);
  border-color: var(--green-700);
}

.legend {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-600);
}

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

.map-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(46, 125, 91, 0.08);
}

#map {
  height: 620px;
  width: 100%;
  background: #dfeae3;
}

.map-popup {
  font-size: 13px;
  line-height: 1.5;
}

.map-popup strong {
  display: block;
  margin-bottom: 4px;
  color: var(--green-900);
}

.map-popup .popup-row {
  color: var(--ink-600);
}

.leaflet-popup-content-wrapper {
  border-radius: 12px;
}

.district-label {
  background: rgba(255, 255, 255, 0.85);
  border: none;
  box-shadow: none;
  color: #2e6fb0;
  font-size: 10.5px;
  font-weight: 600;
  padding: 0;
}

.district-label::before {
  display: none;
}

.page-footer-note {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid #e6ece9;
  color: var(--ink-600);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-footer-note .dot {
  color: var(--ink-300);
}

.offline-banner {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-900);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-hover);
  z-index: 1200;
}

.offline-banner i {
  font-size: 18px;
}

.skeleton {
  background: linear-gradient(90deg, #eef3f0 25%, #e2ebe6 37%, #eef3f0 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 8px;
  color: transparent;
}

@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

@media (max-width: 992px) {
  .filter-bar-title {
    flex: 1 1 100%;
    padding-bottom: 0;
  }

  .filter-field {
    max-width: none;
  }

  .split-grid,
  .map-layout {
    grid-template-columns: 1fr;
  }

  .map-panel {
    order: 2;
  }

  #map {
    height: 460px;
  }

  .brand-text small {
    display: none;
  }
}

@media (max-width: 600px) {
  .container-wide {
    padding: 18px 14px 32px;
  }

  .filter-bar-inner {
    padding: 10px 14px 8px;
    gap: 10px 12px;
  }

  .filter-field {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  .filter-reset {
    flex: 1 1 100%;
    justify-content: center;
  }

  .filter-active {
    padding: 0 14px 10px;
  }

  .section-block {
    scroll-margin-top: 260px;
  }

  .section-head h2 {
    font-size: 19px;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
  }

  .kpi-value {
    font-size: 22px;
  }

  .chart-box {
    height: 230px;
  }

  #map {
    height: 380px;
  }

  .app-nav .brand-logo {
    left: 0;
  }
}
