.muted-text {
    color: #667085;
    font-size: 0.95rem;
}

#timesheetApp {
    margin-top: 18px;
    min-width: 0;
    overflow-x: visible;
    overflow-y: visible;
}

.timesheet-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.timesheet-sidebar,
.timesheet-panel {
    background: #fff;
    border: 1px solid #dbe4ee;
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
}

.timesheet-sidebar {
    padding: 18px;
    position: sticky;
    top: 16px;
}

.timesheet-sidebar-title,
.timesheet-kicker {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #b54708;
}

.timesheet-report-list,
.timesheet-main {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.timesheet-report-card {
    width: 100%;
    text-align: left;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    padding: 14px;
    cursor: pointer;
}

.timesheet-report-card.active {
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}

.timesheet-report-date {
    font-weight: 700;
    color: #101828;
}

.timesheet-report-site {
    margin-top: 6px;
    color: #111827;
}

.timesheet-report-foreman {
    margin-top: 4px;
    color: #667085;
    font-size: 0.92rem;
}

.timesheet-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 700;
}

.timesheet-pill.is-filled {
    background: #dcfce7;
    color: #166534;
}

.timesheet-pill.is-missing {
    background: #fee2e2;
    color: #991b1b;
}

.timesheet-panel {
    padding: 20px;
    min-width: 0;
}

.timesheet-meta,
.timesheet-editor-header,
.timesheet-owner-filters,
.timesheet-actions,
.timesheet-grid {
    display: grid;
    gap: 12px;
}

.timesheet-meta {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid #edf2f7;
}

.timesheet-meta h3 {
    margin: 4px 0 0;
    font-size: 1.35rem;
}

.timesheet-meta-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    justify-content: flex-end;
    color: #475467;
    font-size: 0.95rem;
}

.timesheet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.timesheet-form label {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
    color: #344054;
    font-weight: 600;
}

.timesheet-form input,
.timesheet-form textarea,
.timesheet-owner-filters input,
.timesheet-owner-filters select {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    padding: 11px 12px;
    background: #fff;
    font: inherit;
}

.timesheet-form textarea {
    resize: vertical;
}

.timesheet-actions {
    justify-content: end;
}

.timesheet-actions-bottom {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #edf2f7;
}

.timesheet-table-wrap {
    overflow-x: auto;
    max-width: 100%;
}

.timesheet-photo-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #edf2f7;
}

.timesheet-photo-help {
    margin: 8px 0 12px;
    color: #667085;
}

.timesheet-photo-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.timesheet-photo-form input[type="file"] {
    flex: 1 1 260px;
}

.timesheet-required {
    color: #dc2626;
    font-weight: 800;
}

.timesheet-photo-pending {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.timesheet-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.timesheet-save-status {
    margin: 0 0 10px;
    padding: 10px 14px;
    border-radius: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-size: 0.92rem;
    font-weight: 700;
    text-align: center;
}

.timesheet-save-status.is-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.timesheet-save-status.is-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid rgba(29, 78, 216, 0.25);
    border-top-color: #1d4ed8;
    animation: timesheetSpin 0.8s linear infinite;
}

.timesheet-actions button[disabled] {
    opacity: 0.85;
    cursor: wait;
    box-shadow: none;
}

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

.timesheet-photo-card {
    display: grid;
    gap: 8px;
}

.timesheet-photo-caption {
    color: #667085;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
}

.timesheet-photo-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
}

.timesheet-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.timesheet-table th,
.timesheet-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #edf2f7;
    text-align: left;
    vertical-align: top;
}

.timesheet-table th {
    color: #475467;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.timesheet-table .active-row {
    background: #fff7ed;
}

.timesheet-owner-filters {
    grid-template-columns: 180px minmax(240px, 1fr) 180px;
    margin-bottom: 16px;
}

.timesheet-empty,
.timesheet-empty-cell {
    padding: 24px;
    color: #667085;
    text-align: center;
}

.timesheet-owner-groups {
    display: grid;
    gap: 16px;
}

