:root {
    --bg: #020617;
    --bg-elevated: #0b1220;
    --panel: #111827;
    --panel-soft: #0f172a;
    --panel-hover: #162033;
    --border: rgba(255, 255, 255, 0.05);
    --text: #e5ecf6;
    --muted: #94a3b8;
    --primary: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-lg: 16px;
    --content-max: 1280px;
    --transition: 0.2s ease;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 22%),
        linear-gradient(180deg, #020617 0%, #07101f 100%);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }
.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    background: rgba(10, 15, 28, 0.94);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    gap: 18px;
    backdrop-filter: blur(14px);
}
.sidebar.open { transform: translateX(0); }
.main-content { margin-left: 272px; min-width: 0; padding: 24px; }
.main-inner { max-width: var(--content-max); margin: 0 auto; }
.brand-panel, .login-brand { display: flex; align-items: center; gap: 14px; }
.brand-panel {
    padding: 8px 10px 14px;
}
.login-brand {
    justify-content: center;
    margin-bottom: 8px;
}
.brand-image {
    display: block;
    width: 100%;
    max-width: 220px;
    height: auto;
    object-fit: contain;
}
.brand-image-login {
    max-width: 340px;
}
.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #1d4ed8, #2563eb);
    color: #fff;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
    font-size: 1.2rem;
}
.brand-logo.xl { width: 56px; height: 56px; font-size: 1.4rem; }
.brand-eyebrow {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.68rem;
    font-weight: 600;
}
.brand-name { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.02em; }
.brand-stack { display: flex; flex-direction: column; gap: 2px; }
.sidebar-section-title {
    padding: 0 10px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.7rem;
    font-weight: 600;
}
.nav-pill {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    color: #c7d2e3;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}
.nav-pill i { width: 18px; text-align: center; font-size: 1rem; }
.nav-pill:hover { background: rgba(255, 255, 255, 0.03); color: #fff; }
.nav-pill.active { background: rgba(255, 255, 255, 0.04); color: #fff; }
.nav-pill.active::before {
    content: "";
    position: absolute;
    left: -16px;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 999px;
    background: var(--primary);
}
.sidebar-footer {
    margin-top: auto;
    padding: 16px 10px 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(2, 6, 23, 0.78);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.page-title {
    margin: 0;
    font-size: 1.75rem;
    line-height: 1.1;
    font-weight: 600;
    letter-spacing: -0.03em;
}
.page-subtitle, .text-white-50 { color: var(--muted) !important; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar-search { position: relative; min-width: 320px; }
.topbar-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
}
.input-pro, .form-control, .form-select, .ts-control {
    background: #0f172a !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 10px !important;
    color: var(--text) !important;
    min-height: 46px;
    box-shadow: none !important;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.topbar-search .form-control { padding-left: 40px; }
.form-control::placeholder, .form-select, .ts-control input::placeholder { color: #64748b !important; }
.input-pro:focus, .form-control:focus, .form-select:focus, .ts-wrapper.focus .ts-control {
    border-color: rgba(37, 99, 235, 0.6) !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14) !important;
    background: #111c31 !important;
}
.form-label { color: #cbd5e1; font-size: 0.92rem; font-weight: 500; margin-bottom: 8px; }
.btn, .btn-pro {
    border-radius: 10px;
    min-height: 42px;
    font-weight: 500;
    transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.btn:active, .btn-pro:active { transform: scale(0.98); }
.btn-primary, .btn-pro-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}
.btn-primary:hover, .btn-pro-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-outline-light, .btn-pro-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #dbe5f2;
}
.btn-outline-light:hover, .btn-pro-secondary:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.btn-outline-info, .btn-outline-success { background: transparent; }
.card-pro, .glass-card, .modal-glass {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(17, 24, 39, 0.96));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.content-area { display: grid; gap: 24px; }
.page-section { display: grid; gap: 16px; }
.section-title { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -0.02em; }
.section-subtitle { color: var(--muted); font-size: 0.92rem; }
.module-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.filter-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter-select { min-width: 180px; }
.kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 18px !important;
    align-items: stretch;
}
#kpiCards > *,
.kpi-item {
    min-width: 0;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    flex: unset !important;
}
.kpi-grid > [class*="col-"] { width: 100% !important; }
.kpi-card {
    width: 100%;
    position: relative;
    overflow: hidden;
    padding: 20px;
    min-height: 146px;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.kpi-card:hover { transform: scale(1.02); border-color: rgba(37, 99, 235, 0.18); }
.kpi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.kpi-eyebrow {
    color: var(--muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 600;
    line-height: 1.35;
    max-width: 12ch;
}
.kpi-value {
    margin-top: 12px;
    font-size: 2rem;
    line-height: 1;
    font-weight: 600;
    letter-spacing: -0.04em;
    white-space: nowrap;
}
.kpi-caption {
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.45;
    max-width: 28ch;
}
.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(37, 99, 235, 0.12);
    color: #7fb0ff;
    font-size: 1.15rem;
}
.chart-card, .table-shell, .summary-shell { padding: 20px; }
.chart-stage {
    position: relative;
    width: 100%;
    margin-top: 18px;
}
.chart-stage-lg { height: 320px; }
.chart-stage-md { height: 280px; }
.chart-stage canvas {
    width: 100% !important;
    height: 100% !important;
}
.table-shell { overflow: hidden; }
.table-pro, .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: transparent;
    margin-bottom: 0;
}
.table > :not(caption) > * > * {
    padding: 16px 14px;
    background: transparent;
    color: inherit;
    box-shadow: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.table thead th {
    color: #92a0b5;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.table-actions { display: flex; gap: 8px; justify-content: flex-end; }
.badge-pro, .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 8px 10px;
    font-size: 0.78rem;
    font-weight: 500;
}
.text-bg-success { background: rgba(34, 197, 94, 0.15) !important; color: #86efac !important; }
.text-bg-warning { background: rgba(245, 158, 11, 0.15) !important; color: #fcd34d !important; }
.text-bg-danger { background: rgba(239, 68, 68, 0.15) !important; color: #fca5a5 !important; }
.text-bg-info, .text-bg-primary { background: rgba(37, 99, 235, 0.15) !important; color: #93c5fd !important; }
.text-bg-secondary, .text-bg-dark { background: rgba(148, 163, 184, 0.12) !important; color: #cbd5e1 !important; }
.dataTables_wrapper .row:first-child, .dataTables_wrapper .row:last-child { padding: 14px 0; }
.dataTables_wrapper .dataTables_filter label, .dataTables_wrapper .dataTables_length label, .dataTables_wrapper .dataTables_info {
    color: var(--muted) !important;
    font-size: 0.9rem;
}
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select {
    background: #0f172a !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    color: var(--text) !important;
    border-radius: 10px !important;
    min-height: 38px;
}
.dataTables_wrapper .paginate_button .page-link, .page-link {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #dbe5f2;
    min-width: 38px;
}
.page-item.active .page-link {
    background: rgba(37, 99, 235, 0.16);
    border-color: rgba(37, 99, 235, 0.3);
    color: #bfdbfe;
}
.page-link:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
}
.user-chip__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #1d4ed8, #2563eb);
    color: #fff;
    font-weight: 600;
}
.icon-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    color: #dbe5f2;
}
.icon-button:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--danger);
}
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.summary-card { padding: 18px; }
.summary-value { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; }
.summary-label { color: var(--muted); font-size: 0.86rem; }
.timeline {
    position: relative;
    display: grid;
    gap: 16px;
    margin-top: 6px;
}
.timeline::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 8px;
    bottom: 8px;
    width: 1px;
    background: rgba(255, 255, 255, 0.08);
}
.timeline-step {
    position: relative;
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 14px;
    align-items: start;
}
.timeline-dot {
    position: relative;
    z-index: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #93c5fd;
}
.timeline-step.active .timeline-dot {
    background: rgba(37, 99, 235, 0.18);
    border-color: rgba(37, 99, 235, 0.35);
}
.timeline-title { font-weight: 600; font-size: 0.95rem; }
.timeline-date { margin-top: 4px; color: var(--muted); font-size: 0.85rem; }
.login-body {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 24%),
        linear-gradient(180deg, #020617 0%, #07101f 100%);
    color: var(--text);
}
.login-scene { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel {
    width: 100%;
    max-width: 560px;
    padding: 28px;
    background: rgba(17, 24, 39, 0.96);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.login-title {
    margin: 8px 0 8px;
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    text-align: center;
}
.login-panel p {
    text-align: center;
}
.login-panel .alert {
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
    border: 1px solid rgba(239, 68, 68, 0.18);
}
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.report-card, .alert-chip {
    padding: 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.modal-content {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 16px;
}
.modal-header, .modal-footer { border-color: rgba(255, 255, 255, 0.05); }
.btn-close { filter: invert(1) grayscale(1); }
.ts-dropdown {
    background: #0f172a !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    box-shadow: var(--shadow);
    color: var(--text);
}
.ts-dropdown .active { background: rgba(37, 99, 235, 0.16) !important; }
.ts-dropdown .option { color: var(--text); }
.loading-overlay {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(2, 6, 23, 0.62);
    backdrop-filter: blur(4px);
    z-index: 2000;
}
.loading-overlay.active { display: grid; }
.loading-card {
    width: 120px;
    height: 120px;
    display: grid;
    place-items: center;
    gap: 10px;
    background: rgba(17, 24, 39, 0.96);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    color: var(--muted);
}
.spinner-pro {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}
.mobile-toggle { display: none; }
.backdrop-mobile {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.58);
    z-index: 1035;
}
.backdrop-mobile.show { display: block; }
.swal2-popup.swal-pro {
    background: #111827;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 18px;
}
.swal2-popup.swal-pro .swal2-title { color: #f8fafc; }
.swal2-popup.swal-pro .swal2-html-container { color: #cbd5e1; }
.swal2-popup.swal-pro .swal2-input {
    background: #0f172a;
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 1199px) {
    .kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
    .summary-grid,
    .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); transition: transform var(--transition); }
    .main-content { margin-left: 0; padding: 16px; }
    .mobile-toggle { display: inline-grid; }
    .topbar-search { min-width: 100%; }
    .topbar-row { align-items: flex-start; }
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
@media (max-width: 767px) {
    .kpi-grid { grid-template-columns: 1fr !important; }
    .kpi-item,
    .summary-grid,
    .report-grid { grid-template-columns: 1fr; }
    .summary-grid { display: grid; }
    .chart-stage-lg,
    .chart-stage-md { height: 240px; }
    .module-header,
    .filter-row,
    .topbar-actions { align-items: stretch; }
    .filter-select,
    .btn,
    .btn-pro { width: 100%; }
    .table-shell { overflow-x: auto; }
    .login-panel { padding: 24px 18px; }
    .brand-image { max-width: 180px; }
    .brand-image-login { max-width: 260px; }
}
