/* ============================================================
   LEAD & ENQUIRY MODULE - DESIGN SYSTEM
   Theme: "Ledger" - an academic-institutional CRM identity.
   Rationale: the product sells to universities/colleges/schools,
   so the palette borrows from collegiate ledgers and gazettes
   (deep navy, brass/gold accent, warm paper background) instead
   of a generic SaaS blue-on-white look.
   ============================================================ */

:root {
    /* Color tokens */
    --navy-950: #0B1220;
    --navy-900: #0F1B2E;
    --navy-800: #16263F;
    --navy-700: #1E344F;
    --navy-600: #2A4568;
    --paper: #F6F4EE; /* warm paper background */
    --paper-card: #FFFFFF;
    --ink: #182233; /* primary text */
    --ink-soft: #4B5567;
    --brass: #B8892B; /* signature accent - brass/gold */
    --brass-light: #E7C784;
    --brass-dark: #8C6A20;
    --line: #E4DFD3;
    --success: #1E7B4D;
    --success-bg: #E6F4EC;
    --danger: #B3352C;
    --danger-bg: #FBEAE8;
    --warning: #B8892B;
    --warning-bg: #FBF3E2;
    --info: #2A6E8C;
    --info-bg: #E7F1F5;
    /* Dark mode surface (toggled via [data-theme="dark"]) */
    --dm-bg: #0B1220;
    --dm-card: #131E30;
    --dm-line: #233247;
    --dm-ink: #E7E9EE;
    --dm-ink-soft: #9AA6B8;
    /* Typography */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, Segoe UI, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    /* Layout */
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 2px rgba(15,27,46,0.06), 0 4px 16px rgba(15,27,46,0.06);
    --shadow-pop: 0 12px 32px rgba(15,27,46,0.18);
    --transition: 180ms cubic-bezier(.4,0,.2,1);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] body {
    background: var(--dm-bg);
    color: var(--dm-ink);
}

h1, h2, h3, .display {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
}

[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3, [data-theme="dark"] .display {
    color: var(--dm-ink);
}

a {
    color: var(--info);
    text-decoration: none;
}

    a:hover {
        color: var(--brass-dark);
    }

::selection {
    background: var(--brass-light);
    color: var(--navy-950);
}

/* Focus visibility - accessibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh; /* real visible viewport height on browsers that support it (progressive enhancement, falls back to 100vh above) */
    background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
    color: #C9D2E0;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: width var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid rgba(255,255,255,0.06);
}

    .sidebar.collapsed {
        width: var(--sidebar-w-collapsed);
        overflow: hidden; /* guarantees no horizontal clipping/scroll leaks out of the narrow rail */
    }

        /* ---- Collapsed (icon-only) state ----
       Previously only the sidebar's width shrank; the brand text, section
       headings and nav-item labels stayed in the DOM at full size with just
       "overflow:hidden" on their row, so they appeared partially cut instead
       of collapsing cleanly. These rules hide the text cleanly and re-center
       the icons, without touching markup, links, icons, or active-state logic. */
        .sidebar.collapsed .sidebar-brand {
            padding: 0;
            justify-content: center;
            gap: 0;
        }

            .sidebar.collapsed .sidebar-brand .brand-text {
                display: none;
            }

        .sidebar.collapsed .sidebar-nav {
            padding-left: .5rem;
            padding-right: .5rem;
        }

        .sidebar.collapsed .nav-section-label {
            display: none; /* section headings hidden in collapsed mode, per spec */
        }

        .sidebar.collapsed .nav-item {
            justify-content: center;
            gap: 0;
            padding: .6rem 0;
        }

            .sidebar.collapsed .nav-item span,
            .sidebar.collapsed .nav-item .badge-count {
                display: none; /* label text/badges hidden cleanly instead of clipping */
            }

            .sidebar.collapsed .nav-item i {
                width: auto;
                font-size: 1rem;
            }

        .sidebar.collapsed .sidebar-footer {
            padding: .85rem .25rem;
            text-align: center;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 0; /* footer text collapses to nothing so it can never overlap Users/Roles or spill outside the rail */
        }

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

    .sidebar-brand .mark {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        background: var(--brass);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--navy-950);
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 16px;
        flex-shrink: 0;
    }

    .sidebar-brand .brand-text {
        font-family: var(--font-display);
        font-size: 1.05rem;
        color: #fff;
        white-space: nowrap;
        overflow: hidden;
    }

        .sidebar-brand .brand-text small {
            display: block;
            font-family: var(--font-body);
            font-size: .65rem;
            letter-spacing: .12em;
            color: var(--brass-light);
            text-transform: uppercase;
        }

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0; /* required so this flex child can shrink below its content height and become scrollable instead of pushing the footer/Administration off-screen */
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem .75rem 1.25rem;
    scrollbar-gutter: stable;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(255,255,255,0.35) transparent; /* Firefox */
    /* Scroll-position fade cues (top/bottom) so it's visually obvious there is
       more menu content (e.g. Administration / Users / Roles) to scroll to,
       instead of the list appearing to be abruptly cut off. Purely decorative;
       does not affect layout, items, links or highlighting. */
    background-image: linear-gradient(var(--navy-900) 30%, rgba(15,27,46,0)), linear-gradient(rgba(15,27,46,0), var(--navy-900) 70%), radial-gradient(farthest-side at 50% 0%, rgba(0,0,0,.45), rgba(0,0,0,0)), radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,.45), rgba(0,0,0,0));
    background-repeat: no-repeat;
    background-size: 100% 36px, 100% 36px, 100% 12px, 100% 12px;
    background-position: top, bottom, top, bottom;
    background-attachment: local, local, scroll, scroll;
}

    .sidebar-nav::-webkit-scrollbar {
        width: 7px;
    }

    .sidebar-nav::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar-nav::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.3);
        border-radius: 4px;
    }

        .sidebar-nav::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.45);
        }

