/* Revvence PSA Platform - Custom Styles */

/* KPI tile disabled state for RBAC security - enhanced UX */
.kpi-tile.no-drill.is-disabled { 
    opacity: 0.6; 
    filter: grayscale(20%); 
    cursor: not-allowed; 
    position: relative; 
    transition: opacity 0.15s ease, filter 0.15s ease; 
}

/* Subtle "Restricted" badge for disabled tiles */
.kpi-tile.no-drill.is-disabled::after { 
    content: "🔒 Restricted"; 
    position: absolute; 
    top: 0.5rem; 
    right: 0.5rem; 
    font-size: 0.75rem; 
    color: #6c757d; 
    background: rgba(248,249,250,0.92); 
    border: 1px solid rgba(0,0,0,0.06); 
    padding: 0.15rem 0.4rem; 
    border-radius: 0.25rem; 
    z-index: 1; 
}
.kpi-tile.no-drill.is-disabled .kpi-tile-overlay { 
    position: absolute; 
    inset: 0; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 0.85rem; 
    padding: 0 0.5rem; 
    text-align: center; 
}

/* Use natural table sizing; let content drive widths */
#forecastTable { table-layout: auto; width: 100%; }

/* Forecast wrapper needs overflow: auto for sticky to work */
/* Do NOT use overflow: visible - it breaks sticky positioning */

/* These are set by JS below */
:root { --nav-h: 56px; --filters-h: 56px; }

/* Divider row */
#forecastTable tr.proj-label td{
  font-size:.85rem; color:var(--bs-secondary-color,#6c757d);
  padding-top:.35rem; padding-bottom:.2rem; background:transparent; border-top:none;
}

/* Project data rows */
#forecastTable tr.proj-row td{
  font-size:.90rem; color:var(--bs-secondary-color,#6c757d);
  background-color:#fafafa; padding-top:.35rem; padding-bottom:.35rem;
}
#forecastTable tr.proj-row td:first-child{ padding-left:1rem; }

/* Parent project rows in By Period view - bold black for top-level hierarchy */
/* bp-parent-row is added by renderByPeriodTable() for top-level rows */
/* bp-project-row is added for project rows when Client scope is used */
#byPeriodTable tr.bp-parent-row td,
#byPeriodTable tr.bp-project-row td {
  font-weight: 700 !important;
  color: #212529 !important;
}

/* Invoice/Assignment subtotal rows - bold darker grey for secondary emphasis */
/* Must use #byPeriodTable specificity to beat #byPeriodTable tr.proj-row td rule */
#byPeriodTable tr.summary-subtotal td,
#forecastTable tr.summary-subtotal td,
#plTable tr.summary-subtotal td {
  font-weight: 700 !important;
  color: #495057 !important;
}

/* P&L view - parent metric rows (Revenue, Cost, Margin) - bold black for top-level hierarchy */
#plTable tr.pl-parent-row td {
  font-weight: 700 !important;
  color: #212529 !important;
}

/* P&L view - child project rows - bold grey for secondary emphasis */
#plTable tr.pl-project-row td {
  font-weight: 600 !important;
  color: #495057 !important;
}

/* First column: left + wrap; numbers tight; details centered */
#forecastTable th:first-child, #forecastTable td:first-child{
  text-align:left !important; white-space:normal !important;
  word-break:break-word; overflow-wrap:anywhere;
}
#forecastTable td.text-end{ white-space:nowrap; }
#forecastTable th:last-child, #forecastTable td:last-child{
  width:88px; min-width:88px; white-space:nowrap; text-align:center;
}

/* CRITICAL: Filter CARD (parent) must be in a HIGHER stacking context than table cards.
   This allows dropdowns (z-index 1200+) to appear above table headers (z-index 1015-1021).
   Sibling elements compare stacking contexts at the parent level first. */
#forecastFiltersCard {
  position: relative !important;
  z-index: 10 !important;  /* Higher than table cards (z-index: 1) */
  /* Disable backdrop-filter to prevent stacking context trap */
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Filter bar inside the card needs overflow visible for dropdowns */
#forecastFilters {
  overflow: visible !important;
}

/* Table cards must be in LOWER stacking context than filter card */
#summarySection,
#byPeriodSection,
#plSection,
#financialsSection,
#utilizationContentSection,
#assignmentContentSection,
#dvbContentSection {
  position: relative !important;
  z-index: 1 !important;  /* Lower than filter card (z-index: 10) */
}

/* Report filter cards - higher stacking context than content */
#utilizationFiltersCard,
#assignmentFiltersCard,
#dvbFiltersCard {
  position: relative !important;
  z-index: 10 !important;  /* Higher than content cards (z-index: 1) */
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* ========== UNIFIED TREE TABLE STYLES FOR ALL THREE FORECAST TABLES ========== */

/* Compact baseline for all four forecast tables */
#forecastTable.table-compact,
#byPeriodTable.table-compact,
#plTable.table-compact,
#financialsTable.table-compact {
  font-size: .875rem;              /* ≈14px */
}

#forecastTable.table-compact th,
#forecastTable.table-compact td,
#byPeriodTable.table-compact th,
#byPeriodTable.table-compact td,
#plTable.table-compact th,
#plTable.table-compact td,
#financialsTable.table-compact th,
#financialsTable.table-compact td {
  padding: .35rem .5rem;           /* tighter cells */
  line-height: 1.25;
}

/* Allow headers to wrap to two lines */
#forecastTable.table-compact thead th,
#byPeriodTable.table-compact thead th,
#plTable.table-compact thead th,
#financialsTable.table-compact thead th {
  white-space: normal;
}

/* Right-align numeric cells; prevent wrapping for amounts */
#forecastTable.table-compact td.text-end,
#byPeriodTable.table-compact td.text-end,
#plTable.table-compact td.text-end,
#financialsTable.table-compact td.text-end {
  white-space: nowrap;
  text-align: right !important;
}

/* Sticky first column for all four tables */
#forecastTable.table-compact .sticky-start,
#byPeriodTable.table-compact .sticky-start,
#plTable.table-compact .sticky-start,
#financialsTable.table-compact .sticky-start {
  position: sticky;
  left: 0;
  z-index: 1016;
  background: #fff;
}

/* Fixed-width Details column */
#forecastTable.table-compact th.details-col,
#forecastTable.table-compact td.details-col,
#byPeriodTable.table-compact th.details-col,
#byPeriodTable.table-compact td.details-col {
  width: 50px;
  min-width: 50px;
  text-align: center;
  padding: .25rem;
}

/* Tree table child row styling */
#forecastTable.table-compact .level-1,
#byPeriodTable.table-compact .level-1 {
  background-color: #f8f9fa;
  border-left: 3px solid #dee2e6;
}

#forecastTable.table-compact .level-1 td:first-child,
#byPeriodTable.table-compact .level-1 td:first-child {
  padding-left: 1.5rem;
}

/* Subtle row hover for non-totals rows */
#forecastTable.table-compact tbody tr:not(.totals-row):hover,
#byPeriodTable.table-compact tbody tr:not(.totals-row):hover {
  background-color: rgba(0, 123, 255, 0.05);
}

/* Tree toggle button styling */
.tree-toggle {
  border: none;
  background: none;
  padding: 0.25rem;
  border-radius: 3px;
  color: #6c757d;
  cursor: pointer;
  transition: color 0.15s ease-in-out;
}

.tree-toggle:hover {
  color: #495057;
  background-color: #e9ecef;
}

.tree-toggle:focus {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

.tree-toggle .fas {
  font-size: 0.75rem;
}

/* Numbers tight + no wrapping */
#forecastTable.table-compact td.text-end {
  white-space: nowrap;
}

/* Details column: icon-only to save width */
#forecastTable.table-compact th.col-details,
#forecastTable.table-compact td.col-details {
  width: 44px; min-width: 44px; text-align: center;
}
#forecastTable .btn-details {
  padding: .25rem .4rem; font-size: .8rem;
}

/* Keep first column wrapping left */
#forecastTable.table-compact th:first-child,
#forecastTable.table-compact td:first-child {
  white-space: normal !important;
}

/* Project detail rows stay visually secondary */
#forecastTable tr.proj-row td {
  font-size: .85rem;
  color: var(--bs-secondary-color,#6c757d);
  background-color: #fafafa;
}
#forecastTable tr.proj-row td:first-child { padding-left: 1rem; }
#forecastTable tr.proj-row td { font-size: 0.875rem; } /* Make child rows slightly smaller */

/* Utilisation bands – force precedence inside the forecast table */
#forecastTable td .util-95 { color: var(--psa-util-excellent, #2e7d32) !important; font-weight: 600; }
#forecastTable td .util-75 { color: var(--psa-util-good,      #ffb300) !important; font-weight: 600; } /* amber */
#forecastTable td .util-50 { color: var(--psa-util-warning,   #fb8c00) !important; }                   /* orange */
#forecastTable td .util-0  { color: var(--psa-util-danger,    #d32f2f) !important; }                   /* red */

/* If the td applies a financial color, neutralize it for our span */
#forecastTable td.text-end.financial-cell > .util-95,
#forecastTable td.text-end.financial-cell > .util-75,
#forecastTable td.text-end.financial-cell > .util-50,
#forecastTable td.text-end.financial-cell > .util-0 {
  color: inherit; /* span's own !important color will still win */
}

/* Over-capacity uses Bootstrap warning color; ensure it wins too */
#forecastTable td .text-warning { color: #ff9800 !important; font-weight: 600; }

/* Neutral finance text */
.financial-neutral { color: #6c757d; }

/* Forecast Report – force distinct utilisation band colours */
#forecastTable td .util-95 { color: #2e7d32 !important; font-weight: 600; } /* green (76–95)  */
#forecastTable td .util-75 { color: #8d4925 !important; font-weight: 600; } /* brown (51–75)  */
#forecastTable td .util-50 { color: #fb8c00 !important; }                    /* orange (1–50)  */
#forecastTable td .util-0  { color: #d32f2f !important; }                    /* red (0)        */
#forecastTable td .text-warning { color: #d32f2f !important; font-weight: 600; } /* >100 */

/* IMPORTANT: neutralise any td-level colour so the span wins */
#forecastTable td.text-end.financial-cell > .util-95,
#forecastTable td.text-end.financial-cell > .util-75,
#forecastTable td.text-end.financial-cell > .util-50,
#forecastTable td.text-end.financial-cell > .util-0,
#forecastTable td.text-end.financial-cell > .text-warning {
  color: inherit;
}

