:root {
    --primary-green: #7cb342;
    --primary-green-dark: #689f38;
    --primary-green-light: #8BC34A;
    --text-primary: #24313f;
    --text-secondary: #687586;
    --text-dark: #2c3e50;
    --text-gray: #6c757d;
    --text-light: #95a5a6;
    --border-light: #e6ebf1;
    --surface-white: #ffffff;
    --surface-page: #f5f7fb;
    /* Raised chip/badge surface on white cards. Several Sites-area views already
       reference this token — it was previously undefined (rendered transparent). */
    --surface-raised: #f5f7fb;
    --shadow-soft: 0 10px 30px rgba(36, 49, 63, 0.08);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
    /* Dashboard redesign (#217). --primary-green-text is the AA-contrast green for small text
       and links on white (--primary-green-dark is about 3.2:1); --text-secondary-strong is the
       AA grey for small captions on grey surfaces. */
    --hero-green: #2d4f1e;
    --hero-green-accent: #c5e1a5;
    --primary-green-text: #4d7c1b;
    /* Label on --primary-green buttons (#219): white on #7cb342 is about 2.5:1, this is about 6.4:1 (5:1 on the hover green). */
    --primary-green-contrast: #14260a;
    /* Filled primary buttons: white label on this deeper green (about 5.5:1), matching the Site Builder buttons. */
    --btn-fill: #4f7d24;
    --btn-fill-hover: #436b1e;
    --btn-on-fill: #ffffff;
    --text-secondary-strong: #5f6c7b;
    --badge-beta-bg: #fef3c7;
    --badge-beta-fg: #92400e;
    --warning-amber: #f97316;
    --warning-amber-bg: rgba(249, 115, 22, 0.06);
    --warning-amber-border: rgba(249, 115, 22, 0.25);
    --overlay-scrim: rgba(15, 23, 42, 0.55);
    --touch-target-min: 44px;
    --mobile-padding: 1rem;
    --bottom-safe-area: env(safe-area-inset-bottom, 0px);
    --mobile-font-base: 16px;

    /* Status-pill palettes (pale bg + dark fg) and signature ruled-line surface */
    --status-success-bg: #d1fae5;
    --status-success-fg: #065f46;
    --status-info-bg: #e0f2fe;
    --status-info-fg: #075985;
    --surface-ruled: #f3f4f6;
    /* Semantic status badge tokens */
    --status-active-bg: #d1e7dd;     --status-active-fg: #0f5132;
    --status-inactive-bg: #e9ecef;   --status-inactive-fg: #6c757d;
    --status-completed-bg: #cfe2ff;  --status-completed-fg: #084298;
    --status-forecasted-bg: #fff3cd; --status-forecasted-fg: #856404;
    --status-cancelled-bg: #f8d7da;  --status-cancelled-fg: #721c24;
    --status-renewing-bg: #fff4e6;   --status-renewing-fg: #92400e;
    --status-lapsed-bg: #fde2e2;     --status-lapsed-fg: #b91c1c;
    --status-expired-bg: #ede9fe;    --status-expired-fg: #6d28d9;

    /* .status-badge compound variants (Jobs, InvoiceSummary, CustomerSummary) */
    --badge-success-bg: rgba(124, 179, 66, 0.08); --badge-success-fg: var(--primary-green);
    --badge-warning-bg: rgba(249, 115, 22, 0.08); --badge-warning-fg: var(--warning-amber);
    --badge-danger-bg: rgba(220, 53, 69, 0.08);   --badge-danger-fg: #dc3545;
    --badge-indigo-bg: rgba(99, 102, 241, 0.08);  --badge-indigo-fg: #6366f1;
    --badge-neutral-bg: rgba(75, 85, 99, 0.08);   --badge-neutral-fg: #4b5563;

    /* Invoice .status-badge[data-status] variants (Sales grid; statuses from InvoiceStatusResolver) */
    --badge-paid-bg: #d1e7dd;     --badge-paid-fg: #0f5132;
    --badge-open-bg: #cfe2ff;     --badge-open-fg: #084298;
    --badge-partial-bg: #fff3cd;  --badge-partial-fg: #856404;
    --badge-overdue-bg: #f8d7da;  --badge-overdue-fg: #842029;
    --badge-closed-bg: #e9ecef;   --badge-closed-fg: #6c757d;
    --badge-overpaid-bg: #ede9fe; --badge-overpaid-fg: #6d28d9;

    /* Semantic alert tokens */
    --alert-success-bg: #d1e7dd; --alert-success-fg: #0f5132;
    --alert-danger-bg: #f8d7da;  --alert-danger-fg: #721c24;
    --alert-info-bg: #cfe2ff;    --alert-info-fg: #084298;

    /* Accent / info (blue) — palette gap filled for consolidation */
    --accent-blue: #3b82f6;      --accent-blue-dark: #2563eb;
    --info-bg: #e0f2fe;          --info-fg: #075985;          --info-border: #bfdbfe;

    /* Functional success/danger accents (text/icon greens & reds) */
    --success-fg: #15803d;       --success-bg: #e6f7ec;       --success-border: #b6e1c5;
    --danger-fg: #b42318;        --danger-bg: #fef2f2;        --danger-border: #fecaca;

    /* Dark navy top-nav chrome */
    --nav-dark: #101e41;

    /* Keyboard focus ring (#223): about 5:1 on white and 4.6:1 on --surface-page; white on the dark chrome. */
    --focus-ring: var(--primary-green-text);
    --focus-ring-on-dark: var(--surface-white);
}

/* Shared keyboard focus ring (#223). app.css keeps mouse and touch focus quiet with
   `:focus:not(:focus-visible)`; anything a keyboard reaches gets this unless a component draws its own. */
:focus-visible,
button:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Syncfusion's theme drops the outline on everything inside a control (`.e-control *:focus`), which hides the
   ring on our own links and buttons in grid cells and dialogs. Its own parts (e- classes) and Bootstrap
   form fields keep their own focus styling, as they do outside a control. Same specificity as that rule,
   so a component that draws its own focus later in the cascade still wins. */
.e-control :focus-visible:where(:not([class^="e-"], [class*=" e-"], .form-control, .custom-select)) {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Syncfusion's dialog close button clears every focus cue (no outline, shadow, border or background). */
.e-dialog .e-btn.e-dlg-closeicon-btn:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* The navy top bar and the dark green dashboard hero. Top-bar links fill the bar's height, so their ring
   sits inside them rather than past the top of the window. */
.topnavbar :focus-visible,
.dash-hero :focus-visible {
    outline-color: var(--focus-ring-on-dark);
}

.topnavbar :focus-visible {
    outline-offset: -2px;
}

.sidebar-badge-beta {
    background: var(--badge-beta-bg);
    border-radius: 4px;
    color: var(--badge-beta-fg);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-left: 4px;
    padding: 2px 6px;
    text-transform: uppercase;
}

/* Live open-request count on Receptionist > Inbox. Distinct from
   .sidebar-badge-beta above: that's an uppercase amber LABEL, this is a number,
   and reusing it would make a live count read as a "Beta" tag. Green (not red)
   matches the sidebar's own active state — "you have things", not "something is
   broken"; urgency ordering lives inside the inbox. */
.sidebar-badge-count {
    background: var(--primary-green-dark);
    border-radius: 999px;
    color: var(--primary-green-contrast);
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    line-height: 1;
    min-width: 1.25rem;
    padding: 3px 6px;
    text-align: center;
}

/* Scoped to badged links ONLY — `.sidebar-subnav li a` is display:block and is
   shared by ~30 entries, so changing it globally is a needless blast radius. */
.sidebar-subnav li a.has-badge {
    align-items: center;
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
}

.depot-warning {
    align-items: flex-start;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 6px;
    color: #9a3412;
    display: flex;
    font-size: 0.875rem;
    gap: 0.625rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    padding: 0.625rem 0.75rem;
}

.depot-warning svg {
    flex-shrink: 0;
    margin-top: 1px;
}

.form-hint-inline {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 400;
    margin-left: 0.25rem;
}

/* Scoped to depot empty state to avoid colliding with page-level .empty-state-text rules
   in CrewSummary, RenewalWizard, Weather, etc. */
.route-depot-address .empty-state-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-style: italic;
}

.route-depot-address .empty-state-text a {
    color: var(--primary-green-dark);
    font-style: normal;
    text-decoration: underline;
}

.page-header,
.page-header-modern {
    background: var(--surface-white);
    border-bottom: none;
    margin: -1.5rem -1.5rem 1.5rem -1.5rem;
    padding: 2rem 2.5rem;
}

