/* =====================================================================
   IBN-Sina CMS — Phoenix UI skin (v2, comprehensive)
   Loaded AFTER the layout's inline <style>; redefines design tokens and
   restyles every Bootstrap 5 component + the app shell (sidebar, topbar,
   content-area) so all 220+ dashboard pages get a consistent, light,
   modern look without touching individual Blade files.
   Brand navy: #0B2545 · Primary: #3874ff
   ===================================================================== */

/* Note: Inter is loaded via a non-blocking <link> in the layout head, not an
   @import here (CSS @import blocks rendering). Falls back to Outfit/system. */

/* ---------- 1. DESIGN TOKENS ------------------------------------------ */
:root {
    --primary-color: #3874ff;
    --primary-dark: #2c5fd6;
    --primary-light: #5e93ff;
    --primary-subtle: #e8f0ff;
    --brand-navy: #0B2545;

    --secondary-color: #6e7891;
    --success-color: #25b865;
    --warning-color: #e5a000;
    --danger-color: #e63757;
    --info-color: #2c9ffb;

    --bg-primary: #ffffff;
    --bg-secondary: #f5f7fa;
    --bg-tertiary: #eef2f7;
    --border-color: #e3e6ed;
    --border-strong: #cdd3df;
    --text-primary: #141824;
    --text-secondary: #525b75;
    --text-muted: #8a94ad;

    --shadow-xs: 0 1px 2px rgba(20, 24, 36, 0.04);
    --shadow-sm: 0 1px 3px rgba(20, 24, 36, 0.05);
    --shadow-md: 0 4px 12px rgba(20, 24, 36, 0.06);
    --shadow-lg: 0 12px 28px rgba(20, 24, 36, 0.08);
    --shadow-xl: 0 24px 48px rgba(20, 24, 36, 0.12);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Bootstrap variable bridge */
    --bs-primary: #3874ff;
    --bs-primary-rgb: 56, 116, 255;
    --bs-success: #25b865;
    --bs-success-rgb: 37, 184, 101;
    --bs-warning: #e5a000;
    --bs-warning-rgb: 229, 160, 0;
    --bs-danger: #e63757;
    --bs-danger-rgb: 230, 55, 87;
    --bs-info: #2c9ffb;
    --bs-info-rgb: 44, 159, 251;
    --bs-link-color: #3874ff;
    --bs-link-hover-color: #2c5fd6;
    --bs-body-color: #141824;
    --bs-body-bg: #f5f7fa;
    --bs-border-color: #e3e6ed;
    --bs-border-radius: 0.5rem;
    --bs-border-radius-sm: 0.375rem;
    --bs-border-radius-lg: 0.75rem;
}

