/* ============================================================
   Light admin theme — navy sidebar + white top bar + light body.
   Layered on top of Bootstrap 5 + Tailwind so existing markup
   (.btn, .card, .table, .form-control, .alert) re-skins itself.
   ============================================================ */

:root,
html,
[data-bs-theme="dark"] {
    /* Dark theme — surfaces */
    --background: #0f172a;          /* slate-900 — page bg */
    --surface: #1e293b;             /* slate-800 — cards, header, modals */
    --surface-alt: #15203a;         /* between bg and surface */
    --foreground: #e2e8f0;          /* slate-200 — primary text */
    --muted-foreground: #94a3b8;    /* slate-400 — muted text */
    --border: #334155;              /* slate-700 */
    --border-strong: #475569;       /* slate-600 */

    /* Brand */
    --primary: #38bdf8;             /* sky-400 — brighter for dark bg */
    --primary-hover: #0ea5e9;
    --primary-foreground: #0f172a;
    --accent: #22d3ee;
    --success: #10b981;
    --success-hover: #059669;
    --info: #38bdf8;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --secondary: #64748b;

    /* Sidebar matches the right-side content (dark theme) */
    --sidebar: #15203a;
    --sidebar-darker: #0f172a;
    --sidebar-foreground: #e2e8f0;
    --sidebar-muted: #94a3b8;
    --sidebar-section: #64748b;
    --sidebar-hover: #1e293b;
    --sidebar-active: rgba(56,189,248,0.12);
    --sidebar-accent: var(--primary);
    --sidebar-border: #334155;

    --topbar: #1e293b;
    --topbar-border: #334155;

    --radius: 4px;
    --radius-sm: 3px;
    --radius-lg: 6px;

    /* Bootstrap overrides */
    --bs-body-bg: var(--background);
    --bs-body-color: var(--foreground);
    --bs-border-color: var(--border);
    --bs-secondary-bg: var(--surface-alt);
    --bs-tertiary-bg: var(--background);
    --bs-emphasis-color: var(--foreground);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-hover);
}

* { box-sizing: border-box; }
html, body { background: var(--background); color: var(--foreground); }
body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 13px;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.55;
}

h1, h2, h3, h4, h5, h6 { color: var(--foreground); font-weight: 500; margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: none; }
hr { border-color: var(--border); opacity: 1; }

/* Scrollbar */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #cbd0d8; border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: #aab0bb; }

/* ---------- Layout shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--background);
}
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 230px;
    background: var(--sidebar);
    border-right: 1px solid var(--sidebar-border, var(--border));
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transform: translateX(0);
    transition: transform .25s ease, width .25s ease;
}
.app-main {
    margin-left: 230px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left .3s ease;
}
.app-header {
    position: sticky; top: 0; z-index: 1030;
    height: 55px;
    background: var(--topbar);
    border-bottom: 1px solid var(--topbar-border);
    display: flex; align-items: center;
    padding: 0 18px;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.app-content {
    flex: 1;
    padding: 20px 22px 32px;
}

/* Desktop: full-width collapse toggle — slide the whole sidebar off-screen and
   let the main content reclaim the space, with smooth easing. */
@media (min-width: 1025px) {
    body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
    body.sidebar-collapsed .app-main { margin-left: 0; }
}

@media (max-width: 1024px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.expanded { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-sidebar.expanded ~ .app-main::before {
        content: ''; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
        z-index: 1035;
    }
}

/* ---------- Sidebar (light, matches main content) ---------- */
.sb-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 0 16px;
    height: 55px;
    background: var(--sidebar-darker);
    border-bottom: 1px solid var(--sidebar-border, var(--border));
    flex-shrink: 0;
}
.sb-brand-mark {
    width: 32px; height: 32px; border-radius: 6px;
    background: var(--sidebar-accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    flex-shrink: 0;
}
.sb-brand-text { line-height: 1.15; min-width: 0; }
.sb-brand-text .title { font-weight: 600; color: var(--foreground); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-brand-text .subtitle { color: var(--sidebar-muted); font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; }

.sb-nav { flex: 1; overflow-y: auto; padding: 6px 0 12px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--border-strong, #d1d5db); }

.sb-group { margin: 4px 0 0; }
.sb-group-label {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 6px;
    font-size: 10.5px; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--sidebar-section);
    background: transparent; border: none; width: 100%;
    cursor: pointer;
}
.sb-group-label:hover { color: var(--foreground); }
.sb-group-label .chev { transition: transform .2s ease; font-size: 9px; opacity: .55; }
.sb-group.collapsed .chev { transform: rotate(-90deg); }
.sb-group.collapsed .sb-items { display: none; }

.sb-items { display: flex; flex-direction: column; }
.sb-item, a.sb-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 16px;
    color: var(--sidebar-foreground);
    text-decoration: none;
    font-size: 13px; font-weight: 500;
    transition: background .12s ease, color .12s ease;
    position: relative;
    border-left: 3px solid transparent;
}
.sb-item i { width: 16px; text-align: center; font-size: 13px; color: var(--sidebar-muted); transition: color .12s; }
.sb-item:hover { background: var(--sidebar-hover); color: var(--foreground); }
.sb-item:hover i { color: var(--foreground); }
.sb-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-accent);
    border-left-color: var(--sidebar-accent);
    font-weight: 600;
}
.sb-item.active i { color: var(--sidebar-accent); }
.sb-item .sb-badge {
    margin-left: auto;
    background: var(--sidebar-accent);
    color: #fff;
    font-size: 10px; font-weight: 600;
    padding: 1px 7px; border-radius: 10px;
}
.sb-item .sb-chev { margin-left: auto; font-size: 10px; opacity: .55; transition: transform .2s ease; }
.sb-item.open .sb-chev { transform: rotate(180deg); }
.sb-submenu {
    display: none; flex-direction: column;
    background: var(--sidebar-darker);
    border-top: 1px solid var(--sidebar-border, var(--border));
    border-bottom: 1px solid var(--sidebar-border, var(--border));
}
.sb-item.open + .sb-submenu { display: flex; }
.sb-sub {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px 8px 46px;
    color: var(--sidebar-muted);
    text-decoration: none;
    font-size: 12.5px;
    transition: background .12s, color .12s;
    border-left: 3px solid transparent;
}
.sb-sub i { font-size: 11px; width: 14px; }
.sb-sub:hover { color: var(--foreground); background: var(--sidebar-hover); }
.sb-sub.active { color: var(--sidebar-accent); background: var(--sidebar-active); border-left-color: var(--sidebar-accent); font-weight: 600; }

