:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.08);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Animated Shapes */
.background-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
    z-index: -1;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.5;
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -100px;
    left: -100px;
}

.shape-2 {
    width: 500px;
    height: 500px;
    background: #4338ca;
    bottom: -200px;
    right: -100px;
    animation-delay: -5s;
}

.shape-3 {
    width: 300px;
    height: 300px;
    background: #ec4899;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Main Container */
.app-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
    z-index: 10;
}

.hidden {
    display: none !important;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

/* Toggles */
.toggle-btns {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin-bottom: 2rem;
    padding: 4px;
}

.toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: var(--panel-border);
    color: var(--text-main);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Forms */
.form-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.form-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.input-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.input-group input, .input-group select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.2s ease;
    outline: none;
}

.input-group input:focus, .input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

select option {
    background-color: #334155; /* Solid gray background to overwrite OS defaults */
    color: #f8fafc;
}

.helper-text {
    font-size: 0.8rem;
    color: var(--primary);
    margin-top: 5px;
}

.error-text {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    margin-top: 1rem;
}

.primary-btn {
    background: var(--primary);
    color: white;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.3);
}

.primary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-main);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Dashboard specific */
.app-container.dashboard-mode {
    max-width: 100%;
    height: 100vh;
    padding: 0;
    display: flex;
}

.dashboard-layout {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.3s ease;
    z-index: 50;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 10px;
    overflow-y: auto;
}

.nav-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--panel-border);
}

.user-info {
    margin-bottom: 15px;
}

.company-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
}

.sidebar-logout {
    margin-top: 0;
    padding: 8px;
    font-size: 0.9rem;
}

/* Main Content Area */
.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
}

.glass-header {
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--panel-border);
    padding: 20px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.content-body {
    padding: 30px;
    flex: 1;
}

.main-panel {
    max-width: 1200px;
    margin: 0 auto;
}

/* Mobile Toggles */
.icon-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

.mobile-only {
    display: none !important;
}

/* Responsiveness */
@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 49;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        animation: overlayFadeIn 0.25s ease;
    }

    .sidebar-overlay.active {
        display: block;
    }

    @keyframes overlayFadeIn {
        from { opacity: 0; }
        to   { opacity: 1; }
    }

    /* Reduce panel padding to give more room to forms on mobile */
    .glass-panel {
        padding: 1.25rem !important;
    }
    .content-body {
        padding: 15px;
    }

    /* Fix Permit Accordions chopping on Mobile Viewport */
    .permit-node-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .permit-node-header > div {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }
    .permit-node {
        margin-left: 0 !important; /* Prevent deep nesting from pushing off screen */
    }
    .pdf-btn {
        font-size: 0.75rem;
        padding: 6px 10px;
        white-space: normal;
        text-align: center;
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    overflow-y: auto;
    display: block;
    padding: 20px 10px;
}

.modal-content {
    margin: 2vh auto;
    width: 100%;
}

.company-id-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    text-align: center;
}

.company-id-box h2 {
    color: var(--primary);
    letter-spacing: 2px;
    margin: 10px 0;
    font-family: monospace;
}

.warning-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Company Profile Card */
.profile-card {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-top: 20px;
    align-items: center;
}

.logo-upload-container {
    width: 150px;
    height: 150px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.logo-upload-container:hover {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.logo-upload-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    padding: 10px;
    transition: padding 0.3s ease;
}

.upload-overlay {
    position: absolute;
    bottom: -100%;
    left: 0;
    width: 100%;
    height: 40px;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    transition: bottom 0.3s ease;
}

.logo-upload-container:hover .upload-overlay {
    bottom: 0;
}

.company-details {
    flex: 1;
    min-width: 250px;
}

.company-details h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.id-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 8px;
    padding: 8px 16px;
    margin-bottom: 8px;
}

.id-badge .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-right: 8px;
}

.id-badge .value {
    font-family: monospace;
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--primary);
    letter-spacing: 1px;
}

.confidential-remark {
    font-size: 0.8rem;
    color: #fcd34d;
    margin-top: 5px;
    line-height: 1.4;
}

/* Header Layout & Selectors */
.header-left { display: flex; align-items: center; gap: 15px; }
.header-right { margin-left: auto; }
.project-dropdown {
    background: rgba(0,0,0,0.3);
    color: var(--text-main);
    border: 1px solid var(--panel-border);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}
