/* ════════════════════════════════════════════════════════════
   Waveledger — Modern UI  v4
   Palette: Midnight navigation · Airy analytics · Accessible themes
   ════════════════════════════════════════════════════════════ */

/* ── CSS variables ───────────────────────────────────────── */
:root {
    --sidebar-width:   252px;
    --topbar-height:    58px;

    /* Brand (overridden by inline <style> from settings) */
    --brand:           #2563eb;
    --brand-dark:      #1d4ed8;
    --brand-light:     #eff6ff;
    --brand-muted:     rgba(37,99,235,.12);
    --brand-contrast:  #ffffff;

    /* Surface */
    --bg:              #f5f6fb;
    --surface:         #ffffff;
    --surface-2:       #f8fafc;
    --border:          #e9ecf3;
    --border-light:    #f2f4f8;

    /* Sidebar */
    --sidebar-bg:      #0d1526;
    --sidebar-text:    #8ea3bf;
    --sidebar-active:  rgba(37,99,235,.20);
    --sidebar-hover:   rgba(255,255,255,.055);

    /* Text */
    --text:            #1a2332;
    --text-muted:      #637488;
    --text-light:      #94a3b8;

    /* Status colours */
    --green:   #10b981;
    --amber:   #f59e0b;
    --red:     #ef4444;
    --purple:  #8b5cf6;
    --cyan:    #06b6d4;

    /* Radius & shadow */
    --radius:  1rem;
    --radius-sm: .5rem;
    --shadow-sm: 0 4px 18px rgba(32,37,54,.045);
    --shadow:    0 10px 28px rgba(32,37,54,.075);
    --shadow-lg: 0 18px 42px rgba(32,37,54,.12);

    --transition: .18s ease;
}

/* ── Reset & base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
    background: var(--bg);
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .875rem;
    margin: 0;
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
.text-primary { color: color-mix(in srgb, var(--brand) 48%, #0f172a) !important; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ════════════════════════════════════════════════════════════
   TOP BAR
   ════════════════════════════════════════════════════════════ */
#topNavbar {
    height: var(--topbar-height);
    background: var(--sidebar-bg) !important;
    border-bottom: 1px solid rgba(255,255,255,.06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 16px rgba(0,0,0,.25);
    padding: 0 1rem;
    z-index: 1050;
}
#topNavbar .navbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: #fff !important;
    gap: .5rem;
}
#topNavbar .navbar-brand .wl-navbar-logo {
    display: block;
    width: auto;
    height: 32px;
    max-width: min(180px, 28vw);
    object-fit: contain;
}
.wl-header-logo-preview {
    min-height: 92px;
    background: linear-gradient(135deg, #f8fafc, #eef2f7);
    border: 1px solid var(--bs-border-color, #dee2e6);
    display: flex;
    align-items: center;
    justify-content: center;
}
.wl-header-logo-preview img {
    display: block;
    max-width: 100%;
    width: auto;
    max-height: 80px;
    object-fit: contain;
}
body.dark-mode .wl-header-logo-preview { background: rgba(255,255,255,.06); }
@media (max-width: 575.98px) {
    #topNavbar .navbar-brand .wl-navbar-logo { max-width: 108px; }
}

/* Actionable System Health cards and repair guidance. */
.wl-health-card {
    color: inherit;
    text-decoration: none;
    transition: transform .16s ease, box-shadow .16s ease, border-width .16s ease;
}
.wl-health-card:hover,
.wl-health-card:focus-visible {
    color: inherit;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 .65rem 1.5rem rgba(15,23,42,.12);
    outline: 3px solid color-mix(in srgb, var(--brand) 28%, transparent);
    outline-offset: 2px;
}
.wl-health-card.is-selected {
    border-width: 2px !important;
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 15%, transparent);
}
.wl-health-card .card-body { display: flex; flex-direction: column; }
.wl-health-card-action { margin-top: auto; font-size: .78rem; font-weight: 700; }
.wl-health-guidance { scroll-margin-top: calc(var(--topbar-height) + 1rem); }
.wl-health-guidance .bg-light { overflow-wrap: anywhere; }
.wl-health-steps { padding-left: 1.25rem; }
.wl-health-steps li { margin-bottom: .6rem; padding-left: .25rem; }
body.dark-mode .wl-health-guidance .bg-light { background: rgba(255,255,255,.06) !important; color: inherit; }
#topNavbar .nav-link,
#topNavbar .btn-link { color: rgba(255,255,255,.72) !important; }
#topNavbar .nav-link:hover { color: #fff !important; }

/* Search box in topbar */
#topNavbar .form-control.search-box {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: .8rem;
    padding: .35rem .85rem;
    width: 220px;
    transition: var(--transition);
}
#topNavbar .form-control.search-box::placeholder { color: rgba(255,255,255,.38); }
#topNavbar .form-control.search-box:focus {
    background: rgba(255,255,255,.14);
    border-color: rgba(255,255,255,.28);
    box-shadow: none;
    width: 280px;
    color: #fff;
    outline: none;
}