.sb-footer {
    background: var(--sidebar-darker);
    padding: 10px 12px;
    display: flex; align-items: center; gap: 10px;
}
.sb-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--sidebar-accent);
    color: #fff; font-weight: 600; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sb-userinfo { line-height: 1.2; flex: 1; min-width: 0; overflow: hidden; }
.sb-userinfo .name { color: #fff; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-userinfo .role { color: var(--sidebar-muted); font-size: 10.5px; }
.sb-logout {
    background: transparent; border: 1px solid transparent;
    color: var(--sidebar-muted);
    width: 30px; height: 30px; border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .12s;
}
.sb-logout:hover { color: #fff; background: rgba(255,255,255,0.05); }

/* ---------- Top bar ---------- */
.hdr-toggle {
    display: inline-flex;
    background: transparent; border: none;
    color: var(--muted-foreground);
    width: 34px; height: 34px; border-radius: var(--radius);
    align-items: center; justify-content: center;
    cursor: pointer; transition: background .12s;
}
.hdr-toggle:hover { background: var(--surface-alt); color: var(--foreground); }

.hdr-quick {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--radius);
    background: var(--success); color: #fff;
    border: none; cursor: pointer;
    transition: background .12s;
}
.hdr-quick:hover { background: var(--success-hover); color: #fff; }

.hdr-search {
    flex: 1; max-width: 520px; min-width: 200px;
    display: flex; align-items: center; gap: 10px;
    height: 38px; padding: 0 6px 0 14px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted-foreground);
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
    margin-left: 6px;
    box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
/* Undo Tailwind preflight that sets --tw-content:'' on every ::before,
   which wipes Font Awesome glyph content. */
.fa, .fas, .far, .fab, .fal, .fad, .fa-solid, .fa-regular, .fa-brands,
[class^="fa-"], [class*=" fa-"] { --tw-content: unset !important; }
.fa::before, .fas::before, .far::before, .fab::before, .fal::before, .fad::before,
.fa-solid::before, .fa-regular::before, .fa-brands::before,
[class^="fa-"]::before, [class*=" fa-"]::before {
    --tw-content: unset !important;
}

.hdr-search > i.fa-magnifying-glass {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(3,169,244,0.10); color: var(--primary, #03a9f4);
    border-radius: 50%; font-size: 13px; font-weight: 900;
    flex-shrink: 0;
    transition: background .15s, color .15s, transform .15s;
}
.hdr-search:hover {
    border-color: var(--primary, #03a9f4);
    box-shadow: 0 1px 2px rgba(15,23,42,0.06), 0 0 0 3px rgba(3,169,244,0.08);
}
.hdr-search:hover > i.fa-magnifying-glass {
    background: var(--primary, #03a9f4); color: #fff; transform: scale(1.05);
}
.hdr-search .hdr-search-text {
    flex: 1; text-align: left; color: var(--muted-foreground);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-weight: 400; letter-spacing: .01em;
    background: transparent !important; opacity: 1 !important;
    min-height: auto !important;
}
.hdr-search .kbd {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 3px 8px; border-radius: 6px;
    background: var(--surface); color: var(--muted-foreground);
    font-size: 11px; font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Liberation Sans", Roboto, "Noto Sans", sans-serif;
    border: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(15,23,42,0.04);
    flex-shrink: 0; letter-spacing: .02em;
}
@media (max-width: 900px) {
    .hdr-search { max-width: 320px; }
}
@media (max-width: 640px) {
    .hdr-search .hdr-search-text { display: none; }
    .hdr-search { padding: 0 10px; max-width: 64px; }
    .hdr-search .kbd { display: none; }
}

.hdr-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.hdr-btn {
    background: transparent; border: 1px solid transparent;
    color: var(--muted-foreground);
    width: 36px; height: 36px; border-radius: var(--radius);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .12s;
    position: relative;
    text-decoration: none;
}
.hdr-btn:hover { background: #f1f3f6; color: var(--foreground); }
.hdr-btn .dot {
    position: absolute; top: 7px; right: 8px;
    min-width: 14px; height: 14px; padding: 0 3px;
    border-radius: 7px;
    background: var(--danger);
    color: #fff; font-size: 9px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
}
.hdr-cta {
    display: inline-flex; align-items: center; gap: 6px;
    background: #047857;            /* deeper emerald so white label is readable (AA) */
    color: #fff;
    border: none;
    padding: 7px 14px; border-radius: var(--radius);
    font-size: 12.5px; font-weight: 600;
    cursor: pointer; transition: background .12s;
    text-decoration: none;
}
.hdr-cta:hover { background: #065f46; color: #fff; }
.hdr-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary);
    color: var(--primary-foreground); font-weight: 700; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; border: none;
    margin-left: 4px;
}

/* ---------- Profile dropdown ---------- */
.profile-menu {
    position: absolute; top: 46px; right: 0;
    width: 240px;
    background: var(--surface);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    overflow: hidden; z-index: 2010;
}
.profile-menu .pm-head {
    padding: 14px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}
.profile-menu .pm-head .name { color: var(--foreground); font-weight: 600; font-size: 13px; }
.profile-menu .pm-head .email { color: var(--muted-foreground); font-size: 11.5px; word-break: break-all; }
.profile-menu .pm-list { padding: 4px; }
.profile-menu .pm-list a, .profile-menu .pm-list button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
    color: var(--foreground); text-decoration: none;
    background: transparent; border: none; cursor: pointer;
    font-size: 13px; text-align: left;
    transition: background .12s;
}
.profile-menu .pm-list a:hover, .profile-menu .pm-list button:hover { background: var(--surface-alt); }
.profile-menu .pm-list i { color: var(--muted-foreground); width: 16px; text-align: center; }
.profile-menu .pm-divider { height: 1px; background: var(--border); margin: 4px 0; }
.profile-menu .pm-list .danger { color: var(--danger); }
.profile-menu .pm-list .danger i { color: var(--danger); }

/* ---------- Cards ---------- */
.card, .apx-card {
    background: var(--surface);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.card-header, .card-footer {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--foreground);
    padding: 12px 16px;
    font-weight: 500;
}
.card-title { color: var(--foreground); }

.apx-card { padding: 16px 18px; }
.apx-card-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin: -2px 0 14px; gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.apx-card-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--foreground); }
.apx-card-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted-foreground); }

