:root {
    --solar: #e65c00;
    --solar-dark: #c64e00;
    --solar-light: #ffefe6;
    --navy: #0b2545;
    --navy-light: #1b3a63;
    --navy-mid: #2a4d7f;
    --success: #10b981;
    --success-dark: #059669;
    --slate-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(11, 37, 69, 0.08);
    --shadow-lg: 0 10px 30px rgba(11, 37, 69, 0.14);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --touch-min: 48px;
    --toast-duration: 5000ms;
}

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

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    /* overflow-x: clip NO crea un contenedor de scroll, por lo que el scroll
       vertical con rueda/táctil sigue funcionando en Chromium (con "hidden"
       en html y body el documento quedaba sin scroll). */
    overflow-x: clip;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    background: var(--slate-bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

/* Navegadores sin soporte de overflow: clip (Safari < 16): se usa la
   combinación clásica html hidden + body visible, que no rompe el scroll. */
@supports not (overflow: clip) {
    html { overflow-x: hidden; }
    body { overflow-x: visible; }
}

body {
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Botones y enlaces táctiles */
button, .btn, a[role="button"] {
    min-height: var(--touch-min);
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(230, 92, 0, 0.08);
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease, border-color 0.18s ease;
}

button:active, .btn:active, a[role="button"]:active {
    transform: scale(0.98);
}

/* Foco visible accesible */
:focus-visible {
    outline: 3px solid rgba(230, 92, 0, 0.5);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ============ FONDO DE LOGIN ============ */
.login-bg {
    background:
        radial-gradient(1100px 560px at 88% -12%, rgba(230, 92, 0, 0.38), transparent 62%),
        radial-gradient(900px 520px at -12% 112%, rgba(42, 77, 127, 0.6), transparent 62%),
        linear-gradient(165deg, #0b2545 0%, #0d2c52 52%, #06203f 100%);
    position: relative;
}

.login-bg::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 30%, rgba(230, 92, 0, 0.16), transparent 45%);
    pointer-events: none;
}

/* ============ ANIMACIONES DE ENTRADA ============ */
@keyframes cardIn {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card-in { animation: cardIn 0.35s ease-out both; }
#resultModal > .modal-in { animation: modalIn 0.28s ease-out both; }

/* ============ PASOS (desktop) ============ */
.step-badge {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: var(--navy);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

/* ============ TARJETAS RESUMEN (modal) ============ */
.summary-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.summary-card i { margin-bottom: 2px; }

.summary-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.2;
}

.summary-value {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.15;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 640px) {
    .summary-card { padding: 16px 14px; }
    .summary-label { font-size: 11px; }
    .summary-value { font-size: 19px; }
}

/* ============ DROP ZONE CORPORATIVA ============ */
.drop-zone {
    background: var(--slate-bg);
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    min-height: 170px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.drop-zone:hover {
    border-color: var(--solar);
    background: var(--solar-light);
}

.drop-zone.drag-over {
    border-color: var(--solar);
    background: var(--solar-light);
    transform: scale(1.01);
}

/* ============ TARJETAS DE RESULTADOS ============ */
.result-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.result-card.border-emerald {
    border-left: 4px solid var(--success);
}

.result-card.border-sky {
    border-left: 4px solid #0ea5e9;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--navy);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
}

.section-title i {
    color: var(--solar);
}

.result-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    min-width: 0;
}

.result-item:has(.result-value.highlight) {
    background: #f0f7ff;
    border-color: #dbeafe;
}

.result-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.result-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    word-break: break-word;
}

.result-value.highlight {
    color: var(--navy);
    font-size: 16px;
    font-weight: 800;
}

/* ============ SLIDER DE CONSUMO ============ */
.range-slider {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #e2e8f0, #cbd5e1);
    outline: none;
    width: 100%;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--solar);
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(11, 37, 69, 0.25);
    cursor: pointer;
}

.range-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--solar);
    border: 3px solid #fff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(11, 37, 69, 0.25);
}

/* ============ LOADING SPINNER ============ */
.loading-spinner {
    width: 70px;
    height: 70px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--solar);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============ TOASTS ============ */
.toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    max-width: 400px;
    border-radius: 14px;
    padding: 12px 14px 14px;
    color: #fff;
    box-shadow: 0 10px 28px rgba(11, 37, 69, 0.28);
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    transition: opacity 0.28s ease, transform 0.28s ease;
    overflow: hidden;
    pointer-events: auto;
}

