@import url('https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@300;400;500;600;700;900&family=Red+Hat+Mono:wght@400;500;600&display=swap');

/* ═══════════════════════════════════════════════════════════════════════════
   RAPID DISPATCH — Design Tokens
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
    --rrn-navy: #0c2448;
    --rrn-navy-mid: #0e2d56;
    --rrn-navy-light: #142f5e;
    --rrn-green: #1cc478;
    --rrn-green-dim: #0d6e42;
    --rrn-mustard: #e8b81c;
    --rrn-orange: #f0854a;
    --rrn-teal: #8fd6d9;
    --bg: #070f1d;
    --surface: #0c1628;
    --surface2: #0f1e35;
    --border: #132040;
    --border2: #1a2d55;
    --text: #a8bcd4;
    --text-dim: #a8bcd4;
    --text-bright: #e8f0f8;
    --accent: var(--rrn-green);
    --accent-dim: #0b3d2a;
    --green: var(--rrn-green);
    --green-dim: var(--rrn-green-dim);
    --amber: var(--rrn-mustard);
    --red: var(--rrn-orange);
    --red-dim: #3d1a08;
    --teal: var(--rrn-teal);
    --sans: 'Red Hat Display', sans-serif;
    --mono: 'Red Hat Mono', monospace;
    --hour-height: 52px;
    --gutter-width: 42px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIGHT THEME OVERRIDES
   Applied via [data-theme="light"] on <html>
   ═══════════════════════════════════════════════════════════════════════════ */
[data-theme="light"] {
    --bg:         #eef2f8;
    --surface:    #ffffff;
    --surface2:   #f3f7fc;
    --border:     #d8e2ee;
    --border2:    #c2d0e2;
    --text:       #4a6080;
    --text-dim:   #7a90aa;
    --text-bright: #0c2448;
    --accent-dim: #d0f5e6;
    --red-dim:    #fde8df;
    --red:        #c94518;
    --amber:      #b8920e;
    --green-dim:  #d0f5e6;
    --rrn-green-dim: #12a063;  /* darken dim green so it reads on white */
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIGHT THEME — Component overrides for hardcoded dark colours
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Buttons ── */
[data-theme="light"] .btn-ok {
    border-color: rgba(21,128,61,.45);
}
[data-theme="light"] .btn-ok:hover:not(:disabled) {
    background: #15803d;
    color: #fff;
}
[data-theme="light"] .btn-danger {
    border-color: rgba(185,28,28,.45);
}
[data-theme="light"] .btn-danger:hover:not(:disabled) {
    background: #b91c1c;
    color: #fff;
}

/* ── err-box ── */
[data-theme="light"] .err-box {
    border-color: rgba(185,28,28,.35);
}

/* ── Modal backdrop: lighter fog ── */
[data-theme="light"] .modal-backdrop {
    background: rgba(10,20,50,.45);
}

/* ── Global search dropdown shadow ── */
[data-theme="light"] .global-search-results {
    box-shadow: 0 8px 28px rgba(0,0,40,.12);
}

/* ── User menu shadow ── */
[data-theme="light"] .user-menu {
    box-shadow: 0 8px 24px rgba(0,0,40,.14);
}

/* ── Admin: active tab count badge ── */
[data-theme="light"] .admin-tab.active .admin-tab-count {
    background: rgba(28,196,120,.12);
    border-color: rgba(28,196,120,.25);
}

[data-theme="light"] .admin-section .admin-tab.active {
    background: rgba(28,196,120,.1);
    border-color: rgba(28,196,120,.25);
}

[data-theme="light"] .admin-section .admin-tab.active .admin-tab-count {
    background: rgba(28,196,120,.15);
    border-color: rgba(28,196,120,.25);
}

/* ── Conflict banner ── */
[data-theme="light"] .conflict-banner {
    background: rgba(234,88,12,.08);
    border-bottom-color: rgba(234,88,12,.2);
    color: #c2410c;
}
[data-theme="light"] .conflict-row {
    border-bottom-color: var(--border);
}

/* ── Availability calendar ── */
[data-theme="light"] .avail-cal-day:hover {
    background: var(--surface2);
}
[data-theme="light"] .avail-cal-day.weekend {
    background: #e9eef6;
}
[data-theme="light"] .avail-cal-day.bank-hol {
    background: #ede9fe;
}
[data-theme="light"] .avail-cal-bk {
    color: #5b21b6;
    background: rgba(91,33,182,.09);
    border-left-color: #7c3aed;
}

/* ── Leaflet tile tinting ── */
/* Applied only when the dark layer is active (.rrn-tiles-dark set in JS) */
.rrn-tiles-dark .leaflet-tile-pane,
#login-map .leaflet-tile-pane {
    filter: sepia(0.6) hue-rotate(190deg) saturate(2.2) brightness(0.78);
}