/* Forecast table entity links: match cell color, underline on hover */
#forecastTable .entity-link {
  color: inherit;
  text-decoration: none;
}
#forecastTable .entity-link:hover,
#forecastTable .entity-link:focus {
  text-decoration: underline;
}

/* Root Variables */
:root {
    --psa-primary: #0d6efd;
    --psa-secondary: #6c757d;
    --psa-success: #198754;
    --psa-warning: #ffc107;
    --psa-danger: #dc3545;
    --psa-info: #0dcaf0;
    --psa-light: #f8f9fa;
    --psa-dark: #212529;
    
    /* PSA Specific Colors */
    --psa-placeholder-bg: #fff3cd;
    --psa-placeholder-border: #ffeaa7;
    --psa-placeholder-text: #856404;
    
    /* Margin and Health Colors */
    --psa-margin-good: #d1e7dd;
    
    /* Client Carousel Colors */
    --psa-carousel-scroll-track: #f8f9fa;
    --psa-carousel-scroll-thumb: #0d6efd;
    --psa-carousel-scroll-thumb-hover: #0a58ca;
    --psa-margin-warning: #fff3cd;
    --psa-margin-danger: #f8d7da;
    
    /* Utilization Colors */
    --psa-util-excellent: #198754;
    --psa-util-good: #20c997;
    --psa-util-warning: #ffc107;
    --psa-util-danger: #dc3545;
    
    /* Shadow and Border Radius */
    --psa-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --psa-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --psa-border-radius: 0.375rem;
}

/* Column 1 Typography Improvements - Dense and Consistent */
/* Dense default for all text rows in Column 1 cards */
.col1-card .consultant-role-name,
.col1-card .consultant-role,
.col1-card .consultant-level,
.col1-card .assignment-location,
.col1-card .rate,
.col1-card .revenue,
.col1-card .margin,
.col1-card .forecast-effort-days {
  font-size: 10px;         /* Very compact for density */
  line-height: 1.3;
}

/* Make ALL labels uniformly darker */
.col1-card .label,
.col1-card .meta-line .label {
  font-weight: 600;
  color: #212529 !important;  /* Dark, uniform color for all labels */
}

/* Align £/day (left) with Effort (right) on one baseline */
.col1-card .metrics-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
}

/* Make specific text labels darker using custom CSS targeting */
.col1-card .revenue,
.col1-card .margin {
  color: #212529 !important;
  font-weight: 600;
}

/* Make "Effort:" darker by extracting the label part */
.col1-card .forecast-effort-days {
  color: #212529 !important; 
  font-weight: 600;
}
.col1-card .rate,
.col1-card .forecast-effort-days {
  white-space: nowrap;     /* prevent wrap on tight cards */
}

/* Status badge token colors - Force green for Booked badges */
.badge-status.Booked, 
.assignment-status-badge.Booked { 
  background-color: #198754 !important; 
  color: #fff !important; 
}
.badge-status.Planned,
.assignment-status-badge.Planned   { background-color: #e9ecef; color:#495057; }
.badge-status.Complete,
.assignment-status-badge.Complete  { background-color: #0d6efd; color:#fff; }
.badge-status.OnHold,
.assignment-status-badge.OnHold    { background-color: #ffc107; color:#212529; }
.badge-status.Cancelled,
.assignment-status-badge.Cancelled { background-color: #6c757d; color:#fff; }
.badge-status.Proposed,
.badge-status.Tentative,
.assignment-status-badge.Proposed,
.assignment-status-badge.Tentative { background-color: #cfe2ff; color:#084298; }

/* Global Enhancements */
html {
    scroll-padding-top: 130px; /* Offset scroll-to-anchor positioning for fixed elements */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--psa-dark);
    margin-top: 60px; /* Account for fixed navbar height */
}

/* Fixed Navigation Bar */
.navbar.fixed-top {
    position: fixed !important;
    top: 0 !important;
    width: 100% !important;
    z-index: 1100 !important;
    background-color: var(--psa-primary) !important;
}

/* Main Content Spacing */
main.container-fluid {
    padding-top: 80px;
}

/* Page Headers Fix */
main h1, main .h1, main h2, main .h2 {
    color: #212529 !important;
    font-weight: 600 !important;
}

/* Navigation Enhancements */
.navbar {
    background-color: var(--psa-primary) !important;
    overflow: visible !important;
}

/* Ensure navbar collapse doesn't clip dropdowns */
.navbar-collapse {
    overflow: visible !important;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
    color: white !important;
}

.navbar-nav .nav-link {
    font-weight: 500;
    transition: color 0.15s ease-in-out;
    color: rgba(255, 255, 255, 0.9) !important;
}

.navbar-nav .nav-link:hover {
    color: rgba(255, 255, 255, 1) !important;
}

.navbar-toggler {
    border-color: rgba(255, 255, 255, 0.1);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Active navigation states */
.navbar-nav .nav-link.active {
    color: rgba(255, 255, 255, 1) !important;
    font-weight: 600;
}

/* Navbar dropdown menus - ensure they appear above floating menus */
.navbar .dropdown-menu {
    z-index: 1050 !important;
    position: absolute !important;
}

/* Also ensure the dropdown container has proper z-index */
.navbar .dropdown {
    z-index: 1050 !important;
}

/* Navbar dropdown active item - use subtle styling instead of solid button */
.navbar .dropdown-menu .dropdown-item.active,
.navbar .dropdown-menu .dropdown-item:active {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--psa-primary, #4f46e5);
    font-weight: 500;
}

.navbar .dropdown-menu .dropdown-item.active:hover {
    background-color: rgba(79, 70, 229, 0.15);
}

/* Fix z-index for Add Slot Modal in Project Wizard Step 3 */
.step3-slot-modal {
    z-index: 1200 !important;
    position: relative;
}

.step3-slot-modal .modal-dialog {
    z-index: 1205 !important;
}

/* Fix z-index for Delete Assignment Modal in Project Modelling */
.delete-assignment-modal {
    z-index: 1200 !important;
    position: relative;
}

.delete-assignment-modal .modal-dialog {
    z-index: 1205 !important;
}

/* Fix z-index for Unsaved Changes Modal in Project Modelling */
#unsavedChangesModal {
    z-index: 1200 !important;
    position: relative;
}

#unsavedChangesModal .modal-dialog {
    z-index: 1205 !important;
}

/* Fix z-index for Delete Cloned Assignment Modal in Project Modelling */
#deleteClonedAssignmentModal {
    z-index: 1200 !important;
    position: relative;
}

#deleteClonedAssignmentModal .modal-dialog {
    z-index: 1205 !important;
}

.modal-backdrop {
    z-index: 1190 !important;
}

/* Fix z-index for Toast Notifications - ensure they appear above all UI elements */
.toast-container {
    z-index: 10000 !important;
    position: fixed !important;
    top: 80px !important;
    right: 20px !important;
}

/* Fix pale success toast color - Flask flash messages */
.toast-header.bg-success {
    background-color: #157347 !important;
    color: #ffffff !important;
    opacity: 1 !important;
}

/* Fix pale success alert color - JavaScript showToast function */
.alert-success {
    background-color: #157347 !important;
    color: #ffffff !important;
    border-color: #157347 !important;
}

/* Mobile Toast Optimizations */
@media (max-width: 767px) {
    .toast-container {
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
        max-width: none !important;
    }
    
    .toast {
        width: 100% !important;
        max-width: none !important;
    }
    
    .toast-body {
        padding: 1rem !important;
        font-size: 0.9375rem !important;
    }
    
    .toast-header {
        padding: 0.75rem 1rem !important;
    }
    
    .toast .btn-close {
        padding: 0.5rem !important;
        margin: 0 !important;
    }
}

/* Specific targeting for Reports and Quick Add dropdowns */
.nav-dropdown, .quick-add-dropdown {
    z-index: 1050 !important;
    position: absolute !important;
}

/* Card Enhancements */
.card {
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: var(--psa-shadow-sm);
    transition: box-shadow 0.15s ease-in-out;
}

.card:hover {
    box-shadow: var(--psa-shadow);
}

.card-header {
    background-color: var(--psa-light) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    font-weight: 600;
    color: #212529 !important;
}

.card-header h1, .card-header h2, .card-header h3, .card-header h4, .card-header h5, .card-header h6,
.card-header .h1, .card-header .h2, .card-header .h3, .card-header .h4, .card-header .h5, .card-header .h6 {
    color: #212529 !important;
}

/* Placeholder Consultant Styling */
.table-warning {
    background-color: var(--psa-placeholder-bg) !important;
    border-color: var(--psa-placeholder-border);
}

.placeholder-consultant {
    background-color: var(--psa-placeholder-bg);
    border: 1px solid var(--psa-placeholder-border);
    border-radius: var(--psa-border-radius);
    padding: 0.5rem;
}

.placeholder-consultant .badge {
    background-color: var(--psa-warning) !important;
    color: var(--psa-placeholder-text) !important;
}

/* Project Health Indicators */
.project-health-excellent {
    background-color: var(--psa-margin-good);
    border-left: 4px solid var(--psa-success);
}

.project-health-warning {
    background-color: var(--psa-margin-warning);
    border-left: 4px solid var(--psa-warning);
}

.project-health-danger {
    background-color: var(--psa-margin-danger);
    border-left: 4px solid var(--psa-danger);
}

/* Utilization Styling */
.utilization-excellent {
    color: var(--psa-util-excellent) !important;
}

.utilization-good {
    color: var(--psa-util-good) !important;
}

.utilization-warning {
    color: var(--psa-util-warning) !important;
}

.utilization-danger {
    color: var(--psa-util-danger) !important;
}

/* Progress Bar Enhancements */
.progress {
    background-color: #e9ecef;
    border-radius: 0.25rem;
}

.progress-bar {
    transition: width 0.6s ease;
}

/* Metric Cards */
.metric-card {
    text-align: center;
    padding: 1.5rem;
    border-radius: var(--psa-border-radius);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-bottom: 1rem;
}

.metric-card h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.metric-card p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 0;
}

/* Dashboard Specific Styles */
.dashboard-widget {
    background: white;
    border-radius: var(--psa-border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--psa-shadow-sm);
}

.dashboard-widget h5 {
    color: var(--psa-secondary);
    font-size: 0.875rem;
}

