body {
    min-height: 100vh;
}

/* Support Ticket Timeline Styling */
.timeline-container {
    position: relative;
}

.timeline-rail {
    position: absolute;
    left: 28px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--bs-border-color);
}

.timeline-entry {
    position: relative;
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.timeline-marker {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    position: relative;
    z-index: 1;
    margin: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.timeline-marker--comment {
    background: linear-gradient(135deg, #0d6efd, #0a58ca);
}

.timeline-marker--system {
    background: linear-gradient(135deg, #6c757d, #5a6268);
}

.timeline-marker--internal {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #000;
}

.timeline-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

.timeline-author-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.timeline-author-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.timeline-timestamp {
    font-size: 0.8125rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
}

@media (max-width: 768px) {
    .timeline-entry {
        grid-template-columns: 48px 1fr;
        gap: 0.75rem;
    }
    
    .timeline-rail {
        left: 24px;
    }
    
    .timeline-marker {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
        margin: 6px;
    }
}

/* Active Navigation Link Styling */
.navbar-nav .nav-link.active {
    color: var(--bs-primary) !important;
    font-weight: 500;
}

.navbar-nav .nav-link.active:hover {
    color: var(--bs-primary) !important;
    opacity: 0.85;
}

.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3);
}

/* Autocomplete Dropdown Theme-Aware Styling */
.autocomplete-dropdown {
    background-color: var(--scope-bg-primary);
    border-color: var(--scope-border-primary) !important;
}

.autocomplete-item {
    color: var(--scope-text-primary);
    transition: background-color 0.15s ease;
}

.autocomplete-item:hover {
    background-color: var(--scope-hover-bg);
}

/* Scope Label Input Styling */
.scope-label-input {
    background-color: var(--scope-bg-primary) !important;
    border-color: var(--scope-border-primary) !important;
    color: var(--scope-text-primary) !important;
    transition: all 0.15s ease;
}

.scope-label-input:focus {
    background-color: var(--scope-bg-primary) !important;
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.15) !important;
    outline: none;
}

.scope-label-input::placeholder {
    color: var(--scope-text-muted);
    opacity: 0.6;
}

/* Multi-Scope Accordion Theme-Aware Styling */
#scopesAccordion .accordion-item {
    background-color: var(--scope-bg-primary) !important;
    border-color: var(--scope-border-primary) !important;
}

#scopesAccordion .accordion-header {
    padding: 0 !important;
}

#scopesAccordion .accordion-button {
    background-color: var(--scope-bg-header) !important;
    color: var(--scope-text-primary) !important;
    border-radius: 0 !important;
    border-color: var(--scope-border-primary) !important;
}

#scopesAccordion .accordion-button:not(.collapsed) {
    background-color: var(--scope-bg-header) !important;
    color: var(--scope-text-primary) !important;
    box-shadow: none !important;
}

#scopesAccordion .accordion-button:focus {
    border-color: var(--scope-border-primary) !important;
    box-shadow: none !important;
}

/* Dark mode: invert the chevron icon */
[data-bs-theme="dark"] #scopesAccordion .accordion-button::after {
    filter: invert(1) grayscale(100%) brightness(200%) !important;
}

/* Light mode: keep the chevron normal */
[data-bs-theme="light"] #scopesAccordion .accordion-button::after {
    filter: none !important;
}

#scopesAccordion .accordion-body {
    background-color: var(--scope-bg-primary) !important;
    border-color: var(--scope-border-primary) !important;
}

#chatMessages {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
    padding: 1rem;
}

.chat-message {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
}

.chat-message.user {
    background-color: rgba(13, 110, 253, 0.3);
    margin-left: 2rem;
}

.chat-message.assistant {
    background-color: rgba(108, 117, 125, 0.3);
    margin-right: 2rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.25rem;
}

/* Work Order Cards in Chat */
.work-order-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.875rem;
    margin-top: 1rem;
}

