/* ==========================================================================
   Resource Schedule - Grid Styles
   Schedule grid table, group headers, project rows, editing states
   ========================================================================== */

/* --- Grid Container --- */
#grid-container {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
}

/* Table is sized by an inline width set in JS (sum of label widths +
   weekCount * 52). Both 12-week and 52-week modes use the same fixed
   pixel widths for the label columns + Total; only the number of week
   columns differs between modes. */
#grid-container.grid-wide {
    max-height: calc(100vh - 320px); /* leave room for the bottom range track */
}
.schedule-grid {
    /* width set inline by JS */
}
/* Keep cells from expanding under their content */
.schedule-grid th,
.schedule-grid td {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.schedule-grid .cell-projectlong {
    white-space: normal;
}
/* Week headers stay on 2 lines (Wk N + date) */
.schedule-grid thead th.col-week-header {
    white-space: pre-line;
    text-overflow: clip;
}

/* --- Sticky-left columns (applies in BOTH 12-week and 52-week modes) ---
   The first 3 label columns + Total stay frozen as the user scrolls the
   week columns horizontally. JS sets `left: Xpx` inline based on the cell's
   logical column index; CSS just provides position/z-index/background. */
.schedule-grid .sticky-cell {
    position: sticky;
    z-index: 4;
    background-clip: padding-box;
    background-color: #fff; /* default body background for project rows */
}
/* Thead sticky cells (also top: 0 from existing thead rule) need higher z
   so they overlay both vertical and horizontal scrolling cells */
.schedule-grid thead .sticky-cell {
    z-index: 15;
}
/* Row-type-specific backgrounds on sticky cells so the row band continues
   across the frozen section without showing scrolled content underneath */
.schedule-grid tr.group-header .sticky-cell {
    background-color: var(--primary-light, #dce4f0);
}
.schedule-grid tr.group-no-assignments .sticky-cell {
    background-color: var(--gray-50, #f9fafb);
}
.schedule-grid tr.subgroup-header .sticky-cell {
    background-color: var(--gray-100, #f3f4f6);
}
.schedule-grid tr.jt-subgroup-header .sticky-cell {
    background-color: var(--gray-50, #f9fafb);
}
.schedule-grid .filter-row-header .sticky-cell {
    background-color: var(--gray-50, #f9fafb);
}

/* --- Unified full-row hover highlight ---
   A translucent primary overlay on EVERY cell of the hovered row (data rows
   AND group/subgroup/JT headers), including the frozen sticky columns. Uses an
   inset box-shadow so it layers on top of each row type's own background and
   reads as a consistent highlight regardless of base color — so it's always
   clear which row (and thus which ⋯ menu) the cursor is on. */
.schedule-grid tbody tr:hover > td {
    box-shadow: inset 0 0 0 9999px rgba(74, 109, 167, 0.10);
}
/* Total cell keeps its emphasized gray-100 background — col-total-cell
   already enforces this via !important */
/* Month-group label row: visible only in wide mode, sits above the week dates */
.schedule-grid thead th.col-month-group {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600, #4b5563);
    background: var(--gray-50, #f9fafb);
    border-bottom: 1px solid var(--gray-300, #d1d5db);
    padding: 3px 4px;
}
.schedule-grid thead th.col-month-group.week-month-start {
    border-left: 2px solid var(--gray-400, #9ca3af);
}

/* --- Job Title subgroup header (employee mode) --- */
.schedule-grid tr.jt-subgroup-header td {
    background: var(--gray-50, #f9fafb);
    color: var(--gray-700, #374151);
    font-size: 11px;
    font-weight: 500;
    /* Horizontal padding must match the other rows so right-aligned numbers
       line up vertically with project-row and group-header values. */
    padding: 3px 4px;
    border-top: 1px solid var(--gray-200, #e5e7eb);
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    cursor: pointer;
    user-select: none;
}
.schedule-grid tr.jt-subgroup-header td:first-child {
    padding-left: 28px; /* indent under employee row */
}
.schedule-grid tr.jt-subgroup-header .jt-subgroup-toggle {
    display: inline-block;
    width: 12px;
    color: var(--gray-500, #6b7280);
    font-size: 9px;
    margin-right: 4px;
}
.schedule-grid tr.jt-subgroup-header .jt-subgroup-name {
    font-weight: 600;
    color: var(--gray-800, #1f2937);
}
.schedule-grid tr.jt-subgroup-header .jt-subgroup-count {
    margin-left: 6px;
    color: var(--gray-400, #9ca3af);
    font-size: 10px;
    font-weight: 400;
}
.schedule-grid tr.jt-subgroup-header .jt-subgroup-total,
.schedule-grid tr.jt-subgroup-header .jt-subgroup-week {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--gray-700, #374151);
}
/* Project rows: first cell now only holds the × remove button.
   Centered with light padding so the × sits naturally in the narrow column. */
.schedule-grid tr.project-row td:first-child {
    padding-left: 8px;
    padding-right: 4px;
    text-align: center;
}

/* --- Summary block (Total · Bill Rate · Est. Rev) ---
   These three trailing columns are emphasized together so they read as one
   anchored summary block at the right end of every row. !important deliberately
   overrides row-level styling (gray bands on group/JT-subgroup rows) so the
   block always stands out. */
.schedule-grid .col-total-cell,
.schedule-grid .col-billrate-cell,
.schedule-grid .col-estrev-cell {
    background: var(--gray-100, #f3f4f6) !important;
    /* Pin horizontal padding so values right-align to the same pixel regardless
       of which row type owns the cell. */
    padding-left: 4px !important;
    padding-right: 6px !important;
}
/* Divider marking the start of the summary block (left edge of Total). */
.schedule-grid .col-total-cell {
    border-left: 2px solid var(--gray-400, #9ca3af) !important;
}
.schedule-grid thead th.col-total {
    font-weight: 700;
    background: var(--gray-100, #f3f4f6);
}
/* Match the Bill Rate / Est. Rev header font to the Total header (11px) — the
   trailing-cells rule sets 13px for the body values, but the column headers
   should read like the Total header. */
.schedule-grid thead th.col-billrate-cell,
.schedule-grid thead th.col-estrev-cell {
    font-size: var(--font-size-base);
    font-weight: 700;
}
.schedule-grid thead tr.month-group-row th.col-month-group-pad {
    background: var(--gray-50, #f9fafb);
}
/* Left border on the month row's trailing pad so the summary-block divider
   extends up into the month-label row, aligning with the Total cell's left border. */
.schedule-grid thead tr.month-group-row th.col-summary-pad {
    border-left: 2px solid var(--gray-400, #9ca3af);
}

/* --- Month boundary: vertical line where the calendar month changes --- */
.schedule-grid th.week-month-start,
.schedule-grid td.week-month-start {
    border-left: 2px solid var(--gray-400, #9ca3af);
}

/* --- Bottom 52-week range track --- */
#week-range-track {
    margin: 6px 12px 0;
    padding: 6px 8px;
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-200, #e5e7eb);
    font-size: 10px;
    color: var(--gray-600, #4b5563);
    user-select: none;
}
#week-range-track.hidden { display: none; }
#week-range-track .wrt-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 3px;
    color: var(--gray-500, #6b7280);
}
#week-range-track .wrt-track {
    position: relative;
    height: 18px;
    background: #fff;
    border: 1px solid var(--gray-200, #e5e7eb);
    cursor: pointer;
}
#week-range-track .wrt-cells {
    position: absolute;
    inset: 0;
    display: flex;
}
#week-range-track .wrt-cell {
    flex: 1;
    border-right: 1px solid var(--gray-100, #f3f4f6);
}
#week-range-track .wrt-cell:last-child { border-right: 0; }
#week-range-track .wrt-viewport {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(74, 109, 167, 0.20);
    border-left: 2px solid var(--primary, #4a6da7);
    border-right: 2px solid var(--primary, #4a6da7);
    pointer-events: none;
    transition: left 0.05s linear, width 0.05s linear;
}

/* --- Schedule Grid Table --- */
.schedule-grid {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 12px;
    line-height: 1.3;
}

/* --- Column Widths --- */
.schedule-grid .col-jtname      { width: 12%; }
.schedule-grid .col-projectpath { width: 14%; }
.schedule-grid .col-projectlong { width: 24%; }
.schedule-grid .col-week        { width: 4.5%; }
.schedule-grid .col-total       { width: 4%; }
.schedule-grid .col-billrate    { width: 5%; }
.schedule-grid .col-estrev      { width: 5%; }

/* --- Table Head --- */
.schedule-grid thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
}

.schedule-grid thead th {
    padding: var(--sp-2) var(--sp-2);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--gray-700);
    text-align: left;
    border-bottom: 2px solid var(--gray-300);
    vertical-align: bottom;
    white-space: nowrap;
    overflow: hidden;
    background: #fff;
}

.schedule-grid thead th.text-right {
    text-align: right;
}

/* Week column header: two-line date range */
.schedule-grid thead th.col-week-header {
    text-align: right;
    font-size: var(--font-size-sm);
    line-height: 1.3;
    white-space: pre-line;
    padding-left: 1px;
    padding-right: var(--sp-1);
}

/* --- Filter Row (second row in thead) --- */
.schedule-grid .filter-row-header th {
    padding: var(--sp-1) var(--sp-2);
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.schedule-grid .filter-row-header input {
    width: 100%;
    padding: var(--sp-1) var(--sp-2);
    font-size: var(--font-size-sm);
    border: 1px solid var(--gray-200);
    background: #fff;
    color: var(--gray-700);
    outline: none;
    border-radius: 0;
}

.schedule-grid .filter-row-header input:focus {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.schedule-grid .filter-row-header input::placeholder {
    color: var(--gray-400);
    font-style: italic;
}

/* --- Table Body --- */
.schedule-grid tbody {
    font-size: 12px;
}

/* --- Group Header Row (Employee) --- */
.schedule-grid .group-header {
    background: var(--primary-light);
    cursor: pointer;
    user-select: none;
}

.schedule-grid .group-header td {
    padding: 7px var(--sp-2);
    font-weight: 600;
    font-size: var(--font-size-md);
    color: var(--gray-800);
    border-bottom: 1px solid var(--gray-300);
    white-space: nowrap;
}

/* Toggle arrow */
.group-toggle {
    display: inline-block;
    width: 12px;
    font-size: 10px;
    color: var(--gray-600);
    margin-right: var(--sp-2);
    transition: transform 0.15s;
}

.group-toggle.collapsed {
    transform: rotate(0deg);
}

.group-toggle.expanded {
    transform: rotate(0deg);
}

/* Employee code badge */
.group-empcode {
    font-size: var(--font-size-base);
    font-weight: 400;
    color: var(--gray-500);
    margin-left: var(--sp-2);
}

/* Group header weekly total cells */
.group-header .group-week-total,
.subgroup-header .group-week-total {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: var(--font-size-md);
}

.group-header .group-total-sum,
.subgroup-header .group-total-sum {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: var(--font-size-md);
    font-weight: 700;
}

.group-header .group-estrev-sum,
.subgroup-header .group-estrev-sum {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: var(--font-size-md);
    font-weight: 700;
}

/* --- Subgroup Header Row (Project Mode Level 2) --- */
.schedule-grid .subgroup-header {
    background: var(--gray-100);
    cursor: pointer;
    user-select: none;
}

.schedule-grid .subgroup-header td {
    padding: 6px var(--sp-3);
    font-weight: 600;
    font-size: var(--font-size-md);
    color: var(--gray-800);
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.schedule-grid .subgroup-header td:first-child {
    padding-left: 28px;
}

.subgroup-toggle {
    display: inline-block;
    width: 12px;
    font-size: 9px;
    color: var(--gray-500);
    margin-right: var(--sp-2);
}

/* Project mode detail rows: indent further */
.schedule-grid .project-row-pm td:first-child {
    padding-left: 40px;
}

/* --- Overtime Highlighting --- */
.overtime-warning {
    background: var(--warning-light) !important;
    color: var(--warning-dark);
}

.overtime-severe {
    background: var(--danger-light) !important;
    color: var(--danger-dark);
    font-weight: 700;
}

/* --- Project Detail Rows --- */
.schedule-grid .project-row td {
    padding: 5px var(--sp-2);
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.schedule-grid .project-row:nth-child(odd) {
    background: var(--gray-50);
}

.schedule-grid .project-row:nth-child(even) {
    background: #fff;
}

/* Text columns */
.schedule-grid .project-row .cell-text {
    text-align: left;
    font-size: var(--font-size-md);
}

/* Remove-allocation button (× inside JT name cell) */
.cell-jtname {
    position: relative;
}

.row-remove-btn {
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 13px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-400);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 4px;
    vertical-align: middle;
    border-radius: 0;
    flex-shrink: 0;
}

.row-remove-btn:hover {
    color: var(--danger);
    background: var(--danger-light);
}

@media print {
    .row-remove-btn { display: none; }
}

/* --- Indent gutter (By-Employee col 0) ---
   Row actions moved into the ⋯ menu (right-aligned), so this column is now an
   empty indent gutter (width from LABEL_WIDTHS). No side borders so it reads as
   pure indentation, nesting detail rows under their Job Title subgroup. */
.cell-rowactions {
    border-left: none;
    border-right: none;
    white-space: nowrap;
}
/* Right-align the ⋯ actions menu against the Total column WITHOUT flexing the
   <td> (which breaks table layout). Float keeps the cell a table-cell. Applies
   to assignment rows (.cell-rowshift-right) AND group/subgroup header label
   cells, so every line's ⋯ lines up in the same vertical column. */
/* Pin the ⋯ button to a fixed offset from its cell's right edge so every line's
   button lands in one vertical column. Absolute positioning (anchored to the
   sticky cell, which is a positioning context) is independent of each cell's
   text padding — float:right was not, so buttons drifted between row types. */
.cell-rowshift-right .row-menu-btn,
.group-header td .row-menu-btn,
.subgroup-header td .row-menu-btn,
.jt-subgroup-header td .row-menu-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    float: none;
    margin-left: 0;
}
/* Reserve room on the right so the label text never flows under the button. */
.schedule-grid td.cell-rowshift-right,
.schedule-grid tr.group-header > td:first-child,
.schedule-grid tr.subgroup-header > td:first-child,
.schedule-grid tr.jt-subgroup-header > td:first-child {
    padding-right: 30px;
}
@media print {
    .row-menu-btn { display: none; }
}

/* --- Previous-week read-only columns (Prev Sched, Prev Actual) ---
   Sit just before week 1. Right-aligned like the week cells; a divider after
   Prev Actual separates last week from the current schedule window. */
.schedule-grid .col-prevsched,
.schedule-grid .col-prevactual {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: var(--font-size-md);
    /* Pin padding (with !important) so the values right-align to the same pixel
       on every row type — data rows otherwise inherit cell-readonly's smaller
       padding-right while header totals use the default, splaying the columns. */
    padding-left: 1px !important;
    padding-right: var(--sp-1) !important;
}
.schedule-grid td.col-prevactual,
.schedule-grid th.col-prevactual {
    border-right: 2px solid var(--gray-300, #d1d5db);
}
.schedule-grid thead th.col-prevsched,
.schedule-grid thead th.col-prevactual {
    font-size: var(--font-size-base);
    white-space: pre-line;   /* render the "\n" as a 2nd line: "Prev" / "Sch" */
    text-overflow: clip;
}

.schedule-grid .project-row .cell-projectlong {
    text-align: left;
    font-size: var(--font-size-md);
    color: var(--gray-700);
}

/* Numeric columns */
.schedule-grid .project-row .cell-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: var(--font-size-md);
}

/* Trailing summary columns (Bill Rate, Est. Rev) — right-align in every row
   context (data rows AND group/subgroup/BT header rows). Weight/background are
   set by the shared summary-block rule above. */
.schedule-grid .col-billrate-cell,
.schedule-grid .col-estrev-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: var(--font-size-md);
}

/* --- Week Cell Compact Padding --- */
.cell-editable,
.cell-readonly,
.group-week-total {
    padding-left: 1px !important;
    padding-right: var(--sp-1) !important;
    font-size: var(--font-size-md);
}

/* --- Editable Week Cells --- */
.cell-editable {
    cursor: pointer;
    /* No text selection — clicks drive edit / multi-select, not text dragging. */
    user-select: none;
    -webkit-user-select: none;
    text-align: right;
    font-variant-numeric: tabular-nums;
    transition: background 0.1s;
}

.cell-editable:hover {
    background: var(--primary-bg);
}

/* --- Editing States --- */
.cell-editing {
    padding: 0 !important;
    border: 2px solid var(--primary) !important;
    background: #fff !important;
}

.cell-editing input {
    width: 100%;
    height: 100%;
    min-height: 22px;
    padding: var(--sp-1) var(--sp-2);
    text-align: right;
    font-size: var(--font-size-md);
    font-variant-numeric: tabular-nums;
    font-family: var(--font-family);
    border: none;
    outline: none;
    background: #fff;
    color: var(--gray-800);
    border-radius: 0;
}

.cell-saving {
    cursor: wait !important;
    color: var(--gray-400) !important;
    background: var(--gray-50) !important;
}

/* Flash green on success */
.cell-success {
    animation: flash-green 0.6s ease-out;
}

@keyframes flash-green {
    0% { background: var(--success-light); }
    100% { background: transparent; }
}

/* Flash red on error */
.cell-error {
    animation: flash-red 0.6s ease-out;
}

@keyframes flash-red {
    0% { background: var(--danger-light); }
    100% { background: transparent; }
}

/* Retry state */
.cell-retry {
    background: var(--warning-light) !important;
}

/* --- Read-Only Cells (Non-Editable Week Cells) --- */
.cell-readonly {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--gray-500);
}

/* --- "No Assignments" Group --- */
/* Both classes are on the same <tr> element */
.group-header.group-no-assignments {
    background: var(--gray-100);
    font-style: italic;
}

.group-header.group-no-assignments td {
    color: var(--gray-500);
    font-weight: 500;
}

/* Project rows after a No Assignments header */
.group-no-assignments ~ .project-row td {
    color: var(--gray-400);
}

/* --- Collapsed Group: Hide Project Rows --- */
.group-collapsed .project-row {
    display: none;
}

/* --- Status Bar (footer) --- */
.grid-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--font-size-sm);
    color: var(--gray-500);
    background: #fff;
    border-top: 1px solid var(--gray-200);
}

.grid-status-bar .status-left {
    display: flex;
    gap: var(--sp-4);
}

.grid-status-bar .status-right {
    color: var(--gray-400);
}

/* --- Empty State --- */
.grid-empty {
    padding: 40px var(--sp-5);
    text-align: center;
    color: var(--gray-500);
    font-size: var(--font-size-md);
}

.grid-empty p {
    margin-bottom: var(--sp-3);
}

.grid-empty .grid-empty-hint {
    font-size: var(--font-size-base);
    color: var(--gray-400);
}

/* --- Multi-cell selection + bulk-fill bar --- */
.schedule-grid .cell-editable.cell-selected {
    background: rgba(74, 109, 167, 0.18) !important;
    box-shadow: inset 0 0 0 1px var(--primary, #4a6da7);
}

#bulk-fill-bar {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-800, #1f2937);
    color: #fff;
    padding: 8px 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    z-index: 50;
    font-size: var(--font-size-md);
}
#bulk-fill-bar.hidden { display: none; }
#bulk-fill-bar .bfb-count { font-weight: 600; white-space: nowrap; }
#bulk-fill-bar .bfb-input {
    width: 72px;
    padding: 3px 6px;
    border: 1px solid var(--gray-400, #9ca3af);
    font-size: var(--font-size-md);
    font-variant-numeric: tabular-nums;
    text-align: right;
}
#bulk-fill-bar button {
    padding: 4px 10px;
    font-size: var(--font-size-md);
    cursor: pointer;
    border: 1px solid transparent;
}
#bulk-fill-bar .bfb-apply { background: var(--primary, #4a6da7); color: #fff; }
#bulk-fill-bar .bfb-apply:hover { background: var(--primary-dark, #3b5998); }
#bulk-fill-bar .bfb-spread { background: var(--info, #6b8db5); color: #fff; }
#bulk-fill-bar .bfb-spread:hover { background: var(--primary, #4a6da7); }
#bulk-fill-bar .bfb-clear { background: transparent; color: #fff; border-color: var(--gray-500, #6b7280); }
#bulk-fill-bar button:disabled { opacity: 0.5; cursor: default; }

/* --- "Roll Unused Hours" button (in the month-row, over the prev columns) --- */
.schedule-grid thead th.col-roll-pad {
    padding: 2px;
    text-align: center;
    vertical-align: middle;
    background: var(--gray-50, #f9fafb);
    border-bottom: 1px solid var(--gray-300, #d1d5db);
}
.roll-unused-btn {
    width: 100%;
    font-size: 9px;
    line-height: 1.15;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    padding: 3px 2px;
    background: var(--primary, #4a6da7);
    color: #fff;
    border: none;
    cursor: pointer;
    white-space: normal;
}
.roll-unused-btn:hover { background: var(--primary-dark, #3b5998); }

/* --- Roll confirmation modal --- */
.roll-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
}
.roll-modal {
    background: #fff;
    width: 1040px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.roll-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--primary, #4a6da7);
    color: #fff;
}
.roll-head .roll-title { font-size: var(--font-size-lg, 16px); font-weight: 700; }
.roll-head .roll-close {
    background: transparent; border: none; color: #fff;
    font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.roll-sub {
    padding: 10px 14px;
    font-size: var(--font-size-md);
    color: var(--gray-700, #374151);
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
}
.roll-body { overflow-y: auto; overflow-x: hidden; padding: 0; }
.roll-table { width: 100%; border-collapse: collapse; font-size: var(--font-size-base); table-layout: fixed; }
.roll-table th, .roll-table td {
    padding: 3px 8px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Checkbox column: narrow + centered. */
.roll-table .roll-check { width: 30px; text-align: center; padding-left: 4px; padding-right: 4px; }
.roll-table .roll-check input { cursor: pointer; }
/* Text columns wrap instead of forcing horizontal scroll. */
.roll-table .roll-emp { width: 22%; white-space: normal; }
.roll-table .roll-proj { width: 34%; white-space: normal; }
.roll-table .num { width: 11%; }
.roll-table thead th {
    position: sticky; top: 0;
    background: var(--gray-100, #f3f4f6);
    font-weight: 700; color: var(--gray-700, #374151);
}
.roll-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.roll-table .roll-unused-val { font-weight: 700; color: var(--primary-dark, #3b5998); }
.roll-table tbody tr:hover td { background: var(--primary-bg, #f2f5fa); }
.roll-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--gray-200, #e5e7eb);
}
.roll-foot button { padding: 6px 14px; font-size: var(--font-size-md); cursor: pointer; border: 1px solid transparent; }
.roll-foot .roll-cancel { background: transparent; border-color: var(--gray-300, #d1d5db); color: var(--gray-700, #374151); }
.roll-foot .roll-confirm { background: var(--primary, #4a6da7); color: #fff; }
.roll-foot .roll-confirm:hover { background: var(--primary-dark, #3b5998); }
.roll-foot button:disabled { opacity: 0.6; cursor: default; }

/* --- Grand totals row (tfoot), sticky to the bottom of the scroll area --- */
.schedule-grid tfoot .grid-totals-row td {
    position: sticky;
    bottom: 0;
    background: var(--gray-200, #e5e7eb);
    font-weight: 700;
    color: var(--gray-800, #1f2937);
    border-top: 2px solid var(--gray-500, #6b7280);
    z-index: 6;
    font-size: var(--font-size-md);
    text-align: right;
    font-variant-numeric: tabular-nums;
}
/* Week-total cells match the week-column cells' compact padding so the totals
   line up vertically under each week. */
.schedule-grid tfoot .grid-totals-row td.totals-week {
    padding-left: 1px !important;
    padding-right: var(--sp-1) !important;
}
/* The label cell is also sticky-left (corner) — keep it above its neighbours. */
.schedule-grid tfoot .grid-totals-row td.totals-label {
    z-index: 16;
    text-align: right;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: var(--font-size-base);
    color: var(--gray-700, #374151);
    padding-right: 10px;
}
/* Override the summary block's gray-100 so the whole totals row reads as one band. */
.schedule-grid tfoot .grid-totals-row .col-total-cell,
.schedule-grid tfoot .grid-totals-row .col-billrate-cell,
.schedule-grid tfoot .grid-totals-row .col-estrev-cell {
    background: var(--gray-200, #e5e7eb) !important;
}
