#tab-hours table,
#tab-hours thead tr,
#tab-hours tbody tr,
#tab-hours td,
#tab-hours th {
    all: unset;
    display: revert;
}









/* ============================================================
   DAILY SAFETY REPORTS — ORIGINAL LAYOUT + DARK THEME SUPPORT
============================================================ */

#dailySafetyContainer {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid var(--border-soft, #e5e7eb);
    border-radius: 10px;
    background: var(--bg-card, #f9fafb);
}

#dailySafetyContainer h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 18px;
    color: var(--text-main, #111);
}

#dailySafetyContainer h4 {
    margin-top: 18px;
    margin-bottom: 8px;
    font-size: 16px;
    color: var(--text-main, #111);
}

/* ============================================================
   LIST ITEMS
============================================================ */

.safety-report-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.safety-report-item {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-soft, #e5e7eb);
    background: var(--bg-card, #ffffff);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.safety-report-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.safety-report-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.safety-report-date {
    font-weight: 600;
    color: var(--text-main, #111);
}

.safety-report-jobsite {
    color: var(--text-muted, #374151);
}

.safety-report-foreman {
    color: var(--text-muted, #6b7280);
    font-size: 13px;
}

.safety-report-meta {
    color: var(--text-muted, #4b5563);
    font-size: 13px;
}

.safety-report-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.safety-report-actions .top-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ============================================================
   BUTTONS
============================================================ */

button.primary {
    background: var(--btn-primary-bg, #2563eb) !important;
    color: #fff !important;
    border: none !important;
    padding: 7px 12px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    font-size: 13px !important;
}

button.primary:hover {
    background: var(--btn-primary-hover, #1d4ed8) !important;
}

button.secondary {
    background: var(--bg-tab, #e5e7eb) !important;
    border: 1px solid var(--border-soft, #d1d5db) !important;
    padding: 7px 12px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-size: 13px !important;
}

button.secondary:hover {
    background: var(--border-soft, #d1d5db) !important;
}

button.danger,
button.logout,
button.back-danger {
    background: var(--btn-danger-bg, #dc2626) !important;
    color: #fff !important;
    border: none !important;
    padding: 7px 12px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    cursor: pointer !important;
}

button.danger:hover,
button.logout:hover,
button.back-danger:hover {
    background: #b91c1c !important;
}

/* ============================================================
   STATUS BADGES
============================================================ */

.status-btn {
    padding: 5px 10px !important;
    border-radius: 999px !important;
    font-weight: 600 !important;
    border: none !important;
    display: inline-block !important;
    font-size: 12px !important;
}

.status-pending {
    background: #e0ecff !important;
    color: #1d4ed8 !important;
}

.status-submitted {
    background: #dcfce7 !important;
    color: #15803d !important;
}

.badge {
    padding: 3px 8px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    display: inline-block !important;
}

.badge-green {
    background: #d1fae5 !important;
    color: #065f46 !important;
    border: 1px solid #a7f3d0 !important;
}

.badge-red {
    background: #fee2e2 !important;
    color: #991b1b !important;
    border: 1px solid #fecaca !important;
}

.badge-blue {
    background: #e0ecff !important;
    color: #1d4ed8 !important;
    border: 1px solid #bfdbfe !important;
}

/* ============================================================
   EDITOR / DETAILS
============================================================ */

#foremanReportEditor,
#workerSafetyList,
#ownerSafetyList {
    margin-top: 16px;
    padding: 14px;
    border: 1px solid var(--border-soft, #e5e7eb);
    border-radius: 10px;
    background: var(--bg-card, #ffffff);
}

/* ============================================================
   TABLE
============================================================ */

.safety-table-header {
    display: grid;
    grid-template-columns: 140px 1fr 120px 120px 120px 100px;
    font-weight: 600;
    padding: 10px;
    background: var(--bg-table-header, #f3f4f6);
    border-radius: 8px;
    margin-bottom: 8px;
}

.safety-row {
    display: grid;
    grid-template-columns: 140px 1fr 120px 120px 120px 100px;
    padding: 10px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-soft, #e5e7eb);
    border-radius: 8px;
    margin-bottom: 6px;
    align-items: center;
    font-size: 14px;
}

.safety-create-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    padding: 16px 18px;
    margin-bottom: 16px;
    border: 1px solid #d9e2f2;
    border-radius: 14px;
    background: linear-gradient(180deg, #fdfefe 0%, #f4f8ff 100%);
}

.safety-create-toolbar-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.safety-create-toolbar-copy strong {
    font-size: 16px;
    color: #0f2347;
}

.safety-create-toolbar-copy span {
    color: #5e6f8f;
    font-size: 13px;
}

.safety-create-toolbar-control {
    min-width: 250px;
}

.safety-create-toolbar-control label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #506684;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.safety-create-toolbar-control select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #c7d5eb;
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
    color: #15284a;
}

.safety-paper-frame {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
}

.safety-paper-frame::-webkit-scrollbar {
    height: 10px;
}

.safety-paper-frame::-webkit-scrollbar-thumb {
    background: #cad6ea;
    border-radius: 999px;
}

.safety-paper {
    min-width: 860px;
    border: 1px solid #cfd6e4;
    border-radius: 14px;
    background: #fff;
    padding: 18px;
    box-shadow: 0 18px 34px rgba(30, 64, 175, 0.08);
}

.safety-paper-readonly {
    box-shadow: none;
}

.safety-paper-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #a9b7cf;
    margin-bottom: 8px;
}

.safety-paper-header-copy {
    display: flex;
    align-items: center;
    gap: 8px;
}

.safety-paper-mark {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    background: url('../safety/field-risk-logo.png') center / contain no-repeat;
}

.safety-paper-brand {
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    color: #1e293b;
}

.safety-paper-mini {
    margin-top: 2px;
    font-size: 10px;
    color: #6b7280;
    letter-spacing: 0.04em;
}

.safety-paper-sub {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    text-align: right;
}

.safety-paper-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid #7b8799;
    border-bottom: none;
    margin-bottom: 12px;
}

.safety-paper-meta label,
.safety-paper-meta-readonly > div {
    display: grid;
    grid-template-columns: 180px 1fr;
    align-items: stretch;
    border-bottom: 1px solid #7b8799;
}

.safety-paper-meta label span,
.safety-paper-meta-readonly > div span {
    padding: 7px 8px;
    border-right: 1px solid #7b8799;
    background: #f9fafb;
    font-size: 11px;
    font-weight: 700;
}

.safety-paper-meta label input,
.safety-paper-meta-readonly > div strong {
    min-width: 0;
    padding: 7px 8px;
    font-size: 12px;
    border: none;
    border-radius: 0;
    background: #fff;
    color: #111827;
}

.safety-paper-meta label:nth-child(2),
.safety-paper-meta label:nth-child(4),
.safety-paper-meta label:nth-child(6),
.safety-paper-meta-readonly > div:nth-child(2),
.safety-paper-meta-readonly > div:nth-child(4),
.safety-paper-meta-readonly > div:nth-child(6) {
    grid-template-columns: 90px minmax(120px, 1fr);
}

.safety-paper-meta label input:focus {
    outline: 2px solid #bfd3ff;
    outline-offset: -2px;
}

.safety-paper-title {
    margin-bottom: 7px;
    font-size: 11px;
    font-weight: 700;
    color: #111827;
}

.safety-paper-checks {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 14px;
}

.safety-paper-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.safety-template-group-title {
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 800;
    color: #111827;
    text-transform: uppercase;
}

.safety-template-subtitle {
    margin: 4px 0 2px 24px;
    font-size: 11px;
    color: #475569;
}

.safety-template-check {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 6px;
    align-items: start;
    margin-bottom: 2px;
    font-size: 11px;
    color: #1f2937;
}

.safety-template-checkbox {
    width: 14px;
    height: 14px;
    margin-top: 2px;
}

.safety-template-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    font-size: 14px;
    line-height: 1;
}

.safety-paper-table {
    border: 1px solid #7b8799;
    margin-bottom: 14px;
}

.safety-paper-table-head,
.safety-paper-table-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1.4fr;
}

.safety-paper-table-head-edit,
.safety-paper-table-row-edit {
    grid-template-columns: 1.1fr 1fr 1.35fr 1.1fr 1fr 1.35fr;
}

.safety-paper-table-head > div {
    padding: 7px 8px;
    border-right: 1px solid #7b8799;
    background: #f9fafb;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.safety-paper-table-head > div:last-child,
.safety-paper-table-row > *:last-child {
    border-right: none;
}

.safety-paper-table-row {
    border-top: 1px solid #7b8799;
}

.safety-paper-table-row input,
.safety-paper-table-row-readonly > div {
    min-width: 0;
    min-height: 38px;
    padding: 8px;
    border: none;
    border-right: 1px solid #7b8799;
    border-radius: 0;
    background: #fff;
    font-size: 12px;
}

.safety-paper-table-row input:focus {
    outline: 2px solid #bfd3ff;
    outline-offset: -2px;
}

.safety-paper-signatures {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.safety-paper-sign-note {
    font-size: 11px;
    color: #475569;
}

.safety-paper-worker-grid {
    border: 1px solid #7b8799;
}

.safety-paper-worker-head,
.safety-paper-worker-row {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr 1.2fr 0.8fr;
}

.safety-paper-worker-head span,
.safety-paper-worker-row span {
    min-height: 34px;
    padding: 7px 8px;
    border-right: 1px solid #7b8799;
    border-top: 1px solid #7b8799;
    font-size: 12px;
}

.safety-paper-worker-head span {
    background: #f9fafb;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.safety-paper-worker-head span:nth-child(4),
.safety-paper-worker-row span:nth-child(4) {
    border-right: none;
}

.safety-paper-worker-head span {
    border-top: none;
}

.safety-paper-foreman-sign {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 12px;
}

.safety-paper-foreman-sign label,
.safety-paper-foreman-sign.readonly > div {
    display: grid;
    grid-template-columns: 170px 1fr;
    border: 1px solid #7b8799;
}

.safety-paper-foreman-sign label span,
.safety-paper-foreman-sign.readonly > div span {
    padding: 7px 8px;
    border-right: 1px solid #7b8799;
    background: #f9fafb;
    font-size: 11px;
    font-weight: 800;
}

.safety-paper-foreman-sign label input,
.safety-paper-foreman-sign.readonly > div strong {
    padding: 7px 8px;
    border: none;
    border-radius: 0;
    background: #fff;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
}

.safety-paper-foreman-sign label input:focus {
    outline: 2px solid #bfd3ff;
    outline-offset: -2px;
}

.safety-template-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.safety-support-card {
    margin-top: 14px;
}

.safety-support-copy {
    margin: 0 0 10px;
    color: #5f6f89;
    font-size: 13px;
}

.safety-worker-select-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.safety-signature-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.safety-signature-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fbff;
}

/* ============================================================
   MOBILE
============================================================ */

@media (max-width: 600px) {
    .safety-create-toolbar {
        align-items: stretch;
    }

    .safety-create-toolbar-control {
        min-width: 0;
    }

    .safety-paper {
        min-width: 860px;
        padding: 14px;
    }

    .safety-template-actions,
    .safety-signature-row {
        flex-direction: column;
        align-items: stretch;
    }

    .safety-report-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .safety-report-actions {
        align-items: flex-start;
        width: 100%;
    }

    .safety-report-actions .top-row {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .safety-table-header {
        grid-template-columns: 1fr;
    }

    .safety-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   DARK THEME FIX
============================================================ */

body[data-theme="dark"] #dailySafetyContainer,
body[data-theme="dark"] .safety-report-item,
body[data-theme="dark"] .safety-row {
    background: #0f172a !important;
    border-color: #1e293b !important;
}

body[data-theme="dark"] .safety-table-header {
    background: #1e293b !important;
    border-color: #334155 !important;
}

body[data-theme="dark"] .safety-report-date,
body[data-theme="dark"] .safety-report-jobsite,
body[data-theme="dark"] .safety-report-meta,
body[data-theme="dark"] #dailySafetyContainer h3,
body[data-theme="dark"] #dailySafetyContainer h4 {
    color: #e2e8f0 !important;
}

body[data-theme="dark"] button.secondary {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

/* ============================================================
   SAFETY SITE TILES (GRID)
============================================================ */

#safetyJobsiteSelect {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.safety-site-card {
    padding: 16px;
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-color);
    text-align: center;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: 0.2s;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.safety-site-card:hover {
    background: var(--card-hover);
    transform: translateY(-2px);
}

/* LIGHT THEME */
body[data-theme="light"] .safety-site-card {
    --card-bg: #f4f4f4;
    --card-hover: #e8e8e8;
    --text-color: #222;
    --border-color: #ccc;
}

/* DARK THEME */
body[data-theme="dark"] .safety-site-card {
    --card-bg: #1e293b;
    --card-hover: #334155;
    --text-color: #f1f5f9;
    --border-color: #475569;
}
.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-soft, #d1d5db);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: 0.2s;
}

.icon-btn:hover {
    background: var(--border-soft, #e5e7eb);
}

.icon-btn.danger {
    border-color: #dc2626;
    color: #dc2626;
}

.icon-btn.danger:hover {
    background: #fee2e2;
}


.modal-backdrop {
    display: none;              /* ← головне */
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#createReportModalBackdrop {
    z-index: 10020;
}

#dailyReportModalBackdrop {
    z-index: 10030;
}

#deleteReportModalBackdrop {
    z-index: 10040;
}

#confirmModalBackdrop,
#alertModalBackdrop {
    z-index: 10120 !important;
}

#createReportModalBackdrop .modal,
#dailyReportModalBackdrop .modal {
    width: min(1080px, calc(100vw - 48px));
    max-width: 1080px;
}

#createReportModalContent,
#dailyReportModalContent {
    max-height: min(78vh, 920px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
}

@media (max-width: 768px) {
    #createReportModalBackdrop,
    #dailyReportModalBackdrop {
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
    }

    #createReportModalBackdrop .modal,
    #dailyReportModalBackdrop .modal {
        width: 100vw;
        max-width: none;
        min-height: 100vh;
        margin: 0;
        border-radius: 0 !important;
        border: none !important;
        padding: 14px !important;
        box-shadow: none !important;
    }

    #createReportModalBackdrop .modal-header,
    #dailyReportModalBackdrop .modal-header {
        position: sticky;
        top: 0;
        z-index: 2;
        background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    }

    #createReportModalContent,
    #dailyReportModalContent {
        max-height: calc(100vh - 88px);
        padding-right: 0;
    }

    #createReportModalContent .safety-paper,
    #dailyReportModalContent .safety-paper {
        border-radius: 12px;
        padding: 12px;
    }
}