.nav-section-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: rgba(201,210,224,0.45);
    padding: 1rem .6rem .4rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .65rem;
    border-radius: var(--radius-sm);
    color: #C9D2E0;
    font-size: .88rem;
    margin-bottom: 2px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    overflow: hidden;
}

    .nav-item i {
        width: 18px;
        text-align: center;
        flex-shrink: 0;
        color: #8EA1BE;
        transition: color var(--transition);
    }

    .nav-item:hover {
        background: rgba(184,137,43,0.12);
        color: #fff;
    }

        .nav-item:hover i {
            color: var(--brass-light);
        }

    .nav-item.active {
        background: rgba(184,137,43,0.18);
        color: #fff;
        box-shadow: inset 3px 0 0 var(--brass);
    }

        .nav-item.active i {
            color: var(--brass);
        }

    .nav-item .badge-count {
        margin-left: auto;
        background: var(--brass);
        color: var(--navy-950);
        font-size: .68rem;
        font-weight: 700;
        padding: .05rem .4rem;
        border-radius: 10px;
    }

.sidebar-footer {
    flex: 0 0 auto;
    padding: .85rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: .72rem;
    color: rgba(201,210,224,0.5);
    background: inherit;
}

/* Main column */
.main-col {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    transition: margin-left var(--transition);
    display: flex;
    flex-direction: column;
}

    .main-col.expanded {
        margin-left: var(--sidebar-w-collapsed);
    }

.topbar {
    height: var(--topbar-h);
    background: var(--paper-card);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

[data-theme="dark"] .topbar {
    background: var(--dm-card);
    border-color: var(--dm-line);
}

.topbar-search {
    position: relative;
    width: 340px;
    max-width: 40vw;
}

    .topbar-search input {
        width: 100%;
        padding: .5rem .9rem .5rem 2.3rem;
        border-radius: 20px;
        border: 1px solid var(--line);
        background: var(--paper);
        font-size: .85rem;
    }

    .topbar-search i {
        position: absolute;
        left: .85rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--ink-soft);
    }

.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* ============================================================
   CARDS / KPI
   ============================================================ */
