:root {
  --bg-main: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-sidebar: #ffffff;
  --border-color: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --accent-color: #1a73e8; /* Azul estilo Google */
  --header-height: 56px;
  --footer-height: 32px;
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  font-family: 'Roboto', 'Inter', sans-serif; 
}

html, body {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--bg-main);
  color: var(--text-primary);
}

body {
  display: flex;
  flex-direction: column;
}

/* --- HEADER SUPERIOR ESTILO GOOGLE --- */
.app-header {
  height: var(--header-height);
  min-height: var(--header-height);
  width: 100%;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1001;
  box-shadow: 0 1px 3px rgba(60,64,67,0.15);
}

.header-left { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
}

.toggle-btn {
  background: transparent;
  border: none;
  color: #5f6368;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.2s;
}
.toggle-btn:hover { 
  background: #f1f3f4; 
  color: #202124; 
}

.app-title { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
}
.app-title i { 
  font-size: 20px; 
  color: #ea4335; /* Rojo Google */
}
.app-title h1 { 
  font-size: 16px; 
  font-weight: 500; 
  color: #3c4043; 
}

/* Leyenda estilo chips */
.legend-box {
  background: #ffffff;
  padding: 4px 8px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-size: 11px;
  display: flex;
  gap: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.legend-item { 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  font-weight: 500;
  color: #3c4043;
}
.legend-icon { 
  width: 20px;
  height: 20px; 
  border-radius: 50%; 
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 10px;
}

.header-right { 
  display: flex; 
  align-items: center; 
  gap: 16px; 
}

.user-profile { 
  position: relative; 
  cursor: pointer; 
}
.user-info { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
}
.avatar {
  width: 32px;
  height: 32px;
  background: #1a73e8;
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.user-details { 
  display: flex; 
  flex-direction: column; 
}
.user-name { 
  font-size: 12px; 
  font-weight: 600; 
  color: var(--text-primary); 
}
.user-role { 
  font-size: 10px; 
  color: var(--text-secondary); 
}

/* Dropdown */
.dropdown-menu {
  position: absolute;
  top: 42px;
  right: 0;
  width: 170px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2000;
}
.user-profile:hover .dropdown-menu { 
  display: flex; 
}
.dropdown-item {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}
.dropdown-item:hover { 
  background: #f8fafc; 
}
.dropdown-item.logout { 
  color: #ea4335; 
  border-top: 1px solid var(--border-color); 
}

/* --- CONTENEDOR PRINCIPAL --- */
.main-wrapper {
  flex: 1;
  display: flex !important;
  flex-direction: row !important;
  position: relative;
  width: 100vw;
  height: calc(100vh - var(--header-height) - var(--footer-height));
  overflow: hidden;
}

/* --- SIDEBAR LATERAL --- */
#sidebar {
  width: 360px !important;
  min-width: 360px !important;
  max-width: 360px !important;
  height: 100% !important;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease-in-out;
  z-index: 1000;
  flex-shrink: 0;
}

#sidebar.collapsed { 
  margin-left: -360px !important; 
}

.kpi-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
}
.kpi-card {
  background: var(--bg-surface);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.kpi-card span { 
  font-size: 10px; 
  color: var(--text-secondary); 
  font-weight: 600; 
  text-transform: uppercase; 
}
.kpi-card h3 { 
  font-size: 16px; 
  color: var(--accent-color); 
  margin-top: 2px; 
  font-weight: 700; 
}

.filters-section {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 45vh;
  overflow-y: auto;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
}
.filters-section::-webkit-scrollbar { 
  width: 4px; 
}
.filters-section::-webkit-scrollbar-thumb { 
  background: #cbd5e1; 
  border-radius: 4px; 
}

.filter-group { 
  display: flex; 
  flex-direction: column; 
  gap: 3px; 
}
.filter-group label { 
  font-size: 11px; 
  color: #5f6368; 
  font-weight: 600; 
  display: flex; 
  align-items: center; 
  gap: 5px; 
}
.filter-group label i { 
  color: var(--accent-color); 
}
.filter-group input, .filter-group select {
  width: 100%;
  padding: 7px 10px;
  background: #ffffff;
  border: 1px solid #dadce0;
  color: var(--text-primary);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}
.filter-group input:focus, .filter-group select:focus { 
  border-color: #1a73e8; 
  box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
}

.btn-reset {
  padding: 8px;
  background: #fce8e6;
  color: #c5221f;
  border: 1px solid #fad2cf;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}
.btn-reset:hover { 
  background: #fad2cf; 
}

.selected-card {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  background: #f8fafc;
  margin: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}
.selected-card h4 { 
  font-size: 11px; 
  color: var(--accent-color); 
  text-transform: uppercase; 
  margin-bottom: 8px; 
  display: flex; 
  align-items: center; 
  gap: 5px; 
}
.detail-item { 
  font-size: 11px; 
  margin-bottom: 6px; 
  color: var(--text-primary); 
  line-height: 1.4; 
}
.detail-item b { 
  color: var(--text-secondary); 
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  background: #e8f0fe;
  color: #1a73e8;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

/* --- MAPA --- */
#map { 
  flex-grow: 1;
  height: 100% !important; 
  width: 100% !important;
  background: #e5e3df; /* Color base clásico de Mapas */
}

/* --- FOOTER INFERIOR --- */
.app-footer {
  height: var(--footer-height);
  min-height: var(--footer-height);
  width: 100%;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 11px;
  color: var(--text-secondary);
  z-index: 1001;
}

/* --- ESTILO MARCADOR GOOGLE MAPS --- */
.custom-google-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 12px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.15s ease-in-out;
}

.marker-circle:hover {
  transform: scale(1.2);
  z-index: 999;
}

/* Popups Leaflet Estilo Google */
.leaflet-popup-content-wrapper {
  background: #ffffff !important;
  color: var(--text-primary) !important;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2) !important;
  padding: 4px;
}
.leaflet-popup-tip { 
  background: #ffffff !important; 
}
.popup-title { 
  font-weight: 700; 
  color: #1a73e8; 
  font-size: 13px; 
  margin-bottom: 4px; 
}
.popup-text { 
  font-size: 11px; 
  color: #5f6368; 
  margin-bottom: 2px; 
}

.app-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-renipress {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,.20));
}

.app-title h1 {
    margin: 0;
}