.work-order-card {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 1rem;
    transition: all 0.2s;
}

.work-order-card:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(13, 110, 253, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.work-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.work-order-number {
    font-family: monospace;
    font-weight: bold;
    color: #0d6efd;
}

.work-order-title {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

.work-order-details {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
}

.work-order-details > div {
    margin-bottom: 0.25rem;
}

.work-order-details i {
    margin-right: 0.5rem;
    color: rgba(255, 255, 255, 0.5);
}

/* ===== DESIGN SYSTEM: SCOPE/TRIAGE PANELS ===== */

/* Design Tokens */
/* Scope Panel Variables - Dark Mode */
[data-bs-theme="dark"] {
    --scope-bg-primary: #1a1d20;
    --scope-bg-header: #24272b;
    --scope-border-primary: #3a3d42;
    --scope-border-subtle: rgba(255, 255, 255, 0.08);
    --scope-text-primary: rgba(255, 255, 255, 0.92);
    --scope-text-secondary: rgba(255, 255, 255, 0.65);
    --scope-text-muted: rgba(255, 255, 255, 0.4);
    --scope-hover-bg: rgba(255, 255, 255, 0.05);
}

/* Scope Panel Variables - Light Mode */
[data-bs-theme="light"] {
    --scope-bg-primary: #ffffff;
    --scope-bg-header: #f8f9fa;
    --scope-border-primary: #dee2e6;
    --scope-border-subtle: rgba(0, 0, 0, 0.08);
    --scope-text-primary: rgba(0, 0, 0, 0.92);
    --scope-text-secondary: rgba(0, 0, 0, 0.65);
    --scope-text-muted: rgba(0, 0, 0, 0.4);
    --scope-hover-bg: rgba(0, 0, 0, 0.03);
}

/* Scope Panel Variables - Spacing (theme-independent) */
:root {
    --scope-spacing-sm: 0.5rem;
    --scope-spacing-md: 0.75rem;
    --scope-spacing-lg: 1rem;
    --scope-radius: 6px;
}

/* Panel Container */
.scope-panel {
    border: 1px solid var(--scope-border-primary);
    border-radius: var(--scope-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--scope-bg-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Panel Label (Above Panel) */
.scope-panel-label {
    font-size: 0.813rem;
    color: var(--scope-text-primary);
    margin-bottom: var(--scope-spacing-sm);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Panel Header */
.scope-panel-header {
    background-color: var(--scope-bg-header);
    padding: 0.625rem var(--scope-spacing-md);
    border-bottom: 1px solid var(--scope-border-subtle);
    text-transform: uppercase;
    font-size: 0.688rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--scope-text-secondary);
    display: grid;
    grid-template-columns: 1fr 60px 40px;
    gap: var(--scope-spacing-sm);
    align-items: center;
}

/* Panel Toolbar (Search + Add Controls) */
.scope-panel-toolbar {
    padding: var(--scope-spacing-md);
    background-color: var(--scope-bg-primary);
    border-bottom: 1px solid var(--scope-border-subtle);
    display: grid;
    grid-template-columns: 1fr 60px 40px;
    gap: var(--scope-spacing-sm);
    align-items: center;
}

/* Panel Body (Scrollable List Area) */
.scope-panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--scope-bg-primary);
    min-height: 100px;
    max-height: 150px;
}

/* Scrollbar Styling */
.scope-panel-body::-webkit-scrollbar {
    width: 8px;
}

.scope-panel-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.scope-panel-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.scope-panel-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* List Container */
.scope-list {
    display: flex;
    flex-direction: column;
}

/* List Row (Parts/Equipment) */
.scope-list-row {
    display: grid;
    grid-template-columns: 1fr 60px 40px;
    align-items: center;
    padding: 0.625rem var(--scope-spacing-md);
    gap: var(--scope-spacing-sm);
    border-bottom: 1px solid var(--scope-border-subtle);
    transition: background-color 0.15s ease;
}

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

.scope-list-row:hover {
    background-color: var(--scope-hover-bg);
}

.scope-list-item-name {
    font-size: 0.813rem;
    color: var(--scope-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

.scope-list-item-qty {
    text-align: right;
    font-size: 0.813rem;
    color: var(--scope-text-primary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.scope-list-item-action {
    display: flex;
    justify-content: center;
    align-items: center;
}

.scope-list-item-action .btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1;
    border: 1px solid rgba(220, 53, 69, 0.3);
    background-color: transparent;
    color: rgba(220, 53, 69, 0.8);
    transition: all 0.15s ease;
}

.scope-list-item-action .btn:hover {
    background-color: rgba(220, 53, 69, 0.12);
    border-color: rgba(220, 53, 69, 0.6);
    color: rgba(220, 53, 69, 1);
}

/* Empty State */
.scope-list-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--scope-text-muted);
    font-size: 0.813rem;
    font-style: italic;
}

/* Task Panel Bodies - No scrollbars, natural expansion */
.scope-panel-body--tasks {
    max-height: none;
    overflow-y: visible;
    min-height: auto;
}

/* Task List Containers */
[id$="_tasks_checkin_list"],
[id$="_tasks_install_list"],
[id$="_tasks_checkout_list"] {
    padding: var(--scope-spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--scope-spacing-sm);
}

/* Task item background (theme-aware) */
/* Hierarchy Table Headers - Theme Aware */
.hierarchy-table-header {
    background-color: var(--scope-bg-header) !important;
    color: var(--scope-text-primary) !important;
    font-weight: 600 !important;
    border-color: var(--scope-border-primary) !important;
}

/* Tenant Mode Banner - Theme Aware */
.tenant-mode-banner {
    padding: 0.75rem 0;
    font-size: 0.9rem;
    border-bottom: 2px solid;
    position: sticky;
    top: 0;
    z-index: 1040;
}

[data-bs-theme="dark"] .tenant-mode-banner {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    border-bottom-color: #4299e1;
    color: rgba(255, 255, 255, 0.95);
}

[data-bs-theme="light"] .tenant-mode-banner {
    background: linear-gradient(135deg, #ebf8ff 0%, #bee3f8 100%);
    border-bottom-color: #3182ce;
    color: rgba(0, 0, 0, 0.87);
}

.tenant-mode-banner .btn-outline-light {
    font-size: 0.85rem;
    padding: 0.375rem 0.75rem;
}

[data-bs-theme="light"] .tenant-mode-banner .btn-outline-light {
    color: #2d3748;
    border-color: #2d3748;
}

[data-bs-theme="light"] .tenant-mode-banner .btn-outline-light:hover {
    background-color: #2d3748;
    color: white;
}

/* Impersonation Banner - Always Dark Red (exempt from light mode) */
.impersonation-banner {
    padding: 0.75rem 0;
    font-size: 0.9rem;
    border-bottom: 2px solid #fc8181;
    position: sticky;
    top: 0;
    z-index: 1040;
    background: linear-gradient(135deg, #742a2a 0%, #9b2c2c 100%);
    color: rgba(255, 255, 255, 0.95);
}

.impersonation-banner .btn-outline-light {
    font-size: 0.85rem;
    padding: 0.375rem 0.75rem;
}

.impersonation-banner .btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

[data-bs-theme="dark"] .scope-task-item-bg {
    background-color: rgba(0, 0, 0, 0.15);
}

[data-bs-theme="light"] .scope-task-item-bg {
    background-color: rgba(0, 0, 0, 0.03);
}

[id$="_tasks_checkin_list"] > div,
[id$="_tasks_install_list"] > div,
[id$="_tasks_checkout_list"] > div {
    padding: var(--scope-spacing-md);
    border: 1px solid var(--scope-border-subtle);
    border-radius: 6px;
    transition: all 0.15s ease;
}

[data-bs-theme="dark"] [id$="_tasks_checkin_list"] > div,
[data-bs-theme="dark"] [id$="_tasks_install_list"] > div,
[data-bs-theme="dark"] [id$="_tasks_checkout_list"] > div {
    background-color: rgba(0, 0, 0, 0.15);
}

[data-bs-theme="light"] [id$="_tasks_checkin_list"] > div,
[data-bs-theme="light"] [id$="_tasks_install_list"] > div,
[data-bs-theme="light"] [id$="_tasks_checkout_list"] > div {
    background-color: rgba(0, 0, 0, 0.03);
}

[id$="_tasks_checkin_list"] > div:hover,
[id$="_tasks_install_list"] > div:hover,
[id$="_tasks_checkout_list"] > div:hover {
    background-color: var(--scope-hover-bg);
    border-color: var(--scope-border-primary);
}

/* Task empty states */
[id$="_tasks_checkin_list"] .text-muted,
[id$="_tasks_install_list"] .text-muted,
[id$="_tasks_checkout_list"] .text-muted {
    padding: 2rem 0.5rem;
    text-align: center;
    color: var(--scope-text-muted);
    font-size: 0.813rem;
    font-style: italic;
}

/* Improve form controls in panels */
.scope-panel-toolbar input[type="text"],
.scope-panel-toolbar input[type="number"] {
    height: 36px;
    font-size: 0.875rem;
    border-radius: 4px;
}

.scope-panel-toolbar input[type="number"] {
    text-align: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.scope-panel-toolbar .btn {
    height: 36px;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.scope-panel-toolbar .btn-success {
    background-color: rgba(25, 135, 84, 0.15);
    border-color: rgba(25, 135, 84, 0.5);
    color: rgb(75, 181, 67);
}

.scope-panel-toolbar .btn-success:hover {
    background-color: rgba(25, 135, 84, 0.25);
    border-color: rgba(25, 135, 84, 0.7);
    color: rgb(94, 201, 85);
    transform: scale(1.05);
}

.scope-panel-toolbar .btn-success:active {
    transform: scale(0.98);
}

/* Focus states for accessibility */
.scope-panel-toolbar input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    outline: none;
}

/* ===== SCOPE/TRIAGE SECTION IMPROVEMENTS ===== */

/* Scope Triage Card Header Buttons */
#scopeTriageCard .card-header .btn-primary,
#scopeTriageCard .card-header .btn-success {
    height: 32px;
    padding: 0 0.875rem;
    font-size: 0.813rem;
    font-weight: 500;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    border-radius: 5px;
    transition: all 0.15s ease;
}

#scopeTriageCard .card-header .btn-primary {
    background-color: rgba(13, 110, 253, 0.15);
    border-color: rgba(13, 110, 253, 0.5);
    color: rgb(102, 168, 255);
}

#scopeTriageCard .card-header .btn-primary:hover {
    background-color: rgba(13, 110, 253, 0.25);
    border-color: rgba(13, 110, 253, 0.7);
    color: rgb(132, 187, 255);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.2);
}

#scopeTriageCard .card-header .btn-success {
    background-color: rgba(25, 135, 84, 0.15);
    border-color: rgba(25, 135, 84, 0.5);
    color: rgb(75, 181, 67);
}

#scopeTriageCard .card-header .btn-success:hover {
    background-color: rgba(25, 135, 84, 0.25);
    border-color: rgba(25, 135, 84, 0.7);
    color: rgb(94, 201, 85);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(25, 135, 84, 0.2);
}

