/* ============================================================
   MODERNIZACIÓN v5 — Diseño profesional + responsive
   ============================================================ */

/* --- Password toggle --- */
.input-pass-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-pass-wrap .form-control {
    padding-right: 46px;
}

.btn-pass-toggle {
    position: absolute;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0;
    line-height: 0;
    transition: color .15s ease, background .15s ease;
    flex-shrink: 0;
}

.btn-pass-toggle:hover {
    color: var(--color-accent);
    background: var(--color-accent-light);
}

.btn-pass-toggle:active {
    transform: scale(.9);
}

.btn-pass-toggle svg,
.btn-pass-toggle i[data-lucide] { width: 17px; height: 17px; }

/* --- Stat cards clickables --- */
.stat-card[data-estado] {
    cursor: pointer;
    user-select: none;
}
.stat-card[data-estado]:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-3px);
}
.stat-card[data-estado]:active { transform: translateY(-1px); }

/* --- Safe area iPhone X+ --- */
:root {
    --sat: env(safe-area-inset-top);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
    --sar: env(safe-area-inset-right);
}

/* Soporte iOS standalone mode */
@supports (padding-top: env(safe-area-inset-top)) {
    .topbar {
        padding-top: max(0px, env(safe-area-inset-top));
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }

    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(64px + env(safe-area-inset-bottom));
    }

    .sidebar {
        padding-top: env(safe-area-inset-top);
    }
}

/* --- Topbar mobile: mostrar logo cuando sidebar está oculto --- */
@media (max-width: 768px) {
    .topbar::before {
        content: '';
        display: inline-flex;
        width: 26px;
        height: 26px;
        background: var(--gradient-accent, var(--color-accent));
        border-radius: 7px;
        margin-right: 8px;
        flex-shrink: 0;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white' stroke='white' stroke-width='0'%3E%3Cpath d='M13.5 2c-5.621 0-10.211 4.443-10.5 10h-3l3.968 5.289 4.032-5.289h-3.017c.285-4.194 3.808-7.5 8.017-7.5 4.418 0 8 3.582 8 8s-3.582 8-8 8c-1.08 0-2.107-.218-3.044-.609l-1.422 1.97A10.02 10.02 0 0 0 13.5 22c5.523 0 10-4.477 10-10s-4.477-10-10-10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: center;
        background-size: 60%;
        box-shadow: 0 2px 8px oklch(56% 0.20 265 / .4);
        vertical-align: middle;
    }

    .topbar-title {
        font-size: 14px;
        font-weight: 700;
    }

    /* Grids inline con columnas fijas → columna en mobile */
    div[style*="grid-template-columns: 1fr 280px"],
    div[style*="grid-template-columns:1fr 280px"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns:1fr 1fr"],
    div[style*="grid-template-columns: 280px 1fr"],
    div[style*="grid-template-columns:280px 1fr"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    /* Auth box en pantallas muy pequeñas */
    .auth-box {
        padding: 28px 18px;
        border-radius: 16px;
    }

    /* Wizard en mobile */
    .wizard-box { border-radius: 0; border-left: none; border-right: none; }
    .wizard-page { padding: 0 0 80px; align-items: flex-start; }
    .wizard-header { padding: 20px 18px 0; }
    .wizard-body { padding: 20px 18px; }
    .wizard-footer { padding: 14px 18px; }
    .wizard-step-label { font-size: 9px; }

    /* Chat en mobile: mostrar solo la lista o el chat, no ambos */
    .chat-layout { position: relative; }
    .chat-sidebar { width: 100%; border-right: none; }
    .chat-main { position: absolute; inset: 0; background: var(--color-surface); transform: translateX(100%); transition: transform .25s ease; }
    .chat-main.open { transform: translateX(0); }

    /* Perfil hero en mobile */
    .perfil-hero { padding: 20px 16px; gap: 14px; }
    .perfil-avatar { width: 58px; height: 58px; font-size: 20px; }
    .perfil-nombre { font-size: 17px; }

    /* Cards de prestador en mobile */
    .prestadores-grid { gap: 10px; }
    .prestador-card { gap: 10px; }
    .pcard-actions { flex-direction: row; }
    .pcard-actions .btn { flex: 1; font-size: 11px; padding: 6px 8px; }

    /* Tabla responsive */
    .table-wrap { margin: 0 -14px; padding: 0 14px; }

    /* Stats en mobile: 2 columnas */
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    /* Solicitud card acciones stack */
    .solicitud-card-acciones { flex-wrap: wrap; }
    .solicitud-card-acciones .btn { flex: 1; min-width: 100px; justify-content: center; }
}

@media (max-width: 390px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card .stat-value { font-size: 22px; }
    .auth-box { padding: 24px 16px; }
    .bottom-nav-item span { font-size: 9px; }
    .wizard-step-label { display: none; }
}

/* --- Variables nuevas --- */
:root {
    --gradient-accent:    linear-gradient(135deg, var(--color-accent) 0%, oklch(52% 0.22 295) 100%);
    --gradient-success:   linear-gradient(135deg, var(--color-success) 0%, oklch(52% 0.18 170) 100%);
    --gradient-warning:   linear-gradient(135deg, var(--color-warning) 0%, oklch(64% 0.18 50) 100%);
    --gradient-danger:    linear-gradient(135deg, var(--color-danger) 0%, oklch(52% 0.22 10) 100%);
    --color-surface-alt:  oklch(98.8% 0.004 265);
    --shadow-card:        0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
    --shadow-card-hover:  0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);
}

/* --- Fondo page-content con profundidad sutil --- */
.page-content {
    background:
        radial-gradient(ellipse 70% 60% at 10% 90%, oklch(56% 0.20 265 / .04) 0%, transparent 55%),
        radial-gradient(ellipse 60% 50% at 90% 10%, oklch(56% 0.20 295 / .04) 0%, transparent 55%),
        var(--color-bg);
}

/* --- Topbar más pronunciado --- */
.topbar {
    box-shadow: 0 1px 0 var(--color-border), 0 2px 12px rgba(0,0,0,.05);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* --- Cards mejoradas --- */
.card {
    box-shadow: var(--shadow-card);
    border-color: var(--color-border);
    transition: box-shadow .22s ease, transform .22s ease;
}

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

.card-header {
    background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-surface-alt) 100%);
}