[data-theme="light"] .leaflet-control-attribution {
    background: rgba(240,244,248,.92) !important;
    color: var(--text-dim) !important;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

.app-shell {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GLOBAL TOPBAR
   ═══════════════════════════════════════════════════════════════════════════ */
.topbar {
    display: flex;
    align-items: center;
    height: 48px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.topbar-brand {
    padding: 0 20px;
    border-right: 1px solid var(--border);
    height: 100%;
    display: flex;
    align-items: center;
}

.brand-wordmark {
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-bright);
    white-space: nowrap;
}

    .brand-wordmark span {
        color: var(--rrn-green);
    }

/* App switcher (brand trigger + popover) */
.app-switcher {
    position: relative;
}

.app-switcher-trigger {
    height: 100%;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0 18px 0 0;
}

.app-switcher-trigger:hover .brand-wordmark {
    color: var(--accent);
}

.app-switcher-caret {
    font-size: 9px;
    color: var(--text-dim);
    transition: transform .2s ease, color .2s ease;
}

.app-switcher-caret.open {
    transform: rotate(180deg);
    color: var(--accent);
}

.app-switcher-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 10px;
    min-width: 300px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 12px;
    overflow: hidden;
    z-index: 1200;
    box-shadow: 0 18px 42px rgba(0,0,0,.46);
}

.app-switcher-menu--pop {
    animation: app-switcher-pop .22s cubic-bezier(.22,.84,.29,1.15) both;
}

@keyframes app-switcher-pop {
    from { opacity: 0; transform: translateY(-6px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.app-switcher-title {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.app-switcher-item {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.02);
    transition: background .15s ease, transform .15s ease;
}

.app-switcher-item:hover {
    background: var(--surface2);
    transform: translateX(2px);
}

.app-switcher-item--active {
    background: rgba(0, 255, 140, 0.06);
}

.app-switcher-item--current {
    background: rgba(255,255,255,0.02);
    color: var(--text-dim);
    cursor: default;
    opacity: .72;
}

.app-switcher-item--current:hover {
    background: rgba(255,255,255,0.02);
    transform: none;
}

.app-switcher-item--accent {
    border-left: 2px solid var(--accent);
}

.app-switcher-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface2);
    font-size: 14px;
    flex-shrink: 0;
}

.app-switcher-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.app-switcher-text strong {
    font-size: 13px;
    color: var(--text-bright);
}

.app-switcher-text small {
    font-size: 11px;
    color: var(--text-dim);
}

/* Environment banner (non-prod UI) */
.env-banner {
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}

.env-banner-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.env-banner-right {
    color: var(--text-dim);
    opacity: .9;
}

.env-pill {
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 600;
    border: 1px solid transparent;
}

.env-app-name {
    opacity: .9;
}

.env-meta {
    font-size: 9px;
}

.env-banner--staging {
    background: rgba(59,130,246,.12);
    color: #bfdbfe;
}

.env-banner--staging .env-pill {
    background: rgba(59,130,246,.32);
    border-color: rgba(59,130,246,.6);
    color: #eff6ff;
}

.env-banner--local {
    background: rgba(28,196,120,.16);
    color: #bbf7d0;
}

.env-banner--local .env-pill {
    background: rgba(28,196,120,.38);
    border-color: rgba(28,196,120,.7);
    color: #ecfdf5;
}

[data-theme="light"] .env-banner--staging {
    background: rgba(59,130,246,.08);
    color: #1d4ed8;
}

[data-theme="light"] .env-banner--staging .env-pill {
    background: rgba(59,130,246,.14);
    border-color: rgba(59,130,246,.4);
    color: #1d4ed8;
}

[data-theme="light"] .env-banner--local {
    background: rgba(22,163,74,.06);
    color: #166534;
}

[data-theme="light"] .env-banner--local .env-pill {
    background: rgba(34,197,94,.14);
    border-color: rgba(34,197,94,.4);
    color: #166534;
}

.app-switcher-current-tag {
    margin-top: 2px;
    font-family: var(--mono);
    font-size: 9px !important;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-dim) !important;
}

.topbar-nav {
    display: flex;
    align-items: stretch;
    height: 100%;
}

.topbar-nav-extra {
    display: flex;
    align-items: center;
    margin-left: 10px;
}

.nav-item {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    text-decoration: none;
    padding: 0 18px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    border-right: 1px solid var(--border);
    transition: color .15s, background .15s;
    white-space: nowrap;
}

    .nav-item:hover {
        color: var(--text-bright);
        background: var(--surface2);
    }

    .nav-item.active {
        color: var(--accent);
        background: var(--accent-dim);
        border-bottom: 2px solid var(--accent);
    }

.nav-badge {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 8px;
}

.topbar-spacer {
    flex: 1;
}

/* Theme toggle button */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border2);
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: color .15s, background .15s, border-color .15s;
    margin-right: 10px;
    flex-shrink: 0;
}

    .theme-toggle-btn:hover {
        color: var(--text-bright);
        background: var(--surface2);
        border-color: var(--accent);
    }

/* User chip */
.topbar-user {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-left: 1px solid var(--border);
    height: 100%;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 5px 8px;
    border-radius: 6px;
    transition: background .15s;
}

    .user-chip:hover, .user-chip.open {
        background: var(--surface2);
    }

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--mono);
}

.user-chip-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-bright);
}

.user-chip-caret {
    color: var(--text-dim);
    font-size: 9px;
}

.user-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 8px;
    min-width: 210px;
    z-index: 1000;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
}

.user-menu-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

    .user-menu-header strong {
        color: var(--text-bright);
        font-size: 13px;
    }

    .user-menu-header span {
        color: var(--text-dim);
        font-size: 12px;
    }

.user-menu-role {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent) !important;
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: 9px 14px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background .15s;
    font-family: var(--sans);
}

    .user-menu-item:hover {
        background: var(--surface2);
        color: var(--text-bright);
    }

.user-menu-logout {
    color: var(--red);
}

    .user-menu-logout:hover {
        background: var(--red-dim) !important;
        color: var(--red) !important;
    }

.user-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTEXTUAL SUB-BAR  (each page renders its own controls here)
   ═══════════════════════════════════════════════════════════════════════════ */
.sub-bar {
    display: flex;
    align-items: center;
    height: 40px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    padding: 0 4px;
    gap: 2px;
}

.sub-bar-spacer {
    flex: 1;
}