/* KPI / stat card */
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.kpi-card .kpi-label { color: var(--muted-foreground); font-size: 12px; margin: 0 0 4px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.kpi-card .kpi-value { color: var(--foreground); font-size: 24px; font-weight: 600; margin: 0; }
.kpi-card .kpi-delta { margin-top: 6px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; color: var(--muted-foreground); }
.kpi-card .kpi-delta .up { color: var(--success); }
.kpi-card .kpi-delta .down { color: var(--danger); }
.kpi-card .kpi-icon {
    position: absolute; top: 16px; right: 18px;
    width: 38px; height: 38px; border-radius: 8px;
    background: rgba(3, 169, 244, 0.10);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.kpi-card.variant-blue .kpi-icon { background: rgba(3,169,244,0.10); color: var(--info); }
.kpi-card.variant-amber .kpi-icon { background: rgba(253,126,20,0.10); color: var(--warning); }
.kpi-card.variant-rose .kpi-icon { background: rgba(231,76,60,0.10); color: var(--danger); }

/* ---------- Tables ---------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--foreground);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--surface-alt);
    --bs-table-hover-bg: #f0f4f8;
    color: var(--foreground);
    border-color: var(--border);
    margin-bottom: 0;
}
.table > :not(caption) > * > * {
    background: transparent; color: var(--foreground);
    border-bottom-color: var(--border);
    padding: 11px 14px;
    vertical-align: middle;
}
.table thead th {
    background: var(--surface-alt);
    color: var(--muted-foreground);
    font-size: 11.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
}
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-alt); }

/* ---------- Buttons ---------- */
.btn {
    --bs-btn-padding-y: 6px;
    --bs-btn-padding-x: 12px;
    --bs-btn-font-size: 12.5px;
    --bs-btn-font-weight: 500;
    --bs-btn-border-radius: var(--radius);
    border-radius: var(--radius);
    transition: background .12s, border-color .12s;
    font-weight: 500;
}
.btn-primary {
    --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary);
    --bs-btn-color: var(--primary-foreground);
    --bs-btn-hover-bg: var(--primary-hover); --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-hover-color: var(--primary-foreground);
    --bs-btn-active-bg: var(--primary-hover); --bs-btn-active-border-color: var(--primary-hover);
    font-weight: 600;
}
.btn-secondary {
    --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--border-strong);
    --bs-btn-color: var(--foreground);
    --bs-btn-hover-bg: var(--border); --bs-btn-hover-border-color: var(--muted-foreground);
    --bs-btn-hover-color: var(--foreground);
    --bs-btn-active-bg: var(--border); --bs-btn-active-border-color: var(--muted-foreground);
}
.btn-success {
    --bs-btn-bg: #047857; --bs-btn-border-color: #047857;
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: #065f46; --bs-btn-hover-border-color: #065f46;
    --bs-btn-hover-color: #fff;
    font-weight: 600;
}
.btn-info {
    --bs-btn-bg: var(--info); --bs-btn-border-color: var(--info);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--primary-hover); --bs-btn-hover-border-color: var(--primary-hover);
}
.btn-warning {
    --bs-btn-bg: var(--warning); --bs-btn-border-color: var(--warning);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: #e96f00; --bs-btn-hover-border-color: #e96f00;
    --bs-btn-hover-color: #fff;
}
.btn-danger {
    --bs-btn-bg: var(--danger); --bs-btn-border-color: var(--danger);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--danger-hover); --bs-btn-hover-border-color: var(--danger-hover);
}
.btn-light, .btn-outline-secondary {
    --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--border);
    --bs-btn-color: var(--foreground);
    --bs-btn-hover-bg: var(--border); --bs-btn-hover-border-color: var(--muted-foreground);
    --bs-btn-hover-color: var(--foreground);
}
.btn-sm { --bs-btn-padding-y: 4px; --bs-btn-padding-x: 9px; --bs-btn-font-size: 12px; }