/* Client Carousel Styles */
.clients-carousel {
    scrollbar-width: thin;
    scrollbar-color: var(--psa-carousel-scroll-thumb) var(--psa-carousel-scroll-track);
    scroll-snap-type: x mandatory;
    padding: 0.5rem 0;
}

.clients-carousel::-webkit-scrollbar {
    height: 8px;
}

.clients-carousel::-webkit-scrollbar-track {
    background: var(--psa-carousel-scroll-track);
    border-radius: 4px;
}

.clients-carousel::-webkit-scrollbar-thumb {
    background: var(--psa-carousel-scroll-thumb);
    border-radius: 4px;
}

.clients-carousel::-webkit-scrollbar-thumb:hover {
    background: var(--psa-carousel-scroll-thumb-hover);
}

.client-card {
    scroll-snap-align: start;
    scroll-snap-stop: normal;
}

.client-card .card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    border: 1px solid rgba(0,0,0,0.1);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    min-height: 180px;
    cursor: pointer;
}

.client-card .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.15) !important;
    background: linear-gradient(135deg, #ffffff 0%, #f0f2f5 100%);
}

.client-card .card:active {
    transform: translateY(-1px);
    transition: transform 0.1s ease;
}

.client-card .card-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    padding: 1.25rem;
}

/* Responsive carousel for mobile */
@media (max-width: 576px) {
    .client-card {
        width: 260px !important;
    }
    
    .clients-carousel {
        gap: 0.75rem !important;
        padding: 0.25rem 0;
    }
    
    .client-card .card {
        min-height: 160px;
    }
}
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

/* Time Period Selector */
.period-selector .btn-group .btn {
    border-radius: 0;
    border-right: 0;
}

.period-selector .btn-group .btn:first-child {
    border-radius: 0.375rem 0 0 0.375rem;
}

.period-selector .btn-group .btn:last-child {
    border-radius: 0 0.375rem 0.375rem 0;
    border-right: 1px solid var(--bs-border-color);
}

/* Status Badges */
.status-forecast {
    background-color: var(--psa-secondary) !important;
}

.status-awarded {
    background-color: var(--psa-info) !important;
}

.status-in-flight {
    background-color: var(--psa-primary) !important;
}

.status-complete {
    background-color: var(--psa-success) !important;
}

/* Financial Indicators */
.financial-positive {
    color: var(--psa-success);
    font-weight: 600;
}

.financial-negative {
    color: var(--psa-danger);
    font-weight: 600;
}

.financial-neutral {
    color: var(--psa-secondary);
}

/* Table Enhancements */
.table > :not(caption) > * > * {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.table-hover > tbody > tr:hover > * {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Action Buttons */
.btn-group-actions {
    display: flex;
    gap: 0.25rem;
}

.btn-sm {
    --bs-btn-padding-y: 0.25rem;
    --bs-btn-padding-x: 0.5rem;
    --bs-btn-font-size: 0.775rem;
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

/* Alert Enhancements */
.alert {
    border: 0;
    border-radius: var(--psa-border-radius);
    box-shadow: var(--psa-shadow-sm);
}

.alert-info {
    background-color: rgba(13, 202, 240, 0.1);
    border-left: 4px solid var(--psa-info);
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    border-left: 4px solid var(--psa-warning);
}

.alert-success {
    background-color: rgba(25, 135, 84, 0.1);
    border-left: 4px solid var(--psa-success);
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    border-left: 4px solid var(--psa-danger);
}

/* Form Enhancements */
.form-control:focus,
.form-select:focus {
    border-color: var(--psa-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Autocomplete Search Dropdown */
#searchDropdown {
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--psa-border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    background: white;
    margin-top: 2px;
}

#searchDropdown .dropdown-item {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    text-align: left;
    width: 100%;
    transition: background-color 0.15s ease-in-out;
}

#searchDropdown .dropdown-item:hover,
#searchDropdown .dropdown-item.active {
    background-color: var(--psa-primary);
    color: white;
}

@media print {
    .btn,
    .navbar,
    .sidebar,
    .no-print {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
    
    .table {
        font-size: 0.875rem;
    }
}

/* Timeline Allocation Badges */
.allocation-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 8px;
    color: white;
    z-index: 1;
    pointer-events: auto; /* Enable hover detection */
}

.allocation-badge.zero {
    background-color: #FF4136; /* red */
    display: inline-block;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 12px;
    color: white;
    float: right;
    margin-left: 4px;
}

.allocation-badge.low {
    background-color: #FFA500; /* Orange - matches util-50 */
    display: inline-block;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 12px;
    color: white;
    float: right;
    margin-left: 4px;
}

.allocation-badge.green {
    background-color: #2EDD4A; /* Green - matches util-95 */
    display: inline-block;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 12px;
    color: white;
    float: right;
    margin-left: 4px;
}

.allocation-badge.navy {
    background-color: #001f3f; /* Navy */
    display: inline-block;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 12px;
    color: white;
    float: right;
    margin-left: 4px;
}

/* Time Range Selectors */
.time-range-filter {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

.quick-range-btn {
    padding: 5px 10px;
    border: 1px solid #ddd;
    background-color: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.quick-range-btn:hover {
    background-color: #e9ecef;
}

.quick-range-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

/* Timeline Resize Handles */
.resize-handle {
    position: absolute;
    top: 0;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    opacity: 0;
    transition: opacity 0.2s;
}

.resize-handle.left {
    left: 0;
}

.resize-handle.right {
    right: 0;
}

.timeline-item:hover .resize-handle {
    opacity: 1;
}

.resize-handle:hover {
    background-color: rgba(0, 123, 255, 0.3);
}

/* Timeline Grid Lines */
.timeline-week-grid {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 1px solid #e0e0e0;
    pointer-events: none;
}

.timeline-month-grid {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 2px solid #d0d0d0;
    pointer-events: none;
}

/* Timeline Header Months */
.timeline-header-month {
    position: absolute;
    top: 0;
    height: 30px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    color: #495057;
}

/* Timeline Header Weeks */
.timeline-header-week {
    position: absolute;
    top: 30px;
    height: 20px;
    background-color: #ffffff;
    border-left: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #6c757d;
}

/* Timeline Row Labels */
.timeline-row-label {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: #ffffff;
    border-right: 2px solid #dee2e6;
    padding: 8px 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    min-height: 60px;
}

/* Timeline Scrollable Area */
.timeline-scroll-container {
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid #dee2e6;
    background-color: #ffffff;
}

/* Timeline Content */
.timeline-content {
    position: relative;
    min-height: 400px;
}

/* Edit Assignment Panel */
.edit-assignment-panel {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 350px;
    z-index: 1050;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
}

.edit-assignment-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.edit-assignment-panel .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-assignment-panel .close-btn:hover {
    color: #495057;
}

/* Find Work Modal (centered in viewport) */
.find-work-modal {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 500px !important;
    max-width: 90vw !important;
    max-height: 80vh !important;
    z-index: 1200 !important;
    background: white !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    padding: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
}

.find-work-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1190;
}

.find-work-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.find-work-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.find-work-body {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
    max-height: calc(80vh - 120px); /* Account for header and padding */
}

#findWorkMatches {
    max-height: 100%;
    overflow-y: auto;
}

#matchesList {
    max-height: 400px;
    overflow-y: auto;
}

.find-work-modal .btn-close {
    background: none !important;
    border: none !important;
    font-size: 24px !important;
    cursor: pointer !important;
    color: #6c757d !important;
    padding: 0 !important;
    width: 30px !important;
    height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
}

.find-work-modal .btn-close:hover {
    color: #495057 !important;
    opacity: 0.75 !important;
}

.find-work-modal .btn-close::before {
    content: "×" !important;
    font-size: 24px !important;
    line-height: 1 !important;
}

/* Match item styling */
.match-item {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: #fff;
    transition: box-shadow 0.2s;
}

.match-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.match-score {
    background: #007bff;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.match-details {
    font-size: 0.875rem;
    color: #6c757d;
}

.match-actions {
    margin-top: 0.5rem;
}

.match-actions .btn {
    margin-right: 0.5rem;
    margin-bottom: 0.25rem;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .find-work-modal {
        width: 350px;
    }
}

@media (max-width: 768px) {
    .find-work-modal {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        transform: none;
    }
}

/* Assignment Save Status */
.save-status {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
    z-index: 1;
}

.save-status.saving {
    background-color: #ffc107;
}

.save-status.saved {
    background-color: #28a745;
}

.save-status.error {
    background-color: #dc3545;
}

/* Assignment Status Icons */
.assignment-item .status-icon {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    z-index: 2;
}

.status-icon.booked {
    background-color: #28a745;
}

.status-icon.planned {
    background-color: #6c757d;
}

.status-icon.proposed {
    background-color: #17a2b8;
}

.status-icon.on-hold {
    background-color: #ffc107;
}

.status-icon.cancelled {
    background-color: #dc3545;
}

/* Assignment Capacity Warnings */
.capacity-warning {
    background-color: #fff3cd !important;
    border-left: 4px solid #ffc107 !important;
}

.capacity-error {
    background-color: #f8d7da !important;
    border-left: 4px solid #dc3545 !important;
}

/* Assignment Clone Button */
.clone-assignment-btn {
    position: absolute;
    top: 5px;
    right: 25px;
    opacity: 0;
    transition: opacity 0.2s;
    background: rgba(0, 123, 255, 0.8);
    color: white;
    border: none;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 11px;
    cursor: pointer;
    z-index: 3;
}

.assignment-item:hover .clone-assignment-btn {
    opacity: 1;
}

.clone-assignment-btn:hover {
    background: rgba(0, 123, 255, 1);
}

/* Status Notes Section */
.status-notes-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
}

.status-notes-preview {
    max-height: 60px;
    overflow: hidden;
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 10px;
}

.status-notes-history {
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
}

.status-notes-entry {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

.status-notes-entry:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.status-notes-meta {
    font-weight: 600;
    color: #495057;
    margin-bottom: 3px;
}

.status-notes-text {
    color: #6c757d;
    line-height: 1.4;
}

/* Switch Consultant Modal */
.switch-consultant-modal .consultant-option {
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.switch-consultant-modal .consultant-option:hover {
    background-color: #f8f9fa;
}

.switch-consultant-modal .consultant-option.selected {
    background-color: #e3f2fd;
    border-color: #2196f3;
}

.consultant-fit-score {
    float: right;
    font-weight: 600;
    color: #28a745;
}

/* Hover Tooltip */
.hover-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1060;
    pointer-events: none;
    white-space: nowrap;
    max-width: 300px;
}

/* Assignment Context Menu */
.assignment-context-menu {
    position: absolute;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 1055;
    min-width: 150px;
}

.assignment-context-menu .menu-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f8f9fa;
}