.toast-in {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-out {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
}

.toast-success { background: #059669; }
.toast-error   { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info    { background: #0369a1; }

.toast-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 9999px;
}

.toast-icon svg { width: 14px; height: 14px; }

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 13px;
    font-weight: 800;
    margin: 0 0 2px;
}

.toast-msg {
    font-size: 13px;
    line-height: 1.35;
    margin: 0;
    opacity: 0.95;
}

.toast-close {
    flex-shrink: 0;
    min-height: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.12);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}

.toast-close:hover { background: rgba(255, 255, 255, 0.25); }
.toast-close::before { content: '✕'; }

.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 0 3px 3px 0;
    animation: toastProgress var(--toast-duration) linear forwards;
}

@keyframes toastProgress {
    from { width: 100%; }
    to   { width: 0; }
}

@media (min-width: 640px) {
    .toast { width: 380px; }
}

/* ============ ERRORES DE FORMULARIO ============ */
.input-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12) !important;
}

/* ============ WHATSAPP BUTTON ============ */
#whatsappContactBtn {
    background: var(--success);
    transition: background 0.18s ease, transform 0.15s ease;
}

#whatsappContactBtn:hover { background: var(--success-dark); }
#whatsappContactBtn:active { transform: scale(0.97); }

/* ============ SCROLLBAR DEL MODAL ============ */
.overflow-y-auto::-webkit-scrollbar { width: 6px; }
.overflow-y-auto::-webkit-scrollbar-track { background: transparent; }
.overflow-y-auto::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ============ CUOTA MENSUAL DE DIMENSIONAMIENTOS ============ */
.quota-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #e2e8f0;
    border-radius: 9999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
}

.quota-pill i { color: #fdba74; }

.quota-pill b { color: #fff; font-weight: 800; }

.quota-pill-empty {
    background: rgba(220, 38, 38, 0.18);
    border-color: rgba(252, 165, 165, 0.35);
}

.quota-pill-empty i { color: #fca5a5; }

@media (min-width: 640px) {
    .quota-pill { font-size: 13px; padding: 7px 14px; }
}

/* ============ AJUSTES RESPONSIVE ============ */
@media (max-width: 768px) {
    .result-item { padding: 10px; }
    .result-value { font-size: 14px; }
}

/* ============ MOVIMIENTO REDUCIDO ============ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============ PANEL ADMINISTRATIVO ============ */

/* Tarjetas de estadísticas */
.admin-stat {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.admin-stat-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.admin-stat-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.2;
}

.admin-stat-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.15;
    word-break: break-word;
}

.admin-stat-sub {
    font-size: 10px;
    font-weight: 600;
    margin-top: 2px;
}

@media (min-width: 640px) {
    .admin-stat { padding: 16px 14px; }
    .admin-stat-value { font-size: 24px; }
    .admin-stat-label { font-size: 11px; }
    .admin-stat-sub { font-size: 11px; }
}

/* Campos y etiquetas de filtros */
.admin-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 5px;
}

.admin-input {
    width: 100%;
    min-height: var(--touch-min);
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-primary);
    background: #fff;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    font-family: inherit;
}

.admin-input:focus {
    border-color: var(--solar);
    box-shadow: 0 0 0 3px rgba(230, 92, 0, 0.15);
}

.admin-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 34px;
}

/* Botones de paginación */
.pager-btn {
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--navy);
    font-size: 13px;
    font-weight: 700;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.pager-btn:hover {
    border-color: var(--solar);
    color: var(--solar);
}

.pager-btn-active {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}

.pager-btn-active:hover {
    color: #fff;
}

/* Filtros en móvil: colapsados dentro de <details> */
.admin-filters { display: grid; }
details[open] .admin-filters { display: grid; }

/* ============ MAPA DEL PERÚ (dashboard) ============ */
.mapa-peru {
    width: 100%;
    height: auto;
    display: block;
}

.mapa-peru .mapa-dept {
    stroke: #ffffff;
    stroke-width: 1;
    stroke-linejoin: round;
    fill: #e2e8f0;
    transition: fill 0.15s ease, opacity 0.15s ease;
    cursor: pointer;
}

.mapa-peru .mapa-dept:hover {
    opacity: 0.85;
}

.mapa-peru .mapa-nivel-0 { fill: #e2e8f0; }
.mapa-peru .mapa-nivel-1 { fill: #fed7aa; }
.mapa-peru .mapa-nivel-2 { fill: #fb923c; }
.mapa-peru .mapa-nivel-3 { fill: #e65c00; }

.mapa-leyenda {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.mapa-leyenda-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.mapa-leyenda-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.08);
}

@media (min-width: 640px) {
    .mapa-peru { max-width: 560px; margin: 0 auto; }
}