.header-wrapper {
    align-items: flex-start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.header-left,
.header-right {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.header-right {
    align-items: flex-end;
    justify-content: center;
}

.page-title {
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    line-height: 1.1;
    margin: 0;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

.breadcrumb {
    align-items: center;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.875rem;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.breadcrumb a {
    color: var(--primary-green-dark);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary-green-dark);
    text-decoration: underline;
}

.content-wrapper,
.content-container {
    padding: 0 0.75rem 1.5rem;
    border-top: none;
}

.data-card,
.modern-card,
.legacy-shell-card {
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.empty-state-modern {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state-icon {
    align-items: center;
    background: var(--surface-page);
    border-radius: 50%;
    color: var(--text-light);
    display: flex;
    height: 72px;
    justify-content: center;
    margin-bottom: 0.5rem;
    width: 72px;
}

.empty-state-title {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.empty-state-description {
    color: var(--text-secondary);
    margin: 0;
    max-width: 32rem;
}

.empty-state-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.modal-notice-modern {
    align-items: flex-start;
    background: var(--surface-page);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-secondary);
    display: flex;
    font-size: 0.875rem;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
}

.modal-notice-modern svg {
    color: var(--text-light);
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.modal-notice-modern.modal-notice-warning {
    background: var(--warning-amber-bg);
    border-color: var(--warning-amber-border);
    color: var(--text-primary);
}

.modal-notice-modern.modal-notice-warning svg {
    color: var(--warning-amber);
}

/* m-SCHED-10: inline error notice for AJAX modal forms — replaces alert() so a failed
   save reads like the rest of the v2 shell instead of a native browser dialog. */
.modal-notice-modern.modal-notice-danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-fg);
}

.modal-notice-modern.modal-notice-danger svg {
    color: var(--danger-fg);
}

.btn-danger-modern {
    align-items: center;
    background: var(--surface-white);
    border: 1px solid var(--danger-fg);
    border-radius: 6px;
    color: var(--danger-fg);
    cursor: pointer;
    display: inline-flex;
    font-size: 0.9375rem;
    font-weight: 500;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-danger-modern:hover,
.btn-danger-modern:focus {
    background: var(--danger-fg);
    color: var(--surface-white);
    text-decoration: none;
}

/* Syncfusion grid header text — prevent truncation */
.e-grid .e-headercell .e-headercelldiv {
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
    line-height: 1.3;
}

.card-header-modern {
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
}

.card-header-modern h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.btn-add,
.btn-primary-modern,
.btn-action {
    align-items: center;
    border-radius: 6px;
    display: inline-flex;
    font-size: 0.9375rem;
    font-weight: 500;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-add,
.btn-primary-modern {
    background: var(--btn-fill);
    border: 1px solid var(--btn-fill);
    color: var(--btn-on-fill);
}

.btn-add:hover,
.btn-primary-modern:hover {
    background: var(--btn-fill-hover);
    border-color: var(--btn-fill-hover);
    box-shadow: var(--shadow-hover);
    color: var(--btn-on-fill);
    text-decoration: none;
    transform: translateY(-1px);
}

.btn-add:focus,
.btn-add:active,
.btn-add:disabled,
.btn-add.disabled,
.btn-primary-modern:focus,
.btn-primary-modern:active,
.btn-primary-modern:disabled,
.btn-primary-modern.disabled {
    color: var(--btn-on-fill);
}

/* Primary buttons keep a box-shadow ring with a white halo, so it reads on any background. The outline is
   transparent (not none) so forced-colors mode, which drops box-shadows, still paints a ring (#223). */
.btn-add:focus-visible,
.btn-primary-modern:focus-visible {
    box-shadow: 0 0 0 2px var(--surface-white), 0 0 0 4px var(--focus-ring);
    outline-color: transparent;
}

.btn-add svg {
    flex-shrink: 0;
}

.btn-action {
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
}

.btn-action:hover {
    border-color: var(--primary-green);
    color: var(--primary-green-dark);
    text-decoration: none;
}

.page-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
}

.workflow-guide {
    background: linear-gradient(135deg, rgba(124, 179, 66, 0.08), rgba(255, 255, 255, 0.98));
    border: 1px solid rgba(124, 179, 66, 0.18);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    display: grid;
    gap: 1.5rem;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    margin: 0 0 1.5rem;
    padding: 1.5rem;
    position: relative;
}

.workflow-guide-close {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0.85;
    transition: opacity 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    padding: 0.35rem;
    line-height: 1;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.workflow-guide-close:hover {
    opacity: 1;
    color: var(--text-primary);
    background: var(--surface-white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.workflow-guide.workflow-guide-emphasis {
    background: linear-gradient(135deg, rgba(36, 49, 63, 0.05), rgba(124, 179, 66, 0.12));
}

.workflow-guide.workflow-guide-compact {
    padding: 1.25rem;
}

.workflow-guide-eyebrow {
    color: var(--primary-green-dark);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin: 0 0 0.35rem;
    text-transform: uppercase;
}

.workflow-guide-title {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.workflow-guide-description,
.workflow-next-step-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
}

.workflow-guide-highlights {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0 0;
}

.workflow-guide-pill {
    background: rgba(124, 179, 66, 0.12);
    border-radius: 999px;
    color: var(--primary-green-dark);
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
}

.workflow-guide-steps {
    display: grid;
    gap: 0.85rem;
    list-style: none;
    margin: 1.15rem 0 0;
    padding: 0;
}

.workflow-guide-steps li {
    align-items: flex-start;
    display: flex;
    gap: 0.75rem;
}

.workflow-guide-step-number {
    align-items: center;
    background: var(--surface-white);
    border: 1px solid rgba(124, 179, 66, 0.2);
    border-radius: 999px;
    color: var(--primary-green-dark);
    display: inline-flex;
    flex: 0 0 2rem;
    font-size: 0.85rem;
    font-weight: 700;
    height: 2rem;
    justify-content: center;
}

.workflow-guide-steps li.is-done .workflow-guide-step-number {
    background: var(--primary-green);
    border-color: var(--primary-green);
    color: var(--primary-green-contrast);
}

.workflow-guide-steps li.is-done .workflow-guide-step-text {
    color: var(--text-secondary);
}

.workflow-guide-step-text {
    color: var(--text-primary);
    display: block;
    font-size: 0.93rem;
    line-height: 1.5;
    padding-top: 0.2rem;
}

.workflow-guide-side {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: space-between;
    padding: 1rem;
}

.workflow-next-step-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin: 0 0 0.35rem;
    text-transform: uppercase;
}

.workflow-next-step-title {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.4rem;
}

.workflow-guide-actions {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.workflow-guide-actions .btn-action,
.workflow-guide-actions .btn-primary-modern {
    width: 100%;
}

.route-depot-card,
.route-stop-card {
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 16px;
}

.route-depot-card {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
}

.route-depot-label,
.route-depot-meta {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.route-depot-address {
    color: var(--text-primary);
    font-size: 0.93rem;
    margin-top: 0.3rem;
}

.route-list {
    display: grid;
    gap: 0.9rem;
}

.route-stop-card {
    align-items: center;
    display: grid;
    gap: 1rem;
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 1rem 1.1rem;
}

.route-stop-handle {
    color: var(--text-secondary);
    display: inline-flex;
}

.route-stop-top {
    align-items: flex-start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.route-stop-title {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
}

.route-stop-subtitle,
.route-stop-address {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.route-stop-order {
    background: rgba(124, 179, 66, 0.12);
    border-radius: 999px;
    color: var(--primary-green-dark);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.35rem 0.7rem;
    white-space: nowrap;
}

.route-stop-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.route-move-button {
    align-items: center;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    color: var(--text-secondary);
    display: inline-flex;
    justify-content: center;
    padding: 0.45rem;
}

.route-move-button:hover {
    border-color: var(--primary-green);
    color: var(--primary-green-dark);
}

@media (max-width: 991px) {
    /* Tablet (#222): the header bleeds 1rem, the wrappers indent cards 1.5rem, so the text sits at 1.75rem
       to meet the card edge. 768px and below drops to 1rem with the single gutter. */
    .page-header,
    .page-header-modern {
        padding: 1.25rem 1.75rem;
        margin: -1rem -1rem 1rem -1rem;
    }

    .header-wrapper {
        align-items: stretch;
        flex-direction: column;
    }

    .header-right {
        align-items: stretch;
    }

    .page-actions {
        justify-content: stretch;
    }

    .btn-add,
    .btn-primary-modern,
    .btn-action {
        width: 100%;
    }

    .workflow-guide {
        grid-template-columns: 1fr;
    }

    .route-depot-card,
    .route-stop-card {
        grid-template-columns: 1fr;
    }

    .route-stop-actions {
        flex-direction: row;
    }
}

.modern-topnavbar {
    align-items: center;
    background: #101e41 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    gap: 0.75rem;
    grid-template-columns: auto auto 1fr auto;
    min-height: 55px;
    overflow: visible;
    padding: 0 1.25rem;
}

/* Lift the navbar above the section-container's z-index: 111 stacking context
   (set in app.css). Without this, the settings dropdown renders behind dashboard
   cards. Pick a value that beats section-container but stays below the aside
   container (z-index: 116) and Bootstrap modals (1050+). */
.topnavbar-wrapper {
    position: relative;
    z-index: 120;
}

/* Ensure the dropdown panel itself wins inside its own stacking context. */
.modern-topnavbar .dropdown-menu {
    z-index: 1050;
}

/* Override legacy app.css padding that inflates navbar height */
.modern-topnavbar .navbar-header .brand-logo {
    padding: 4px 10px;
}

/* Override app.css fixed 220px width on navbar-header */
.modern-topnavbar .navbar-header {
    width: auto;
}

/* Override Bootstrap column-stacking + zero padding on navbar-nav */
.modern-topnavbar .navbar-nav {
    flex-direction: row;
    align-items: center;
}

.modern-topnavbar .navbar-nav .nav-link {
    padding: 0.5rem 0.75rem;
}

/* Override Bootstrap static dropdown positioning */
.modern-topnavbar .navbar-nav .dropdown-menu {
    position: absolute;
}

.modern-topnavbar .nav-link {
    color: #eef4ff;
}

/* Angle styles the open/hovered nav item with a teal inset underline and a
   dark-teal icon, which reads as a stray bar on the navy navbar. */
.modern-topnavbar .navbar-nav > .nav-item > .nav-link:hover,
.modern-topnavbar .navbar-nav > .nav-item > .nav-link:focus,
.modern-topnavbar .navbar-nav > .nav-item.show > .nav-link,
.modern-topnavbar .navbar-nav > .nav-item.show > .nav-link:hover,
.modern-topnavbar .navbar-nav > .nav-item.show > .nav-link:focus {
    box-shadow: none;
    color: var(--surface-white);
}

/* The settings <li> carries Angle's .dropdown-list, which zeroes the panel and
   item padding (it expects a list-group inside) and pins the panel at
   top: 54px, under the navbar's bottom edge. Restore spacing and drop the
   panel just below the bar. */
.modern-topnavbar .navbar-nav .dropdown-menu {
    background-color: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-hover);
    min-width: 180px;
    padding: 0.375rem;
    top: calc(100% + 0.5rem);
}

/* Dropdown items sit on a white panel — use dark, readable text.
   (The light #eef4ff above is for the gear icon on the dark navbar only.) */
.modern-topnavbar .dropdown-menu .dropdown-item {
    border-radius: 8px;
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
}

.modern-topnavbar .dropdown-menu .dropdown-item:hover,
.modern-topnavbar .dropdown-menu .dropdown-item:focus {
    background-color: rgba(124, 179, 66, 0.08);
    color: var(--primary-green-dark);
}

.global-search-shell {
    margin: 0 auto;
    max-width: 720px;
    position: relative;
    width: 100%;
}

.global-search-label {
    display: none;
}

.global-search-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    color: #fff;
    padding: 0.45rem 1rem;
    width: 100%;
}

.global-search-input::placeholder {
    color: rgba(255, 255, 255, 0.75);
}

/* Wave 4 (list-scale): the shared search partial rendered in the mobile shell's own bar. The
   base input styling above assumes the dark desktop navbar; this variant sits on the page
   surface, so it takes the light form-control look. */
.mobile-search-bar {
    padding: 0.5rem 1rem 0;
}

.mobile-search-bar .global-search-input {
    background: var(--surface-white);
    border-color: var(--border-color, #e3e8ef);
    color: var(--text-primary);
}

.mobile-search-bar .global-search-input::placeholder {
    color: var(--text-gray, #64748b);
}

.global-search-input:focus {
    outline: none;
    border-color: rgba(124, 179, 66, 0.9);
    background: rgba(255, 255, 255, 0.14);
}

.global-search-results {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    margin-top: 0.5rem;
    max-height: 420px;
    overflow-y: auto;
    position: absolute;
    width: 100%;
    z-index: 1000;
}

.global-search-item {
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    display: flex;
    gap: 1rem;
    padding: 0.9rem 1rem;
    text-decoration: none;
}

.global-search-item:last-child {
    border-bottom: none;
}

.global-search-item:hover,
.global-search-item.is-active {
    background: rgba(124, 179, 66, 0.05);
    text-decoration: none;
}

/* Keyboard highlight needs to survive on its own — arrow keys move .is-active
   without the mouse, so it also gets an inset ring for visible focus. */
.global-search-item.is-active {
    box-shadow: inset 3px 0 0 var(--primary-green-dark);
}

.global-search-kind {
    color: var(--primary-green-dark);
    font-size: 0.78rem;
    font-weight: 700;
    min-width: 92px;
    text-transform: uppercase;
}

.global-search-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.global-search-meta,
.global-search-empty {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.global-search-empty {
    padding: 1rem;
}

.modern-sidebar {
    padding: 1rem 0.85rem;
}

.sidebar-user-block {
    background: transparent;
    border: none;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    margin: 0 0 1rem;
    padding: 1rem;
}

.sidebar-greeting {
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 700;
}

.sidebar-company {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.grouped-sidebar > li > a,
.sidebar-group-link {
    align-items: center;
    border-radius: 12px;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    padding: 0.8rem 0.95rem;
    text-decoration: none;
}

.grouped-sidebar > li > a:hover,
.sidebar-group-link:hover {
    background: rgba(124, 179, 66, 0.08);
    text-decoration: none;
}

.sidebar-group-title {
    align-items: center;
    display: inline-flex;
    gap: 0.65rem;
}

.sidebar-group-chevron {
    transition: transform 0.2s ease;
}

.sidebar-group-link.collapsed .sidebar-group-chevron {
    transform: rotate(-90deg);
}

.sidebar-subnav {
    margin: 0 0 0.45rem;
    padding: 0 0 0 0.5rem;
}

.sidebar-subnav li a {
    border-radius: 10px;
    color: var(--text-secondary);
    display: block;
    padding: 0.65rem 0.95rem;
    text-decoration: none;
}

.sidebar-subnav li a:hover {
    background: rgba(124, 179, 66, 0.06);
    color: var(--text-primary);
    text-decoration: none;
}

/* Override legacy blue active states with theme green */
.grouped-sidebar > li.active > a,
.grouped-sidebar > li.active > a > em,
.grouped-sidebar > li.active > a .sidebar-group-title > em {
    color: var(--primary-green-dark);
}

.grouped-sidebar > li.active > a {
    background: rgba(124, 179, 66, 0.08);
}

.sidebar-subnav > li.active > a {
    color: var(--primary-green-dark) !important;
    background: rgba(124, 179, 66, 0.08);
    font-weight: 600;
}

.sidebar-subnav > li.active > a:after {
    border-color: var(--primary-green-dark);
    background-color: var(--primary-green-dark);
}

.sidebar-nav > li.active {
    border-left-color: var(--primary-green-dark);
}

@media (max-width: 991px) {
    /* The TOPNAV search collapses on narrow screens (no room beside the burger)… */
    .global-search-shell {
        display: none;
    }

    /* …but the mobile layout renders its own dedicated search bar, which must stay
       visible — this rule once silently killed search on every phone width. */
    .mobile-search-bar .global-search-shell {
        display: block;
    }
}

/* ============================================================
   CREATE / EDIT / SUMMARY PAGE — SHARED PATTERNS
   These classes were duplicated in 16-18 page files.
   ============================================================ */

.modern-header {
    background: var(--surface-white);
    border-bottom: 1px solid var(--border-light);
    margin: -1.5rem -1.5rem 1.5rem -1.5rem;
    padding: 1.75rem 2rem;
}

.header-content {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.header-content .header-left {
    align-items: center;
    flex-direction: row;
    gap: 1rem;
}

.header-info .page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
}

.entity-avatar,
.customer-avatar,
.job-avatar,
.program-avatar-large,
.lead-avatar {
    align-items: center;
    background: var(--primary-green);
    border-radius: 8px;
    color: var(--primary-green-contrast);
    display: flex;
    flex-shrink: 0;
    font-size: 1.125rem;
    font-weight: 600;
    height: 48px;
    justify-content: center;
    width: 48px;
}

.header-actions {
    align-items: center;
    display: flex;
    gap: 0.75rem;
}

.breadcrumb-modern {
    align-items: center;
    color: var(--text-secondary);
    display: flex;
    font-size: 0.8125rem;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.breadcrumb-modern a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumb-modern a:hover {
    color: var(--primary-green-dark);
}

.card-body-modern {
    padding: 1.5rem;
}

.btn-secondary-modern {
    align-items: center;
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-secondary);
    display: inline-flex;
    font-size: 0.875rem;
    font-weight: 500;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-secondary-modern:hover {
    background: var(--surface-page);
    border-color: var(--primary-green);
    color: var(--primary-green-dark);
}

/* ============================================================
   FORM PATTERNS — shared across all create/edit pages
   ============================================================ */

.modern-form {
    /* Full card width. The form's grid rows (.form-row-modern) handle column
       layout; capping the form itself left dense two-column forms filling only
       part of a wide card. */
    width: 100%;
}

.form-row-modern {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1fr;
}

.form-group-modern {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-group-modern label {
    color: var(--text-primary);
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* m-SALES-6: standard required-field marker. Pair a `.required` label with an
   inline `<span class="text-danger">*</span>` (kept explicit, rather than a
   CSS-generated ::after asterisk, so it reads correctly to screen readers). */
.form-group-modern label.required {
    font-weight: 600;
}

.form-input-modern {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.875rem;
    padding: 0.625rem 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.form-input-modern:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(124, 179, 66, 0.1);
    outline: none;
}

.form-input-modern:hover {
    border-color: #d1d5db;
}

.form-hint {
    color: var(--text-secondary);
    display: block;
    font-size: 0.8125rem;
    margin-top: 0.375rem;
}

.form-hint a {
    color: var(--primary-green-dark);
    text-decoration: none;
}

.form-hint a:hover {
    text-decoration: underline;
}

.form-actions {
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
}

.address-row {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr 120px 120px;
}

/* Toggle Switch */
.toggle-label {
    display: block;
}

.toggle-switch {
    display: inline-block;
    height: 26px;
    position: relative;
    width: 48px;
}

.toggle-switch input {
    height: 0;
    opacity: 0;
    width: 0;
}

.toggle-slider {
    background-color: var(--border-light);
    border-radius: 26px;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: 0.3s;
}

.toggle-slider:before {
    background-color: #fff;
    border-radius: 50%;
    bottom: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    content: "";
    height: 20px;
    left: 3px;
    position: absolute;
    transition: 0.3s;
    width: 20px;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-green);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* The real checkbox is hidden, so the keyboard ring (#223) goes on the visible slider or box. */
.toggle-switch input:focus-visible + .toggle-slider,
.switch input:focus-visible + span,
.c-checkbox input:focus-visible + span,
.c-radio input:focus-visible + span {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Checkbox */
.checkbox-modern {
    align-items: center;
    display: flex;
    gap: 0.5rem;
}

.checkbox-input {
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    height: 18px;
    margin: 0;
    position: relative;
    transition: background-color 0.15s, border-color 0.15s;
    width: 18px;
}

.checkbox-input:hover {
    border-color: #d1d5db;
}

.checkbox-input:checked {
    background-color: var(--primary-green);
    border-color: var(--primary-green);
}

.checkbox-input:checked::after {
    border: solid var(--primary-green-contrast);
    border-width: 0 2px 2px 0;
    content: "";
    height: 9px;
    left: 5px;
    position: absolute;
    top: 1px;
    transform: rotate(45deg);
    width: 4px;
}

.checkbox-label {
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
}

/* ============================================================
   ESTIMATE LINE OPTIONS — the Option / Include cell pair
   Shared by Views/Lead/EstimateCreate.cshtml and EstimateSummary.cshtml via
   Views/Lead/_EstimateLineItemOptionCells.cshtml. Column geometry stays in each
   view, because the two tables use different layout algorithms.
   ============================================================ */

.option-cell select.option-class { width: 100%; }
.include-cell { text-align: center; white-space: nowrap; }

/* Required rows swap the switch for a lock chip. The checkbox itself stays in the
   DOM (checked + disabled) because EstimateCreate.js reads .checked / .disabled
   off it. A disabled toggle looks broken; "Always" reads as deliberate. */
.include-cell .include-lock { display: none; }
tr[data-option-class="0"] .include-cell .toggle-switch { display: none; }
tr[data-option-class="0"] .include-cell .include-lock {
    align-items: center;
    background: var(--surface-ruled);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    color: var(--text-gray);
    display: inline-flex;
    font-size: 0.6875rem;
    font-weight: 600;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
}

/* Option-class rail on the row-number cell: the good/better/best shape of the
   proposal, scannable without reading every dropdown. */
tr[data-option-class="1"] td.rowIndex { box-shadow: inset 3px 0 0 var(--primary-green); }
tr[data-option-class="2"] td.rowIndex { box-shadow: inset 3px 0 0 var(--warning-amber); }

/* Not pre-selected: still on the proposal, but out of the total. Cells 2-6 only,
   so the two controls that fix it stay at full contrast. */
tr.line-excluded td:nth-child(n+2):nth-child(-n+6) { opacity: 0.55; }

/* Read-only state, once the estimate is locked or accepted. */
.option-badge {
    border: 1px solid var(--border-light);
    border-radius: 999px;
    color: var(--text-secondary);
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}
.option-badge-recommended { background: var(--status-active-bg);     color: var(--status-active-fg);     border-color: transparent; }
.option-badge-optional    { background: var(--status-forecasted-bg); color: var(--status-forecasted-fg); border-color: transparent; }

.include-state { font-size: 0.75rem; font-weight: 600; }
.include-state.is-in  { color: var(--status-active-fg); }
.include-state.is-out { color: var(--text-light); }

/* Money fields carry no spin buttons: an amount is typed, not nudged, and the two
   icons ate ~50px of the width the number needed. Done in CSS because the
   <ejs-numerictextbox> tag helper does not accept a show-spin-button attribute in
   any casing (it passes it through as dead markup) and setting .showSpinButton on
   the instance after render does not re-render it. Same approach the invoice tables
   already use. Qty keeps its spinners on purpose; JS-built rows set the real
   showSpinButton option and never reach here. */
#table_estimatelineitems .estimate-subtotal .e-input-group-icon.e-spin-up,
#table_estimatelineitems .estimate-subtotal .e-input-group-icon.e-spin-down,
#table_estimatelineitems .estimate-tax      .e-input-group-icon.e-spin-up,
#table_estimatelineitems .estimate-tax      .e-input-group-icon.e-spin-down,
#table_estimatelineitems .estimate-total    .e-input-group-icon.e-spin-up,
#table_estimatelineitems .estimate-total    .e-input-group-icon.e-spin-down,
#table_estimatelineitems .price             .e-input-group-icon.e-spin-up,
#table_estimatelineitems .price             .e-input-group-icon.e-spin-down,
#table_estimatelineitems .total             .e-input-group-icon.e-spin-up,
#table_estimatelineitems .total             .e-input-group-icon.e-spin-down {
    display: none !important;
}

/* ============================================================
   STATUS BADGES
   ============================================================ */

.status-badge {
    border-radius: 12px;
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    padding: 0.25rem 0.75rem;
    text-transform: uppercase;
}

.status-badge.status-success {
    background: var(--badge-success-bg);
    color: var(--badge-success-fg);
}

.status-badge.status-warning {
    background: var(--badge-warning-bg);
    color: var(--badge-warning-fg);
}

.status-badge.status-danger {
    background: var(--badge-danger-bg);
    color: var(--badge-danger-fg);
}

.status-badge.status-overdue {
    background: var(--badge-danger-bg);
    color: var(--badge-danger-fg);
}

.status-badge.status-indigo {
    background: var(--badge-indigo-bg);
    color: var(--badge-indigo-fg);
}

.status-badge.status-neutral {
    background: var(--badge-neutral-bg);
    color: var(--badge-neutral-fg);
}

.status-active     { background: var(--status-active-bg);     color: var(--status-active-fg); }
.status-inactive   { background: var(--status-inactive-bg);   color: var(--status-inactive-fg); }
.status-info       { background: var(--status-info-bg);       color: var(--status-info-fg); }
.status-completed  { background: var(--status-completed-bg);  color: var(--status-completed-fg); }
.status-forecasted { background: var(--status-forecasted-bg); color: var(--status-forecasted-fg); }
.status-cancelled  { background: var(--status-cancelled-bg);  color: var(--status-cancelled-fg); }

/* Contract lifecycle additions (ServicePlanStatus) */
.status-draft      { background: var(--status-inactive-bg);   color: var(--status-inactive-fg); }
.status-renewing   { background: var(--status-renewing-bg);   color: var(--status-renewing-fg); }
.status-lapsed     { background: var(--status-lapsed-bg);     color: var(--status-lapsed-fg); }
.status-expired    { background: var(--status-expired-bg);    color: var(--status-expired-fg); }

/* Reusable inline-SVG spinner (replaces Font Awesome fa-spin) */
@keyframes icon-spin { to { transform: rotate(360deg); } }
.icon-spin {
    animation: icon-spin 0.8s linear infinite;
    transform-origin: center;
    vertical-align: middle;
}

/* ============================================================
   STAT CARDS — used by CustomerSummary, Dashboard
   ============================================================ */

.stats-container {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 1.5rem;
}

.stat-card {
    align-items: center;
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
}

.stat-icon {
    align-items: center;
    border-radius: 12px;
    display: flex;
    flex-shrink: 0;
    height: 44px;
    justify-content: center;
    width: 44px;
}

.stat-icon svg {
    height: 22px;
    width: 22px;
}

.stat-blue   { background: rgba(59, 130, 246, 0.1);  color: #3b82f6; }
.stat-green  { background: rgba(124, 179, 66, 0.12); color: var(--primary-green); }
.stat-purple { background: rgba(139, 92, 246, 0.1);  color: #8b5cf6; }
.stat-orange { background: rgba(249, 115, 22, 0.1);  color: #f97316; }
.stat-red    { background: rgba(239, 68, 68, 0.1);   color: #ef4444; }

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    color: var(--text-primary);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

/* ============================================================
   MODERN TABS — used by CustomerSummary, JobSummary, LeadSummary
   ============================================================ */

.modern-tabs {
    /* Gray rule drawn as an inset shadow (not border-bottom) so the active
       tab's green border can paint over it without the -2px margin trick,
       which created 2px of vertical overflow and a stray scrollbar. */
    box-shadow: inset 0 -2px 0 var(--border-light);
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    overflow-y: hidden;
}

.tab-btn {
    align-items: center;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    font-size: 0.875rem;
    font-weight: 500;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    border-bottom-color: var(--primary-green);
    color: var(--primary-green-dark);
    font-weight: 600;
}

.tab-badge {
    background: var(--surface-page);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 22px;
    padding: 0.15rem 0.5rem;
    text-align: center;
}

.tab-btn.active .tab-badge {
    background: rgba(124, 179, 66, 0.12);
    color: var(--primary-green-dark);
}

.tab-content > .tab-pane {
    display: none;
}

.tab-content > .tab-pane.active {
    display: block;
}

/* ============================================================
   GROUPED TABS — used by CustomerSummary
   Each group renders on its own row with the label on the left
   and tab buttons inline. Order in markup is the display order
   (Profile · Work · Financials · Portal).

   Each group also has its own active pane visible directly
   under its tab strip — see the `order` rules below that
   interleave panes between group tab rows even though DOM
   keeps all panes after all tab groups.
   ============================================================ */

.modern-tabs-grouped {
    overflow-x: visible;        /* override .modern-tabs overflow-x: auto */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    border-bottom: none;        /* override .modern-tabs underline — each group row owns its own */
}

/* Visual interleave: each tab group row is followed by its
   active pane(s). DOM order is preserved, only the visual
   stacking order changes. */
.modern-tabs-grouped .tab-group[data-group="profile"]              { order: 1; }
.modern-tabs-grouped .tab-pane-modern[data-group="profile"]        { order: 2; }
.modern-tabs-grouped .tab-group[data-group="work"]                 { order: 3; }
.modern-tabs-grouped .tab-pane-modern[data-group="work"]           { order: 4; }
.modern-tabs-grouped .tab-group[data-group="financials"]           { order: 5; }
.modern-tabs-grouped .tab-pane-modern[data-group="financials"]     { order: 6; }
.modern-tabs-grouped .tab-group[data-group="portal"]               { order: 7; }
.modern-tabs-grouped .tab-pane-modern[data-group="portal"]         { order: 8; }

/* Spacing under each active pane before the next group's tab row */
.modern-tabs-grouped .tab-pane-modern.active {
    margin: 1rem 0 2rem;
}

.tab-group {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    padding: 0;
    border-right: none;
    border-bottom: 2px solid var(--border-light);
}

.tab-group:last-child {
    border-bottom: none;        /* outer .modern-tabs border-bottom acts as final rule */
}

.tab-group-label {
    display: flex;
    align-items: center;
    min-width: 110px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0 0.75rem;
    flex-shrink: 0;
}

.tab-group-items {
    display: flex;
    flex: 1 1 auto;
    gap: 0;
    flex-wrap: wrap;
    min-width: 0;
}

.modern-tabs-grouped .tab-btn {
    padding: 0.5rem 0.75rem;
}

@media (max-width: 768px) {
    .tab-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .tab-group-label {
        min-width: 0;
        padding: 0.5rem 0.75rem 0.25rem;
    }
}

/* ============================================================
   INSIGHT CARDS — used by CustomerSummary
   ============================================================ */

.insight-card {
    background: linear-gradient(135deg, rgba(124, 179, 66, 0.06), rgba(255, 255, 255, 0.98));
    border: 1px solid rgba(124, 179, 66, 0.15);
    border-radius: 16px;
    margin-bottom: 1.5rem;
    padding: 1.25rem;
}

.insight-header {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.insight-icon {
    align-items: center;
    background: rgba(124, 179, 66, 0.12);
    border-radius: 10px;
    color: var(--primary-green);
    display: flex;
    height: 36px;
    justify-content: center;
    width: 36px;
}

.insight-title {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.insight-metrics {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr 1fr;
}

.insight-metric-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.insight-metric-value {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
}

/* ============================================================
   DISPATCH BOARD — used by Scheduler
   ============================================================ */

.dispatch-board {
    margin-bottom: 1.5rem;
}

.dispatch-crew-card {
    background: var(--surface-white);
    border: 2px solid var(--border-light);
    border-radius: 14px;
    cursor: pointer;
    padding: 1.25rem;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s;
}

.dispatch-crew-card:hover {
    border-color: var(--primary-green);
    box-shadow: var(--shadow-soft);
    text-decoration: none;
    transform: translateY(-2px);
}

.dispatch-crew-card.active {
    background: rgba(124, 179, 66, 0.06);
    border-color: var(--primary-green);
}

.date-pills {
    align-items: center;
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.date-pill {
    border: 1px solid var(--border-light);
    border-radius: 999px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    text-decoration: none;
    transition: all 0.2s;
}

.date-pill:hover {
    border-color: var(--primary-green);
    color: var(--primary-green-dark);
    text-decoration: none;
}

.date-pill.active {
    background: var(--primary-green);
    border-color: var(--primary-green);
    color: var(--primary-green-contrast);
}

/* ============================================================
   BILLING TOOLBAR — used by Sales
   ============================================================ */

.modern-billing-toolbar {
    align-items: center;
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
}

.modern-billing-toolbar label {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    margin-right: 0.35rem;
}

.modern-billing-toolbar input[type="date"],
.modern-billing-toolbar select {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.875rem;
    padding: 0.45rem 0.75rem;
}

/* ============================================================
   MODERN MODAL — replaces Bootstrap legacy modal styling
   ============================================================ */

.modal-modern .modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(36, 49, 63, 0.15);
    overflow: hidden;
}

.modal-modern .modal-header {
    background: var(--surface-white);
    border-bottom: 1px solid var(--border-light);
    padding: 1.25rem 1.5rem;
}

.modal-modern .modal-title {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-modern .modal-body {
    padding: 1.5rem;
}

.modal-modern .modal-footer {
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
}

/* ============================================================
   MODAL — *-modern suffix variant (used by CustomerSummary, ContractSummary)
   Promoted from page-scoped CustomerSummary.css so cross-page modals
   (Cancel Contract, etc.) render with consistent chrome.
   ============================================================ */

.modal-dialog-modern {
    max-width: 500px;
    margin: 3rem auto;
}

/* This sheet loads after bootstrap.css, so the 500px above would otherwise win
   over Bootstrap's own .modal-lg / .modal-xl size modifiers at equal specificity. */
@media (min-width: 992px) {
    .modal-dialog-modern.modal-lg,
    .modal-dialog-modern.modal-xl {
        max-width: 800px;
    }
}

@media (min-width: 1200px) {
    .modal-dialog-modern.modal-xl {
        max-width: 1140px;
    }
}

.modal-content-modern {
    background: var(--surface-white);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-soft);
}

.modal-header-modern {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.modal-header-modern h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.btn-close-modern {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close-modern:hover {
    background: var(--surface-page);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.modal-body-modern {
    padding: 1.5rem;
}

.modal-footer-modern {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 0.625rem;
    background: var(--surface-page);
    border-radius: 0 0 8px 8px;
}

@media (max-width: 768px) {
    .modal-dialog-modern {
        margin: 1rem;
    }
}

/* ============================================================
   SUMMARY / DETAIL PAGE LAYOUT
   ============================================================ */

.summary-layout {
    display: flex;
    gap: 1.5rem;
}

.summary-main {
    flex: 1;
    min-width: 0;
}

/* Space stacked cards within the main column */
.summary-main > .modern-card {
    margin-bottom: 1.5rem;
}

.summary-sidebar {
    flex: 0 0 340px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Stacked cards inside form/content shells. Adjacent-sibling selector only adds
   spacing between two touching cards — never a trailing margin on a lone card.
   These shells are plain blocks (no flex/grid gap), so there's no double-gap risk. */
.modern-form > .modern-card + .modern-card,
.content-wrapper > .modern-card + .modern-card,
.content-container > .modern-card + .modern-card {
    margin-top: 1.5rem;
}

.detail-list {
    display: grid;
    gap: 0;
    grid-template-columns: 1fr 1fr;
}

.detail-item {
    border-bottom: 1px solid var(--border-light);
    padding: 0.85rem 0;
}

.detail-item dt {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.detail-item dd {
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 500;
    margin: 0;
}

.detail-full {
    grid-column: 1 / -1;
}

.stats-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-bottom: 1.5rem;
}

.stat-item {
    text-align: center;
}

.stat-item .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-primary { color: var(--primary-green-dark); }
.stat-success { color: #0f5132; }

.stat-item .stat-label {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* ============================================================
   AUTH PAGES — Login, Register, Recover, Lock, Error pages
   ============================================================ */

.block-center.wd-xl:has(.auth-card) {
    width: 440px;
    max-width: calc(100% - 2rem);
}

.auth-card {
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.auth-header {
    background: #101e41;
    padding: 2rem;
    text-align: center;
}

.auth-header img {
    max-width: 220px;
}

.auth-body {
    padding: 2rem;
}

.auth-body p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

.auth-input-group {
    margin-bottom: 1rem;
    position: relative;
}

.auth-input-group input {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.9rem;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    width: 100%;
}

.auth-input-group input:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(124, 179, 66, 0.1);
    outline: none;
}

.auth-input-group .auth-input-icon {
    color: var(--text-secondary);
    left: 0.875rem;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.auth-btn-primary {
    background: var(--primary-green);
    border: none;
    border-radius: 8px;
    color: var(--primary-green-contrast);
    cursor: pointer;
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 0.75rem;
    transition: background 0.2s;
    width: 100%;
}

.auth-btn-primary:hover {
    background: var(--primary-green-dark);
}

.auth-btn-secondary {
    background: var(--surface-page);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    display: block;
    font-size: 0.9375rem;
    font-weight: 500;
    padding: 0.75rem;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s;
    width: 100%;
}

.auth-btn-secondary:hover {
    border-color: var(--primary-green);
    color: var(--primary-green-dark);
    text-decoration: none;
}

.auth-footer {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 1.5rem;
    text-align: center;
}

.auth-remember {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.auth-remember label {
    align-items: center;
    color: var(--text-secondary);
    display: flex;
    font-size: 0.875rem;
    gap: 0.5rem;
}

.auth-remember a {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-decoration: none;
}

.auth-remember a:hover {
    color: var(--primary-green-dark);
}

.auth-checkbox {
    accent-color: var(--primary-green);
    height: 16px;
    width: 16px;
}

/* ============================================================
   FILTER CARD
   ============================================================ */

.filter-card {
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.filter-header {
    background: var(--surface-page);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
}

.filter-content {
    padding: 1.5rem;
}

.filter-row {
    align-items: flex-end;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.filter-select {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.875rem;
    padding: 0.625rem 0.875rem;
    width: 100%;
}

.btn-filter {
    background: var(--primary-green);
    border: none;
    border-radius: 6px;
    box-shadow: var(--shadow-soft);
    color: var(--primary-green-contrast);
    cursor: pointer;
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    transition: all 0.2s ease;
}

.btn-filter:hover {
    background: var(--primary-green-dark);
    transform: translateY(-1px);
}

.btn-clear {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-clear:hover {
    background: var(--surface-page);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* List scope chips + banner (Wave 1, list-scale). The shared chip component the pages
   re-invented per-view (.appt-chip, .appt-filter-btn): chips are plain GET links so every
   scope is bookmarkable and the dashboard can deep-link into a pre-filtered list. The
   companion .list-scope-note always states what is and isn't loaded, with a one-click escape. */
.list-scope-bar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.list-chip {
    align-items: center;
    background: var(--surface-page);
    border: 1px solid var(--border-color, #e3e8ef);
    border-radius: 999px;
    color: var(--text-gray, #475569);
    display: inline-flex;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.4rem 0.95rem;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Fingers, not cursors: at phone widths the chips are the page's primary control,
   and 31px pills sit under the 44px touch guideline. */
@media (max-width: 576px) {
    .list-chip {
        min-height: 44px;
        padding: 0.6rem 1.05rem;
    }
}

.list-chip:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
    text-decoration: none;
}

.list-chip:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.list-chip.is-active {
    background: var(--primary-green, #16a34a);
    border-color: var(--primary-green, #16a34a);
    box-shadow: 0 1px 2px rgba(22, 163, 74, 0.25);
    color: var(--primary-green-contrast);
}

.list-range-form {
    align-items: center;
    display: inline-flex;
    gap: 0.4rem;
    margin-left: auto;
}

.list-range-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
}

.list-range-form input[type="date"] {
    background: var(--surface-white);
    border: 1px solid var(--border-color, #e3e8ef);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8125rem;
    padding: 0.3rem 0.5rem;
}

.list-range-form .btn-filter {
    padding: 0.35rem 0.9rem;
}

.list-scope-note {
    align-items: baseline;
    color: var(--text-gray, #64748b);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.8125rem;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.list-scope-note a {
    color: var(--primary-green, #16a34a);
    font-weight: 600;
    text-decoration: none;
}

.list-scope-note a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .list-range-form {
        margin-left: 0;
        width: 100%;
    }
}

/* List-scale wave 5: the operator-inbox bell's unread pill in the topnavbar. */
.activity-bell {
    position: relative;
}

.activity-nav-badge {
    background: var(--danger-fg, #b42318);
    border-radius: 999px;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    min-width: 16px;
    padding: 2px 4px;
    position: absolute;
    right: 4px;
    text-align: center;
    top: 6px;
}

/* S33: load failures render a visible banner instead of an empty page that reads as "no data". */
.load-error-banner {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: 8px;
    color: var(--danger-fg);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
}

.btn-view {
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--primary-green-dark);
    display: inline-block;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.875rem;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn-view:hover {
    background: rgba(124, 179, 66, 0.08);
    color: var(--primary-green-dark);
}

/* Primary name link inside grid rows — the standard way to open a record's summary page */
.grid-name-link {
    color: var(--primary-green);
    font-weight: 500;
    text-decoration: none;
}

.grid-name-link:hover {
    color: var(--primary-green-dark);
    text-decoration: underline;
}

/* ============================================================
   SYNCFUSION GRID — shared across all list pages
   ============================================================ */

.e-grid {
    border: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.e-grid .e-headercell {
    background: #fafbfc;
    border-bottom: 2px solid var(--border-light);
    color: var(--text-dark);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 1rem;
}

.e-grid .e-rowcell {
    border-bottom: 1px solid #f5f7fa;
    color: var(--text-gray);
    font-size: 0.9375rem;
    padding: 1rem;
}

.e-grid .e-altrow {
    background-color: #fafbfc;
}

.e-grid .e-row {
    transition: background-color 0.15s ease;
}

.e-grid .e-gridcontent tr:hover {
    background-color: #f8f9fa;
}

.e-grid .e-toolbar {
    background: var(--surface-white);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem;
}

.e-grid .e-toolbar .e-toolbar-item .e-tbar-btn {
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    transition: background-color 0.15s ease;
}

.e-grid .e-toolbar .e-toolbar-item .e-tbar-btn:hover {
    background-color: #f5f7fa;
    color: var(--text-primary);
}

.e-grid .e-pager {
    background: var(--surface-white);
    border-top: 1px solid var(--border-light);
    padding: 1rem;
}

.e-pager .e-numericitem,
.e-pager .e-currentitem {
    border-radius: 4px;
    margin: 0 0.125rem;
}

.e-pager .e-currentitem {
    background: var(--primary-green) !important;
    color: var(--primary-green-contrast) !important;
    font-weight: 500;
}

.e-pager .e-numericitem:hover {
    background-color: #f5f7fa;
}

/* The bootstrap5 theme paints page numbers, arrows and the focus ring Bootstrap blue (#0d6efd / #86b7fe). */
.e-pager .e-numericitem,
.e-pager .e-numericitem:hover,
.e-pager .e-prevpage,
.e-pager .e-nextpage,
.e-pager .e-firstpage,
.e-pager .e-lastpage,
.e-pager div.e-icons.e-pager-default {
    color: var(--primary-green-text);
}

.e-pager div.e-icons.e-disable,
.e-pager .e-prevpagedisabled,
.e-pager .e-nextpagedisabled,
.e-pager .e-firstpagedisabled,
.e-pager .e-lastpagedisabled {
    color: var(--text-muted, #adb5bd);
}

.e-pager .e-numericitem.e-spacing,
.e-pager .e-pager-default:hover {
    color: var(--primary-green-text);
}

.e-pager .e-currentitem,
.e-pager .e-currentitem:hover,
.e-pager .e-currentitem.e-numericitem.e-focused {
    background: var(--primary-green) !important;
    color: var(--primary-green-contrast) !important;
    border: 3px solid var(--primary-green);
}

.e-pager .e-focused,
.e-pager .e-currentitem.e-numericitem.e-focused {
    box-shadow: 0 0 0 1px var(--primary-green-dark) inset;
}

.e-spinner-pane {
    background: rgba(255, 255, 255, 0.96);
}

.e-grid .e-columnmenu {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.e-grid .e-filter-popup {
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.e-grid .e-search {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s ease;
}

.e-grid .e-search:focus {
    border-color: var(--primary-green);
    outline: none;
}

/* ============================================================
   RESPONSIVE — forms, summary, address, tabs
   ============================================================ */

@media (max-width: 768px) {
    .modern-header {
        padding: 1.25rem 1rem;
        margin: -1rem -1rem 1rem -1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .summary-layout {
        flex-direction: column;
    }

    .summary-sidebar {
        flex: auto;
    }

    .detail-list {
        grid-template-columns: 1fr;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .insight-metrics {
        grid-template-columns: 1fr;
    }

    .modern-tabs {
        gap: 0;
    }

    .tab-btn {
        font-size: 0.8rem;
        padding: 0.6rem 0.75rem;
    }

    .modern-billing-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .dispatch-crew-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-row {
        flex-direction: column;
        gap: 1rem;
    }

    .filter-group {
        width: 100%;
    }

    .filter-actions {
        width: 100%;
        justify-content: stretch;
    }

    .btn-filter,
    .btn-clear {
        flex: 1;
        text-align: center;
    }

    .content-wrapper,
    .content-container {
        padding: 0 0.5rem 1rem;
    }

    /* One gutter up to 768px (#220, #222): the layout's wrapper carries the 1rem that the page headers' -1rem bleed
       already assumes, and the page's own wrapper inside it adds none, so header text and cards line up. */
    .content-wrapper {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .content-wrapper .content-wrapper,
    .content-wrapper .content-container {
        padding-left: 0;
        padding-right: 0;
    }

    .page-header,
    .page-header-modern {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .header-wrapper {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .btn-add {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .form-row-modern {
        grid-template-columns: 1fr;
    }

    .address-row {
        grid-template-columns: 1fr;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }

    .dispatch-crew-grid {
        grid-template-columns: 1fr;
    }
}

/* Mask the brief "No records to display" flash that Syncfusion server-rendered grids
 * show during initial hydration. We fade the empty-row in after 600ms — long enough for
 * the grid to bind data, short enough that genuinely empty grids still reveal quickly. */
.e-grid .e-emptyrow {
    animation: gridEmptyRowReveal 600ms ease-out forwards;
    opacity: 0;
}

@keyframes gridEmptyRowReveal {
    0%, 90% { opacity: 0; }
    100% { opacity: 1; }
}

/* ============================================================
   MOBILE — touch targets (pointer: coarse)
   Bumps interactive elements to the WCAG 44x44 minimum and
   keeps form inputs at 16px to stop iOS auto-zoom on focus.
   ============================================================ */
@media (pointer: coarse) {
  .btn-add,
  .btn-primary-modern,
  .btn-action,
  .btn-secondary,
  .btn-filter,
  .btn-clear,
  .btn-view,
  .e-toolbar-item,
  .e-btn,
  .grid-action-btn,
  a.sidebar-toggle,
  .breadcrumb a {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* Form controls — bigger tap targets and stop iOS zoom */
  .form-input-modern,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="number"],
  select,
  textarea {
    min-height: var(--touch-target-min);
    font-size: var(--mobile-font-base);
  }
}

/* ============================================================
   MOBILE — typography baseline
   ============================================================ */
@media (max-width: 768px) {
  body {
    font-size: 1rem;
    line-height: 1.5;
  }
}

/* ============================================================
   Mobile shell (operator-side, used by _MobileLayout.cshtml)
   ============================================================ */
.mobile-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--surface-page);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    background: var(--primary-green-dark);
    color: var(--primary-green-contrast);
    min-height: var(--touch-target-min);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.mobile-topbar .mobile-back,
.mobile-topbar .mobile-menu-toggle {
    background: transparent;
    border: 0;
    color: inherit;
    padding: 0.5rem;
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
}

.mobile-topbar .mobile-back:hover,
.mobile-topbar .mobile-back:focus,
.mobile-topbar .mobile-menu-toggle:hover,
.mobile-topbar .mobile-menu-toggle:focus {
    color: var(--primary-green-contrast);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
}

.mobile-topbar .mobile-title {
    flex: 1 1 auto;
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-main {
    flex: 1 1 auto;
    padding: var(--mobile-padding);
    /* Reserve space for a future bottom-nav (W2-B) plus iOS home-bar inset. */
    padding-bottom: calc(var(--mobile-padding) + var(--bottom-safe-area) + 4rem);
}

/* ============================================================
   Mobile bottom nav (W2-B, used by _BottomNav.cshtml inside _MobileLayout)
   ============================================================ */
.mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
    padding: 0.25rem 0;
    padding-bottom: calc(0.25rem + var(--bottom-safe-area));
    background: #ffffff;
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}
.mobile-bottom-nav .bn-tab {
    flex: 1 1 0;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.125rem;
    min-height: var(--touch-target-min);
    padding: 0.25rem 0.25rem;
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    text-decoration: none;
    /* Bumped from 0.75rem so the label qualifies as "large text" for WCAG
       contrast (3:1 minimum) when --primary-green-dark sits on a white
       bottom-nav background — addresses W2-FIXUP review finding. */
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}
.mobile-bottom-nav .bn-tab svg {
    width: 22px;
    height: 22px;
    display: block;
    stroke: currentColor;
}
.mobile-bottom-nav .bn-tab.is-active {
    color: var(--primary-green-dark);
    /* Heavier weight + a top-accent strip make the active state distinguishable
       even when raw colour contrast against white sits below the 4.5:1 normal-
       text bar. Inset shadow is the cheapest way to draw the accent without
       changing layout. */
    font-weight: 700;
    box-shadow: inset 0 2px 0 var(--primary-green-dark);
}
.mobile-bottom-nav .bn-tab.is-active .bn-label {
    font-size: 0.8125rem;
    font-weight: 700;
}
.mobile-bottom-nav .bn-tab:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: -2px;
    border-radius: 6px;
}
/* Only show the bottom nav on small screens. On desktop it's hidden — the sidebar is the nav. */
@media (min-width: 769px) {
    .mobile-bottom-nav { display: none; }
}

/* ============================================================
   Mobile sidebar drawer wrapper (W2-FIXUP)
   The mobile layout embeds the desktop sidebar partial inside a .wrapper so the
   existing off-canvas CSS (.aside-toggled .wrapper .aside-container) keeps
   working. Force the wrapper itself to be a pinned overlay so it doesn't
   participate in the .mobile-shell flex flow (which would push the topbar/main
   downward).
   ============================================================ */
.mobile-shell .mobile-sidebar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    z-index: 120;
    pointer-events: none;
    min-height: 0;
}
/* Re-enable pointer events on the sidebar surface itself so links are tappable
   once the drawer is opened. The aside-container slides into view via the
   existing app.css transform rules. */
.mobile-shell .mobile-sidebar-wrapper .aside-container {
    pointer-events: auto;
}
/* Backdrop while the drawer is open — tap-to-close is handled by the existing
   data-sidebar-anyclick-close behaviour on the sidebar; this is purely visual. */
.mobile-shell.aside-toggled::before,
body.aside-toggled .mobile-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 115;
    pointer-events: none;
}

/* ============================================================
   Mobile job detail (W2-C, _MobileLayout view)
   ============================================================ */
.job-mobile-hero {
    background: #fff;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.job-mobile-hero .hero-status { margin-bottom: 0.5rem; }
.job-mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.job-mobile-actions .btn-primary-modern,
.job-mobile-actions .btn-action {
    width: 100%;
    justify-content: center;
}
.job-mobile-photos {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.job-mobile-photos img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
}
.mobile-fab {
    position: fixed;
    right: 1rem;
    bottom: calc(4rem + var(--bottom-safe-area) + 1rem); /* sit above the bottom-nav */
    z-index: 70;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-green-dark);
    color: var(--primary-green-contrast);
    border: 0;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.mobile-fab svg { stroke: currentColor; }
.mobile-fab:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}
.job-mobile-section {
    margin-bottom: 1.25rem;
}
.job-mobile-section h3 {
    font-size: 1rem;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

/* ----------------------------------------------------------------------
   W3-A — PWA install banner.

   Rendered by _MobileLayout.cshtml just inside <body>; the inline script
   reveals it only when `beforeinstallprompt` fires (Chromium / Edge on
   Android, desktop Chrome). iOS Safari does not fire that event so the
   banner simply stays hidden there.
   ---------------------------------------------------------------------- */
.pwa-install-banner {
    position: sticky;
    top: 0;
    z-index: 60;
    background: var(--primary-green, #689f38);
    color: var(--primary-green-contrast);
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.pwa-install-banner[hidden] {
    display: none;
}
.pwa-install-banner__text {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.95rem;
    font-weight: 500;
}
.pwa-install-banner__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}
.pwa-install-banner .btn-primary-modern,
.pwa-install-banner .btn-action {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 0.9rem;
    border-radius: 6px;
}
.pwa-install-banner .btn-action {
    background: transparent;
    color: var(--primary-green-contrast);
    border: 1px solid currentColor;
}
.pwa-install-banner .btn-action:hover,
.pwa-install-banner .btn-action:focus {
    background: rgba(255, 255, 255, 0.12);
}
@media (max-width: 576px) {
    .pwa-install-banner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .pwa-install-banner__actions {
        justify-content: center;
    }
}

/* ----------------------------------------------------------------------
   W3-C — Web Push opt-in banner.

   Rendered by _MobileLayout.cshtml just inside <body>; the inline script
   reveals it only when the browser supports Push + Notifications, a VAPID
   public key is configured server-side, and permission is still 'default'.
   Visually matches .pwa-install-banner so the two banners feel like one
   system; uses a slightly darker accent so they can be distinguished if
   they happen to appear back-to-back.
   ---------------------------------------------------------------------- */
.push-opt-in-banner {
    position: sticky;
    top: 0;
    z-index: 60;
    background: var(--secondary-blue, #2c7a7b);
    color: #ffffff;
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.push-opt-in-banner[hidden] {
    display: none;
}
.push-opt-in-banner__text {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.95rem;
    font-weight: 500;
}
.push-opt-in-banner__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}
.push-opt-in-banner .btn-primary-modern,
.push-opt-in-banner .btn-action {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 0.9rem;
    border-radius: 6px;
}
.push-opt-in-banner .btn-action {
    background: transparent;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.5);
}
.push-opt-in-banner .btn-action:hover,
.push-opt-in-banner .btn-action:focus {
    background: rgba(255, 255, 255, 0.12);
}
@media (max-width: 576px) {
    .push-opt-in-banner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .push-opt-in-banner__actions {
        justify-content: center;
    }
}

/* W3-E: geotag pin badge overlaid on photo thumbnails.
   Used in JobSummary.cshtml's .photo-tile-wrap and JobMobile.cshtml's
   .job-mobile-photo-tile-wrap. The host element must be position: relative
   (both already are by virtue of being a flex column / explicit relative).
   The pin opens Google Maps in a new tab so the operator can verify the
   crew was actually on-site when the photo was taken.

   Min 24×24 visual hit + 8px hit-slop (padding) keeps it above the WCAG
   24×24 target without crowding the photo. */
.photo-geo-pin {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.78); /* slate-900 @ 78% — readable on any photo */
    color: #ffffff;
    text-decoration: none;
    line-height: 0;
    z-index: 2;
    transition: background 0.15s ease;
}
.photo-geo-pin:hover,
.photo-geo-pin:focus-visible {
    background: rgba(17, 24, 39, 0.95);
    color: #ffffff;
}
.photo-geo-pin:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}
.photo-geo-pin svg { stroke: currentColor; }

/* Wrapper for the mobile photo tile so the geo pin can be absolutely positioned. */
.job-mobile-photo-tile-wrap {
    position: relative;
    line-height: 0;
}

/* ----------------------------------------------------------------------
   W3-B — Offline indicator badge.

   Rendered by _MobileLayout.cshtml above <main>. The inline script there
   toggles the `hidden` attribute on `online` / `offline` events so the
   badge appears the moment the device loses connectivity. Sits below the
   topbar (not sticky on top of it) so it never covers controls; the orange
   hue contrasts strongly with the green theme without colliding with
   primary CTAs.
   ---------------------------------------------------------------------- */
.offline-badge {
    background: #f97316;
    color: #fff;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    text-align: center;
    font-weight: 500;
}
.offline-badge[hidden] {
    display: none;
}

/* ----------------------------------------------------------------------
   Appointment quick filters + status pills (shared component).
   Used by the Job summary and Customer summary appointment grids; the
   matching engine lives in js/custom/appt-quick-filters.js. Promoted from
   JobSummary.cshtml inline styles; var(--border)/var(--white) normalized
   to the defined tokens --border-light/--surface-white.
   ---------------------------------------------------------------------- */
.tab-actions { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.appt-filter-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.appt-quick-filters { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.appt-filter-btn { padding: 5px 12px; border: 1px solid var(--border-light); border-radius: 16px; background: var(--surface-white); color: var(--text-primary); font-size: 12px; font-weight: 500; cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.appt-filter-btn:hover { border-color: var(--primary-green); color: var(--primary-green); }
.appt-filter-btn.active { background: var(--primary-green); border-color: var(--primary-green); color: var(--primary-green-contrast); }
.appt-filter-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.appt-filter-status { display: inline-flex; align-items: center; gap: 8px; }
.appt-filter-status label { margin: 0; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.appt-status-select { padding: 5px 10px; border: 1px solid var(--border-light); border-radius: 6px; font-size: 12px; color: var(--text-primary); background: var(--surface-white); }
.appt-count-label { font-size: 12px; color: var(--text-secondary); }
@media (max-width: 768px) {
    .appt-filter-bar { flex-direction: column; align-items: stretch; }
    .appt-filter-status { justify-content: space-between; }
}
.appt-status-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.appt-status-pill.completed   { background: var(--success-bg); color: var(--success-fg); }
.appt-status-pill.scheduled   { background: var(--info-bg); color: var(--info-fg); }
.appt-status-pill.onmyway     { background: var(--info-bg); color: var(--info-fg); }
.appt-status-pill.inprogress  { background: var(--badge-beta-bg); color: var(--badge-beta-fg); }
.appt-status-pill.skipped     { background: var(--danger-bg); color: var(--danger-fg); }
.appt-status-pill.rescheduled { background: var(--border-light); color: var(--text-primary); }
/* legacy binary class retained for safety */
.appt-status-pill.active { background: var(--info-bg); color: var(--info-fg); }
/* Past-dated visit still open (not closed), rendered next to the status pill */
.appt-overdue { margin-left: 4px; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 10px; background: var(--danger-bg); color: var(--danger-fg); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }


/* ==========================================================================
   Impersonation banner (support "sign in as")

   Lives HERE, not in admin-panel.css: this renders on TENANT pages, which never
   load the admin stylesheet. Sticky rather than fixed so it pushes the page down
   instead of covering the topnav; z-index clears .topnavbar-wrapper (121) and
   .sidebar-backdrop (112).
   ========================================================================== */

.impersonation-banner {
    position: sticky;
    top: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--danger-bg);
    border-bottom: 2px solid var(--danger-fg);
    color: var(--danger-fg);
    font-size: 0.875rem;
}

.impersonation-banner__icon {
    flex: 0 0 auto;
}

.impersonation-banner__text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}

.impersonation-banner__meta {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.impersonation-banner__actions {
    margin: 0 0 0 auto;
    flex: 0 0 auto;
}

.impersonation-banner__button {
    background: var(--danger-fg);
    border: none;
    border-radius: 6px;
    color: var(--surface-white);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.4rem 0.9rem;
    white-space: nowrap;
}

.impersonation-banner__button:hover,
.impersonation-banner__button:focus {
    filter: brightness(1.1);
}

@media (max-width: 576px) {
    .impersonation-banner {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .impersonation-banner__meta {
        display: none;
    }
}

/* Read-only lockout banner (_ReadOnlyBanner.cshtml, 2026-09-24) */
.read-only-banner {
    align-items: center;
    flex-wrap: wrap;
}

.read-only-banner span {
    display: inline;
    margin-left: 0.25rem;
}

.read-only-banner__cta {
    margin-left: auto;
    white-space: nowrap;
}

/* ============================================================
   ALERTS (v2) — replaces Bootstrap `.alert .alert-*`
   The --alert-* tokens above were declared but never had a base
   rule consuming them, so `alert-modern` (the documented v2 class,
   already used by PaymentSummary/PropertyMap) rendered unstyled.
   ============================================================ */

.alert-modern {
    align-items: flex-start;
    border: 1px solid transparent;
    border-radius: 6px;
    display: flex;
    font-size: 0.875rem;
    gap: 0.75rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    padding: 0.875rem 1.125rem;
}

.alert-modern svg { flex-shrink: 0; margin-top: 0.125rem; }
.alert-modern strong { font-weight: 600; }

.alert-modern.alert-success {
    background: var(--alert-success-bg);
    border-color: var(--success-border);
    color: var(--alert-success-fg);
}

.alert-modern.alert-danger {
    background: var(--alert-danger-bg);
    border-color: var(--danger-border);
    color: var(--alert-danger-fg);
}

.alert-modern.alert-info {
    background: var(--alert-info-bg);
    border-color: var(--status-completed-bg);
    color: var(--alert-info-fg);
}

.alert-modern.alert-warning {
    background: var(--warning-amber-bg);
    border-color: var(--warning-amber-border);
    color: var(--status-forecasted-fg);
}

/* Invoice lifecycle badges (Sales/InvoiceSummary) */
.status-paid    { background: var(--status-active-bg);    color: var(--status-active-fg); }
.status-partial { background: var(--status-forecasted-bg); color: var(--status-forecasted-fg); }
.status-open    { background: var(--status-info-bg);       color: var(--status-info-fg); }
.status-overdue { background: var(--status-cancelled-bg);  color: var(--status-cancelled-fg); }

.sidebar-group-link:focus-visible,
.workflow-help > summary:focus-visible, .workflow-options > summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.workflow-help > summary, .workflow-options > summary { cursor: pointer; font-weight: 600; padding: .75rem 0; }
.workflow-help { margin-top: .5rem; }
.workflow-help .workflow-guide-steps { margin-top: .75rem; }
.workflow-options { margin-bottom: 1rem; }
.workflow-options > summary { color: var(--text-primary); }
/* A collapsible card: the summary reads as the card header, with a chevron on the right. */
details.modern-card > summary { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.5rem; list-style: none; border-radius: inherit; }
details.modern-card > summary::-webkit-details-marker { display: none; }
details.modern-card > summary::after { content: ""; flex-shrink: 0; margin-left: auto; width: .55rem; height: .55rem; border-right: 2px solid var(--text-secondary); border-bottom: 2px solid var(--text-secondary); transform: translateY(-25%) rotate(45deg); transition: transform .2s; }
details.modern-card[open] > summary::after { transform: translateY(25%) rotate(-135deg); }
details.modern-card > summary:hover { background: var(--surface-page); }
details.modern-card[open] > summary { border-bottom: 1px solid var(--border-light); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
details.modern-card > summary .summary-title { white-space: nowrap; }
details.modern-card > summary .summary-meta { font-weight: 400; font-size: .875rem; color: var(--text-secondary); min-width: 0; }
.workflow-return { margin-bottom: 1rem; }
.workflow-return[hidden] { display: none; }
.workflow-return-link { display: inline-flex; align-items: center; gap: .4rem; color: var(--text-secondary); font-size: .875rem; font-weight: 500; text-decoration: none; }
.workflow-return-link:hover, .workflow-return-link:focus-visible { color: var(--primary-green-dark); text-decoration: none; }
/* A back link followed by a page header joins the header band; the header's negative
   top margin would otherwise slide it over the link. */
.workflow-return:not([hidden]):has(+ .modern-header, + .page-header) { background: var(--surface-white); margin: -1.5rem -1.5rem 0; padding: 1.75rem 2rem 0; }
.workflow-return:not([hidden]) + .modern-header, .workflow-return:not([hidden]) + .page-header { margin-top: 0; padding-top: 1rem; }
@media (max-width: 768px) { .workflow-return:not([hidden]):has(+ .modern-header, + .page-header) { margin: -1rem -1rem 0; padding: 1.25rem 1rem 0; } }
@media (max-width: 576px) { .workflow-guide-actions { flex-direction: column; align-items: stretch; } }

/* Address lookup dropdown (#263). Positioned by wwwroot/js/custom/address-autocomplete.js
   under the street input; the input's parent becomes the positioning host. */
.addr-suggest-host { position: relative; }
.addr-suggest {
    position: absolute;
    z-index: 1060;               /* above Bootstrap modals (1050) */
    margin: 2px 0 0;
    padding: 4px 0;
    list-style: none;
    max-height: 380px;
    overflow-y: auto;
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
}
.addr-suggest[hidden] { display: none; }
.addr-suggest-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; cursor: pointer; }
.addr-suggest-row:hover, .addr-suggest-row.is-active { background: var(--surface-raised); }
.addr-suggest-primary { color: var(--text-primary); font-weight: 600; }
.addr-suggest-secondary { color: var(--text-secondary-strong); font-size: 0.85em; }
@media (max-width: 576px) { .addr-suggest-row { padding: 12px; } }