.project-dropdown:focus { border-color: var(--primary); }
.project-dropdown option { background: var(--bg-color); color: var(--text-main); }

/* Modals */
.large-modal { max-width: 600px; width: 90%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

/* Project Grid */
.module-header-flex { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.project-info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; margin-top: 20px; }
.info-block { background: rgba(0,0,0,0.2); padding: 15px; border-radius: 12px; border: 1px solid var(--panel-border); }
.info-label { font-size: 0.8rem; color: var(--text-muted); display: block; margin-bottom: 5px; }
.info-block h4 { font-size: 1.1rem; font-weight: 600; }
.primary-text { color: var(--primary); font-family: monospace; }
.highlight-text { color: #ec4899; font-size: 1.3rem !important; }
#no-project-message { text-align: center; padding: 40px; color: var(--text-muted); background: rgba(0,0,0,0.1); border-radius: 12px; border: 1px dashed var(--panel-border); }

/* Dashboard Tables Data */
.styled-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.9em; min-width: 400px; text-align: left; background: rgba(0, 0, 0, 0.15); border-radius: 8px; overflow: hidden; }
.styled-table th, .styled-table td { padding: 15px 15px; border-bottom: 1px solid var(--panel-border); }
.styled-table th { background-color: rgba(255,255,255,0.05); color: #fff; font-weight: 600; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.5px; }
.styled-table tbody tr { transition: background-color 0.2s ease; }
.styled-table tbody tr:hover { background-color: rgba(255,255,255,0.05); }

/* Warning Badges */
.badge { padding: 6px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: bold; white-space: nowrap; }
.badge-green { background: rgba(16, 185, 129, 0.2); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.4); }
.badge-yellow { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.4); }
.badge-orange { background: rgba(249, 115, 22, 0.2); color: #f97316; border: 1px solid rgba(249, 115, 22, 0.4); }
.badge-red { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.4); }

/* Nested Accordion Nodes (Permits) */
.permit-node { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; margin-bottom: 15px; overflow: hidden; }
.permit-node-header { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: background 0.2s ease; }
.permit-node-header:hover { background: rgba(255,255,255,0.06); }
.permit-node-body { padding: 20px; border-top: 1px solid rgba(255,255,255,0.05); background: rgba(0,0,0,0.2); display: none; }
.permit-node.expanded > .permit-node-body { display: block; }
.permit-arrow { font-size: 0.8rem; transition: transform 0.2s ease; }
.permit-node.expanded > .permit-node-header .permit-arrow { transform: rotate(90deg); }

/* Levels */
.node-pmk { border-left: 4px solid #3b82f6; }
.node-gp { border-left: 4px solid #f59e0b; margin-top: 15px; }
.node-hrp { border-left: 4px solid #ef4444; margin-top: 10px; margin-left: 10px; }

.permit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 15px; }
.pdf-btn { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.1); color: #fff; padding: 8px 15px; border-radius: 6px; text-decoration: none; font-size: 0.85rem; transition: 0.2s ease; border: 1px solid rgba(255,255,255,0.2); }
.pdf-btn:hover { background: rgba(255,255,255,0.2); }
.btn-small { padding: 6px 12px; font-size: 0.8rem; }

/* -------------------------------------- */
/* TOGGLE SWITCH & MANPOWER CSS           */
/* -------------------------------------- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); transition: .3s; border: 1px solid var(--panel-border); }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: var(--text-muted); transition: .3s; }
input:checked + .slider { background-color: rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.6); }
input:checked + .slider:before { transform: translateX(20px); background-color: #10b981; }
.slider.round { border-radius: 24px; }
.slider.round:before { border-radius: 50%; }

#manpower-table {
    table-layout: fixed;
    width: 100%;
}
#manpower-table th:last-child,
#manpower-table td:last-child {
    width: 70px;
    white-space: nowrap;
}

.manpower-input { 
    width: 100%;
    min-width: 0;
    background: transparent; 
    border: 1px solid transparent; 
    color: var(--text-main); 
    font-size: 0.9rem; 
    padding: 10px 12px; 
    border-radius: 6px; 
    pointer-events: none;
    transition: all 0.2s;
    box-sizing: border-box;
    /* Clip overflowing text cleanly in view mode */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.manpower-input:focus { outline: none; }

.edit-mode .manpower-input { 
    width: 100%;
    background: rgba(0,0,0,0.3); 
    border: 1px solid var(--panel-border); 
    pointer-events: auto;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}
.edit-mode .manpower-input:focus { border-color: var(--primary); }

/* Hide select dropdown arrows strictly in view mode */
.view-mode select.manpower-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}
.edit-mode select.manpower-input {
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
}

select.count-input {
    pointer-events: auto !important;
    appearance: auto !important;
    -webkit-appearance: auto !important;
    -moz-appearance: auto !important;
}

/* Mobile: compact manpower table */
@media (max-width: 768px) {
    #manpower-table th, #manpower-table td {
        padding: 2px 4px !important;
        font-size: 0.82rem;
    }
    #manpower-table .manpower-input {
        padding: 8px 4px;
        font-size: 0.82rem;
    }
    #manpower-table th:last-child,
    #manpower-table td:last-child {
        width: 60px !important;
    }
    .count-input {
        width: 55px !important;
    }
}