/* Trip Type Select */
#scope_trip_type {
    height: 38px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 5px;
    border-color: var(--scope-border-primary);
    transition: all 0.15s ease;
}

#scope_trip_type:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    outline: none;
}

/* Additional Information Textarea */
#scope_additional_info {
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: var(--scope-radius);
    border-color: var(--scope-border-primary);
    padding: var(--scope-spacing-md);
    transition: all 0.15s ease;
}

#scope_additional_info:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    outline: none;
}

#scope_additional_info::placeholder {
    color: var(--scope-text-muted);
    font-style: italic;
}

/* Task Description Styling */
[id$="_tasks_checkin_list"] .text-light,
[id$="_tasks_install_list"] .text-light,
[id$="_tasks_checkout_list"] .text-light {
    font-size: 0.875rem;
    color: var(--scope-text-primary);
    line-height: 1.5;
}

[id$="_tasks_checkin_list"] textarea,
[id$="_tasks_install_list"] textarea,
[id$="_tasks_checkout_list"] textarea {
    margin-top: 0.625rem;
    font-size: 0.813rem;
    line-height: 1.4;
    border-radius: 4px;
    border-color: var(--scope-border-subtle);
    transition: all 0.15s ease;
}

[id$="_tasks_checkin_list"] textarea:focus,
[id$="_tasks_install_list"] textarea:focus,
[id$="_tasks_checkout_list"] textarea:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.15);
    outline: none;
}