.assignment-context-menu .menu-item:hover {
    background-color: #f8f9fa;
}

.assignment-context-menu .menu-item:last-child {
    border-bottom: none;
}

.assignment-context-menu .menu-item.danger:hover {
    background-color: #f8d7da;
    color: #721c24;
}

/* Timeline Zoom Controls */
.timeline-zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    z-index: 10;
}

.timeline-zoom-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background-color 0.2s;
}

.timeline-zoom-btn:hover {
    background-color: #f8f9fa;
}

/* Timeline Loading State */
.timeline-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 20;
}

.timeline-loading .spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
}

/* Assignment Overlap Indicator */
.assignment-overlap {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid #dc3545;
    border-radius: 4px;
    pointer-events: none;
    z-index: 1;
}

.assignment-overlap::before {
    content: "⚠";
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

/* Assignment Dragging State */
.assignment-item.dragging {
    opacity: 0.7;
    z-index: 1000;
    pointer-events: none;
}

.assignment-item.drag-over {
    background-color: rgba(0, 123, 255, 0.1) !important;
}

/* Assignment Selection */
.assignment-item.selected {
    box-shadow: 0 0 0 2px #007bff;
    z-index: 100;
}

/* Multi-select mode */
.timeline-container.multi-select .assignment-item {
    cursor: pointer;
}

.timeline-container.multi-select .assignment-item.selected {
    box-shadow: 0 0 0 2px #28a745;
}

/* Holiday Indicators */
.timeline-holiday {
    position: absolute;
    top: 0;
    bottom: 0;
    background-color: rgba(255, 193, 7, 0.2);
    border-left: 1px dashed #ffc107;
    border-right: 1px dashed #ffc107;
    pointer-events: none;
    z-index: 1;
}

.timeline-holiday-label {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffc107;
    color: #212529;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

/* Weekend Indicators */
.timeline-weekend {
    position: absolute;
    top: 0;
    bottom: 0;
    background-color: rgba(108, 117, 125, 0.1);
    pointer-events: none;
    z-index: 0;
}

/* Today Indicator */
.timeline-today {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #dc3545;
    z-index: 15;
    pointer-events: none;
}

.timeline-today::before {
    content: "Today";
    position: absolute;
    top: 5px;
    left: 5px;
    background: #dc3545;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

/* Assignment Utilization Indicators */
.utilization-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    font-size: 8px;
    font-weight: bold;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.utilization-indicator.excellent {
    background-color: #28a745;
}

.utilization-indicator.good {
    background-color: #ffc107;
    color: #212529;
}

.utilization-indicator.warning {
    background-color: #fd7e14;
}

.utilization-indicator.danger {
    background-color: #dc3545;
}

/* Assignment Type Indicators */
.assignment-type-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    z-index: 2;
}

.assignment-type-indicator.billable {
    background-color: #28a745;
}

.assignment-type-indicator.non-billable {
    background-color: #6c757d;
}

.assignment-type-indicator.internal {
    background-color: #17a2b8;
}

/* Timeline Navigation */
.timeline-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
}

.timeline-nav-btn {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.timeline-nav-btn:hover {
    background-color: #e9ecef;
}

.timeline-nav-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.timeline-period-info {
    font-weight: 600;
    color: #495057;
    margin: 0 10px;
}

/* Timeline Legend */
.timeline-legend {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    font-size: 12px;
}

.timeline-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.timeline-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Timeline Export */
.timeline-export-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
    z-index: 10;
}

.timeline-export-btn:hover {
    background-color: #f8f9fa;
}

/* Responsive Timeline */
@media (max-width: 1200px) {
    .edit-assignment-panel {
        width: 300px;
    }
    
    .timeline-row-label {
        min-width: 150px;
    }
}

@media (max-width: 768px) {
    .edit-assignment-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        transform: none;
    }
    
    .timeline-nav {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .timeline-legend {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .timeline-row-label {
        min-width: 120px;
        font-size: 12px;
        padding: 6px 8px;
    }
}

/* Print Styles for Timeline */
@media print {
    .timeline-container {
        break-inside: avoid;
    }
    
    .edit-assignment-panel,
    .timeline-zoom-controls,
    .timeline-export-btn {
        display: none !important;
    }
    
    .assignment-item {
        border: 1px solid #000 !important;
        background-color: #f0f0f0 !important;
        color: #000 !important;
    }
}

/* Accessibility Improvements */
.assignment-item:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.timeline-container[aria-busy="true"] {
    cursor: wait;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .assignment-item {
        border: 2px solid;
    }
    
    .timeline-holiday {
        background-color: #ffff00;
    }
    
    .timeline-weekend {
        background-color: #cccccc;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .assignment-item,
    .timeline-zoom-btn,
    .timeline-nav-btn {
        transition: none;
    }
    
    .loading-spinner {
        animation: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .timeline-container {
        background-color: #212529;
        color: #fff;
    }
    
    .timeline-row-label {
        background-color: #343a40;
        border-color: #495057;
    }
    
    .edit-assignment-panel {
        background-color: #343a40;
        border-color: #495057;
        color: #fff;
    }
    
    .assignment-item {
        border-color: #495057;
    }
}

/* == FORECAST TABLE SORTING == */

/* Prevent sort indicators in body cells */
#forecastTable tbody th[data-sort-col],
#forecastTable tbody td[data-sort-col] { position: static; }
#forecastTable tbody th[data-sort-col]::after,
#forecastTable tbody td[data-sort-col]::after { content: none !important; }

/* Sort indicators */
#forecastTable thead th[data-sort-col] { position: relative; }

#forecastTable thead th.sorted { font-weight: 600; }

#forecastTable thead th, #byPeriodTable thead th, #plTable thead th {
  background-color: #f8f9fa;
  color: var(--psa-dark, #212529);
  border-bottom: 2px solid var(--psa-primary, #0d6efd);
}

/* Hover & zebra remain Bootstrap-driven; this keeps visuals consistent. */

/* ---- Overrides to neutralise older, conflicting rules (no deletions required) ---- */

/* Some older styles set a larger .forecast-proj-table font-size. Force the Summary size here. */
#byPeriodTable.forecast-proj-table,
#byPeriodTable.forecast-proj-table th,
#byPeriodTable.forecast-proj-table td {
  font-size: .875rem;             /* match Summary */
}

/* If any legacy rule bumps P&L sizing, pin it back to Summary size. */
#plTable.table-compact,
#plTable.table-compact th,
#plTable.table-compact td {
  font-size: .875rem;
}

/* Optional: small-screen tweak so it stays readable on a 14" display */
@media (max-width: 1280px) {
  #forecastTable.table-compact,
  #byPeriodTable.table-compact,
  #plTable.table-compact { font-size: .8125rem; }  /* ≈13px */
}

/* === Forecast table: header-only sort indicators (no layout shift) === */
#forecastTable thead th[data-sort-col] { position: relative; }

/* prevent any body cells from ever showing arrows even if classes leak */
#forecastTable tbody th[data-sort-col],
#forecastTable tbody td[data-sort-col] { position: static; }
#forecastTable tbody th[data-sort-col]::after,
#forecastTable tbody td[data-sort-col]::after { content: none !important; }


/* optional emphasis on active header */
#forecastTable thead th.sorted { font-weight: 600; }

/* Hidden when there are no rows (renderEmpty) */
#forecastTable tfoot.is-hidden { display: none !important; }

/* === Forecast filterbar multi-selects (scoped) === */
.frc-filterbar .frc-ms { position: relative; display: inline-block; }
.frc-filterbar .frc-ms-btn {
  /* mimic Bootstrap form-select but taller */
  font-size: .875rem; line-height: 1.5;
  background: #fff;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: .375rem;
  padding: .5rem 2rem .5rem .75rem;       /* taller padding */
  height: 38px;                           /* match taller filter inputs */
  min-width: 160px;
  text-align: left;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.frc-filterbar .frc-ms-btn::after {
  content: ""; position: absolute; right: .75rem; top: 50%; transform: translateY(-50%);
  border-width: .3rem .3rem 0 .3rem; border-style: solid;
  border-color: #6c757d transparent transparent transparent; /* caret */
}
.frc-filterbar .frc-ms-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 240px; background: #fff;
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: .5rem; box-shadow: 0 10px 20px rgba(0,0,0,.08);
  padding: .5rem; z-index: 1000;
}
.frc-filterbar .frc-ms.open .frc-ms-menu { display: block; }
.frc-filterbar .frc-ms-actions { display: flex; gap: .5rem; justify-content: space-between; margin-bottom: .5rem; }
.frc-filterbar .frc-ms-actions button { 
  font-size: .75rem; 
  padding: .2rem .4rem; 
  background: none; 
  border: none; 
  color: #6c757d; 
  text-decoration: underline;
  cursor: pointer;
}
.frc-filterbar .frc-ms-actions button:hover { 
  color: #495057; 
  text-decoration: none; 
}
.frc-filterbar .frc-ms-item { display: block; font-size: .875rem; padding: .2rem 0; }
.frc-filterbar .frc-ms-separator { height: 1px; background-color: #dee2e6; margin: .5rem 0; }

/* Ensure filter bar and its dropdown menus sit above the table/card */
.frc-filterbar {
  position: relative;        /* creates a stacking context */
  z-index: 1200;             /* higher than sticky headers/tables (< 1100) */
  overflow: visible;         /* allow dropdown menus to overflow their container */
}

/* Popover menu must outrank table/sticky z-index */
.frc-filterbar .frc-ms-menu {
  z-index: 1250;             /* ensure it paints above .frc-filterbar siblings */
}

/* --- Forecast filter: rigid single row on >=1200px, flexible below --- */
.frc-filterbar .form-label { margin-bottom: 0; font-size: .75rem; color: #6c757d; }
.frc-filterbar select.form-select-sm,
.frc-filterbar input.form-control-sm { 
  height: 38px;                           /* taller for better touch targets */
  padding: .5rem .75rem;                  /* more vertical padding */
}

/* Project filter search dropdown */
.frc-project-search { position: relative; }
.frc-project-search input { padding-right: 1.75rem; }
.frc-project-clear {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #6c757d; font-size: .75rem;
  cursor: pointer; padding: 0; line-height: 1;
}
.frc-project-clear:hover { color: #dc3545; }
.frc-project-dropdown {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 250px; overflow-y: auto;
  background: #fff; border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: .375rem; box-shadow: 0 6px 12px rgba(0,0,0,.1);
  z-index: 1080;
}
.frc-project-dropdown.show { display: block; }
.frc-project-item {
  display: block; width: 100%; text-align: left; padding: .5rem .75rem;
  font-size: .8125rem; border: none; background: none; cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
.frc-project-item:last-child { border-bottom: none; }
.frc-project-item:hover { background: #f8f9fa; }
.frc-project-item .project-name { font-weight: 500; color: #212529; }
.frc-project-item .project-client { font-size: .75rem; color: #6c757d; }
.frc-project-selected { background-color: #e8f4fd; border-color: #0d6efd; }
#projectFilterContainer.disabled { opacity: 0.5; pointer-events: none; }

/* Laptop / desktop: force a single neat row */
@media (min-width: 1200px) {
  .frc-row1 {
    display: grid !important;
    grid-auto-flow: column;
    /* Updated column widths to fit Project filter on 14" (≈1440px) */
    grid-template-columns:
      140px  /* Quick Range */
      120px  /* Start */
      120px  /* End */
      100px  /* Scope */
      120px  /* View */
      90px   /* Bucket */
      170px  /* Assignment Status (frc-ms) */
      170px  /* Project Status (frc-ms) */
      200px; /* Project filter - wider for better UX */
    column-gap: .5rem;
    row-gap: .5rem;
    align-items: end;
  }
  /* Second row: checkbox left, buttons right */
  .frc-row2 {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
  }
}

/* Tablets/smaller: allow wrapping with sane minimums */
@media (max-width: 1199.98px) {
  .frc-row1 { 
    display: flex !important; 
    flex-wrap: wrap; 
    gap: .5rem .75rem; 
    align-items: end; 
  }
  .frc-row1 > div { flex: 0 1 auto; min-width: 140px; }
  .frc-row1 #projectFilterContainer { min-width: 200px; } /* Project filter wider */
  .frc-row2 { 
    display: flex !important; 
    flex-wrap: wrap; 
    gap: .5rem .75rem; 
    align-items: center; 
  }
  .frc-row2 .ms-auto { margin-left: auto !important; }
}

/* Keep filter menus on top of sticky table headers */
.frc-filterbar { position: relative; z-index: 1200; }
.frc-filterbar .frc-ms-menu { z-index: 1250; }

/* DVB filter bar: use proven flex layout (same as Forecast) */
@media (min-width: 1200px) {
  #dvbFilters .frc-row1 {
    display: flex !important;
    align-items: end;
    gap: .75rem;
    flex-wrap: nowrap;
  }
  
  /* Quick Range: fixed width */
  #dvbFilters .frc-row1 > div:nth-child(1) {
    flex: 0 0 150px;
  }
  
  /* Fixed date inputs */
  #dvbFilters .frc-row1 > div:nth-child(2),
  #dvbFilters .frc-row1 > div:nth-child(3) {
    flex: 0 0 140px;
  }
  
  /* Elastic multi-selects with min-width */
  #dvbFilters .frc-row1 .frc-ms {
    flex: 1 1 200px;
    min-width: 180px;
  }
  
  /* Actions: never wrap, right-aligned */
  #dvbFilters .frc-actions {
    flex: 0 0 auto;
    white-space: nowrap;
    margin-left: auto;
  }
}

/* Responsive: allow wrapping on smaller screens */
@media (max-width: 1199.98px) {
  #dvbFilters .frc-row1 {
    display: flex !important;
    flex-wrap: wrap;
    gap: .5rem .75rem;
    align-items: end;
  }
  
  #dvbFilters .frc-row1 > div {
    flex: 0 1 auto;
    min-width: 140px;
  }
  
  #dvbFilters .frc-row1 .frc-ms {
    min-width: 200px;
  }
}

/* Assignment filter bar: use same proven flex layout as DVB */
@media (min-width: 1200px) {
  #assignmentFilters .frc-row1 {
    display: flex !important;
    align-items: end;
    gap: .75rem;
    flex-wrap: nowrap;
  }
  
  /* Quick Range: fixed width */
  #assignmentFilters .frc-row1 > div:nth-child(1) {
    flex: 0 0 140px;
  }
  
  /* Fixed date inputs */
  #assignmentFilters .frc-row1 > div:nth-child(2),
  #assignmentFilters .frc-row1 > div:nth-child(3) {
    flex: 0 0 130px;
  }
  
  /* Elastic multi-selects with min-width (smaller because we have more fields) */
  #assignmentFilters .frc-row1 .frc-ms {
    flex: 1 1 160px;
    min-width: 160px;
  }
  
  /* Actions: never wrap, right-aligned */
  #assignmentFilters .frc-actions {
    flex: 0 0 auto;
    white-space: nowrap;
    margin-left: auto;
  }
}

