/* ==========================================================================
   Haiti RH — design system
   --------------------------------------------------------------------------
   One stylesheet for every page. Colours come from CSS variables printed by
   theme_style_tag() (config/theme.php) from the company's settings, so a
   company changing its brand colour re-themes the whole app.

   Sections
     1. Tokens            6. Cards & KPI tiles      11. Modals & dialogs
     2. Base              7. Tables & DataTables    12. Badges & pills
     3. App shell         8. Forms                  13. Feedback (alerts, toasts, empty states)
     4. Sidebar           9. Buttons                14. Auth pages
     5. Topbar & header  10. Tabs & segmented       15. Utilities, print, responsive
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
    /* defaults, overridden per company by #hrt-theme */
    --brand: #163761;
    --brand-ink: #163761;
    --brand-rgb: 22, 55, 97;
    --brand-contrast: #fff;
    --brand-50: #f1f4f8;
    --brand-100: #dfe6ef;
    --brand-200: #c0cddd;
    --brand-300: #8fa3bf;
    --brand-600: #13304f;
    --brand-700: #10294a;
    --brand-800: #0d213a;
    --brand-900: #0a192c;
    --accent: #2a9d8f;
    --accent-rgb: 42, 157, 143;
    --accent-contrast: #fff;
    --accent-50: #eaf6f4;
    --accent-100: #d4ede9;
    --accent-700: #1f766b;
    --sidebar-bg: #0b1c30;
    --sidebar-fg: #e6edf5;
    --sidebar-muted: rgba(230, 237, 245, .62);
    --sidebar-heading: rgba(230, 237, 245, .45);
    --sidebar-hover: rgba(255, 255, 255, .07);
    --sidebar-active-bg: rgba(255, 255, 255, .14);
    --sidebar-active-fg: #fff;
    --sidebar-border: rgba(255, 255, 255, .08);
    --sidebar-brand-bg: #fff;
    --sidebar-brand-fg: #163761;

    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e4e9f0;
    --border-strong: #d5dde7;
    --text: #0f1b2d;
    --text-2: #3b4a5e;
    --muted: #6b7a8f;
    --faint: #98a4b5;

    --success: #12805c;
    --success-bg: #e6f5ee;
    --warning: #b45309;
    --warning-bg: #fdf3e2;
    --danger: #c0283d;
    --danger-bg: #fcebee;
    --info: #1d64c8;
    --info-bg: #e8f0fc;
    --neutral-bg: #eef2f6;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(15, 27, 45, .05);
    --shadow-sm: 0 1px 3px rgba(15, 27, 45, .07), 0 1px 2px rgba(15, 27, 45, .04);
    --shadow-md: 0 8px 24px -6px rgba(15, 27, 45, .14), 0 2px 6px rgba(15, 27, 45, .05);
    --shadow-lg: 0 24px 48px -12px rgba(15, 27, 45, .24);
    --ring: 0 0 0 3px rgba(var(--brand-rgb), .18);

    --sidebar-w: 264px;
    --topbar-h: 64px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

    /* Bootstrap 5.3 bridge */
    --bs-body-font-family: var(--font);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--border);
    --bs-primary: var(--brand);
    --bs-primary-rgb: var(--brand-rgb);
    --bs-link-color: var(--brand-ink);
    --bs-link-color-rgb: var(--brand-rgb);
    --bs-link-hover-color: var(--brand-700);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-lg: var(--radius);
    --bs-tertiary-bg: var(--surface-2);
    --bs-secondary-color: var(--muted);
    --bs-emphasis-color: var(--text);
}

/* 2. Base --------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-display);
    color: var(--text);
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.25;
    margin: 0 0 .5rem;
}

h1, .h1 { font-size: 1.85rem; letter-spacing: -.025em; font-weight: 800; }
h2, .h2 { font-size: 1.45rem; letter-spacing: -.02em; }
h3, .h3 { font-size: 1.2rem; }
h4, .h4 { font-size: 1.08rem; }
h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: .9rem; color: var(--text-2); }

p { margin: 0 0 .75rem; }

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

a:hover { color: var(--brand-700); }

hr {
    border: 0;
    border-top: 1px solid var(--border);
    opacity: 1;
    margin: 1rem 0;
}

::selection { background: rgba(var(--brand-rgb), .16); }

img { max-width: 100%; }

.mono, .num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
}

:focus-visible {
    outline: 2px solid rgba(var(--brand-rgb), .55);
    outline-offset: 2px;
}

/* legacy markup used <pre></pre> as vertical spacers */
pre:empty { display: none; }

/* 3. App shell ------------------------------------------------------------------ */
.app {
    min-height: 100vh;
}

.app-main {
    margin-left: var(--sidebar-w);
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1;
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    padding: 28px 32px 48px;
}

.app-content.is-wide { max-width: none; }

/* legacy wrappers still present in some views */
.app-content .main,
.app-content #content,
.app-content .main.container-fluid {
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    max-width: none !important;
    overflow: visible !important;
    background: transparent !important;
    display: block !important;
    opacity: 1 !important;
}