[id$="_tasks_checkin_list"] .btn-outline-danger,
[id$="_tasks_install_list"] .btn-outline-danger,
[id$="_tasks_checkout_list"] .btn-outline-danger {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1;
    border-color: rgba(220, 53, 69, 0.3);
    color: rgba(220, 53, 69, 0.8);
    transition: all 0.15s ease;
}

[id$="_tasks_checkin_list"] .btn-outline-danger:hover,
[id$="_tasks_install_list"] .btn-outline-danger:hover,
[id$="_tasks_checkout_list"] .btn-outline-danger:hover {
    background-color: rgba(220, 53, 69, 0.12);
    border-color: rgba(220, 53, 69, 0.6);
    color: rgba(220, 53, 69, 1);
}

/* Badge Improvements in Headers */
.scope-panel-header .badge {
    font-size: 0.688rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
}

/* Responsive Breakpoints */
@media (max-width: 991px) {
    /* Stack columns on tablet */
    .scope-panel-toolbar {
        grid-template-columns: 1fr 56px 36px;
        padding: 0.625rem;
    }
    
    .scope-panel-header {
        grid-template-columns: 1fr 56px 36px;
        font-size: 0.688rem;
    }
    
    .scope-list-row {
        grid-template-columns: 1fr 56px 36px;
        padding: 0.5rem 0.625rem;
    }
}

