/* ============================================================
   Civil Limitless — Unified Design System
   Inspired by Windows 11 + macOS Sonoma
   All existing class names preserved for backward compatibility.
   ============================================================ */

/* ── App-wide: remove number-input spinner arrows (type directly) ── */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ── Design Tokens (Light) ── */
:root {
    /* Brand (v1.0.210 — Corporate) */
    --primary: #0D0D63;
    --primary-light: #16167a;
    --primary-dark: #060640;
    --primary-subtle: #f0f0ff;
    --accent: #DE076E;

    /* Semantic */
    --success: #10b981;
    --warning: #d97706; /* Ledger Premium: refined amber (was pure #FFFF00 — illegible on light) */
    --danger: #ef4444;
    --info: #0D0D63;

    /* Surfaces */
    --body-bg: #ffffff;
    --surface-bg: #ffffff;
    --surface-secondary: #f8fafc;
    --surface-tertiary: #f1f5f9;
    --surface-hover: #f1f5f9;
    --surface-pressed: #e2e8f0;

    /* Text */
    --text-primary: #000000;        /* Pure Black */
    --text-secondary: #1e293b;      /* Navy Gray — WCAG AA */
    --text-muted: #475569;          /* Medium Gray — WCAG AA */
    --text-inverse: #ffffff;
    
    /* Bootstrap compatibility */
    --bs-secondary-color: #475569;
    --bs-tertiary-color: #64748b;
    --bs-secondary-bg: #f8fafc;
    --bs-tertiary-bg: #f1f5f9;

    /* Borders */
    --border-color: #B3B3B3;
    --border-strong: #4D4D4D;
    --border-light: #e2e8f0;
    --border-subtle: #f1f5f9;

    /* Sidebar */
    --sidebar-bg: #0D0D63;
    --sidebar-bg-gradient: #0D0D63;
    --sidebar-width: 200px;
    --sidebar-collapsed-width: 62px;
    --sidebar-text: #ffffff;
    --sidebar-text-active: #fcd34d; /* Ledger Premium: soft gold (was harsh #FFFF00) */
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --sidebar-active: rgba(222, 7, 110, 0.2);

    /* Shape / elevation tokens used throughout legacy pages */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-2xl: 16px;
    --radius-full: 9999px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 14px 34px rgba(15, 23, 42, 0.16);
    --shadow-xl: 0 18px 48px rgba(15, 23, 42, 0.18);
    --shadow-2xl: 0 24px 64px rgba(15, 23, 42, 0.22);
    --card-shadow: var(--shadow-xs);
    --input-bg: #ffffff;
    --input-border: var(--border-color);
    --dropdown-bg: #ffffff;
    --scrollbar-track: var(--surface-secondary);
    --scrollbar-thumb: #cbd5e1;

    /* Numbered surface stack (light) — parity with the dark theme so the many
       components that reference --surface-1..5 render correctly in light mode
       instead of falling back / breaking. */
    --surface-0: #ffffff;
    --surface-1: #ffffff;
    --surface-2: #ffffff;
    --surface-3: #f1f5f9;
    --surface-4: #e2e8f0;
    --surface-5: #cbd5e1;

    /* Accent surfaces (light tints) — used for subtotal/highlight/status rows */
    --surface-accent: #fffbeb;          /* light amber */
    --surface-accent-blue: #eff6ff;
    --surface-accent-green: #ecfdf5;
    --surface-accent-red: #fef2f2;
    --surface-accent-purple: #f5f3ff;

    /* Extended text tones (light) */
    --text-faint: #94a3b8;
    --text-disabled: #cbd5e1;

    /* Bootstrap surface parity (light) */
    --bs-body-bg: #ffffff;
    --bs-body-color: #000000;
    --bs-border-color: #B3B3B3;
    --bs-light-rgb: 248, 250, 252;
    --bs-white-rgb: 255, 255, 255;
}

/* ── Design Tokens (Dark) ── */
[data-theme="dark"] {
    --body-bg: #000000;

    /* Bright interaction blue for dark-mode content. Sidebar stays navy via
       --sidebar-bg, but buttons, section labels and links need contrast. */
    --primary: #3b82f6;
    --primary-light: #93c5fd;
    --primary-dark: #1d4ed8;

    /* Surface stack */
    --surface-0: #000000;
    --surface-1: #0D0D63;          /* Navy Sidebar */
    --surface-2: #161616;
    --surface-3: #1c1c1c;
    --surface-4: #2c2c2c;
    --surface-5: #363636;

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #B3B3B3;      /* Standard Gray */
    --text-muted: #808080;          /* Medium Gray — Fixed contrast from #4D4D4D */
    --text-faint: #4D4D4D;
    --text-disabled: #333333;
    --text-inverse: #000000;

    /* Borders */
    --border-color: #4D4D4D;
    --border-strong: #B3B3B3;
    --border-light: #252525;
    --border-subtle: #1c1c1c;

    /* Sidebar */
    --sidebar-bg: #0D0D63;
    --sidebar-bg-gradient: #0D0D63;
    --sidebar-text-active: #fcd34d; /* Ledger Premium: soft gold (was harsh #FFFF00) */
    --sidebar-active: rgba(222, 7, 110, 0.3);
    --primary-subtle: rgba(13, 13, 99, 0.4);
    --warning: #fbbf24; /* Ledger Premium: bright amber for dark surfaces */

    /* Surface Mappings — Fixed "White Patti" (Bug 9) */
    --surface-bg: #161616;
    --surface-secondary: #1c1c1c;
    --surface-tertiary: #2c2c2c;
    --surface-hover: #2c2c2c;
    --surface-pressed: #363636;

    /* Surface Accents for Dark Mode — Fixed "White Patti" (Bug 9) */
    --surface-accent: rgba(222, 7, 110, 0.15);
    --surface-accent-blue: rgba(30, 64, 175, 0.2);
    --surface-accent-green: rgba(16, 185, 129, 0.2);
    --surface-accent-red: rgba(239, 68, 68, 0.2);
    --surface-accent-purple: rgba(124, 58, 237, 0.2);

    /* Bootstrap Overrides for Dark Mode - Fixes "White Patti" (Bug 9) and Hidden Email (Bug 2) */
    --bs-body-bg: #000000;
    --bs-body-color: #ffffff;
    --bs-secondary-bg: #1c1c1c;
    --bs-tertiary-bg: #2d2d2d;
    --bs-secondary-color: #808080;
    --bs-border-color: #333333;

    /* Force override Bootstrap Utility Classes for Dark Mode */
    --bs-light-rgb: 28, 28, 28;      /* Matches --surface-3 */
    --bs-white-rgb: 22, 22, 22;      /* Matches --surface-2 */

    --card-shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
    --input-bg: #111111;
    --input-border: #4D4D4D;
    --dropdown-bg: #2c2c2c;
    --scrollbar-track: #111111;
    --scrollbar-thumb: #4D4D4D;
}

/* ── Bootstrap Utility Overrides ── */
[data-theme="dark"] .bg-light,
[data-theme="dark"] .bg-body-tertiary {
    background-color: var(--surface-3) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-body-secondary {
    background-color: var(--surface-2) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .text-dark {
    color: var(--text-primary) !important;
}

/* ── Hardcoded Element Fixes ── */
[data-theme="dark"] #projectSelector,
[data-theme="dark"] select[style*="background:#fff"],
[data-theme="dark"] select[style*="background: #fff"],
[data-theme="dark"] select[style*="background:white"],
[data-theme="dark"] select[style*="background: white"] {
    background-color: var(--surface-3) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-strong) !important;
}

[data-theme="dark"] .app-logo-img {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid var(--border-color) !important;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Global ── */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body {
    font-family: 'Inter', 'Segoe UI Variable Text', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--body-bg);
    color: var(--text-primary);
    transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', 'Segoe UI Variable Display', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.015em;
    margin-bottom: 0.5rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.9rem; }

/* Scrollbars — thin, minimal */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--radius-full); border: 2px solid var(--body-bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Auth Pages ── */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    padding: 24px;
}