/* 4. Sidebar -------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    border-right: 1px solid var(--sidebar-border);
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 14px;
    color: var(--sidebar-fg);
    text-decoration: none;
    min-height: 72px;
}

.sidebar-brand:hover { color: var(--sidebar-fg); }

.brand-mark {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 11px;
    background: var(--sidebar-brand-bg);
    color: var(--sidebar-brand-fg);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: .02em;
    overflow: hidden;
    font-family: var(--font-display);
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
    background: #fff;
}

.brand-text { min-width: 0; line-height: 1.15; }

.brand-name {
    display: block;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: .01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-display);
}

.brand-tag {
    display: block;
    font-size: 10.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 6px 12px 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 6px; }

.nav-section { margin-top: 14px; }

.nav-heading {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--sidebar-heading);
    padding: 6px 10px 6px;
    margin: 0;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 10px;
    border-radius: 9px;
    color: var(--sidebar-fg);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.3;
    position: relative;
    transition: background .15s ease, color .15s ease;
}

.nav-item-link .nav-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    color: var(--sidebar-muted);
    flex: 0 0 18px;
    transition: color .15s;
}

.nav-item-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-fg);
}

.nav-item-link:hover .nav-icon { color: var(--sidebar-fg); }

.nav-item-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-fg);
    font-weight: 600;
}

.nav-item-link.active .nav-icon { color: var(--sidebar-active-fg); }

.nav-item-link .nav-badge {
    margin-left: auto;
    font-size: 10.5px;
    font-weight: 700;
    background: var(--accent);
    color: var(--accent-contrast);
    border-radius: 999px;
    padding: 1px 7px;
}

.nav-group > .nav-item-link .nav-caret {
    margin-left: auto;
    font-size: 10px;
    color: var(--sidebar-muted);
    transition: transform .2s ease;
}

.nav-group.open > .nav-item-link .nav-caret { transform: rotate(90deg); }

.nav-sub {
    list-style: none;
    margin: 2px 0 4px;
    padding: 0 0 0 29px;
    display: none;
}

.nav-group.open > .nav-sub { display: block; }

.nav-sub .nav-item-link {
    padding: 6px 10px;
    font-size: 13px;
    color: var(--sidebar-muted);
    font-weight: 500;
}

.nav-sub .nav-item-link:hover,
.nav-sub .nav-item-link.active {
    color: var(--sidebar-active-fg);
}

.nav-sub .nav-item-link.active { background: var(--sidebar-hover); }

.sidebar-user {
    border-top: 1px solid var(--sidebar-border);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user .avatar {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-fg);
    border: 0;
}

.sidebar-user .who { min-width: 0; flex: 1; line-height: 1.2; }
.sidebar-user .who strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--sidebar-fg); }
.sidebar-user .who span { font-size: 11.5px; color: var(--sidebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.sidebar-user .signout {
    color: var(--sidebar-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
}

.sidebar-user .signout:hover { background: var(--sidebar-hover); color: var(--sidebar-fg); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(9, 17, 30, .45);
    z-index: 1035;
    backdrop-filter: blur(1px);
}

/* 5. Topbar & page header ----------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--topbar-h);
    background: rgba(255, 255, 255, .86);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px 0 28px;
}

.topbar .menu-toggle {
    display: none;
    border: 1px solid var(--border);
    background: #fff;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: var(--text-2);
}

.global-search {
    position: relative;
    flex: 0 1 440px;
}

.global-search i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--faint);
    font-size: 13px;
    pointer-events: none;
}

.global-search input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 10px;
    padding: 0 12px 0 36px;
    font-size: 13.5px;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.global-search input:focus {
    outline: none;
    background: #fff;
    border-color: rgba(var(--brand-rgb), .45);
    box-shadow: var(--ring);
}

.global-search .kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--faint);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 6px;
    background: #fff;
}

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
    display: none;
    max-height: 420px;
    overflow: auto;
    z-index: 1050;
}

.search-results.show { display: block; }

.search-results a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
}

.search-results a:hover,
.search-results a.focus { background: var(--brand-50); }

.search-results small { color: var(--muted); display: block; }

.topbar-spacer { flex: 1; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-2);
    display: inline-grid;
    place-items: center;
    font-size: 15px;
    transition: background .15s, border-color .15s;
}

.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }

.icon-btn .dot {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: grid;
    place-items: center;
    border: 2px solid #fff;
}

.chip-env {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--success);
    background: var(--success-bg);
    border: 1px solid rgba(18, 128, 92, .18);
    white-space: nowrap;
}

.company-switch {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 40px;
    padding: 0 10px 0 6px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    max-width: 260px;
}

.company-switch:hover { border-color: var(--border-strong); }

.company-switch .cs-logo {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    overflow: hidden;
    flex: 0 0 28px;
}

.company-switch .cs-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.company-switch .cs-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: transparent;
    padding: 4px;
    border-radius: 999px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.page-head .ph-text { min-width: 0; }

.page-head h1 {
    margin: 0;
    font-size: 2rem;
}

.page-head .ph-sub {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14.5px;
}

.page-head .ph-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.breadcrumbs {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 8px;
}

.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--brand-ink); }

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 28px 0 12px;
}

.section-title h2,
.section-title h3 { margin: 0; font-size: 1.05rem; }

/* 6. Cards & KPI tiles --------------------------------------------------------- */
.card {
    --bs-card-border-color: var(--border);
    --bs-card-border-radius: var(--radius);
    --bs-card-inner-border-radius: calc(var(--radius) - 1px);
    --bs-card-cap-bg: transparent;
    --bs-card-bg: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    background: var(--surface);
}

.card.shadow,
.card.shadow-sm,
.card.shadow-lg { box-shadow: var(--shadow-xs) !important; }

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 14px 18px;
    font-weight: 650;
}

.card-header h5,
.card-header h6,
.card-header .card-title { margin: 0; font-size: 15px; color: var(--text); font-weight: 700; }

.card-body { padding: 18px; }

.card-footer {
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    padding: 12px 18px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 0;
}

.panel-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.panel-head .sub {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12.5px;
}

.panel-head a.more,
.panel-head .more {
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.panel-body { padding: 14px 18px 18px; }
.panel-body.flush { padding: 8px 0 4px; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
    gap: 14px;
}

.kpi-grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 16px 16px;
    min-height: 104px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-xs);
    position: relative;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}

a.kpi { color: inherit; }
a.kpi:hover { border-color: rgba(var(--brand-rgb), .35); box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.kpi-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.kpi-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    line-height: 1.35;
}

.kpi-icon {
    color: var(--faint);
    font-size: 14px;
    line-height: 1;
}

.kpi-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text);
    margin-top: 10px;
    line-height: 1.1;
}

.kpi-foot {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

.kpi.is-success .kpi-value { color: var(--success); }
.kpi.is-warning .kpi-value { color: var(--warning); }
.kpi.is-danger .kpi-value { color: var(--danger); }
.kpi.is-brand .kpi-value { color: var(--brand-ink); }
.kpi.is-accent .kpi-value { color: var(--accent-700); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.grid-side-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* list rows used in dashboard panels */
.row-list { list-style: none; margin: 0; padding: 0; }

.row-list > li,
.row-list > a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    color: var(--text);
}

.row-list > li:first-child,
.row-list > a:first-child { border-top: 0; }

.row-list > a:hover { background: var(--surface-2); }

.row-list .rl-main { flex: 1; min-width: 0; }
.row-list .rl-title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-list .rl-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-list .rl-end { text-align: right; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }

.todo-list .todo-count {
    min-width: 26px;
    height: 22px;
    border-radius: 999px;
    background: var(--warning-bg);
    color: var(--warning);
    font-size: 12px;
    font-weight: 700;
    display: grid;
    place-items: center;
    padding: 0 7px;
}

.progress {
    --bs-progress-height: 6px;
    --bs-progress-bg: var(--neutral-bg);
    --bs-progress-bar-bg: var(--brand);
    border-radius: 999px;
    height: 6px;
}

.progress-bar { background-color: var(--brand); border-radius: 999px; }

.avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 50%;
    background: var(--neutral-bg);
    color: var(--text-2);
    display: inline-grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    overflow: hidden;
    border: 1px solid var(--border);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; flex-basis: 28px; font-size: 10.5px; }
.avatar.lg { width: 56px; height: 56px; flex-basis: 56px; font-size: 18px; }
.avatar.xl { width: 88px; height: 88px; flex-basis: 88px; font-size: 26px; }

.person {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.person .p-name { font-weight: 600; color: var(--text); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .p-sub { font-size: 12px; color: var(--muted); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* 7. Tables & DataTables --------------------------------------------------------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--surface-2);
    --bs-table-hover-bg: #f6f8fb;
    --bs-table-hover-color: var(--text);
    margin-bottom: 0;
    font-size: 13.5px;
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: 12px 14px;
    border-bottom-color: var(--border);
}

.table thead th,
.table > thead > tr > th {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2) !important;
    border-bottom: 1px solid var(--border) !important;
    white-space: nowrap;
    padding-top: 11px;
    padding-bottom: 11px;
}

