:root {
    --white: #ffffff;
    --danger: #dc3545;
    --border: #e6e9ef;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --radius: 18px;
    --primary: #1f3c88;
    --secondary: #f39c12;
    --bg: #f4f6f9;
    --text: #212529;
    --font-main: Segoe UI, Tahoma, Geneva, Verdana, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text);
}

.card-box canvas {
    max-width: 100%;
    min-height: 280px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.card-box canvas {
    width: 100% !important;
    min-height: 280px;
}

/* LOGIN */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #eaf0fb, #f7f9fc);
}

.login-wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
}

.login-brand-panel {
    background: linear-gradient(135deg, rgba(31,60,136,.95), rgba(15,28,64,.95)), url('/img/login-bg.jpg') center center / cover no-repeat;
    color: white;
    position: relative;
}

.brand-overlay {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 60px;
}

.brand-content {
    max-width: 520px;
}

    .brand-content h1 {
        font-size: 48px;
        margin-bottom: 16px;
        line-height: 1.1;
    }

    .brand-content p {
        font-size: 18px;
        line-height: 1.6;
        margin-bottom: 25px;
        opacity: 0.95;
    }

    .brand-content ul {
        padding-left: 20px;
        line-height: 2;
        font-size: 16px;
    }

.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.login-card-modern {
    width: 100%;
    max-width: 430px;
    background: var(--white);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 40px 34px;
}

.login-header {
    margin-bottom: 25px;
}

    .login-header h2 {
        margin: 0 0 10px 0;
        font-size: 30px;
        color: var(--primary);
    }

    .login-header p {
        margin: 0;
        color: #6c757d;
        line-height: 1.5;
    }

.form-group-modern {
    margin-bottom: 18px;
}

    .form-group-modern label {
        display: block;
        margin-bottom: 8px;
        font-weight: 600;
    }

.form-control-modern {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 15px;
    font-size: 15px;
    outline: none;
    transition: all .2s ease;
    background: #fbfcfe;
}

    .form-control-modern:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 4px rgba(31,60,136,.12);
        background: #fff;
    }

.btn-login-modern {
    width: 100%;
    border: none;
    background: linear-gradient(135deg, var(--primary), #274da8);
    color: #fff;
    border-radius: 14px;
    padding: 14px 18px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
}

    .btn-login-modern:hover {
        opacity: .96;
    }

.text-danger {
    color: var(--danger);
    font-size: 13px;
}

/* LAYOUT PRINCIPAL */
.main-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary), var(--primary));
    color: #fff;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.35) transparent;
}

    .sidebar::-webkit-scrollbar {
        width: 8px;
    }

    .sidebar::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.35);
        border-radius: 10px;
    }

        .sidebar::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.55);
        }

.sidebar-brand {
    padding: 8px 12px 20px 12px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    margin-bottom: 18px;
}

    .sidebar-brand h2 {
        margin: 0;
        font-size: 24px;
    }

    .sidebar-brand p {
        margin: 8px 0 0 0;
        font-size: 13px;
        opacity: .8;
    }

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

    .sidebar ul li {
        margin-bottom: 8px;
    }

        .sidebar ul li a {
            display: block;
            color: white;
            text-decoration: none;
            padding: 12px 14px;
            border-radius: 12px;
            transition: .2s ease;
            font-weight: 500;
        }

            .sidebar ul li a:hover {
                background: rgba(255,255,255,.12);
            }

.content {
    flex: 1;
    background: var(--bg);
    padding: 24px;
}

.topbar {
    background: #fff;
    padding: 16px 20px;
    border-radius: 18px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

    .page-header h2 {
        margin: 0;
        color: var(--primary);
    }

    .page-header p {
        margin: 6px 0 0 0;
        color: #6c757d;
    }

/* TARJETAS */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.card-box {
    background: #fff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: var(--shadow);
}

    .card-box h3 {
        margin-top: 0;
        margin-bottom: 10px;
        color: var(--primary);
    }

/* TABLAS */
.table-custom {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

    .table-custom th,
    .table-custom td {
        padding: 14px 16px;
        border-bottom: 1px solid #edf0f4;
        text-align: left;
        vertical-align: middle;
    }

    .table-custom th {
        background: #f7f9fc;
        color: var(--primary);
    }

/* FORMULARIOS */
.form-card {
    background: #fff;
    padding: 24px;
    border-radius: 18px;
    max-width: 800px;
    box-shadow: var(--shadow);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-group {
    margin-bottom: 16px;
}

    .form-group label {
        display: block;
        font-weight: 600;
        margin-bottom: 8px;
    }

.form-control,
select.form-control,
textarea.form-control {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 15px;
    background: #fff;
}

    .form-control:focus,
    select.form-control:focus,
    textarea.form-control:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 4px rgba(31,60,136,.12);
    }

.btn-primary {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 11px 18px;
    border-radius: 12px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary,
.btn-login-modern {
    background: var(--primary);
    color: #fff;
}

.btn-secondary {
    display: inline-block;
    background: #6c757d;
    color: #fff;
    padding: 11px 18px;
    border-radius: 12px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-warning {
    display: inline-block;
    background: var(--secondary);
    color: #fff;
    padding: 11px 18px;
    border-radius: 12px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.badge-active {
    display: inline-block;
    background: #d1f3dd;
    color: #18794e;
    padding: 6px 10px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 700;
}

.badge-inactive {
    display: inline-block;
    background: #fde2e1;
    color: #b42318;
    padding: 6px 10px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 700;
}

@media print {
    .no-print,
    .sidebar,
    .topbar {
        display: none !important;
    }

    .content {
        padding: 0;
        background: var(--bg);
        color: var(--text);
    }

    .print-area {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* RESPONSIVE */
@media (max-width: 991px) {
    .login-wrapper {
        grid-template-columns: 1fr;
    }

    .login-brand-panel {
        display: none;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .main-layout {
        flex-direction: column;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* LOGO LOGIN */
.login-logo-box {
    margin-bottom: 20px;
}

.login-logo {
    max-width: 180px;
    max-height: 120px;
    object-fit: contain;
    display: block;
}

/* MOBILE SIDEBAR */
.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1200;
}

.mobile-title {
    font-weight: 700;
    font-size: 16px;
    margin-left: 10px;
    flex: 1;
}

.menu-toggle-btn {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
}

.sidebar-overlay-show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 1098;
}

@media (max-width: 991px) {
    .mobile-topbar {
        display: flex;
    }

    .main-layout {
        display: block;
        height: auto;
        overflow: visible;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        height: 100vh;
        z-index: 1099;
        transition: left .25s ease;
        overflow-y: auto;
    }

        .sidebar.sidebar-open {
            left: 0;
        }

    .content {
        padding: 16px;
        overflow: visible;
    }

    .topbar {
        display: none;
    }
}