/* Notification badge */
.notif-btn { position: relative; }
.notif-btn .badge-dot {
    position: absolute; top: 4px; right: 4px;
    width: 8px; height: 8px;
    background: var(--red); border-radius: 50%;
    border: 2px solid var(--sidebar-bg);
    display: none;
}
.notif-btn.has-unread .badge-dot { display: block; }

/* Notification previews must stay inside the dropdown even when a message
   contains a very long URL, reference number or word without spaces. */
.wl-notification-dropdown {
    width: min(360px, calc(100vw - 1rem));
    max-width: calc(100vw - 1rem);
    overflow: hidden;
}
.wl-notification-dropdown #notif-list {
    max-height: min(420px, calc(100vh - 160px));
    overflow-x: hidden;
    overflow-y: auto;
}
.wl-notification-item {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    white-space: normal !important;
}
.wl-notification-title,
.wl-notification-preview {
    max-width: 100%;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-overflow: ellipsis;
}
.wl-notification-title {
    white-space: nowrap;
    text-overflow: ellipsis;
}
.wl-notification-preview {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    font-size: .75rem;
    line-height: 1.35;
}
.wl-notification-time { font-size: .7rem; }
.wl-notification-full {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Accessible theme swatches replace the inconsistent browser color slider. */
.wl-theme-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
    gap: .75rem;
}
.wl-theme-swatch {
    position: relative;
    display: block;
    min-width: 0;
    cursor: pointer;
}
.wl-theme-swatch input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    pointer-events: none;
}
.wl-theme-swatch-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    border: 3px solid transparent;
    border-radius: .7rem;
    background: var(--swatch-color);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), 0 2px 8px rgba(15,23,42,.08);
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.wl-theme-swatch-box .fa-check { opacity: 0; transform: scale(.75); transition: inherit; }
.wl-theme-swatch-name {
    display: block;
    margin-top: .3rem;
    color: var(--text-muted);
    font-size: .7rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wl-theme-swatch:hover .wl-theme-swatch-box { transform: translateY(-2px); }
.wl-theme-swatch input:focus-visible + .wl-theme-swatch-box {
    outline: 3px solid color-mix(in srgb, var(--swatch-color) 35%, transparent);
    outline-offset: 2px;
}
.wl-theme-swatch input:checked + .wl-theme-swatch-box {
    border-color: var(--surface);
    box-shadow: 0 0 0 3px var(--swatch-color), 0 5px 14px rgba(15,23,42,.2);
}
.wl-theme-swatch input:checked + .wl-theme-swatch-box .fa-check { opacity: 1; transform: scale(1); }

/* ════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════ */
.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: var(--sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition);
    z-index: 1040;
    scrollbar-width: thin;
    scrollbar-color: #1e3a5f transparent;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-nav { padding: .75rem 0 1.5rem; flex: 1; }

/* Section title */
.nav-section-title {
    color: rgba(255,255,255,.22);
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    padding: 1.1rem 1.1rem .4rem;
}

/* Nav items */
.nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .48rem 1.1rem .48rem 1.1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    border-left: 2.5px solid transparent;
    font-size: .82rem;
    cursor: pointer;
    border-radius: 0;
    margin: 1px 0;
    position: relative;
}
.nav-item:hover {
    background: var(--sidebar-hover);
    color: #dde8f8;
    border-left-color: rgba(255,255,255,.15);
}
.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: var(--brand);
    font-weight: 600;
}
.nav-item.active i { color: var(--brand) !important; }
.nav-item i {
    width: 16px;
    text-align: center;
    font-size: .88rem;
    flex-shrink: 0;
    color: var(--sidebar-text);
    transition: color var(--transition);
}
.nav-item:hover i { color: #dde8f8; }
.nav-item .nav-arrow { transition: transform .2s; margin-left: auto; font-size: .7rem; opacity: .5; }
.nav-item[aria-expanded="true"] .nav-arrow { transform: rotate(180deg); }
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--brand);
    color: var(--brand-contrast);
    font-size: .62rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 99px;
    line-height: 1.6;
}