/* Date navigator */
.sub-bar-date {
    display: flex;
    align-items: center;
    height: 100%;
}

.sub-bar-nav {
    width: 32px;
    height: 100%;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 16px;
    font-family: var(--mono);
    transition: color .15s, background .15s;
}

    .sub-bar-nav:hover {
        color: var(--text-bright);
        background: var(--surface);
    }

.sub-bar-date-label {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-bright);
    padding: 0 8px;
    min-width: 160px;
    text-align: center;
    white-space: nowrap;
}

.sub-bar-dow {
    color: var(--text-dim);
    margin-right: 4px;
}

.sub-bar-date-clickable {
    cursor: pointer;
    border-bottom: 1px dashed var(--text-dim);
}
.sub-bar-date-clickable:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.sub-bar-date-input {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-bright);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 2px 6px;
    outline: none;
    width: 140px;
}

/* View toggle */
.sub-bar-views {
    display: flex;
    align-items: center;
    height: 100%;
    margin-left: 4px;
}

.sub-view-btn {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    padding: 0 14px;
    height: 100%;
    cursor: pointer;
    transition: color .15s;
}

    .sub-view-btn:hover {
        color: var(--text-bright);
    }

    .sub-view-btn.active {
        color: var(--accent);
        border-bottom-color: var(--accent);
    }

/* Status */
.sub-bar-status {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 14px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    border-left: 1px solid var(--border);
    height: 100%;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 5px var(--green);
    flex-shrink: 0;
}

    .status-dot.busy {
        background: var(--amber);
        box-shadow: 0 0 5px var(--amber);
        animation: blink 1s infinite;
    }

/* Admin back link */
.sub-bar-back {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    text-decoration: none;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--border);
    transition: color .15s, background .15s;
}

    .sub-bar-back:hover {
        color: var(--text-bright);
        background: var(--surface);
    }

@keyframes blink {
    50% {
        opacity: .3;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SHARED BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.btn {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .8px;
    text-transform: uppercase;
    border-radius: 5px;
    padding: 7px 14px;
    border: none;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

    .btn:disabled {
        opacity: .35;
        cursor: not-allowed;
    }

.btn-sm {
    padding: 4px 10px;
    font-size: 9px;
}

.btn-full {
    width: 100%;
    padding: 10px;
    margin-top: 4px;
    justify-content: center;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

    .btn-primary:hover:not(:disabled) {
        filter: brightness(1.12);
    }

.btn-ghost {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border2);
}

    .btn-ghost:hover:not(:disabled) {
        background: var(--border2);
    }

    .btn-ghost.active {
        background: var(--accent-dim);
        color: var(--accent);
        border-color: var(--accent);
    }

.btn-ok {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid #166534;
}

    .btn-ok:hover:not(:disabled) {
        background: #166534;
        color: #fff;
    }

.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid #7f1d1d;
}

    .btn-danger:hover:not(:disabled) {
        background: #7f1d1d;
        color: #fff;
    }

.btn-pill {
    border-radius: 20px;
    padding: 8px 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SHARED FORM ELEMENTS
   ═══════════════════════════════════════════════════════════════════════════ */
.f-group {
    margin-bottom: 12px;
}

.f-hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
    line-height: 1.4;
}

.f-label {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 5px;
}

.f-input, .f-select, .f-textarea {
    font-family: var(--sans);
    font-size: 13px;
    background: var(--bg);
    border: 1px solid var(--border2);
    color: var(--text-bright);
    border-radius: 6px;
    padding: 8px 10px;
    width: 100%;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
    -webkit-appearance: none;
    color-scheme: dark;
}

[data-theme="light"] .f-input,
[data-theme="light"] .f-select,
[data-theme="light"] .f-textarea {
    color-scheme: light;
}

.f-textarea {
    resize: vertical;
    min-height: 60px;
}

.f-input::placeholder {
    color: var(--text-dim);
}

.f-input:focus, .f-select:focus, .f-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}

.f-input:disabled, .f-select:disabled, .f-textarea:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.f-row {
    display: flex;
    gap: 10px;
}

    .f-row .f-group {
        flex: 1;
    }

/* ═══════════════════════════════════════════════════════════════════════════
   SHARED MODAL
   ═══════════════════════════════════════════════════════════════════════════ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-center-wrap {
    width: 480px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    animation: popIn .18s cubic-bezier(.4,0,.2,1);
    max-height: 90vh;
    overflow: hidden;
}

.modal-wide {
    width: 640px;
}

.modal {
    background: var(--surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-center {
    width: 560px;
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 10px;
    border: 1px solid var(--border2);
    animation: popIn .18s cubic-bezier(.4,0,.2,1);
}

.modal-narrow {
    width: 400px !important;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-head {
    padding: 14px 20px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-head-info {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.modal-title {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-bright);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.modal-ref {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
}

.modal-body {
    padding: 18px 20px;
    overflow-y: auto;
}

.modal-body-pad {
    padding: 20px 22px;
    overflow-y: auto;
}

.modal-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
}

.modal-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0 14px;
}

.modal-section-divider {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 16px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* ── Split modal (two-column edit layout) ── */
.modal-split {
    width: 920px;
}

.modal-split .modal-body-pad {
    padding: 0;
    overflow: hidden;
    flex: 1;
    display: flex;
    min-height: 0;
}

.edit-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 0;
    height: min(calc(90vh - 120px), 600px);
}

.edit-form-col,
.edit-history-col {
    overflow-y: auto;
    padding: 20px 22px;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
    display: flex;
    flex-direction: column;
}

.edit-form-col {
    border-right: 1px solid var(--border);
}

