/* ===== Variables de marca (sistema Dashboard) ============================= */
:root {
    --color-primary:    #0A0B2E;
    --color-accent:     #e30613;
    --color-accent-dk:  #c00511;
    --color-bg:         #f4f6f9;
    --color-surface:    #ffffff;
    --color-text:       #111827;
    --color-muted:      #6b7280;
    --color-border:     #e5e7eb;
    --sidebar-w:        260px;
    --sidebar-w-col:    64px;
    --header-h:         60px;
    --radius-card:      12px;

    /* compatibilidad con clases antiguas */
    --brand:            var(--color-accent);
    --brand-dark:       var(--color-accent-dk);
}

/* ===== Reset & base ======================================================= */
html, body {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 15px;
    background: var(--color-bg);
    color: var(--color-text);
    margin: 0; padding: 0;
    height: 100%;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-dk); }

/* ===== Layout principal =================================================== */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--color-primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transition: width 0.25s ease, transform 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1.2rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-logo {
    height: 38px;
    width: 38px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-title {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.3px;
    color: #fff;
    white-space: nowrap;
}

/* ===== Navegación ========================================================= */
.nav-menu {
    flex: 1;
    padding: 0.75rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.nav-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
    padding: 0.85rem 0.5rem 0.3rem;
    text-transform: uppercase;
}

.nav-group { padding: 0; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: rgba(255,255,255,0.72) !important;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.nav-link:hover {
    background: rgba(255,255,255,0.10);
    color: #fff !important;
}

.nav-link.active {
    background: var(--color-accent);
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(227,6,19,0.30);
}

.nav-icon {
    font-size: 1.05rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

/* ===== Footer del sidebar ================================================= */
.sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.user-avatar-icon {
    font-size: 1.8rem;
    color: rgba(255,255,255,0.80);
    flex-shrink: 0;
}

.user-info > div,
.user-info-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.50);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}

.btn-logout:hover {
    color: var(--color-accent);
    background: rgba(227,6,19,0.12);
}

.btn-logout-text {
    font-size: 0.82rem;
    font-weight: 500;
}

/* ===== Área principal ===================================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.top-header {
    height: var(--header-h);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 0.5rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.header-title {
    font-weight: 600;
    color: var(--color-muted);
    font-size: 0.95rem;
    letter-spacing: 0.3px;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.75rem;
}

/* ===== Page header ======================================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.page-subtitle {
    color: var(--color-muted);
    font-size: 0.875rem;
    margin: 2px 0 0;
}

/* ===== Botones ============================================================ */
.btn-primary-custom {
    background: var(--color-accent);
    border: none;
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn-primary-custom:hover  { background: var(--color-accent-dk); }
.btn-primary-custom:active { transform: scale(0.98); }
.btn-primary-custom:disabled { background: #ccc; cursor: not-allowed; }

.btn-primary {
    color: #fff;
    background-color: var(--color-accent);
    border-color: var(--color-accent-dk);
}

.btn-primary:hover {
    background-color: var(--color-accent-dk);
    border-color: var(--color-accent-dk);
}

.btn:focus, .btn:active:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.15rem rgba(227,6,19,0.25);
}

/* ===== Tablas ============================================================= */
.card-table {
    background: var(--color-surface);
    border-radius: var(--radius-card);
    box-shadow: 0 2px 8px rgba(10,11,46,0.07);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.table { margin-bottom: 0; }

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--color-border);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--color-muted);
    padding: 12px 14px;
}

.table tbody td {
    padding: 11px 14px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f4f8;
    font-size: 0.875rem;
}

.table-hover tbody tr:hover { background: #fafbff; }

.badge-user {
    background: #eef2ff;
    color: #4338ca;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.pc-badge {
    background: #f0fdf4;
    color: #166534;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.78rem;
}

/* ===== Loading ============================================================ */
.loading-spinner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 40px;
    justify-content: center;
    color: var(--color-muted);
    font-size: 0.95rem;
}

/* ===== Modales ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-box {
    background: var(--color-surface);
    border-radius: var(--radius-card);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-box.modal-sm { max-width: 420px; }
.modal-xl          { max-width: 860px; }

.modal-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    background: #f8fafc;
    border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.modal-box-header h5 {
    margin: 0;
    font-weight: 700;
    color: var(--color-text);
    font-size: 1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--color-muted);
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.modal-close:hover { background: #fee2e2; color: var(--color-accent); }

.modal-box-body { padding: 20px; }

.modal-box-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding-top: 4px;
}

.modal-header-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--color-accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* ===== Tarjetas KPI (estilo Dashboard) ==================================== */
.card-dashboard {
    background: var(--color-surface);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(10,11,46,0.07);
    border: 1px solid var(--color-border);
}

