:root {
    --primary: #0B5E9E;
    --primary-dark: #084b7d;
    --primary-light: #1B7BBF;
    --accent: #2E8B57;
    --body-bg: #F2F5F9;
    --sidebar-w: 252px;
    --card-radius: 14px;
    --shadow: 0 1px 3px rgba(11, 94, 158, .06), 0 8px 24px rgba(11, 94, 158, .08);
}

* { -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: #26344B;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: linear-gradient(180deg, #0B5E9E 0%, #0A4A79 60%, #08385F 100%);
    color: #fff;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,.12);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand-logo {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: rgba(255,255,255,.15);
    display: grid; place-items: center;
    font-size: 22px;
}
.brand-text strong { display: block; font-size: 15px; letter-spacing: .3px; }
.brand-text small { color: rgba(255,255,255,.65); font-size: 11px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 12px 24px; }
.nav-caption {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
    color: rgba(255,255,255,.55); padding: 14px 10px 6px; display: block;
}
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 12px;
    color: rgba(255,255,255,.82);
    padding: 10px 12px; border-radius: 10px;
    font-size: 13.5px; font-weight: 500;
    text-decoration: none; margin-bottom: 2px;
    transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i { font-size: 16px; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.10); color: #fff; }
.sidebar-nav .nav-link.active {
    background: #fff; color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    font-weight: 600;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 4px; }

.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(8,35,60,.5);
    z-index: 1030;
}

/* ============ MAIN ============ */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
}

.topbar {
    background: #fff;
    padding: 14px 24px;
    display: flex; align-items: center; gap: 14px;
    border-bottom: 1px solid #E6EAF0;
    position: sticky; top: 0; z-index: 1020;
    box-shadow: 0 1px 4px rgba(11,94,158,.05);
}
.topbar-title h1 { font-size: 19px; font-weight: 700; margin: 0; color: var(--primary-dark); }
.topbar-title small { color: #7c8798; font-size: 12px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.btn-ghost { background: transparent; border: 1px solid #E0E5EC; border-radius: 10px; color: #3c4a63; font-weight: 500; }
.btn-ghost:hover { background: #F2F5F9; }

.page-content { padding: 24px; flex: 1; }

/* ============ CARDS ============ */
.card { border: 1px solid #E6EAF0; border-radius: var(--card-radius); box-shadow: var(--shadow); }
.card-header { background: #fff; border-bottom: 1px solid #EFF2F6; border-radius: var(--card-radius) var(--card-radius) 0 0 !important; font-weight: 600; }
.card-header h5 { font-weight: 600; color: var(--primary-dark); }

.stat-card { border: 0; border-radius: var(--card-radius); color: #fff; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat-card .stat-icon {
    position: absolute; right: 14px; bottom: 10px; font-size: 54px; opacity: .18;
}
.stat-card .stat-label { font-size: 12.5px; opacity: .85; font-weight: 500; }
.stat-card .stat-value { font-size: 30px; font-weight: 700; line-height: 1.2; }
.stat-blue { background: linear-gradient(135deg, #1B7BBF, #0B5E9E); }
.stat-green { background: linear-gradient(135deg, #3ba26b, #2E8B57); }
.stat-orange { background: linear-gradient(135deg, #f0993d, #E8721D); }
.stat-purple { background: linear-gradient(135deg, #8e6fd8, #5f45b0); }
.stat-teal { background: linear-gradient(135deg, #2ab3b3, #178f8f); }

/* ============ BOTONES Y FORM ============ */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

.form-control, .form-select { border-radius: 9px; border-color: #D8DFE8; padding: .52rem .75rem; font-size: .9rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 .2rem rgba(11,94,158,.12);
}
.form-label { font-weight: 600; font-size: .82rem; color: #33415b; }
.required::after { content: " *"; color: #dc3545; }

.select2-container--bootstrap-5 .select2-selection { min-height: 40px; border-color: #D8DFE8 !important; border-radius: 9px !important; }

/* ============ TABLAS ============ */
.table thead th {
    background: #F4F7FA; font-size: .78rem; text-transform: uppercase;
    letter-spacing: .5px; color: #5c6b84; border-bottom: 2px solid #E3E9F1;
    white-space: nowrap;
}
.table tbody td { font-size: .86rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #F5F9FE; }

.dataTables_wrapper .dataTables_filter input { border-radius: 8px; border: 1px solid #D8DFE8; padding: .3rem .6rem; }
.dataTables_wrapper .dataTables_length select { border-radius: 8px; border: 1px solid #D8DFE8; }

.btn-action { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; padding: 0; font-size: 13px; }
.btn-action i { font-size: 13px; }

/* ============ LOGIN ============ */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0B5E9E 0%, #0A4A79 55%, #08385F 100%);
    padding: 20px; position: relative; overflow: hidden;
}
.login-wrap::before {
    content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.14), transparent 70%); top: -120px; right: -100px;
}
.login-wrap::after {
    content: ""; position: absolute; width: 320px; height: 320px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.10), transparent 70%); bottom: -90px; left: -80px;
}
.login-card { width: 100%; max-width: 420px; position: relative; z-index: 2; }
.login-card .card { border: 0; border-radius: 18px; padding: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo {
    width: 68px; height: 68px; margin: 6px auto 6px; border-radius: 18px;
    background: linear-gradient(135deg, #1B7BBF, #0B5E9E); color: #fff;
    display: grid; place-items: center; font-size: 32px;
    box-shadow: 0 10px 24px rgba(11,94,158,.35);
}

/* ============ UTILIDADES ============ */
.pagination .page-link { border-radius: 8px; margin: 0 2px; color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

.modal-header { background: #F4F7FA; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; }

/* Scrollbar sutil */
.main-content::-webkit-scrollbar { width: 8px; }
.main-content::-webkit-scrollbar-thumb { background: #CBD3DE; border-radius: 8px; }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; }
    .page-content { padding: 16px; }
}

@media (max-width: 575.98px) {
    .topbar { padding: 12px 14px; }
    .topbar-title h1 { font-size: 16px; }
    .stat-value { font-size: 24px !important; }
}