.timesheet-week-card,
.timesheet-day-card {
    margin-bottom: 0;
}

.timesheet-week-header,
.timesheet-day-header {
    cursor: pointer;
}

.timesheet-week-body {
    display: none;
    padding-top: 12px;
}

.timesheet-day-card {
    border: 1px solid #e4e7ec;
    border-radius: 16px;
    background: #fff;
    padding: 0;
    margin-top: 14px;
}

.timesheet-day-body {
    display: none;
    padding: 0 14px 14px;
}

.timesheet-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
    margin-bottom: 18px;
}

.timesheet-preview-block {
    margin-top: 14px;
}

.timesheet-preview-block p {
    margin: 8px 0 0;
    line-height: 1.5;
    white-space: pre-wrap;
}

.timesheet-preview-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.timesheet-preview-photo {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #dbe4ee;
    cursor: pointer;
}

.mobile-timesheet-modal[hidden] {
    display: none !important;
}

.mobile-timesheet-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: flex-start;
    background: rgba(2, 6, 23, 0.52);
    backdrop-filter: blur(6px);
    overflow: hidden;
}

.mobile-timesheet-sheet {
    width: 100%;
    min-height: 100dvh;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 14px calc(118px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
    background: #f8fbff;
    box-shadow: none;
}

.mobile-timesheet-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: space-between;
    align-items: start;
    gap: 10px;
    margin-bottom: 12px;
}

#mobileTimesheetTitle {
    min-width: 0;
    line-height: 1.15;
    word-break: break-word;
}

.mobile-timesheet-body {
    display: grid;
    gap: 12px;
}

.timesheet-mobile-modal-summary {
    display: grid;
    gap: 6px;
    margin-bottom: 10px;
}

.timesheet-mobile-modal-summary h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
}