/* Responsive: allow wrapping on smaller screens */
@media (max-width: 1199.98px) {
  #assignmentFilters .frc-row1 {
    display: flex !important;
    flex-wrap: wrap;
    gap: .5rem .75rem;
    align-items: end;
  }
  
  #assignmentFilters .frc-row1 > div {
    flex: 0 1 auto;
    min-width: 130px;
  }
  
  #assignmentFilters .frc-row1 .frc-ms {
    min-width: 180px;
  }
}

/* Utilization filter bar: compact layout with checkbox */
@media (min-width: 1200px) {
  #utilizationFilters .frc-row1 {
    display: flex !important;
    align-items: end;
    gap: .5rem;
    flex-wrap: nowrap;
  }
  
  /* Quick Range: compact */
  #utilizationFilters .frc-row1 > div:nth-child(1) {
    flex: 0 0 120px;
  }
  
  /* Fixed date inputs: compact */
  #utilizationFilters .frc-row1 > div:nth-child(2),
  #utilizationFilters .frc-row1 > div:nth-child(3) {
    flex: 0 0 120px;
  }
  
  /* Elastic multi-selects: compact to fit all items */
  #utilizationFilters .frc-row1 .frc-ms {
    flex: 1 1 140px;
    min-width: 140px;
  }
  
  /* Checkbox: minimal width */
  #utilizationFilters .frc-row1 > div:nth-child(7) {
    flex: 0 0 auto;
  }
  
  /* Actions: never wrap, right-aligned */
  #utilizationFilters .frc-actions {
    flex: 0 0 auto;
    white-space: nowrap;
    margin-left: auto;
  }
}

/* Responsive: allow wrapping on smaller screens */
@media (max-width: 1199.98px) {
  #utilizationFilters .frc-row1 {
    display: flex !important;
    flex-wrap: wrap;
    gap: .5rem .75rem;
    align-items: end;
  }
  
  #utilizationFilters .frc-row1 > div {
    flex: 0 1 auto;
    min-width: 130px;
  }
  
  #utilizationFilters .frc-row1 .frc-ms {
    min-width: 180px;
  }
}

/* Demand Planning filter bar: use same proven flex layout as Assignment */
@media (min-width: 1200px) {
  #demandFilters .frc-row1 {
    display: flex !important;
    align-items: end;
    gap: .75rem;
    flex-wrap: nowrap;
  }
  
  /* Quick Range: fixed width */
  #demandFilters .frc-row1 > div:nth-child(1) {
    flex: 0 0 140px;
  }
  
  /* Fixed date inputs */
  #demandFilters .frc-row1 > div:nth-child(2),
  #demandFilters .frc-row1 > div:nth-child(3) {
    flex: 0 0 130px;
  }
  
  /* Elastic multi-selects with min-width */
  #demandFilters .frc-row1 .frc-ms {
    flex: 1 1 160px;
    min-width: 160px;
  }
  
  /* Actions: never wrap, right-aligned */
  #demandFilters .frc-actions {
    flex: 0 0 auto;
    white-space: nowrap;
    margin-left: auto;
  }
}

/* Responsive: allow wrapping on smaller screens */
@media (max-width: 1199.98px) {
  #demandFilters .frc-row1 {
    display: flex !important;
    flex-wrap: wrap;
    gap: .5rem .75rem;
    align-items: end;
  }
  
  #demandFilters .frc-row1 > div {
    flex: 0 1 auto;
    min-width: 130px;
  }
  
  #demandFilters .frc-row1 .frc-ms {
    min-width: 180px;
  }
}

/* Actions page filter bar layout - matches Assignment Report pattern */
@media (min-width: 1200px) {
  #actionsFilters .frc-row1 {
    display: flex !important;
    align-items: flex-end;
    gap: .75rem;
    flex-wrap: nowrap;
  }
  
  /* Multi-selects: elastic with min-width (same as Assignment Report) */
  #actionsFilters .frc-row1 > div {
    flex: 1 1 120px;
    min-width: 100px;
    display: flex;
    flex-direction: column;
  }
  
  /* Show Completed checkbox: fixed width */
  #actionsFilters .frc-row1 > div:has(.form-check) {
    flex: 0 0 auto;
    min-width: auto;
    white-space: nowrap;
  }
  
  /* Actions: never wrap, right-aligned (same as Assignment Report) */
  #actionsFilters .frc-actions {
    flex: 0 0 auto;
    white-space: nowrap;
    margin-left: auto;
  }
}

@media (max-width: 1199.98px) {
  #actionsFilters .frc-row1 {
    display: flex !important;
    flex-wrap: wrap;
    gap: .5rem .75rem;
    align-items: flex-end;
  }
  
  #actionsFilters .frc-row1 > div {
    flex: 0 1 auto;
    min-width: 130px;
    display: flex;
    flex-direction: column;
  }
  
  #actionsFilters .frc-row1 .frc-ms {
    min-width: 160px;
    display: block;
  }
  
  #actionsFilters .frc-actions {
    margin-left: auto;
  }
}

/* Second row: keep actions together next to the checkbox */
.frc-row2 { 
  display: flex !important; 
  justify-content: flex-start; 
  align-items: center; 
}

/* Action Notes column - text wrapping */
.action-notes {
  display: block;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.4;
  max-height: 4.2em;
  cursor: pointer;
}