/* Monthly Matrix Responsive Styles */
.matrix-wrapper {
    background: rgba(0,0,0,0.1);
}
.matrix-table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1200px;
}
.matrix-table th, .matrix-table td {
    padding: 2px !important;
    text-align: center;
    border-right: 1px solid rgba(255,255,255,0.05);
}

/* Edit Mode Visual Tints */
.matrix-edit-mode .matrix-col-locked,
.matrix-edit-mode .matrix-col-locked-2 {
    color: rgba(255, 255, 255, 0.2) !important; /* 20% font opacity */
}
.matrix-edit-mode .matrix-col-locked span,
.matrix-edit-mode .matrix-col-locked-2 span {
    opacity: 0.2; /* 20% element fade-out */
}

/* Edit Mode Headers (Days 1-31) */
.matrix-edit-mode th:not(.matrix-col-locked):not(.matrix-col-locked-2) {
    background: #9a3412 !important; /* dark orange header */
    border-color: rgba(249, 115, 22, 0.3) !important;
    color: #fff !important;
}

/* Edit Mode Editable Cells */
.matrix-edit-mode td:not(.matrix-col-locked):not(.matrix-col-locked-2) {
    background: rgba(249, 115, 22, 0.15) !important; /* bright orange translucent backplate */
    border-color: rgba(249, 115, 22, 0.2) !important;
}

.matrix-edit-mode input.matrix-input {
    color: #f97316; /* bright orange text */
    font-weight: 600;
}

.matrix-table th {
    position: sticky;
    top: 0;
    background: #111827; 
    z-index: 2;
    padding: 8px 4px !important;
    font-size: 0.8rem;
}
.matrix-col-locked {
    position: sticky !important;
    left: 0;
    background: #1f2937 !important;
    z-index: 3 !important;
    width: 140px;
    max-width: 140px;
    text-align: left !important;
    padding: 8px 12px !important;
}
.matrix-col-locked-2 {
    position: sticky !important;
    left: 140px;
    background: #1f2937 !important;
    z-index: 3 !important;
    width: 140px;
    max-width: 140px;
    text-align: left !important;
    padding: 8px 12px !important;
}
.matrix-table th.matrix-col-locked, .matrix-table th.matrix-col-locked-2 {
    z-index: 4 !important;
    background: #111827 !important;
}

.matrix-text-truncate {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

.matrix-input {
    width: 35px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-main);
    text-align: center;
    font-size: 0.85rem;
    padding: 4px;
    border-radius: 4px;
    transition: 0.2s;
}
.matrix-input:hover, .matrix-input:focus {
    background: rgba(0,0,0,0.3);
    border-color: var(--primary);
    outline: none;
}

/* Active Column Highlighting */
.matrix-active-col {
    background: rgba(16, 185, 129, 0.1) !important;
}

/* Edit Mode styling */
.matrix-view-mode .matrix-input {
    pointer-events: none;
    background: transparent !important;
    border-color: transparent !important;
}
.matrix-view-mode .matrix-input:hover, .matrix-view-mode .matrix-input:focus {
    background: transparent !important;
    border-color: transparent !important;
    outline: none;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .matrix-col-locked { width: 80px; max-width: 80px; padding: 8px 4px !important; font-size: 0.75rem; }
    .matrix-col-locked-2 { width: 80px; max-width: 80px; left: 80px; padding: 8px 4px !important; font-size: 0.75rem; }
}