/* Notes field stretches to fill remaining form column space */
.edit-notes-grow {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 60px;
}

.edit-notes-grow .f-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.edit-notes-fill {
    flex: 1;
    resize: none;
}

/* ── Edit Right Panel (CRM Notes + History tabs) ──────────────────────── */

.erp-no-scroll { overflow: hidden !important; }

.erp-tabs {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
}

.erp-tab {
    flex: 0 0 auto;
    padding: 7px 10px;
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.erp-tab:hover { color: var(--text); }
.erp-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.erp-tab-count {
    font-family: var(--mono);
    font-size: 9px;
    background: var(--bg-hover);
    padding: 1px 5px;
    border-radius: 6px;
}

.erp-tab.active .erp-tab-count { background: rgba(56, 189, 248, .15); }

.erp-notes-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.erp-notes-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
    min-height: 0;
    scrollbar-width: thin;
}

.erp-empty {
    font-size: 12px;
    color: var(--text-dim);
    font-style: italic;
    padding: 24px 0;
    text-align: center;
}

.erp-entry {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.erp-entry:last-child { border-bottom: none; }

.erp-entry-hdr {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 3px;
}

.erp-author {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-bright);
}

.erp-time {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--text-dim);
}

.erp-body {
    font-size: 12px;
    color: var(--text);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.erp-add-note {
    flex-shrink: 0;
    padding: 8px 0 0;
    border-top: 1px solid var(--border);
}

.erp-note-input {
    width: 100%;
    resize: none;
    min-height: 48px;
    font-size: 12px;
}

.erp-add-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.erp-followup {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 8px;
    background: var(--surface-alt, rgba(255,255,255,.04));
    border-radius: 6px;
    border: 1px dashed var(--border);
}
.erp-followup-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    white-space: nowrap;
}
.erp-followup-input {
    flex: 1;
    min-width: 0;
    padding: 4px 8px !important;
    font-size: 12px !important;
}
.erp-followup-changed {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}

.erp-error {
    font-size: 11px;
    color: var(--red, #e04b4b);
    flex: 1;
}

/* ── CRM Details panel (loading state) ──────────────────────────────── */

.crm-panel-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 0;
    font-size: 12px;
    color: var(--text-dim);
}

/* ── Order Lines Panel ──────────────────────────────────────────────── */

.order-lines-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
}

.ol-section { margin-bottom: 16px; }
.ol-section:last-child { margin-bottom: 0; }

.ol-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 0 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.ol-section-header-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ol-section-totals {
    flex-shrink: 0;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    text-align: right;
    line-height: 1.35;
    max-width: 55%;
}

.ol-section-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
}

.ol-icon-parts  { background: rgba(56, 189, 248, .12); color: #38bdf8; }
.ol-icon-parts::before  { content: "P"; font-weight: 700; }
.ol-icon-labour { background: rgba(168, 85, 247, .12); color: #a855f7; }
.ol-icon-labour::before { content: "L"; font-weight: 700; }

.ol-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-bright);
}

.ol-section-count {
    font-size: 10px;
    font-weight: 600;
    background: rgba(255,255,255,.06);
    color: var(--text-dim);
    padding: 1px 6px;
    border-radius: 8px;
}

.ol-cards { display: flex; flex-direction: column; gap: 6px; }

.ol-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    transition: border-color .15s;
}
.ol-card:hover { border-color: var(--border2); }

.ol-card-labour { border-left: 2px solid rgba(168, 85, 247, .35); }

.ol-card-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.ol-desc {
    font-size: 12px;
    color: var(--text-bright);
    font-weight: 500;
    flex: 1;
    line-height: 1.4;
}

.ol-part-no {
    font-size: 10px;
    font-family: var(--mono);
    color: var(--text-dim);
    background: rgba(255,255,255,.04);
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.ol-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.ol-chip {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(255,255,255,.05);
    color: var(--text-dim);
}

.ol-chip-dmg {
    background: rgba(239, 68, 68, .1);
    color: #f87171;
}

.ol-card-money {
    display: flex;
    gap: 12px;
    margin-top: 6px;
}

.ol-money {
    font-size: 11px;
    color: var(--text-dim);
}
.ol-money strong {
    color: var(--text-bright);
    font-weight: 600;
}

.ol-card-details {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Before Photos Panel ────────────────────────────────────────────── */

.bp-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    padding: 10px 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.bp-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color .15s, transform .15s;
}
.bp-thumb:hover { border-color: var(--accent); transform: scale(1.03); }
.bp-thumb--active { border-color: var(--accent); }

.bp-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.bp-thumb-num {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 9px;
    font-weight: 700;
    background: rgba(0,0,0,.65);
    color: #fff;
    padding: 1px 5px;
    border-radius: 4px;
}

.bp-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,.85);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.bp-lightbox-inner {
    position: relative;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bp-img-viewport {
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 88vw;
    max-height: 75vh;
    border-radius: 8px;
    background: rgba(0,0,0,.4);
    user-select: none;
    -webkit-user-select: none;
}

.bp-grab { cursor: grab; }
.bp-grabbing { cursor: grabbing; }

.bp-img-viewport img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    transition: transform .15s ease;
    transform-origin: center center;
    pointer-events: none;
}

.bp-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    background: rgba(255,255,255,.08);
    border-radius: 10px;
    padding: 5px 10px;
    backdrop-filter: blur(8px);
}

.bp-nav {
    background: rgba(255,255,255,.1);
    border: none;
    color: #fff;
    font-size: 22px;
    padding: 4px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
    line-height: 1;
}
.bp-nav:hover:not(:disabled) { background: rgba(255,255,255,.2); }
.bp-nav:disabled { opacity: .3; cursor: default; }