@media (max-width: 1200px) {
    .timesheet-layout {
        grid-template-columns: 1fr;
    }

    .timesheet-sidebar {
        position: static;
    }

    .timesheet-preview-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    #tab-tasks {
        overflow: visible;
    }

    #timesheetApp {
        margin-top: 6px;
        padding-bottom: 10px;
    }

    .timesheet-sidebar,
    .timesheet-panel {
        padding: 12px;
        border-radius: 16px;
    }

    .timesheet-kicker,
    .timesheet-sidebar-title {
        font-size: 0.68rem;
        letter-spacing: 0.08em;
    }

    .timesheet-report-list {
        display: grid;
        gap: 10px;
        overflow: visible;
        padding-bottom: 0;
        scroll-snap-type: none;
    }

    .timesheet-report-card {
        width: 100%;
        min-height: 108px;
        padding: 10px;
        border-radius: 12px;
    }

    .timesheet-meta,
    .timesheet-grid,
    .timesheet-owner-filters {
        grid-template-columns: 1fr;
    }

    .timesheet-meta-list {
        justify-content: flex-start;
        gap: 6px 10px;
        font-size: 0.86rem;
    }

    .timesheet-meta {
        gap: 8px;
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    .timesheet-meta h3 {
        font-size: 0.96rem;
        line-height: 1.2;
        word-break: break-word;
        letter-spacing: -0.02em;
    }

    .timesheet-editor-header {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .timesheet-actions {
        justify-content: stretch;
    }

    .timesheet-actions button {
        width: 100%;
    }

    .timesheet-form label {
        gap: 5px;
        margin-bottom: 8px;
        font-size: 0.86rem;
    }

    .timesheet-form input,
    .timesheet-form textarea,
    .timesheet-owner-filters input,
    .timesheet-owner-filters select {
        padding: 9px 10px;
        border-radius: 10px;
        font-size: 14px;
    }

    .timesheet-form textarea {
        min-height: 72px;
    }

    .timesheet-photo-section {
        margin-top: 10px;
        padding-top: 10px;
    }

    .timesheet-photo-help {
        font-size: 0.8rem;
        line-height: 1.3;
        margin-bottom: 8px;
    }

    .timesheet-photo-form {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .timesheet-photo-form input[type="file"] {
        width: 100%;
        min-width: 0;
    }

    .timesheet-photo-grid,
    .timesheet-photo-pending {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .timesheet-actions-bottom {
        position: static;
        z-index: auto;
        padding-top: 8px;
        background: transparent;
    }

    .timesheet-table-wrap {
        overflow: visible;
    }

    .timesheet-main,
    #timesheetDetail {
        display: none;
    }

    .timesheet-panel-mobile {
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
    }

    .timesheet-meta-mobile {
        margin-bottom: 8px;
        padding-bottom: 8px;
    }

    .timesheet-editor-header-mobile {
        gap: 6px;
        padding: 8px 10px;
        border: 1px solid #e5edf6;
        border-radius: 12px;
        background: #f8fbff;
        margin-bottom: 8px;
    }

    .timesheet-form-mobile {
        display: grid;
        gap: 8px;
    }

    .timesheet-mobile-stats {
        gap: 8px;
        margin-bottom: 2px;
    }

    .timesheet-mobile-stat,
    .timesheet-mobile-section {
        margin: 0;
        padding: 10px;
        border: 1px solid #e5edf6;
        border-radius: 12px;
        background: #fbfdff;
    }

    .timesheet-mobile-stat span,
    .timesheet-mobile-section span {
        display: block;
        margin-bottom: 5px;
        color: #5d7290;
        font-size: 0.7rem;
        font-weight: 800;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .timesheet-mobile-stat input,
    .timesheet-mobile-section textarea {
        margin-top: 0;
    }

    .timesheet-photo-section-mobile {
        padding: 10px;
        border: 1px solid #e5edf6;
        border-radius: 12px;
        background: #fbfdff;
    }

    .timesheet-mobile-crew {
        display: grid;
        gap: 6px;
        margin-bottom: 8px;
    }

    .timesheet-mobile-crew-list {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 2px;
        scroll-snap-type: x proximity;
    }

    .timesheet-mobile-crew-card {
        flex: 0 0 148px;
        min-width: 148px;
        padding: 10px;
        border: 1px solid #dbe4ee;
        border-radius: 12px;
        background: #fff;
        text-align: left;
        display: grid;
        gap: 3px;
        box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04);
        scroll-snap-align: start;
        color: #17304f;
    }

    .timesheet-mobile-crew-card.active {
        border-color: #245ddd;
        background: linear-gradient(180deg, #eef4ff 0%, #f8fbff 100%);
        box-shadow: 0 0 0 2px rgba(36, 93, 221, 0.14);
    }

    .timesheet-mobile-crew-card strong {
        color: #17304f;
        font-size: 0.92rem;
        line-height: 1.15;
    }

    .timesheet-mobile-crew-card span:not(.timesheet-pill) {
        color: #667085;
        font-size: 0.78rem;
    }

    .timesheet-mobile-crew-card .timesheet-pill {
        margin-top: 6px;
        width: fit-content;
    }

    .timesheet-table {
        min-width: 0;
        border: 0;
        background: transparent;
    }

    .timesheet-table thead {
        display: none;
    }

    .timesheet-table tbody {
        display: grid;
        gap: 12px;
    }

    .timesheet-table tr {
        display: block;
        padding: 12px;
        border: 1px solid #dbe4ee;
        border-radius: 18px;
        background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
        box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
    }

    .timesheet-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 9px 0;
        border-bottom: 1px solid #edf2f7;
        white-space: normal;
        word-break: break-word;
    }

    .timesheet-table td:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }

    .timesheet-table td::before {
        content: "";
        flex: 0 0 88px;
        color: #667085;
        font-size: 0.74rem;
        font-weight: 800;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .timesheet-table td:nth-child(1)::before { content: "Worker"; }
    .timesheet-table td:nth-child(2)::before { content: "Role"; }
    .timesheet-table td:nth-child(3)::before { content: "Safety"; }
    .timesheet-table td:nth-child(4)::before { content: "Timesheet"; }
    .timesheet-table td:nth-child(5)::before { content: "Hours"; }
    .timesheet-table td:nth-child(6)::before { content: "Work"; }
    .timesheet-table td:nth-child(7)::before { content: "Action"; }

    .timesheet-day-body td:nth-child(1)::before { content: "Job Site"; }
    .timesheet-day-body td:nth-child(2)::before { content: "Foreman"; }
    .timesheet-day-body td:nth-child(3)::before { content: "Worker"; }
    .timesheet-day-body td:nth-child(4)::before { content: "Safety"; }
    .timesheet-day-body td:nth-child(5)::before { content: "Timesheet"; }
    .timesheet-day-body td:nth-child(6)::before { content: "Hours"; }
    .timesheet-day-body td:nth-child(7)::before { content: "Details"; }

    .mobile-timesheet-head {
        position: sticky;
        top: 0;
        z-index: 5;
        margin: -14px -14px 12px;
        padding: 14px 14px 10px;
        background: #f8fbff;
    }

    #mobileTimesheetCloseBtn {
        background: linear-gradient(180deg, #ff5c5c 0%, #d93333 100%);
        color: #fff;
        box-shadow: 0 10px 20px rgba(217, 51, 51, 0.18);
        width: auto;
        min-width: 112px;
        padding-inline: 18px;
        justify-self: end;
    }
}

@media (max-width: 640px) {
    #tab-tasks .section-header {
        gap: 4px;
        margin-bottom: 8px;
    }

    #tab-tasks .section-header h2 {
        font-size: 20px;
    }

    #timesheetRoleHint {
        font-size: 0.84rem;
        line-height: 1.3;
    }

    .timesheet-sidebar,
    .timesheet-panel {
        padding: 10px;
        border-radius: 14px;
    }

    .timesheet-report-card {
        width: 100%;
        min-height: auto;
    }

    .timesheet-meta-list {
        display: grid;
        gap: 6px;
    }

    .timesheet-pill {
        max-width: 100%;
        white-space: normal;
    }

    .timesheet-grid {
        gap: 6px;
    }

    .timesheet-meta {
        margin-bottom: 8px;
        padding-bottom: 8px;
    }

    .timesheet-form textarea {
        min-height: 64px;
    }

    .timesheet-mobile-stat,
    .timesheet-mobile-section,
    .timesheet-photo-section-mobile {
        padding: 8px;
        border-radius: 10px;
    }

    .timesheet-mobile-crew-card {
        flex-basis: 132px;
        min-width: 132px;
    }

    .mobile-timesheet-sheet {
        padding: 10px 10px calc(118px + env(safe-area-inset-bottom, 0px));
    }

    .mobile-timesheet-head {
        margin: -10px -10px 10px;
        padding: 10px 10px 8px;
    }

    .mobile-timesheet-sheet {
        border-radius: 0;
    }

    .timesheet-photo-grid,
    .timesheet-photo-pending {
        grid-template-columns: 1fr;
    }

    .timesheet-table td {
        flex-direction: column;
        gap: 6px;
        text-align: left;
    }

    .timesheet-table td::before {
        flex-basis: auto;
    }

    .timesheet-day-body .timesheet-table td:nth-child(1),
    .timesheet-day-body .timesheet-table td:nth-child(2),
    .timesheet-day-body .timesheet-table td:nth-child(4),
    .timesheet-day-body .timesheet-table td:nth-child(5),
    .timesheet-day-body .timesheet-table td:nth-child(6) {
        display: none;
    }

    .timesheet-day-body .timesheet-table tr {
        padding: 12px;
    }

    .timesheet-day-body .timesheet-table td:nth-child(3),
    .timesheet-day-body .timesheet-table td:nth-child(7) {
        display: flex;
    }

    .timesheet-day-body .timesheet-table td:nth-child(3)::before {
        content: "Worker";
    }

    .timesheet-day-body .timesheet-table td:nth-child(7)::before {
        content: "Details";
    }

    .timesheet-day-body .timesheet-table td:nth-child(7) button {
        width: 100%;
    }

    #tab-tasks,
    #timesheetApp,
    .timesheet-main {
        padding-bottom: 32px;
    }
}