/* ---------- 2. BASE / TYPOGRAPHY -------------------------------------- */
body {
    font-family: 'Inter', 'Outfit', 'Segoe UI', system-ui, sans-serif !important;
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary);
    letter-spacing: -0.005em;
    font-size: 0.9rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    /* No forced color — headings inherit (dark on light cards, white on
       dark/gradient banners). Setting a color here breaks banner contrast. */
    font-weight: 700;
    letter-spacing: -0.02em;
}
/* Ensure text stays readable on dark / colored / gradient surfaces */
.text-white, .text-white h1, .text-white h2, .text-white h3, .text-white h4,
.text-white h5, .text-white h6, .text-white .h1, .text-white .h2,
.bg-primary, .bg-primary h1, .bg-primary h2, .bg-primary h3,
.bg-dark, .bg-dark h1, .bg-dark h2, .bg-dark h3 { color: #fff !important; }
h1, .h1 { font-size: 1.75rem; }
h2, .h2 { font-size: 1.4rem; }
h3, .h3 { font-size: 1.2rem; }
h4, .h4 { font-size: 1.05rem; }
h5, .h5 { font-size: 0.95rem; }
h6, .h6 { font-size: 0.85rem; }
small, .small { font-size: 0.8rem; }
a { color: var(--primary-color); text-decoration: none; }
a:hover { color: var(--primary-dark); }
.text-muted { color: var(--text-muted) !important; }

/* ---------- 3. APP SHELL (sidebar, topbar, content) ------------------- */
.sidebar {
    background: linear-gradient(180deg, #0B2545 0%, #0a1c36 100%) !important;
    border-right: 0;
}
.sidebar-header {
    padding: 1.25rem 1.5rem !important;
    border-bottom: 1px solid rgba(255,255,255,0.06) !important;
    background: rgba(0,0,0,0.15) !important;
}
.sidebar-header h4 { font-weight: 700; letter-spacing: -0.01em; }
.sidebar-search-container .form-control {
    background: rgba(255,255,255,0.06) !important;
    border-color: rgba(255,255,255,0.08) !important;
    color: #fff !important;
    font-size: 0.85rem;
}
.sidebar-search-container .form-control::placeholder { color: rgba(255,255,255,0.5); }
.sidebar-menu {
    padding: 0.5rem 0 !important;
    list-style: none;
}
.sidebar-menu li.sidebar-header {
    padding: 0.85rem 1rem 0.4rem !important;
    background: transparent !important;
    border: 0 !important;
}
.sidebar-menu li.sidebar-header small {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.4) !important;
    font-size: 0.68rem;
    font-weight: 600;
}
.sidebar-menu li a {
    border-radius: var(--radius-md) !important;
    margin: 0.15rem 0.6rem !important;
    padding: 0.55rem 0.85rem !important;
    font-weight: 500 !important;
    font-size: 0.875rem !important;
    color: rgba(255,255,255,0.78) !important;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
}
.sidebar-menu li a i {
    font-size: 1rem !important;
    margin-right: 0.7rem !important;
    width: 1.2rem;
    text-align: center;
}
.sidebar-menu li a:hover {
    background: rgba(255,255,255,0.06) !important;
    color: #fff !important;
}
.sidebar-menu li a.active {
    background: var(--primary-color) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(56, 116, 255, 0.35) !important;
}
.sidebar-menu li a.active i { color: #fff !important; }

.topbar {
    background: var(--bg-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-xs);
    height: var(--topbar-height);
    padding: 0 1.5rem !important;
}
.main-content { background: var(--bg-secondary); }
.content-area {
    padding: 1.5rem !important;
    max-width: 100%;
}
@media (max-width: 768px) {
    .content-area { padding: 1rem !important; }
}

/* ---------- 4. CARDS -------------------------------------------------- */
.card {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm) !important;
    background: var(--bg-primary);
    margin-bottom: 1.25rem;
    transition: box-shadow 0.15s ease;
}
.card:hover { box-shadow: var(--shadow-md) !important; }
.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1rem 1.25rem !important;
    font-weight: 600 !important;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.card-header h5, .card-header h6, .card-header h4 { margin: 0; font-size: inherit; font-weight: inherit; }
.card-body { padding: 1.25rem !important; }
.card-footer {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    padding: 0.85rem 1.25rem !important;
}

/* ---------- 5. BUTTONS ------------------------------------------------ */
.btn {
    border-radius: var(--radius-md) !important;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    transition: all 0.15s ease;
    border-width: 1px;
    line-height: 1.4;
}
.btn-sm, .btn-xs { font-size: 0.78rem !important; padding: 0.32rem 0.7rem !important; border-radius: var(--radius-sm) !important; }
.btn-lg { font-size: 0.95rem; padding: 0.7rem 1.4rem; }
.btn i { vertical-align: -1px; }
.btn-primary { background: var(--primary-color); border-color: var(--primary-color); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark) !important; border-color: var(--primary-dark) !important; box-shadow: 0 4px 12px rgba(56, 116, 255, 0.3); }
.btn-success { background: var(--success-color); border-color: var(--success-color); }
.btn-success:hover, .btn-success:focus { background: #1f9c55 !important; border-color: #1f9c55 !important; }
.btn-warning { background: var(--warning-color); border-color: var(--warning-color); color: #fff; }
.btn-warning:hover, .btn-warning:focus { background: #c48800 !important; border-color: #c48800 !important; color: #fff; }
.btn-danger { background: var(--danger-color); border-color: var(--danger-color); }
.btn-danger:hover, .btn-danger:focus { background: #c92444 !important; border-color: #c92444 !important; }
.btn-info { background: var(--info-color); border-color: var(--info-color); color: #fff; }
.btn-light { background: var(--bg-tertiary); border-color: var(--border-color); color: var(--text-primary); }
.btn-light:hover { background: #dce3ee; }
.btn-outline-primary { color: var(--primary-color); border-color: var(--primary-color); }
.btn-outline-primary:hover { background: var(--primary-color); color: #fff; }
.btn-outline-secondary { color: var(--text-secondary); border-color: var(--border-strong); }
.btn-outline-secondary:hover { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-strong); }
.btn-outline-danger { color: var(--danger-color); border-color: var(--danger-color); }
.btn-outline-danger:hover { background: var(--danger-color); color: #fff; }
.btn-outline-success { color: var(--success-color); border-color: var(--success-color); }
.btn-outline-success:hover { background: var(--success-color); color: #fff; }
.btn-group .btn { border-radius: 0 !important; }
.btn-group .btn:first-child { border-top-left-radius: var(--radius-md) !important; border-bottom-left-radius: var(--radius-md) !important; }
.btn-group .btn:last-child { border-top-right-radius: var(--radius-md) !important; border-bottom-right-radius: var(--radius-md) !important; }

/* ---------- 6. FORMS -------------------------------------------------- */
.form-control, .form-select {
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border-color) !important;
    padding: 0.5rem 0.85rem !important;
    font-size: 0.875rem;
    color: var(--text-primary);
    background-color: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light) !important;
    box-shadow: 0 0 0 3px rgba(56, 116, 255, 0.15) !important;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--danger-color) !important;
    background-image: none;
}
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(230, 55, 87, 0.15) !important; }
.invalid-feedback { font-size: 0.78rem; color: var(--danger-color); }
.form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}
.form-text { font-size: 0.78rem; color: var(--text-muted); }
.form-check-input { border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--primary-color); border-color: var(--primary-color); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(56, 116, 255, 0.15); }
.input-group-text { background: var(--bg-tertiary); border-color: var(--border-color); color: var(--text-secondary); font-size: 0.85rem; }
textarea.form-control { min-height: 90px; }

/* ---------- 7. TABLES ------------------------------------------------- */
.table {
    --bs-table-bg: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0;
}
.table > thead th, .table > thead > tr > th {
    text-transform: uppercase;
    font-size: 0.7rem !important;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 0.75rem 1rem !important;
    white-space: nowrap;
}
.table > tbody > tr > td {
    padding: 0.8rem 1rem !important;
    vertical-align: middle;
    border-color: var(--border-color);
}
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { background-color: rgba(56, 116, 255, 0.04); }
.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(245, 247, 250, 0.5); }
.table-responsive { border-radius: var(--radius-lg); }

/* ---------- 8. BADGES ------------------------------------------------- */
.badge {
    font-weight: 600;
    padding: 0.32em 0.65em;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    letter-spacing: 0.01em;
}
/* Opacity-aware (matches Bootstrap) so "bg-success bg-opacity-10 text-success"
   style chips render a LIGHT background with readable colored text instead of
   a solid block that hides same-color text. */
.badge.bg-primary   { background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity, 1)) !important; }
.badge.bg-success   { background-color: rgba(var(--bs-success-rgb), var(--bs-bg-opacity, 1)) !important; }
.badge.bg-warning   { background-color: rgba(var(--bs-warning-rgb), var(--bs-bg-opacity, 1)) !important; }
.badge.bg-danger    { background-color: rgba(var(--bs-danger-rgb), var(--bs-bg-opacity, 1)) !important; }
.badge.bg-info      { background-color: rgba(var(--bs-info-rgb), var(--bs-bg-opacity, 1)) !important; }
.badge.bg-secondary { background-color: rgba(110, 120, 145, var(--bs-bg-opacity, 1)) !important; }
/* Solid badges (no opacity utility) need light text for contrast */
.badge.bg-primary:not(.bg-opacity-10):not(.bg-opacity-25),
.badge.bg-success:not(.bg-opacity-10):not(.bg-opacity-25),
.badge.bg-warning:not(.bg-opacity-10):not(.bg-opacity-25),
.badge.bg-danger:not(.bg-opacity-10):not(.bg-opacity-25),
.badge.bg-info:not(.bg-opacity-10):not(.bg-opacity-25),
.badge.bg-secondary:not(.bg-opacity-10):not(.bg-opacity-25) { color: #fff; }
/* Subtle/soft variant — semantic backgrounds with matching text */
.bg-primary-subtle { background-color: var(--primary-subtle) !important; }
.text-primary-emphasis { color: var(--primary-dark) !important; }
.bg-success-subtle { background-color: #d6f5e3 !important; }
.text-success-emphasis { color: #137a40 !important; }
.bg-warning-subtle { background-color: #fff1cc !important; }
.text-warning-emphasis { color: #946700 !important; }
.bg-danger-subtle { background-color: #fbd5dd !important; }
.text-danger-emphasis { color: #a01b34 !important; }
.bg-info-subtle { background-color: #d4ecfd !important; }
.text-info-emphasis { color: #126fb3 !important; }

/* ---------- 9. ALERTS ------------------------------------------------- */
.alert {
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.alert-success { background: #ecfaf2; color: #137a40; border-color: #c2eed4; }
.alert-danger { background: #fdeef1; color: #a01b34; border-color: #f6c8d2; }
.alert-warning { background: #fff7e0; color: #946700; border-color: #fae3a7; }
.alert-info { background: #e6f3fe; color: #126fb3; border-color: #b8dcfa; }
.alert-primary { background: var(--primary-subtle); color: var(--primary-dark); border-color: #c9dcff; }
.alert-dismissible .btn-close { padding: 1rem 1rem; }

/* ---------- 10. NAV / TABS / BREADCRUMB ------------------------------ */
.nav-tabs { border-bottom: 1px solid var(--border-color); }
.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: 0;
    transition: all 0.15s ease;
}
.nav-tabs .nav-link:hover { color: var(--primary-color); border-bottom-color: var(--primary-light); }
.nav-tabs .nav-link.active { color: var(--primary-color); border-bottom-color: var(--primary-color); background: transparent; }
.nav-pills .nav-link { color: var(--text-secondary); border-radius: var(--radius-md); font-weight: 600; font-size: 0.85rem; }
.nav-pills .nav-link.active { background: var(--primary-color); color: #fff; }
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1rem;
    font-size: 0.82rem;
}
.breadcrumb-item { color: var(--text-secondary); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 600; }
.breadcrumb-item + .breadcrumb-item::before { content: "›"; color: var(--text-muted); }

/* ---------- 11. DROPDOWNS, MODALS, OFFCANVAS, POPOVERS --------------- */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    font-size: 0.875rem;
}
.dropdown-item { border-radius: var(--radius-sm); padding: 0.55rem 0.75rem; color: var(--text-primary); }
.dropdown-item:hover, .dropdown-item:focus { background-color: var(--bg-tertiary); color: var(--text-primary); }
.dropdown-item.active, .dropdown-item:active { background-color: var(--primary-color); color: #fff; }
.dropdown-divider { border-top-color: var(--border-color); margin: 0.4rem 0; }
.dropdown-header { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 0.6rem 0.75rem 0.3rem; }
.modal-content { border: 0; border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); }
.modal-header { border-bottom: 1px solid var(--border-color); padding: 1rem 1.25rem; }
.modal-title { font-weight: 700; font-size: 1.05rem; }
.modal-body { padding: 1.25rem; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 1rem 1.25rem; gap: 0.5rem; }
.offcanvas { border: 0; }
.offcanvas-header { border-bottom: 1px solid var(--border-color); padding: 1rem 1.25rem; }

/* ---------- 12. PAGINATION ------------------------------------------- */
.pagination { font-size: 0.85rem; gap: 0.25rem; }
.page-link {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md) !important;
    color: var(--text-primary);
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    min-width: 36px;
    text-align: center;
}
.page-link:hover { background: var(--bg-tertiary); border-color: var(--border-strong); color: var(--primary-color); }
.page-item.active .page-link { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.page-item.disabled .page-link { color: var(--text-muted); background: transparent; }

/* ---------- 13. PROGRESS, SPINNERS, LIST-GROUP ----------------------- */
.progress {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 99px;
    overflow: hidden;
}
.progress-bar { background-color: var(--primary-color); }
.list-group { border-radius: var(--radius-lg); }
.list-group-item { border-color: var(--border-color); padding: 0.85rem 1rem; }
.list-group-item.active { background: var(--primary-color); border-color: var(--primary-color); }
.spinner-border-sm { width: 1rem; height: 1rem; border-width: 2px; }

/* ---------- 14. AVATARS / UTILITIES ---------------------------------- */
.avatar, .avatar-sm, .avatar-md, .avatar-lg { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 600; flex-shrink: 0; }
.avatar { width: 38px; height: 38px; font-size: 0.85rem; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.72rem; }
.avatar-md { width: 44px; height: 44px; font-size: 0.95rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
/* Opacity-aware so Bootstrap's .text-opacity-* / .bg-opacity-* still work
   (e.g. icon chips using "bg-primary bg-opacity-10 text-primary"). */
.text-primary { color: rgba(var(--bs-primary-rgb), var(--bs-text-opacity, 1)) !important; }
.bg-primary { background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity, 1)) !important; }
hr { border-color: var(--border-color); opacity: 1; }
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }
.rounded { border-radius: var(--radius-md) !important; }
.rounded-3 { border-radius: var(--radius-lg) !important; }

/* ---------- 15. PAGE-LEVEL SPACING (catches all dashboard pages) ----- */
.content-area > .container,
.content-area > .container-fluid {
    padding-left: 0 !important;
    padding-right: 0 !important;
}
.content-area > .container-fluid > .row,
.content-area > .row { --bs-gutter-x: 1.25rem; --bs-gutter-y: 1.25rem; }
.content-area h1:first-child,
.content-area h2:first-child,
.content-area .page-title,
.content-area .page-header { margin-bottom: 1.25rem; }

/* Section header pattern: "Title — Action button" */
.page-header, .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}
.page-header h1, .page-header h2, .section-header h1, .section-header h2 { margin: 0; }

/* Stat / KPI card pattern (used a lot in dashboards) */
.stat-card, .kpi-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-value, .kpi-card .kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.stat-card .stat-label, .kpi-card .kpi-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

/* ---------- 16. SCROLLBAR + FOCUS ------------------------------------ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5ccdb; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #aab3c7; }
:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; border-radius: 4px; }
button:focus, .btn:focus { outline: 0; }

/* ---------- 17. PRINT + COMPATIBILITY -------------------------------- */
@media print {
    .sidebar, .topbar, .btn, .no-print { display: none !important; }
    .main-content, .content-area { margin: 0 !important; padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}
/* Older custom classes some Blade files use */
.btn-xs { font-size: 0.72rem !important; padding: 0.2rem 0.55rem !important; }
.text-success { color: var(--success-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-info { color: var(--info-color) !important; }
.bg-light { background-color: var(--bg-tertiary) !important; }

/* =====================================================================
   18. DARK MODE  (activated by data-bs-theme="dark" on <html>)
   Redefines the design tokens; the whole shell + components follow.
   ===================================================================== */
[data-bs-theme="dark"] {
    --bg-primary: #1c2030;       /* cards / surfaces */
    --bg-secondary: #12151f;     /* page background */
    --bg-tertiary: #262b3b;      /* subtle fills */
    --border-color: #2c3346;
    --border-strong: #3a4259;
    --text-primary: #e7eaf2;
    --text-secondary: #aab2c6;
    --text-muted: #7e879d;
    --primary-subtle: #1b2742;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.35);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,.45);
    --shadow-lg: 0 12px 28px rgba(0,0,0,.5);
    --shadow-xl: 0 24px 48px rgba(0,0,0,.55);

    /* Bootstrap bridge for dark */
    --bs-body-bg: #12151f;
    --bs-body-color: #e7eaf2;
    --bs-border-color: #2c3346;
    --bs-secondary-bg: #262b3b;
    --bs-tertiary-bg: #1c2030;
    --bs-emphasis-color: #ffffff;
    color-scheme: dark;
}

/* Surfaces */
[data-bs-theme="dark"] body { background-color: var(--bg-secondary); color: var(--text-primary); }
[data-bs-theme="dark"] .main-content { background: var(--bg-secondary); }
[data-bs-theme="dark"] .topbar { background: var(--bg-primary); border-bottom-color: var(--border-color); }
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .stat-card,
[data-bs-theme="dark"] .dashboard-card,
[data-bs-theme="dark"] .phx-metric-card,
[data-bs-theme="dark"] .app-version-footer,
[data-bs-theme="dark"] .list-group,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .dropdown-menu { background-color: var(--bg-primary); border-color: var(--border-color); color: var(--text-primary); }
[data-bs-theme="dark"] .card-header,
[data-bs-theme="dark"] .card-footer,
[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer { border-color: var(--border-color); }
[data-bs-theme="dark"] .card-footer { background: var(--bg-tertiary); }

/* Tables */
[data-bs-theme="dark"] .table { color: var(--text-primary); }
[data-bs-theme="dark"] .table > thead th { background: var(--bg-tertiary); color: var(--text-muted); border-color: var(--border-color); }
[data-bs-theme="dark"] .table > tbody > tr > td { border-color: var(--border-color); }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { background-color: rgba(56,116,255,.10); }
[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(255,255,255,.02); }

/* Forms */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #161a26; border-color: var(--border-color); color: var(--text-primary);
}
[data-bs-theme="dark"] .form-control::placeholder { color: var(--text-muted); }
[data-bs-theme="dark"] .input-group-text { background: var(--bg-tertiary); border-color: var(--border-color); color: var(--text-secondary); }

/* Dropdown / nav / pagination */
[data-bs-theme="dark"] .dropdown-item { color: var(--text-primary); }
[data-bs-theme="dark"] .dropdown-item:hover { background: var(--bg-tertiary); }
[data-bs-theme="dark"] .page-link { background: var(--bg-primary); border-color: var(--border-color); color: var(--text-primary); }
[data-bs-theme="dark"] .page-link:hover { background: var(--bg-tertiary); }
[data-bs-theme="dark"] .nav-tabs { border-bottom-color: var(--border-color); }
[data-bs-theme="dark"] .breadcrumb-item.active { color: var(--text-primary); }

/* Text utilities that views hardcode to dark */
[data-bs-theme="dark"] .text-dark { color: var(--text-primary) !important; }
[data-bs-theme="dark"] .bg-white { background-color: var(--bg-primary) !important; }
[data-bs-theme="dark"] .bg-light { background-color: var(--bg-tertiary) !important; }
[data-bs-theme="dark"] hr { border-color: var(--border-color); }

/* Soft semantic fills tuned for dark */
[data-bs-theme="dark"] .bg-primary-subtle { background-color: #16233f !important; }
[data-bs-theme="dark"] .bg-success-subtle { background-color: #11301f !important; }
[data-bs-theme="dark"] .bg-warning-subtle { background-color: #33280a !important; }
[data-bs-theme="dark"] .bg-danger-subtle { background-color: #3a1620 !important; }
[data-bs-theme="dark"] .bg-info-subtle { background-color: #102a3d !important; }
[data-bs-theme="dark"] .alert-success { background:#11301f; color:#7fe0a6; border-color:#1c4a31; }
[data-bs-theme="dark"] .alert-danger { background:#3a1620; color:#f3a6b4; border-color:#5a2230; }
[data-bs-theme="dark"] .alert-warning { background:#33280a; color:#f0cd7d; border-color:#5a4612; }
[data-bs-theme="dark"] .alert-info { background:#102a3d; color:#9bd2f5; border-color:#1c4763; }
[data-bs-theme="dark"] .alert-primary { background:#16233f; color:#a9c5ff; border-color:#243a63; }

/* =====================================================================
   19. MODALS — never exceed the viewport. Body scrolls; header/footer stay.
   Fixes tall forms (e.g. Create Job) whose lower fields + Save button
   were cut off below the screen.
   ===================================================================== */
.modal-content { max-height: calc(100vh - 2rem); }
.modal-body { overflow-y: auto; }
@media (max-width: 576px) { .modal-content { max-height: calc(100vh - 1rem); } }