/* --- Stat cards semánticas --- */
.stat-card {
    box-shadow: var(--shadow-card);
    transition: box-shadow .22s ease, transform .22s ease;
}

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

.stat-card-primary::before   { background: var(--gradient-accent); }
.stat-card-primary .stat-value { color: var(--color-accent); }

.stat-card-success::before   { background: var(--gradient-success); }
.stat-card-success .stat-value { color: var(--color-success); }

.stat-card-warning::before   { background: var(--gradient-warning); }
.stat-card-warning .stat-value { color: oklch(55% 0.17 68); }

.stat-card-danger::before    { background: var(--gradient-danger); }
.stat-card-danger .stat-value { color: var(--color-danger); }

.stat-card-primary::after  { background: var(--color-accent);  opacity: .05; }
.stat-card-success::after  { background: var(--color-success); opacity: .05; }
.stat-card-warning::after  { background: var(--color-warning); opacity: .05; }
.stat-card-danger::after   { background: var(--color-danger);  opacity: .05; }
.stat-card:hover::after    { opacity: .09; transform: scale(1.2); }

/* --- Sidebar active mejorado --- */
.sidebar-nav a.active {
    background: linear-gradient(90deg, oklch(56% 0.20 265 / .22) 0%, oklch(56% 0.20 265 / .06) 100%);
    color: oklch(80% 0.14 265);
}

.sidebar-logo-icon {
    background: var(--gradient-accent);
    box-shadow: 0 3px 12px oklch(56% 0.20 265 / .45);
}

/* --- Badge disputa (faltaba) --- */
.badge-disputa {
    background: oklch(95% 0.04 20);
    color: oklch(36% 0.18 20);
    border: 1px solid oklch(87% 0.08 20);
}

/* Badge con punto indicador */
.badge-dot::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .7;
    flex-shrink: 0;
}

/* --- Botón con loading state --- */
.btn-loading {
    pointer-events: none;
    opacity: .75;
}

.btn-loading::after {
    content: '';
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin-left: 6px;
    flex-shrink: 0;
    vertical-align: middle;
}

/* --- Modales inline (agenda) con blur y animación --- */
#modalCalificacion,
#modalCalifCliente,
#modalCancelacion {
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    background: oklch(14% 0.025 265 / .5) !important;
}

#modalCalificacion > div,
#modalCalifCliente > div,
#modalCancelacion  > div {
    border-radius: 14px !important;
    box-shadow: 0 24px 64px rgba(0,0,0,.22), 0 4px 16px rgba(0,0,0,.10) !important;
    animation: scaleIn .25s cubic-bezier(.34,1.4,.64,1) both;
    border: 1px solid var(--color-border);
}