.action-notes:hover {
  background-color: #f8f9fa;
}

/* Priority pill styles */
.priority-pill {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}

.priority-pill.priority-high {
  background-color: #fff5f5;
  color: #dc3545;
}

.priority-pill.priority-medium {
  background-color: #fff8e6;
  color: #fd7e14;
}

.priority-pill.priority-low {
  background-color: #e8f5e9;
  color: #28a745;
}

/* Actions table dropdown - fix selected item text color */
.action-table .dropdown-item.active,
.action-table .dropdown-item:active {
  color: #fff !important;
  background-color: var(--bs-primary, #0d6efd);
}

/* Actions table sticky header - sticks to viewport on page scroll */
.action-table thead.sticky-top {
  position: sticky;
  top: 56px; /* navbar height */
  z-index: 1020;
  background: #f8f9fa;
}

.action-table thead.sticky-top th {
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

/* Resizable columns */
.action-table th {
  position: relative;
}

.action-table th.resizable::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
}

.action-table th.resizable:hover::after {
  background: #dee2e6;
}

.action-table th.resizing::after {
  background: var(--bs-primary, #0d6efd);
}

.frc-actions {
  display: flex;
  align-items: center;
  gap: .5rem;         /* space between checkbox and buttons */
  flex-wrap: wrap;    /* graceful wrap on small screens */
}

.frc-actions .form-check { margin-bottom: 0; }

/* Shared sticky helpers for all forecast tables (Summary, By Period, P&L) */
.forecast-wrapper { position: relative; overflow: auto; }

/* Header stays on top while scrolling - SHARED pattern for all forecast tables */
.forecast-wrapper .sticky-top {
  position: sticky;
  top: 0;
  z-index: 1020; /* above body cells, below filter dropdowns (1200+) */
  background: #f8f9fa; /* solid gray header background */
}

/* Ensure all header cells have solid background */
.forecast-wrapper .sticky-top th {
  background: #f8f9fa;
  color: #495057;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #dee2e6;
}

/* ===== Forecast table: single, canonical sticky header ===== */

/* Use THEAD as the only sticky element (robust in all browsers). */
#forecastTable thead {
  position: sticky !important;
  top: var(--nav-h, 56px) !important;      /* adjust if your navbar height differs */
  z-index: 1015 !important;                /* above body cells and totals */
  background: #fff !important;             /* solid so rows don't bleed through */
}

/* Header cells themselves are NOT sticky (prevents conflicts). */
#forecastTable thead th {
  position: static !important;
  background: #fff !important;
  /* remove the blue underline coming from borders/shadows elsewhere */
  border-bottom: 1px solid #dee2e6 !important;
  box-shadow: none !important;
}

/* ===== Forecast header stacking & arrow visibility ===== */

/* Keep THEAD above any body content (details buttons, etc.) */
#forecastTable thead.sticky-top {
  position: sticky;
  top: var(--nav-h, 56px) !important;
  z-index: 1015 !important;
  background: #fff !important;
}

/* Each header cell sits above the THEAD and is opaque */
#forecastTable thead.sticky-top th {
  position: sticky;
  top: var(--nav-h, 56px) !important;
  z-index: 1016 !important;
  background: #fff !important;
}

/* First body row should not re-draw a thick line under the header */
#forecastTable tbody tr:first-child td {
  border-top: 0 !important;
}

/* Keep totals footer at the bottom only (never sticky) */
#forecastTable tfoot,
#forecastTotals {
  display: table-footer-group !important;
  position: static !important;
  top: auto !important;
  z-index: auto !important;
}

/* Hide footer when empty state is shown (your JS already toggles this) */
#forecastTable tfoot.is-hidden { display: none !important; }

/* ===== Forecast header stacking & arrow visibility ===== */

/* Keep THEAD above any body content (details buttons, etc.), but below filter dropdowns (z-index 1075) */
#forecastTable thead.sticky-top {
  position: sticky;
  top: var(--nav-h, 56px) !important;
  z-index: 1015 !important;
  background: #fff !important;
}

/* Each header cell sits above the THEAD and is opaque */
#forecastTable thead.sticky-top th {
  position: sticky;
  top: var(--nav-h, 56px) !important;
  z-index: 1016 !important;
  background: #fff !important;
}

/* Only sortable headers can render arrows; reserve space for arrow */
#forecastTable thead tr > th[data-sort-col] {
  position: relative;
}
#forecastTable thead tr > th[data-sort-col]:not(:first-child) {
  padding-right: 1.25rem; /* prevent overlap */
}

/* DISABLED: Default: no arrow; ensure it paints above header text */
/* #forecastTable thead tr > th[data-sort-col]::after {
  content: "" !important;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9em;
  line-height: 1;
  opacity: 0.95;
  color: currentColor;
  pointer-events: none;
  z-index: 2;
} */

/* DISABLED: Show arrows only when ARIA indicates sorted */
/* #forecastTable thead tr > th[data-sort-col][aria-sort="ascending"]::after  { content: "▲" !important; }
#forecastTable thead tr > th[data-sort-col][aria-sort="descending"]::after { content: "▼" !important; } */

/* DISABLED: Non-sortable header (Details) must never show an arrow */
/* #forecastTable thead tr > th.col-details::after,
#forecastTable thead tr > th:not([data-sort-col])::after { content: none !important; } */

/* Hide any legacy DOM-based arrow spans if they still exist */
#forecastTable thead .sort-indicator { display: none !important; }

/* ===== Forecast header arrows & stacking: final overrides ===== */

/* 0) Kill any old decorative chevron on the Details column header */
#forecastTable thead th.col-details::before,
#forecastTable thead th.col-details::after {
  content: none !important;
}

/* 1) Keep THEAD (and its THs) above every TBODY element, but below filter dropdowns (z-index 1075) */
#forecastTable thead.sticky-top {
  position: sticky;
  top: 0 !important;                      /* stick to wrapper top */
  z-index: 1015 !important;
  background: #f8f9fa !important;
}
#forecastTable thead.sticky-top th {
  position: static !important;            /* cells don't need to be sticky */
  background: #f8f9fa !important;
  color: #495057 !important;
}

/* 2) Push body content below header so nothing bleeds through */
#forecastTable tbody,
#forecastTable tbody * {
  position: relative !important;
  z-index: 0 !important;
}

/* 3) Only sortable headers can render arrows; reserve space for arrow */
#forecastTable thead tr > th[data-sort-col] {
  position: relative;
}
#forecastTable thead tr > th[data-sort-col]:not(:first-child) {
  padding-right: 1.25rem !important; /* ensure arrow doesn't overlap right-aligned text */
}

/* DISABLED: 4) Default: no arrow; absolutely position; paint above header text */
/* #forecastTable thead tr > th[data-sort-col]::after {
  content: "" !important;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9em;
  line-height: 1;
  opacity: 0.95;
  color: currentColor !important;
  pointer-events: none;
  z-index: 2 !important; /* within the TH stacking context */
} */

/* DISABLED: 5) Show arrows only when ARIA indicates sorted */
/* #forecastTable thead tr > th[data-sort-col][aria-sort="ascending"]::after  { content: "▲" !important; }
#forecastTable thead tr > th[data-sort-col][aria-sort="descending"]::after { content: "▼" !important; } */

/* DISABLED: 6) Non-sortable header must never show arrows (extra guard) */
/* #forecastTable thead tr > th:not([data-sort-col])::after { content: none !important; } */

/* 7) Hide any legacy DOM-based arrow spans if they exist */
#forecastTable thead .sort-indicator { display: none !important; }

/* ===== Forecast: make sortable headers feel clickable ===== */

/* All sortable headers (those with data-sort-col) show pointer + link-like hover */
#forecastTable thead th[data-sort-col] {
  cursor: pointer;
}

/* Hover affordance: light underline like our project child rows */
#forecastTable thead th[data-sort-col]:hover {
  text-decoration: underline;
  text-underline-offset: .18em;
  text-decoration-thickness: .08em;
}

/* Keep the underline on the currently sorted column */
#forecastTable thead th[data-sort-col].sorted {
  text-decoration: underline;
  text-underline-offset: .18em;
  text-decoration-thickness: .08em;
  font-weight: 600; /* optional emphasis; remove if you prefer */
}

/* Non-sortable header (Details) must remain neutral */
#forecastTable thead th.col-details,
#forecastTable thead th:not([data-sort-col]) {
  cursor: default !important;
  text-decoration: none !important;
}

/* ===== Forecast: By-Period & P&L sticky headers ===== */
/* CRITICAL: Tables are inside scroll containers (.forecast-wrapper), so top: 0 NOT 56px */

/* THEAD sticks to TOP OF SCROLL CONTAINER (not navbar) */
#byPeriodTable thead.sticky-top,
#plTable thead.sticky-top {
  position: sticky !important;
  top: 0 !important;  /* FIXED: was 56px, now 0 since inside scroll container */
  z-index: 1015 !important;
  background: #fff !important;
}

/* Header cells are static but with solid background */
#byPeriodTable thead.sticky-top th,
#plTable thead.sticky-top th {
  position: static !important;
  background: #fff !important;
  color: #495057 !important;
  font-weight: 600 !important;
  font-size: 0.75rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  border-bottom: 1px solid #dee2e6 !important;
}

/* 3) Ensure the scroll container allows sticky to work */
#byPeriodScroll,
#plScroll,
.forecast-wrapper {
  overflow: auto; /* safe: enables sticky headers inside the scroll area */
}

/* ===== Forecast: sticky first column for By-Period & P&L ===== */
/* Make column 1 (header + body) sticky regardless of .table-compact */
#byPeriodTable .sticky-start,
#plTable .sticky-start {
  position: sticky !important;
  left: 0 !important;
  background: #fff !important;            /* prevent bleed-through */
}

/* Header cell of the first column sticks to top-left corner inside scroll container */
#byPeriodTable thead.sticky-top th.sticky-start,
#plTable thead.sticky-top th.sticky-start {
  top: 0 !important;  /* FIXED: was 56px, now 0 since inside scroll container */
  left: 0 !important;
  z-index: 1020 !important;               /* above body sticky cells and table content */
}

/* Body cells for the first column: below header but above regular cells */
#byPeriodTable tbody td.sticky-start,
#plTable tbody td.sticky-start {
  z-index: 1016 !important;
}

/* ===== Forecast: By-Period & P&L — sticky first column fix ===== */

