* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* This applies to ALL screens (Laptop, Desktop, and Mobile) */
.header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 25px;
    width: 100%;
}

.header-logo {
    height: 90px;
    /* Increased slightly for desktop visibility */
    width: auto;
    background: transparent;
    /* Ensures no background color is stuck on the image */
    display: block;
    filter: drop-shadow(0px 4px 6px rgba(0, 0, 0, 0.3));
}

.header-text {
    text-align: left;
}

/* Mobile Specific Adjustments */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        /* Stacks logo on top of text for narrow screens */
        gap: 10px;
        padding: 20px;
    }

    .header-logo {
        height: 70px;
        /* Slightly smaller for mobile */
    }

    .header-text {
        text-align: center;
    }
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.admin-controls {
    padding: 20px 40px;
    background: #e9ecef;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.admin-controls label {
    font-weight: 600;
    font-size: 1.1em;
    color: #2c3e50;
}

.admin-controls select {
    max-width: 300px;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid #ced4da;
    font-size: 1em;
}

#mainContent {
    display: block;
    /* Container for main application sections */
}

.main-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 550px));
    justify-content: center;
    gap: 30px;
    padding: 40px;
    padding-bottom: 100px;
}

.section {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #3498db;
    font-size: 1.5em;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #34495e;
    font-size: 0.95em;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

/* Style file inputs specially */
input[type="file"] {
    padding: 10px;
    background: #f8f9fa;
    border: 2px dashed #ced4da;
}

input[type="file"]:focus {
    border: 2px dashed #3498db;
}

input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    border: none;
    background: #3498db;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
}

input[type="file"]::file-selector-button:hover {
    background: #2980b9;
}

input#caseId {
    text-transform: uppercase;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #3498db;
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

input[type="number"] {
    -moz-appearance: textfield;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.materials-section {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #3498db;
}

#stockPreviewList ul,
#openingStockPreviewList ul,
#installationPreviewList ul {
    list-style-type: none;
    padding: 0;
}

#stockPreviewList li,
#openingStockPreviewList li,
#installationPreviewList li {
    padding: 4px 0;
    border-bottom: 1px solid #e1e8ed;
}

/* Style for file names in preview */
#installationPreviewList li.file-preview {
    color: #2c3e50;
    font-style: italic;
    font-size: 0.9em;
}

#stockPreviewList li:last-child,
#openingStockPreviewList li:last-child,
#installationPreviewList li:last-child {
    border-bottom: none;
}

#installationPreviewList ul ul {
    padding-left: 20px;
    margin-top: 5px;
}

.stock-display-section {
    background: #f8f9fa;
    border-left: 4px solid #27ae60;
}

.material-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
    align-items: center;
}

.material-name {
    font-weight: 500;
    color: #2c3e50;
    padding: 8px 0;
    border-color: #000;
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 10px 5px;
    background-color: lightgreen;
}

.btn:hover {
    background-color: #044a1f;
    transition: cubic-bezier(0.075, 0.82, 0.165, 1);
    color: white
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #e67e22, #d35400);
    color: white;
}

.btn-excel {
    background: linear-gradient(135deg, #16a085, #1abc9c);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.btn-bill {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
    color: white;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.btn-container {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
    border-radius: 15px;
}

#toggleOpeningStockBtn,
#fixedDeleteBtn {
    position: fixed;
    bottom: 20px;
    z-index: 999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    padding: 0;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#toggleOpeningStockBtn {
    left: 20px;
}

#fixedDeleteBtn {
    right: 20px;
}

.hidden {
    display: none !important;
}

.data-display {
    grid-column: 1 / -1;
    margin-top: 30px;
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

#recordsDisplay {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.record {
    padding: 15px;
    margin-bottom: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    font-size: 15px;
}

.record-summary-list {
    list-style-type: none;
    padding: 10px 0 0 10px;
    margin: 10px 0 0 0;
    border-top: 1px solid #e1e8ed;
    font-size: 14px;
    color: #555;
}

.record-summary-list li {
    padding: 2px 0;
}

