/* ============================================================
   DIESEL MANAGEMENT SYSTEM — CORPORATE THEME
   Color Palette:
     Navy:   #1B2A47  (header, table head, accents)
     Blue:   #1565C0  (primary actions, links)
     Teal:   #00796B  (fuel/success metrics)
     Amber:  #E65100  (amount/financial metrics)
     Slate:  #546E7A  (secondary text)
     BG:     #F0F3F7  (page background)
     Surface:#FFFFFF  (cards, table)
     Border: #D8E0EA  (dividers)
   ============================================================ */

:root {
    --navy:          #1B2A47;
    --navy-dark:     #0D1B36;
    --navy-light:    #253759;
    --primary:       #1565C0;
    --primary-hover: #0D47A1;
    --primary-light: #E3F0FF;
    --teal:          #00796B;
    --teal-light:    #E0F2F1;
    --amber:         #E65100;
    --amber-light:   #FFF3E0;
    --red:           #C62828;
    --red-light:     #FFEBEE;
    --indigo:        #4527A0;
    --indigo-light:  #EDE7F6;
    --text-primary:  #1A2332;
    --text-secondary:#546E7A;
    --text-muted:    #78909C;
    --border:        #D8E0EA;
    --border-light:  #EEF2F7;
    --bg-page:       #F0F3F7;
    --bg-surface:    #FFFFFF;
    --bg-row-hover:  #F5F8FC;
    --shadow-sm:     0 1px 4px rgba(0,0,0,0.08);
    --shadow-md:     0 4px 16px rgba(0,0,0,0.10);
    --shadow-lg:     0 8px 32px rgba(0,0,0,0.12);
    --radius-sm:     4px;
    --radius-md:     8px;
    --radius-lg:     12px;

    /* Legacy aliases so inline HTML classes still resolve */
    --primary-color:   var(--navy);
    --secondary-color: var(--primary);
    --success-color:   var(--teal);
    --danger-color:    var(--red);
    --warning-color:   var(--amber);
    --info-color:      #0277BD;
}

/* ── Fluid root scaling ───────────────────────────────────── */
/* Everything that uses rem units scales proportionally.
   Minimum 12.5px so text never becomes illegible on small screens. */
html {
    font-size: clamp(12.5px, 1vw, 16px);
}

/* ── Base ─────────────────────────────────────────────────── */
body {
    background: var(--bg-page);
    min-height: 100vh;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ── Main wrapper ─────────────────────────────────────────── */
.main-container {
    background: var(--bg-page);
    margin: 0 auto;
    max-width: 100%;
    width: calc(100% - 32px);
    margin: 16px auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

/* ── Header / Topbar ──────────────────────────────────────── */
.header {
    background: var(--navy);
    color: #FFFFFF;
    padding: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: relative;
    border-bottom: 3px solid var(--primary);
}

/* User info / nav strip */
.user-info-panel {
    padding: 0.6rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: var(--navy-dark);
}

.user-info-panel .user-details h6 {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Brand bar */
.header > h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 1.1rem 1.5rem 0.25rem;
    margin: 0;
}

.header > p {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.6);
    padding: 0 1.5rem 1rem;
    margin: 0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.header .connection-status {
    position: absolute;
    top: 0.6rem;
    right: 1.5rem;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    background: #1B5E20 !important;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Dropdown buttons in header */
.header .btn-outline-light {
    border-color: rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.85);
    font-size: 0.8rem;
    padding: 0.3rem 0.9rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}
.header .btn-outline-light:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.45);
    color: #fff;
}

/* ── Access notice ────────────────────────────────────────── */
.access-notice {
    padding: 0.75rem 1.25rem 0;
    background: var(--bg-page);
}
.access-notice .alert-info {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-hover);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    padding: 0.65rem 1rem;
}

/* ── KPI Summary Cards ────────────────────────────────────── */
.dashboard-summary {
    background: var(--bg-page);
    padding: 1.25rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.stats-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1.25rem 1rem 1rem;
    margin: 0.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
}