/* --- Tabla mejorada --- */
thead th {
    background: var(--color-surface-alt);
    border-bottom: 2px solid var(--color-border);
    font-weight: 700;
}

tbody tr { transition: background .12s ease; }

tbody tr:hover {
    background: oklch(97.5% 0.01 265);
}

/* --- Empty state mejorado --- */
.empty-state {
    padding: 56px 24px;
}

.empty-state .empty-icon {
    font-size: 46px;
    margin-bottom: 16px;
    opacity: .32;
    display: block;
}

.empty-state p {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-muted);
    line-height: 1.65;
    max-width: 280px;
    margin: 0 auto;
}

/* --- Barra offline --- */
.offline-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--color-danger);
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    text-align: center;
    padding: 7px 16px;
    transform: translateY(-100%);
    transition: transform .3s ease;
    letter-spacing: .1px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.offline-bar.show { transform: translateY(0); }

/* --- Form control mejorado --- */
.form-control {
    background: var(--color-surface-alt);
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.form-control:focus {
    background: var(--color-surface);
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3.5px oklch(56% 0.20 265 / .12);
}

/* --- Turno card borde más visible --- */
.turno-estado-bar { width: 5px; }

/* --- Prestador card mejorada --- */
.prestador-card:hover {
    box-shadow: 0 8px 28px oklch(56% 0.20 265 / .14);
    transform: translateY(-3px);
}

/* --- Conteo en card-header --- */
.card-count {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    padding: 2px 9px;
    border-radius: 20px;
}

/* --- Topbar badge mejorado --- */
.topbar-badge {
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 11.5px;
    animation: pulse-badge 2s ease-in-out infinite;
}

/* --- Notificación item mejorada --- */
.notif-item.unread {
    background: oklch(97.5% 0.015 265);
    border-left-width: 3px;
}

.notif-icon {
    background: oklch(96% 0.025 265);
    border: 1.5px solid oklch(90% 0.012 265);
}

/* --- Scrollbar más elegante --- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb {
    background: oklch(82% 0.010 265);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: oklch(65% 0.015 265); }

/* --- Auth page mejorada --- */
.auth-page {
    background:
        radial-gradient(ellipse 80% 60% at 15% 25%, oklch(56% 0.20 265 / .3) 0%, transparent 65%),
        radial-gradient(ellipse 60% 50% at 85% 75%, oklch(56% 0.20 300 / .22) 0%, transparent 60%),
        oklch(11% 0.022 265);
}

.auth-box {
    border: 1px solid oklch(92% 0.008 265);
    box-shadow: 0 32px 72px rgba(0,0,0,.32), 0 4px 16px rgba(0,0,0,.14);
}

/* --- Turno card animate --- */
.turno-card { animation: fadeInUp .24s ease both; }

/* --- Solicitud card hover --- */
.solicitud-card:hover { background: var(--color-surface-alt); }

/* ============================================================
   DARK MODE — Component overrides for hardcoded colors
   ============================================================ */
html[data-theme="dark"] {
    --color-surface-alt:  oklch(16% 0.016 265);
    --shadow-card:        0 1px 3px rgba(0,0,0,.35), 0 4px 12px rgba(0,0,0,.25);
    --shadow-card-hover:  0 4px 16px rgba(0,0,0,.48), 0 1px 4px rgba(0,0,0,.30);
    color-scheme: dark;
}

/* Overrides directos para asegurar que el fondo cambie */
html[data-theme="dark"] body,
html[data-theme="dark"] .main-area {
    background-color: oklch(13% 0.015 265);
    color: oklch(94% 0.010 265);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .stat-card {
    background-color: oklch(18% 0.018 265);
    border-color: oklch(26% 0.018 265);
    color: oklch(94% 0.010 265);
}

html[data-theme="dark"] .sidebar {
    background-color: oklch(10% 0.018 265);
}

html[data-theme="dark"] .form-control {
    background-color: oklch(20% 0.018 265);
    border-color: oklch(28% 0.018 265);
    color: oklch(94% 0.010 265);
}

html[data-theme="dark"] .form-control::placeholder {
    color: oklch(50% 0.015 265);
}

html[data-theme="dark"] .topbar {
    background: oklch(16% 0.018 265 / .96);
    box-shadow: 0 1px 0 oklch(28% 0.018 265), 0 2px 12px rgba(0,0,0,.40);
}

html[data-theme="dark"] .page-content {
    background:
        radial-gradient(ellipse 70% 60% at 10% 90%, oklch(56% 0.20 265 / .07) 0%, transparent 55%),
        radial-gradient(ellipse 60% 50% at 90% 10%, oklch(56% 0.20 295 / .07) 0%, transparent 55%),
        var(--color-bg);
}

html[data-theme="dark"] .card-header {
    background: linear-gradient(180deg, var(--color-surface) 0%, oklch(16% 0.016 265) 100%);
}

html[data-theme="dark"] thead th { background: oklch(16% 0.016 265); }
html[data-theme="dark"] tbody tr:hover { background: oklch(21% 0.016 265); }

html[data-theme="dark"] .notif-item.unread { background: oklch(20% 0.022 265); }
html[data-theme="dark"] .notif-icon {
    background: oklch(23% 0.025 265);
    border-color: oklch(30% 0.018 265);
}

html[data-theme="dark"] .auth-page {
    background:
        radial-gradient(ellipse 80% 60% at 15% 25%, oklch(56% 0.20 265 / .18) 0%, transparent 65%),
        radial-gradient(ellipse 60% 50% at 85% 75%, oklch(56% 0.20 300 / .13) 0%, transparent 60%),
        oklch(8% 0.018 265);
}

html[data-theme="dark"] .auth-box {
    border-color: oklch(28% 0.015 265);
    background: oklch(15% 0.016 265);
    box-shadow: 0 32px 72px rgba(0,0,0,.65), 0 4px 16px rgba(0,0,0,.35);
}

html[data-theme="dark"] .solicitud-card:hover { background: oklch(21% 0.016 265); }

html[data-theme="dark"] .chat-main { background: var(--color-surface); }

html[data-theme="dark"] #modalCalificacion,
html[data-theme="dark"] #modalCalifCliente,
html[data-theme="dark"] #modalCancelacion {
    background: oklch(8% 0.018 265 / .68) !important;
}

/* ============================================================
   THEME TOGGLE BUTTON
   ============================================================ */
.btn-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    font-size: 16px;
    transition: background .2s ease, border-color .2s ease, transform .15s ease;
    flex-shrink: 0;
    line-height: 1;
}