.bp-tool {
    background: rgba(255,255,255,.08);
    border: none;
    color: rgba(255,255,255,.85);
    font-size: 14px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
    font-weight: 600;
    min-width: 32px;
    text-align: center;
}
.bp-tool:hover { background: rgba(255,255,255,.18); color: #fff; }

.bp-separator {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,.15);
    margin: 0 2px;
}

.bp-counter {
    font-size: 12px;
    color: rgba(255,255,255,.6);
    font-weight: 500;
    padding: 0 6px;
    white-space: nowrap;
}

.bp-close {
    position: absolute;
    top: -8px;
    right: -8px;
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.bp-close:hover { background: rgba(255,255,255,.25); }

@media (max-width: 768px) {
    .modal-split {
        width: 95vw;
    }

    .modal-split .modal-body-pad {
        overflow-y: auto;
        display: block;
    }

    .edit-layout {
        display: block;
        height: auto;
    }

    .edit-form-col {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .edit-history-col {
        max-height: 300px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SHARED UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */
.mono {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text);
}

.dim {
    color: var(--text-dim);
}

.mt-sm {
    margin-top: 12px;
}

.err-box {
    background: var(--red-dim);
    border: 1px solid #7f1d1d;
    border-radius: 6px;
    padding: 10px 13px;
    font-size: 12px;
    color: var(--red);
    margin-bottom: 12px;
}

.spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid var(--border2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty-state {
    text-align: center;
    padding: 28px 14px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-dim);
}

    .empty-state span {
        display: block;
        font-size: 26px;
        margin-bottom: 8px;
    }

/* ═══════════════════════════════════════════════════════════════════════════
   LOGIN PAGE — split layout
   ═══════════════════════════════════════════════════════════════════════════ */

/* Outer split */
.login-split {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
    background: var(--bg);
}

/* ── Left panel: animated map ── */
.login-panel-left {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #070f1d;           /* dark bg while map tiles load */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

    /* Map fills the panel */
    .login-panel-left #login-map {
        position: absolute;
        inset: 0;
    }

    /* Leaflet container resets for decorative use */
    .login-panel-left .leaflet-container {
        background: #070f1d;   /* dark bg while tiles load */
        cursor: default !important;
    }

    /* Canvas overlay handles the bottom fade — no ::after needed */

.login-panel-content {
    position: relative;
    z-index: 500;   /* above canvas overlay (z-index 450) */
    padding: 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.login-panel-brand .brand-wordmark {
    font-size: 15px;
    letter-spacing: 4px;
    color: #ffffff;
    text-shadow: 0 0 24px rgba(255,255,255,0.25);
}

.login-panel-brand .brand-wordmark span {
    color: var(--rrn-green);
    text-shadow: 0 0 20px rgba(16,185,129,0.4);
}

.login-panel-tagline {
    margin-top: .6rem;
    color: rgba(168, 188, 212, 0.65);
    font-size: .85rem;
    font-weight: 400;
    letter-spacing: .03em;
}

/* Stats row */
.login-panel-stats {
    display: flex;
    align-items: center;
    gap: 0;
}

.lps-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-right: 1.5rem;
}

.lps-val {
    font-family: var(--mono);
    font-size: .8rem;
    font-weight: 600;
    color: var(--rrn-green);
    letter-spacing: .08em;
}

.lps-label {
    font-family: var(--mono);
    font-size: .62rem;
    color: rgba(168, 188, 212, 0.45);
    letter-spacing: .1em;
    text-transform: uppercase;
}

.lps-divider {
    width: 1px;
    height: 28px;
    background: rgba(19, 32, 64, 0.8);
    margin-right: 1.5rem;
    flex-shrink: 0;
}

/* ── Right panel: form ── */
.login-panel-right {
    width: 420px;
    flex-shrink: 0;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
}

/* ── Form wrapper ── */
.login-form-wrap {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-form-header {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-bottom: .5rem;
}

.login-form-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .25rem;
}

.login-form-title {
    color: var(--text-bright);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.login-form-sub {
    color: var(--text-dim);
    font-size: .85rem;
}

.login-footer {
    text-align: center;
    color: var(--text-dim);
    font-size: .75rem;
    font-family: var(--mono);
    opacity: .55;
    margin-top: .5rem;
}

/* ── Shared form elements ── */
.login-field {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

    .login-field label {
        color: var(--text-dim);
        font-family: var(--mono);
        font-size: .72rem;
        text-transform: uppercase;
        letter-spacing: .06em;
    }

    .login-field input {
        background: var(--bg);
        border: 1px solid var(--border2);
        border-radius: 7px;
        color: var(--text-bright);
        padding: .65rem .85rem;
        font-size: .9rem;
        outline: none;
        transition: border-color .15s, box-shadow .15s;
        font-family: var(--sans);
        width: 100%;
    }

        .login-field input:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px rgba(28, 196, 120, 0.12);
        }

.login-btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 7px;
    padding: .75rem;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter .15s;
    margin-top: .35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    letter-spacing: .02em;
}

    .login-btn:hover:not(:disabled) {
        filter: brightness(1.08);
    }

    .login-btn:disabled {
        opacity: .55;
        cursor: not-allowed;
    }

.login-btn-sso {
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

    .login-btn-sso:hover:not(:disabled) {
        filter: none;
        background: var(--surface-3);
    }

.login-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--text-muted);
    font-size: .8rem;
    margin-top: .5rem;
}

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

.login-error {
    background: var(--red-dim);
    border: 1px solid rgba(127, 29, 29, 0.4);
    color: var(--red);
    border-radius: 7px;
    padding: .6rem .85rem;
    font-size: .85rem;
}

/* ── Responsive: stack on narrow screens ── */
@media (max-width: 720px) {
    .login-panel-left {
        display: none;
    }

    .login-panel-right {
        width: 100%;
        border-left: none;
        min-height: 100vh;
    }
}

.auth-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--text-dim);
    font-size: .9rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN SECTIONS (shared between Admin page and any admin components)
   ═══════════════════════════════════════════════════════════════════════════ */
.admin-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: visible;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.section-title {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-bright);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.section-sub {
    font-size: 12px;
    color: var(--text);
}

.save-confirm {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--green);
    align-self: center;
}