.nav-group { background: rgba(0,0,0,.12); }
.nav-child { padding-left: 2.75rem !important; font-size: .79rem; }
.nav-child i { font-size: .78rem !important; }

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.06);
    padding: .5rem 0;
}
.sidebar-footer .nav-item { font-size: .79rem; }

/* ════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ════════════════════════════════════════════════════════════ */
.main-content {
    margin-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    min-height: 100vh;
    transition: margin-left var(--transition);
}
.main-content.expanded { margin-left: 0; }
.content-wrapper {
    padding: 1.6rem 1.75rem;
    max-width: 1600px;
}

/* ════════════════════════════════════════════════════════════
   PAGE HEADER
   ════════════════════════════════════════════════════════════ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.4rem;
    flex-wrap: wrap;
    gap: .75rem;
}
.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -.02em;
}
.page-header p {
    margin: .15rem 0 0;
    font-size: .8rem;
    color: var(--text-muted);
}

/* Module sub-nav */
.module-sub-nav {
    display: flex;
    gap: .2rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .35rem .4rem;
}
.module-sub-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: .8rem;
    font-weight: 500;
    padding: .3rem .9rem;
    border-radius: .4rem;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}
.module-sub-nav a:hover { background: var(--bg); color: var(--text); }
.module-sub-nav a.active {
    background: var(--brand);
    color: var(--brand-contrast);
    font-weight: 600;
}

/* ════════════════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════════════════ */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .9rem 1.25rem;
    font-weight: 600;
    font-size: .87rem;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    color: var(--text);
}
.card-footer {
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius) !important;
    padding: .75rem 1.25rem;
}
.card-body { padding: 1.25rem; }

/* ════════════════════════════════════════════════════════════
   STAT CARDS
   ════════════════════════════════════════════════════════════ */