.table thead th input,
.table thead th select {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    width: 100%;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0 8px;
    font-size: 12.5px;
    background: #fff;
    color: var(--text);
}

.table tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: #f6f8fb; }
.table td.actions, .table th.actions { text-align: right; white-space: nowrap; }

/* legacy tables had thick black borders and rounded corners */
table.table-bordered,
.table-bordered,
.table-bordered > :not(caption) > * > * {
    border-color: var(--border) !important;
    border-width: 0 0 1px 0 !important;
}

table:not(.table):not(.no-style) {
    border-collapse: collapse;
}

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.table-wrap > .table-responsive,
.table-responsive {
    border-radius: inherit;
}

.table-wrap .table > :not(caption) > * > *:first-child { padding-left: 18px; }
.table-wrap .table > :not(caption) > * > *:last-child { padding-right: 18px; }
.table-wrap .table tbody tr:last-child > * { border-bottom: 0; }

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.table-toolbar .search {
    position: relative;
    flex: 0 1 300px;
}

.table-toolbar .search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--faint);
    font-size: 13px;
}

.table-toolbar .search input { padding-left: 34px; }

.dataTables_wrapper {
    font-size: 13.5px;
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

/* layout that does not depend on the DataTables stylesheet:
   [length ........ search] / table / [info ........ pages] */
.dataTables_wrapper > * { order: 3; flex: 1 1 100%; min-width: 0; }
.dataTables_wrapper > .dataTables_length { order: 1; flex: 0 0 auto; float: none !important; padding-left: 0; }
.dataTables_wrapper > .dataTables_filter { order: 2; flex: 0 0 auto; float: none !important; margin-left: auto; padding-right: 0; text-align: right; }
.dataTables_wrapper > .dataTables_info { order: 4; flex: 0 0 auto; float: none !important; padding-left: 0; }
.dataTables_wrapper > .dataTables_paginate { order: 5; flex: 0 0 auto; float: none !important; margin-left: auto; padding-right: 0; }
.dataTables_wrapper > .dataTables_processing { position: absolute; flex: none; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3; padding: 10px 18px; }
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; color: var(--muted); }
.dataTables_wrapper .dataTables_filter input { min-width: 220px; }
.dataTables_wrapper .dataTables_paginate { display: flex; align-items: center; gap: 2px; }
.dataTables_wrapper .dataTables_paginate span { display: inline-flex; gap: 2px; }
.dataTables_wrapper .dataTables_paginate .paginate_button { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; }
.dataTables_wrapper .dataTables_paginate .ellipsis { padding: 0 6px; color: var(--faint); }

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--muted) !important;
    padding: 12px 16px;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border-strong) !important;
    border-radius: 9px !important;
    height: 36px;
    padding: 0 10px !important;
    background: #fff !important;
    color: var(--text);
    margin-left: 6px;
}

.dataTables_wrapper .dataTables_filter input:focus { outline: none; border-color: rgba(var(--brand-rgb), .5) !important; box-shadow: var(--ring); }

table.dataTable { border-collapse: collapse !important; width: 100% !important; }
table.dataTable thead th, table.dataTable thead td { border-bottom: 1px solid var(--border) !important; }
table.dataTable.no-footer { border-bottom: 1px solid var(--border) !important; }
table.dataTable tbody tr { background: transparent !important; }
table.dataTable tbody td { border-top: 0 !important; }
table.dataTable.stripe tbody tr.odd, table.dataTable.display tbody tr.odd { background: var(--surface-2) !important; }
table.dataTable thead .sorting, table.dataTable thead .sorting_asc, table.dataTable thead .sorting_desc { background-image: none !important; }

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
    border: 1px solid transparent !important;
    color: var(--text-2) !important;
    padding: 4px 11px !important;
    margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--surface-2) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--brand) !important;
    color: var(--brand-contrast) !important;
    border-color: var(--brand) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover { color: var(--faint) !important; background: transparent !important; border-color: transparent !important; }

.dataTables_wrapper .dataTables_processing {
    background: rgba(255, 255, 255, .92);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

/* 8. Forms ------------------------------------------------------------------------ */
.form-label,
label.form-label,
.col-form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
}

.form-text { color: var(--muted); font-size: 12px; }

.form-control,
.form-select,
input.form-control,
select.form-select,
textarea.form-control {
    border: 1px solid var(--border-strong);
    border-radius: 10px !important;
    min-height: 40px;
    font-size: 13.5px;
    color: var(--text);
    background-color: #fff;
    box-shadow: none;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}

textarea.form-control { min-height: 96px; padding-top: 10px; }

.form-control-sm,
.form-select-sm { min-height: 34px; font-size: 13px; border-radius: 8px !important; }

.form-control-lg,
.form-select-lg { min-height: 48px; font-size: 15px; }

.form-control:focus,
.form-select:focus,
textarea:focus {
    border-color: rgba(var(--brand-rgb), .55) !important;
    box-shadow: var(--ring) !important;
    outline: none;
}

.form-control::placeholder { color: var(--faint); }

.form-control:disabled,
.form-control[readonly] { background: var(--surface-2); color: var(--text-2); }

.form-check-input {
    width: 1.05em;
    height: 1.05em;
    border-color: var(--border-strong);
    cursor: pointer;
}

.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { box-shadow: var(--ring); border-color: rgba(var(--brand-rgb), .55); }
.form-switch .form-check-input { width: 2.2em; height: 1.2em; }

/* the legacy CSS replaced every checkbox by a custom square; restore native look */
input[type="checkbox"].form-check-input::after { content: none !important; display: none !important; }

.input-group-text {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--muted);
    border-radius: 10px;
}

.input-group > .form-control:not(:first-child),
.input-group > .form-select:not(:first-child) { border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; }
.input-group > .form-control:not(:last-child),
.input-group > .form-select:not(:last-child) { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }

.form-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    background: var(--surface);
    margin-bottom: 16px;
}

.form-section > h3,
.form-section > h4,
.form-section > h6 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin-bottom: 14px;
}

.required::after { content: " *"; color: var(--danger); }
.text-danger.req { color: var(--danger); }

input[type="date"]::-webkit-calendar-picker-indicator { filter: none !important; opacity: .55; cursor: pointer; }

/* bootstrap-select */
.bootstrap-select > .dropdown-toggle,
.bootstrap-select .btn.dropdown-toggle {
    border: 1px solid var(--border-strong) !important;
    border-radius: 10px !important;
    background: #fff !important;
    color: var(--text) !important;
    min-height: 40px;
    font-size: 13.5px;
    box-shadow: none !important;
}

.bootstrap-select .dropdown-menu {
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    box-shadow: var(--shadow-md) !important;
    padding: 6px !important;
}