.admin-table {
    width: 100%;
}

.table-head {
    padding: 7px 22px;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    display: grid;
}

.table-row {
    padding: 11px 22px;
    border-bottom: 1px solid var(--border);
    align-items: center;
    transition: background .12s;
    display: grid;
}

    .table-row:last-child {
        border-bottom: none;
    }

    .table-row:hover {
        background: var(--surface2);
    }

.jt-cols {
    grid-template-columns: 2fr 1fr 1fr 1fr 120px;
}

.eng-cols {
    grid-template-columns: 1.5fr 1fr 1.5fr 1.5fr 2fr 120px;
}

.usr-cols {
    grid-template-columns: 1.2fr 1.8fr 0.8fr 0.8fr 0.6fr 0.8fr 120px;
}

.eng-name-cell {
    font-weight: 600;
    color: var(--text-bright);
    font-size: 13px;
}

.contact-cell {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.days-cell {
    font-size: 10px;
    color: var(--text);
}

.skills-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.skill-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid;
    font-family: var(--mono);
    font-weight: 600;
    white-space: nowrap;
}

.jt-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-bright);
    font-size: 13px;
}

.jt-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.admin-empty {
    padding: 22px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
}

    .admin-empty.warn {
        color: var(--amber);
    }

/* ── Pagination controls ─────────────────────────────────────────────────────── */
.admin-pager {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 0 4px;
    font-family: var(--mono);
}

.pager-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 11px;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.pager-btn:hover:not(:disabled) {
    background: var(--surface-3);
    color: var(--text);
}

.pager-btn.pager-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.pager-btn:disabled {
    opacity: .35;
    cursor: default;
}

.pager-info {
    font-size: 10px;
    color: var(--text-dim);
    margin-left: 6px;
}

/* ── Infinite scroll sentinel ─────────────────────────────────────────────────── */
.scroll-sentinel {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.role-badge {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid;
}

.role-admin {
    background: rgba(239,68,68,.12);
    color: #f87171;
    border-color: rgba(239,68,68,.3);
}

.role-scheduler {
    background: rgba(59,130,246,.12);
    color: #60a5fa;
    border-color: rgba(59,130,246,.3);
}

.role-engineer {
    background: rgba(16,185,129,.12);
    color: #34d399;
    border-color: rgba(16,185,129,.3);
}

.status-pill {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    border: 1px solid;
}

    .status-pill.active {
        background: rgba(16,185,129,.12);
        color: #34d399;
        border-color: rgba(16,185,129,.3);
    }

    .status-pill.inactive {
        background: rgba(107,114,128,.12);
        color: #6b7280;
        border-color: rgba(107,114,128,.3);
    }

/* ── Role badge (custom role) ─────────────────────────────────────────────────── */
.role-badge.role-custom {
    background: #6366f122;
    color: #6366f1;
    border: 1px solid #6366f144;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--mono);
}

/* ── Admin tab (inline, e.g. UsersRolesSection sub-tabs) ───────────────────────── */
.admin-section .admin-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color .15s, background .15s, border-color .15s;
}

.admin-section .admin-tab:hover {
    color: var(--text-bright);
    background: var(--surface3);
}

.admin-section .admin-tab.active {
    color: var(--accent);
    background: rgba(59,130,246,.12);
    border-color: rgba(59,130,246,.3);
}

.admin-section .admin-tab-count {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 20px;
    background: var(--surface);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.admin-section .admin-tab.active .admin-tab-count {
    background: rgba(59,130,246,.2);
    color: var(--accent);
    border-color: rgba(59,130,246,.4);
}

/* ── Name cell with inline badge (LOCKED etc.) ────────────────────────────────── */
.name-with-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
}