.stats-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Colored left-border per card type */
.stats-card:nth-child(1) { border-left-color: var(--primary); }
.stats-card:nth-child(2) { border-left-color: var(--teal); }
.stats-card:nth-child(3) { border-left-color: var(--amber); }
.stats-card:nth-child(4) { border-left-color: var(--indigo); }

.stats-icon {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    opacity: 0.85;
}

.stats-number {
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.stats-card .text-muted {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted) !important;
    font-weight: 500;
}

/* Override Bootstrap color utilities inside stats cards */
.stats-card .text-primary  { color: var(--primary) !important; }
.stats-card .text-success  { color: var(--teal)    !important; }
.stats-card .text-warning  { color: var(--amber)   !important; }
.stats-card .text-info     { color: var(--indigo)  !important; }

/* Quick Summary panel */
.quick-summary-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1.25rem 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    height: 100%;
}

.quick-summary-card h6 {
    color: var(--navy);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 1rem;
}

.quick-summary-card .h5 {
    font-weight: 700;
    font-size: 1.1rem;
}

.quick-summary-card h6.text-muted {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
    color: var(--text-muted) !important;
}

/* ── Navigation Tabs ──────────────────────────────────────── */
.nav-tabs {
    background: var(--bg-surface);
    border-bottom: 2px solid var(--border);
    padding: 0 1.25rem;
    gap: 0;
}

.nav-tabs .nav-link {
    font-size: 0.83rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    padding: 0.85rem 1.5rem;
    transition: color 0.15s, border-color 0.15s;
}

.nav-tabs .nav-link:hover {
    color: var(--primary);
    border-bottom-color: var(--border);
    background: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
    font-weight: 700;
}

/* ── Filters Section ──────────────────────────────────────── */
.filters-section {
    background: var(--bg-surface);
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

/* Search box */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 2.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-page);
    font-size: 0.85rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
    background: var(--bg-surface);
}

.search-box i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Filter selects */
.filter-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-page);
    font-size: 0.85rem;
    transition: border-color 0.15s;
}

.filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-success {
    background: var(--teal);
    border-color: var(--teal);
}
.btn-success:hover {
    background: #004D40;
    border-color: #004D40;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-warning {
    background: var(--amber);
    border-color: var(--amber);
    color: #fff;
}
.btn-warning:hover {
    background: #BF360C;
    border-color: #BF360C;
    color: #fff;
}

.btn-info {
    background: #0277BD;
    border-color: #0277BD;
    color: #fff;
}
.btn-info:hover {
    background: #01579B;
    border-color: #01579B;
    color: #fff;
}

.btn-danger {
    background: var(--red);
    border-color: var(--red);
}
.btn-danger:hover {
    background: #B71C1C;
    border-color: #B71C1C;
}

.btn-secondary {
    background: #546E7A;
    border-color: #546E7A;
    color: #fff;
}
.btn-secondary:hover {
    background: #37474F;
    border-color: #37474F;
}