@media (max-width: 767px) {
    /* Further adjustments for mobile */
    #scopeTriageCard .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    #scopeTriageCard .card-header .d-flex {
        width: 100%;
        justify-content: space-between;
    }
    
    .scope-panel-label {
        font-size: 0.75rem;
    }
    
    .scope-panel-toolbar {
        grid-template-columns: 1fr 48px 32px;
        gap: 0.375rem;
        padding: 0.5rem;
    }
    
    .scope-panel-toolbar .btn {
        height: 32px;
        width: 32px;
    }
    
    .scope-panel-toolbar input[type="text"],
    .scope-panel-toolbar input[type="number"] {
        height: 32px;
        font-size: 0.813rem;
    }
}

/* Autocomplete Dropdown Improvements */
.autocomplete-dropdown {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.autocomplete-dropdown .autocomplete-item {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--scope-border-subtle);
    font-size: 0.875rem;
    transition: background-color 0.1s ease;
}

.autocomplete-dropdown .autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-dropdown .autocomplete-item:hover {
    background-color: var(--scope-hover-bg) !important;
}

/* Loading States */
.scope-list-empty.loading::after {
    content: '...';
    animation: ellipsis 1.5s infinite;
}

@keyframes ellipsis {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Labor Bids Scope Card Header - Theme-Aware Styling */
.labor-bids-scope-header {
    background-color: var(--scope-bg-header);
    color: var(--scope-text-primary);
}

/* Hide default Bootstrap accordion chevron for scope buttons */
.scope-accordion-btn::after {
    display: none !important;
}