/* ---------- Forms ---------- */
.form-control, .form-select, .form-check-input {
    background: var(--surface);
    color: var(--foreground);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 13px;
    padding: 7px 11px;
    transition: border-color .12s, box-shadow .12s;
}
.form-control:focus, .form-select:focus {
    background: var(--surface);
    color: var(--foreground);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(56,189,248,0.18);
}
.form-control::placeholder { color: #9ca3af; }
.form-label { color: var(--foreground); font-weight: 500; font-size: 12.5px; margin-bottom: 4px; }
.form-text { color: var(--muted-foreground); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.input-group-text {
    background: var(--surface-alt); color: var(--muted-foreground);
    border: 1px solid var(--border-strong);
}

/* ---------- Alerts ---------- */
.alert {
    border-radius: var(--radius);
    border: 1px solid transparent;
    border-left-width: 4px;
    padding: 11px 14px;
    font-size: 13px;
}
.alert-success { background: #eaf7d8; border-color: #c8e89e; border-left-color: var(--success); color: #4f7a14; }
.alert-danger  { background: #fde8e6; border-color: #f9c4be; border-left-color: var(--danger); color: #a73224; }
.alert-warning { background: #ffefd9; border-color: #ffd9a8; border-left-color: var(--warning); color: #a35200; }
.alert-info    { background: #d8f0fb; border-color: #a8def4; border-left-color: var(--info); color: #1f7aa8; }

/* ---------- Badges & status pills ---------- */
.badge {
    font-weight: 500; font-size: 11px;
    padding: 3px 8px; border-radius: 3px;
    letter-spacing: 0;
}
.bg-primary   { background: var(--primary) !important; color: #fff !important; }
.bg-success   { background: var(--success) !important; color: #fff !important; }
.bg-danger    { background: var(--danger) !important;  color: #fff !important; }
.bg-warning   { background: var(--warning) !important; color: #fff !important; }
.bg-info      { background: var(--info) !important; color: #fff !important; }
.bg-secondary { background: #6c757d !important; color: #fff !important; }
.bg-light     { background: var(--surface-alt) !important; color: var(--foreground) !important; }
.bg-dark      { background: var(--sidebar) !important; color: #fff !important; }

.status-pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 600; text-transform: capitalize;
    line-height: 1.5; border: 1px solid transparent;
}
/* Soft, high-contrast badges: tinted bg + bright text (readable on dark) */
.status-pill.is-completed, .status-pill.is-active, .status-pill.is-paid {
    background: rgba(16,185,129,0.16); color: #34d399; border-color: rgba(16,185,129,0.35);
}
.status-pill.is-processing, .status-pill.is-pending {
    background: rgba(245,158,11,0.16); color: #fbbf24; border-color: rgba(245,158,11,0.35);
}
.status-pill.is-cancelled, .status-pill.is-inactive, .status-pill.is-failed {
    background: rgba(239,68,68,0.16); color: #f87171; border-color: rgba(239,68,68,0.35);
}
.status-pill.is-draft, .status-pill.is-new {
    background: rgba(148,163,184,0.16); color: #cbd5e1; border-color: rgba(148,163,184,0.3);
}

/* Page heading */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; font-weight: 500; color: var(--foreground); margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--muted-foreground); font-size: 12.5px; }
.page-head .actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Misc */
.text-muted, .text-secondary { color: var(--muted-foreground) !important; }
.modal-content { background: var(--surface); color: var(--foreground); border: 1px solid var(--border); border-radius: var(--radius); }
.modal-header, .modal-footer { border-color: var(--border); }
.modal-header .btn-close { filter: invert(1) brightness(1.2); }
.dropdown-menu {
    background: var(--surface); color: var(--foreground);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 6px 16px rgba(0,0,0,.4);
    padding: 4px;
}
.dropdown-item { color: var(--foreground); border-radius: var(--radius-sm); padding: 7px 12px; font-size: 13px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-alt); color: var(--foreground); }
.dropdown-item i { color: var(--muted-foreground); margin-right: 8px; width: 14px; }
.dropdown-divider { border-color: var(--border); }

.pagination {
    --bs-pagination-bg: var(--surface);
    --bs-pagination-color: var(--foreground);
    --bs-pagination-border-color: var(--border);
    --bs-pagination-hover-bg: var(--surface-alt);
    --bs-pagination-hover-color: var(--foreground);
    --bs-pagination-hover-border-color: var(--border-strong);
    --bs-pagination-focus-bg: var(--surface-alt);
    --bs-pagination-focus-color: var(--foreground);
    --bs-pagination-active-bg: var(--primary);
    --bs-pagination-active-border-color: var(--primary);
    --bs-pagination-active-color: var(--primary-foreground);
    --bs-pagination-disabled-bg: var(--surface-alt);
    --bs-pagination-disabled-color: var(--muted-foreground);
    --bs-pagination-disabled-border-color: var(--border);
}
.pagination .page-link { font-weight: 600; transition: background-color .12s, color .12s, border-color .12s; }
.pagination .page-link:hover { border-color: var(--primary); }

.nav-tabs { border-bottom: 1px solid var(--border); }
.nav-tabs .nav-link { color: var(--muted-foreground); border: 0; background: transparent; padding: 8px 14px; font-size: 13px; }
.nav-tabs .nav-link.active, .nav-tabs .nav-link:hover { color: var(--primary); background: transparent; border-bottom: 2px solid var(--primary); }

/* Avatar */
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary);
    color: #fff; font-weight: 600; font-size: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 46px; height: 46px; font-size: 15px; }

/* ---------- Empty state ---------- */
.empty-state {
    padding: 38px 18px 32px;
    text-align: center;
    color: var(--muted-foreground);
}
.empty-state .es-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--surface-alt);
    color: var(--muted-foreground);
    font-size: 22px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}
.empty-state .es-title {
    color: var(--foreground);
    font-size: 14px; font-weight: 600;
    margin: 4px 0 2px;
}
.empty-state .es-desc {
    font-size: 12.5px; color: var(--muted-foreground);
    margin: 0 0 14px;
}

/* ---------- Kanban board ---------- */
.kanban-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.kanban-col {
    flex: 0 0 280px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    display: flex; flex-direction: column;
    max-height: calc(100vh - 220px);
}
.kanban-col-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 8px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.kanban-col-head .col-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--foreground); }
.kanban-col-head .col-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.kanban-col-head .col-count {
    background: var(--surface); border: 1px solid var(--border);
    color: var(--muted-foreground);
    font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: 10px;
}
.kanban-col-body {
    flex: 1; min-height: 160px;
    display: flex; flex-direction: column; gap: 6px;
    overflow-y: auto;
    transition: background .12s;
}
.kanban-col-body.drop-target {
    background: rgba(3, 169, 244, 0.05);
    border-radius: var(--radius-sm);
}
.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: grab;
    transition: box-shadow .12s, border-color .12s, transform .12s;
}
.kanban-card:hover { box-shadow: 0 4px 12px -4px rgba(0,0,0,0.5); border-color: var(--primary); transform: translateY(-1px); }
.kanban-card:active { cursor: grabbing; }
.kanban-card .kc-title { font-weight: 600; font-size: 13px; color: var(--foreground); margin: 0; }
.kanban-card .kc-meta { color: var(--muted-foreground); font-size: 11.5px; margin-top: 3px; }
.kanban-card .kc-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 8px;
    font-size: 11px;
    color: var(--muted-foreground);
}
.kanban-card .kc-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 1px 6px; border-radius: 3px;
    background: var(--surface-alt); color: var(--muted-foreground);
    font-size: 10.5px;
}
/* Sortable.js ghost / chosen classes */
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: 0 4px 14px rgba(0,0,0,0.10); transform: rotate(-1deg); }
.sortable-drag { box-shadow: 0 8px 22px rgba(0,0,0,0.18); }