.btn-modern {
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.btn-modern:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ── Table ────────────────────────────────────────────────── */
.table-container {
    background: var(--bg-surface);
    border-radius: 0;
    overflow: hidden;
    margin: 0;
    border-top: 1px solid var(--border-light);
}

.table {
    font-size: 0.83rem;
    margin-bottom: 0;
    /* Reset Bootstrap 5 table CSS variables so our overrides win cleanly */
    --bs-table-bg: transparent;
    --bs-table-striped-bg: transparent;
    --bs-table-hover-bg: var(--bg-row-hover);
}

/* Double selector + !important beats Bootstrap's --bs-table-bg variable */
.table > thead > tr > th,
.table thead th {
    background-color: #1E2D3D !important;
    background:       #1E2D3D !important;
    color: rgba(255, 255, 255, 0.88) !important;
    border: none !important;
    border-bottom: 2px solid #2E4A6A !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    padding: 0.85rem 0.75rem;
    position: relative;
    white-space: nowrap;
}

.table > thead > tr > th.sortable,
.table thead th.sortable {
    cursor: pointer;
}

.table > thead > tr > th.sortable:hover,
.table thead th.sortable:hover {
    background-color: #263B50 !important;
    background:       #263B50 !important;
}

.sort-indicator {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}

.table tbody td {
    padding: 0.65rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.table tbody tr:hover {
    background-color: var(--bg-row-hover);
}

.table tbody tr.selected {
    background-color: var(--primary-light);
}

/* ── Action buttons in table ──────────────────────────────── */
.action-btn {
    padding: 0.2rem 0.45rem;
    margin: 0 0.1rem;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.75rem;
    transition: opacity 0.15s, transform 0.1s;
}

.action-btn:hover {
    opacity: 0.85;
    transform: scale(1.05);
}

/* ── Search suggestions ───────────────────────────────────── */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.suggestion-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.83rem;
    transition: background 0.1s;
}

.suggestion-item:hover {
    background-color: var(--bg-row-hover);
}

.suggestion-item:last-child { border-bottom: none; }

/* ── Searchable Dropdown ──────────────────────────────────── */
.searchable-dropdown {
    position: relative;
    width: 100%;
}

.searchable-dropdown .dropdown-input {
    width: 100%;
    padding: 0.5rem 2.2rem 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-page);
    cursor: pointer;
    font-size: 0.85rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.searchable-dropdown .dropdown-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
    outline: none;
    background: var(--bg-surface);
}

.searchable-dropdown .dropdown-arrow {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: transform 0.2s;
}

.searchable-dropdown.open .dropdown-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.searchable-dropdown .dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1001;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    margin-top: 3px;
}

.searchable-dropdown.open .dropdown-list { display: block; }

.searchable-dropdown .dropdown-item {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.83rem;
    color: var(--text-primary);
    transition: background 0.1s;
}

.searchable-dropdown .dropdown-item:hover,
.searchable-dropdown .dropdown-item.highlighted {
    background-color: var(--primary-light);
    color: var(--primary);
}

.searchable-dropdown .dropdown-item:last-child { border-bottom: none; }

.searchable-dropdown .dropdown-item.selected {
    background-color: var(--primary-light);
    font-weight: 600;
}

.searchable-dropdown .no-results {
    padding: 0.75rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-style: italic;
}

.searchable-dropdown .dropdown-search {
    padding: 0.4rem;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 1;
}

.searchable-dropdown .dropdown-search input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

.searchable-dropdown .dropdown-search input:focus {
    border-color: var(--primary);
    outline: none;
}

/* ── Modals ───────────────────────────────────────────────── */
.modal-content {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    background: var(--navy);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 3px solid var(--primary);
    padding: 1rem 1.25rem;
}

.modal-header .modal-title {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.modal-header .btn-close {
    filter: invert(1);
    opacity: 0.7;
}

/* ── Form controls ────────────────────────────────────────── */
.form-control {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

.form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.85rem;
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

/* ── Bulk actions bar ─────────────────────────────────────── */
.bulk-actions {
    background: var(--primary-light);
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: none;
}

/* ── Advanced search panel ────────────────────────────────── */
.advanced-search-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin: 0.75rem 1.25rem;
    box-shadow: var(--shadow-sm);
    display: none;
}

.advanced-search-panel h6 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--navy);
    margin-bottom: 1rem;
}

/* ── Export dropdown ──────────────────────────────────────── */
.export-menu { position: relative; display: inline-block; }

.export-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 210px;
    display: none;
    margin-top: 4px;
}

.export-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.83rem;
    transition: background 0.1s;
}

.export-item:hover { background-color: var(--bg-row-hover); }
.export-item:last-child { border-bottom: none; }
.export-separator { border-top: 1px solid var(--border); margin: 2px 0; }

/* ── Badges ───────────────────────────────────────────────── */
.badge.bg-warning.text-dark {
    background-color: var(--amber) !important;
    color: #fff !important;
    font-weight: 600 !important;
    border: none !important;
}

.badge.bg-success {
    background: var(--teal) !important;
}