.card-surface {
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

[data-theme="dark"] .card-surface {
    background: var(--dm-card);
    border-color: var(--dm-line);
}

.kpi-card {
    padding: 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    position: relative;
    overflow: hidden;
}

    .kpi-card .kpi-icon {
        width: 38px;
        height: 38px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
    }

    .kpi-card .kpi-value {
        font-family: var(--font-display);
        font-size: 1.9rem;
        font-weight: 600;
        color: var(--ink);
    }

[data-theme="dark"] .kpi-card .kpi-value {
    color: var(--dm-ink);
}

.kpi-card .kpi-label {
    font-size: .78rem;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.kpi-card .kpi-trend {
    font-size: .75rem;
    font-weight: 600;
}

    .kpi-card .kpi-trend.up {
        color: var(--success);
    }

    .kpi-card .kpi-trend.down {
        color: var(--danger);
    }

/* Status badges */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .6rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
}

    .badge-status::before {
        content: '';
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: currentColor;
    }

/* Buttons */
.btn {
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 600;
    padding: .5rem 1rem;
    border: 1px solid transparent;
    transition: all var(--transition);
    cursor: pointer;
}

.btn-brass {
    background: var(--brass);
    border-color: var(--brass);
    color: #fff;
}

    .btn-brass:hover {
        background: var(--brass-dark);
        border-color: var(--brass-dark);
        color: #fff;
    }

.btn-outline-navy {
    background: transparent;
    border-color: var(--navy-700);
    color: var(--navy-800);
}

    .btn-outline-navy:hover {
        background: var(--navy-900);
        color: #fff;
    }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--ink-soft);
}

    .btn-ghost:hover {
        background: rgba(0,0,0,0.05);
    }

.btn-ghost-danger {
    background: transparent;
    border-color: transparent;
    color: var(--danger);
}

    .btn-ghost-danger:hover {
        background: rgba(179,53,44,0.1);
    }

/* Tables */
.table-modern {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}

    .table-modern thead th {
        font-size: .72rem;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: var(--ink-soft);
        font-weight: 700;
        padding: .75rem 1rem;
        border-bottom: 2px solid var(--line);
        text-align: left;
    }

    .table-modern tbody td {
        padding: .7rem 1rem;
        border-bottom: 1px solid var(--line);
        font-size: .86rem;
        vertical-align: middle;
    }

    .table-modern tbody tr {
        transition: background var(--transition);
    }

        .table-modern tbody tr:hover {
            background: rgba(184,137,43,0.05);
        }

/* =========================================================================
   PROJECT-WIDE DATA GRID BORDERS  (added)
   -------------------------------------------------------------------------
   Applies the same "Lead Register" bordered-grid look (outer border, a
   divider between every column, a divider between every row, and a
   divider between the header and the data) to every data grid in the
   project, regardless of which page-specific table class it also uses
   (.cf-table, .crm-table, .et-table, .report-table, .wa-table, .ll-table).

   These rules are declared once here, using an element-qualified selector
   (e.g. "table.cf-table" instead of just ".cf-table") so they win over the
   older per-page <style> blocks without needing to edit every page, and
   without using a heavier specificity hack than necessary. Colors,
   backgrounds, fonts and hover states defined on those pages are left
   untouched - only borders/spacing/radius are unified here.
   ========================================================================= */

