:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1a237e;
    --sidebar-hover: #283593;
    --sidebar-active: #3949ab;
    --primary: #1a237e;
    --primary-light: #3f51b5;
    --accent: #ff6f00;
    --text-light: #f5f5f5;
    --bg-light: #f8f9fa;
    --card-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: var(--bg-light); }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.3s ease;
    overflow-y: auto;
}
.sidebar-header {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand i { font-size: 1.4rem; }
#sidebarClose { color: #fff; display: none; }
.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}
.sidebar-nav .nav-item { margin: 0; }
.sidebar-nav .nav-link {
    color: rgba(255,255,255,0.75);
    padding: 0.7rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link:hover {
    color: #fff;
    background: var(--sidebar-hover);
    border-left-color: var(--accent);
}
.sidebar-nav .nav-link.active {
    color: #fff;
    background: var(--sidebar-active);
    border-left-color: var(--accent);
    font-weight: 600;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; width: 20px; text-align: center; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}
.top-navbar { padding: 0.5rem 1rem; }
.sidebar-toggle { color: var(--primary); border: none; padding: 0.25rem; }
.content-wrapper { max-width: 1400px; }

/* Header Avatar */
.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e0e0e0;
}
.header-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
}
/* Profile page avatar */
.profile-avatar-lg {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
}
.profile-avatar-placeholder-lg {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 3rem;
    margin: 0 auto;
}

/* Cards */
.stat-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.1);
}
.stat-card .card-body { padding: 1.25rem; }
.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: #333; }
.stat-card .stat-label { font-size: 0.8rem; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }

/* KPI Cards */
.kpi-card {
    border-radius: 0.75rem;
    border: none;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}