.card-kpi {
    background: var(--color-surface);
    border-radius: var(--radius-card);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 8px rgba(10,11,46,0.07);
    border-top: 4px solid var(--color-accent);
    transition: box-shadow 0.2s;
}

.card-kpi:hover { box-shadow: 0 4px 16px rgba(10,11,46,0.12); }

.kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
}

.kpi-sub {
    font-size: 0.78rem;
    color: var(--color-muted);
    margin-top: 0.3rem;
}

/* ===== Home / dash cards ================================================== */
.dashboard-welcome { padding: 4px 0; }

.welcome-card {
    background: var(--color-surface);
    border-radius: var(--radius-card);
    padding: 28px 32px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(10,11,46,0.07);
    border-left: 5px solid var(--color-accent);
}

.welcome-icon { font-size: 2rem; margin-bottom: 8px; }
.welcome-card h2 { font-weight: 700; color: var(--color-text); margin-bottom: 4px; }

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.dash-card {
    background: var(--color-surface);
    border-radius: 10px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(10,11,46,0.07);
    border: 1px solid var(--color-border);
    border-top: 3px solid var(--color-accent);
    color: var(--color-text);
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s;
}

.dash-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(10,11,46,0.12);
    color: var(--color-accent);
}

.dash-card-icon { font-size: 1.8rem; }
.dash-card-body h5 { font-weight: 700; margin: 0 0 2px; font-size: 0.95rem; }
.dash-card-body p  { margin: 0; font-size: 0.78rem; color: var(--color-muted); }

/* ===== Roles grid ========================================================= */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 6px;
}

.rol-chip {
    display: flex;
    align-items: center;
    padding: 7px 10px;
    border: 1px solid var(--color-border);
    border-radius: 7px;
    background: var(--color-surface);
    cursor: pointer;
    transition: all 0.12s;
    font-size: 0.70rem;
}

.rol-chip:hover { border-color: var(--color-accent); background: #fff5f5; }

.rol-chip--active {
    background: #fff0f0;
    border-color: var(--color-accent);
    color: var(--color-accent);
    font-weight: 600;
}

.rol-chip--active .text-muted { color: var(--color-accent) !important; opacity: 0.6; }

/* ===== Login ============================================================== */
.login-screen {
    min-height: 100vh;
    background: url('/Imagen/bg-2.jpg') center center / cover no-repeat fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    position: relative;
}

.login-screen::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 0;
}

.login-card {
    position: relative;
    z-index: 1;
    background: rgba(255,255,255,0.97);
    border-radius: 18px;
    padding: 40px 40px 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.30), 0 2px 8px rgba(0,0,0,0.10);
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--color-accent) 0%, var(--color-accent-dk) 100%);
    border-radius: 18px 18px 0 0;
}

.login-card-header { text-align: center; margin-bottom: 28px; }

.login-card-logo {
    height: 80px; width: 80px;
    object-fit: contain;
    margin-bottom: 14px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.12));
}

.login-card-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--color-primary);
    margin: 0 0 5px;
    letter-spacing: -0.3px;
}

.login-card-sub { color: var(--color-muted); font-size: 0.875rem; margin: 0; }

.login-field { margin-bottom: 18px; }

.login-label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: #4a5568;
    margin-bottom: 6px;
}

.login-ig-text {
    background: #f7fafc;
    border-right: none;
    color: var(--color-accent);
    border-color: var(--color-border);
}

.login-input {
    border-left: none;
    border-color: var(--color-border);
}

.login-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 0.2rem rgba(227,6,19,0.12);
    border-left: none;
    z-index: 1;
}

.input-group:focus-within .login-ig-text { border-color: var(--color-accent); }

.login-eye-btn {
    border: 1px solid var(--color-border);
    border-left: none;
    background: #f7fafc;
    color: var(--color-muted);
    padding: 0 13px;
    transition: color 0.15s, background 0.15s;
}