table.table-modern,
table.cf-table,
table.crm-table,
table.et-table,
table.report-table,
table.wa-table {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    border: 1px solid var(--line, #e5e7eb) !important;
}

    table.table-modern thead th,
    table.table-modern tbody td,
    table.cf-table thead th,
    table.cf-table tbody td,
    table.crm-table thead th,
    table.crm-table tbody td,
    table.et-table thead th,
    table.et-table tbody td,
    table.et-table th,
    table.et-table td,
    table.report-table thead th,
    table.report-table tbody td,
    table.wa-table thead th,
    table.wa-table tbody td,
    table.wa-table th,
    table.wa-table td {
        border: 1px solid var(--line, #e5e7eb) !important;
        border-radius: 0 !important;
        background-clip: padding-box;
    }

    /* Header/body divider stays a touch stronger, matching the Lead Register table */
    table.table-modern thead th,
    table.cf-table thead th,
    table.crm-table thead th,
    table.et-table thead th,
    table.et-table th,
    table.report-table thead th,
    table.wa-table thead th,
    table.wa-table th {
        border-bottom: 2px solid var(--line, #e5e7eb) !important;
    }

    /* Neutralize the older "floating row" look (row gaps + per-row rounded
   corners) on tables that used to render each row as a separate rounded
   card, so all grids share one continuous bordered table surface. */
    table.cf-table tbody td:first-child,
    table.cf-table tbody td:last-child,
    table.et-table tr td:first-child,
    table.et-table tr td:last-child,
    table.wa-table tr td:first-child,
    table.wa-table tr td:last-child {
        border-radius: 0 !important;
    }

    table.cf-table tbody tr:hover td,
    table.et-table tbody tr:hover td,
    table.wa-table tbody tr:hover td {
        transform: none !important;
        box-shadow: none !important;
    }

/* Column heading icons (inserted client-side, see grid-header-icons.js) */
.grid-header-icon {
    margin-right: .5em;
    opacity: .82;
    font-size: .92em;
}

/* ============================================================
   PROJECT-WIDE GRID HEADER / SERIAL NUMBER REFINEMENT
   ============================================================ */

/* Keep every grid header icon visually separated from its label. */
.erp-grid-header-icon {
    display: inline-block;
    margin-right: 7px;
    width: 1em;
    text-align: center;
    vertical-align: -0.05em;
}

/* Every generated S.No. column is a normal bordered grid column. */
.erp-grid-sno-header,
.erp-grid-sno-cell {
    text-align: center !important;
    white-space: nowrap;
}

/* Ensure the actual data cells and header cells carry the dividers. */
.erp-data-grid {
    width: 100%;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    border: 1px solid var(--line, #E4DFD3) !important;
}

    .erp-data-grid th,
    .erp-data-grid td {
        border: 1px solid var(--line, #E4DFD3) !important;
    }

    .erp-data-grid th {
        border-bottom: 2px solid var(--line, #E4DFD3) !important;
        font-weight: 800 !important;
        color: var(--ink, #17263c) !important;
    }

/* All ERP data-grid column headings must be clearly bold.
   Applies across Lead List, Email/WhatsApp/Call tracking, Reports,
   and any other grid using the shared grid classes. */
table.table-modern th,
table.cf-table th,
table.crm-table th,
table.et-table th,
table.report-table th,
table.wa-table th,
table.ll-table th,
table.erp-data-grid th {
    font-weight: 800 !important;
    color: var(--ink, #17263c) !important;
    vertical-align: middle !important;
}

    /* Keep icon and heading text visibly separated everywhere. */
    table.table-modern th i,
    table.cf-table th i,
    table.crm-table th i,
    table.et-table th i,
    table.report-table th i,
    table.wa-table th i,
    table.ll-table th i,
    table.erp-data-grid th i,
    .erp-grid-header-icon {
        margin-right: 7px !important;
        display: inline-block;
        vertical-align: middle;
    }


/* Forms */
.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: .3rem;
    display: block;
}

.form-control-modern {
    width: 100%;
    padding: .55rem .8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper-card);
    font-size: .87rem;
    color: var(--ink);
    transition: border-color var(--transition), box-shadow var(--transition);
}

    .form-control-modern:focus {
        outline: none;
        border-color: var(--brass);
        box-shadow: 0 0 0 3px rgba(184,137,43,0.18);
    }

.required-mark {
    color: var(--danger);
    margin-left: 2px;
}

/* Utility */
.text-soft {
    color: var(--ink-soft);
}

.divider-line {
    border-top: 1px solid var(--line);
    margin: 1.25rem 0;
}

.animate-fade-in {
    animation: fadeIn .35s ease both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

        .sidebar.show-mobile {
            transform: translateX(0);
        }

    .main-col {
        margin-left: 0;
    }

    .topbar-search {
        width: 180px;
    }
}

/* ============================================================
   DARK MODE - COMPLETE APPLICATION SURFACES
   ============================================================ */
:root {
    --surface: var(--paper-card);
    --text-soft: var(--ink-soft);
}

[data-theme="dark"] {
    --paper: #0B1220;
    --paper-card: #131E30;
    --surface: #131E30;
    --ink: #E7E9EE;
    --ink-soft: #AAB5C5;
    --text-soft: #AAB5C5;
    --line: #2A3950;
    --brass-light: #E7C784;
    --dm-bg: #0B1220;
    --dm-card: #131E30;
    --dm-line: #2A3950;
    --dm-ink: #E7E9EE;
    --dm-ink-soft: #AAB5C5;
    --shadow-card: 0 1px 2px rgba(0,0,0,.28), 0 6px 18px rgba(0,0,0,.18);
}

    [data-theme="dark"] body,
    [data-theme="dark"] .content-area {
        background: var(--dm-bg) !important;
        color: var(--dm-ink) !important;
    }

    [data-theme="dark"] .card-surface,
    [data-theme="dark"] .dashboard-card,
    [data-theme="dark"] .dashboard-kpi,
    [data-theme="dark"] .modal-content,
    [data-theme="dark"] .modal-dialog .modal-content,
    [data-theme="dark"] .dropdown-menu,
    [data-theme="dark"] .list-group-item,
    [data-theme="dark"] .filter-card,
    [data-theme="dark"] .panel,
    [data-theme="dark"] .section-card {
        background: var(--dm-card) !important;
        border-color: var(--dm-line) !important;
        color: var(--dm-ink) !important;
    }

        [data-theme="dark"] .dashboard-heading h2,
        [data-theme="dark"] .dashboard-kpi .kpi-value,
        [data-theme="dark"] .dashboard-kpi .kpi-label,
        [data-theme="dark"] .dashboard-card-head h3,
        [data-theme="dark"] .pipeline-count,
        [data-theme="dark"] .source-name,
        [data-theme="dark"] .form-label,
        [data-theme="dark"] .table-modern td,
        [data-theme="dark"] .table-modern th,
        [data-theme="dark"] table td,
        [data-theme="dark"] table th {
            color: var(--dm-ink) !important;
        }

    [data-theme="dark"] .dash-muted,
    [data-theme="dark"] .dashboard-date,
    [data-theme="dark"] .source-value,
    [data-theme="dark"] .pipeline-percent,
    [data-theme="dark"] .text-soft {
        color: var(--dm-ink-soft) !important;
    }

    [data-theme="dark"] .dash-btn:not(.dash-btn-primary),
    [data-theme="dark"] .btn-outline-navy,
    [data-theme="dark"] .btn-ghost {
        background: transparent !important;
        color: var(--dm-ink) !important;
        border-color: var(--dm-line) !important;
    }

        [data-theme="dark"] .dash-btn:not(.dash-btn-primary):hover,
        [data-theme="dark"] .btn-outline-navy:hover,
        [data-theme="dark"] .btn-ghost:hover {
            background: rgba(255,255,255,.07) !important;
        }

    [data-theme="dark"] .dash-btn-primary {
        color: #fff !important;
    }

    [data-theme="dark"] .pipeline-stage {
        background: #1A273A !important;
        color: var(--dm-ink) !important;
    }

    [data-theme="dark"] .source-bar {
        background: #263347 !important;
    }

    [data-theme="dark"] .table-modern,
    [data-theme="dark"] table.cf-table,
    [data-theme="dark"] table.crm-table,
    [data-theme="dark"] table.et-table,
    [data-theme="dark"] table.report-table,
    [data-theme="dark"] table.wa-table,
    [data-theme="dark"] table.ll-table,
    [data-theme="dark"] table.erp-data-grid {
        background: var(--dm-card) !important;
        color: var(--dm-ink) !important;
    }

        [data-theme="dark"] .table-modern thead th,
        [data-theme="dark"] table.cf-table thead th,
        [data-theme="dark"] table.crm-table thead th,
        [data-theme="dark"] table.et-table thead th,
        [data-theme="dark"] table.report-table thead th,
        [data-theme="dark"] table.wa-table thead th,
        [data-theme="dark"] table.ll-table thead th,
        [data-theme="dark"] table.erp-data-grid th {
            background: #172438 !important;
            color: var(--dm-ink) !important;
            border-color: var(--dm-line) !important;
        }

        [data-theme="dark"] .table-modern tbody td,
        [data-theme="dark"] table.cf-table tbody td,
        [data-theme="dark"] table.crm-table tbody td,
        [data-theme="dark"] table.et-table tbody td,
        [data-theme="dark"] table.report-table tbody td,
        [data-theme="dark"] table.wa-table tbody td,
        [data-theme="dark"] table.ll-table tbody td,
        [data-theme="dark"] table.erp-data-grid td {
            background: var(--dm-card) !important;
            color: var(--dm-ink) !important;
            border-color: var(--dm-line) !important;
        }

    [data-theme="dark"] table tbody tr:hover td {
        background: #1A273A !important;
    }

    [data-theme="dark"] input,
    [data-theme="dark"] select,
    [data-theme="dark"] textarea,
    [data-theme="dark"] .form-control-modern,
    [data-theme="dark"] .form-select,
    [data-theme="dark"] .form-control {
        background: #101B2C !important;
        color: var(--dm-ink) !important;
        border-color: var(--dm-line) !important;
    }

        [data-theme="dark"] input::placeholder,
        [data-theme="dark"] textarea::placeholder {
            color: #8290A5 !important;
        }

    [data-theme="dark"] .status-pill.pending {
        background: #4A3715 !important;
        color: #F0C66D !important;
    }

    [data-theme="dark"] .status-pill.overdue {
        background: #4B2422 !important;
        color: #F0A09A !important;
    }

    /* Existing pages contain a number of hard-coded white card surfaces. */
    [data-theme="dark"] [style*="background:#fff"],
    [data-theme="dark"] [style*="background: #fff"],
    [data-theme="dark"] [style*="background:white"],
    [data-theme="dark"] [style*="background: white"],
    [data-theme="dark"] [style*="background-color:#fff"],
    [data-theme="dark"] [style*="background-color: #fff"],
    [data-theme="dark"] [style*="background-color:white"],
    [data-theme="dark"] [style*="background-color: white"] {
        background: var(--dm-card) !important;
        color: var(--dm-ink) !important;
        border-color: var(--dm-line) !important;
    }

/* ============================================================
   NOTIFICATIONS
   ============================================================ */
.notification-center {
    position: relative;
    flex-shrink: 0;
}

.notification-trigger {
    position: relative;
    width: 38px;
    height: 38px;
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

    .notification-trigger:hover {
        background: rgba(184,137,43,.10);
        color: var(--brass);
    }

.notification-count {
    position: absolute;
    top: 0;
    right: -1px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 20px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 17px;
    text-align: center;
}

.notification-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: -8px;
    width: 390px;
    max-width: min(390px, calc(100vw - 24px));
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-pop);
    overflow: hidden;
    z-index: 3000;
    display: none;
}

    .notification-panel.open {
        display: block;
    }

.notification-panel-head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.notification-title {
    color: var(--ink);
    font-weight: 700;
    font-size: .95rem;
}

.notification-subtitle {
    color: var(--ink-soft);
    font-size: .72rem;
    margin-top: 2px;
}

.notification-mark-all {
    color: var(--brass-dark);
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
    padding-top: 2px;
}

.notification-list {
    max-height: 390px;
    overflow-y: auto;
}

.notification-item {
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--ink) !important;
    text-decoration: none !important;
    text-align: left;
    background: transparent;
    transition: background .15s ease;
}

    .notification-item:hover {
        background: rgba(184,137,43,.07);
    }

    .notification-item.is-unread {
        background: rgba(184,137,43,.045);
    }

.notification-icon {
    width: 31px;
    height: 31px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 31px;
    color: var(--brass-dark);
    background: rgba(184,137,43,.12);
    margin-top: 1px;
}

.notification-content {
    min-width: 0;
    flex: 1;
}

.notification-message {
    display: block;
    color: var(--ink);
    font-size: .8rem;
    line-height: 1.35;
    font-weight: 600;
}

.notification-item.is-read .notification-message {
    font-weight: 500;
    color: var(--ink-soft);
}

.notification-time {
    display: block;
    color: var(--ink-soft);
    font-size: .68rem;
    margin-top: 3px;
}

.notification-unread-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brass);
    flex: 0 0 7px;
    margin-top: 6px;
}

.notification-item.is-read .notification-unread-dot {
    visibility: hidden;
}

.notification-empty {
    min-height: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--ink-soft);
    font-size: .8rem;
}

    .notification-empty i {
        font-size: 1.25rem;
        opacity: .65;
    }

[data-theme="dark"] .notification-panel {
    background: var(--dm-card) !important;
    border-color: var(--dm-line) !important;
}

[data-theme="dark"] .notification-panel-head,
[data-theme="dark"] .notification-item {
    border-color: var(--dm-line) !important;
}

[data-theme="dark"] .notification-title,
[data-theme="dark"] .notification-message {
    color: var(--dm-ink) !important;
}

[data-theme="dark"] .notification-subtitle,
[data-theme="dark"] .notification-time,
[data-theme="dark"] .notification-item.is-read .notification-message,
[data-theme="dark"] .notification-empty {
    color: var(--dm-ink-soft) !important;
}

/* ============================================================
   SIDEBAR SCROLL POSITION
   ============================================================ */
.sidebar-nav {
    scroll-behavior: auto;
}

/* Dark chat widget */
[data-theme="dark"] #erpChatBox,
[data-theme="dark"] #erpChatFooter {
    background: var(--dm-card) !important;
    border-color: var(--dm-line) !important;
    color: var(--dm-ink) !important;
}

[data-theme="dark"] #erpChatMessages {
    background: #0F1929 !important;
}

[data-theme="dark"] .erpBotMessage {
    background: #1A273A !important;
    color: var(--dm-ink) !important;
}

[data-theme="dark"] #erpChatInput {
    background: #101B2C !important;
    color: var(--dm-ink) !important;
    border-color: var(--dm-line) !important;
}