.kpi-card .kpi-header { padding: 1rem 1.25rem; background: var(--primary); color: #fff; }
.kpi-card .kpi-value { font-size: 2rem; font-weight: 700; }
.kpi-indicator { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.kpi-green { background: #28a745; }
.kpi-yellow { background: #ffc107; }
.kpi-red { background: #dc3545; }

/* Tables */
.table-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}
.table-card .card-header {
    background: #fff;
    border-bottom: 2px solid var(--primary);
    padding: 1rem 1.25rem;
}
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: #666; font-weight: 600; white-space: nowrap; }
.table td { vertical-align: middle; font-size: 0.9rem; }

/* Notification Dropdown */
.notification-dropdown { width: 360px; max-height: 440px; padding: 0; }
.notification-dropdown .dropdown-header { padding: 0.75rem 1rem; border-bottom: 1px solid #e0e0e0; }
.notification-dropdown .dropdown-footer { border-top: 1px solid #e0e0e0; }
.notification-list { max-height: 320px; overflow-y: auto; }
.notification-item { padding: 0.75rem 1rem; border-bottom: 1px solid #f0f0f0; white-space: normal; }
.notification-item.unread { background: #f0f7ff; }
.notification-item:hover { background: #e8f0fe; }
.notification-badge { font-size: 0.6rem; }

/* Forms */
.form-card { border: none; border-radius: 0.75rem; box-shadow: var(--card-shadow); }
.form-card .card-header { background: var(--primary); color: #fff; border-radius: 0.75rem 0.75rem 0 0; padding: 1rem 1.25rem; }
.form-label { font-weight: 600; font-size: 0.85rem; color: #555; }
.form-control:focus, .form-select:focus { border-color: var(--primary-light); box-shadow: 0 0 0 0.2rem rgba(26,35,126,0.15); }

/* Badges */
.badge { font-weight: 500; font-size: 0.75rem; padding: 0.35em 0.65em; }

/* Page Header */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: #333; margin: 0; }
.breadcrumb { margin: 0; background: none; padding: 0; font-size: 0.8rem; }

/* Charts */
.chart-container { position: relative; min-height: 300px; }

/* Timeline */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: 0.5rem; top: 0; bottom: 0; width: 2px; background: #dee2e6; }
.timeline-item { position: relative; padding-bottom: 1.5rem; }
.timeline-item::before { content: ''; position: absolute; left: -1.75rem; top: 0.25rem; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; }

/* Score Display */
.score-bar { height: 8px; border-radius: 4px; background: #e9ecef; overflow: hidden; }
.score-bar .progress { height: 100%; border-radius: 4px; transition: width 0.3s; }

/* ============================================================
   RESPONSIVE DESIGN
   Breakpoints: 1200 / 992 / 768 / 576 / 375
   ============================================================ */

/* Global overflow prevention */
.main-content { max-width: 100vw; }
.main-content,
.content-wrapper,
.card,
.card-body,
.table td,
.table th { word-wrap: break-word; overflow-wrap: break-word; }
.table td a { word-break: break-all; }

/* Sidebar overlay */
.sidebar-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1035;
    display: none; opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* --- 1200px --- */
@media (max-width: 1199.98px) {
    .content-wrapper { max-width: 100%; }
}

/* --- 992px: sidebar collapses --- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); box-shadow: 4px 0 16px rgba(0,0,0,0.3); }
    #sidebarClose { display: block; }
    .main-content { margin-left: 0; }
    .chart-container { min-height: 220px; }
    .timeline-workflow .d-flex.mb-3 { flex-wrap: wrap; }
}

/* --- 768px: table-to-card + forms stack --- */
@media (max-width: 767.98px) {
    .content-wrapper { padding: 0.75rem !important; max-width: 100vw; overflow-x: hidden; }

    /* Page header */
    .page-header { margin-bottom: 1rem; }
    .page-header.d-flex,
    .page-header > .d-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    .page-header h1 { font-size: 1.2rem; }

    /* Stat / KPI */
    .stat-card .stat-value { font-size: 1.2rem; }
    .stat-card .stat-icon { width: 40px; height: 40px; font-size: 1.2rem; }
    .stat-card .card-body { padding: 0.75rem; }
    .kpi-card .kpi-value { font-size: 1.5rem; }

    /* Notification dropdown */
    .notification-dropdown {
        width: calc(100vw - 1.5rem);
        max-width: 360px;
        right: -0.5rem !important;
    }

    /* Card padding */
    .card-body { padding: 0.75rem; }
    .card-header { padding: 0.75rem; }
    .table-card .card-header { padding: 0.75rem 1rem; }

    /* Nav tabs: horizontal scroll */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-item { flex-shrink: 0; }
    .nav-tabs .nav-link { white-space: nowrap; font-size: 0.82rem; padding: 0.5rem 0.75rem; }

    /* Buttons wrap */
    .d-flex.gap-2 { flex-wrap: wrap; }

    /* Filter forms: 2 columns */
    .card-body form.row [class*="col-md-"] {
        flex: 0 0 50%; max-width: 50%;
    }

    /* Select2: force responsive width */
    .select2-container { width: 100% !important; }
    .select2-container .select2-selection { min-height: 31px; }

    /* Modals */
    .modal-dialog { margin: 0.5rem; }

    /* Timeline */
    .timeline { padding-left: 1.5rem; }
    .timeline-item::before { left: -1.25rem; width: 10px; height: 10px; }

    /* Detail info tables (contract/vendor/payment view): override fixed widths */
    .table-borderless td[style*="width"],
    .table-borderless th[style*="width"] {
        width: auto !important;
        min-width: 0 !important;
        white-space: normal;
    }
    .table-borderless td,
    .table-borderless th {
        display: block;
        width: 100% !important;
        padding: 0.15rem 0 !important;
    }
    .table-borderless th,
    .table-borderless td.text-muted.fw-semibold,
    .table-borderless td:first-child {
        font-size: 0.72rem;
        color: #888 !important;
        padding-bottom: 0 !important;
    }
    .table-borderless td:last-child,
    .table-borderless td + td {
        padding-top: 0 !important;
        padding-bottom: 0.5rem !important;
        font-size: 0.85rem;
    }

    /* Profile avatar */
    .profile-avatar-lg { width: 90px; height: 90px; }
    .profile-avatar-placeholder-lg { width: 90px; height: 90px; font-size: 2.5rem; }

    /* ========== TABLE-TO-CARD TRANSFORMATION ========== */
    /* Only remove scroll containment AFTER JS card transform has run */
    .table-responsive { overflow-x: auto; }
    .table-responsive.cards-active,
    .table-responsive:has(.table-cards-ready) { overflow-x: visible; }

    .table-cards-ready thead { display: none; }

    .table-cards-ready tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #e0e0e0;
        border-radius: 0.5rem;
        margin-bottom: 0.75rem;
        padding: 0.5rem 0;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }
    .table-cards-ready tbody tr:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .table-cards-ready td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.4rem 0.75rem !important;
        border: none !important;
        border-bottom: 1px solid #f5f5f5 !important;
        font-size: 0.85rem;
        text-align: right;
        min-height: 2rem;
        /* Override any inline width/min-width from table layout */
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
    .table-cards-ready td:last-child {
        border-bottom: none !important;
    }

    .table-cards-ready td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: #666;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        text-align: left;
        flex-shrink: 0;
        margin-right: 1rem;
    }

    .table-cards-ready td .btn-group,
    .table-cards-ready td .btn { margin-left: auto; }

    .table-cards-ready td[colspan] { display: block; text-align: center; }
    .table-cards-ready td[colspan]::before { display: none; }

    .table-cards-ready td .score-bar { width: 60px; }

    /* Workflow timeline steps */
    .timeline-workflow .d-flex.justify-content-between {
        flex-direction: column;
        gap: 0.25rem;
    }

    /* Report stat cards: 2 columns */
    .row.g-3.mb-4 > .col-md-3 { flex: 0 0 50%; max-width: 50%; }
    .row.g-3.mb-4 > .col-md-3 .fs-2 { font-size: 1.25rem !important; }
    .row.g-3.mb-4 > .col-md-3 .fs-4 { font-size: 1rem !important; }

    /* Report vendor risk: col-3 → col-6 */
    .row.text-center > .col-3 { flex: 0 0 50%; max-width: 50%; margin-bottom: 0.75rem; }
    .row.text-center > .col-3 .fs-3 { font-size: 1.25rem !important; }

    /* KPI performance summary: col-4 → col-4 is ok at 768px */
    .row.text-center > .col-4 .fs-4 { font-size: 1.1rem !important; }

    /* KPI summary cards: shrink values + prevent overflow */
    .col-md-3 .card-body .d-flex { flex-wrap: wrap; }
    .col-md-3 .card-body .d-flex > div:first-child { min-width: 0; flex: 1; overflow: hidden; }
    .col-md-3 .fs-3 { font-size: 1.35rem !important; word-break: break-word; }
    .col-md-3 .fs-1 { font-size: 1.5rem !important; flex-shrink: 0; }

    /* KPI health score */
    .text-center > .fs-1 { font-size: 2rem !important; }

    /* KPI sparkline canvas: constrain */
    .table-cards-ready td canvas { max-width: 100px; height: auto !important; }
}

/* --- 576px: mobile phones --- */
@media (max-width: 575.98px) {
    .content-wrapper { padding: 0.5rem !important; }

    /* Page header */
    .page-header h1 { font-size: 1.05rem; }
    .page-header .d-flex.gap-2,
    .page-header > .d-flex > .d-flex {
        flex-direction: column;
        width: 100%;
    }
    .page-header .btn,
    .page-header .d-flex.gap-2 > .btn,
    .page-header .d-flex.gap-2 > a.btn {
        width: 100%;
        justify-content: center;
    }

    /* Top navbar */
    .top-navbar .container-fluid { padding-left: 0.5rem; padding-right: 0.5rem; }
    .top-navbar .nav-item.dropdown.me-3 { margin-right: 0.5rem !important; }

    /* Notification dropdown full-width */
    .notification-dropdown {
        position: fixed !important;
        top: 56px !important;
        left: 0.5rem !important;
        right: 0.5rem !important;
        width: auto !important;
        max-width: none;
        transform: none !important;
        max-height: calc(100vh - 70px);
    }
    .notification-list { max-height: calc(100vh - 160px); }
    .notification-item { padding: 0.5rem 0.75rem; }

    /* Stat cards: 2 columns */
    .row.g-3 > [class*="col-xl-3"][class*="col-md-6"] {
        flex: 0 0 50%; max-width: 50%;
    }
    .stat-card .stat-value { font-size: 1rem; }
    .stat-card .stat-label { font-size: 0.68rem; }
    .stat-card .stat-icon { width: 34px; height: 34px; font-size: 0.95rem; border-radius: 0.5rem; }
    .stat-card .card-body { padding: 0.6rem; }

    /* Table cards */
    .table-cards-ready td {
        padding: 0.35rem 0.65rem !important;
        font-size: 0.82rem;
    }
    .table-cards-ready td::before { font-size: 0.7rem; }

    /* Filter forms: single column */
    .card-body form.row [class*="col-md-"] {
        flex: 0 0 100%; max-width: 100%;
    }

    /* Charts */
    .chart-container { min-height: 180px; }

    /* Smaller radii */
    .card, .table-card, .stat-card, .form-card { border-radius: 0.5rem; }

    /* Breadcrumb */
    .breadcrumb { font-size: 0.72rem; }

    /* Workflow approval buttons: full-width */
    .card.border-warning .card-body .btn {
        width: 100%; margin-bottom: 0.5rem;
    }
    .card.border-warning .card-body .btn.me-2 { margin-right: 0 !important; }

    /* Login */
    .login-wrapper { padding: 0.75rem; }
    .login-card { border-radius: 0.75rem; }
    .login-card .card-body { padding: 1.25rem; }
    .login-card .card-header { padding: 1.25rem 1.25rem 0; }

    /* Renewal stats */
    .row.g-3.mb-4 > .col-md-3 { flex: 0 0 50%; max-width: 50%; }

    /* Button groups */
    .btn-group.btn-group-sm { flex-wrap: wrap; }
    .btn-group.btn-group-sm .btn {
        border-radius: 0.25rem !important;
        margin-bottom: 0.25rem;
    }

    /* Progress bars */
    .progress { height: 8px !important; }

    /* Tab content */
    .tab-content .table-card { border-radius: 0.5rem; overflow: hidden; }

    /* Report stat cards: still 2 columns but tighter */
    .row.g-3.mb-4 > .col-md-3 .fs-2 { font-size: 1.1rem !important; }
    .row.g-3.mb-4 > .col-md-3 .fs-4 { font-size: 0.95rem !important; }

    /* Report list: 3 report cards single column */
    .row.g-4.mb-4 > .col-md-4 { flex: 0 0 100%; max-width: 100%; }

    /* KPI performance summary: col-4 → stacked */
    .row.text-center > .col-4 { flex: 0 0 33.33%; max-width: 33.33%; }
    .row.text-center > .col-4 .fs-4 { font-size: 0.95rem !important; }
    .row.text-center > .col-4 small { font-size: 0.68rem; }

    /* KPI summary cards */
    .col-md-3 .fs-3 { font-size: 1.15rem !important; }
    .col-md-3 .fs-1 { font-size: 1.25rem !important; }

    /* KPI health score */
    .text-center > .fs-1 { font-size: 1.75rem !important; }

    /* Report page header buttons: wrap to stack */
    .page-header > div { display: flex; flex-wrap: wrap; gap: 0.25rem; width: 100%; }
    .page-header > div > .btn,
    .page-header > div > a.btn { flex: 1 1 auto; text-align: center; }

    /* Select2 force full width */
    .select2-container { width: 100% !important; }

    /* Header avatar smaller */
    .header-avatar,
    .header-avatar-placeholder { width: 30px; height: 30px; font-size: 0.85rem; }

    /* Profile avatar */
    .profile-avatar-lg { width: 80px; height: 80px; }
    .profile-avatar-placeholder-lg { width: 80px; height: 80px; font-size: 2rem; }

    /* Input groups: prevent overflow */
    .input-group { flex-wrap: nowrap; }
    .input-group .form-control { min-width: 0; }

    /* All forms single column */
    .row > [class*="col-md-3"],
    .row > [class*="col-md-4"] {
        flex: 0 0 100%; max-width: 100%;
    }
}

/* --- 375px: extreme small (320px devices) --- */
@media (max-width: 374.98px) {
    .content-wrapper { padding: 0.25rem !important; }

    /* Page header */
    .page-header h1 { font-size: 0.92rem; }
    .page-header h1 i.me-2 { display: none; }

    /* Stat cards: single column horizontal */
    .row.g-3 > [class*="col-xl-3"][class*="col-md-6"] {
        flex: 0 0 100%; max-width: 100%;
    }
    .stat-card .card-body {
        padding: 0.5rem 0.75rem;
        display: flex; align-items: center; justify-content: space-between;
    }
    .stat-card .stat-value { font-size: 1.1rem; margin-bottom: 0; }
    .stat-card .stat-label { font-size: 0.68rem; }

    /* Table card rows: label above value */
    .table-cards-ready td {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        padding: 0.3rem 0.6rem !important;
        font-size: 0.8rem;
    }
    .table-cards-ready td::before {
        margin-right: 0;
        margin-bottom: 0.1rem;
        font-size: 0.65rem;
    }

    /* Notification dropdown */
    .notification-dropdown {
        left: 0.25rem !important;
        right: 0.25rem !important;
    }
    .notification-item { padding: 0.4rem 0.5rem; }
    .notification-item .fw-semibold { font-size: 0.78rem; }
    .notification-item .text-muted { font-size: 0.72rem; }

    /* Charts */
    .chart-container { min-height: 150px; }

    /* Top navbar */
    .top-navbar { padding: 0.25rem 0.5rem; }
    .header-avatar,
    .header-avatar-placeholder { width: 28px; height: 28px; font-size: 0.75rem; }

    /* Login */
    .login-wrapper { padding: 0.5rem; }
    .login-card .card-body { padding: 1rem; }
    .login-card .login-icon { font-size: 2rem; }

    /* Modals */
    .modal-dialog { margin: 0.25rem; }
    .modal-body { padding: 0.75rem; }
    .modal-header { padding: 0.75rem; }
    .modal-footer { padding: 0.5rem 0.75rem; }

    /* Forms */
    .form-control, .form-select { font-size: 0.85rem; padding: 0.3rem 0.5rem; }
    .form-label { font-size: 0.78rem; }
    .input-group-text { font-size: 0.8rem; padding: 0.3rem 0.5rem; }

    /* Badges */
    .badge { font-size: 0.62rem; padding: 0.2em 0.45em; }

    /* Sidebar narrower */
    .sidebar { width: 240px; }

    /* Profile */
    .profile-avatar-lg { width: 70px; height: 70px; }
    .profile-avatar-placeholder-lg { width: 70px; height: 70px; font-size: 1.75rem; }

    /* All remaining multi-column forced single */
    .row > [class*="col-md-"],
    .row > [class*="col-lg-"] {
        flex: 0 0 100% !important; max-width: 100% !important;
    }

    /* Detail info table labels even tighter */
    .table-borderless td,
    .table-borderless th {
        font-size: 0.78rem;
        padding: 0.1rem 0 !important;
    }

    /* Workflow timeline compact */
    .timeline-workflow .fs-4 { font-size: 1rem !important; }
    .timeline-workflow .me-3 { margin-right: 0.5rem !important; }
    .timeline-workflow strong { font-size: 0.82rem; }
    .timeline-workflow .small { font-size: 0.72rem; }

    /* Report stat cards: single column, horizontal layout */
    .row.g-3.mb-4 > .col-md-3 { flex: 0 0 100% !important; max-width: 100% !important; }
    .row.g-3.mb-4 > .col-md-3 .card-body {
        display: flex; align-items: center; justify-content: space-between;
        padding: 0.5rem 0.75rem; text-align: left !important;
    }
    .row.g-3.mb-4 > .col-md-3 .card-body .small.text-muted { order: -1; margin: 0; }
    .row.g-3.mb-4 > .col-md-3 .fs-2 { font-size: 1rem !important; margin: 0; }
    .row.g-3.mb-4 > .col-md-3 .fs-4 { font-size: 0.9rem !important; margin: 0; }

    /* Report vendor risk: single column */
    .row.text-center > .col-3 { flex: 0 0 50% !important; max-width: 50% !important; }
    .row.text-center > .col-3 .fs-3 { font-size: 1rem !important; }

    /* KPI performance summary: col-4 stays 3-col but tiny */
    .row.text-center > .col-4 { flex: 0 0 33.33% !important; max-width: 33.33% !important; }
    .row.text-center > .col-4 .fs-4 { font-size: 0.85rem !important; }
    .row.text-center > .col-4 small { font-size: 0.6rem; }

    /* KPI summary cards */
    .col-md-3 .fs-3 { font-size: 0.95rem !important; }
    .col-md-3 .fs-1 { font-size: 1.1rem !important; }

    /* KPI health score */
    .text-center > .fs-1 { font-size: 1.5rem !important; }

    /* KPI sparkline: hide on very small screens (too small to read) */
    .table-cards-ready td canvas { display: none; }
    .table-cards-ready td.kpi-trend-cell::after {
        content: "View trend on desktop";
        font-size: 0.65rem;
        color: #999;
        font-style: italic;
    }
}

/* Print */
@media print {
    .sidebar, .top-navbar, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-wrapper { padding: 0 !important; }
}

/* Loading overlay */
.loading-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
.spinner-lg { width: 3rem; height: 3rem; }

/* Login page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--primary-light) 100%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    border: none;
    border-radius: 1rem;
    box-shadow: 0 1rem 3rem rgba(0,0,0,0.2);
}
.login-card .card-header {
    background: none;
    border: none;
    text-align: center;
    padding: 2rem 2rem 0;
}
.login-card .card-body { padding: 2rem; }
.login-card .login-icon { font-size: 3rem; color: var(--primary); }