.btn-theme-toggle:hover {
    background: var(--color-bg);
    border-color: var(--color-border-strong);
    transform: rotate(20deg) scale(1.08);
}

.btn-theme-toggle--float {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9990;
    box-shadow: var(--shadow-md);
}

/* ============================================================
   TOPBAR USER BUTTON (mobile — logout & perfil)
   ============================================================ */
.topbar-user-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    border: 2px solid oklch(100% 0 0 / .22);
    cursor: pointer;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 2px 8px oklch(56% 0.20 265 / .35);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.topbar-user-btn:hover {
    transform: scale(1.07);
    box-shadow: 0 3px 12px oklch(56% 0.20 265 / .42);
    border-color: oklch(100% 0 0 / .45);
}

.topbar-user-popup {
    position: fixed;
    top: calc(var(--header-height) + env(safe-area-inset-top) + 6px);
    right: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-lg);
    z-index: 9100;
    min-width: 196px;
    display: none;
    flex-direction: column;
    gap: 4px;
    animation: scaleIn .18s ease;
    transform-origin: top right;
}

.topbar-user-popup.show { display: flex; }

.topbar-user-popup-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user-popup-role {
    font-size: 11.5px;
    color: var(--color-text-muted);
    text-transform: capitalize;
    margin-bottom: 10px;
}

.topbar-user-popup hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2px 0 10px;
}

/* ============================================================
   CHAT BACK BUTTON (mobile only)
   ============================================================ */
.chat-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    flex-shrink: 0;
    margin-left: -6px;
    margin-right: 2px;
    transition: background .15s, color .15s;
}

.chat-back-btn:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

/* ============================================================
   RESPONSIVE — Mejoras completas mobile
   ============================================================ */