.name-with-badge .eng-name-cell {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.locked-badge {
    font-family: var(--mono);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .5px;
    padding: 2px 5px;
    border-radius: 3px;
    border: 1px solid #7c3aed44;
    background: #7c3aed22;
    color: #7c3aed;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Table column layouts (Users & Roles) ─────────────────────────────────────── */
.rol-cols {
    grid-template-columns: 180px 1fr 90px 100px 150px;
}

/* ── Permission grid (role editor) ─────────────────────────────────────────────── */
.perm-grid {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.perm-app-header {
    display: block;
    padding: 10px 12px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--accent);
    border-top: 1px solid var(--border);
}

.perm-app-header:first-of-type {
    border-top: none;
    padding-top: 0;
}

.perm-header,
.perm-row {
    display: grid;
    grid-template-columns: 1fr repeat(4, 64px);
    align-items: center;
    gap: 0;
}

.perm-header {
    background: var(--bg2);
    padding: 6px 12px;
    font-size: 10px;
    font-family: var(--mono);
    letter-spacing: .06em;
    color: var(--text-dim);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}

.perm-header span:not(:first-child),
.perm-check {
    text-align: center;
    justify-self: center;
}

.perm-row {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}

.perm-row:last-child {
    border-bottom: none;
}

.perm-row:hover {
    background: var(--bg2);
}

.perm-resource {
    font-size: 12px;
    color: var(--text);
}

.perm-check input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
}

.perm-check input[type="checkbox"]:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.perm-count {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

.rule-group {
    padding: 16px 20px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

    .rule-group:nth-child(3n) {
        border-right: none;
    }

    .rule-group:nth-last-child(-n+3):not(.rule-toggle-wide) {
        border-bottom: none;
    }

.rule-toggle-wide {
    grid-column: 1 / -1;
    border-right: none;
    border-bottom: none;
    padding: 18px 22px;
}

.rule-label {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
}

.rule-sub {
    font-size: 11px;
    color: var(--text);
    margin-bottom: 10px;
    line-height: 1.4;
}

.rule-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rule-input {
    width: 80px !important;
    text-align: center;
    font-family: var(--mono);
    font-weight: 600;
}

.rule-unit {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
}

.rule-toggles {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rule-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    user-select: none;
}

    .rule-toggle:hover {
        background: var(--surface2);
    }

    .rule-toggle.on {
        border-color: var(--accent);
        background: var(--accent-dim);
    }

    .rule-toggle.rule-toggle-disabled {
        opacity: .6;
        cursor: not-allowed;
    }

        .rule-toggle.rule-toggle-disabled:hover {
            background: var(--bg);
        }

.rule-toggle-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border2);
    flex-shrink: 0;
    transition: background .15s;
}

.rule-toggle.on .rule-toggle-dot {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

.rule-toggle-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-bright);
}

.rule-toggle-desc {
    font-size: 11px;
    color: var(--text);
    margin-top: 2px;
}

.colour-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.colour-picker {
    width: 40px;
    height: 38px;
    padding: 2px;
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: 6px;
    cursor: pointer;
}

.colour-preview {
    padding: 6px 12px;
    border-radius: 5px;
    border: 1px solid;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 16px;
}

.day-toggles {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.day-toggle {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid var(--border2);
    background: var(--bg);
    color: var(--text-dim);
    cursor: pointer;
    transition: all .12s;
}

    .day-toggle.active {
        background: var(--accent-dim);
        color: var(--accent);
        border-color: var(--accent);
    }

.skill-toggles {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.skill-toggle {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid var(--border2);
    background: var(--bg);
    color: var(--text-dim);
    cursor: pointer;
    transition: all .12s;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LEAFLET DARK OVERRIDES
   ═══════════════════════════════════════════════════════════════════════════ */
.leaflet-container {
    background: #070f1d !important;
}

.leaflet-control-zoom a {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--border2) !important;
}

    .leaflet-control-zoom a:hover {
        background: var(--surface2) !important;
    }

.leaflet-control-attribution {
    background: rgba(7,15,29,.9) !important;
    color: var(--text-dim) !important;
    font-size: 9px !important;
}

.leaflet-popup-content-wrapper {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border2) !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,.6) !important;
    font-family: var(--sans) !important;
    font-size: 12px !important;
}

.leaflet-popup-tip {
    background: var(--surface) !important;
}

.leaflet-popup-close-button {
    color: var(--text-dim) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GLOBAL SEARCH (in topbar)
   ═══════════════════════════════════════════════════════════════════════════ */
.topbar-search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 8px;
}

.search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-dim);
    font-size: 16px;
    pointer-events: none;
    z-index: 1;
}

.topbar-search-input {
    font-family: var(--sans);
    font-size: 13px;
    background: var(--bg);
    border: 1px solid var(--border2);
    color: var(--text-bright);
    border-radius: 6px;
    padding: 5px 28px 5px 30px;
    width: 220px;
    outline: none;
    transition: border-color .15s, width .2s, box-shadow .15s;
}

    .topbar-search-input::placeholder {
        color: var(--text-dim);
    }

    .topbar-search-input:focus {
        border-color: var(--accent);
        width: 300px;
        box-shadow: 0 0 0 3px rgba(28,196,120,.1);
    }

.search-clear-btn {
    position: absolute;
    right: 6px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 4px;
}

    .search-clear-btn:hover {
        color: var(--text-bright);
    }

.global-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 540px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 8px;
    z-index: 500;
    box-shadow: 0 12px 40px rgba(0,0,0,.6);
    max-height: 420px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.gsr-header {
    padding: 7px 14px;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.gsr-loading {
    padding: 16px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-dim);
}

.gsr-empty {
    padding: 16px 14px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-dim);
}

.gsr-row {
    display: grid;
    grid-template-columns: 130px 1fr 160px;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .12s;
}

    .gsr-row:last-child {
        border-bottom: none;
    }

    .gsr-row:hover {
        background: var(--surface2);
    }

.gsr-row.active {
    background: var(--surface2);
}

.gsr-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gsr-ref {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
}

.gsr-reg {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: 3px;
    padding: 1px 4px;
    display: inline-block;
    text-transform: uppercase;
}

.gsr-mid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.gsr-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gsr-type {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
}

.gsr-right {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: right;
}

.gsr-status {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
}

    .gsr-status.scheduled {
        color: var(--green);
    }

    .gsr-status.unscheduled {
        color: var(--text-dim);
    }