.bootstrap-select .dropdown-menu li a,
.bootstrap-select .dropdown-menu .dropdown-item {
    color: var(--text) !important;
    background: transparent !important;
    border-radius: 7px;
    font-size: 13.5px;
}

.bootstrap-select .dropdown-menu li a:hover,
.bootstrap-select .dropdown-menu .dropdown-item:hover { background: var(--brand-50) !important; color: var(--text) !important; }

.bootstrap-select .dropdown-menu li.selected a,
.bootstrap-select .dropdown-menu li.active a,
.bootstrap-select .dropdown-menu .dropdown-item.active { background: var(--brand-100) !important; color: var(--brand-ink) !important; }

.bootstrap-select .bs-searchbox input { border-radius: 8px !important; min-height: 34px; }
.bootstrap-select .filter-option-inner-inner { color: var(--text); }

/* 9. Buttons ------------------------------------------------------------------------- */
.btn {
    --bs-btn-padding-x: 14px;
    --bs-btn-padding-y: 8px;
    --bs-btn-font-size: 13.5px;
    --bs-btn-font-weight: 600;
    --bs-btn-border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: .005em;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
    white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--ring); }

.btn-sm { min-height: 32px; --bs-btn-padding-x: 11px; --bs-btn-padding-y: 5px; --bs-btn-font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-lg { min-height: 48px; --bs-btn-font-size: 15px; --bs-btn-padding-x: 20px; }
.btn-icon { width: 40px; padding: 0 !important; }
.btn-sm.btn-icon { width: 32px; }

.btn-primary,
.btn-brand,
.custombtnx1,
.hover1,
.anty {
    --bs-btn-color: var(--brand-contrast);
    --bs-btn-bg: var(--brand-ink);
    --bs-btn-border-color: var(--brand-ink);
    --bs-btn-hover-color: var(--brand-contrast);
    --bs-btn-hover-bg: var(--brand-700);
    --bs-btn-hover-border-color: var(--brand-700);
    --bs-btn-active-bg: var(--brand-800);
    --bs-btn-active-border-color: var(--brand-800);
    --bs-btn-active-color: var(--brand-contrast);
    --bs-btn-disabled-bg: var(--brand-300);
    --bs-btn-disabled-border-color: var(--brand-300);
    background: var(--brand-ink) !important;
    border-color: var(--brand-ink) !important;
    color: #fff !important;
}

.btn-primary:hover,
.btn-brand:hover,
.custombtnx1:hover,
.hover1:hover,
.anty:hover { background: var(--brand-700) !important; border-color: var(--brand-700) !important; color: #fff !important; }

.btn-accent {
    --bs-btn-color: var(--accent-contrast);
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-700);
    --bs-btn-hover-border-color: var(--accent-700);
    --bs-btn-hover-color: var(--accent-contrast);
}

.btn-light,
.btn-white,
.btn-outline-secondary,
.btn-secondary,
.custombtnx2 {
    --bs-btn-color: var(--text);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-color: var(--text);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-border-color: #c6d0dc;
    --bs-btn-active-bg: var(--neutral-bg);
    --bs-btn-active-border-color: #c6d0dc;
    --bs-btn-active-color: var(--text);
}

.btn-secondary { --bs-btn-bg: var(--neutral-bg); --bs-btn-border-color: var(--neutral-bg); }

.btn-outline-primary {
    --bs-btn-color: var(--brand-ink);
    --bs-btn-border-color: rgba(var(--brand-rgb), .4);
    --bs-btn-hover-bg: var(--brand-50);
    --bs-btn-hover-color: var(--brand-ink);
    --bs-btn-hover-border-color: rgba(var(--brand-rgb), .6);
    --bs-btn-active-bg: var(--brand-100);
    --bs-btn-active-color: var(--brand-ink);
    --bs-btn-active-border-color: rgba(var(--brand-rgb), .6);
}

.btn-success {
    --bs-btn-bg: var(--success);
    --bs-btn-border-color: var(--success);
    --bs-btn-hover-bg: #0e6a4c;
    --bs-btn-hover-border-color: #0e6a4c;
}

.btn-danger {
    --bs-btn-bg: var(--danger);
    --bs-btn-border-color: var(--danger);
    --bs-btn-hover-bg: #a21f33;
    --bs-btn-hover-border-color: #a21f33;
}

.btn-warning {
    --bs-btn-color: #fff;
    --bs-btn-bg: #d97706;
    --bs-btn-border-color: #d97706;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #b45309;
    --bs-btn-hover-border-color: #b45309;
}

.btn-info {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--info);
    --bs-btn-border-color: var(--info);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #174f9f;
    --bs-btn-hover-border-color: #174f9f;
}

.btn-ghost {
    --bs-btn-color: var(--text-2);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-color: var(--text);
    --bs-btn-hover-border-color: var(--border);
}

.btn-whatsapp {
    --bs-btn-color: #fff;
    --bs-btn-bg: #1f9d55;
    --bs-btn-border-color: #1f9d55;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #187e44;
    --bs-btn-hover-border-color: #187e44;
}

.btn-link { --bs-btn-color: var(--brand-ink); --bs-btn-hover-color: var(--brand-700); min-height: auto; }

.btn-close:focus { box-shadow: var(--ring); }

/* legacy "rounded 18px" inputs */
.nouvo { border-radius: 10px !important; }

/* 10. Tabs & segmented ----------------------------------------------------------- */
.nav-tabs {
    border-bottom: 1px solid var(--border);
    gap: 4px;
}

.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--muted);
    font-weight: 600;
    font-size: 13.5px;
    padding: 10px 12px;
    margin-bottom: -1px;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.nav-tabs .nav-link:hover { color: var(--text); border-color: var(--border-strong); }
.nav-tabs .nav-link.active { color: var(--brand-ink); border-bottom-color: var(--brand); background: transparent; }