/* NEW: Styles for download links */
.record-file-links {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ced4da;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.record-file-links a {
    display: inline-block;
    padding: 5px 10px;
    background: #2c3e50;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.85em;
    font-weight: 500;
    transition: background 0.2s;
}

.record-file-links a:hover {
    background: #3498db;
}

.stock-level-low {
    color: #e74c3c;
    font-weight: bold;
}

.stock-level-ok {
    color: #27ae60;
    font-weight: bold;
}

.stock-level-warn {
    color: rgb(255, 106, 0);
    /* This is a "dark yellow" */
    font-weight: bold;
    animation: blink 1s linear infinite;
}

.stock-level-zero {
    color: #c6bfbf;
    font-weight: bold;
    /* Standard black/dark text */
    font-weight: normal;
}

@keyframes blink {
    50% {
        opacity: 0.3;
    }
}

/* --- NEW STYLES FOR DIALOG BOXES & ALERTS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleUp {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
    animation: fadeIn 0.3s ease forwards;
}

.modal-content-new {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 550px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    animation: scaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.modal-header-new {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 20px;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    margin: -40px -40px 20px -40px;
    font-size: 1.5em;
    font-weight: 600;
}

.modal-content-new h2 {
    margin-bottom: 25px;
    color: #2c3e50;
    font-size: 2em;
}

.modal-content-new .form-group {
    text-align: left;
    margin-bottom: 25px;
}

.modal-content-new input {
    padding: 15px;
    font-size: 16px;
}

.modal-content-new .btn {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    flex: 1;
    padding-right: 40px;
}

#togglePassword {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
}

#togglePassword:hover {
    color: #000;
}

.login-error {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    padding: 10px;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 14px;
    display: none;
}

.modal-btn-container {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

#customAlertModalOverlay .modal-content-new {
    max-width: 450px;
    text-align: left;
}

#customAlertModalOverlay h3 {
    font-size: 1.5em;
    margin-bottom: 10px;
}

#customAlertModalOverlay .alert-message {
    margin-bottom: 20px;
    color: #555;
    line-height: 1.5;
}

#customAlertModalOverlay .modal-btn-container {
    justify-content: flex-end;
}

/* Bill Details Page Styles */
#billDetailsSection {
    /* Ensure this section takes full width */
    grid-column: 1 / -1;
    max-width: 1000px;
    /* Limit width for large screens */
    margin: 30px auto;
}

/* New style for the header with the close button */
.bill-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#closeBillDetailsBtn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #e74c3c;
    padding: 5px;
    transition: transform 0.2s;
}

#closeBillDetailsBtn:hover {
    transform: scale(1.2);
}

.bill-split-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.bill-box {
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 10px;
    background: #f8f8f8;
}

.bill-box h3 {
    color: #3498db;
    margin-bottom: 10px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
    font-size: 1.2em;
}

#costDetailsTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 0.9em;
}

#costDetailsTable th,
#costDetailsTable td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    vertical-align: middle;
}

#costDetailsTable th {
    background-color: #ecf0f1;
    color: #2c3e50;
}

/* Custom styles for input fields within the cost table */
#costDetailsTable input[type="text"],
#costDetailsTable input[type="number"] {
    width: 100%;
    padding: 8px;
    margin: 0;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9em;
    box-sizing: border-box;
    /* Important for 100% width */
    background: white;
    transition: border-color 0.2s;
}

#costDetailsTable input:focus {
    border-color: #3498db;
}

.cost-summary-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    margin-top: 15px;
    padding: 10px 0;
    border-top: 1px solid #ddd;
    align-items: center;
}

.cost-summary-row label {
    text-align: right;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 0;
}

.cost-summary-row input {
    text-align: right;
    padding: 8px;
}

.total-amount {
    text-align: right;
    font-size: 1.1em;
    font-weight: bold;
    color: #e67e22;
}

/* NEW: Style for Print Invoice button container */
.bill-footer-container {
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
    padding: 10px 0;
}

/* New styles for the material purchase row controls */
.material-controls-cell {
    text-align: center;
    width: 15px;
    /* Fixed width for the button column */
}

.material-controls-cell button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.add-material-btn {
    color: #1abc9c;
    /* Brighter, more distinct green */
    font-size: 1.6em;
    /* Increased size */
    font-weight: 900;
    /* Made it bolder */
    display: block !important;
    /* Ensure it is visible by default on the last row */
}

.remove-material-btn {
    color: #e74c3c;
    font-size: 1.2em;
    display: block;
    /* Ensure it takes up vertical space */
    margin: 0 auto;
}

/* --- ADD THESE STYLES TO THE END OF style.css --- */

.progress-container {
    width: 100%;
    background-color: #e9ecef;
    border-radius: 8px;
    margin-top: 15px;
    margin-bottom: 20px;
    overflow: hidden;
    position: relative;
    height: 30px;
    border: 1px solid #ced4da;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-radius: 8px;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #2c3e50;
    font-weight: 600;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.7);
}