/* Heavy Machinery Module Responsive Styles */
.machinery-accordion-header {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 15px;
    border: 1px solid var(--panel-border);
    transition: all 0.2s;
}
.machinery-accordion-header:hover {
    background: rgba(255,255,255,0.1);
}
.machinery-data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.85rem;
}
.machinery-data-table th, .machinery-data-table td {
    padding: 10px 12px;
    border: 1px solid var(--panel-border);
    text-align: left;
    color: var(--text-main);
    vertical-align: middle;
}
.machinery-data-table th {
    background: rgba(255,255,255,0.05);
    font-weight: 600;
    color: var(--text-muted);
}
.machinery-operator-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 40px;
    gap: 10px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    align-items: end;
}
@media (max-width: 768px) {
    .machinery-operator-row {
        grid-template-columns: 1fr 1fr;
    }
    .machinery-operator-row .remove-op-btn {
        grid-column: 1 / -1;
        text-align: right;
    }
}

/* Worker Registration Form Styles */
.form-section {
    margin-bottom: 30px;
}
.section-title {
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.worker-photo-container {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 16px;
    border: 1px solid var(--panel-border);
}
.photo-preview {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 2px dashed var(--panel-border);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}
.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.safety-cert-row {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 15px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 15px;
    align-items: flex-end;
    animation: workerFadeIn 0.3s ease;
}
@keyframes workerFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 768px) {
    .safety-cert-row {
        grid-template-columns: 1fr;
    }
}

/* ================================================ */
/* Worker Profile A4 Layout                         */
/* ================================================ */
.worker-profile-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(30,41,59,0.8);
    border-radius: 16px 16px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.worker-a4 {
    background: #ffffff;
    color: #1e293b;
    padding: 35px 45px;
    min-height: 297mm;
    font-family: 'Inter', Arial, sans-serif;
    font-size: 0.85rem;
}

.wa4-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

.wa4-photo {
    width: 100px;
    height: 120px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #f8fafc;
}

.wa4-title {
    flex: 1;
    padding-top: 5px;
}

.wa4-logo-area {
    text-align: right;
    padding-top: 5px;
}

.wa4-divider {
    border: none;
    border-top: 2px solid #6366f1;
    margin: 15px 0;
}

.wa4-section {
    margin-bottom: 20px;
}

.wa4-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #6366f1;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 6px;
    margin-bottom: 12px;
}

.wa4-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px 20px;
}

.wa4-field {
    width: calc(25% - 20px);
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    page-break-inside: avoid;
}

.wa4-field label {
    font-size: 0.65rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wa4-field span {
    font-size: 0.82rem;
    color: #1e293b;
    font-weight: 500;
    word-break: break-word;
}

.wa4-links a {
    color: #6366f1;
    font-size: 0.75rem;
    text-decoration: underline;
}

.wa4-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.wa4-table th, .wa4-table td {
    border: 1px solid #e2e8f0;
    padding: 7px 10px;
    text-align: left;
}

.wa4-table th {
    background: #f1f5f9;
    font-weight: 600;
    color: #475569;
    font-size: 0.75rem;
}

.wa4-footer {
    margin-top: 40px;
    display: flex;
    justify-content: space-between;
    gap: 30px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

.wa4-sign-box {
    flex: 1;
    text-align: center;
    font-size: 0.72rem;
    color: #64748b;
}

.wa4-sign-line {
    height: 50px;
    border-bottom: 1px solid #94a3b8;
    margin-bottom: 6px;
}

/* ================================================ */
/* PRINT STYLES                                     */
/* ================================================ */
@media print {
    /* Explicitly hide only the main application views and backgrounds */
    #dashboard-view,
    #auth-view,
    #sidebar,
    .background-shapes,
    .no-print {
        display: none !important;
    }
    
    /* Ensure the wrapper expands fully and doesn't trap the modal into mobile-width */
    #app-container,
    .app-container {
        display: block !important;
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Target the specific modal to render */
    #worker-profile-modal {
        display: block !important;
        position: static !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Normalize HTML and Body to allow spanning across pages */
    html, body {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
        background: #ffffff !important;
        color: #1e293b !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Only apply structural resets to `.modal` and `.modal-content` without forcing display: block on hidden ones */
    .modal, 
    .modal-content {
        position: static !important;
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
        min-height: 0 !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        transform: none !important;
    }

    /* Specifically target the print area of the active modal to ensure it's block */
    #worker-profile-print-area {
        position: static !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        min-height: 0 !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Force links to render nicely in print */
    .wa4-links a {
        color: #6366f1 !important;
    }
}
