* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f172a;
    color: #1e293b;
}

#map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* ==========================================================================
   BARRA SUPERIOR FLOTANTE
   ========================================================================== */
.header-bar {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.96);
    padding: 10px 16px;
    border-radius: 14px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    display: flex;
    gap: 12px;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.brand-text h1 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.brand-text p {
    margin: 1px 0 0 0;
    font-size: 11px;
    color: #64748b;
}

/* Buscador */
.search-container {
    flex: 1;
    position: relative;
    max-width: 420px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 4px 10px;
    border: 1.5px solid #e2e8f0;
    transition: all 0.2s ease;
}

.search-input-wrapper:focus-within {
    background: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 12.5px;
    color: #0f172a;
    outline: none;
    padding: 4px;
}

.search-icon {
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
}

.search-results-dropdown {
    position: absolute;
    top: 42px;
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border: 1px solid #e2e8f0;
    max-height: 240px;
    overflow-y: auto;
    display: none;
    z-index: 1200;
}

.search-item {
    padding: 9px 12px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.search-item:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.search-item .item-main {
    font-weight: 600;
    color: #0f172a;
}

.search-item .item-sub {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

/* Selector de Radio (1km, 2km, 3km) */
.radio-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    padding: 4px 10px;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    flex-shrink: 0;
}

.radio-label {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.radio-pills {
    display: flex;
    background: #e2e8f0;
    padding: 2px;
    border-radius: 8px;
    gap: 2px;
}

.btn-radio-pill {
    background: transparent;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-radio-pill:hover {
    color: #0f172a;
}

.btn-radio-pill.active {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.btn-action {
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-limpiar {
    background: #f1f5f9;
    color: #475569;
}

.btn-limpiar:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Toast de Instrucción */
.instruction-toast {
    position: absolute;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(15, 23, 42, 0.90);
    color: white;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* ==========================================================================
   PANEL LATERAL DE KPIS
   ========================================================================== */
.kpi-panel {
    position: absolute;
    top: 75px;
    right: 12px;
    bottom: 12px;
    width: 340px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 14px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi-panel.hidden {
    transform: translateX(360px);
}

.kpi-panel h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.location-subtitle {
    font-size: 11.5px;
    color: #64748b;
    margin-top: -6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Banner de Atractivo Promedio */
.atractivo-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    padding: 10px 14px;
    border-radius: 12px;
}

.atractivo-banner .atr-title {
    font-size: 10.5px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.atractivo-banner .atr-desc {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.atractivo-score {
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
    background: #2563eb;
    padding: 4px 12px;
    border-radius: 8px;
    min-width: 45px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Cuadrícula de KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.kpi-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
}

.kpi-box.highlight {
    background: #eff6ff;
    border-color: #bfdbfe;
    grid-column: span 2;
}

.kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 2px;
}

.kpi-val {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.kpi-box.highlight .kpi-val {
    font-size: 22px;
    color: #1d4ed8;
}

/* Desglose de Atractivo en mini barras */
.distribucion-container {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
}

.distribucion-title {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.distribucion-barras {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 40px;
    padding-top: 4px;
}

.barra-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.barra-fill {
    width: 100%;
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    transition: height 0.3s ease;
}

.barra-num {
    font-size: 9px;
    color: #64748b;
    margin-top: 2px;
    font-weight: 600;
}

/* Botón de Descarga */
.kpi-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-kpi-action {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.btn-kpi-csv {
    background: #10b981;
    color: white;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.btn-kpi-csv:hover {
    background: #059669;
}

/* ==========================================================================
   LEYENDA DE INTELIGENCIA TERRITORIAL
   ========================================================================== */
.legend-bar {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 12px;
    padding: 8px 12px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 380px;
}

.legend-title {
    font-weight: 700;
    color: #0f172a;
    font-size: 11px;
}

.map-legend-grid {
    display: flex;
    gap: 2px;
}

.map-legend-cell {
    width: 26px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    border-radius: 3px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 2px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #475569;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* ==========================================================================
   MARCADOR PERSONALIZADO DE EDIFICIOS (🏢)
   ========================================================================== */
.marker-edificio {
    background: transparent;
    border: none;
}

.marker-edificio-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s ease;
    cursor: pointer;
}

.marker-edificio-pin:hover {
    transform: scale(1.15);
}

.marker-edificio-emoji {
    font-size: 14px;
    line-height: 1;
}

.marker-edificio-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: #0f172a;
    color: #ffffff;
    font-size: 9px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 8px;
    border: 1.5px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Spinner Overlay */
.loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: white;
    font-weight: 600;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.loader-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3.5px solid rgba(255, 255, 255, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