/* Sticky works reliably when the table is not collapsing borders */
#byPeriodTable,
#plTable {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

/* The scroll containers (ensure sticky context is correct) */
#byPeriodScroll,
#plScroll {
  overflow: auto; /* horizontal + vertical scroll area */
}

/* Note: By-Period and P&L sticky headers use shared .forecast-wrapper .sticky-top pattern */

/* Utilization table: standard table styling without sticky positioning */
#utilizationTable {
  border-collapse: collapse;
}

/* First column (header + body): stick to the left and stack above others */
#byPeriodTable th.sticky-start,
#plTable th.sticky-start,
#byPeriodTable td.sticky-start,
#plTable td.sticky-start {
  position: sticky !important;
  left: 0 !important;
  background: #fff !important;
}

/* Raise the header cell of column 1 above body cells */
#byPeriodTable thead.sticky-top th.sticky-start,
#plTable thead.sticky-top th.sticky-start {
  z-index: 1020 !important;
}

/* Body cells of column 1 beneath the header but above normal cells */
#byPeriodTable tbody td.sticky-start,
#plTable tbody td.sticky-start {
  z-index: 1018 !important;
}

/* ===== Forecast: force sticky first column (header + body) for By-Period & P&L ===== */

/* 0) Ensure sticky works in tables */
#byPeriodTable,
#plTable {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

/* 1) First HEADER cell: pin to top and left (independent of .sticky-start) */
#byPeriodTable thead.sticky-top th:first-child,
#plTable thead.sticky-top th:first-child {
  position: sticky !important;
  top: 0 !important;  /* FIXED: was 56px, now 0 since inside scroll container */
  left: 0 !important;
  z-index: 1021 !important;  /* above other header cells */
  background: #fff !important;
}

/* 2) First BODY cell: pin to left under the header (works even if .sticky-start is missing) */
#byPeriodTable tbody td:first-child,
#plTable tbody td:first-child {
  position: sticky !important;
  left: 0 !important;
  z-index: 1018 !important;  /* below the header, above regular cells */
  background: #fff !important;
}

/* 3) Keep the header row itself sticky (INSIDE scroll container, so top: 0) */
#byPeriodTable thead.sticky-top,
#plTable thead.sticky-top {
  position: sticky !important;
  top: 0 !important;  /* FIXED: inside scroll container */
  z-index: 1015 !important;
  background: #fff !important;
}

/* ===== BY-PERIOD & P&L: unify sticky behavior (thead controls vertical stickiness) ===== */

/* The whole header row sticks to top of scroll container */
#byPeriodTable thead.sticky-top,
#plTable thead.sticky-top {
  position: sticky !important;
  top: 0 !important;  /* FIXED: inside scroll container */
  z-index: 1015 !important;
  background: #fff !important;
}

/* Header cells should NOT add another top offset — let the thead handle vertical sticky */
#byPeriodTable thead.sticky-top th,
#plTable thead.sticky-top th {
  position: sticky !important;       /* keep sticky so left-fixed cells can also be sticky */
  top: 0 !important;                  /* <<< critical: prevent double top offset */
  z-index: 1016 !important;           /* above body cells */
  background: #fff !important;
}

/* First header cell also sticks to the left edge */
#byPeriodTable thead.sticky-top th:first-child,
#plTable thead.sticky-top th:first-child {
  left: 0 !important;
  z-index: 1021 !important;           /* on top of other header cells */
}

/* First body cell sticks to the left under the header */
#byPeriodTable tbody td:first-child,
#plTable tbody td:first-child {
  position: sticky !important;
  left: 0 !important;
  z-index: 1018 !important;           /* below header, above regular cells */
  background: #fff !important;
}

/* Ensure sticky works nicely inside a scroller */
#byPeriodTable,
#plTable {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

/* === BY-PERIOD & P&L: remove double top on the first header cell ===
   The THEAD is already sticky with the navbar offset; the first TH must not
   add another top offset. Force it to top: 0 to align with its siblings. */
#byPeriodTable thead.sticky-top th.sticky-start:first-child,
#plTable      thead.sticky-top th.sticky-start:first-child {
  top: 0 !important;
}

/* Keep the first header cell pinned to the left */
#byPeriodTable thead.sticky-top th.sticky-start:first-child,
#plTable      thead.sticky-top th.sticky-start:first-child {
  left: 0 !important;
  z-index: 1021 !important; /* above other header cells */
  background: #fff !important;
}

/* Ensure sticky works cleanly inside the scroller */
#byPeriodTable, #plTable {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

/* === BY-PERIOD & P&L: unify sticky behavior with Summary === */
/* CRITICAL: These tables are INSIDE scroll containers, so top: 0 NOT 56px */

/* 1) THEAD is the only element that controls vertical stickiness */
#byPeriodTable thead.sticky-top,
#plTable      thead.sticky-top {
  position: sticky !important;
  top: 0 !important;   /* FIXED: inside scroll container */
  z-index: 1015 !important;
  background: #fff !important;
}

/* 2) Header cells themselves are NOT vertically sticky */
#byPeriodTable thead.sticky-top th,
#plTable      thead.sticky-top th {
  position: static !important;
  top: auto !important;
}

/* 3) Only the FIRST header cell is sticky horizontally (left),
      and we align its vertical offset with THEAD (top: 0) */
#byPeriodTable thead.sticky-top th.sticky-start:first-child,
#plTable      thead.sticky-top th.sticky-start:first-child {
  position: sticky !important;          /* enable sticky for left pin */
  left: 0 !important;
  top: 0 !important;   /* FIXED: inside scroll container */
  z-index: 1021 !important;             /* above other header cells */
  background: #fff !important;
}

/* 4) Body first column stays pinned left under the header */
#byPeriodTable tbody td.sticky-start,
#plTable      tbody td.sticky-start {
  position: sticky !important;
  left: 0 !important;
  z-index: 1018 !important;             /* below header first cell */
  background: #fff !important;
}

/* 5) Ensure sticky works cleanly inside the scroller */
#byPeriodTable, #plTable {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

/* ===== By-Period & P&L: scroll containers for sticky to work ===== */

/* Scroll containers need overflow: auto for sticky headers */
#byPeriodScroll,
#plScroll,
.forecast-wrapper {
  overflow: auto;      /* REQUIRED: enables sticky headers inside the scroll area */
  position: relative;  /* safe stacking context */
}

/* Kill any transforms on ancestors that would break position: sticky */
#byPeriodSection,
#plSection,
#byPeriodScroll,
#plScroll,
.forecast-wrapper,
#byPeriodTable,
#plTable {
  transform: none !important;
  will-change: auto !important; /* avoid implicit transforms */
}

/* ===== Extend Summary child row styling to By-Period & P&L tables ===== */

/* Child/data rows match Summary */
#forecastTable .proj-row,
#byPeriodTable .proj-row,
#plTable .proj-row {
  background: #fafafa;
  font-size: .85rem;
}

/* Child row TD elements inherit grey text color like Summary */
#forecastTable tr.proj-row td,
#byPeriodTable tr.proj-row td,
#plTable tr.proj-row td {
  color: var(--bs-secondary-color, #6c757d);
}

/* Section label row matches Summary */
#forecastTable .proj-label,
#byPeriodTable .proj-label,
#plTable .proj-label {
  color: #6c757d;
  font-size: .85rem;
  background: transparent;
}

/* Indent and subtle left bar for child first column */
#forecastTable .level-1 .sticky-start,
#byPeriodTable .level-1 .sticky-start,
#plTable .level-1 .sticky-start {
  padding-left: 1rem;
  box-shadow: inset 3px 0 0 #e9ecef;
}

/* Make entity links inherit parent color and behave like Summary */
#forecastTable .entity-link,
#byPeriodTable .entity-link,
#plTable .entity-link,
#dvbTable .entity-link,
#utilizationTable .entity-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
#forecastTable .entity-link:hover,
#forecastTable .entity-link:focus,
#byPeriodTable .entity-link:hover,
#byPeriodTable .entity-link:focus,
#plTable .entity-link:hover,
#plTable .entity-link:focus,
#dvbTable .entity-link:hover,
#dvbTable .entity-link:focus,
#utilizationTable .entity-link:hover,
#utilizationTable .entity-link:focus {
  text-decoration: underline;
}

/* ===== Details column width and placeholder styling ===== */

/* Details column width — apply to both header and body cells across tables */
#forecastTable .col-details,
#forecastTable .details-col,
#byPeriodTable .col-details,
#byPeriodTable .details-col {
  width: 2.25rem; /* ~36px; just the control column */
  text-align: right;
  white-space: nowrap;
}

/* Hidden button placeholder for perfect alignment */
.btn-details.btn-placeholder {
  visibility: hidden;      /* takes space, not visible */
  pointer-events: none;    /* not interactive */
}

/* Compact height for P&L chart */
#plChartWrap { 
  height: 220px; 
  max-height: 220px; 
}
#plChart { 
  width: 100% !important; 
  height: 100% !important; 
}

/* KPI Tile Access Control - Disabled state for consultants */
.kpi-drill-link.is-disabled .card,
.kpi-tile.is-disabled .card {
  opacity: 0.6;
  cursor: not-allowed;
}

.kpi-tile.no-drill,
.kpi-drill-link.is-disabled.no-drill {
  pointer-events: none; /* completely non-interactive for consultants */
}