@media (max-width: 768px) {

    /* --- Botón usuario en topbar: visible en mobile --- */
    .topbar-user-btn { display: flex; }

    /* --- Botón volver en chat --- */
    .chat-back-btn { display: flex; }

    /* --- Chat: panel deslizante correcto --- */
    .chat-layout {
        position: relative !important;
        flex-direction: row !important;
        overflow: hidden;
        height: 100%;
    }

    .chat-sidebar {
        min-width: 100%;
        flex-shrink: 0;
        height: 100%;
        border-right: none;
    }

    .chat-main {
        position: absolute !important;
        inset: 0;
        transform: translateX(105%) !important;
        transition: transform .28s cubic-bezier(.4,0,.2,1) !important;
        z-index: 10;
        background: var(--color-bg) !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .chat-main.open { transform: translateX(0) !important; }

    /* --- Chat input más cómodo en mobile --- */
    .chat-input-bar {
        padding: 10px 12px;
        gap: 8px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    /* --- Modal de acuerdo: bottom sheet en mobile --- */
    #modalAcuerdo {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    #modalAcuerdo > div {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 18px 18px 0 0 !important;
        max-height: 92vh;
        overflow-y: auto;
    }

    /* --- Touch targets: mínimo 44px --- */
    .btn {
        min-height: 44px;
        padding: 10px 18px;
    }

    .btn-sm {
        min-height: 38px;
        padding: 8px 14px;
        font-size: 12.5px;
    }

    .btn-xs {
        min-height: 32px;
        padding: 5px 10px;
    }

    /* --- Card header: wrap en pantallas pequeñas --- */
    .card-header {
        flex-wrap: wrap;
        row-gap: 10px;
        align-items: flex-start;
    }

    .card-header h2 {
        flex: 1 1 100%;
    }

    /* Inputs dentro del card-header: expanden al ancho disponible */
    .card-header input[type="text"],
    .card-header input[type="search"],
    .card-header .form-control {
        flex: 1 !important;
        width: auto !important;
        min-width: 0;
    }

    /* Grupo de controles en card-header → full width */
    .card-header > div {
        width: 100%;
        flex-wrap: wrap;
        display: flex;
        gap: 8px;
    }

    /* --- Table: touch scroll --- */
    .table-wrap {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        border-radius: 0 0 var(--radius) var(--radius);
    }

    /* Celdas de acciones: botones no se cortan */
    tbody td:last-child {
        white-space: nowrap;
    }

    /* --- Form actions: columna en mobile --- */
    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* --- Acciones de turno y solicitud: siempre flex-wrap --- */
    .turno-acciones {
        flex-wrap: wrap;
    }

    .turno-acciones .btn {
        flex: 1;
        min-width: 110px;
    }

    /* --- Topbar más compacto con el user button --- */
    .topbar { padding: 0 12px; gap: 8px; }

    /* Assegurarse que el topbar-title no ocupe todo el espacio */
    .topbar-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* --- Bottom nav más touch-friendly --- */
    .bottom-nav-item { padding: 8px 2px; }

    /* --- Logout sidebar-footer: oculto porque hay btn en topbar --- */
    .sidebar-footer .btn-logout { display: none; }
}

@media (max-width: 480px) {
    /* Stats: asegurarse 2 columnas */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

    /* Valores de stat más chicos */
    .stat-card .stat-value { font-size: 24px; }
    .stat-card { padding: 14px 14px; }

    /* Card header: botones en fila completa */
    .card-header .btn {
        flex: 1;
        justify-content: center;
    }

    /* Inputs de auth */
    .auth-box { padding: 24px 16px; }
}

/* ============================================================
   DARK MODE — bottom nav ajuste de contraste
   ============================================================ */
html[data-theme="dark"] .bottom-nav {
    background: oklch(10% 0.018 265 / .97);
    border-top-color: rgba(255,255,255,.05);
}

html[data-theme="dark"] .topbar-user-popup {
    box-shadow: 0 8px 32px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.30);
}

/* ============================================================
   SIDEBAR FOOTER — tarjeta de usuario pulida
   ============================================================ */
.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: oklch(100% 0 0 / .06);
    margin-bottom: 8px;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 2px 8px oklch(56% 0.20 265 / .35);
}

.sidebar-user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-sidebar-text, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: oklch(100% 0 0 / .50);
    margin-top: 1px;
}

.btn-logout-sidebar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: none;
    border: 1px solid oklch(100% 0 0 / .12);
    color: oklch(100% 0 0 / .65);
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.btn-logout-sidebar:hover {
    background: oklch(54% 0.22 25 / .15);
    border-color: oklch(54% 0.22 25 / .40);
    color: oklch(80% 0.14 25);
}

.btn-logout-sidebar svg,
.btn-logout-sidebar i[data-lucide] { width: 15px; height: 15px; flex-shrink: 0; }

/* ============================================================
   BRAND BOOK — SoluciON Identity Applied
   ============================================================ */

/* --- Gradient accent variables (brand exact values) --- */
:root {
    --brand-indigo:   var(--ql-primario);
    --brand-indigo-l: var(--ql-primario-claro);
    --brand-indigo-d: var(--ql-primario-hover);
    --brand-green:    #10b981;
    --gradient-brand: linear-gradient(135deg, var(--ql-primario-claro) 0%, var(--ql-primario-hover) 100%);
}