.nav-pills .nav-link { border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: 13.5px; }
.nav-pills .nav-link.active { background: var(--brand-ink); color: #fff; }

.segmented {
    display: inline-flex;
    background: var(--neutral-bg);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.segmented button,
.segmented a {
    border: 0;
    background: transparent;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.segmented .active {
    background: #fff;
    color: var(--text);
    box-shadow: var(--shadow-xs);
}

/* dropdowns */
.dropdown-menu {
    --bs-dropdown-link-active-bg: var(--brand-100);
    --bs-dropdown-link-active-color: var(--brand-ink);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 6px;
    font-size: 13.5px;
}

.dropdown-item {
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown-item i { width: 16px; text-align: center; color: var(--muted); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2) !important; color: var(--text); }
.dropdown-item.active, .dropdown-item:active { background: var(--brand-100) !important; color: var(--brand-ink) !important; }
.dropdown-header { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 700; padding: 6px 10px; }
.dropdown-divider { border-color: var(--border); margin: 6px 0; }

/* 11. Modals --------------------------------------------------------------------------- */
.modal { --bs-modal-border-radius: var(--radius-lg); --bs-modal-inner-border-radius: calc(var(--radius-lg) - 1px); }

.modal-content {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: #fff;
    align-items: center;
}

.modal-title {
    font-size: 17px;
    font-weight: 750;
    font-family: var(--font-display);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); gap: 8px; }
.modal-backdrop.show { opacity: .42; }
.modal-backdrop { --bs-backdrop-bg: #0b1626; }

/* SweetAlert2 */
.swal2-popup {
    border-radius: 18px !important;
    font-family: var(--font) !important;
    padding: 1.6em 1.4em 1.4em !important;
}

.swal2-title { font-family: var(--font-display) !important; font-size: 1.3em !important; color: var(--text) !important; }
.swal2-html-container { color: var(--text-2) !important; font-size: 1em !important; }
.swal2-styled.swal2-confirm { background: var(--brand-ink) !important; border-radius: 10px !important; font-weight: 600 !important; box-shadow: none !important; }
.swal2-styled.swal2-cancel { background: #fff !important; color: var(--text) !important; border: 1px solid var(--border-strong) !important; border-radius: 10px !important; font-weight: 600 !important; }
.swal2-styled.swal2-deny { border-radius: 10px !important; }
.swal2-icon { transform: scale(.85); }

/* 12. Badges & pills --------------------------------------------------------------- */
.badge {
    font-weight: 650;
    border-radius: 999px;
    padding: .38em .7em;
    font-size: 11.5px;
    letter-spacing: .01em;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--neutral-bg);
    color: var(--text-2);
    border: 1px solid transparent;
}

.pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .85;
}

.pill.no-dot::before { display: none; }
.pill-success { background: var(--success-bg); color: var(--success); border-color: rgba(18, 128, 92, .14); }
.pill-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(180, 83, 9, .14); }
.pill-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(192, 40, 61, .14); }
.pill-info { background: var(--info-bg); color: var(--info); border-color: rgba(29, 100, 200, .14); }
.pill-brand { background: var(--brand-50); color: var(--brand-ink); border-color: rgba(var(--brand-rgb), .14); }
.pill-accent { background: var(--accent-50); color: var(--accent-700); border-color: rgba(var(--accent-rgb), .18); }