.gsr-date {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════════════════════════
   ACCOUNT / CHANGE PASSWORD PAGE
   ═══════════════════════════════════════════════════════════════════════════ */
.account-page {
    min-height: calc(100vh - 88px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 24px;
}

.account-card {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 10px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
}

    .account-card h2 {
        font-family: var(--mono);
        font-size: 14px;
        font-weight: 700;
        letter-spacing: 1.5px;
        text-transform: uppercase;
        color: var(--text-bright);
        margin: 0 0 6px;
    }

.account-user {
    font-size: 13px;
    color: var(--text-dim);
    margin: 0 0 24px;
}

    .account-user strong {
        color: var(--accent);
    }

.account-actions {
    margin-top: 20px;
    display: flex;
    gap: 8px;
}

.alert-success {
    background: rgba(28,196,120,.12);
    border: 1px solid rgba(28,196,120,.3);
    color: var(--green);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--red-dim);
    border: 1px solid rgba(239,68,68,.3);
    color: var(--red);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ── Engineer proximity selector ─────────────────────────────────────────────── */
.eng-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-dim);
    padding: 8px 0 4px;
}

.eng-selector {
    margin-bottom: 10px;
}

.eng-selector-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.eng-selector-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.eng-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    transition: all .15s;
}

    .eng-chip:hover {
        border-color: var(--accent);
        color: var(--text-bright);
    }

.eng-chip-on {
    background: rgba(28,196,120,.15);
    border-color: var(--green);
    color: var(--green) !important;
}

.eng-chip-name {
    font-weight: 500;
}

.eng-chip-dist {
    font-family: var(--mono);
    font-size: 10px;
    opacity: 0.7;
}

.eng-chip-dim {
    opacity: 0.35;
    cursor: not-allowed;
}

.eng-chip-lock {
    font-size: 10px;
    opacity: 0.8;
}

.eng-chip-more {
    border-style: dashed;
    color: var(--text-dim);
    font-style: italic;
}

    .eng-chip-more:hover {
        border-color: var(--accent);
        color: var(--text-bright);
    }

.eng-warn {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOLIDAYS / AVAILABILITY TAB
   ═══════════════════════════════════════════════════════════════════════════ */

/* Conflict banner */
.conflict-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px;
    background: #7c2d1222;
    border-bottom: 1px solid #7c2d1244;
    cursor: pointer;
    font-size: 12px;
    color: #f97316;
    font-family: var(--mono);
}
.conflict-icon { font-size: 14px; }
.conflict-expand { margin-left: auto; font-size: 10px; opacity: .7; }

.conflict-list {
    border-bottom: 1px solid var(--border);
    padding: 8px 22px 12px;
}
.conflict-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-dim, #2a2a2a);
    gap: 16px;
}
.conflict-row:last-child { border-bottom: none; }
.conflict-row-info { display: flex; gap: 16px; align-items: center; font-size: 12px; flex-wrap: wrap; }
.conflict-date { font-family: var(--mono); color: var(--text-dim); min-width: 90px; }
.conflict-eng  { color: var(--text-bright); font-weight: 500; }
.conflict-job  { color: var(--text); }
.conflict-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Tab count badge in warning state */
.warn-count {
    background: #f97316 !important;
    color: #fff !important;
}

/* Controls row */
.avail-controls {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.avail-eng-picker { width: 280px; }
.avail-eng-search-wrap { position: relative; }
.avail-eng-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 240px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-top: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.avail-eng-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    transition: background .1s;
}
.avail-eng-option:hover { background: var(--hover); }
.avail-eng-option.selected { background: var(--accent); color: #fff; }
.avail-eng-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.avail-month-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}
.avail-month-label {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-bright);
    min-width: 120px;
    text-align: center;
}

/* Calendar */
.avail-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    margin: 16px 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.avail-cal-header {
    display: contents;
}
.avail-cal-header span,
.avail-calendar > .avail-cal-header span {
    display: block;
    background: var(--bg);
    padding: 6px 8px;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.avail-cal-day {
    background: var(--surface);
    padding: 6px 8px;
    min-height: 64px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: background .1s;
}
.avail-cal-day:hover { background: var(--hover, #1a1a1a); }
.avail-cal-day.other-month { background: var(--bg); cursor: default; }
.avail-cal-day.other-month * { opacity: .3; pointer-events: none; }
.avail-cal-day.weekend { background: #10100e; }
.avail-cal-day.bank-hol { background: #1a0d2e; cursor: default; }

.avail-cal-num {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
}
.avail-cal-num.today {
    background: var(--accent, #3b82f6);
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}
.avail-cal-bk {
    font-size: 9px;
    font-family: var(--mono);
    color: #a78bfa;
    background: #4c1d9511;
    border-left: 2px solid #7c3aed;
    padding: 1px 4px;
    border-radius: 2px;
    line-height: 1.4;
    word-break: break-word;
}
.avail-cal-block {
    font-size: 9px;
    font-family: var(--mono);
    padding: 1px 4px;
    border-radius: 2px;
    line-height: 1.4;
}

/* Legend */
.avail-legend {
    display: flex;
    gap: 16px;
    padding: 0 22px 16px;
    flex-wrap: wrap;
}
.avail-leg-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-dim);
}
.avail-leg-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Availability list */
.avail-list-head {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 8px 22px 4px;
}
.avail-cols {
    grid-template-columns: 110px 90px 160px 1fr 100px 80px;
}
.avail-type-badge {
    font-family: var(--mono);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Blazor error UI */
#blazor-error-ui {
    background: var(--red-dim);
    border-top: 1px solid #7f1d1d;
    color: var(--red);
    bottom: 0;
    left: 0;
    padding: 12px 16px;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 13px;
    font-family: var(--mono);
    display: none;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 16px;
        top: 12px;
    }

/* ── Drag-to-reschedule global cursor ── */
body.gantt-dragging,
body.gantt-dragging * {
    cursor: grabbing !important;
    user-select: none !important;
}