/* === TIMELINE UTILISATION HEATMAP (scoped) === */
.timeline-container .timeline-cell.util-0   { background: linear-gradient(135deg, #FF6B6B, #FF4C4C); }
.timeline-container .timeline-cell.util-50  { background: linear-gradient(135deg, #FFA500, #FF8C00); }
.timeline-container .timeline-cell.util-75  { background: linear-gradient(135deg, #FFD580, #FFC04D); }
.timeline-container .timeline-cell.util-95  { background: linear-gradient(135deg, #4CAF50, #388E3C); }
.timeline-container .timeline-cell.util-100 { 
  background: linear-gradient(135deg, #FF9A56, #FF7043); 
  border: 2px solid #E53935 !important;
  box-shadow: inset 0 0 0 1px rgba(229, 57, 53, 0.2);
}

/* Optional: selection clarity */
.timeline-container .timeline-cell:hover { outline: 1px solid #cbd5e1; outline-offset: -1px; }

/* === Timeline Utilization Legend === */
.timeline-legend {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 16px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  flex-wrap: wrap;
}

.timeline-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-legend .legend-box {
  width: 32px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
}

.timeline-legend .legend-label {
  font-size: 13px;
  color: #374151;
  font-weight: 500;
  white-space: nowrap;
}

/* Legend box colors matching timeline cells */
.timeline-legend .util-legend-0 {
  background: linear-gradient(135deg, #FF6B6B, #FF4C4C);
}

.timeline-legend .util-legend-50 {
  background: linear-gradient(135deg, #FFA500, #FF8C00);
}

.timeline-legend .util-legend-75 {
  background: linear-gradient(135deg, #FFD580, #FFC04D);
}

.timeline-legend .util-legend-95 {
  background: linear-gradient(135deg, #4CAF50, #388E3C);
}

.timeline-legend .util-legend-100 {
  background: linear-gradient(135deg, #FF9A56, #FF7043);
  border: 2px solid #E53935;
  box-shadow: inset 0 0 0 1px rgba(229, 57, 53, 0.2);
}

/* Timeline cell font size - match Column 1 standard */
.timeline-container .timeline-cell {
  font-size: 12px !important;
}

.timeline-container .timeline-cell .badge,
.timeline-container .timeline-cell .allocation-badge {
  font-size: 12px !important;
}

/* Smaller badges for overlap info section in day cells */
.timeline-container .timeline-cell .overlap-info .badge {
  font-size: 8px !important;
  padding: 1px 3px !important;
  line-height: 1.2 !important;
}

/* === Booked Progress Bar Treatment === */
.timeline-container .status-progress-bar {
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  height: 20px;
  background: #198754;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  border: 1px solid rgba(25, 135, 84, 0.3);
}

/* Progress bar positioning variants */
.timeline-container .status-progress-bar.first {
  border-radius: 12px 0 0 12px;
  padding-left: 8px;
}

.timeline-container .status-progress-bar.middle {
  border-radius: 0;
  border-left: none;
  border-right: none;
}

.timeline-container .status-progress-bar.last {
  border-radius: 0 12px 12px 0;
  padding-right: 8px;
}

.timeline-container .status-progress-bar.single {
  border-radius: 12px;
  padding: 0 8px;
}

/* Adjust day-label positioning when progress bar is present */
.timeline-container .day-content.has-status-bar .day-label {
  margin-top: 22px;
}

/* === Modelling: Column 1 badge/readability fixes === */
.timeline-container .col1-card .badge-allocation {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.2;
  background: #eef2ff;   /* light indigo */
  color: #1e3a8a;        /* readable on white */
}

.timeline-container .col1-card .badge-status.assignment-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.2;
  background: #e9ecef;
  color: #111827;
}
.timeline-container .col1-card .badge-status.Planned  { background: #e2e8f0; color: #111827; }
.timeline-container .col1-card .badge-status.Booked   { background: #dcfce7; color: #065f46; }
.timeline-container .col1-card .badge-status.Complete { background: #e5e7eb; color: #374151; }

/* Ensure sticky column remains crisp on scroll */
.timeline-container td.bg-white[style*="position: sticky"] {
  box-shadow: 2px 0 0 #e5e7eb inset; /* subtle right divider */
}

/* === Column 1 Font Size Standardization === */
/* Override all Column 1 text to consistent 12px */
.timeline-container .col1-card .consultant-role-name,
.timeline-container .col1-card .consultant-role,
.timeline-container .col1-card .consultant-level,
.timeline-container .col1-card .assignment-location,
.timeline-container .col1-card .assignment-dates,
.timeline-container .col1-card .assignment-rate,
.timeline-container .col1-card .rate,
.timeline-container .col1-card .revenue,
.timeline-container .col1-card .margin,
.timeline-container .col1-card .forecast-effort-days,
.timeline-container .col1-card .metrics-row {
  font-size: 12px !important;
}

/* Consultant name link styling - remove blue, add subtle hover */
.timeline-container .col1-card .consultant-link {
  font-size: 12px !important;
  color: #111827 !important;
  text-decoration: none !important;
  font-weight: 600;
}

.timeline-container .col1-card .consultant-link:hover {
  color: #111827 !important;
  text-decoration: underline !important;
  text-decoration-color: #9ca3af;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* Make the sticky Column 1 wider on larger screens */
.timeline-container td.bg-white[style*="position: sticky"] {
  min-width: 240px; /* small bump for all screens */
}

@media (min-width: 1200px) {
  .timeline-container td.bg-white[style*="position: sticky"] {
    min-width: 300px; /* laptops / desktops */
  }
}

@media (min-width: 1600px) {
  .timeline-container td.bg-white[style*="position: sticky"] {
    min-width: 340px; /* large monitors */
  }
}

/* Reduce awkward wrapping for key rows */
.timeline-container .col1-card .metrics-row,
.timeline-container .col1-card .assignment-dates .value {
  white-space: nowrap;           /* keep rate/effort and dates on one line */
}

/* Slightly tighten vertical rhythm to offset added width */
.timeline-container .col1-card .meta-line,
.timeline-container .col1-card .metrics-row {
  margin-bottom: 4px;
}

/* === Column 1 Section Spacing Improvements === */
/* Add consistent vertical spacing between major sections */
.timeline-container .col1-card .c1-identity {
  margin-bottom: 12px;
}

.timeline-container .col1-card .c1-role {
  margin-bottom: 12px;
}

.timeline-container .col1-card .c1-financials {
  margin-bottom: 12px;
}

/* Consultant status badge spacing - add margin to create breathing room */
.timeline-container .col1-card .consultant-status {
  margin-top: 6px;
}

/* TBD (Unassigned) Badge Styling - professional pill design */
.timeline-container .col1-card .tbd-unassigned-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.3;
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

/* === Timeline Sticky Positioning System ===
 * Z-Index Stack (highest to lowest):
 *   40 - Top-left corner header cell (sticky on both axes)
 *   30 - Header row cells (sticky on top axis)
 *   20 - Frozen column cells (sticky on left axis)
 *   
 * This ensures proper layering when scrolling horizontally and vertically.
 * Uses --nav-h CSS variable (defined in root above) for navbar offset.
 */

/* Override design-refresh.css .table { overflow: hidden } which breaks sticky */
.timeline-table {
  overflow: visible !important;
}

/* Note: Timeline hover is disabled via :not(.timeline-table) exclusions in design-refresh.css */

/* Timeline container needs overflow visible so sticky can work during page scroll */
.timeline-container {
  overflow: visible !important;
  overflow-x: auto !important;
}

/* Sticky header row - stays visible during vertical scroll */
.timeline-container table thead th {
  position: sticky;
  top: var(--nav-h, 56px);
  z-index: 30;
  background: #fff;
  padding: 12px 8px;
  line-height: 1.4;
  vertical-align: middle;
}

/* Top-left corner cell: sticky on BOTH axes */
.timeline-container table thead th:first-child {
  position: sticky;
  left: 0;
  top: var(--nav-h, 56px);
  z-index: 40; /* highest - above both header row and frozen column */
  background: #fff;
}

/* Frozen first column - stays visible during horizontal scroll */
.timeline-frozen-col {
  position: sticky;
  left: 0;
  z-index: 20;
  background: #fff;
  min-width: 220px;
}

/* Remove responsive adjustments - widths now set dynamically by JS */

/* Restore inline table-row behaviour for the Timeline edit panel */
tr.edit-assignment-panel {
  display: table-row !important;
  position: static !important;
  right: auto !important;
  left: auto !important;
  top: auto !important;
  bottom: auto !important;
  transform: none !important;
  width: auto !important;
  height: auto !important;
  z-index: auto !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* Cell styling (keeps the original light inline look) */
tr.edit-assignment-panel > td {
  position: relative !important;
  background-color: #f8f9fa !important;
  border-left: 4px solid var(--psa-primary, #007bff) !important;
}

/* Neutralise sidebar responsive overrides when used as a table row */
@media (max-width: 1200px) {
  tr.edit-assignment-panel { width: auto !important; }
}
@media (max-width: 768px) {
  tr.edit-assignment-panel { width: auto !important; height: auto !important; }
}


/* Autocomplete Search Dropdown Styles */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1050;
    margin-top: 0.25rem;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.15s ease;
}

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

.autocomplete-item:hover {
    background-color: #f8f9fa;
}

.autocomplete-item:active {
    background-color: #e9ecef;
}

/* Filter Chips Styles */
.search-chips {
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    background-color: #0d6efd;
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    gap: 0.5rem;
}

.filter-chip-staged {
    background-color: #6c757d;
    border: 2px dashed #495057;
    opacity: 0.85;
}

.filter-chip-label {
    font-weight: 500;
}

.filter-chip-remove {
    background: none;
    border: none;
    color: white;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    opacity: 0.8;
    transition: opacity 0.15s ease;
}

.filter-chip-remove:hover {
    opacity: 1;
}

.filter-chip-remove i {
    font-size: 0.875rem;
}

/* ========== PROJECT CREATION WIZARD ========== */
/* Step indicator styling for the multi-step project creation wizard */

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.wizard-step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-bottom: 8px;
    background-color: #e9ecef;
    color: #6c757d;
}

.wizard-step.active .wizard-step-number {
    background-color: #0d6efd;
    color: white;
}

.wizard-step.completed .wizard-step-number {
    background-color: #198754;
    color: white;
}

.wizard-step-title {
    font-size: 0.875rem;
    text-align: center;
    color: #6c757d;
}

.wizard-step.active .wizard-step-title {
    color: #0d6efd;
    font-weight: 600;
}

.wizard-step.completed .wizard-step-title {
    color: #198754;
    font-weight: 600;
}

.wizard-connector {
    height: 2px;
    background-color: #e9ecef;
    flex: 1;
    margin: 0 20px;
    margin-top: 20px;
}

.wizard-connector.completed {
    background-color: #198754;
}

/* @mention autocomplete dropdown - system-wide */
.mention-autocomplete {
    position: absolute;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1060;
    display: none;
    min-width: 200px;
    top: 100%;
    left: 0;
    margin-top: 4px;
}
.mention-autocomplete.show {
    display: block;
}
.mention-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.mention-item:hover, .mention-item.selected {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
}
.mention-item-name {
    font-weight: 500;
}
.mention-item-role {
    font-size: 0.75rem;
    color: #6c757d;
}
.mention-autocomplete-wrapper {
    position: relative;
}