.bg-primary { background-color: var(--brand) !important; }
.text-primary { color: var(--brand-ink) !important; }
.border-primary { border-color: var(--brand) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted, .text-secondary { color: var(--muted) !important; }
.bg-light, .bg-body-tertiary { background-color: var(--surface-2) !important; }

/* 13. Feedback ------------------------------------------------------------------------- */
.alert {
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13.5px;
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.alert-success { background: var(--success-bg); color: #0b5e43; border-color: rgba(18, 128, 92, .2); }
.alert-danger { background: var(--danger-bg); color: #8f1d2e; border-color: rgba(192, 40, 61, .2); }
.alert-warning { background: var(--warning-bg); color: #8a4207; border-color: rgba(180, 83, 9, .22); }
.alert-info, .alert-primary { background: var(--info-bg); color: #164e9c; border-color: rgba(29, 100, 200, .2); }

.notice-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    margin-bottom: 18px;
    border-radius: var(--radius);
    font-size: 13.5px;
    background: var(--info-bg);
    color: #164e9c;
    border: 1px solid rgba(29, 100, 200, .2);
}

.notice-banner.is-success { background: var(--success-bg); color: #0b5e43; border-color: rgba(18, 128, 92, .2); }
.notice-banner.is-error { background: var(--danger-bg); color: #8f1d2e; border-color: rgba(192, 40, 61, .2); }
.notice-banner .close { margin-left: auto; background: transparent; border: 0; color: inherit; opacity: .6; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

.empty-state .es-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--brand-50);
    color: var(--brand-ink);
    display: grid;
    place-items: center;
    font-size: 22px;
    margin: 0 auto 12px;
}

.empty-state h4 { color: var(--text); font-size: 15px; margin-bottom: 4px; }

.skeleton {
    background: linear-gradient(90deg, #eef2f6 25%, #f6f8fb 37%, #eef2f6 63%);
    background-size: 400% 100%;
    animation: skeleton 1.3s ease infinite;
    border-radius: 8px;
    min-height: 14px;
}

@keyframes skeleton {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-item {
    pointer-events: auto;
    min-width: 280px;
    max-width: 380px;
    background: #0f1b2d;
    color: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 13.5px;
    animation: toast-in .2s ease;
}

.toast-item.is-success i { color: #4ade80; }
.toast-item.is-error i { color: #f87171; }
.toast-item.is-info i { color: #93c5fd; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--accent);
    z-index: 3000;
    transition: width .3s ease, opacity .3s ease;
}

/* AI assistant drawer */
.ai-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1030;
    height: 48px;
    padding: 0 18px 0 14px;
    border-radius: 999px;
    border: 0;
    background: var(--brand-ink);
    color: #fff;
    font-weight: 650;
    font-size: 13.5px;
    box-shadow: var(--shadow-lg);
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.ai-fab:hover { background: var(--brand-700); }

.ai-panel {
    position: fixed;
    right: 22px;
    bottom: 82px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    z-index: 1031;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.ai-panel.open { display: flex; }

.ai-panel header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-panel header .ai-badge {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff;
    display: grid;
    place-items: center;
}

.ai-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--surface-2);
}

.ai-msg {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ai-msg.user { align-self: flex-end; background: var(--brand-ink); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-msg.typing { color: var(--muted); font-style: italic; }

.ai-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.ai-input textarea {
    flex: 1;
    min-height: 42px !important;
    max-height: 120px;
    resize: none;
    border-radius: 12px !important;
}

.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; background: var(--surface-2); }
.ai-suggest button { border: 1px solid var(--border); background: #fff; border-radius: 999px; font-size: 12px; padding: 4px 10px; color: var(--text-2); }
.ai-msg ul { margin: 4px 0 4px 16px; padding: 0; }
.ai-msg li { margin: 2px 0; }
.ai-msg code { font-size: 12px; background: rgba(0, 0, 0, .05); padding: 1px 4px; border-radius: 4px; }
.ai-suggest button:hover { border-color: rgba(var(--brand-rgb), .4); color: var(--brand-ink); }

/* chat (WhatsApp console) */
.chat-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    height: calc(100vh - var(--topbar-h) - 140px);
    min-height: 520px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
}

.chat-list { border-right: 1px solid var(--border); overflow-y: auto; }
.chat-list .chat-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.chat-list .chat-item:hover { background: var(--surface-2); }
.chat-list .chat-item.active { background: var(--brand-50); }
.chat-thread { display: flex; flex-direction: column; min-width: 0; }
.chat-thread .thread-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.chat-thread .thread-body { flex: 1; overflow-y: auto; padding: 18px; background: #efeae2; display: flex; flex-direction: column; gap: 6px; }
.chat-thread .bubble { max-width: 72%; padding: 7px 10px 18px; border-radius: 10px; font-size: 13.5px; position: relative; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); }
.chat-thread .bubble.in { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.chat-thread .bubble.out { align-self: flex-end; background: #d9fdd3; border-top-right-radius: 2px; }
.chat-thread .bubble .meta { position: absolute; right: 8px; bottom: 3px; font-size: 10.5px; color: #667781; }
.chat-thread .thread-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: #f0f2f5; }

/* 14. Auth pages ---------------------------------------------------------------------- */
.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    background: #fff;
}

.auth-aside {
    position: relative;
    background: var(--sidebar-bg);
    color: #fff;
    padding: 44px 52px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.auth-aside::before {
    content: "";
    position: absolute;
    inset: auto -20% -35% auto;
    width: 640px;
    height: 640px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(var(--accent-rgb), .38), transparent);
    pointer-events: none;
}

.auth-aside::after {
    content: "";
    position: absolute;
    inset: -30% auto auto -25%;
    width: 560px;
    height: 560px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(255, 255, 255, .08), transparent);
    pointer-events: none;
}

.auth-aside > * { position: relative; z-index: 1; }

.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand .brand-mark { width: 46px; height: 46px; flex-basis: 46px; border-radius: 13px; }
.auth-brand .brand-name { font-size: 18px; color: #fff; }
.auth-brand .brand-tag { color: rgba(255, 255, 255, .6); }

.auth-pitch h2 {
    color: #fff;
    font-size: 2.3rem;
    line-height: 1.15;
    letter-spacing: -.03em;
    font-weight: 800;
    max-width: 520px;
}

.auth-pitch p { color: rgba(255, 255, 255, .72); font-size: 15px; max-width: 480px; }

.auth-features { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; max-width: 460px; }
.auth-features li { display: flex; gap: 12px; align-items: center; color: rgba(255, 255, 255, .86); font-size: 14px; }
.auth-features li i { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .1); display: grid; place-items: center; color: #fff; flex: 0 0 34px; }

.auth-foot { color: rgba(255, 255, 255, .5); font-size: 12.5px; }

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.75rem; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); font-size: 14.5px; margin-bottom: 26px; }
.auth-card .form-control { min-height: 46px; font-size: 14.5px; }
.auth-card .btn { min-height: 46px; font-size: 14.5px; width: 100%; }
.auth-card .company-logo { height: 54px; max-width: 220px; object-fit: contain; margin-bottom: 22px; }

.pw-field { position: relative; }
.pw-field .toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); width: 36px; height: 36px; border-radius: 8px; }
.pw-field .toggle:hover { background: var(--surface-2); color: var(--text); }

.lang-switch { display: inline-flex; gap: 2px; background: var(--neutral-bg); border-radius: 8px; padding: 2px; }
.lang-switch a { padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.lang-switch a.active { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); }

/* public pages (careers, kiosk) */
.public-wrap { max-width: 980px; margin: 0 auto; padding: 32px 20px 64px; }
.public-header { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.public-header img { height: 52px; max-width: 200px; object-fit: contain; }

/* colour swatches (company settings) */
.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 9px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }

.theme-preview {
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    display: grid;
    grid-template-columns: 120px 1fr;
    height: 210px;
    background: #fff;
}

.theme-preview .tp-side { padding: 14px 10px; display: flex; flex-direction: column; gap: 6px; }
.theme-preview .tp-side span { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .25); }
.theme-preview .tp-side span.on { background: rgba(255, 255, 255, .55); }
.theme-preview .tp-main { padding: 16px; background: var(--bg); display: flex; flex-direction: column; gap: 10px; }
.theme-preview .tp-title { height: 14px; width: 55%; border-radius: 4px; background: #1f2937; opacity: .85; }
.theme-preview .tp-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-preview .tp-cards div { height: 46px; border-radius: 8px; background: #fff; border: 1px solid var(--border); }
.theme-preview .tp-btn { align-self: flex-start; height: 26px; width: 110px; border-radius: 7px; }

/* company cards (platform console) */
.cc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.form-control.form-control-color { width: 46px !important; flex: 0 0 46px; height: 40px; padding: 4px; border-radius: 10px; cursor: pointer; }

.company-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .15s, transform .15s;
}

.company-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.company-card .cc-band { height: 6px; }
.company-card .cc-body { padding: 16px; display: flex; gap: 14px; align-items: center; }
.company-card .cc-logo { width: 54px; height: 54px; border-radius: 12px; border: 1px solid var(--border); display: grid; place-items: center; font-weight: 800; color: #fff; overflow: hidden; flex: 0 0 54px; }
.company-card .cc-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.company-card .cc-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); }
.company-card .cc-stats div { padding: 10px 12px; border-right: 1px solid var(--border); }
.company-card .cc-stats div:last-child { border-right: 0; }
.company-card .cc-stats b { display: block; font-family: var(--font-mono); font-size: 15px; }
.company-card .cc-stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.company-card .cc-actions { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* announcement / emergency banner (read confirmation) */
.bc-banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius); background: var(--brand-50); border: 1px solid rgba(var(--brand-rgb), .22); color: var(--text); margin-bottom: 16px; }
.bc-banner > i { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: #fff; flex: 0 0 36px; }
.bc-banner .bc-t { display: block; font-size: 14px; font-weight: 700; }
.bc-banner span { display: block; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-banner .bc-actions { margin-left: auto; display: flex; gap: 6px; flex: 0 0 auto; }
.bc-banner.is-emergency { background: var(--danger-bg); border-color: rgba(192, 40, 61, .35); }
.bc-banner.is-emergency > i { background: var(--danger); animation: bcPulse 1.6s infinite; }
@keyframes bcPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(192, 40, 61, .45); } 50% { box-shadow: 0 0 0 8px rgba(192, 40, 61, 0); } }
@media (max-width: 575.98px) { .bc-banner { flex-wrap: wrap; } .bc-banner .bc-actions { margin-left: 48px; } }

/* WhatsApp message preview (broadcasts) */
.wa-preview { background: #e5ddd5 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23d4cbc2'/%3E%3C/svg%3E"); border-radius: var(--radius); padding: 16px; min-height: 160px; }
.wa-bubble { background: #fff; border-radius: 0 10px 10px 10px; padding: 9px 11px 6px; max-width: 92%; font-size: 13.5px; line-height: 1.4; box-shadow: 0 1px 1px rgba(0, 0, 0, .08); white-space: pre-wrap; word-break: break-word; position: relative; color: #111b21; }
.wa-bubble::after { content: attr(data-time); display: block; text-align: right; font-size: 10.5px; color: #8696a0; margin-top: 2px; }

/* employee directory cards */
.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.emp-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .15s, transform .15s, border-color .15s;
}
.emp-card:hover { color: var(--text); box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: rgba(var(--brand-rgb), .3); }
.emp-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.emp-card-name { font-weight: 700; font-size: 14.5px; line-height: 1.3; }
.emp-card-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.emp-card-meta { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-2); border-top: 1px dashed var(--border); padding-top: 10px; margin-top: auto; }
.emp-card-meta span { display: flex; gap: 8px; align-items: center; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-card-meta i { width: 14px; color: var(--faint); text-align: center; flex: 0 0 14px; }

/* employee 360 profile */
.profile-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    margin-bottom: 18px;
}
.profile-hero .ph-band { height: 84px; background: linear-gradient(110deg, var(--brand) 0%, var(--brand-600) 55%, var(--accent) 140%); }
.profile-hero .ph-main { display: flex; gap: 18px; align-items: flex-end; padding: 0 22px 18px; margin-top: -40px; flex-wrap: wrap; }
.profile-hero .avatar.xl { border: 4px solid var(--surface); box-shadow: var(--shadow-sm); background: var(--brand-50); color: var(--brand-ink); }
.profile-hero .ph-id { flex: 1; min-width: 220px; padding-top: 44px; }
.profile-hero .ph-id h2 { font-size: 1.35rem; font-weight: 750; margin: 0; letter-spacing: -.01em; }
.profile-hero .ph-id .ph-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.profile-hero .ph-id .ph-meta i { margin-right: 5px; color: var(--faint); }
.profile-hero .ph-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 2px; }
.profile-hero .ph-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-top: 1px solid var(--border); }
.profile-hero .ph-stats > div { padding: 12px 18px; border-right: 1px solid var(--border); }
.profile-hero .ph-stats > div:last-child { border-right: 0; }
.profile-hero .ph-stats b { display: block; font-size: 16px; font-weight: 700; }
.profile-hero .ph-stats span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.profile-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.profile-tabs::-webkit-scrollbar { display: none; }
.profile-tabs button { border: 0; background: none; padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.profile-tabs button:hover { color: var(--text); }
.profile-tabs button.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.profile-tabs button .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--neutral-bg); font-size: 11px; margin-left: 4px; color: var(--text-2); }
.tab-pane-x { display: none; }
.tab-pane-x.active { display: block; }
.mini-stat { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.mini-stat .ms-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-ink); flex: 0 0 38px; }
.mini-stat b { display: block; font-size: 17px; line-height: 1.2; }
.mini-stat span { font-size: 12px; color: var(--muted); }
.att-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.att-cal .d { aspect-ratio: 1 / 1; border-radius: 8px; display: grid; place-items: center; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--faint); border: 1px solid var(--border); position: relative; }
.att-cal .d.present { background: var(--success-bg); color: var(--success); border-color: transparent; }
.att-cal .d.late { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.att-cal .d.absent { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.att-cal .d.leave { background: var(--info-bg); color: var(--info); border-color: transparent; }
.att-cal .d.today { outline: 2px solid var(--brand); outline-offset: 1px; }
.att-cal .h { font-size: 11px; text-transform: uppercase; color: var(--muted); text-align: center; font-weight: 600; }
.att-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.att-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.doc-tile { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--surface); }
.doc-tile:hover { border-color: rgba(var(--brand-rgb), .35); color: var(--text); background: var(--surface-2); }
.doc-tile .dt-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--danger-bg); color: var(--danger); flex: 0 0 38px; font-size: 16px; }
.doc-tile .dt-icon.img { background: var(--info-bg); color: var(--info); }
.doc-tile .dt-icon.xls { background: var(--success-bg); color: var(--success); }
.payslip-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr auto; gap: 12px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); }
.payslip-row:first-child { border-top: 0; }
@media (max-width: 767.98px) {
    .payslip-row { grid-template-columns: 1fr 1fr; }
    .profile-hero .ph-main { padding: 0 16px 16px; }
    .profile-hero .ph-stats { grid-template-columns: repeat(2, 1fr); }
}