.auth-card {
    background: var(--surface-bg);
    border-radius: var(--radius-2xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 440px;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.auth-card .logo { text-align: center; margin-bottom: 1.5rem; }
.auth-card .logo h2 { color: var(--primary); font-weight: 700; margin-bottom: 0.25rem; }
.auth-card .logo p { color: var(--text-muted); font-size: 0.85rem; margin: 0; }

/* ── Polished centered auth (login / reset / activate) ──
   Same centered card as before, refined: richer blueprint background, deeper
   card, inline-icon inputs with a focus ring, gradient primary button.
   Scoped to :not(.signup-card) so the signup wizard keeps its own design. */
.auth-container {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #10225a 0%, #1e3a8a 48%, #1e40af 100%);
}
.auth-container::before { /* subtle blueprint grid — construction feel */
    content: ""; position: absolute; inset: 0; z-index: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 34px 34px;
    -webkit-mask-image: radial-gradient(130% 90% at 50% 0%, #000 34%, transparent 78%);
    mask-image: radial-gradient(130% 90% at 50% 0%, #000 34%, transparent 78%);
    pointer-events: none;
}
.auth-card { position: relative; z-index: 1; }
.auth-card:not(.signup-card) {
    border-radius: 18px;
    padding: 2.25rem;
    max-width: 428px;
    box-shadow: 0 24px 60px rgba(2,6,23,0.45), 0 2px 6px rgba(2,6,23,0.25);
}

/* Centered brand/heading blocks */
.auth-panel-head { text-align: center; margin-bottom: 1.4rem; }
.auth-panel-head h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; color: var(--text-primary); margin: 0 0 3px; }
.auth-panel-head p { font-size: 0.85rem; color: var(--text-muted); margin: 0; }
.auth-logo-box {
    width: 60px; height: 60px; border-radius: 15px; margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    box-shadow: 0 8px 20px rgba(30,64,175,0.30);
}
.auth-logo-box .app-logo-img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 9px; padding: 3px; }
.auth-logo-box .app-logo-icon { font-size: 1.7rem; color: #fff; }

/* Refined form controls inside the centered auth cards (login / reset / activate) */
.auth-card:not(.signup-card) .form-label { font-weight: 600; font-size: 0.82rem; color: var(--text-primary); margin-bottom: 6px; }
.auth-card:not(.signup-card) .form-control, .auth-card:not(.signup-card) .form-select { border-radius: 10px; padding: 11px 12px; border: 1px solid var(--border-color); background: var(--surface-bg, #fff); color: var(--text-primary); font-size: 0.92rem; }
.auth-card:not(.signup-card) .form-control:focus, .auth-card:not(.signup-card) .form-select:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); background: var(--surface-bg, #fff); }
.auth-card:not(.signup-card) .input-group { border: 1px solid var(--border-color); border-radius: 10px; overflow: hidden; background: var(--surface-bg, #fff); transition: border-color .15s, box-shadow .15s; }
.auth-card:not(.signup-card) .input-group:focus-within { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.auth-card:not(.signup-card) .input-group > .form-control, .auth-card:not(.signup-card) .input-group > .btn, .auth-card:not(.signup-card) .input-group > .input-group-text { border: none; box-shadow: none !important; background: transparent; }
.auth-card:not(.signup-card) .input-group .input-group-text { color: var(--text-muted); padding-left: 14px; }
/* A filled button inside an auth input-group loses its fill to the rule above, so its
   white label would be invisible on the light card. Paint the label with the accent. */
.auth-card:not(.signup-card) .input-group > .btn-success,
.auth-card:not(.signup-card) .input-group > .btn-primary,
.auth-card:not(.signup-card) .input-group > .btn-danger { font-weight: 650; }
.auth-card:not(.signup-card) .input-group > .btn-success { color: var(--success); }
.auth-card:not(.signup-card) .input-group > .btn-primary { color: var(--primary); }
.auth-card:not(.signup-card) .input-group > .btn-danger { color: var(--danger); }
[data-theme="dark"] .auth-card:not(.signup-card) .input-group > .btn-primary { color: #93c5fd; }
.auth-card:not(.signup-card) .btn-primary { background: var(--primary); border: none; border-radius: 8px; font-weight: 650; padding: 11px; box-shadow: none; transition: filter .15s; }
.auth-card:not(.signup-card) .btn-primary:hover { filter: brightness(1.3); }

/* ── Layout ── */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg-gradient);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    overflow: hidden; /* inner nav will scroll */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 190px; /* reserve space for footer above Windows taskbar */
}

/* Compact sidebar: the nav scrolls, but NO scrollbar is ever painted — the rail is a
   flat surface and a track/thumb strip on its edge looks like a seam. Wheel, trackpad,
   drag and keyboard scrolling all still work; only the widget is hidden. */
#sidebar ul.nav {
    max-height: calc(100vh - 230px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px; /* breathing room at the rail edge */
    flex-wrap: nowrap !important;
    align-content: stretch;
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* legacy Edge */
}
#sidebar ul.nav::-webkit-scrollbar { width: 0; height: 0; }
#sidebar .sidebar-footer { position: absolute; bottom: 58px; left: 12px; right: 12px; }

#sidebar { scrollbar-width: none; -ms-overflow-style: none; }
#sidebar::-webkit-scrollbar { width: 0; height: 0; }

.sidebar-link {
    color: var(--sidebar-text) !important;
    padding: 7px 12px !important;
    border-radius: var(--radius-md) !important;
    margin: 1px 0;
    transition: background 0.15s ease, color 0.15s ease;
    display: flex !important;
    align-items: center;
    gap: 10px;
    font-size: 0.83rem;
    line-height: 1.3;
    font-weight: 500;
    position: relative;
    text-decoration: none;
    width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-link:hover {
    background: rgba(250, 204, 21, 0.18) !important;
    color: var(--sidebar-text-active) !important;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active) !important;
    font-weight: 600;
}

/* Win11-style pill indicator on active */
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 2px;
    /* Bright on the navy sidebar in both themes (was --primary-light = navy, invisible in light) */
    background: var(--sidebar-text-active, #FFFF00);
}

.sidebar-link i {
    font-size: 0.98rem;
    width: 20px;
    text-align: center;
    opacity: 0.85;
    flex: 0 0 20px;
}

.sidebar-link.active i { opacity: 1; }

.sidebar-link-label {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-feature-signal {
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    margin-left: auto;
    border-radius: 999px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12), 0 0 8px currentColor;
}

.sidebar-feature-signal.available {
    color: #20d66b;
    background: #20d66b;
}

.sidebar-feature-signal.locked {
    color: #ff4d4f;
    background: #ff4d4f;
}

.sidebar-section {
    width: 100%;
    margin-top: 10px;
    flex: 0 0 auto;
}

.sidebar-section-toggle {
    width: 100%;
    min-height: 34px;
    padding: 7px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.045);
    color: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    font-size: 0.66rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    line-height: 1;
    text-transform: uppercase;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-section-toggle span {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-section-toggle i:first-child {
    width: 18px;
    text-align: center;
    opacity: 0.85;
}

.sidebar-section-toggle:hover {
    background: rgba(250, 204, 21, 0.18) !important;
    color: var(--sidebar-text-active, #FFFF00) !important;
}

.sidebar-section-chevron {
    flex-shrink: 0;
    font-size: 0.72rem;
    transition: transform 0.16s ease;
}

.sidebar-section-toggle.collapsed .sidebar-section-chevron {
    transform: rotate(-90deg);
}

.sidebar-section-items {
    width: 100%;
    min-width: 0;
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: block;
}

.sidebar-section-items.collapsed {
    display: none;
}

.sidebar-section-items li {
    width: 100%;
    min-width: 0;
}

/* Quick access overlay for sidebar navigation */
.quick-access-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 34px;
    background: rgba(13, 13, 99, 0.38);
    backdrop-filter: blur(7px);
    z-index: 20050;
}

.quick-access-overlay.show { display: flex; }

.quick-access-shell {
    width: min(1380px, calc(100vw - 72px));
    height: min(840px, calc(100vh - 72px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface-bg);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.34);
}

.quick-access-header {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    color: #fff;
    background: linear-gradient(90deg, #0D0D63, #312e91);
    flex-shrink: 0;
}

.quick-access-title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 1rem;
    font-weight: 800;
}

.quick-access-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-access-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.quick-access-actions .btn {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-weight: 700;
}

.quick-access-actions .btn:hover {
    background: rgba(255, 255, 255, 0.24);
    color: #fff;
}

.quick-access-close {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.quick-access-body {
    flex: 1;
    min-height: 0;
    background: var(--body-bg);
}

.quick-access-body iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: var(--body-bg);
}

body.quick-access-open { overflow: hidden; }
body.quick-access-embedded .main-content {
    margin-left: 0 !important;
    width: 100% !important;
}
body.quick-access-embedded .layout-wrapper { min-height: 100vh; }
body.quick-access-embedded #sidebar,
body.quick-access-embedded .sidebar-toggle,
body.quick-access-embedded #subscription-bar { display: none !important; }

@media (max-width: 768px) {
    .quick-access-overlay { padding: 12px; }
    .quick-access-shell {
        width: calc(100vw - 24px);
        height: calc(100vh - 24px);
        border-radius: 8px;
    }
    .quick-access-header {
        padding: 10px 12px;
        gap: 8px;
    }
    .quick-access-title { font-size: 0.9rem; }
    .quick-access-full { font-size: 0.78rem; }
}

.sidebar-footer {
    position: absolute;
    bottom: 58px;
    left: 12px;
    right: 12px;
    width: auto;
    min-height: 82px;
    padding: 11px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(6, 6, 64, 0.96);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.28);
    z-index: 5;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

.sidebar-user-meta {
    min-width: 0;
    flex: 1;
    line-height: 1.2;
}

.sidebar-user-name {
    color: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.68rem;
    font-weight: 600;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-version {
    color: #ffff66;
    font-size: 0.64rem;
    font-weight: 800;
    margin-top: 4px;
    letter-spacing: 0.02em;
}

.sidebar-theme-toggle {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #1e3a8a;
    border: 2px solid #3b82f6;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.sidebar-theme-toggle:hover {
    background: #2563eb;
    border-color: #ffffff;
    transform: scale(1.06);
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 28px;
    min-height: 100vh;
}

/* ── Page Header ── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;           /* Mandate: limited to 12px */
    padding-bottom: 2px;
}

/* ── Branding Elements ── */
.branding-logo-wrapper {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.9); /* Subtle semi-transparent white */
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
}
[data-theme="dark"] .branding-logo-wrapper {
    background: rgba(255, 255, 255, 0.15); /* Slightly brighter in dark mode */
    border-color: rgba(255, 255, 255, 0.2);
}

.branding-text-primary {
    font-weight: 700;
    font-size: 1.05rem;
    color: #ffffff;
    line-height: 1.2;
    letter-spacing: -0.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.branding-text-secondary {
    font-size: 0.65rem;
    color: var(--sidebar-text-active); /* Yellow highlight */
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    opacity: 0.9;
}

/* ── Professional Dialogs & Modals (v1.0.220) ── */
dialog, .modal-content {
    background: #ffffff !important;
    color: #1e293b !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-2xl) !important;
    padding: 0 !important;
    overflow: hidden;
    
    /* Animation Fix: Prevent flash by using a smooth transition */
    animation: ds-dialog-appear 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transform-origin: center;
}

[data-theme="dark"] dialog, 
[data-theme="dark"] .modal-content {
    background: #161616 !important; /* Solid dark surface */
    color: #ffffff !important;
    border: 1px solid #333333 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7) !important;
}

@keyframes ds-dialog-appear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0) !important;
    backdrop-filter: blur(0px) !important;
    transition: all 0.2s ease;
    animation: ds-backdrop-fade 0.2s forwards;
}

@keyframes ds-backdrop-fade {
    to {
        background: rgba(0, 0, 0, 0.45) !important;
    }
}

.modal-header {
    padding: 16px 20px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    background: #f8fafc !important;
}

[data-theme="dark"] .modal-header {
    background: #1c1c1c !important;
    border-bottom: 1px solid #333333 !important;
}

.modal-footer {
    padding: 12px 20px !important;
    background: #f8fafc !important;
    border-top: 1px solid #f1f5f9 !important;
}

[data-theme="dark"] .modal-footer {
    background: #1c1c1c !important;
    border-top: 1px solid #333333 !important;
}

.page-header h3 {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.25rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-header h3 i {
    color: var(--primary);
    font-size: 1.4rem;
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 28px;
    min-height: 100vh;
}

/* ── Page Header ── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;           /* Mandate: limited to 12px */
    padding-bottom: 2px;
}

/* ── Branding Elements ── */
.branding-logo-wrapper {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.9); /* Subtle semi-transparent white */
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
}
[data-theme="dark"] .branding-logo-wrapper {
    background: rgba(255, 255, 255, 0.15); /* Slightly brighter in dark mode */
    border-color: rgba(255, 255, 255, 0.2);
}

.branding-text-primary {
    font-weight: 700;
    font-size: 1.05rem;
    color: #ffffff;
    line-height: 1.2;
    letter-spacing: -0.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.branding-text-secondary {
    font-size: 0.65rem;
    color: var(--sidebar-text-active); /* Yellow highlight */
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    opacity: 0.9;
}

/* ── Professional Dialogs & Modals (v1.0.220) ── */
dialog, .modal-content {
    background: #ffffff !important;
    color: #1e293b !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-2xl) !important;
    padding: 0 !important;
    overflow: hidden;
    
    /* Animation Fix: Prevent flash by using a smooth transition */
    animation: ds-dialog-appear 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transform-origin: center;
}

[data-theme="dark"] dialog, 
[data-theme="dark"] .modal-content {
    background: #161616 !important; /* Solid dark surface */
    color: #ffffff !important;
    border: 1px solid #333333 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7) !important;
}

@keyframes ds-dialog-appear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0) !important;
    backdrop-filter: blur(0px) !important;
    transition: all 0.2s ease;
    animation: ds-backdrop-fade 0.2s forwards;
}

@keyframes ds-backdrop-fade {
    to {
        background: rgba(0, 0, 0, 0.45) !important;
    }
}

.modal-header {
    padding: 16px 20px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    background: #f8fafc !important;
}

[data-theme="dark"] .modal-header {
    background: #1c1c1c !important;
    border-bottom: 1px solid #333333 !important;
}

.modal-footer {
    padding: 12px 20px !important;
    background: #f8fafc !important;
    border-top: 1px solid #f1f5f9 !important;
}

[data-theme="dark"] .modal-footer {
    background: #1c1c1c !important;
    border-top: 1px solid #333333 !important;
}

.page-header h3 {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.25rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-header h3 i {
    color: var(--primary);
    font-size: 1.4rem;
}

/* ── Cards ── */
.card {
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    color: var(--text-primary);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 14px 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body { padding: 18px; }
/* ── Stat Cards (Executive KPIs) ── */
.stat-card {
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary); /* Sleek color-coded left border */
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-icon {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--surface-secondary) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: var(--radius-md) !important;
    opacity: 0.9;
}
[data-theme="dark"] .stat-card .stat-icon {
    background: var(--surface-secondary) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: none !important;
    opacity: 0.85;
}
[data-theme="dark"] .stat-icon-boq,
[data-theme="dark"] .stat-icon-boq i {
    color: #60a5fa !important;
}
[data-theme="dark"] .stat-icon-billed,
[data-theme="dark"] .stat-icon-billed i {
    color: #34d399 !important;
}
[data-theme="dark"] .stat-icon-outstanding,
[data-theme="dark"] .stat-icon-outstanding i {
    color: #f87171 !important;
}
[data-theme="dark"] .stat-icon-subscription,
[data-theme="dark"] .stat-icon-subscription i {
    color: #a78bfa !important;
}

/* ── Windows File Explorer Style Project Tree Grid ── */
.project-explorer-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.project-explorer-table thead th {
    background: #1a1d20 !important;
    color: #ffffff !important;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-strong, #333333);
}

[data-theme="dark"] .project-explorer-table thead th {
    background: #111111 !important;
    color: #ffffff !important;
    border-bottom: 2px solid #444444;
}

.project-explorer-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
}

.project-explorer-table tbody tr:nth-child(even) {
    background: var(--surface-secondary, rgba(0,0,0,0.02));
}

[data-theme="dark"] .project-explorer-table tbody tr:nth-child(even) {
    background: #161616;
}

.project-explorer-table tbody tr:hover {
    background: var(--surface-hover, rgba(0,0,0,0.04)) !important;
}

[data-theme="dark"] .project-explorer-table tbody tr:hover {
    background: #222222 !important;
}

.project-explorer-table td {
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--text-primary);
    vertical-align: middle;
}

/* Tree Connectors and Nodes */
.project-tree-node {
    display: flex;
    align-items: center;
    gap: 8px;
}

.project-tree-indent {
    display: inline-block;
    width: 16px;
    height: 20px;
    position: relative;
    flex-shrink: 0;
}

.project-tree-connector {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 1.1rem;
    letter-spacing: -2px;
    margin-right: 4px;
    opacity: 0.7;
    user-select: none;
}

.folder-icon-parent {
    color: #2563eb; /* Windows-style Royal Blue */
    font-size: 1.1rem;
}

.folder-icon-child {
    color: #0d9488; /* Elegant Teal for Sub-projects/Phases */
    font-size: 1.1rem;
}

/* Health status dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 6px;
}
.status-dot-active { background-color: #10b981; }
.status-dot-delayed { background-color: #ef4444; }
.status-dot-stale { background-color: #f59e0b; }

/* ── Project Card ── */
.project-card {
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 16px 18px;
    box-shadow: var(--shadow-xs);
    transition: all 0.15s ease;
    cursor: pointer;
    color: var(--text-primary);
}

.project-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.project-card .project-name {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.98rem;
}

.project-card .project-meta {
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* ── Buttons ── */
.btn {
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: transform 0.12s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    font-size: 0.875rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(15,23,42,0.10); }
.btn:active { transform: translateY(0) scale(0.98); box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled, .btn.disabled { transform: none !important; box-shadow: none !important; opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #059669; border-color: #059669; color: #fff; }

.btn-warning { background: var(--warning); border-color: var(--warning); color: #1a1a1a; }
.btn-warning:hover { background: #d97706; border-color: #d97706; color: #fff; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }

.btn-outline-primary, .btn-outline-secondary {
    background: var(--surface-bg);
    border-color: var(--border-strong);
    color: var(--text-primary);
}
.btn-outline-primary:hover { background: var(--primary-subtle); border-color: var(--primary); color: var(--primary); }
.btn-outline-secondary:hover {
    background: rgba(234, 179, 8, 0.15) !important;
    border-color: #d97706 !important;
    color: #b45309 !important;
}

.btn-light {
    background: var(--surface-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-light:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text-primary); }

/* Solid secondary — token-based so it follows the theme (Bootstrap default is a fixed grey) */
.btn-secondary {
    background: var(--surface-tertiary);
    border-color: var(--border-strong);
    color: var(--text-primary);
}
.btn-secondary:hover { background: var(--surface-pressed); border-color: var(--border-strong); color: var(--text-primary); }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 0.6rem 1.2rem; font-size: 1rem; border-radius: var(--radius-lg); }

.btn-action {
    padding: 0.25rem 0.55rem;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
}

.btn-outline-success,
.btn-outline-danger,
.btn-outline-warning,
.btn-outline-info {
    background: var(--surface-bg);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-outline-success:hover { background: rgba(16, 185, 129, 0.1); border-color: var(--success); color: #047857; }
.btn-outline-danger:hover { background: rgba(239, 68, 68, 0.1); border-color: var(--danger); color: #dc2626; }
.btn-outline-warning:hover { background: rgba(245, 158, 11, 0.12); border-color: #d97706; color: #92400e; }
.btn-outline-info:hover { background: rgba(14, 165, 233, 0.1); border-color: #0284c7; color: #0369a1; }

.page-header .btn,
.cs-page-header .btn,
.ps-header .btn,
.bs-header .btn,
.fw-header .btn,
.fn-header .btn,
.ew-header .btn,
.wp-header .btn,
.jn-header .btn,
.qs-project-bar .btn,
.project-actions .btn {
    min-height: 34px;
    border-radius: 8px !important;
    font-weight: 800;
    letter-spacing: 0;
    box-shadow: none;
}

.page-header .btn i,
.cs-page-header .btn i,
.ps-header .btn i,
.bs-header .btn i,
.fw-header .btn i,
.fn-header .btn i,
.ew-header .btn i,
.wp-header .btn i,
.jn-header .btn i,
.qs-project-bar .btn i {
    font-size: 0.95rem;
}

/* Main project + sub-project selector shared by all project-scoped pages */
.project-scope-control {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 100%;
}

.project-scope-field {
    min-width: 220px;
    max-width: min(420px, 100%);
    flex: 1 1 240px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.project-scope-sub-field {
    min-width: 190px;
    max-width: 340px;
    flex-basis: 210px;
}

.project-scope-label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: uppercase;
}

.project-scope-label i {
    color: var(--primary);
    font-size: 0.78rem;
}

.project-scope-select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 34px !important;
    padding: 5px 34px 5px 11px !important;
    border: 1.5px solid #b7c3d4 !important;
    border-radius: 8px !important;
    background-color: var(--surface-bg) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
    cursor: pointer;
    font-size: 0.82rem !important;
    font-weight: 800 !important;
}

.project-scope-select:hover {
    border-color: var(--primary) !important;
}

.project-scope-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(13, 13, 99, 0.13) !important;
}

.subtitle .project-scope-control,
.is-tags .project-scope-control {
    margin: 6px 0 6px;
}

.qs-project-bar {
    gap: 12px !important;
}

.qs-project-bar .project-scope-control {
    flex: 1 1 620px;
}

/* ── Forms ── */
.form-control, .form-select {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 0.45rem 0.75rem;
    font-size: 0.88rem;
    background: var(--surface-bg);
    color: var(--text-primary);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    outline: none;
}

.form-control-sm, .form-select-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

.form-control-lg {
    padding: 0.6rem 1rem;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-check-input {
    border-color: var(--border-strong);
    cursor: pointer;
}
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}
.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-switch .form-check-input {
    width: 2.25rem;
    height: 1.2rem;
}

.input-group-text {
    background: var(--surface-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ── Tables ── */
.data-table {
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.data-table table { margin: 0; }

.data-table thead th,
.table thead th {
    background: var(--surface-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table tbody td,
.table tbody td {
    padding: 11px 14px;
    vertical-align: middle;
    font-size: 0.88rem;
    color: var(--text-primary);
    border-color: var(--border-light);
}

.table tbody tr:hover,
.data-table tbody tr:hover {
    background-color: var(--surface-hover);
}

/* Editable cells */
.editable-cell {
    cursor: text;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    min-width: 60px;
    transition: border-color 0.15s, background 0.15s;
}
.editable-cell:hover {
    border-color: var(--border-color);
    background: var(--surface-secondary);
}
.editable-cell:focus {
    border-color: var(--primary);
    outline: none;
    background: var(--primary-subtle);
}
.editable-cell input {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    padding: 2px;
}

/* ── Badges ── */
.badge {
    font-weight: 500;
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.1px;
}

.badge.bg-primary { background: var(--primary-subtle) !important; color: var(--primary) !important; }
.badge.bg-success { background: #d1fae5 !important; color: #065f46 !important; }
.badge.bg-warning { background: #fef3c7 !important; color: #92400e !important; }
.badge.bg-danger { background: #fee2e2 !important; color: #991b1b !important; }
.badge.bg-info { background: #dbeafe !important; color: #1e40af !important; }
.badge.bg-secondary { background: var(--surface-tertiary) !important; color: var(--text-secondary) !important; }
.badge.bg-dark { background: var(--text-primary) !important; color: var(--surface-bg) !important; }

[data-theme="dark"] .badge.bg-primary { background: rgba(59, 130, 246, 0.15) !important; color: #93c5fd !important; }
[data-theme="dark"] .badge.bg-success { background: rgba(16, 185, 129, 0.15) !important; color: #6ee7b7 !important; }
[data-theme="dark"] .badge.bg-warning { background: rgba(245, 158, 11, 0.15) !important; color: #fcd34d !important; }
[data-theme="dark"] .badge.bg-danger { background: rgba(239, 68, 68, 0.15) !important; color: #fca5a5 !important; }
[data-theme="dark"] .badge.bg-info { background: rgba(14, 165, 233, 0.15) !important; color: #7dd3fc !important; }
[data-theme="dark"] .badge.bg-secondary { background: var(--surface-tertiary) !important; color: var(--text-secondary) !important; }

.badge-active { background: #d1fae5 !important; color: #065f46 !important; }
.badge-expired { background: #fee2e2 !important; color: #991b1b !important; }
.badge-pending { background: #fef3c7 !important; color: #92400e !important; }
.badge-cancelled { background: var(--surface-tertiary) !important; color: var(--text-secondary) !important; }

/* ── Modals ── */
.modal-content {
    background: var(--modal-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border-light);
    padding: 16px 20px;
}

.modal-title { font-weight: 600; font-size: 1.05rem; }

.modal-body { padding: 20px; }

.modal-footer {
    border-top: 1px solid var(--border-light);
    padding: 12px 20px;
    gap: 6px;
}

/* ── Nav Tabs / Pills ── */
.nav-tabs {
    border-bottom: 1px solid var(--border-color);
    gap: 2px;
}

.nav-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.12s ease;
}

.nav-tabs .nav-link:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border: none;
}

.nav-tabs .nav-link.active {
    background: transparent;
    color: var(--primary);
    font-weight: 600;
    border: none;
    border-bottom: 2px solid var(--primary);
    border-radius: 0;
}

.nav-pills .nav-link {
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
}

.nav-pills .nav-link:hover { background: var(--surface-hover); color: var(--text-primary); }

.nav-pills .nav-link.active {
    background: var(--primary);
    color: #fff;
}

/* ── Alerts ── */
.alert {
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    font-size: 0.88rem;
}

.alert-primary, .alert-info { background: var(--primary-subtle); color: var(--primary-dark); border-color: rgba(37, 99, 235, 0.2); }
.alert-success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

[data-theme="dark"] .alert-primary, [data-theme="dark"] .alert-info { background: rgba(59, 130, 246, 0.08); color: #93c5fd; border-color: rgba(59, 130, 246, 0.3); }
[data-theme="dark"] .alert-success { background: rgba(16, 185, 129, 0.08); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.3); }
[data-theme="dark"] .alert-warning { background: rgba(245, 158, 11, 0.08); color: #fcd34d; border-color: rgba(245, 158, 11, 0.3); }
[data-theme="dark"] .alert-danger { background: rgba(239, 68, 68, 0.08); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }

/* ── Subscription Bar ── */
.subscription-bar {
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    box-shadow: var(--shadow-xs);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.subscription-bar.warning { border-left: 3px solid var(--warning); }
.subscription-bar.danger { border-left: 3px solid var(--danger); background: var(--surface-accent-red); }
.subscription-bar.success { border-left: 3px solid var(--success); }

/* ── Summary Row ── */
.summary-row {
    background: var(--surface-secondary) !important;
    font-weight: 600;
}
.summary-row td { border-top: 2px solid var(--primary) !important; }

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 2.75rem;
    margin-bottom: 12px;
    color: var(--border-strong);
}

/* ── Dropdowns ── */
.dropdown-menu {
    --bs-dropdown-bg: var(--dropdown-bg);
    --bs-dropdown-color: var(--text-primary);
    --bs-dropdown-link-color: var(--text-primary);
    --bs-dropdown-link-hover-color: var(--text-primary);
    --bs-dropdown-link-hover-bg: var(--surface-hover);
    --bs-dropdown-link-active-bg: var(--primary-subtle);
    --bs-dropdown-link-active-color: var(--primary);
    background: var(--dropdown-bg) !important;
    background-color: var(--dropdown-bg) !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    font-size: 0.88rem;
    color: var(--text-primary);
    opacity: 1;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.dropdown-item {
    color: var(--text-primary);
    background-color: transparent;
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    transition: background 0.1s ease;
}

.dropdown-item:hover, .dropdown-item:focus {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.dropdown-divider { border-color: var(--border-light); margin: 4px 0; }

select,
.form-select,
.form-control,
.type-filter,
.sor-dept-select,
.project-scope-select {
    background-color: var(--surface-bg) !important;
    color: var(--text-primary) !important;
}

select option,
.form-select option {
    background-color: var(--surface-bg);
    color: var(--text-primary);
}

/* ── List Group ── */
.list-group-item {
    background: var(--surface-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    font-size: 0.9rem;
}

/* ── Pagination ── */
.page-link {
    color: var(--text-secondary);
    background: var(--surface-bg);
    border-color: var(--border-color);
    border-radius: var(--radius-sm);
    margin: 0 2px;
    font-size: 0.85rem;
}

.page-link:hover { background: var(--surface-hover); color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Toasts ── */
.toast {
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    backdrop-filter: blur(12px);
}

/* ── Accordion ── */
.accordion-item {
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    overflow: hidden;
}
.accordion-item:first-of-type, .accordion-item:last-of-type { border-radius: var(--radius-lg); }
.accordion-button {
    background: var(--surface-bg);
    color: var(--text-primary);
    font-weight: 500;
    padding: 12px 16px;
    font-size: 0.92rem;
}
.accordion-button:not(.collapsed) { background: var(--surface-secondary); color: var(--text-primary); box-shadow: none; }
.accordion-button:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.accordion-body { padding: 16px; background: var(--surface-bg); }
[data-theme="dark"] .accordion-button::after { filter: invert(1) brightness(2); }

/* ── Progress ── */
.progress {
    background: var(--border-color);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
}
.progress-bar { background: var(--primary); transition: width 0.3s ease; }

/* ── Breadcrumb (Windows File Explorer Style) ── */
.global-breadcrumb-shell {
    margin-bottom: 16px;
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px 12px;
    box-shadow: var(--shadow-sm);
    position: relative;
    /* Above sticky hub tab bars (bbs.html / boq.html use position:sticky; z-index:10).
       This shell forms a stacking context, so its OWN level must beat the tab bar or the
       breadcrumb's project/sub-project dropdown gets painted over by the later-in-DOM tabs
       no matter how high the dropdown's inner z-index is. Stays below modals/overlays (2000+). */
    z-index: 1050;
    overflow: visible;
}

/* Hub pages (boq/bbs/billing/client-billing) hardcode the container WITHOUT the shell
   class, so the stacking fix above never applied there and the project/sub-project
   dropdown painted BEHIND the sticky .hub-tabs (z-index:10) / iframe. Target the id
   directly so every page — inline markup or dynamically created — gets the lift. */
#globalBreadcrumbsContainer {
    position: relative;
    z-index: 1050;
    overflow: visible;
}

.global-breadcrumb {
    padding: 0;
    position: relative;
    z-index: 10;
    overflow: visible;
}

.global-breadcrumb .breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
    background: transparent;
    padding: 0;
    margin: 0;
    min-width: 0;
    position: relative;
    z-index: 10;
    overflow: visible;
}

.global-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    content: "\F285"; /* bootstrap icon chevron-right */
    font-family: "bootstrap-icons";
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0 4px;
    display: flex;
    align-items: center;
}

.global-breadcrumb .breadcrumb-item,
.global-breadcrumb .breadcrumb-item a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s ease;
    min-width: 0;
}

.global-breadcrumb .breadcrumb-item {
    flex: 0 1 auto;
    overflow: visible;
}

.global-breadcrumb .breadcrumb-item a,
.global-breadcrumb .breadcrumb-item.active {
    max-width: min(280px, 32vw);
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-breadcrumb .breadcrumb-item a:hover {
    background: var(--surface-hover, rgba(0,0,0,0.05));
    color: var(--text-primary);
    text-decoration: none;
}

[data-theme="dark"] .global-breadcrumb .breadcrumb-item a:hover {
    background: rgba(255,255,255,0.1);
}

.global-breadcrumb .breadcrumb-item.active {
    color: var(--text-muted);
    background: transparent;
}

.global-breadcrumb .dropdown-toggle {
    color: var(--text-primary);
}

.global-breadcrumb .dropdown-toggle::after {
    margin-left: 0.35rem;
}

.global-breadcrumb .dropdown {
    position: relative;
    overflow: visible;
}

/* When a breadcrumb project/sub-project dropdown is open, lift its stacking context
   above sticky hub tab bars (bbs.html, boq.html use position:sticky;z-index:10, which
   otherwise paint over the dropdown menu even though the menu itself is z-index:2050). */
.global-breadcrumb .dropdown.show {
    z-index: 3000;
}

.global-breadcrumb .dropdown-menu {
    z-index: 2050;
    min-width: 220px;
    max-width: min(360px, calc(100vw - 32px));
    max-height: min(360px, calc(100vh - 160px));
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--surface-bg, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: var(--shadow-lg, 0 10px 30px rgba(0,0,0,0.18));
}

/* Higher specificity than ".global-breadcrumb .breadcrumb-item a" so menu items are
   real block links (not the collapsed inline-flex breadcrumb links) and stay readable. */
.global-breadcrumb .dropdown-menu .dropdown-item {
    display: block !important;
    width: 100%;
    max-width: none !important;
    white-space: normal !important;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 8px 12px;
    color: var(--text-primary, #0f172a) !important;
    border-radius: 6px;
}
.global-breadcrumb .dropdown-menu .dropdown-item:hover,
.global-breadcrumb .dropdown-menu .dropdown-item:focus {
    background: var(--surface-hover, rgba(0,0,0,0.06)) !important;
    color: var(--text-primary, #0f172a) !important;
}
.global-breadcrumb .dropdown-menu .dropdown-item.active {
    background: var(--primary, #1e40af) !important;
    color: #fff !important;
}

/* Searchable-select dropdown (formula material picker, etc.) — guarantee readable
   contrast in both themes regardless of inline fallback colors. */
.cl-searchable-select-menu { background: var(--surface-bg, #fff) !important; border-color: var(--border-color, #cbd5e1) !important; }
.cl-searchable-select-trigger { background: var(--surface-bg, #fff) !important; color: var(--text-primary, #1e293b) !important; }
.cl-searchable-select-search { background: var(--surface-bg, #fff) !important; color: var(--text-primary, #1e293b) !important; border-color: var(--border-color, #cbd5e1) !important; }
.cl-searchable-select-option { color: var(--text-primary, #1e293b) !important; }
/* Selected option: light-blue highlight with readable text. Two-class selector +
   !important guarantees it beats the generic .cl-searchable-select-option color rule. */
.cl-searchable-select-option.cl-searchable-select-option--selected { background: #dbeafe !important; color: #0d2a6b !important; font-weight: 700 !important; }
[data-theme="dark"] .cl-searchable-select-menu { background: var(--surface-2, #1e1e1e) !important; }
[data-theme="dark"] .cl-searchable-select-trigger,
[data-theme="dark"] .cl-searchable-select-search,
[data-theme="dark"] .cl-searchable-select-option { color: var(--text-primary, #e2e8f0) !important; }
[data-theme="dark"] .cl-searchable-select-option.cl-searchable-select-option--selected { background: rgba(59, 130, 246, 0.30) !important; color: #dbeafe !important; }

/* -- Dark scrollbar -- */
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* -- Sidebar -- clear active state, sharp text -- */
[data-theme="dark"] #sidebar { background: var(--sidebar-bg) !important; }
[data-theme="dark"] .sidebar-link { color: rgba(255,255,255,0.85) !important; }
[data-theme="dark"] .sidebar-link:hover {
    background: rgba(250, 204, 21, 0.18) !important;
    color: var(--sidebar-text-active) !important;
}
[data-theme="dark"] .sidebar-link.active {
    background: var(--sidebar-active) !important;
    color: var(--sidebar-text-active) !important;
    font-weight: 600;
}
[data-theme="dark"] .sidebar-link.active::before {
    background: var(--sidebar-text-active) !important;
}
/* Bootstrap paints .btn-outline-dark with near-black text + border, which disappears on the
   dark background (e.g. the BBS "Revisions" button). Same treatment as the other outline
   buttons: theme tokens, so it reads in both themes. */
[data-theme="dark"] .btn-outline-dark {
    color: var(--text-primary) !important;
    border-color: var(--border-strong, #475569) !important;
}
[data-theme="dark"] .btn-outline-dark:hover,
[data-theme="dark"] .btn-outline-dark:focus,
[data-theme="dark"] .btn-outline-dark.active {
    background: rgba(254, 240, 138, 0.15) !important;
    border-color: #facc15 !important;
    color: #fef08a !important;
}
[data-theme="dark"] .btn-outline-secondary:hover {
    background: rgba(254, 240, 138, 0.15) !important;
    border-color: #facc15 !important;
    color: #fef08a !important;
}
[data-theme="dark"] .project-card .project-name {
    color: #ffffff !important;
    font-weight: 700;
}
[data-theme="dark"] .project-card .project-meta { color: var(--text-secondary) !important; }

/* -- Subscription bar / banners -- */
[data-theme="dark"] .subscription-bar {
    background: var(--surface-3) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* -- Modal headers -- */
[data-theme="dark"] .modal-header {
    border-bottom: 1px solid var(--border-strong);
}

/* -- Numeric currency in tables -- */
[data-theme="dark"] td .currency-cell,
[data-theme="dark"] .rate-display,
[data-theme="dark"] .amount-display {
    color: var(--primary-light) !important;
    font-weight: 600;
}

/* ── Headings — readable hierarchy ── */
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 {
    color: #ffffff !important;
}

/* ── Links — readable blue ── */
[data-theme="dark"] a:not(.btn):not(.sidebar-link):not(.nav-link):not(.dropdown-item) {
    color: var(--primary-light);
}
[data-theme="dark"] a:not(.btn):not(.sidebar-link):not(.nav-link):hover {
    color: #93c5fd;
}

/* ── Card body text — clear hierarchy ── */
[data-theme="dark"] .card-body { color: var(--text-primary); }
[data-theme="dark"] .card-body p { color: var(--text-secondary) !important; }
[data-theme="dark"] .card-body small,
[data-theme="dark"] .card-body .small { color: var(--text-muted) !important; }

/* ── Empty state ── */
[data-theme="dark"] .empty-state { color: var(--text-muted) !important; }
[data-theme="dark"] .empty-state i { color: var(--border-strong) !important; }

/* ════════════════════════════════════════════════════════════
   Typography Polish — Dark Mode Readability
   Construction software needs SHARP, READABLE labels everywhere.
   Bumps weight + opacity + brightness on small/secondary text.
   ════════════════════════════════════════════════════════════ */

/* ── Sidebar nav text — sharper + brighter ── */
[data-theme="dark"] .sidebar-link {
    color: #d8d8d8 !important;
    font-weight: 500;
}
[data-theme="dark"] .sidebar-link:hover {
    color: var(--sidebar-text-active) !important;
}
[data-theme="dark"] .sidebar-link.active {
    color: var(--sidebar-text-active) !important;
    font-weight: 600;
}
[data-theme="dark"] .sidebar-link i {
    opacity: 1;
    color: rgba(255,255,255,0.7);
}
[data-theme="dark"] .sidebar-link.active i,
[data-theme="dark"] .sidebar-link:hover i {
    color: var(--sidebar-text-active);
}

/* Sidebar section labels (SITE & QC, BILLING, ADMIN) */
[data-theme="dark"] .sidebar-section-label small {
    color: #888888 !important;
    font-weight: 700 !important;
    letter-spacing: 1.5px !important;
    font-size: 0.62rem !important;
    opacity: 1;
}

/* Sidebar header brand */
[data-theme="dark"] .sidebar-header h5,
[data-theme="dark"] .sidebar-header > div > div:first-child { color: #ffffff !important; }
[data-theme="dark"] .sidebar-header small { color: #b0b0b0 !important; }

/* Sidebar footer (user info + version) */
[data-theme="dark"] .sidebar-footer { color: #d8d8d8; }
[data-theme="dark"] .sidebar-footer strong,
[data-theme="dark"] .sidebar-footer .user-name { color: #ffffff !important; font-weight: 600; }
[data-theme="dark"] .sidebar-footer small,
[data-theme="dark"] .sidebar-footer .user-role,
[data-theme="dark"] .sidebar-footer .version-text { color: #a8a8a8 !important; }

/* ── Page-level section labels (CORE MODULES / SITE & QUALITY CONTROL / BILLING) ── */
[data-theme="dark"] .section-label,
[data-theme="dark"] .hub-section-label {
    color: #b0b0b0 !important;
    font-weight: 700 !important;
    letter-spacing: 1.2px;
    opacity: 1;
}

/* ── Project header subtitle (Civil Limitless PVT LTD • Raipur • ...) ── */
[data-theme="dark"] .hub-subtitle,
[data-theme="dark"] .project-meta,
[data-theme="dark"] .page-subtitle {
    color: #b8b8b8 !important;
    font-weight: 500;
}

/* ── Hub-tile descriptions (SOR, Measurement Book & Bill of Quantities) ── */
[data-theme="dark"] .hub-tile-desc {
    color: #c0c0c0 !important;
    line-height: 1.4;
}
[data-theme="dark"] .hub-tile-name {
    color: #ffffff !important;
    font-weight: 700;
}

/* ── Hub stat tiles (BOQ VALUE / GROUPS / MEASUREMENTS) ── */
[data-theme="dark"] .hub-stat-label {
    color: #a8a8a8 !important;
    font-weight: 700;
    letter-spacing: 1px;
}
[data-theme="dark"] .hub-stat-value {
    color: #ffffff !important;
    font-weight: 700;
}

/* ── All small text + .text-muted across pages — readable not invisible ── */
[data-theme="dark"] small,
[data-theme="dark"] .small,
[data-theme="dark"] .text-muted {
    color: #a8a8a8 !important;
}

/* ── Form labels — always readable ── */
[data-theme="dark"] label,
[data-theme="dark"] .form-label {
    color: #d8d8d8 !important;
    font-weight: 500;
}

/* ── Stat card values — hierarchy ── */
[data-theme="dark"] .stat-card .stat-value { color: #ffffff !important; font-weight: 700; }
[data-theme="dark"] .stat-card .stat-label { color: #a8a8a8 !important; font-weight: 700; letter-spacing: 0.8px; }

/* ── Page subheadings + secondary text ── */
[data-theme="dark"] .text-secondary { color: #d0d0d0 !important; }

/* ── Card title hierarchy ── */
[data-theme="dark"] .card-title { color: #ffffff !important; font-weight: 600; }
[data-theme="dark"] .card-subtitle { color: #b8b8b8 !important; }

/* ── Empty state text — visible but unobtrusive ── */
[data-theme="dark"] .empty-state { color: #a8a8a8 !important; }
[data-theme="dark"] .empty-state h5,
[data-theme="dark"] .empty-state h6 { color: #d0d0d0 !important; }

/* ── Table cell text crispness ── */
[data-theme="dark"] td { color: #e0e0e0 !important; }
[data-theme="dark"] th { color: #c8c8c8 !important; font-weight: 700 !important; letter-spacing: 0.5px; }

/* ── Modal body text hierarchy ── */
[data-theme="dark"] .modal-body { color: #e0e0e0 !important; }
[data-theme="dark"] .modal-body label { color: #d0d0d0 !important; }
[data-theme="dark"] .modal-body small,
[data-theme="dark"] .modal-body .text-muted { color: #a8a8a8 !important; }
[data-theme="dark"] .modal-title { color: #ffffff !important; font-weight: 600; }

/* ── Breadcrumb readability ── */
[data-theme="dark"] .breadcrumb-item { color: #b0b0b0; }
[data-theme="dark"] .breadcrumb-item.active { color: #d8d8d8 !important; }
[data-theme="dark"] .breadcrumb-item a { color: var(--primary-light); }

/* ── Anti-aliasing boost — sharper rendering on dark ── */
[data-theme="dark"] body,
[data-theme="dark"] body * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ════════════════════════════════════════════════════════════
   Guided Workflow — Dark mode polish
   ════════════════════════════════════════════════════════════ */
[data-theme="dark"] .guided-card {
    background: var(--surface-3) !important;
    border-color: var(--border-strong) !important;
    box-shadow: var(--card-shadow) !important;
}
[data-theme="dark"] .guided-eyebrow { color: #a8a8a8 !important; }
[data-theme="dark"] .guided-pct {
    background: rgba(59, 130, 246, 0.18) !important;
    color: var(--primary-light) !important;
}
[data-theme="dark"] .guided-title { color: #ffffff !important; }
[data-theme="dark"] .guided-subtitle { color: #b8b8b8 !important; }
[data-theme="dark"] .guided-progress-bar { background: var(--surface-2) !important; }
[data-theme="dark"] .guided-step {
    background: var(--surface-2) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .guided-step.current {
    background: rgba(59, 130, 246, 0.10) !important;
    border-color: rgba(59, 130, 246, 0.5) !important;
}
[data-theme="dark"] .guided-step.current:hover {
    background: rgba(59, 130, 246, 0.16) !important;
    border-color: var(--primary) !important;
}
[data-theme="dark"] .guided-step-num {
    background: var(--surface-4) !important;
    color: var(--text-muted) !important;
}
[data-theme="dark"] .guided-step.done .guided-step-num {
    background: var(--success) !important;
    color: #ffffff !important;
}
[data-theme="dark"] .guided-step.current .guided-step-num {
    background: var(--primary) !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.20) !important;
}
[data-theme="dark"] .guided-step-title { color: #ffffff !important; }
[data-theme="dark"] .guided-step-meta { color: #a8a8a8 !important; }
[data-theme="dark"] .guided-step-cta {
    background: var(--primary) !important;
    color: #ffffff !important;
}
[data-theme="dark"] .guided-step.done .guided-step-cta {
    background: var(--surface-4) !important;
    color: var(--text-secondary) !important;
}

/* ════════════════════════════════════════════════════════════
   Empty-state Coaching (used by emptyState() helper)
   ════════════════════════════════════════════════════════════ */
.empty-coach {
    text-align: center;
    padding: 48px 32px;
    border: 2px dashed var(--border-color);
    border-radius: 14px;
    background: var(--surface-secondary);
    color: var(--text-secondary);
}
.empty-coach .empty-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.empty-coach .empty-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.empty-coach .empty-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}
.empty-coach .empty-steps {
    text-align: left;
    max-width: 360px;
    margin: 0 auto 20px;
    padding-left: 22px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.7;
}
.empty-coach .empty-steps li::marker { color: var(--primary); font-weight: 700; }
[data-theme="dark"] .empty-coach {
    background: var(--surface-2) !important;
    border-color: var(--border-strong) !important;
}
[data-theme="dark"] .empty-coach .empty-icon { color: #6e6e6e !important; }
[data-theme="dark"] .empty-coach .empty-title { color: #ffffff !important; }
[data-theme="dark"] .empty-coach .empty-desc { color: #b8b8b8 !important; }
[data-theme="dark"] .empty-coach .empty-steps { color: #d0d0d0 !important; }

/* ════════════════════════════════════════════════════════════
   First-time User Tour (overlay + step bubble)
   ════════════════════════════════════════════════════════════ */
.tour-backdrop {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    backdrop-filter: blur(2px);
}
.tour-bubble {
    position: fixed;
    z-index: 9999;
    max-width: 360px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    padding: 20px 22px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
}
.tour-bubble .tour-step-num {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}
.tour-bubble h4 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--text-primary);
}
.tour-bubble p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 14px;
    line-height: 1.5;
}
.tour-bubble .tour-actions {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.tour-bubble .tour-progress { font-size: 0.75rem; color: var(--text-muted); }
.tour-bubble .tour-buttons { display: flex; gap: 8px; }
.tour-bubble .tour-skip {
    font-size: 0.78rem;
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; padding: 6px 10px;
}
.tour-bubble .tour-skip:hover { color: var(--text-secondary); }
.tour-bubble .tour-next {
    font-size: 0.82rem; padding: 6px 16px; border-radius: 6px;
    background: var(--primary); color: #fff; border: none; cursor: pointer; font-weight: 500;
}
.tour-bubble .tour-next:hover { background: var(--primary-dark); }

/* ── Skeleton loader (used for stat cards + tables while data fetches) ── */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-4) 50%, var(--surface-2) 100%) !important;
    background-size: 200% 100% !important;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    color: transparent !important;
    border-radius: var(--radius-sm);
    pointer-events: none;
    user-select: none;
}
@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
[data-theme="dark"] .loading-state {
    color: var(--text-muted) !important;
    padding: 24px;
    text-align: center;
}
[data-theme="dark"] .loading-state i {
    animation: spin 0.8s linear infinite;
    margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════
   Survey Modal — Eliminate White Border + Force Dark Throughout
   The surveyShared modal had `var(--bg-primary, #f8fafc)` fallback
   which showed as light gray border in dark mode. Force --surface-2.
   ════════════════════════════════════════════════════════════ */
[data-theme="dark"] .survey-modal-content,
[data-theme="dark"] .modal-content.survey-modal-content {
    background: var(--surface-3) !important;
    border: 1px solid var(--border-strong) !important;
    box-shadow: var(--shadow-xl) !important;
}
[data-theme="dark"] .survey-modal-body,
[data-theme="dark"] .modal-body.survey-modal-body {
    background: var(--surface-2) !important;
    color: var(--text-primary);
}
[data-theme="dark"] .survey-modal-body .ps-card,
[data-theme="dark"] .survey-modal-body .cs-card,
[data-theme="dark"] .survey-modal-body .bs-card,
[data-theme="dark"] .survey-modal-body .fw-card,
[data-theme="dark"] .survey-modal-body .fi-card,
[data-theme="dark"] .survey-modal-body .ew-card,
[data-theme="dark"] .survey-modal-body .wp-card,
[data-theme="dark"] .survey-modal-body .variants-block,
[data-theme="dark"] .survey-modal-body .ps-card.variants-block {
    background: var(--surface-3) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}
[data-theme="dark"] .survey-modal-body label,
[data-theme="dark"] .survey-modal-body .ps-label,
[data-theme="dark"] .survey-modal-body .cs-label,
[data-theme="dark"] .survey-modal-body .bs-label,
[data-theme="dark"] .survey-modal-body .fw-label,
[data-theme="dark"] .survey-modal-body .fi-label,
[data-theme="dark"] .survey-modal-body .ew-label,
[data-theme="dark"] .survey-modal-body .wp-label {
    color: #d8d8d8 !important;
    font-weight: 500;
}
[data-theme="dark"] .survey-modal-body input:not([type="radio"]):not([type="checkbox"]),
[data-theme="dark"] .survey-modal-body select,
[data-theme="dark"] .survey-modal-body textarea {
    background: var(--surface-1) !important;
    color: #ffffff !important;
    border: 1px solid var(--border-color) !important;
}
[data-theme="dark"] .survey-modal-body input::placeholder,
[data-theme="dark"] .survey-modal-body textarea::placeholder {
    color: var(--text-muted) !important;
}
[data-theme="dark"] .survey-modal-body small,
[data-theme="dark"] .survey-modal-body .ps-hint,
[data-theme="dark"] .survey-modal-body .cs-hint,
[data-theme="dark"] .survey-modal-body .bs-hint,
[data-theme="dark"] .survey-modal-body .fw-hint,
[data-theme="dark"] .survey-modal-body .fi-hint,
[data-theme="dark"] .survey-modal-body .ew-hint,
[data-theme="dark"] .survey-modal-body .wp-hint { color: var(--text-muted) !important; }

/* Element-type pills (Slab / Beam / Column / Wall / Footing / Staircase + Excavation/Backfill) */
/* Active state had blue bg + white text = readable. Inactive gray bg + white text was too subtle. */
[data-theme="dark"] .work-pill,
[data-theme="dark"] .element-pill,
[data-theme="dark"] .work-type-pill,
[data-theme="dark"] .et-pill,
[data-theme="dark"] .es-pill,
[data-theme="dark"] .ws-pill,
[data-theme="dark"] .fi-pill,
[data-theme="dark"] .formwork-element-pill,
[data-theme="dark"] .ew-element-pill,
[data-theme="dark"] .wp-element-pill {
    background: var(--surface-2) !important;
    border: 1px solid var(--border-color) !important;
    color: #d0d0d0 !important;
    font-weight: 500;
}
[data-theme="dark"] .work-pill.active,
[data-theme="dark"] .element-pill.active,
[data-theme="dark"] .work-type-pill.active,
[data-theme="dark"] .et-pill.active,
[data-theme="dark"] .es-pill.active,
[data-theme="dark"] .ws-pill.active,
[data-theme="dark"] .fi-pill.active,
[data-theme="dark"] .formwork-element-pill.active,
[data-theme="dark"] .ew-element-pill.active,
[data-theme="dark"] .wp-element-pill.active {
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Inline styled element-pills (some pages use inline `style="background:#1e40af;color:#fff"`) */
[data-theme="dark"] [style*="background:#1e40af"][style*="color:#fff"],
[data-theme="dark"] [style*="background:#0d9488"][style*="color:#fff"],
[data-theme="dark"] [style*="background:#7c3aed"][style*="color:#fff"],
[data-theme="dark"] [style*="background:#b45309"][style*="color:#fff"],
[data-theme="dark"] [style*="background:#0891b2"][style*="color:#fff"],
[data-theme="dark"] [style*="background:#92400e"][style*="color:#fff"] {
    /* Already has solid bg + white text — fine, but enhance contrast */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Site Photo / Input Units / Material Variants header cards */
[data-theme="dark"] .survey-modal-body [style*="background:var(--surface-bg"],
[data-theme="dark"] .survey-modal-body [style*="background: var(--surface-bg"] {
    background: var(--surface-3) !important;
    border-color: var(--border-color) !important;
}

/* Auto/Manual Working Method pills */
[data-theme="dark"] .working-method-pills .btn,
[data-theme="dark"] [data-method-pill] {
    background: var(--surface-2) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
}
[data-theme="dark"] .working-method-pills .btn.active,
[data-theme="dark"] [data-method-pill].active {
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
}

/* Volume / Cost orange/green strips at bottom of survey forms */
[data-theme="dark"] .calc-strip,
[data-theme="dark"] .total-strip,
[data-theme="dark"] [class*="-strip"] {
    filter: brightness(0.82) saturate(1.1);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

/* Force #ffffff text contrast on any solid colored button/pill (paranoia override) */
[data-theme="dark"] button[style*="color:#fff"],
[data-theme="dark"] a[style*="color:#fff"],
[data-theme="dark"] div[style*="color:#fff"] { color: #ffffff !important; }

/* ── Print-only PDFs always render light ── */
@media print {
    [data-theme="dark"] * { background: white !important; color: black !important; border-color: #ddd !important; }
}

/* ════════════════════════════════════════════════════════════
   Quick Wins Polish - Enhanced Loading States & Validation
   ════════════════════════════════════════════════════════════ */

/* Enhanced Loading States */
.loading-overlay-backdrop {
    animation: fadeIn 0.2s ease-out;
}

.loading-content {
    animation: slideUp 0.3s ease-out;
}

.loading-icon {
    animation: spin 1s linear infinite;
}

.loading-message {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.loading-dots {
    font-size: 0.8rem;
    opacity: 0.6;
    letter-spacing: 2px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Form Validation Styles */
.validation-error {
    font-size: 0.85rem;
    color: var(--danger);
    margin-top: 4px;
    display: none;
}

.validation-error::before {
    content: '⚠ ';
    margin-right: 4px;
}

input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

input.is-valid,
select.is-valid,
textarea.is-valid {
    border-color: var(--success) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

/* Enhanced Toast Actions */
.toast-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toast-actions .btn {
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toast-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Empty State Enhancements */
.empty-coach {
    padding: 40px 32px;
    text-align: center;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: var(--surface-2);
    animation: fadeIn 0.3s ease-out;
}

.empty-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

.empty-steps {
    text-align: left;
    margin: 20px 0;
    padding-left: 20px;
    color: var(--text-secondary);
}

.empty-steps li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.empty-steps li::marker {
    color: var(--primary);
    font-weight: bold;
}

/* Keyboard Shortcut Hints */
[data-theme="dark"] .keyboard-hint {
    background: var(--surface-3);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.keyboard-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
    cursor: pointer;
    transition: all 0.2s ease;
}

.keyboard-hint:hover {
    background: var(--surface-3);
    border-color: var(--primary);
    color: var(--primary);
}

.keyboard-hint kbd {
    background: var(--surface-4);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    padding: 2px 6px;
    font-family: inherit;
    font-size: 0.85em;
}

/* Button Loading States */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Table Enhancements */
.table-hover tbody tr:hover {
    background-color: var(--surface-hover);
    transition: background-color 0.15s ease;
}

.table-sortable th {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.table-sortable th:hover {
    background-color: var(--surface-3);
}

.table-sortable th::after {
    content: '⇅';
    position: absolute;
    right: 8px;
    opacity: 0.3;
    font-size: 0.8em;
}

.table-sortable th.sort-asc::after {
    content: '↑';
    opacity: 1;
}

.table-sortable th.sort-desc::after {
    content: '↓';
    opacity: 1;
}

/* Modal Enhancements */
.modal-content {
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-backdrop {
    animation: fadeIn 0.2s ease-out;
    /* NOTE: full-page backdrop-filter blur was removed — on heavy pages (dashboard
       charts) Chromium stalls compositing the whole viewport, which looked like the
       screen briefly going blank when a dialog opened. A plain dark scrim is instant. */
    background: #0b1020;
}
.modal-backdrop.show { opacity: 0.5; }
/* Native <dialog> elements — plain dark scrim (no expensive blur) */
dialog::backdrop {
    background: rgba(15, 23, 42, 0.5);
}

/* Input Focus Enhancements */
input:focus,
select:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    border-color: var(--primary) !important;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Success/Error States */
.state-success {
    border-left: 4px solid var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.state-error {
    border-left: 4px solid var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.state-warning {
    border-left: 4px solid var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.state-info {
    border-left: 4px solid var(--info);
    background: rgba(14, 165, 233, 0.05);
}

/* Progress Indicators */
.progress-bar-animated {
    animation: progressStrip 1s linear infinite;
}

@keyframes progressStrip {
    0% { background-position: 1rem 0; }
    100% { background-position: 0 0; }
}

/* Responsive Improvements */
@media (max-width: 768px) {
    .empty-coach {
        padding: 24px 16px;
    }

    .empty-icon {
        font-size: 2rem;
    }

    .keyboard-hint {
        display: none; /* Hide keyboard hints on mobile */
    }
}

/* Accessibility Improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Visible for Keyboard Navigation */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Skip to Content Link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.3s;
}

.skip-to-content:focus {
    top: 0;
}

/* ── Native Dialog Backdrop (Lightweight Blur) ── */
dialog {
    padding: 0;
    border: none;
    border-radius: var(--radius-xl);
    background: var(--surface-bg);
    color: var(--text-primary);
    box-shadow: var(--shadow-2xl);
    overflow: hidden;
}
[data-theme="dark"] dialog {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
}

dialog::backdrop {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
}
[data-theme="dark"] dialog::backdrop {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
}
/* Keep modal close buttons visible on gradient/dark headers and desktop WebView. */
/* Keep modal close buttons visible on gradient/dark headers and desktop WebView. */
.btn-close,
.btn-close-white {
    box-sizing: border-box !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    border-radius: 50% !important; /* Elegant circular shape */
    background-image: none !important; /* Remove bootstrap SVG background */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    opacity: 0.8 !important;
    cursor: pointer !important;
}

/* Unicode close symbol */
.btn-close::before,
.btn-close-white::before {
    content: "×" !important;
    font-family: system-ui, -apple-system, sans-serif !important;
    font-size: 20px !important;
    font-weight: 300 !important;
    line-height: 1 !important;
    display: block !important;
    text-align: center !important;
}

/* Light Mode modal headers close button (light modal header has default close button) */
.modal-header .btn-close {
    background-color: var(--surface-tertiary, #f1f5f9) !important;
    color: var(--text-primary, #000000) !important;
    border: 1px solid var(--border-color, #cbd5e1) !important;
}
.modal-header .btn-close:hover {
    background-color: var(--surface-pressed, #cbd5e1) !important;
    color: var(--text-primary, #000000) !important;
    opacity: 1 !important;
    transform: scale(1.08) !important;
}

/* Gradient/Dark-themed modal headers close button in Light Mode */
.modal-header[style*="background:linear-gradient"] .btn-close,
.modal-header[style*="background: linear-gradient"] .btn-close,
.modal-header .btn-close-white {
    background-color: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
}
.modal-header[style*="background:linear-gradient"] .btn-close:hover,
.modal-header[style*="background: linear-gradient"] .btn-close:hover,
.modal-header .btn-close-white:hover {
    background-color: rgba(255, 255, 255, 0.35) !important;
    color: #ffffff !important;
    opacity: 1 !important;
    transform: scale(1.08) !important;
}

/* Dark Theme overrides globally */
[data-theme="dark"] .btn-close,
[data-theme="dark"] .btn-close-white {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    filter: none !important; /* Remove bootstrap filter filters */
    opacity: 0.8 !important;
}
[data-theme="dark"] .btn-close:hover,
[data-theme="dark"] .btn-close-white:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    opacity: 1 !important;
    transform: scale(1.08) !important;
}

/* Prevent double scrollbars inside Embedded Quick Access views */
body.quick-access-embedded {
    overflow-y: auto !important;
    height: 100vh !important;
}

/* ============================================================
   Sidebar Collapse & Toggle Aesthetics (v1.0.242)
   ============================================================ */

/* Hide legacy hamburger button globally */
.sidebar-toggle {
    display: none !important;
}

/* Add smooth transition to main-content margins */
.main-content {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Sidebar width/slide transition (animate width so collapse shrinks to an icon rail) */
#sidebar {
    transition: width 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.32s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ── Collapsed = WhatsApp-style icon rail (shrink, keep icons) ── */
.sidebar-collapsed #sidebar {
    width: var(--sidebar-collapsed-width) !important;
    transform: none !important;
    overflow: visible !important;
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width) !important;
    padding-left: 28px !important;
}

/* Header: center the logo, hide brand text */
.sidebar-collapsed #sidebar > div:first-child {
    padding: 18px 0 14px !important;
    justify-content: center !important;
    gap: 0 !important;
}
.sidebar-collapsed #sidebar > div:first-child > div:last-child {
    display: none !important;
}

/* Nav list: keep room, center everything */
.sidebar-collapsed #sidebar ul.nav {
    padding-left: 8px !important;
    padding-right: 8px !important;
    overflow-x: visible !important;
}

/* Nav links → centered icon buttons */
.sidebar-collapsed .sidebar-link {
    justify-content: center !important;
    padding: 9px 0 !important;
    gap: 0 !important;
}
.sidebar-collapsed .sidebar-link i {
    margin: 0 !important;
    font-size: 1.12rem;
}
.sidebar-collapsed .sidebar-link-label,
.sidebar-collapsed .sidebar-feature-signal {
    display: none !important;
}
.sidebar-collapsed .sidebar-link.active::before {
    left: -4px;
    top: 6px;
    bottom: 6px;
}

/* Section headers: icon-only, still clickable to expand/collapse like the full sidebar */
.sidebar-collapsed .sidebar-section {
    margin-top: 6px !important;
}
.sidebar-collapsed .sidebar-section-toggle {
    justify-content: center !important;
    padding: 9px 0 !important;
    background: transparent;
}
.sidebar-collapsed .sidebar-section-toggle:hover {
    background: rgba(250, 204, 21, 0.18) !important;
    color: var(--sidebar-text-active, #FFFF00) !important;
}
/* Hide the section label text (the bare text node sits beside the icon in the span) */
.sidebar-collapsed .sidebar-section-toggle span {
    justify-content: center;
    gap: 0;
    font-size: 0; /* collapses the bare label text node */
    letter-spacing: 0; /* inherited 0.12em computes to fixed px on the button's font — even at font-size 0 it gave the hidden text ~10px width, pushing section icons ~4px left of the nav icons */
}
.sidebar-collapsed .sidebar-section-toggle span i:first-child {
    font-size: 1.12rem; /* same as nav-link icons */
    width: 20px;        /* same icon box → identical center line */
    text-align: center;
    opacity: 0.85;
}
.sidebar-collapsed .sidebar-section-chevron {
    display: none !important;
}
/* Section items keep their own collapsed/expanded state, exactly like the full sidebar */

/* The group whose fly-out is open stays highlighted, so it is obvious which one is selected */
.sidebar-collapsed .sidebar-section-toggle:not(.collapsed) {
    background: rgba(250, 204, 21, 0.18) !important;
    color: var(--sidebar-text-active, #fcd34d) !important;
    border-radius: 8px;
    box-shadow: inset 3px 0 0 var(--sidebar-text-active, #fcd34d);
}
.sidebar-collapsed .sidebar-section-toggle:not(.collapsed) span i:first-child {
    opacity: 1;
}

/* Collapsed rail: an OPEN section opens as a labelled fly-out panel beside the rail
   (icon-only children in a 62px rail are impossible to identify). `top` is set in JS. */
.sidebar-collapsed .sidebar-section-items:not(.collapsed) {
    position: fixed;
    left: calc(var(--sidebar-collapsed-width) + 4px);
    width: max-content;      /* the base rule stretches it to the viewport otherwise */
    min-width: 210px;
    max-width: 280px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: 6px !important;
    margin: 0 !important;
    background: var(--sidebar-bg, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    z-index: 1200;
}
/* …and its links look like the FULL sidebar again: icon + label, left aligned */
.sidebar-collapsed .sidebar-section-items:not(.collapsed) .sidebar-link {
    justify-content: flex-start !important;
    padding: 8px 10px !important;
    gap: 10px !important;
    white-space: nowrap;
}
.sidebar-collapsed .sidebar-section-items:not(.collapsed) .sidebar-link-label {
    display: inline !important;
    font-size: 0.86rem;
}
.sidebar-collapsed .sidebar-section-items:not(.collapsed) .sidebar-feature-signal {
    display: inline-block !important;
}

/* Footer: avatar + theme toggle only, stacked & centered */
.sidebar-collapsed .sidebar-footer {
    left: 8px !important;
    right: 8px !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 10px 4px !important;
    min-height: 0 !important;
    align-items: center !important;
}
.sidebar-collapsed .sidebar-user-meta {
    display: none !important;
}

/* Floating tooltip shown on hover over a rail icon */
.sidebar-rail-tip {
    position: fixed;
    transform: translateY(-50%) translateX(-6px);
    background: #0D0D63;
    color: #fff;
    padding: 6px 11px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease;
}
.sidebar-rail-tip.show {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}
[data-theme="dark"] .sidebar-rail-tip {
    background: #2563eb;
    border-color: rgba(255, 255, 255, 0.2);
}

/* ── Center EVERY Bootstrap modal as a floating popup, project-wide ──
   Mimics Bootstrap's .modal-dialog-centered for all dialogs that didn't opt in,
   so every dialog box opens as a centered popup (faster, consistent). */
.modal-dialog:not(.modal-dialog-centered):not(.modal-fullscreen) {
    display: flex;
    align-items: center;
    min-height: calc(100% - 1rem);
}
@media (min-width: 576px) {
    .modal-dialog:not(.modal-dialog-centered):not(.modal-fullscreen) {
        min-height: calc(100% - 3.5rem);
    }
}

/* ── One smooth, centered, FLASH-FREE open for EVERY dialog (authoritative) ──
   Earlier rules animated .modal-content two ways (ds-dialog-appear + modalSlideIn)
   AND Bootstrap slid .modal-dialog from the top — that fought the flex-centering
   and caused a first-frame flash. Fix: disable those keyframe animations and the
   top-slide, then drive the entrance with a TRANSITION keyed off Bootstrap's
   `.show` (added one frame after display:block), which cannot first-frame-flash. */
.modal.fade .modal-dialog {
    transform: none !important;
    transition: none !important;
}
.modal-content {
    animation: none !important;       /* kill ds-dialog-appear / modalSlideIn */
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: center center;
}
.modal.show .modal-content {
    opacity: 1;
    transform: scale(1);
}
@keyframes clPopIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}
/* Native <dialog> elements (no .show toggle) — keyframe scale-in, browser-centered */
dialog[open] {
    animation: clPopIn 0.2s cubic-bezier(0.22, 1, 0.36, 1) both !important;
    transform-origin: center center;
}

/* ── Native-app feel: disable text selection globally (keep it inside fields) ── */
html, body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
input, textarea, select, [contenteditable="true"], [contenteditable=""] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Glassy Toggle Handle Button */
/* Glassy Toggle Handle Button */
.sidebar-toggle-handle {
    position: fixed;
    top: 24px;
    left: calc(var(--sidebar-width) - 26px);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #0D0D63; /* Navy brand color */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1010; /* Above fixed sidebar (100) and headers */
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
                background-color 0.2s ease, 
                border-color 0.2s ease,
                color 0.2s ease;
    padding: 0;
}

.sidebar-toggle-handle i {
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-handle:hover {
    background: #ffffff;
    transform: scale(1.1);
    border-color: #DE076E; /* Pink/Accent brand color */
    color: #DE076E;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2);
}

.sidebar-collapsed .sidebar-toggle-handle {
    left: calc(var(--sidebar-collapsed-width) - 14px) !important;
    background: rgba(13, 13, 99, 0.9);
    border-color: rgba(255, 255, 255, 0.15);
    color: #FFFF00; /* Yellow accent */
    box-shadow: 0 4px 16px rgba(13, 13, 99, 0.4);
}

.sidebar-collapsed .sidebar-toggle-handle:hover {
    background: #0D0D63;
    border-color: #FFFF00;
    color: #FFFF00;
}

/* Dark theme glassy overrides */
[data-theme="dark"] .sidebar-toggle-handle {
    background: rgba(22, 22, 22, 0.85);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .sidebar-toggle-handle:hover {
    background: #2c2c2c;
    border-color: #3b82f6; /* Blue in dark theme */
    color: #3b82f6;
}

[data-theme="dark"] .sidebar-collapsed .sidebar-toggle-handle {
    background: rgba(59, 130, 246, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
}

[data-theme="dark"] .sidebar-collapsed .sidebar-toggle-handle:hover {
    background: #3b82f6;
    border-color: #ffffff;
    color: #ffffff;
}

/* ── F11 Presentation (Distraction-free) Mode ── */
.presentation-mode #sidebar,
.presentation-mode .sidebar-toggle-handle,
.presentation-mode .global-breadcrumb-shell,
.presentation-mode .project-topbar,
.presentation-mode .project-tabs,
.presentation-mode .hub-header,
.presentation-mode .hub-tabs,
.presentation-mode .dt-topbar {
    display: none !important;
}

.presentation-mode .main-content {
    margin-left: 0 !important;
    padding-top: 10px !important;
    width: 100vw !important;
    height: 100vh !important;
}

/* ===== SOR Picker (sor-picker.js) ===== */
#sorPickerRoot { display: none; }
#sorPickerRoot.open { display: block; }
body.sorp-open { overflow: hidden; }

.sorp-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 13000;
    animation: sorp-fade 120ms ease;
}
.sorp-dialog {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(960px, calc(100vw - 36px));
    height: min(640px, calc(100vh - 36px));
    background: var(--surface-1, #ffffff);
    color: var(--text-primary, #0f172a);
    border-radius: 14px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.08);
    z-index: 13001;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: sorp-pop 140ms ease;
}
.sorp-dialog-compact {
    width: min(920px, calc(100vw - 36px));
    height: min(620px, calc(100vh - 36px));
}
[data-theme="dark"] .sorp-dialog {
    background: #1c1c1e;
    color: #f1f5f9;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
@keyframes sorp-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sorp-pop { from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.sorp-head {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}
[data-theme="dark"] .sorp-head { border-bottom-color: #2a2a2e; }
.sorp-head-icon-inline {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.sorp-head-title {
    font-size: 0.95rem; font-weight: 700; line-height: 1.2;
    white-space: nowrap;
    flex-shrink: 0;
}
.sorp-search-inline {
    flex: 1 1 200px;
    position: relative;
    min-width: 160px;
}
.sorp-search-inline i {
    position: absolute; left: 9px; top: 50%;
    transform: translateY(-50%);
    color: #64748b; font-size: 0.85rem;
}
.sorp-search-inline input {
    width: 100%;
    padding: 6px 10px 6px 28px;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 7px;
    font-size: 0.82rem;
    background: var(--surface-2, #f8fafc);
    color: inherit;
    outline: none;
}
.sorp-search-inline input:focus { border-color: #1e40af; box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.18); }
[data-theme="dark"] .sorp-search-inline input { background: #2a2a2e; border-color: #3a3a40; color: #f1f5f9; }
[data-theme="dark"] .sorp-search-inline input::placeholder { color: #94a3b8; }
.sorp-close {
    border: 0; background: transparent;
    color: var(--text-primary, #0f172a);
    width: 30px; height: 30px;
    border-radius: 7px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sorp-close:hover { background: rgba(15, 23, 42, 0.06); }
[data-theme="dark"] .sorp-close { color: #f1f5f9; }
[data-theme="dark"] .sorp-close:hover { background: rgba(255, 255, 255, 0.08); }

.sorp-filter-row {
    display: flex; gap: 8px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-wrap: wrap;
}
[data-theme="dark"] .sorp-filter-row { border-bottom-color: #2a2a2e; }
.sorp-filter-select {
    flex: 1 1 0;
    min-width: 120px;
    padding: 5px 8px;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 6px;
    font-size: 0.78rem;
    background: var(--surface-1, #ffffff);
    color: var(--text-primary, #0f172a);
    outline: none;
    cursor: pointer;
}
.sorp-filter-select:focus { border-color: #1e40af; box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.16); }
[data-theme="dark"] .sorp-filter-select { background: #2a2a2e; border-color: #3a3a40; color: #f1f5f9; }
[data-theme="dark"] .sorp-filter-select option { background: #1c1c1e; color: #f1f5f9; }

.sorp-private-toggle {
    display: inline-flex;
    border-radius: 999px;
    background: var(--surface-2, #f1f5f9);
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
}
[data-theme="dark"] .sorp-private-toggle { background: #2a2a2e; }
.sorp-toggle-btn {
    border: 0;
    background: transparent;
    padding: 4px 10px;
    font-size: 0.74rem;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    color: var(--text-muted, #64748b);
}
.sorp-toggle-btn.active {
    background: #ffffff;
    color: #1e40af;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .sorp-toggle-btn { color: #94a3b8; }
[data-theme="dark"] .sorp-toggle-btn.active { background: #0f172a; color: #93c5fd; }

.sorp-recent {
    padding: 6px 14px 0 14px;
    display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
}
.sorp-recent-label {
    font-size: 0.72rem; color: var(--text-muted, #64748b); font-weight: 600;
    margin-right: 4px;
}
.sorp-recent-chip {
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--surface-2, #f8fafc);
    color: inherit;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    cursor: pointer;
}
.sorp-recent-chip:hover { border-color: #1e40af; color: #1e40af; }
[data-theme="dark"] .sorp-recent-chip { background: #2a2a2e; border-color: #3a3a40; }
[data-theme="dark"] .sorp-recent-chip:hover { border-color: #93c5fd; color: #93c5fd; }

/* Legacy left-rail layout kept for any callers that still use .sorp-body.
   The compact picker uses .sorp-filter-row instead. */
.sorp-body {
    flex: 1; min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
}

.sorp-list-wrap { overflow: hidden; display: flex; flex-direction: column; }
.sorp-list { overflow-y: auto; padding: 8px 14px; flex: 1; min-height: 0; }
.sorp-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 9px;
    margin-bottom: 6px;
    background: var(--surface-1, #fff);
    cursor: pointer;
    transition: border-color 100ms, transform 80ms;
}
.sorp-row:hover { border-color: #1e40af; transform: translateY(-1px); }
.sorp-row.selected { border-color: #1e40af; background: rgba(30, 64, 175, 0.05); }
.sorp-row[data-private="1"] { border-left: 3px solid #be185d; }
[data-theme="dark"] .sorp-row { background: #1c1c1e; border-color: #2a2a2e; }
[data-theme="dark"] .sorp-row:hover { border-color: #93c5fd; }
.sorp-row-main { flex: 1; min-width: 0; }
.sorp-row-name { font-weight: 700; font-size: 0.92rem; color: inherit; }
.sorp-row-meta { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.sorp-row-right { display: flex; align-items: center; gap: 8px; }
.sorp-row-edit {
    width: 30px; height: 30px;
    border: 1px solid var(--border-color, #cbd5e1);
    background: var(--surface-1, #fff);
    color: var(--text-muted, #475569);
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
    transition: all 100ms;
}
.sorp-row-edit:hover { background: #1e40af; color: #fff; border-color: #1e40af; }
[data-theme="dark"] .sorp-row-edit { background: #2a2a2e; border-color: #3a3a40; color: #cbd5e1; }
[data-theme="dark"] .sorp-row-edit:hover { background: #2563eb; border-color: #2563eb; color: #fff; }

.sorp-group { margin-bottom: 14px; }
.sorp-group-head {
    font-size: 0.78rem; font-weight: 700;
    color: var(--text-muted, #64748b);
    padding: 6px 4px 6px 4px;
    border-bottom: 1px dashed var(--border-color, #e5e7eb);
    margin-bottom: 6px;
    display: flex; align-items: center; justify-content: space-between;
    letter-spacing: 0.02em;
}
[data-theme="dark"] .sorp-group-head { border-bottom-color: #2a2a2e; color: #94a3b8; }
.sorp-grp-country { color: #1e40af; font-weight: 800; text-transform: uppercase; }
[data-theme="dark"] .sorp-grp-country { color: #93c5fd; }
.sorp-grp-state { color: var(--text-primary, #0f172a); }
[data-theme="dark"] .sorp-grp-state { color: #f1f5f9; }
.sorp-grp-sep { opacity: 0.5; margin: 0 4px; }
.sorp-group-count {
    background: var(--surface-2, #f1f5f9);
    color: var(--text-muted, #64748b);
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 0.7rem;
}
[data-theme="dark"] .sorp-group-count { background: #2a2a2e; color: #cbd5e1; }

.sorp-row-count {
    font-weight: 700; font-size: 1rem; color: #1e40af;
    text-align: right; min-width: 90px;
}
.sorp-row-count small { font-weight: 500; color: var(--text-muted, #64748b); margin-left: 2px; font-size: 0.7rem; }
[data-theme="dark"] .sorp-row-count { color: #93c5fd; }
.sorp-pill {
    display: inline-flex; align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem; font-weight: 700;
    letter-spacing: 0.02em;
}
.sorp-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--surface-2, #f1f5f9);
    color: var(--text-muted, #475569);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.72rem;
}
[data-theme="dark"] .sorp-chip { background: #2a2a2e; color: #cbd5e1; }
.sorp-recent-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #f59e0b;
    margin-right: 6px;
    vertical-align: middle;
}
.sorp-empty {
    text-align: center;
    color: var(--text-muted, #64748b);
    padding: 40px 20px;
    font-size: 0.88rem;
}
.sorp-empty i { font-size: 1.6rem; opacity: 0.6; }

.sorp-foot {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 14px;
    border-top: 1px solid var(--border-color, #e5e7eb);
    background: var(--surface-2, #f8fafc);
    gap: 10px;
    flex-shrink: 0;
}
[data-theme="dark"] .sorp-foot { background: #16161a; border-top-color: #2a2a2e; }
.sorp-foot-right { display: flex; align-items: center; gap: 12px; }
.sorp-foot-count { font-size: 0.78rem; color: var(--text-muted, #64748b); }
.sorp-btn-ghost, .sorp-btn-primary {
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 0.82rem; font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    display: inline-flex; align-items: center; gap: 6px;
}
.sorp-btn-ghost {
    background: transparent;
    color: var(--text-primary, #0f172a);
    border-color: var(--border-color, #cbd5e1);
}
.sorp-btn-ghost:hover { background: rgba(15, 23, 42, 0.05); }
[data-theme="dark"] .sorp-btn-ghost { color: #f1f5f9; border-color: #3a3a40; }
[data-theme="dark"] .sorp-btn-ghost:hover { background: rgba(255, 255, 255, 0.05); }
.sorp-btn-primary {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: #fff;
}
.sorp-btn-primary:hover { filter: brightness(1.08); }

/* SOR chip button used on host pages */
.sor-pick-chip {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--border-color, #cbd5e1);
    background: var(--surface-1, #fff);
    color: var(--text-primary, #0f172a);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.82rem; font-weight: 600;
    cursor: pointer;
}
.sor-pick-chip:hover { border-color: #1e40af; color: #1e40af; }
.sor-pick-chip i { font-size: 0.85rem; }
[data-theme="dark"] .sor-pick-chip { background: #2a2a2e; border-color: #3a3a40; color: #f1f5f9; }
[data-theme="dark"] .sor-pick-chip:hover { border-color: #93c5fd; color: #93c5fd; }

/* ===== Login page CTA tiles + tertiary row ===== */
.cta-divider {
    display:flex; align-items:center; gap:10px;
    color: var(--text-muted, #94a3b8);
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em;
    margin: 14px 0 10px;
}
.cta-divider::before, .cta-divider::after {
    content: ''; flex: 1; height: 1px;
    background: var(--border-color, #e5e7eb);
}
[data-theme="dark"] .cta-divider::before, [data-theme="dark"] .cta-divider::after { background: #2a2a2e; }

.cta-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}
.cta-tile {
    flex: 1;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 8px 10px;
    border-radius: 12px;
    background: var(--surface-2, #f8fafc);
    color: var(--text-primary, #0f172a);
    border: 1px solid var(--border-color, #e5e7eb);
    transition: all 140ms;
    text-align: center;
    position: relative;
}
.cta-tile:hover {
    border-color: #1e40af;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(30, 64, 175, 0.18);
    color: #1e40af;
    background: #fff;
}
[data-theme="dark"] .cta-tile { background: #2a2a2e; border-color: #3a3a40; color: #f1f5f9; }
[data-theme="dark"] .cta-tile:hover { border-color: #93c5fd; color: #93c5fd; background: #1c1c1e; box-shadow: 0 10px 24px rgba(147, 197, 253, 0.18); }
.cta-icon {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    margin-bottom: 6px;
    box-shadow: 0 4px 10px rgba(30, 64, 175, 0.30);
}
.cta-tile:hover .cta-icon { transform: scale(1.05); }
.cta-title { font-weight: 700; font-size: 0.9rem; line-height: 1.1; }
.cta-sub { font-size: 0.7rem; color: var(--text-muted, #64748b); margin-top: 2px; line-height: 1.2; }
[data-theme="dark"] .cta-sub { color: #94a3b8; }
.cta-tile:hover .cta-sub { color: inherit; opacity: 0.75; }

.login-tertiary {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    color: var(--text-muted, #64748b);
    font-size: 0.74rem;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color, #e5e7eb);
}
[data-theme="dark"] .login-tertiary { border-top-color: #2a2a2e; }
.login-tertiary a {
    color: var(--text-muted, #64748b);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 100ms;
}
.login-tertiary a:hover { color: #1e40af; }
[data-theme="dark"] .login-tertiary a:hover { color: #93c5fd; }
.login-tertiary .dot { opacity: 0.45; font-size: 0.6rem; }
.login-tertiary .ver { opacity: 0.55; font-family: 'Courier New', monospace; font-size: 0.7rem; padding: 1px 6px; background: var(--surface-2, #f1f5f9); border-radius: 4px; }
[data-theme="dark"] .login-tertiary .ver { background: #2a2a2e; }

/* Topbar active-dept pill — replaces the flat <select> on the SOR page */
.sor-active-pill {
    display: inline-flex; align-items: center; gap: 10px;
    min-width: 320px;
    max-width: 520px;
    padding: 8px 14px;
    border: 1px solid var(--border-color, #cbd5e1);
    background: var(--surface-1, #ffffff);
    color: var(--text-primary, #0f172a);
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 100ms, box-shadow 100ms;
    text-align: left;
}
.sor-active-pill > span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sor-active-pill:hover {
    border-color: #1e40af;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.10);
}
.sor-active-pill > i:first-child { color: #1e40af; }
[data-theme="dark"] .sor-active-pill {
    background: #2a2a2e; border-color: #3a3a40; color: #f1f5f9;
}
[data-theme="dark"] .sor-active-pill:hover {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.15);
}
[data-theme="dark"] .sor-active-pill > i:first-child { color: #93c5fd; }

@media (max-width: 720px) {
    .sorp-body { grid-template-columns: 1fr; }
    .sorp-rail {
        max-height: 36vh;
        border-right: 0;
        border-bottom: 1px solid var(--border-color, #e5e7eb);
    }
}

/* ── 2-line clamp for long SOR descriptions (Estimation & BOQ lists) ──
   .cl-clamp2 caps the text at 2 lines; .cl-more-btn is the dark "Show more"
   pill revealed by clInitLineClamps() only when the text actually overflows. */
.cl-clamp2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    position: relative;
}
/* A quiet text-link, not a chip: it inherits the size of the line it sits in and is
   bold enough to spot, but muted so it never fights the description for attention.
   The --body-bg fill is not decoration — it masks the clamped text running behind the
   button (same colour the fade below ends on), so it reads as "no background". */
.cl-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    align-self: center;
    padding: 0 0 0 4px;
    background: var(--body-bg);
    color: var(--text-muted, #64748b);
    border: none;
    border-radius: 0;
    font-size: inherit;
    font-weight: 700;
    line-height: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.12s;
}
.cl-more-btn i { font-size: 0.85em; opacity: 0.8; }
.cl-more-btn:hover { color: var(--primary, #1e40af); text-decoration: underline; }
[data-theme="dark"] .cl-more-btn { color: #94a3b8; }
[data-theme="dark"] .cl-more-btn:hover { color: #93c5fd; }

/* Collapsed: the button lives INSIDE .cl-clamp2 and pins to the end of the
   last (2nd) line instead of wrapping onto a 3rd line; a short fade hides the
   text it overlaps. Expanded (class removed) it flows inline after the text. */
.cl-clamp2 > .cl-more-btn { position: absolute; right: 0; bottom: 0; margin-top: 0; }
.cl-clamp2 > .cl-more-btn::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 0;
    bottom: 0;
    width: 26px;
    background: linear-gradient(to right, transparent, var(--body-bg));
    pointer-events: none;
}



/* ══════════════════════════════════════════════════════════════════════════════
   LEDGER PREMIUM OVERRIDE LAYER (design language — see DESIGN-LANGUAGE.md)
   Line-pattern editorial UI: hairline rules instead of enclosed boxes, zero
   gradients, small-caps labels + tabular numerals. Loaded LAST so it wins over
   the legacy component styles above; page <style> blocks still override it.
   Floating surfaces (modals, dropdowns, toasts) intentionally stay boxed.
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Cards → open sections (transparent, rule-topped) ── */
.card { background: transparent; border: 0; border-top: 1px solid var(--border-strong); border-radius: 0; box-shadow: none; }
.card-header { background: transparent; border-bottom: 1px solid var(--border-color); padding: 12px 4px; }
.card-body { padding: 16px 4px; }
.modal-content .card, dialog .card { border-top-color: var(--border-color); } /* inside dialogs keep it quiet */

/* ── Stat cards → flat KPI blocks (left tick accent, no lift/shadow) ── */
.stat-card { background: transparent; border: 0; border-top: 1px solid var(--border-strong); border-left: 3px solid var(--sc-accent, var(--primary)); border-radius: 0; box-shadow: none; }
.stat-card:hover { transform: none; box-shadow: none; }
.stat-value { font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-card .stat-icon { background: transparent !important; border: 0 !important; box-shadow: none !important; }

/* ── Buttons: flat, radius 6, no hover-lift ── */
.btn { border-radius: 6px; box-shadow: none; }
.btn:hover { transform: none; box-shadow: none; }
.btn:active { transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary); border-color: var(--primary); filter: brightness(1.3); }

/* ── Tables: rule-work, no enclosure ── */
.data-table { background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.data-table thead th, .table thead th { background: transparent; border-bottom: 1px solid var(--border-strong); font-size: 0.66rem; font-weight: 750; letter-spacing: 0.07em; }
.data-table tbody td, .table tbody td { background: transparent; }
.table tfoot td { background: transparent; border-top: 2px solid var(--border-strong); font-weight: 750; font-variant-numeric: tabular-nums; }

/* ── Badges → dot + small-caps text (status); neutral = plain muted text ── */
.badge { background: transparent !important; padding: 0; border-radius: 0; font-size: 0.68rem; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 6px; }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge.bg-secondary::before, .badge.bg-dark::before, .badge.bg-light::before, .badge-cancelled::before { content: none; }
.badge.bg-primary { background: transparent !important; color: var(--primary) !important; }
.badge.bg-success, .badge-active { background: transparent !important; color: #15803d !important; }
.badge.bg-warning, .badge-pending { background: transparent !important; color: #b45309 !important; }
.badge.bg-danger, .badge-expired { background: transparent !important; color: #dc2626 !important; }
.badge.bg-info { background: transparent !important; color: #2563eb !important; }
.badge.bg-secondary, .badge-cancelled { background: transparent !important; color: var(--text-muted) !important; }
.badge.bg-dark { background: transparent !important; color: var(--text-primary) !important; }
[data-theme="dark"] .badge.bg-primary { background: transparent !important; color: #93c5fd !important; }
[data-theme="dark"] .badge.bg-success, [data-theme="dark"] .badge-active { background: transparent !important; color: #86efac !important; }
[data-theme="dark"] .badge.bg-warning, [data-theme="dark"] .badge-pending { background: transparent !important; color: #fcd34d !important; }
[data-theme="dark"] .badge.bg-danger, [data-theme="dark"] .badge-expired { background: transparent !important; color: #fca5a5 !important; }
[data-theme="dark"] .badge.bg-info { background: transparent !important; color: #7dd3fc !important; }

/* ── Alerts → left-rule notes ── */
.alert { border: 0; border-left: 2px solid var(--border-strong); border-radius: 0; background: transparent; padding: 6px 14px; }
.alert-primary, .alert-info { background: transparent; border-left-color: #2563eb; color: var(--primary-dark); }
.alert-success { background: transparent; border-left-color: #15803d; color: #15803d; }
.alert-warning { background: transparent; border-left-color: #d97706; color: #b45309; }
.alert-danger { background: transparent; border-left-color: #dc2626; color: #b91c1c; }
[data-theme="dark"] .alert-primary, [data-theme="dark"] .alert-info { background: transparent; color: #93c5fd; }
[data-theme="dark"] .alert-success { background: transparent; color: #86efac; }
[data-theme="dark"] .alert-warning { background: transparent; color: #fcd34d; }
[data-theme="dark"] .alert-danger { background: transparent; color: #fca5a5; }

/* ── Pills → underline tabs ── */
.nav-pills .nav-link { border-radius: 0; }
.nav-pills .nav-link.active { background: transparent; color: var(--primary); box-shadow: inset 0 -2px 0 var(--primary); }

/* ── Progress: 3px flat ── */
.progress { height: 3px; border-radius: 0; background: var(--surface-pressed); }
.progress-bar { background: var(--primary); }

/* ── Breadcrumb shell: transparent strip over a rule ── */
.global-breadcrumb-shell { background: transparent; border: 0; border-bottom: 1px solid var(--border-color); border-radius: 0; box-shadow: none; padding: 4px 2px 8px; }

/* ── Reusable Ledger Premium primitives (USE THESE on pages — see DESIGN-LANGUAGE.md) ── */
.lp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: 26px; border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); }
.lp-kpi { background: transparent; border: 0; border-left: 1px solid var(--border-color); border-radius: 0; padding: 14px 18px 15px; min-width: 0; }
.lp-kpi:nth-child(4n+1) { border-left: 0; padding-left: 2px; }
.lp-kpi .lp-label { font-size: 0.63rem; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 7px; }
.lp-kpi .lp-label::before { content: ''; width: 3px; height: 11px; background: var(--lp-accent, var(--primary)); flex: 0 0 auto; }
.lp-kpi .lp-value { margin-top: 8px; font-size: 1.42rem; font-weight: 650; color: var(--text-primary); line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.lp-kpi .lp-foot { margin-top: 5px; font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.lp-kpi.k-blue { --lp-accent: #2563eb; } .lp-kpi.k-violet { --lp-accent: #7c3aed; } .lp-kpi.k-green { --lp-accent: #16a34a; } .lp-kpi.k-amber { --lp-accent: #d97706; } .lp-kpi.k-red { --lp-accent: #dc2626; }
@media (max-width: 840px) {
  .lp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lp-kpi:nth-child(2n+1) { border-left: 0; padding-left: 2px; }
  .lp-kpi:nth-child(n+3) { border-top: 1px solid var(--border-color); }
}
@media (max-width: 680px) {
  .lp-kpis { grid-template-columns: 1fr; }
  .lp-kpi { border-left: 0; padding-left: 2px; }
  .lp-kpi:nth-child(n+2) { border-top: 1px solid var(--border-color); }
}

.lp-section { background: transparent; border: 0; border-radius: 0; padding: 0; margin-bottom: 32px; }
.lp-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-bottom: 9px; border-bottom: 1px solid var(--border-strong); margin-bottom: 10px; }
.lp-section-title { font-size: 0.78rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.lp-section-title i { color: var(--primary); }

.lp-rows { display: flex; flex-direction: column; }
.lp-row { position: relative; border: 0; border-bottom: 1px solid var(--border-color); border-radius: 0; background: transparent; transition: background 0.15s; }
.lp-row:hover { background: var(--surface-hover); }

.lp-pill { display: inline-flex; align-items: center; gap: 6px; padding: 0; border-radius: 0; font-size: 0.68rem; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; background: transparent; color: #2563eb; white-space: nowrap; }
.lp-pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.lp-pill.green { color: #15803d; } .lp-pill.amber { color: #b45309; } .lp-pill.red { color: #dc2626; } .lp-pill.gray { color: var(--text-muted); }
.lp-pill.gray::before { content: none; }
[data-theme="dark"] .lp-pill { color: #93c5fd; }
[data-theme="dark"] .lp-pill.green { color: #86efac; }
[data-theme="dark"] .lp-pill.amber { color: #fcd34d; }
[data-theme="dark"] .lp-pill.red { color: #fca5a5; }
[data-theme="dark"] .lp-pill.gray { color: var(--text-muted); }

.lp-tabs { display: flex; gap: 26px; flex-wrap: wrap; border-bottom: 1px solid var(--border-strong); background: var(--body-bg); }
.lp-tab { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-muted); border-radius: 0; padding: 8px 2px 10px; margin-bottom: -1px; font-weight: 650; font-size: 0.84rem; cursor: pointer; transition: 0.14s; }
.lp-tab:hover { color: var(--text-primary); }
.lp-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.lp-note { font-size: 0.74rem; color: #b45309; background: transparent; border: 0; border-left: 2px solid #d97706; border-radius: 0; padding: 4px 12px; display: flex; align-items: center; gap: 7px; }
[data-theme="dark"] .lp-note { color: #fcd34d; border-left-color: #f59e0b; }

.lp-btn-text { background: transparent; border: 0; color: var(--primary); font-weight: 650; font-size: 0.82rem; padding: 5px 9px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.lp-btn-text:hover { text-decoration: underline; text-underline-offset: 3px; }
.lp-btn-text.danger { color: #dc2626; }
.lp-btn-text:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Right-click a nav link → open that section in its own window ────────── */
.cl-win-menu { position: fixed; z-index: 2147483000; min-width: 232px; padding: 4px; background: var(--dropdown-bg, #fff); border: 1px solid var(--border-color); border-radius: 8px; box-shadow: var(--shadow-lg, 0 12px 32px rgba(15,23,42,.18)); }
.cl-win-menu button { display: flex; align-items: center; gap: 9px; width: 100%; background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 6px; font-size: 0.82rem; color: var(--text-primary); cursor: pointer; }
.cl-win-menu button:hover { background: var(--surface-hover, rgba(37,99,235,.1)); }
.cl-win-menu button i { color: var(--primary); }

/* Another window changed the project — say so instead of silently mixing two projects. */
.cl-scope-changed { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 2147483000; display: flex; align-items: center; gap: 12px; max-width: min(720px, calc(100vw - 24px)); padding: 10px 12px 10px 14px; background: var(--surface-1, #1c1c1e); color: var(--text-primary, #f1f5f9); border: 1px solid var(--border-color); border-left: 3px solid #d97706; border-radius: 8px; box-shadow: 0 12px 32px rgba(15,23,42,.3); font-size: 0.82rem; }
.cl-scope-changed i { color: #d97706; }
.cl-scope-changed span { flex: 1; min-width: 0; }
.cl-scope-changed .cl-sc-go { background: var(--primary); color: #fff; border: 0; border-radius: 6px; padding: 6px 12px; font-size: 0.78rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.cl-scope-changed .cl-sc-x { background: none; border: 0; color: var(--text-secondary); font-size: 1.15rem; line-height: 1; cursor: pointer; padding: 0 2px; }

/* ── Type-to-search dropdown (clSearchableSelect in app.js) ──────────────────
   The panel is body-level so a modal cannot clip it. Pages may restyle .ss-input
   (measurement.html gives it a purple accent) — those page rules win. */
.ss-wrap { position: relative; }
.ss-input { cursor: text; }
.ss-panel { position: fixed; z-index: 5000; max-height: 260px; overflow-y: auto; background: var(--surface-bg, #fff); border: 1px solid var(--border-color, #cbd5e1); border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,0.20); padding: 4px; }
.ss-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; font-size: 0.84rem; cursor: pointer; color: var(--text-primary, #0f172a); border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-item:hover, .ss-item.ss-hi { background: var(--surface-2, #eff6ff); }
.ss-item.ss-active { font-weight: 700; }
.ss-item .ss-dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; border: 1px solid rgba(0,0,0,0.15); }
.ss-empty { padding: 9px 12px; font-size: 0.8rem; color: var(--text-muted, #94a3b8); }
[data-theme="dark"] .ss-panel { background: #1b1b1b; border-color: #383838; box-shadow: 0 12px 32px rgba(0,0,0,0.55); }
[data-theme="dark"] .ss-item { color: #f1f5f9; }
[data-theme="dark"] .ss-item:hover, [data-theme="dark"] .ss-item.ss-hi { background: #2a2a2a; }

/* ── Checkbox multi-select (clMultiSelect in app.js) — Work / Stage filters ────────────
   The trigger is a form control (keeps its border, radius 6); the panel reuses .ss-panel.
   Pages add their own sizing selector (e.g. `.boq-filters .ms-trigger`) beside their <select>
   rule, so the trigger sits visually flush with the neighbouring inputs. */
.ms-wrap { position: relative; display: inline-block; max-width: 100%; vertical-align: middle; }
.ms-trigger { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 150px; max-width: 300px; padding: 3px 8px; border: 1px solid var(--border-color, #cbd5e1); border-radius: 6px; background: var(--surface-bg, #fff); color: var(--text-primary, #0f172a); font: inherit; font-size: 0.78rem; line-height: 1.35; cursor: pointer; text-align: left; white-space: nowrap; }
.ms-trigger:focus-visible { outline: none; border-color: var(--primary, #1e40af); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.ms-trigger.ms-on { border-color: var(--primary, #1e40af); color: var(--primary, #1e40af); font-weight: 650; }
.ms-trigger .ms-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ms-trigger .ms-caret { font-size: 0.68rem; flex: 0 0 auto; color: var(--text-muted, #64748b); }
.ms-panel { max-height: 330px; min-width: 200px; max-width: 360px; padding: 6px; overflow: hidden; }
.ms-panel .ms-search { display: block; width: 100%; margin: 0 0 6px; padding: 5px 9px; font-size: 0.8rem; border: 1px solid var(--border-color, #cbd5e1); border-radius: 6px; background: var(--surface-bg, #fff); color: var(--text-primary, #0f172a); }
.ms-panel .ms-list { max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
.ms-panel .ms-item { margin: 0; padding: 5px 8px; font-size: 0.8rem; white-space: normal; line-height: 1.3; cursor: pointer; user-select: none; }
.ms-panel .ms-item input { margin: 0; width: 14px; height: 14px; flex: 0 0 auto; accent-color: var(--primary, #1e40af); cursor: pointer; }
.ms-panel .ms-item .ms-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ms-panel .ms-all { border-bottom: 1px solid var(--border-color, #e2e8f0); border-radius: 0; margin-bottom: 4px; padding-bottom: 7px; font-weight: 600; }
[data-theme="dark"] .ms-trigger { background: var(--surface-bg, #141414); border-color: var(--border-color, #383838); color: var(--text-primary, #f1f5f9); }
[data-theme="dark"] .ms-trigger.ms-on { color: #93c5fd; border-color: #93c5fd; }
[data-theme="dark"] .ms-panel .ms-search { background: #141414; border-color: #383838; color: #f1f5f9; }
[data-theme="dark"] .ms-panel .ms-all { border-bottom-color: #383838; }

/* ── Toasts: top-CENTER of the screen (user request) ─────────────────────────────────────
   Pages hard-code #toast-container with Bootstrap top-0/end-0 (top-right), which sits on the
   page action buttons and blocks them until the toast dismisses. The id selector outranks the
   utility classes (both !important), so ONE rule repositions every page — no 54-file edit.
   Toasts are transient (4s); the top-center strip is breadcrumb dead-space on every screen. */
#toast-container {
    top: 10px !important;
    bottom: auto !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
}

/* ── Team Desk unread badge (migration 240) ──────────────────────────────────
   Sits inside the sidebar link, so it rides along with whatever branding colour
   the workspace is using. Flat, no gradient, tokens only — Ledger Premium. */
.cl-nav-badge {
    margin-left: auto;
    min-width: 18px;
    padding: 0 5px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    background: #dc2626;
    color: #fff;
    font-size: 0.64rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
}
[data-theme="dark"] .cl-nav-badge { background: #ef4444; color: #fff; }

/* Whole date box opens the calendar (app.js patchDateBoxOpensPicker) */
input[type="date"]:not(:disabled):not([readonly]), input[type="datetime-local"]:not(:disabled):not([readonly]), input[type="month"]:not(:disabled):not([readonly]), input[type="week"]:not(:disabled):not([readonly]) { cursor: pointer; }

/* ── App search trigger (top of the sidebar) — opens the palette in /js/app-search.js ──
   Sticky so it stays reachable while the nav scrolls. The rail is navy in both themes,
   so it speaks the sidebar's own colours, not the page tokens. */
#sidebar .cl-side-search-li { position: sticky; top: 0; z-index: 2; background: var(--sidebar-bg); padding: 2px 0 8px; list-style: none; }
#sidebar .cl-side-search { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 12px; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 6px; background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.7); font-size: 0.82rem; text-align: left; cursor: text; }
#sidebar .cl-side-search:hover, #sidebar .cl-side-search:focus-visible { border-color: var(--sidebar-text-active); color: var(--sidebar-text); outline: none; }
#sidebar .cl-side-search .sidebar-link-label { flex: 1; min-width: 0; }
#sidebar .cl-side-search kbd { font: 600 0.68rem/1 inherit; padding: 2px 6px; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 4px; background: transparent; color: rgba(255, 255, 255, 0.6); box-shadow: none; }
.sidebar-collapsed #sidebar .cl-side-search { justify-content: center; padding: 8px 0; }
.sidebar-collapsed #sidebar .cl-side-search kbd { display: none; }

/* An organisation server hides what only works for a laptop's own database (docs/org-server.md). */
.cl-org-server .cl-laptop-only { display: none !important; }