/* --- Primary button: gradient fill (brand signature) --- */
.btn-primary {
    background: var(--gradient-brand);
    border-color: transparent;
    box-shadow: 0 2px 10px rgb(var(--ql-primario-rgb) / .35);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--ql-primario) 0%, #2e27a0 100%);
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgb(var(--ql-primario-rgb) / .45);
}

/* --- Sidebar logo icon: SVG display --- */
.sidebar-logo-icon {
    background: var(--gradient-brand);
    box-shadow: 0 3px 14px rgb(var(--ql-primario-rgb) / .45);
    font-size: 0;
}

.sidebar-logo-icon svg { display: block; }

/* --- Wordmark: Conecta/PRO split (brand typography treatment) --- */
.sidebar-logo h1 {
    display: flex;
    align-items: baseline;
    gap: 0;
    letter-spacing: -.3px;
}

.wm-base {
    font-size: 15px;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: -.2px;
}

.wm-pro {
    font-size: 15px;
    font-weight: 900;
    color: var(--brand-indigo-l);
    letter-spacing: -.1px;
    position: relative;
}

.wm-pro::after {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--brand-green);
    box-shadow: 0 0 6px var(--brand-green);
    position: absolute;
    bottom: 1px;
    right: -8px;
}

/* --- Auth logo badge: SVG display --- */
.auth-logo-badge {
    background: var(--gradient-brand);
    box-shadow: 0 4px 16px rgb(var(--ql-primario-rgb) / .45);
    font-size: 0;
}

.auth-logo-badge svg { display: block; }

/* --- Auth page: brand dark radial background --- */
.auth-page {
    background:
        radial-gradient(ellipse 70% 60% at 15% 15%, rgb(var(--ql-primario-rgb) / .22) 0%, transparent 65%),
        radial-gradient(ellipse 55% 50% at 85% 85%, rgba(16,185,129,.12) 0%, transparent 60%),
        #080b14;
}

/* --- Auth box: dark brand aesthetic --- */
.auth-box {
    background: rgba(255,255,255,.97);
    border-color: rgba(255,255,255,.12);
    box-shadow: 0 24px 64px rgba(0,0,0,.45), 0 4px 16px rgba(0,0,0,.2);
}

/* --- Auth page logo area --- */
.auth-header h1 {
    letter-spacing: -.5px;
    font-weight: 800;
}

.auth-header .wm-base {
    color: var(--color-text);
    font-weight: 700;
}

.auth-header .wm-pro {
    color: var(--brand-indigo);
    font-weight: 900;
}

/* --- Sidebar active nav: brand gradient strip --- */
.sidebar-nav a.active {
    background: linear-gradient(90deg, rgb(var(--ql-primario-rgb) / .22) 0%, rgb(var(--ql-primario-rgb) / .06) 100%);
    color: #a5b4fc;
}

.sidebar-nav a.active::before {
    background: var(--gradient-brand);
}

/* --- Stat card top border: use gradient --- */
.stat-card:nth-child(4n+1)::before { background: var(--gradient-brand); }

/* --- Chat bubble own: gradient --- */
.chat-bubble.own {
    background: linear-gradient(135deg, var(--ql-primario) 0%, #4338ca 100%);
    box-shadow: 0 2px 10px rgb(var(--ql-primario-rgb) / .3);
}

/* --- Acuerdo card header: gradient --- */
.acuerdo-card-header {
    background: linear-gradient(135deg, var(--ql-primario) 0%, #4338ca 100%);
}

/* --- Dark mode: adjust brand elements --- */
html[data-theme="dark"] .auth-page {
    background:
        radial-gradient(ellipse 70% 60% at 15% 15%, rgb(var(--ql-primario-rgb) / .18) 0%, transparent 65%),
        radial-gradient(ellipse 55% 50% at 85% 85%, rgba(16,185,129,.09) 0%, transparent 60%),
        #05070e;
}

html[data-theme="dark"] .auth-box {
    background: oklch(15% 0.016 265);
    border-color: oklch(28% 0.015 265);
}

html[data-theme="dark"] .wm-base { color: #c7d2fe; }

/* --- Spinner: brand gradient --- */
.spinner { border-top-color: var(--brand-indigo); }

/* --- Focus ring: brand color --- */
:focus-visible { outline-color: var(--brand-indigo); }