/* steps (wizards) */
.steps { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.steps .step { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--neutral-bg); }
.steps .step b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--text-2); font-size: 12px; }
.steps .step.active { background: var(--brand-50); color: var(--brand-ink); }
.steps .step.active b { background: var(--brand-ink); color: #fff; }
.steps .step.done b { background: var(--success); color: #fff; }

/* drop zone (Excel import) */
.dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 36px 20px;
    text-align: center;
    background: var(--surface-2);
    transition: border-color .15s, background .15s;
    cursor: pointer;
}

.dropzone:hover, .dropzone.drag { border-color: rgba(var(--brand-rgb), .6); background: var(--brand-50); }
.dropzone i { font-size: 30px; color: var(--brand-ink); margin-bottom: 10px; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ""; position: absolute; left: 2px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); }
.timeline .t-time { font-size: 11.5px; color: var(--muted); }

/* employee badge (print) keep legacy look inside modals */
.badge-card { box-shadow: var(--shadow-sm); }

/* 15. Utilities, print, responsive ------------------------------------------------- */
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.fw-650 { font-weight: 650 !important; }
.fs-12 { font-size: 12px !important; }
.fs-13 { font-size: 13px !important; }
.text-2 { color: var(--text-2) !important; }
.text-faint { color: var(--faint) !important; }
.bg-surface { background: var(--surface) !important; }
.rounded-xl { border-radius: var(--radius) !important; }
.minw-0 { min-width: 0 !important; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cursor-pointer { cursor: pointer; }
.hidden-i { display: none !important; }

.divider-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--faint);
    font-size: 12px;
    margin: 18px 0;
}

.divider-label::before,
.divider-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.key-value { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 13.5px; }
.key-value dt { color: var(--muted); font-weight: 500; }
.key-value dd { margin: 0; color: var(--text); font-weight: 500; }

.code-box {
    background: #0f1b2d;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    overflow-x: auto;
    white-space: pre;
}

@media (max-width: 1280px) {
    .app-content { padding: 24px 22px 40px; }
}

@media (max-width: 1100px) {
    .grid-main-side, .grid-side-main, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 991.98px) {
    :root { --sidebar-w: 280px; }
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .app-main { margin-left: 0; }
    .topbar { padding: 0 14px; }
    .topbar .menu-toggle { display: inline-grid; place-items: center; }
    .chip-env, .company-switch .cs-name { display: none; }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .auth { grid-template-columns: minmax(0, 1fr); }
    .auth-aside { display: none; }
    .chat-layout { grid-template-columns: minmax(0, 1fr); }
    .chat-layout .chat-list { display: none; }
    .chat-layout.show-list .chat-list { display: block; }
    .chat-layout.show-list .chat-thread { display: none; }
}