/* SweetAlert adjustments — dark theme */
.swal2-popup {
    background: var(--surface) !important;
    color: var(--foreground) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg, 8px) !important;
}
.swal2-title, .swal2-html-container { color: var(--foreground) !important; }
.swal2-content, .swal2-html-container { color: var(--muted-foreground) !important; }
/* Hide unused Swal input slots — Bootstrap dark-theme select reboot otherwise reveals them */
.swal2-popup .swal2-input,
.swal2-popup .swal2-select,
.swal2-popup .swal2-textarea,
.swal2-popup .swal2-file,
.swal2-popup .swal2-radio,
.swal2-popup .swal2-checkbox,
.swal2-popup .swal2-range,
.swal2-popup .swal2-input-label,
.swal2-popup .swal2-validation-message { display: none !important; }
/* Also kill any Select2 wrapper that latches onto swal2-select */
.swal2-popup .select2-container,
.swal2-popup .select2 { display: none !important; }
.swal2-popup .swal2-select.select2-hidden-accessible + .select2 { display: none !important; }
/* Re-show whichever input the developer actually requested */
.swal2-popup.swal2-show .swal2-input[style*="flex"],
.swal2-popup.swal2-show .swal2-select[style*="flex"],
.swal2-popup.swal2-show .swal2-textarea[style*="flex"],
.swal2-popup.swal2-show .swal2-file[style*="flex"],
.swal2-popup.swal2-show .swal2-radio[style*="flex"],
.swal2-popup.swal2-show .swal2-checkbox[style*="flex"],
.swal2-popup.swal2-show .swal2-range[style*="flex"] { display: flex !important; }
/* Styling for whichever Swal input is actually shown */
.swal2-input, .swal2-select, .swal2-textarea, .swal2-file {
    background: var(--surface-alt) !important;
    color: var(--foreground) !important;
    border: 1px solid var(--border) !important;
}
.swal2-styled.swal2-confirm {
    background: var(--primary) !important;
    color: var(--primary-foreground, #0f172a) !important;
}
.swal2-styled.swal2-confirm:hover { background: var(--primary-hover) !important; }
.swal2-styled.swal2-cancel { background: var(--danger) !important; color: #fff !important; }
.swal2-styled.swal2-cancel:hover { background: var(--danger-hover) !important; }
.swal2-styled.swal2-deny { background: var(--warning) !important; color: #fff !important; }
.swal2-icon.swal2-warning { color: var(--warning) !important; border-color: var(--warning) !important; }
.swal2-icon.swal2-success { color: var(--success) !important; border-color: var(--success) !important; }
.swal2-icon.swal2-error { color: var(--danger) !important; border-color: var(--danger) !important; }
.swal2-icon.swal2-info { color: var(--info) !important; border-color: var(--info) !important; }
.swal2-icon.swal2-question { color: var(--primary) !important; border-color: var(--primary) !important; }
.swal2-close { color: var(--muted-foreground) !important; }
.swal2-close:hover { color: var(--foreground) !important; }

/* ---------- Dark-mode overrides for Bootstrap helpers that hard-code white/black --------- */
[data-bs-theme="dark"] .bg-white { background-color: var(--surface) !important; color: var(--foreground) !important; }
[data-bs-theme="dark"] .bg-light { background-color: var(--surface-alt) !important; color: var(--foreground) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--foreground) !important; }
[data-bs-theme="dark"] .text-muted { color: var(--muted-foreground) !important; }
[data-bs-theme="dark"] .text-black { color: var(--foreground) !important; }
[data-bs-theme="dark"] .border, [data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom, [data-bs-theme="dark"] .border-start,
[data-bs-theme="dark"] .border-end, [data-bs-theme="dark"] .border-light {
    border-color: var(--border) !important;
}
[data-bs-theme="dark"] .table { --bs-table-color: var(--foreground); --bs-table-bg: var(--surface); --bs-table-border-color: var(--border); }
[data-bs-theme="dark"] .table-light { --bs-table-bg: var(--surface-alt); --bs-table-color: var(--foreground); }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select {
    background-color: var(--surface-alt); color: var(--foreground); border-color: var(--border);
}
[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus {
    background-color: var(--surface); color: var(--foreground); border-color: var(--primary);
}
[data-bs-theme="dark"] .form-control::placeholder { color: var(--muted-foreground); }
[data-bs-theme="dark"] .modal-content { background: var(--surface); color: var(--foreground); border-color: var(--border); }
[data-bs-theme="dark"] .modal-header, [data-bs-theme="dark"] .modal-footer { border-color: var(--border); }
[data-bs-theme="dark"] .modal-header .btn-close { filter: invert(1) brightness(1.2); }
[data-bs-theme="dark"] .dropdown-menu { background: var(--surface); color: var(--foreground); border-color: var(--border); }
[data-bs-theme="dark"] .dropdown-item { color: var(--foreground); }
[data-bs-theme="dark"] .dropdown-item:hover, [data-bs-theme="dark"] .dropdown-item:focus {
    background: var(--surface-alt); color: var(--foreground);
}
[data-bs-theme="dark"] .dropdown-divider { border-color: var(--border); }
[data-bs-theme="dark"] .alert { border-color: var(--border); }
[data-bs-theme="dark"] .alert-success { background: rgba(16,185,129,0.12); color: #6ee7b7; border-color: rgba(16,185,129,0.35); }
[data-bs-theme="dark"] .alert-danger { background: rgba(239,68,68,0.12); color: #fca5a5; border-color: rgba(239,68,68,0.35); }
[data-bs-theme="dark"] .alert-warning { background: rgba(245,158,11,0.12); color: #fcd34d; border-color: rgba(245,158,11,0.35); }
[data-bs-theme="dark"] .alert-info { background: rgba(56,189,248,0.12); color: #7dd3fc; border-color: rgba(56,189,248,0.35); }
[data-bs-theme="dark"] .input-group-text { background: var(--surface-alt); color: var(--foreground); border-color: var(--border); }

/* Soft, high-contrast Bootstrap badges in dark mode (tinted bg + bright text) */
[data-bs-theme="dark"] .badge { font-weight: 600; border: 1px solid transparent; }
[data-bs-theme="dark"] .badge.bg-success { background: rgba(16,185,129,0.16) !important; color: #34d399 !important; border-color: rgba(16,185,129,0.35); }
[data-bs-theme="dark"] .badge.bg-warning { background: rgba(245,158,11,0.16) !important; color: #fbbf24 !important; border-color: rgba(245,158,11,0.35); }
[data-bs-theme="dark"] .badge.bg-danger  { background: rgba(239,68,68,0.16)  !important; color: #f87171 !important; border-color: rgba(239,68,68,0.35); }
[data-bs-theme="dark"] .badge.bg-info,
[data-bs-theme="dark"] .badge.bg-primary { background: rgba(56,189,248,0.16) !important; color: #7dd3fc !important; border-color: rgba(56,189,248,0.35); }
[data-bs-theme="dark"] .badge.bg-secondary { background: rgba(148,163,184,0.16) !important; color: #cbd5e1 !important; border-color: rgba(148,163,184,0.3); }
[data-bs-theme="dark"] .badge.bg-light { background: rgba(148,163,184,0.16) !important; color: #cbd5e1 !important; }

/* Select2 dark-mode overrides */
[data-bs-theme="dark"] .select2-container--bootstrap-4 .select2-selection {
    background-color: var(--surface-alt); border-color: var(--border);
}
[data-bs-theme="dark"] .select2-container--bootstrap-4 .select2-selection--single .select2-selection__rendered { color: var(--foreground); }
[data-bs-theme="dark"] .select2-dropdown { background: var(--surface); border-color: var(--border); }
[data-bs-theme="dark"] .select2-container--bootstrap-4 .select2-results__option { color: var(--foreground); }
[data-bs-theme="dark"] .select2-container--bootstrap-4 .select2-results__option--highlighted[aria-selected] { background: var(--primary); color: var(--primary-foreground); }
[data-bs-theme="dark"] .select2-search--dropdown .select2-search__field { background: var(--surface-alt); color: var(--foreground); border-color: var(--border); }
[data-bs-theme="dark"] .select2-selection__placeholder { color: var(--muted-foreground); }
[data-bs-theme="dark"] .select2-container--bootstrap-4 .select2-selection--single .select2-selection__arrow b { border-top-color: var(--muted-foreground) !important; }

/* ============================================================
   Interactive polish — make hovers, focuses, and transitions
   feel responsive everywhere
   ============================================================ */

/* Smooth, consistent transitions everywhere */
.btn, .hdr-btn, .hdr-cta, .hdr-search, .sb-item, .sb-sub, a.sb-item,
.dropdown-item, .pm-list a, .pm-list button, .table tbody tr,
.card, .apx-card, .conv-menu-btn, .conv-menu-item,
.welcome-chip, .conversation-item {
    transition: background-color .15s ease, color .15s ease,
        border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

/* Buttons: subtle lift + stronger shadow on hover; ring on focus */
.btn { cursor: pointer; }
.btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px -3px rgba(0,0,0,0.35);
}
.btn:not(:disabled):active { transform: translateY(0); box-shadow: none; }
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(56,189,248,0.35);
}
.btn-primary:focus-visible { box-shadow: 0 0 0 3px rgba(56,189,248,0.45); }
.btn-danger:focus-visible { box-shadow: 0 0 0 3px rgba(239,68,68,0.45); }
.btn-success:focus-visible { box-shadow: 0 0 0 3px rgba(16,185,129,0.45); }

/* Header icon buttons: clear hover */
.hdr-btn:hover {
    background: var(--surface-alt);
    color: var(--foreground);
    transform: translateY(-1px);
}
.hdr-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(56,189,248,0.35);
}
.hdr-avatar:hover { box-shadow: 0 0 0 3px rgba(56,189,248,0.25); }

/* Tables: row hover is now clearly visible */
.table tbody tr:hover {
    background: rgba(56,189,248,0.06);
    cursor: default;
}
.table tbody tr.cursor-pointer:hover,
.table tbody tr a:hover { cursor: pointer; }
.table > :not(caption) > * > * { color: var(--foreground); }

/* Links inside tables / content */
a:not(.btn):not(.sb-item):not(.sb-sub):not(.hdr-btn):not(.hdr-cta):not(.dropdown-item):hover {
    color: var(--primary-hover);
    text-decoration: none;
}

/* Dropdown items: clearer hover */
.dropdown-item:hover, .dropdown-item:focus {
    background: var(--surface-alt) !important;
    color: var(--foreground) !important;
}

/* Cards / apx-cards that act as interactive (anchored or button) */
a.card:hover, a.apx-card:hover, .card-clickable:hover {
    border-color: var(--primary);
    box-shadow: 0 6px 18px -6px rgba(56,189,248,0.25);
    transform: translateY(-1px);
}

/* Form focus ring */
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(56,189,248,0.18) !important;
    outline: none;
}

/* Header search bar: stronger hover ring */
.hdr-search:hover {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(56,189,248,0.12);
}

/* Badges & pills hover (no transform, just color shift) */
.badge { transition: background-color .12s, color .12s; }

/* Sidebar items: stronger hover */
.sb-item:hover { transform: none; }
.sb-sub:hover { transform: none; }

/* Pagination, navigation tabs */
.page-link, .nav-link {
    transition: background-color .15s, color .15s, border-color .15s;
}
.page-link:hover, .nav-link:hover {
    background: var(--surface-alt);
    color: var(--foreground);
}

/* Smooth scroll for in-page anchors */
html { scroll-behavior: smooth; }

/* Keep browser autofill from forcing a light background on inputs in dark mode */
[data-bs-theme="dark"] input:-webkit-autofill,
[data-bs-theme="dark"] input:-webkit-autofill:hover,
[data-bs-theme="dark"] input:-webkit-autofill:focus,
[data-bs-theme="dark"] textarea:-webkit-autofill,
[data-bs-theme="dark"] select:-webkit-autofill {
    -webkit-text-fill-color: var(--foreground);
    -webkit-box-shadow: 0 0 0 1000px var(--surface-alt) inset;
    caret-color: var(--foreground);
    transition: background-color 9999s ease-in-out 0s;
}

/* ============================================================
   Dark-mode remap for hard-coded Tailwind utility colors.
   Many module/legacy views use text-gray-*, bg-gray-*, bg-white,
   border-gray-* which are light-theme colors and become invisible
   on the dark surfaces. Remap them to theme variables.
   ============================================================ */
[data-bs-theme="dark"] .text-gray-900,
[data-bs-theme="dark"] .text-gray-800,
[data-bs-theme="dark"] .text-gray-700,
[data-bs-theme="dark"] .text-gray-600,
[data-bs-theme="dark"] .text-slate-900,
[data-bs-theme="dark"] .text-slate-800,
[data-bs-theme="dark"] .text-slate-700,
[data-bs-theme="dark"] .text-black { color: var(--foreground) !important; }

[data-bs-theme="dark"] .text-gray-500,
[data-bs-theme="dark"] .text-gray-400,
[data-bs-theme="dark"] .text-slate-500,
[data-bs-theme="dark"] .text-slate-400,
[data-bs-theme="dark"] .text-gray-300 { color: var(--muted-foreground) !important; }

[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-gray-50,
[data-bs-theme="dark"] .bg-slate-50 { background-color: var(--surface) !important; }

[data-bs-theme="dark"] .bg-gray-100,
[data-bs-theme="dark"] .bg-gray-200,
[data-bs-theme="dark"] .bg-slate-100,
[data-bs-theme="dark"] .bg-slate-200 { background-color: var(--surface-alt) !important; color: var(--foreground); }

[data-bs-theme="dark"] .border-gray-100,
[data-bs-theme="dark"] .border-gray-200,
[data-bs-theme="dark"] .border-gray-300,
[data-bs-theme="dark"] .border-slate-200,
[data-bs-theme="dark"] .border-slate-300,
[data-bs-theme="dark"] .border-b-2,
[data-bs-theme="dark"] .divide-gray-200 > * { border-color: var(--border) !important; }

/* Tailwind hover bg grays used on table rows / list items */
[data-bs-theme="dark"] .hover\:bg-gray-50:hover,
[data-bs-theme="dark"] .hover\:bg-gray-100:hover,
[data-bs-theme="dark"] .hover\:bg-slate-50:hover,
[data-bs-theme="dark"] .hover\:bg-slate-100:hover { background-color: var(--surface-alt) !important; }

/* Generic shadow softening so white-shadowed cards don't glow oddly on dark */
[data-bs-theme="dark"] .shadow, [data-bs-theme="dark"] .shadow-sm,
[data-bs-theme="dark"] .shadow-md, [data-bs-theme="dark"] .shadow-lg {
    box-shadow: 0 4px 14px -6px rgba(0,0,0,0.5) !important;
}

/* ============================================================
   Print styles — print only the page content (table or detail
   view), on white with black text, no app chrome.
   ============================================================ */
@media print {
    /* Force light, ink-friendly output regardless of dark theme */
    html, body, [data-bs-theme="dark"] {
        background: #fff !important;
        color: #000 !important;
    }

    /* Hide the app shell */
    .app-sidebar,
    .app-header,
    .app-footer,
    .spa-progress,
    .toast-stack,
    [data-print-btn],
    [data-print-toolbar],
    #printPageBtn { display: none !important; }

    /* Content takes the full page */
    .app-main { margin-left: 0 !important; }
    .app-content { padding: 0 !important; }
    body { display: block !important; }

    /* Hide interactive controls that make no sense on paper */
    .page-head .actions,
    .hdr-cta,
    .btn,
    .pagination,
    .cp-backdrop,
    form[action*="destroy"],
    .conv-menu, .conv-menu-btn,
    .sb-footer { display: none !important; }

    /* Drop the whole "Actions" column on action tables (header + every cell),
       but ONLY on tables that actually contain action buttons/forms — so data
       tables like Trial Balance keep their last column. */
    table:has(tbody td:last-child .btn) thead th:last-child,
    table:has(tbody td:last-child .btn) tbody td:last-child,
    table:has(tbody td:last-child form) thead th:last-child,
    table:has(tbody td:last-child form) tbody td:last-child { display: none !important; }
    th:last-child:empty { display: none; }

    /* Hide the "← Back to index" link on show/detail pages */
    .page-head a:has(.fa-arrow-left),
    .page-head p:has(.fa-arrow-left) { display: none !important; }

    /* Cards / tables: flat, bordered, no shadows, avoid breaking rows */
    .apx-card, .card, .kpi-card, .kanban-col {
        background: #fff !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        color: #000 !important;
        break-inside: avoid;
    }
    .table, .table * {
        color: #000 !important;
        background: #fff !important;
        border-color: #ccc !important;
    }
    .table { width: 100% !important; border-collapse: collapse !important; }
    .table th, .table td { border: 1px solid #ccc !important; padding: 6px 8px !important; }
    tr, .kanban-card, .apx-card { break-inside: avoid; }

    /* Headings + text readable */
    h1, h2, h3, h4, h5, h6, p, span, td, th, div, a { color: #000 !important; }
    .text-muted { color: #444 !important; }

    /* Status pills / badges: outline style so they show in B/W */
    .status-pill, .badge {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #888 !important;
    }

    /* Charts: let canvases print as-is */
    canvas { max-width: 100% !important; }

    /* Show full table (no inner scroll) */
    .table-responsive { overflow: visible !important; }

    a[href]::after { content: ""; } /* don't append URLs */
    @page { margin: 14mm; }
}