.login-eye-btn:hover { color: var(--color-accent); background: #fff5f5; border-color: var(--color-accent); }

.btn-login-submit {
    background: var(--color-accent);
    border: none;
    color: #fff;
    padding: 13px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-login-submit:hover:not(:disabled)  { background: var(--color-accent-dk); }
.btn-login-submit:active:not(:disabled) { transform: scale(0.98); }
.btn-login-submit:disabled { background: #cbd5e0; cursor: not-allowed; color: #fff; }

.login-card-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #f0f4f8;
    color: #a0aec0;
    font-size: 0.78rem;
}

/* ===== Filtros ============================================================ */
.filter-panel {
    background: var(--color-surface);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    margin-bottom: 16px;
    border-left: 4px solid var(--color-accent);
}

.filter-panel-body { padding: 14px 16px; }

.filter-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ===== Results bar ======================================================== */
.results-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 2px 10px;
}

.results-count { font-size: 0.875rem; color: #4a5568; }
.results-pages  { font-size: 0.8rem;  color: var(--color-muted); }

/* ===== Paginación ========================================================= */
.pagination-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 12px;
    border-top: 1px solid #f0f4f8;
}

/* ===== User cell ========================================================== */
.user-cell { display: flex; align-items: center; gap: 8px; }

.user-avatar-sm {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ===== Type badges ======================================================== */
.badge-interno {
    background: #e0f2fe; color: #075985;
    font-size: 0.75rem; padding: 4px 8px; border-radius: 20px;
}

.badge-externo {
    background: #fef9c3; color: #854d0e;
    font-size: 0.75rem; padding: 4px 8px; border-radius: 20px;
}

/* ===== Form sections ====================================================== */
.form-section {
    background: #fafbfc;
    border: 1px solid #e8edf2;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 14px;
}

.form-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0e8e8;
    display: flex;
    align-items: center;
}

/* ===== Tipo toggle ======================================================== */
.tipo-toggle {
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
}

.tipo-btn {
    padding: 8px 22px;
    border: none;
    background: var(--color-surface);
    color: #4a5568;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.tipo-btn:first-child { border-right: 1px solid var(--color-border); }
.tipo-btn:hover { background: #f7fafc; }

.tipo-btn--active {
    background: var(--color-accent);
    color: #fff;
    font-weight: 700;
}

.tipo-btn--active:hover { background: var(--color-accent-dk); }

/* ===== Proveedor seleccionado ============================================= */
.proveedor-selected {
    display: inline-flex;
    align-items: center;
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.875rem;
}

/* ===== Sucursales grid ==================================================== */
.sucursales-grid {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.sucursal-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: background 0.12s;
}

.sucursal-row:hover { background: #edf2f7; }

.sucursal-row--active {
    background: var(--color-surface);
    border-color: var(--color-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.btn-xs {
    padding: 2px 8px;
    font-size: 0.72rem;
    border-radius: 4px;
    line-height: 1.4;
}

/* ===== Autocomplete ======================================================= */
.autocomplete-wrap { position: relative; }

.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    list-style: none;
    margin: 0;
    padding: 4px 0;
    z-index: 500;
    max-height: 260px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 9px 14px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #f7fafc;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #fff5f5; }

.ac-main { font-size: 0.9rem; color: var(--color-text); display: flex; align-items: center; }

.ac-sub {
    font-size: 0.76rem;
    color: var(--color-muted);
    margin-top: 2px;
    padding-left: 22px;
    display: flex;
    gap: 12px;
}

.autocomplete-searching {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.875rem;
    color: var(--color-muted);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 500;
    display: flex;
    align-items: center;
}

/* ===== Utilidades ========================================================= */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid var(--color-accent); }
.validation-message { color: var(--color-accent); font-size: 0.8rem; }

/* ===== Blazor error ======================================================= */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: 8px;
}

.blazor-error-boundary::after { content: "Se produjo un error."; }

#blazor-error-ui {
    background: #ffe4e4;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: #c62828;
    font-size: 0.88rem;
}

#blazor-error-ui .dismiss { cursor: pointer; font-weight: bold; }

/* ===== Sidebar toggle button ============================================== */
.btn-sidebar-toggle {
    background: none;
    border: none;
    color: var(--color-muted);
    font-size: 1.2rem;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}

.btn-sidebar-toggle:hover {
    background: #f0f4f8;
    color: var(--color-accent);
}

/* Botón cerrar en sidebar (mobile) */
.btn-sidebar-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1.1rem;
    padding: 4px 6px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.btn-sidebar-close:hover { color: #fff; background: rgba(255,255,255,0.15); }

/* ===== Backdrop mobile ==================================================== */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1049;
}

/* ===== Desktop: sidebar colapsado (sin .sidebar-open) ==================== */
@media (min-width: 769px) {
    .app-wrapper:not(.sidebar-open) .sidebar {
        width: var(--sidebar-w-col);
    }

    .app-wrapper:not(.sidebar-open) .sidebar-title,
    .app-wrapper:not(.sidebar-open) .nav-section-title,
    .app-wrapper:not(.sidebar-open) .nav-text,
    .app-wrapper:not(.sidebar-open) .user-info-text,
    .app-wrapper:not(.sidebar-open) .btn-logout-text {
        display: none;
    }

    .app-wrapper:not(.sidebar-open) .nav-link {
        justify-content: center;
        padding: 0.6rem;
    }

    .app-wrapper:not(.sidebar-open) .nav-menu {
        padding: 0.75rem 0.4rem;
    }

    .app-wrapper:not(.sidebar-open) .nav-group {
        padding: 0;
    }

    .app-wrapper:not(.sidebar-open) .sidebar-header {
        justify-content: center;
        padding: 1rem 0.5rem;
    }

    .app-wrapper:not(.sidebar-open) .sidebar-logo {
        margin: 0;
    }

    .app-wrapper:not(.sidebar-open) .sidebar-footer {
        justify-content: center;
        padding: 0.85rem 0.4rem;
    }

    .app-wrapper:not(.sidebar-open) .user-info {
        justify-content: center;
    }

    .app-wrapper:not(.sidebar-open) .user-avatar-icon {
        font-size: 1.5rem;
    }

    .app-wrapper:not(.sidebar-open) .btn-logout {
        padding: 0.35rem;
    }
}

/* ===== Mobile: sidebar como overlay ====================================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed !important;
        top: 0; left: 0; bottom: 0;
        height: 100dvh;
        width: var(--sidebar-w) !important;
        transform: translateX(-100%);
        z-index: 1050;
    }

    .app-wrapper.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-wrapper.sidebar-open .sidebar-backdrop {
        display: block;
    }

    /* Restaurar elementos ocultos por colapso desktop */
    .app-wrapper:not(.sidebar-open) .sidebar-title,
    .app-wrapper:not(.sidebar-open) .nav-section-title,
    .app-wrapper:not(.sidebar-open) .nav-text,
    .app-wrapper:not(.sidebar-open) .user-info-text,
    .app-wrapper:not(.sidebar-open) .btn-logout-text,
    .app-wrapper.sidebar-open .sidebar-title,
    .app-wrapper.sidebar-open .nav-section-title,
    .app-wrapper.sidebar-open .nav-text,
    .app-wrapper.sidebar-open .user-info-text,
    .app-wrapper.sidebar-open .btn-logout-text {
        display: revert;
    }

    .app-wrapper:not(.sidebar-open) .nav-link,
    .app-wrapper.sidebar-open .nav-link {
        justify-content: flex-start;
        padding: 0.6rem 0.75rem;
    }

    .app-wrapper:not(.sidebar-open) .nav-menu,
    .app-wrapper.sidebar-open .nav-menu {
        padding: 0.75rem 0.65rem;
    }

    .app-wrapper:not(.sidebar-open) .nav-group,
    .app-wrapper.sidebar-open .nav-group {
        padding: 0;
    }

    .app-wrapper:not(.sidebar-open) .sidebar-header,
    .app-wrapper.sidebar-open .sidebar-header {
        justify-content: flex-start;
        padding: 1.2rem 1rem;
    }

    .app-wrapper:not(.sidebar-open) .user-info,
    .app-wrapper.sidebar-open .user-info {
        justify-content: flex-start;
    }

    .app-wrapper:not(.sidebar-open) .user-avatar-icon,
    .app-wrapper.sidebar-open .user-avatar-icon {
        font-size: 1.8rem;
    }

    .app-wrapper:not(.sidebar-open) .btn-logout,
    .app-wrapper.sidebar-open .btn-logout {
        padding: 0.35rem 0.5rem;
    }

    .app-wrapper:not(.sidebar-open) .sidebar-footer,
    .app-wrapper.sidebar-open .sidebar-footer {
        justify-content: flex-start;
    }

    /* Main content full width */
    .main-content { width: 100%; }

    /* Ajustes de padding */
    .content-area { padding: 1rem; }
    .top-header   { padding: 0 1rem; }

    /* Page header apilado */
    .page-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    /* Tablas más compactas */
    .table thead th,
    .table tbody td {
        font-size: 0.8rem;
        padding: 8px 10px;
    }

    /* Modales */
    .modal-box {
        max-height: 95dvh;
        margin: 0 4px;
    }
}

@media (max-width: 480px) {
    .content-area { padding: 0.75rem; }
    .page-title   { font-size: 1.15rem; }
    .login-card   { padding: 32px 24px 24px; }
    .kpi-value    { font-size: 1.6rem; }
    .table .col-hide-xs { display: none; }
}
