:root {
    --sidebar-width: 260px;
    --navbar-height: 56px;
    --brand-primary: #1a237e;
    --brand-dark: #0d1442;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f4f6f9;
}

/* ===== SIDEBAR ===== */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    z-index: 1040;
    transition: transform 0.3s ease;
    overflow-y: auto;
    padding-bottom: 2rem;
}

#sidebar .nav-link {
    color: rgba(255,255,255,.65);
    padding: .55rem 1rem;
    border-radius: .375rem;
    margin: 1px .5rem;
    font-size: .875rem;
    transition: all .15s;
    display: flex;
    align-items: center;
}

#sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}

#sidebar .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,.15);
    font-weight: 500;
}

#sidebar .nav-link .bi-chevron-down {
    transition: transform .2s;
}

#sidebar [data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

#sidebar .collapse .nav-link {
    font-size: .82rem;
    padding: .4rem .5rem .4rem 1.8rem;
    color: rgba(255,255,255,.5);
}

#sidebar .collapse .nav-link:hover,
#sidebar .collapse .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,.06);
}

.sidebar-brand {
    min-height: var(--navbar-height);
}

/* ===== MAIN CONTENT ===== */
#main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding-top: var(--navbar-height);
    transition: margin .3s ease;
}

#main-content .navbar.fixed-top {
    height: var(--navbar-height);
    left: var(--sidebar-width);
}

.page-wrapper {
    padding: 1.5rem;
}

/* ===== STAT CARDS ===== */
.stat-card {
    border: none;
    border-radius: .75rem;
    transition: transform .15s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: .8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* ===== CARDS ===== */
.card {
    border: none;
    border-radius: .75rem;
}

.card-header {
    border-bottom: 1px solid #eee;
    font-weight: 600;
}

/* ===== FORM SECTION TITLES ===== */
.form-section-title {
    font-size: .95rem;
    font-weight: 600;
    color: #495057;
    margin: 1.5rem 0 1rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid #dee2e6;
}

.form-section-title:first-child {
    margin-top: 0;
}

.form-hint {
    font-size: .78rem;
    color: #6c757d;
}

/* ===== TABLE ===== */
.table > thead {
    background: #f8f9fa;
}

.table > thead th {
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #495057;
    border-bottom-width: 2px;
}

/* ===== TABLAS CON SCROLL HORIZONTAL (DataTables scrollX) =====
   Muchas tablas .data-table tienen muchas columnas y, con scrollX activo, la
   ultima columna (normalmente los botones de accion: PDF, XML, Evidencias,
   ZIP, Descargar, etc.) queda fuera de pantalla y el usuario nunca la ve sin
   hacer scroll horizontal manual dentro de la tabla. Se fija esa columna al
   borde derecho del área visible para que los botones de accion siempre
   sean visibles. El ":not(:only-child)" evita fijar la fila de detalle
   expandible (un solo <td colspan> que ocupa toda la fila). */
table.data-table > thead > tr > th:last-child,
table.data-table > tfoot > tr > th:last-child {
    position: sticky;
    right: 0;
    z-index: 3;
    background-color: #f8f9fa;
}

table.data-table > tbody > tr > td:last-child:not(:only-child) {
    position: sticky;
    right: 0;
    z-index: 2;
    background-color: #fff;
    box-shadow: -6px 0 6px -6px rgba(0, 0, 0, .3);
}

table.data-table > tbody > tr:hover > td:last-child:not(:only-child) {
    background-color: #f5f5f5;
}

/* ===== WELCOME PAGE ===== */
.welcome-page {
    background: linear-gradient(135deg, #0d1442 0%, #1a237e 50%, #0d1442 100%);
}

.welcome-page .welcome-card {
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    text-decoration: none;
    color: #fff;
    transition: all .3s;
}

.welcome-page .welcome-card:hover {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.25);
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(0,0,0,.3);
}

.welcome-page .welcome-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    font-size: 2rem;
}

.welcome-page .icon-proveedor {
    background: rgba(37,99,235,.2);
    color: #60a5fa;
}

.welcome-page .icon-admin {
    background: rgba(139,92,246,.2);
    color: #a78bfa;
}

.welcome-page .welcome-card h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: .5rem;
}

.welcome-page .welcome-card p {
    font-size: .88rem;
    color: #94a3b8;
    margin-bottom: 1rem;
}

.welcome-page .welcome-arrow {
    font-size: 1.3rem;
    transition: transform .3s;
}

.welcome-page .welcome-card:hover .welcome-arrow {
    transform: translateX(5px);
}

/* ===== LOGIN ===== */
.login-page {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-dark) 100%);
}

.login-page .login-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,.15);
}

.login-page .login-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.8rem;
}

.login-page .login-icon-proveedor {
    background: rgba(37,99,235,.1);
    color: #2563eb;
}

.login-page .login-icon-admin {
    background: rgba(139,92,246,.1);
    color: #8b5cf6;
}

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1035;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 767.98px) {
    #sidebar {
        transform: translateX(-100%);
    }

    #sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,.4);
    }

    #main-content {
        margin-left: 0;
    }

    .page-wrapper {
        padding: 1rem;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    :root {
        --sidebar-width: 220px;
    }
}