.stat-card {
    --stat-accent: #6d28d9;
    border-radius: var(--radius);
    padding: 1.25rem 5rem 1.25rem 1.3rem;
    color: var(--text);
    position: relative;
    overflow: hidden;
    min-height: 118px;
    border: 1px solid var(--border);
    background: var(--surface) !important;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before { display: none; }
.stat-card .stat-icon {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    color: var(--stat-accent);
    background: color-mix(in srgb, var(--stat-accent) 12%, var(--surface));
    opacity: 1;
    pointer-events: none;
}
.stat-card .stat-label { font-size: .78rem; color: var(--text-muted); opacity: 1; text-transform: none; letter-spacing: 0; margin-bottom: .35rem; }
.stat-card .stat-value { font-size: 1.65rem; color: var(--text); font-weight: 800; line-height: 1.1; letter-spacing: -.03em; }
.stat-card .stat-change { font-size: .73rem; margin-top: .45rem; color: var(--text-muted); opacity: 1; display: flex; align-items: center; gap: .3rem; }
.stat-card .stat-sub { font-size: .75rem; color: var(--text-muted); opacity: 1; margin-top: .3rem; }
.stat-card[style*="#16a34a"], .stat-card[style*="#15803d"], .stat-card[style*="#059669"], .stat-card[style*="#047857"] { --stat-accent: #10c7a5; }
.stat-card[style*="#dc2626"], .stat-card[style*="#b91c1c"], .stat-card[style*="#e11d48"], .stat-card[style*="#be123c"] { --stat-accent: #f43f72; }
.stat-card[style*="#d97706"], .stat-card[style*="#b45309"], .stat-card[style*="#f59e0b"] { --stat-accent: #ff7a45; }
.stat-card[style*="#2563eb"], .stat-card[style*="#1d4ed8"], .stat-card[style*="#7c3aed"], .stat-card[style*="#6d28d9"], .stat-card[style*="#5b21b6"], .stat-card[style*="#4f46e5"] { --stat-accent: #6d28d9; }
.stat-card[style*="#0891b2"], .stat-card[style*="#06b6d4"] { --stat-accent: #38bdf8; }

/* ════════════════════════════════════════════════════════════
   TABLES
   ════════════════════════════════════════════════════════════ */
.table {
    color: var(--text);
    border-color: var(--border-light);
}
.table th {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border) !important;
    padding: .65rem .9rem;
    white-space: nowrap;
    background: var(--surface-2);
}
.table td {
    padding: .65rem .9rem;
    font-size: .84rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.table-hover > tbody > tr {
    transition: background var(--transition);
}
.table-hover > tbody > tr:hover > td {
    background: #f0f7ff;
}
.table-dark th { background: #1e293b !important; color: #e2e8f0 !important; }

/* ════════════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════════════ */
.btn {
    font-size: .83rem;
    font-weight: 500;
    border-radius: .55rem;
    padding: .45rem 1rem;
    transition: all var(--transition);
    letter-spacing: .01em;
}
.btn:active { transform: scale(.97); }
.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-contrast);
    box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); box-shadow: 0 4px 14px rgba(37,99,235,.35); }
.btn-outline-primary { border-color: var(--brand); color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); color: var(--brand-contrast); }
.btn-success { box-shadow: 0 2px 8px rgba(16,185,129,.22); }
.btn-danger  { box-shadow: 0 2px 8px rgba(239,68,68,.22); }

.btn-sm  { padding: .3rem .7rem; font-size: .78rem; border-radius: .45rem; }
.btn-xs  { padding: .2rem .55rem; font-size: .72rem; border-radius: .38rem; }

/* ════════════════════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════════════════════ */
.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: .55rem;
    font-size: .84rem;
    color: var(--text);
    background: var(--surface);
    padding: .45rem .85rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
    background: var(--surface);
    outline: none;
}
.form-control::placeholder { color: #b0bec5; }
.form-label { font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.form-text  { font-size: .75rem; color: var(--text-light); }

.input-group .form-control { border-radius: 0; }
.input-group .form-control:first-child { border-radius: .55rem 0 0 .55rem; }
.input-group .form-control:last-child  { border-radius: 0 .55rem .55rem 0; }
.input-group-text {
    background: var(--surface-2);
    border-color: var(--border);
    font-size: .83rem;
    color: var(--text-muted);
}

/* ════════════════════════════════════════════════════════════
   BADGES
   ════════════════════════════════════════════════════════════ */
.badge {
    font-size: .7rem;
    font-weight: 600;
    padding: .25em .65em;
    border-radius: .4rem;
    letter-spacing: .02em;
}

/* Status badge helpers — matches getStatusBadge() output */
.badge.bg-success-subtle  { background: #d1fae5 !important; color: #065f46 !important; }
.badge.bg-warning-subtle  { background: #fef3c7 !important; color: #92400e !important; }
.badge.bg-danger-subtle   { background: #fee2e2 !important; color: #991b1b !important; }
.badge.bg-info-subtle     { background: #e0f2fe !important; color: #0369a1 !important; }
.badge.bg-secondary-subtle{ background: #f1f5f9 !important; color: #475569 !important; }
.badge.bg-primary-subtle  { background: #eff6ff !important; color: #1e40af !important; }

/* ════════════════════════════════════════════════════════════
   ALERTS
   ════════════════════════════════════════════════════════════ */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: .84rem;
    padding: .8rem 1.1rem;
}
.alert-info    { background: #e0f2fe; color: #0369a1; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-danger  { background: #fee2e2; color: #991b1b; }

/* ════════════════════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════════════════════ */
.modal-content {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.4rem;
    border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header .modal-title { font-size: .95rem; font-weight: 700; }
.modal-footer {
    border-top: 1px solid var(--border);
    padding: .85rem 1.4rem;
}
.modal-body { padding: 1.25rem 1.4rem; }

/* ════════════════════════════════════════════════════════════
   MISC UTILITIES
   ════════════════════════════════════════════════════════════ */
.text-truncate-2 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Highlight on focus-within for form sections */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.form-section:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-muted); }

/* Progress bar */
.progress { height: 6px; border-radius: 99px; background: var(--border); }
.progress-bar { border-radius: 99px; background: var(--brand); }

/* Invoice / quote summary box */
.total-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
}

/* ── DataTables overrides ─────────────────────────────────── */
div.dataTables_wrapper div.dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: .45rem;
    padding: .3rem .75rem;
    font-size: .8rem;
    margin-left: .5rem;
}
div.dataTables_wrapper div.dataTables_length select {
    border: 1px solid var(--border);
    border-radius: .45rem;
    padding: .3rem .5rem;
    font-size: .8rem;
}
.dataTables_paginate .page-item .page-link {
    border-radius: .4rem !important;
    font-size: .8rem;
}

/* ── Charts & profile identity ───────────────────────────── */
.chart-container { position: relative; min-height: 310px; }
.chart-container.chart-sm { min-height: 250px; }
.chart-container.chart-donut { min-height: 190px; height: 190px; }
.chart-container.chart-donut-lg { min-height: 260px; height: 260px; }
.chart-card, .wc-chart-card { overflow: hidden; border-color: var(--border); box-shadow: var(--shadow-sm); }
.chart-card .card-header, .wc-chart-card .card-header { padding: 1rem 1.25rem; font-size: .9rem; }
.chart-card .card-body, .wc-chart-card .card-body { background: var(--surface); padding: 1.25rem; }
.wc-chart-surface { border-radius: .75rem; }
.wc-chart-card canvas { max-width: 100%; }
.dark-mode .stat-card { background: var(--surface) !important; border-color: var(--border); }
.dark-mode .stat-card .stat-value { color: var(--text); }
.user-avatar {
    display: block;
    flex: 0 0 auto;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    border: 2px solid color-mix(in srgb, var(--brand) 45%, var(--surface));
    background: var(--surface-2);
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.user-avatar-sm { width: 30px; height: 30px; }
.user-avatar-lg { width: 96px; height: 96px; }
.user-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    color: var(--brand-contrast);
    font-weight: 800;
}
.user-avatar-lg.user-avatar-fallback { font-size: 2rem; }

/* ════════════════════════════════════════════════════════════
   DARK THEME — Bootstrap and plugin contrast corrections
   ════════════════════════════════════════════════════════════ */
body.dark-mode {
    color-scheme: dark;
    --bg: #0a1220;
    --surface: #111c2d;
    --surface-2: #17243a;
    --border: #2a3a52;
    --border-light: #213149;
    --text: #f1f5f9;
    --text-muted: #c0ccda;
    --text-light: #9babc0;
    --brand-light: color-mix(in srgb, var(--brand) 18%, #111c2d);
    --brand-muted: color-mix(in srgb, var(--brand) 22%, transparent);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.2);
    --shadow: 0 6px 20px rgba(0,0,0,.38);
    --shadow-lg: 0 16px 38px rgba(0,0,0,.5);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-secondary-color: var(--text-muted);
    --bs-emphasis-color: #ffffff;
    background: var(--bg);
    color: var(--text);
}
.dark-mode .card,
.dark-mode .modal-content,
.dark-mode .dropdown-menu,
.dark-mode .list-group-item,
.dark-mode .offcanvas,
.dark-mode .accordion-item,
.dark-mode .toast { background-color: var(--surface); color: var(--text); border-color: var(--border); }
.dark-mode .dropdown-item,
.dark-mode .dropdown-header,
.dark-mode .modal-title,
.dark-mode .nav-link,
.dark-mode label,
.dark-mode p { color: var(--text); }
.dark-mode .dropdown-item:hover,
.dark-mode .dropdown-item:focus,
.dark-mode .dropdown-item.active,
.dark-mode .list-group-item-action:hover { background-color: var(--surface-2); color: #fff; }
.dark-mode .dropdown-divider,
.dark-mode .border,
.dark-mode .border-top,
.dark-mode .border-bottom,
.dark-mode .border-start,
.dark-mode .border-end { border-color: var(--border) !important; }
.dark-mode .text-muted { color: var(--text-muted) !important; }
.dark-mode .text-dark { color: var(--text) !important; }
.dark-mode .text-primary { color: color-mix(in srgb, var(--brand) 58%, #ffffff) !important; }
.dark-mode .bg-light,
.dark-mode .bg-white,
.dark-mode .table-light,
.dark-mode .table-light > * > *,
.dark-mode .alert-light { background-color: var(--surface-2) !important; color: var(--text) !important; }
.dark-mode .table { --bs-table-color: var(--text); --bs-table-bg: transparent; --bs-table-border-color: var(--border-light); }
.dark-mode .table-hover > tbody > tr:hover > * { --bs-table-accent-bg: color-mix(in srgb, var(--brand) 10%, var(--surface)); color: var(--text); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
.dark-mode .table-primary > * { --bs-table-bg: #17345f; --bs-table-color: #e8f1ff; }
.dark-mode .table-success > * { --bs-table-bg: #103b31; --bs-table-color: #d1fae5; }
.dark-mode .table-danger > * { --bs-table-bg: #4a1d2b; --bs-table-color: #ffe4e6; }
.dark-mode .table-warning > * { --bs-table-bg: #493715; --bs-table-color: #fef3c7; }
.dark-mode .table-info > * { --bs-table-bg: #123c4b; --bs-table-color: #cffafe; }
.dark-mode .form-control,
.dark-mode .form-select,
.dark-mode .form-check-input,
.dark-mode .input-group-text,
.dark-mode .dataTables_wrapper input,
.dark-mode .dataTables_wrapper select {
    background-color: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}
.dark-mode .form-control:disabled,
.dark-mode .form-select:disabled,
.dark-mode .form-control[readonly] { background-color: #1d2a40; color: var(--text-muted); opacity: 1; }
.dark-mode .form-control::placeholder { color: #8999ad; }
.dark-mode .form-select option { background: var(--surface); color: var(--text); }
.dark-mode .form-control:focus,
.dark-mode .form-select:focus { background-color: var(--surface-2); color: #fff; }
.dark-mode .nav-tabs { border-bottom-color: var(--border); }
.dark-mode .nav-tabs .nav-link { color: var(--text-muted); }
.dark-mode .nav-tabs .nav-link:hover { border-color: var(--border); color: #fff; }
.dark-mode .nav-tabs .nav-link.active { background: var(--surface); border-color: var(--border) var(--border) var(--surface); color: #fff; }
.dark-mode .pagination .page-link { background: var(--surface); border-color: var(--border); color: var(--text); }
.dark-mode .pagination .page-item.active .page-link { background: var(--brand); color: var(--brand-contrast); }
.dark-mode .btn-outline-dark { border-color: #93a4b8; color: #e2e8f0; }
.dark-mode .btn-outline-dark:hover { background: #e2e8f0; color: #111827; }
.dark-mode .btn-close { filter: invert(1) grayscale(100%) brightness(180%); }
.dark-mode hr { border-color: var(--border); opacity: 1; }
.dark-mode div.dataTables_wrapper,
.dark-mode div.dataTables_info,
.dark-mode div.dataTables_length,
.dark-mode div.dataTables_filter { color: var(--text-muted) !important; }

/* ════════════════════════════════════════════════════════════
   PRINT STYLES
   ════════════════════════════════════════════════════════════ */
@media print {
    .sidebar, .module-sub-nav, nav, .no-print,
    #syncQueueBadge, .stat-icon, .page-header .d-flex,
    .chart-container, canvas { display: none !important; }
    .main-content { margin-left: 0 !important; padding-top: 0 !important; }
    .card { box-shadow: none !important; break-inside: avoid; border: 1px solid #dee2e6 !important; }
    .card-header { border-bottom: 1px solid #dee2e6 !important; }
    body { background: #fff; font-size: 11pt; color: #000; }
    .print-only { display: block !important; }
    h1 .fas, h1 .far, .card-header .fas { display: none !important; }
    .stat-card { color: #000 !important; }
    table { font-size: 9pt; }
    a { text-decoration: none; color: #000; }
    .badge {
        background: transparent !important;
        color: #000 !important;
        border: 1px solid #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    body::after { display: none !important; content: none !important; }
    .attendance-print-week { page-break-inside: avoid; }
    .invoice-footer, .inv-footer, .doc-footer,
    [class*="invoice-footer"], [class*="doc-footer"] {
        display: block !important; visibility: visible !important;
        opacity: 1 !important; position: relative !important;
        page-break-inside: avoid !important;
        border-top: 1px solid #ccc !important;
        padding-top: 8px !important; margin-top: 16px !important;
        font-size: 9pt; color: #444;
    }
    .invoice-totals, .inv-totals { page-break-inside: avoid !important; }
}
.print-only { display: none; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — mobile
   ════════════════════════════════════════════════════════════ */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0 !important; }
    .content-wrapper { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.5rem; }
}

/* Keyboard, accessibility and productivity surfaces */
.skip-link{position:fixed;left:1rem;top:-5rem;z-index:3000;background:#fff;color:#111827;padding:.65rem 1rem;border-radius:.5rem;box-shadow:var(--shadow-lg)}
.skip-link:focus{top:1rem}
:focus-visible{outline:3px solid color-mix(in srgb,var(--brand) 70%,#fff);outline-offset:2px}
.saved-view-tools{max-width:440px}
#waveledgerSearchResults .list-group-item{min-height:64px}
.place-items-center{place-items:center}
@media (max-width:576px){.page-header{align-items:flex-start}.page-header>.d-flex{width:100%;flex-wrap:wrap}.table-responsive{font-size:.875rem}.modal-dialog{margin:.5rem}.saved-view-tools{max-width:none;flex-wrap:wrap}.saved-view-tools select{flex:1 1 180px}.btn,.form-control,.form-select{min-height:42px}}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}