/* KPI badge colors in table cells */
.badge.bg-primary { background: var(--primary) !important; }
.badge.bg-info    { background: #0277BD !important; }

/* ── Loading overlay ──────────────────────────────────────── */
.loading {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(13, 27, 54, 0.55);
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 2rem;
}

/* ── Toast notifications ──────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

/* ── Dropdown menus (Bootstrap) ───────────────────────────── */
.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 0.85rem;
    padding: 0.25rem 0;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.83rem;
    color: var(--text-primary);
    transition: background 0.1s;
}

.dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.dropdown-item.text-danger:hover {
    background: var(--red-light);
    color: var(--red);
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination .page-link {
    color: var(--primary);
    border-color: var(--border);
    font-size: 0.82rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm) !important;
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination .page-link:hover {
    background: var(--primary-light);
    color: var(--primary-hover);
}

/* ── Dropdown animation ───────────────────────────────────── */
@keyframes dropdownSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.searchable-dropdown.open .dropdown-list {
    animation: dropdownSlide 0.15s ease-out;
}

/* ── Scrollbar ────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.table-responsive::-webkit-scrollbar { height: 5px; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: #90A4AE; }

/* ── Focus / Accessibility ────────────────────────────────── */
.btn:focus,
.form-control:focus,
.form-select:focus,
.action-btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.sr-only {
    position: absolute !important;
    width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .main-container {
        margin: 8px auto;
        width: calc(100% - 16px);
        border-radius: var(--radius-md);
    }

    .header {
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }

    .header > h1 { font-size: 1.1rem; padding: 0.75rem 1rem 0.15rem; }
    .header > p  { font-size: 0.72rem; padding: 0 1rem 0.75rem; }

    .user-info-panel {
        padding: 0.5rem 1rem;
    }

    .connection-status {
        position: static !important;
        display: inline-block;
        margin-bottom: 0.75rem;
    }

    .user-info-panel .d-flex {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }

    .user-info-panel .ms-auto { margin: 0 !important; }

    .filters-section { padding: 0.75rem 1rem; }

    .filters-section .col-lg-3,
    .filters-section .col-lg-2,
    .filters-section .col-md-4,
    .filters-section .col-md-3,
    .filters-section .col-md-2 { padding: 0.2rem; }

    .filters-section .d-flex.gap-2 { gap: 0.2rem !important; }
    .filters-section .btn-sm { padding: 0.35rem 0.45rem; font-size: 0.72rem; }

    .dashboard-summary { padding: 0.75rem 0.75rem 0.5rem; }

    .stats-card { margin: 0.2rem; padding: 0.85rem 0.75rem; }
    .stats-number { font-size: 1.25rem; }
    .stats-icon { font-size: 1.5rem; margin-bottom: 0.35rem; }

    .table-responsive { font-size: 0.78rem; }
    .table thead th { padding: 0.65rem 0.5rem; font-size: 0.68rem; white-space: nowrap; }
    .table tbody td { padding: 0.45rem 0.4rem; font-size: 0.78rem; white-space: nowrap; }

    .table th:nth-child(5), .table td:nth-child(5),
    .table th:nth-child(9), .table td:nth-child(9) { display: none; }

    .modal-dialog { margin: 0.5rem; max-width: calc(100% - 1rem); }

    .advanced-search-panel { margin: 0.5rem; padding: 0.875rem; }
    .advanced-search-panel .d-flex.gap-2 { flex-direction: column; gap: 0.4rem !important; }

    .export-dropdown { right: auto; left: 0; min-width: 240px; max-width: 90vw; }
    .export-item { padding: 0.45rem 0.75rem; }

    .nav-tabs .nav-link { padding: 0.6rem 1rem; font-size: 0.75rem; }

    .d-flex.justify-content-between.align-items-center.p-3 {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem !important;
        align-items: stretch !important;
    }

    .d-flex.justify-content-between.align-items-center.p-3 > div:first-child {
        order: 2; text-align: center; width: 100%;
    }

    .d-flex.justify-content-between.align-items-center.p-3 > nav { order: 1; width: 100%; }

    .pagination { flex-wrap: wrap; gap: 2px; justify-content: center; margin-bottom: 0; }
    .pagination .page-item { margin: 1px; }
    .pagination .page-link { padding: 0.3rem 0.5rem; font-size: 0.78rem; min-width: 30px; min-height: 30px; display: flex; align-items: center; justify-content: center; }

    .d-flex.align-items-center { flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
    #recordInfo { margin-bottom: 0.4rem; width: 100%; text-align: center; font-size: 0.82rem; }

    .bulk-actions .d-flex { flex-direction: column; gap: 0.75rem; text-align: center; }
    .bulk-actions .btn-sm { margin: 0.1rem; }
}

@media (max-width: 576px) {
    .main-container { margin: 4px auto; width: calc(100% - 8px); border-radius: var(--radius-sm); }
    .header { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
    .header > h1 { font-size: 1rem; }
    .filters-section { padding: 0.6rem 0.75rem; }
    .stats-card { border-radius: var(--radius-sm); padding: 0.65rem; }
    .advanced-search-panel { margin: 0.25rem; padding: 0.75rem; }
    .modal-dialog { margin: 0.25rem; max-width: calc(100% - 0.5rem); }
    .modal-header, .modal-body, .modal-footer { padding: 0.875rem; }
    .btn-modern { padding: 0.45rem 1rem; font-size: 0.8rem; }
    .pagination .page-item:not(.active):not(:first-child):not(:last-child) { display: none; }
    .pagination .page-item:first-child,
    .pagination .page-item:last-child,
    .pagination .page-item.active { display: flex !important; }
}

@media (max-width: 768px) and (orientation: landscape) {
    .user-info-panel .d-flex { flex-direction: row; text-align: left; }
    .stats-card { padding: 0.65rem; }
    .stats-number { font-size: 1.35rem; }
    .modal-dialog { max-width: 90%; }
    .pagination .page-link { min-width: 34px; min-height: 34px; }
}

/* Touch targets */
@media (pointer: coarse) {
    .btn { min-height: 42px; }
    .form-control, .form-select { min-height: 42px; }
    .action-btn { min-height: 34px; min-width: 34px; }
    .pagination .page-link { min-height: 34px; min-width: 34px; display: flex; align-items: center; justify-content: center; }
    input[type="checkbox"] { transform: scale(1.2); margin: 0.2rem; }
    .searchable-dropdown .dropdown-item { min-height: 42px; display: flex; align-items: center; }
    .export-item { min-height: 42px; display: flex; align-items: center; }
}

/* Print */
@media print {
    body { background: white; }

    .filters-section, .bulk-actions, .modal,
    .toast-container, .loading, .nav-tabs { display: none !important; }

    .main-container { box-shadow: none; margin: 0; border-radius: 0; border: none; }

    .header {
        background: var(--navy) !important;
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
        border-radius: 0;
    }

    .table thead th {
        background-color: #1E2D3D !important;
        background:       #1E2D3D !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
    }

    .pagination { display: none !important; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .btn-modern:hover { transform: none; }
    .stats-card:hover { transform: none; }
    .action-btn:hover { transform: none; }
    .searchable-dropdown.open .dropdown-list { animation: none; }
    * { transition: none !important; animation: none !important; }
}

/* Dark mode (system) */
@media (prefers-color-scheme: dark) {
    .search-suggestions,
    .searchable-dropdown .dropdown-list,
    .export-dropdown {
        background: #1E2D45;
        border-color: #2E3F5C;
        color: #E0E8F4;
    }
    .suggestion-item:hover,
    .searchable-dropdown .dropdown-item:hover,
    .export-item:hover { background-color: #253759; }
    .modal-content { background: #1B2A47; color: #E0E8F4; border-color: #2E3F5C; }
    .form-control, .form-select { background: #253759; border-color: #2E3F5C; color: #E0E8F4; }
    .table { background: #1B2A47; color: #E0E8F4; }
    .table tbody tr:hover { background-color: #253759; }
}

/* ── Desktop compact breakpoints ─────────────────────────── */
/* These complement the clamp() scaling for elements that need
   explicit shrinking of padding / spacing at lower resolutions. */

@media (max-width: 1400px) {
    .main-container { width: calc(100% - 24px); margin: 12px auto; }
    .header > h1 { font-size: 1.35rem; padding: 0.9rem 1.25rem 0.2rem; }
    .stats-card { padding: 1rem 0.875rem; }
    .stats-number { font-size: 1.45rem; }
    .stats-icon { font-size: 1.5rem; }
    .dashboard-summary, .compact-summary-panel { padding: 0.875rem 1rem; }
    .filters-section { padding: 0.75rem 1rem; }
    .nav-tabs .nav-link { padding: 0.7rem 1.25rem; }
}

@media (max-width: 1200px) {
    .main-container { width: calc(100% - 16px); margin: 8px auto; }
    .header > h1 { font-size: 1.2rem; padding: 0.75rem 1rem 0.15rem; }
    .header > p { font-size: 0.7rem; padding: 0 1rem 0.65rem; }
    .user-info-panel { padding: 0.45rem 1rem; }
    .stats-card { padding: 0.875rem 0.75rem 0.75rem; margin: 0.175rem; }
    .stats-number { font-size: 1.3rem; }
    .stats-icon { font-size: 1.35rem; margin-bottom: 0.35rem; }
    .dashboard-summary, .compact-summary-panel { padding: 0.75rem 0.875rem; }
    .filters-section { padding: 0.65rem 0.875rem; }
    .table thead th { padding: 0.7rem 0.6rem; }
    .table tbody td { padding: 0.55rem 0.6rem; }
    .nav-tabs { padding: 0 0.875rem; }
    .nav-tabs .nav-link { padding: 0.6rem 1rem; }
    .quick-summary-card { padding: 1rem 0.75rem; }
    .quick-summary-card .h5 { font-size: 1rem; }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .main-container { width: calc(100% - 12px); margin: 6px auto; }
    .header > h1 { font-size: 1.05rem; }
    .header > p { font-size: 0.68rem; }
    .user-info-panel { padding: 0.4rem 0.875rem; }
    .user-info-panel .user-details h6 { font-size: 0.78rem; }
    .stats-card { padding: 0.75rem 0.625rem 0.625rem; margin: 0.15rem; }
    .stats-number { font-size: 1.15rem; }
    .stats-icon { font-size: 1.2rem; margin-bottom: 0.25rem; }
    .stats-card .text-muted { font-size: 0.68rem; }
    .dashboard-summary, .compact-summary-panel { padding: 0.625rem 0.75rem; }
    .quick-summary-card { padding: 0.75rem 0.625rem; }
    .quick-summary-card h6 { font-size: 0.7rem; margin-bottom: 0.5rem; }
    .quick-summary-card .h5 { font-size: 0.9rem; }
    .filters-section { padding: 0.5rem 0.75rem; }
    .search-box input, .filter-select, .form-control, .form-select { font-size: 0.78rem; }
    .btn { font-size: 0.76rem; }
    .filters-section .btn-sm { padding: 0.3rem 0.5rem; }
    .table thead th { padding: 0.6rem 0.5rem; font-size: 0.67rem; }
    .table tbody td { padding: 0.45rem 0.5rem; font-size: 0.78rem; }
    .nav-tabs .nav-link { padding: 0.5rem 0.875rem; font-size: 0.74rem; }
    .advanced-search-panel { margin: 0.5rem 0.75rem; padding: 0.875rem; }
    .action-btn { padding: 0.175rem 0.4rem; font-size: 0.7rem; }
    .dropdown-menu { font-size: 0.8rem; }
    .dropdown-item { padding: 0.4rem 0.875rem; font-size: 0.78rem; }
}

/* ── Misc overrides ───────────────────────────────────────── */
/* Compact summary panel tweak */
.compact-summary-panel {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
}

/* border-end utility for the divider between KPI cols */
@media (min-width: 992px) {
    .border-end-lg { border-right: 1px solid var(--border) !important; }
}