/* Responsive adjustments for fixed buttons */
@media (max-width: 900px) {

    body {
        padding: 10px;
        /* Reduced outer padding */
    }

    /* 👇 AGGRESSIVE MOBILE FIX FOR ADMIN CONTROLS 👇 */
    /* Reduce padding to only 5px on the sides, giving maximum room */
    .admin-controls {
        padding: 15px 5px;
        /* Reduced side padding to 5px */
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    /* Reduce font size for labels to make them fit better */
    .admin-controls label {
        font-size: 0.9em;
    }

    .admin-controls select {
        width: 100%;
        max-width: 100%;
        font-size: 0.9em;
        /* Also reduce font size in the select box */
    }

    /* 👆 END AGGRESSIVE MOBILE FIX 👆 */

    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px 10px;
        padding-bottom: 120px;
    }

    #billDetailsSection {
        margin: 0 auto;
    }

    .bill-split-section {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 1.8em;
    }

    #toggleOpeningStockBtn,
    #fixedDeleteBtn {
        width: 50px;
        height: 50px;
        font-size: 20px;
        bottom: 10px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    }

    #toggleOpeningStockBtn {
        left: 10px;
    }

    #fixedDeleteBtn {
        right: 10px;
    }

    .modal-content-new {
        padding: 25px;
        margin: 0 10px;
    }

    .modal-header-new {
        margin: -25px -25px 20px -25px;
    }

    .edit-material-btn {
        padding: 5px 10px;
        font-size: 12px;
        margin-top: 10px;
        margin-left: auto;
        display: block;
        text-transform: uppercase;
        letter-spacing: 0;
        width: 120px;
    }

    .download-zip-btn {
        padding: 5px 10px !important;
        font-size: 12px !important;
        margin-top: 10px;
        margin-left: 10px;
        display: inline-block;
        text-transform: uppercase;
        letter-spacing: 0;
        width: auto;
    }

    /* Unique Delete Confirmation Style */
    #deleteConfirmModalOverlay .modal-content-new {
        border: 3px solid #e74c3c;
        /* Red Border for Alert */
        background: #fff5f5;
    }

    #deleteConfirmModalOverlay .modal-header-new {
        background: linear-gradient(135deg, #e74c3c, #c0392b);
    }

    #deleteRecordDetails {
        background: white;
        border-radius: 8px;
        padding: 15px;
        text-align: left;
        margin-bottom: 20px;
        box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    }

    /* Unique Edit Modal Style */
    #editMaterialModalOverlay .modal-content-new {
        border: 3px solid #3498db;
        /* Blue Border for Edit */
    }

    #editMaterialModalOverlay .material-row {
        background: #f0f7ff;
        padding: 10px;
        border-radius: 8px;
        margin-bottom: 8px;
    }

    /* Unique Design for Delete (Red Theme) */
    #deleteConfirmModalOverlay .modal-content-new {
        border: 3px solid #e74c3c !important;
        background: #fff5f5 !important;
    }

    #deleteRecordDetails {
        background: white;
        border: 1px solid #feb2b2;
        padding: 15px;
        border-radius: 8px;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    /* Unique Edit Modal Design (Blue Theme) */
    #editMaterialModalOverlay .modal-content-new {
        border: 4px solid #3498db !important;
        /* Strong blue border */
        box-shadow: 0 15px 35px rgba(52, 152, 219, 0.3);
    }

    #editMaterialModalOverlay .modal-header-new {
        background: linear-gradient(135deg, #3498db, #2980b9);
    }

    #editMaterialList .material-row:hover {
        background: #e1f0ff !important;
        border-color: #3498db !important;
    }

    /* --- Action Buttons for Records --- */
    .record-actions {
        display: flex;
        gap: 12px;
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px dashed var(--border-color);
    }

    .btn-edit-materials {
        background: #f39c12;
        /* Warning Orange */
        color: white;
        border: none;
        padding: 8px 15px;
        border-radius: 6px;
        font-weight: 600;
        font-size: 13px;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        transition: background 0.3s, transform 0.2s;
        margin-bottom: 5px;
    }

    .btn-edit-materials:hover {
        background: #e67e22;
        transform: scale(1.02);
    }

    .btn-edit-materials:active {
        transform: scale(0.98);
    }

    .btn-download-files {
        background: #10b981;
        /* Tech Teal */
        color: white;
        font-size: 0.75rem;
        padding: 8px 16px;
        border-radius: 8px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .btn-download-files:hover {
        background: #059669;
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    }

    /* Colorful Record Action Buttons */
    .record-actions {
        display: flex;
        gap: 10px;
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px dashed #e2e8f0;
    }

    /* Edit Button - Vibrant Orange */
    .btn-edit-materials {
        background: #f97316 !important;
        /* Safety Orange */
        color: white !important;
        border: none !important;
        padding: 10px 18px !important;
        border-radius: 8px !important;
        font-weight: 700 !important;
        font-size: 0.8rem !important;
        cursor: pointer;
        transition: all 0.2s ease;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.2);
    }

    .btn-edit-materials:hover {
        background: #ea580c !important;
        transform: translateY(-2px);
        box-shadow: 0 10px 15px -3px rgba(249, 115, 22, 0.3);
    }

    /* Enhanced Modify Button Style */
    .btn-edit-materials {
        background: #f39c12 !important;
        color: white !important;
        border: none;
        padding: 8px 16px;
        border-radius: 6px;
        font-weight: bold;
        cursor: pointer;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        transition: 0.3s;
        display: inline-flex;
        align-items: center;
        gap: 5px;
    }

    .btn-edit-materials:hover {
        background: #d35400 !important;
        transform: scale(1.05);
    }

    @media (max-width: 600px) {
        .btn-edit-materials {
            width: 100%;
            justify-content: center;
            padding: 12px;
        }
    }

}