@media (max-width: 640px) {
    .app-content { padding: 18px 14px 32px; }
    .page-head h1 { font-size: 1.55rem; }
    .global-search { flex-basis: 100%; }
    .global-search .kbd { display: none; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .kpi-value { font-size: 1.25rem; }
    .key-value { grid-template-columns: 1fr; }
    .ai-panel { right: 8px; bottom: 76px; width: calc(100vw - 16px); }
    .table > :not(caption) > * > * { padding: 10px; }
}

@media print {
    .sidebar, .topbar, .ai-fab, .ai-panel, .no-print, .toast-stack, .sidebar-backdrop { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .app-content { padding: 0 !important; max-width: none !important; }
    body { background: #fff !important; }
    .card, .panel, .kpi, .table-wrap { box-shadow: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* KPI tile whose value is a word rather than a number */
.kpi-value .kpi-text { font-family: var(--font-display); font-size: 20px; font-weight: 750; letter-spacing: -.01em; }

/* ==========================================================================
 * Payroll screens (view/pm.php, view/psm.php, view/ph.php)
 * ======================================================================= */
.pay-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
@media (max-width: 1100px) { .pay-grid { grid-template-columns: 1fr; } }
.pay-grid .card { margin: 0; }
.pay-sub { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
.pay-sub:first-child { margin-top: 0; }
.pay-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pay-chip { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; user-select: none; transition: background .12s, border-color .12s, color .12s; }
.pay-chip:hover { border-color: var(--border-strong); }
.pay-chip input { position: absolute; opacity: 0; pointer-events: none; }
.pay-chip i { font-size: 12px; color: var(--muted); }
.pay-chip small { font-weight: 600; color: var(--muted); }
.pay-chip:has(input:checked) { background: var(--brand-50); border-color: rgba(var(--brand-rgb), .45); color: var(--brand-ink); }
.pay-chip:has(input:checked) i { color: var(--brand-ink); }
.pay-chip:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .2); }
.pay-chip.is-tax:has(input:checked) { background: var(--accent-50); border-color: rgba(var(--accent-rgb), .5); color: var(--accent-700); }
.pay-chip.is-tax:has(input:checked) i, .pay-chip.is-tax:has(input:checked) small { color: var(--accent-700); }
.pay-emp td, .pay-emp th { white-space: nowrap; }
.pay-emp td.num, .pay-emp th.num, .pay-res td.num, .pay-res th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pay-emp tr.is-off td { opacity: .45; }
.pay-emp tbody tr { cursor: pointer; }
.pay-emp tbody tr:hover td { background: var(--surface-2); }
.pay-emp .form-check-input { margin: 0; cursor: pointer; }
.pay-emp .emp-name { font-weight: 650; color: var(--text); }
.pay-emp .emp-meta { font-size: 12px; color: var(--muted); }
.pay-scroll { position: relative; max-height: 520px; overflow: auto; }   /* relative: absolutely positioned children (visually-hidden labels) stay inside the scroll box */
.pay-scroll thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); box-shadow: inset 0 -1px 0 var(--border); }
.pay-bar { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 18px 0; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 10px 30px rgba(15, 23, 42, .10); }
@media (min-width: 768px) { .pay-bar { margin-right: 180px; } }
@media (max-width: 767.98px) { .pay-bar { padding-right: 76px; } .pay-bar .pay-total { flex-basis: 100%; } }
.pay-bar .pay-count { font-weight: 650; }
.pay-bar .pay-total { font-size: 13px; color: var(--muted); }
.pay-bar .pay-total b { color: var(--text); font-variant-numeric: tabular-nums; }
.pay-res th { font-size: 11.5px; }
.pay-res tfoot td, .pay-res tfoot th { font-weight: 750; background: var(--surface-2); }
.pay-res td.net { font-weight: 750; color: var(--brand-ink); }
.pay-res .detail-row td { background: var(--surface-2); font-size: 12.5px; color: var(--text-2); white-space: normal; }
.pay-res .detail-row ul { margin: 0; padding-left: 18px; columns: 2; column-gap: 32px; }
@media (max-width: 768px) { .pay-res .detail-row ul { columns: 1; } }
.pay-stale { opacity: .55; filter: grayscale(.4); }
.pay-edit { border: 0; background: transparent; color: var(--muted); padding: 0 4px; }
.pay-edit:hover { color: var(--brand-ink); }
/* monthly batch table */
.pm-table td, .pm-table th { white-space: nowrap; vertical-align: middle; }
.pm-table th.gain { background: color-mix(in srgb, var(--success-bg) 70%, var(--surface)); }
.pm-table th.deduc { background: color-mix(in srgb, var(--danger-bg) 70%, var(--surface)); }
.pm-table th.total { background: var(--brand-50); }
.pm-table td.total { background: color-mix(in srgb, var(--brand-50) 55%, var(--surface)); font-weight: 650; font-variant-numeric: tabular-nums; }
.pm-table input.montant { width: 104px; text-align: right; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.pm-table .col-nom { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 210px; box-shadow: inset -1px 0 0 var(--border); }
.pm-table thead .col-nom { z-index: 3; }
.pm-table td.calc { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

/* =========================================================================
 * Badges & RFID cards (view/badges.php)
 * ======================================================================= */
.bdg-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; margin-bottom: 18px; align-items: start; }
@media (max-width: 1100px) { .bdg-top { grid-template-columns: 1fr; } }
.bdg-top .card { margin: 0; }
.bdg-orient { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bdg-o { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s; }
.bdg-o input { position: absolute; opacity: 0; pointer-events: none; }
.bdg-o b { display: block; font-size: 14px; }
.bdg-o small { display: block; font-size: 12px; color: var(--muted); }
.bdg-o .ico { flex: 0 0 auto; border: 2px solid var(--border-strong); border-radius: 5px; background: linear-gradient(var(--brand) 0 32%, transparent 32%); }
.bdg-o .ico.land { width: 44px; height: 28px; }
.bdg-o .ico.port { width: 28px; height: 44px; }
.bdg-o:has(input:checked) { border-color: rgba(var(--brand-rgb), .55); background: var(--brand-50); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .12); }
.bdg-o:has(input:checked) .ico { border-color: var(--brand); }
.bdg-o:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .3); }
.bdg-frame { width: 100%; aspect-ratio: 181.2 / 60; max-height: 420px; border-radius: 14px; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 18px 18px; border: 1px solid var(--border); overflow: hidden; }
.bdg-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.bdg-table tr.is-current td { background: color-mix(in srgb, var(--brand-50) 70%, var(--surface)); }
.bdg-rfid { position: relative; display: flex; align-items: center; gap: 8px; }
.bdg-rfid > i { color: var(--muted); font-size: 13px; transform: rotate(90deg); }
.bdg-rfid input { max-width: 200px; letter-spacing: .04em; }
.bdg-rfid input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .18); }
.bdg-st { width: 18px; text-align: center; font-size: 13px; }
.bdg-st.is-busy::before { content: ""; display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; animation: bdg-spin .7s linear infinite; }
.bdg-st.is-ok::before { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; color: var(--success); }
.bdg-st.is-err::before { content: "\f071"; font-family: "Font Awesome 6 Free"; font-weight: 900; color: var(--danger); }
@keyframes bdg-spin { to { transform: rotate(360deg); } }
/* small screens: long segmented filters scroll instead of widening the page */
.segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button, .segmented a { white-space: nowrap; flex: 0 0 auto; }
