/* ECUES - PORTAL RESPONSIVE */
/* Dashboard + Mapa interactivo */

/* DESKTOP INTERMEDIO */

@media (min-width: 1451px) {
  .map-page-heading h1 {
    white-space: nowrap;
  }
}

@media (max-width: 1450px) {
  .map-page-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .map-page-toolbar {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

@media (max-width: 1350px) {
  body:has(.hero) .hero-top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body:has(.hero) .hero-title {
    grid-column: 1 / -1;
  }

  body:has(.hero) .period-card {
    grid-column: 1;
  }

  body:has(.hero) .report-card {
    grid-column: 2;
  }

  body:has(.hero) .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body:has(.hero) .summary-grid .map-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1100px) {
  body:has(.map-page) .map-page-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 0 18px 18px;
  }

  body:has(.map-page) .map-page-toolbar {
    width: 100%;
    justify-content: flex-end;
  }

  body:has(.map-page) .map-summary {
    gap: 18px;
  }

  body:has(.map-page) .map-commune-filter {
    width: 210px;
    flex-basis: 210px;
  }

  body:has(.map-page) .map-type-filter {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body:has(.map-page) .map-type-filter::-webkit-scrollbar {
    display: none;
  }

  body:has(.map-page) .map-type-filter-button {
    flex: 1 0 auto;
  }

  body:has(.hero) .report-modal {
    padding: 16px;
  }

  body:has(.hero) .report-modal-dialog {
    width: calc(100vw - 32px);
    height: calc(100dvh - 32px);
  }
}

@media (max-width: 1000px) {
  body:has(.hero) .hero, body:has(.hero) .dashboard, body:has(.hero) .footer {
    padding-left: 24px;
    padding-right: 24px;
  }

  body:has(.hero) .hero-top {
    grid-template-columns: 1fr;
  }

  body:has(.hero) .hero-title, body:has(.hero) .period-card, body:has(.hero) .report-card {
    grid-column: 1;
  }

  body:has(.hero) .period-card {
    min-height: 145px;
  }

  body:has(.hero) .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body:has(.hero) .summary-grid .map-card {
    grid-column: 1 / -1;
  }

  body:has(.hero) .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  body:has(.hero) .chart-modal {
    padding: 14px;
  }

  body:has(.hero) .chart-modal-dialog {
    width: 100%;
    max-height: 94dvh;
    border-radius: 12px;
  }

  body:has(.hero) .chart-modal-header {
    padding: 12px 14px;
  }

  body:has(.hero) .chart-modal-body {
    padding: 12px;
  }

  body:has(.hero) .chart-modal-canvas {
    height: 520px;
    min-height: 380px;
  }
}

/* MOBILE */

@media (max-width: 767px) {
  body:has(.hero), body:has(.map-page) {
    overflow-x: hidden;
  }

  body:has(.hero) .topbar, body:has(.map-page) .topbar {
    height: auto;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 18px;
  }

  body:has(.hero) .brand, body:has(.map-page) .brand {
    width: 100%;
    min-width: 0;
    gap: 11px;
  }

  body:has(.hero) .brand-logo, body:has(.map-page) .brand-logo {
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
  }

  body:has(.hero) .brand-main, body:has(.map-page) .brand-main {
    min-width: 0;
  }

  body:has(.hero) .brand-title, body:has(.map-page) .brand-title {
    gap: 7px;
  }

  body:has(.hero) .brand-same, body:has(.hero) .brand-separator, body:has(.hero) .brand-ecues,
  body:has(.map-page) .brand-same, body:has(.map-page) .brand-separator, body:has(.map-page) .brand-ecues {
    font-size: 27px;
  }

  body:has(.hero) .brand-subtitle, body:has(.map-page) .brand-subtitle {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.2;
  }

  body:has(.hero) .topbar-actions, body:has(.map-page) .topbar-actions {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  body:has(.hero) .theme-switch, body:has(.map-page) .theme-switch {
    flex: 0 0 70px;
  }

  body:has(.hero) .language-menu, body:has(.map-page) .language-menu {
    flex: 0 0 auto;
  }

  body:has(.hero) .language-menu-trigger, body:has(.map-page) .language-menu-trigger {
    min-width: 104px;
    justify-content: center;
  }

  body:has(.hero) .user-menu, body:has(.map-page) .user-menu {
    flex: 0 0 auto;
  }

  body:has(.hero) .user-menu-trigger, body:has(.map-page) .user-menu-trigger {
    gap: 8px;
    padding: 2px;
  }

  body:has(.hero) .user-avatar, body:has(.map-page) .user-avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    font-size: 16px;
  }

  body:has(.hero) .user-meta, body:has(.map-page) .user-meta {
    display: none;
  }

  body:has(.hero) .user-chevron, body:has(.map-page) .user-chevron {
    margin-left: 2px;
    font-size: 9px;
  }

  body:has(.hero) .user-dropdown, body:has(.map-page) .user-dropdown {
    width: min(280px, calc(100vw - 28px));
    min-width: 0;
  }

  body:has(.hero) .admin-login-trigger, body:has(.map-page) .admin-login-trigger {
    height: 42px;
    padding: 0 12px;
    font-size: 11px;
  }

  body:has(.hero) .hero {
    padding: 24px 18px 22px;
  }

  body:has(.hero) .hero-top {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  body:has(.hero) .hero-title {
    grid-column: 1;
  }

  body:has(.hero) .hero-title h1 {
    font-size: 30px;
    letter-spacing: -0.6px;
  }

  body:has(.hero) .hero-title p {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.4;
  }

  body:has(.hero) .period-card {
    min-height: 0;
    height: auto;
    grid-column: 1;
    padding: 16px;
    border-radius: 12px;
  }

  body:has(.hero) .period-card-heading strong {
    font-size: 22px;
  }

  body:has(.hero) .period-card-heading span {
    font-size: 12px;
  }

  body:has(.hero) .period-live-status {
    display: none;
  }

  body:has(.hero) .period-types {
    height: 44px;
    margin: 12px 0 18px;
  }

  body:has(.hero) .period-types .segment {
    font-size: 11px;
  }

  body:has(.hero) .period-content {
    min-height: 58px;
  }

  body:has(.hero) .period-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  body:has(.hero) .period-fields-semestral, body:has(.hero) .period-fields-anual {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  body:has(.hero) .period-fields-manual {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  body:has(.hero) .period-manual-date {
    grid-template-columns: 0.72fr 1.25fr 0.9fr;
    gap: 6px;
  }

  body:has(.hero) .filter-group label {
    font-size: 12px;
  }

  body:has(.hero) .report-card {
    min-height: 0;
    grid-column: 1;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 12px;
    padding: 20px 18px;
    border-radius: 12px;
  }

  body:has(.hero) .report-icon {
    width: 44px;
    height: 44px;
    font-size: 34px;
  }

  body:has(.hero) .report-content {
    min-width: 0;
  }

  body:has(.hero) .report-content h2 {
    font-size: 22px;
  }

  body:has(.hero) .report-content p {
    margin-bottom: 14px;
    font-size: 12px;
    line-height: 1.5;
  }

  body:has(.hero) .report-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  body:has(.hero) .report-button {
    width: 100%;
    min-width: 0;
    height: 38px;
  }

  body:has(.hero) .report-bars {
    display: none;
  }

  body:has(.hero) .summary-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 16px;
  }

  body:has(.hero) .kpi-card, body:has(.hero) .summary-grid .map-card {
    min-height: 98px;
    border-radius: 12px;
  }

  body:has(.hero) .kpi-card {
    gap: 14px;
    padding: 15px 18px;
  }

  body:has(.hero) .kpi-icon {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
    font-size: 24px;
  }

  body:has(.hero) .kpi-label {
    font-size: 14px;
  }

  body:has(.hero) .kpi-value-row {
    gap: 18px;
  }

  body:has(.hero) .kpi-value-row strong {
    font-size: 30px;
  }

  body:has(.hero) .frequency-day {
    font-size: 12px;
  }

  body:has(.hero) .frequency-time {
    font-size: 17px;
  }

  body:has(.hero) .summary-grid .map-card {
    grid-column: 1;
    min-height: 108px;
  }

  body:has(.hero) .summary-grid .map-overlay {
    padding: 16px 18px;
  }

  body:has(.hero) .summary-grid .map-button {
    width: 100%;
    min-width: 0;
  }

  body:has(.hero) .dashboard {
    padding: 18px;
  }

  body:has(.hero) .chart-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  body:has(.hero) .chart-card {
    height: 310px;
    padding: 14px 14px 10px;
  }

  body:has(.hero) .chart-title h3 {
    font-size: 14px;
  }

  body:has(.hero) .chart-modal {
    padding: 0;
  }

  body:has(.hero) .chart-modal-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  body:has(.hero) .chart-modal-header {
    min-height: 56px;
    padding: 11px 14px;
  }

  body:has(.hero) .chart-modal-body {
    padding: 10px;
  }

  body:has(.hero) .chart-modal-canvas {
    height: 100%;
    min-height: 0;
  }

  body:has(.hero) .chart-modal-footer {
    min-height: 54px;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 9px 14px;
  }

  body:has(.hero) .chart-modal-footer-text {
    width: 100%;
  }

  body:has(.hero) .chart-modal-footer-separator {
    display: none;
  }

  body:has(.hero) .report-modal {
    display: flex;
    padding: 0;
  }

  body:has(.hero) .report-modal-dialog {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  body:has(.hero) .report-modal-header {
    min-height: 58px;
    flex-basis: 58px;
    gap: 10px;
    padding: 0 12px;
  }

  body:has(.hero) .report-modal-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  body:has(.hero) .report-modal-title-wrap h3 {
    font-size: 13px;
  }

  body:has(.hero) .report-modal-download {
    height: 32px;
    padding: 0 10px;
  }

  body:has(.hero) .report-modal-close {
    width: 32px;
    height: 32px;
  }

  body:has(.map-page) {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body:has(.map-page) .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  body:has(.map-page) .app-shell > main {
    min-height: 0;
    display: block;
    overflow: visible;
  }

  body:has(.map-page) .map-page {
    height: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 18px 14px 0;
    overflow: visible;
  }

  body:has(.map-page) .map-page-header {
    width: 100%;
    gap: 14px;
    padding: 0 0 14px;
  }

  body:has(.map-page) .map-page-heading {
    width: 100%;
    margin: 0;
  }

  body:has(.map-page) .map-page-heading h1 {
    font-size: 28px;
    letter-spacing: -0.6px;
  }

  body:has(.map-page) .map-page-heading p {
    margin-top: 7px;
    font-size: 12px;
    line-height: 1.35;
  }

  body:has(.map-page) .map-page-toolbar {
    width: 100%;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0;
  }

  body:has(.map-page) .map-toolbar-separator {
    display: none;
  }

  body:has(.map-page) .map-summary {
    order: 1;
    width: auto;
    min-width: 0;
    flex: 1 1 calc(50% - 5px);
    justify-content: flex-start;
    padding: 2px 9px;
  }

  body:has(.map-page) .map-summary-item {
    min-width: 0;
  }

  body:has(.map-page) .map-summary-item strong {
    font-size: 15px;
  }

  body:has(.map-page) .map-commune-filter {
    order: 2;
    width: auto;
    min-width: 0;
    flex: 1 1 calc(50% - 5px);
    flex-basis: calc(50% - 5px);
  }

  body:has(.map-page) .map-commune-menu {
    width: min(320px, calc(100vw - 28px));
    right: 0;
    left: auto;
  }

  body:has(.map-page) .map-type-filter {
    order: 3;
    width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  body:has(.map-page) .map-type-filter::-webkit-scrollbar {
    display: none;
  }

  body:has(.map-page) .map-type-filter-button {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  body:has(.map-page) .map-header-actions {
    order: 4;
    width: auto;
    min-width: 0;
    flex: 1 1 calc(50% - 5px);
  }

  body:has(.map-page) .map-header-actions .map-header-button {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
  }

  body:has(.map-page) .map-back-button {
    order: 5;
    min-width: 0;
    flex: 1 1 calc(50% - 5px);
    justify-content: center;
    padding: 0 10px;
    text-align: center;
  }

  body:has(.map-page) .map-page .map-card {
    width: 100%;
    height: 62dvh;
    min-height: 420px;
    max-height: 680px;
    flex: 0 0 auto;
    border-radius: 10px 10px 0 0;
  }

  body:has(.map-page) .map-container-wrap, body:has(.map-page) .incident-map {
    min-height: 0;
  }

  body:has(.map-page) .map-legend {
    width: 132px;
    padding: 9px 10px;
  }

  body:has(.map-page) .map-legend strong {
    margin-bottom: 6px;
    font-size: 10px;
  }

  body:has(.map-page) .map-legend-grid {
    gap: 4px 6px;
  }

  body:has(.map-page) .map-legend-grid span {
    gap: 3px;
    font-size: 9px;
  }

  body:has(.map-page) .incident-map .leaflet-control-layers-toggle {
    width: 38px;
    height: 38px;
    background-size: 20px 20px;
  }

  body:has(.map-page) .incident-map .leaflet-control-zoom a {
    width: 31px;
    height: 31px;
    line-height: 31px;
  }

  body:has(.map-page) .incident-map .leaflet-popup-content-wrapper {
    max-width: calc(100vw - 48px);
  }

  body:has(.map-page) .incident-map .leaflet-popup-content {
    margin: 12px 13px;
  }
}

/* MOBILE COMPACTO */

@media (max-width: 520px) {
  body:has(.hero) .topbar, body:has(.map-page) .topbar {
    gap: 15px;
    padding: 15px 14px;
  }

  body:has(.hero) .brand, body:has(.map-page) .brand {
    gap: 10px;
  }

  body:has(.hero) .brand-logo, body:has(.map-page) .brand-logo {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
  }

  body:has(.hero) .brand-same, body:has(.hero) .brand-separator, body:has(.hero) .brand-ecues,
  body:has(.map-page) .brand-same, body:has(.map-page) .brand-separator, body:has(.map-page) .brand-ecues {
    font-size: 26px;
  }

  body:has(.hero) .brand-subtitle, body:has(.map-page) .brand-subtitle {
    font-size: 10px;
  }

  body:has(.hero) .topbar-actions, body:has(.map-page) .topbar-actions {
    gap: 10px;
  }

  body:has(.hero) .theme-switch, body:has(.map-page) .theme-switch {
    width: 68px;
    flex-basis: 68px;
  }

  body:has(.hero) .language-menu-trigger, body:has(.map-page) .language-menu-trigger {
    min-width: 98px;
    height: 38px;
    padding: 0 10px 0 8px;
  }

  body:has(.hero) .language-trigger-flag, body:has(.map-page) .language-trigger-flag {
    width: 23px;
    height: 23px;
  }

  body:has(.hero) .user-avatar, body:has(.map-page) .user-avatar {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  body:has(.hero) .hero {
    padding: 22px 14px 18px;
  }

  body:has(.hero) .hero-title h1 {
    font-size: 28px;
  }

  body:has(.hero) .hero-title p {
    font-size: 13px;
  }

  body:has(.hero) .period-card {
    padding: 15px 14px;
  }

  body:has(.hero) .period-types .segment {
    font-size: 10px;
  }

  body:has(.hero) .report-card {
    grid-template-columns: 46px minmax(0, 1fr);
    padding: 18px 14px;
  }

  body:has(.hero) .report-content h2 {
    font-size: 20px;
  }

  body:has(.hero) .report-actions {
    gap: 8px;
  }

  body:has(.hero) .report-button {
    padding: 0 8px;
    font-size: 11px;
  }

  body:has(.hero) .kpi-card {
    padding: 14px 15px;
  }

  body:has(.hero) .kpi-value-row strong {
    font-size: 28px;
  }

  body:has(.hero) .dashboard {
    padding: 14px;
  }

  body:has(.hero) .chart-card {
    height: 290px;
  }

  body:has(.hero) .report-modal-download span {
    display: none;
  }

  body:has(.map-page) .map-page {
    padding: 16px 12px 0;
  }

  body:has(.map-page) .map-page-heading h1 {
    font-size: 26px;
  }

  body:has(.map-page) .map-page .map-card {
    height: 58dvh;
    min-height: 400px;
  }

  body:has(.map-page) .map-summary, body:has(.map-page) .map-commune-filter,
  body:has(.map-page) .map-header-actions, body:has(.map-page) .map-back-button {
    min-height: 42px;
  }

  body:has(.map-page) .map-back-button, body:has(.map-page) .map-header-actions .map-header-button {
    font-size: 11px;
  }
}

@media (max-width: 380px) {
  body:has(.hero) .topbar, body:has(.map-page) .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  body:has(.hero) .brand-logo, body:has(.map-page) .brand-logo {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  body:has(.hero) .brand-same, body:has(.hero) .brand-separator, body:has(.hero) .brand-ecues,
  body:has(.map-page) .brand-same, body:has(.map-page) .brand-separator, body:has(.map-page) .brand-ecues {
    font-size: 24px;
  }

  body:has(.hero) .brand-subtitle, body:has(.map-page) .brand-subtitle {
    font-size: 9px;
  }

  body:has(.hero) .theme-switch, body:has(.map-page) .theme-switch {
    width: 64px;
    flex-basis: 64px;
  }

  body:has(.hero) .language-menu-trigger, body:has(.map-page) .language-menu-trigger {
    min-width: 92px;
  }

  body:has(.hero) .language-trigger-code, body:has(.map-page) .language-trigger-code {
    font-size: 11px;
  }

  body:has(.hero) .user-avatar, body:has(.map-page) .user-avatar {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  body:has(.hero) .period-types .segment {
    font-size: 9px;
  }

  body:has(.hero) .report-button {
    font-size: 10px;
  }

  body:has(.map-page) .map-page-toolbar {
    gap: 8px;
  }

  body:has(.map-page) .map-summary, body:has(.map-page) .map-commune-filter,
  body:has(.map-page) .map-header-actions, body:has(.map-page) .map-back-button {
    flex-basis: calc(50% - 4px);
  }

  body:has(.map-page) .map-type-filter-button {
    padding: 0 9px;
    font-size: 11px;
  }
}

/* ============================================================
   ECUES - DASHBOARD RESPONSIVE V2 (03-11-2026)
   Las reglas de escritorio originales permanecen intactas.
   ============================================================ */

.mobile-options-trigger {
  display: none;
}

.mobile-options-overlay[hidden],
.mobile-chart-legend[hidden],
.mobile-heatmap-scale[hidden],
.chart-modal-mobile-legend[hidden],
.chart-modal-mobile-scale[hidden] {
  display: none !important;
}

.mobile-options-overlay {
  position: fixed;
  inset: 0;
  z-index: 4100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.mobile-options-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.mobile-options-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 22, 41, 0.62);
  backdrop-filter: blur(3px);
}

.mobile-options-panel {
  width: min(420px, 100%);
  max-height: min(660px, calc(100dvh - 32px));
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--theme-border);
  border-radius: 16px;
  background: var(--theme-surface);
  box-shadow: 0 24px 66px rgba(3, 19, 34, 0.27);
  color: var(--theme-text);
  transform: translateY(12px);
  transition: transform 0.18s ease;
}

.mobile-options-overlay.is-open .mobile-options-panel {
  transform: translateY(0);
}

.mobile-options-heading {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--theme-border);
}

.mobile-options-heading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.mobile-options-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  border: 1px solid var(--theme-border);
  border-radius: 9px;
  background: var(--theme-surface-2);
  color: var(--theme-text);
}

.mobile-options-content {
  padding: 16px 18px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mobile-options-section-title {
  margin: 4px 0 10px;
  color: var(--theme-muted);
  font-size: 12px;
  font-weight: 700;
}

.mobile-options-themes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 23px;
}

.mobile-options-theme {
  min-width: 0;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px;
  border: 1px solid var(--theme-border);
  border-radius: 10px;
  background: var(--theme-surface-2);
  color: var(--theme-text);
  font-size: 12px;
  font-weight: 600;
}

.mobile-options-theme.active {
  border-color: var(--same-green);
  background: rgba(0, 150, 64, 0.09);
  color: var(--same-green);
}

html[data-theme="dark"] .mobile-options-theme.active {
  color: #4ddc90;
}

.mobile-options-languages {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mobile-options-language {
  min-height: 46px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--theme-border);
  border-radius: 10px;
  color: var(--theme-text);
  background: var(--theme-surface-2);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.mobile-options-language.active {
  border-color: var(--same-green);
  background: rgba(0, 150, 64, 0.08);
}

.mobile-options-language img {
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  border-radius: 50%;
  object-fit: cover;
}

.mobile-options-language span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.mobile-options-language i {
  margin-left: auto;
  color: var(--same-green);
}

body.mobile-options-open {
  overflow: hidden;
}

.mobile-chart-legend,
.chart-modal-mobile-legend {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 4px 6px 10px;
}

.mobile-legend-item {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--theme-text);
  font-size: 11px;
  line-height: 1.35;
}

.mobile-legend-marker {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border-radius: 3px;
  border: 1px solid rgba(100, 130, 155, 0.25);
}

.mobile-legend-label {
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
}

.mobile-legend-value {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 11px;
}

.mobile-heatmap-scale,
.chart-modal-mobile-scale {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(32px, 1fr) minmax(0, auto);
  align-items: center;
  gap: 9px;
  padding: 6px 3px 12px;
  color: var(--theme-muted);
  font-size: 10px;
  line-height: 1.3;
}

.mobile-heatmap-scale span:last-child,
.chart-modal-mobile-scale span:last-child {
  text-align: right;
}

.mobile-heatmap-gradient {
  width: 100%;
  height: 10px;
  display: block;
  border-radius: 5px;
  background: linear-gradient(90deg, #fff5d5, #ffd365, #ff8a3d, #eb3029, #9a002e);
}

@media (max-width: 767px) {
  body:has(.hero) .topbar,
  body:has(.map-page) .topbar {
    height: 66px;
    min-height: 66px;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
  }

  body:has(.hero) .brand,
  body:has(.map-page) .brand {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    gap: 7px;
  }

  body:has(.hero) .brand-logo,
  body:has(.map-page) .brand-logo {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }

  body:has(.hero) .brand-title,
  body:has(.map-page) .brand-title {
    gap: 5px;
    white-space: nowrap;
  }

  body:has(.hero) .brand-same,
  body:has(.hero) .brand-separator,
  body:has(.hero) .brand-ecues,
  body:has(.map-page) .brand-same,
  body:has(.map-page) .brand-separator,
  body:has(.map-page) .brand-ecues {
    font-size: 20px;
  }

  body:has(.hero) .brand-subtitle,
  body:has(.map-page) .brand-subtitle {
    max-width: 205px;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 8px;
    line-height: 1.15;
  }

  body:has(.hero) .topbar-actions,
  body:has(.map-page) .topbar-actions {
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 7px;
  }

  body:has(.hero) .topbar-actions .theme-switch,
  body:has(.hero) .topbar-actions .language-menu,
  body:has(.map-page) .topbar-actions .theme-switch,
  body:has(.map-page) .topbar-actions .language-menu {
    display: none;
  }

  body:has(.hero) .admin-login-trigger,
  body:has(.map-page) .admin-login-trigger {
    width: 40px;
    min-width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    border-radius: 9px;
    font-size: 15px;
  }

  body:has(.hero) .admin-login-trigger span,
  body:has(.map-page) .admin-login-trigger span {
    display: none;
  }

  body:has(.hero) .mobile-options-trigger,
  body:has(.map-page) .mobile-options-trigger {
    width: 40px;
    min-width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--theme-border);
    border-radius: 9px;
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: 16px;
  }

  body:has(.hero) .user-menu-trigger,
  body:has(.map-page) .user-menu-trigger {
    height: 40px;
    gap: 0;
    padding: 0;
  }

  body:has(.hero) .user-avatar,
  body:has(.map-page) .user-avatar {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }

  body:has(.hero) .user-chevron,
  body:has(.map-page) .user-chevron {
    display: none;
  }

  body:has(.hero) .hero {
    padding-top: 17px;
  }

  body:has(.hero) .hero-top {
    gap: 14px;
  }

  body:has(.hero) .chart-card {
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  body:has(.hero) .chart-card .chart {
    width: 100%;
    height: 250px;
  }

  body:has(.hero) #chart-incidentes {
    height: 250px;
  }

  body:has(.hero) #chart-vehiculos,
  body:has(.hero) #chart-traslados {
    height: 205px;
  }

  body:has(.hero) #chart-zonas {
    height: 220px;
  }

  body:has(.hero) #chart-heatmap {
    height: 228px;
  }

  body:has(.hero) #chart-edades {
    height: 265px;
  }

  body:has(.hero) .chart-modal-dialog {
    min-width: 0;
  }

  body:has(.hero) .chart-modal-body {
    min-width: 0;
    padding: 12px 10px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body:has(.hero) .chart-modal-canvas {
    width: 100%;
    min-height: 0;
    max-width: 100%;
    flex: 0 0 auto;
  }

  body:has(.hero) .chart-modal-header {
    flex: 0 0 auto;
    gap: 8px;
  }

  body:has(.hero) .chart-modal-header .chart-title h3 {
    overflow-wrap: anywhere;
  }

  body:has(.hero) .chart-modal-actions {
    flex: 0 0 auto;
  }

  body:has(.hero) .chart-modal-footer {
    min-height: 0;
    flex: 0 0 auto;
    align-items: center;
    padding: 9px 12px;
  }

  body:has(.hero) .chart-modal-footer-brand {
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 5px 8px;
  }

  body:has(.hero) .chart-modal-footer-brand img {
    height: 20px;
  }

  body:has(.hero) .chart-modal-footer-text {
    width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 9px;
  }

  body:has(.hero) .chart-modal-watermark img {
    max-width: 50vw;
  }

  body:has(.hero) .period-manual-date {
    grid-template-columns: minmax(52px, 0.75fr) minmax(0, 1.4fr) minmax(65px, 1fr);
    gap: 6px;
  }

  body:has(.hero) .period-manual-date .ecues-select,
  body:has(.hero) .period-manual-date .ecues-select-trigger {
    min-width: 0;
    width: 100%;
  }

  body:has(.hero) .period-manual-date .ecues-select-trigger-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body:has(.hero) .period-types .segment {
    min-width: 0;
  }

  body:has(.hero) .kpi-content,
  body:has(.hero) .kpi-value-row {
    min-width: 0;
  }

  body:has(.hero) .kpi-value-row {
    flex-wrap: wrap;
    gap: 6px 15px;
  }

}

@media (min-width: 520px) and (max-width: 767px) {
  .mobile-chart-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 350px) {
  body:has(.hero) .brand-logo,
  body:has(.map-page) .brand-logo {
    width: 35px;
    height: 35px;
    flex-basis: 35px;
  }

  body:has(.hero) .brand-same,
  body:has(.hero) .brand-separator,
  body:has(.hero) .brand-ecues,
  body:has(.map-page) .brand-same,
  body:has(.map-page) .brand-separator,
  body:has(.map-page) .brand-ecues {
    font-size: 18px;
  }

  body:has(.hero) .brand-subtitle,
  body:has(.map-page) .brand-subtitle {
    display: none;
  }

  body:has(.hero) .admin-login-trigger,
  body:has(.map-page) .admin-login-trigger,
  body:has(.hero) .mobile-options-trigger,
  body:has(.map-page) .mobile-options-trigger {
    width: 37px;
    height: 37px;
    min-width: 37px;
  }

  .mobile-options-languages {
    grid-template-columns: 1fr;
  }
}

/* ================================================================
   ECUES / MAPA - AJUSTES TACTILES Y FILTRO COMPACTO (2026-11-03)
   Mantiene la barra de filtros original en escritorio.
   ================================================================ */

.map-type-select-mobile {
  display: none;
}

@media (max-width: 767px) {
  body:has(.map-page) .map-type-filter {
    display: none;
  }

  body:has(.map-page) .map-header-actions {
    display: none;
  }

  body:has(.map-page) .map-type-select-mobile {
    order: 3;
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }

  body:has(.map-page) .map-type-select-mobile-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Usa el mismo componente ECUESSelect que los filtros del portal. */
  body:has(.map-page) .map-type-select-mobile > .ecues-select {
    width: 100%;
    min-height: 44px;
    border-radius: 9px;
  }

  body:has(.map-page) .map-type-select-mobile .ecues-select-trigger {
    min-height: 42px;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 600;
  }

  body:has(.map-page) .map-type-select-mobile .ecues-select-trigger i {
    font-size: 10px;
  }

  body:has(.map-page) .map-back-button {
    order: 4;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    flex: 1 1 100%;
    justify-content: center;
    text-align: center;
    font-size: 12px;
  }

  body:has(.map-page) .map-page-toolbar {
    gap: 8px;
  }

  /* La vista y el mapa ocupan el espacio libre hasta el footer. */
  body:has(.map-page) .app-shell > main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  body:has(.map-page) .map-page {
    height: 100%;
    flex: 1 1 auto;
    min-height: 0;
  }

  body:has(.map-page) .map-page .map-card {
    height: auto;
    min-height: clamp(310px, 46dvh, 480px);
    max-height: none;
    flex: 1 1 auto;
  }

  /* El mapa recibe el gesto tactil para arrastrar con un dedo.
     Para desplazar la pagina, deslizar desde fuera del mapa. */
  body:has(.map-page) .incident-map {
    touch-action: none;
  }
}

/* ================================================================
   ECUES | ENCABEZADO RESPONSIVE GLOBAL - 2026-11-04
   Misma topbar en dashboard, mapa, administracion y futuras vistas.
   Sustituye visualmente las reglas antiguas de admin-responsive.css,
   sin modificar los componentes del contenido administrativo.
   ================================================================ */

@media (max-width: 767px) {
  body .app-shell > .topbar {
    height: 66px;
    min-height: 66px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
  }

  body .app-shell > .topbar .brand {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    gap: 7px;
  }

  body .app-shell > .topbar .brand-logo {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }

  body .app-shell > .topbar .brand-main {
    min-width: 0;
  }

  body .app-shell > .topbar .brand-title {
    gap: 5px;
    white-space: nowrap;
  }

  body .app-shell > .topbar .brand-same,
  body .app-shell > .topbar .brand-separator,
  body .app-shell > .topbar .brand-ecues {
    font-size: 20px;
  }

  body .app-shell > .topbar .brand-subtitle {
    max-width: 205px;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 8px;
    line-height: 1.15;
  }

  body .app-shell > .topbar .topbar-actions {
    width: auto;
    min-width: 0;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
  }

  body .app-shell > .topbar .topbar-actions .theme-switch,
  body .app-shell > .topbar .topbar-actions .language-menu {
    display: none;
  }

  body .app-shell > .topbar .admin-login-trigger {
    width: 40px;
    min-width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    border-radius: 9px;
    font-size: 15px;
  }

  body .app-shell > .topbar .admin-login-trigger span {
    display: none;
  }

  body .app-shell > .topbar .mobile-options-trigger {
    width: 40px;
    min-width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--theme-border);
    border-radius: 9px;
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: 16px;
  }

  body .app-shell > .topbar .user-menu {
    position: relative;
    flex: 0 0 auto;
  }

  body .app-shell > .topbar .user-menu-trigger {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
  }

  body .app-shell > .topbar .user-avatar {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }

  body .app-shell > .topbar .user-meta,
  body .app-shell > .topbar .user-chevron {
    display: none;
  }

  body .app-shell > .topbar .user-dropdown {
    width: min(280px, calc(100vw - 24px));
    min-width: 0;
    right: 0;
    left: auto;
  }
}

@media (max-width: 350px) {
  body .app-shell > .topbar .brand-logo {
    width: 35px;
    height: 35px;
    flex-basis: 35px;
  }

  body .app-shell > .topbar .brand-same,
  body .app-shell > .topbar .brand-separator,
  body .app-shell > .topbar .brand-ecues {
    font-size: 18px;
  }

  body .app-shell > .topbar .brand-subtitle {
    display: none;
  }

  body .app-shell > .topbar .admin-login-trigger,
  body .app-shell > .topbar .mobile-options-trigger {
    width: 37px;
    height: 37px;
    min-width: 37px;
  }

  body .app-shell > .topbar .user-menu-trigger,
  body .app-shell > .topbar .user-avatar {
    width: 37px;
    height: 37px;
    flex-basis: 37px;
  }
}

/* ============================================================
   ECUES - FOOTER GLOBAL RESPONSIVE
   Una sola estructura para dashboard, mapa y administracion.
   ============================================================ */

@media (max-width: 767px) {
  body .app-shell > .footer {
    min-height: 66px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    padding: 9px 14px;
  }

  body .app-shell > .footer .footer-brand {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
  }

  body .app-shell > .footer .footer-copy {
    min-width: 0;
    align-items: flex-start;
    gap: 4px;
  }

  body .app-shell > .footer .footer-team,
  body .app-shell > .footer .updated {
    width: auto;
    max-width: 100%;
    font-size: 10px;
    line-height: 1.3;
    text-align: left;
  }
}

@media (max-width: 350px) {
  body .app-shell > .footer .footer-brand {
    grid-template-columns: 38px minmax(0, 1fr);
    column-gap: 10px;
  }

  body .app-shell > .footer .footer-logo {
    width: 38px;
    height: 38px;
  }
}
