:root {
    --primary-color: #1a237e;
    /* Dark Blue (Indigo 900) */
    --secondary-color: #00bcd4;
    /* Cyan 500 */
    --accent-color: #2196f3;
    /* Blue 500 */
    --bg-color: #f4f4f4;
    --page-bg: #ffffff;
    --border-color: #ddd;
    --highlight-color: #f0e6e6;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body,
html {
    font-family: 'Times New Roman', Times, serif;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Strictly prevent all native exterior scroll bars */
    box-sizing: border-box;
}

#app-container, .app-container, .hr-container {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.view {
    display: none;
    height: 100%;
    flex-direction: column;
    width: 100%;
}

.view.active {
    display: flex;
}

/* Dashboard Styles */
#dashboard-view {
    padding: 15px;
    width: 100%;
    overflow-y: auto;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    flex-wrap: wrap;
    /* Allow items to wrap on smaller screens */
    gap: 15px;
}

.app-header h1 {
    flex-shrink: 0;
    margin-right: 20px;
    font-size: 1.5em;
    /* Adjust font size for responsiveness */
}

.dashboard-header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.dashboard-summary-container {
    display: flex;
    gap: 20px;
    text-align: right;
    margin-left: auto;
    padding-right: 20px;
    flex-wrap: wrap;
    /* Allow summary items to wrap */
    justify-content: flex-end;
}

.summary-item .label {
    font-size: 12px;
    color: #555;
}

.summary-item .value {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-color);
}

#pending-invoices-summary {
    cursor: pointer;
}

.dashboard-controls {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
    /* Allow controls to wrap */
}

.dashboard-controls input,
.dashboard-controls select,
.dashboard-controls button {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    /* Slightly smaller font for mobile */
}

#search-box {
    flex-grow: 1;
    min-width: 200px;
}

.project-list-container {
    flex-grow: 1;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

#project-list-table {
    width: 100%;
    border-collapse: collapse;
}
/* Add this to your style.css or theme-premium-minimal.css file */

/* Scope Tab Panel Styling - Distinct Colors for Each Section */
.document-category {
    border-left: 4px solid;
    border-radius: 8px;
    margin-bottom: 20px;
    transition: box-shadow 0.2s ease;
}

.document-category:hover {
    box-shadow: var(--shadow-md);
}

/* Architectural Modification Proposal Panel - Teal/Blue */
#architectural-modification-proposal-panel {
    border-left-color: #0891b2;
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
}

/* Scope Selection Container (Main Scope Sections) */
#scope-selection-container .document-category {
    border-left-color: #3b82f6;
}

/* Scope Sections - Different Colors by Section Type */
#scope-selection-container .document-category:nth-child(1) { border-left-color: #3b82f6; } /* Study and Design - Blue */
#scope-selection-container .document-category:nth-child(2) { border-left-color: #10b981; } /* Preliminary Design - Green */
#scope-selection-container .document-category:nth-child(3) { border-left-color: #f59e0b; } /* Final Stage - Amber */
#scope-selection-container .document-category:nth-child(4) { border-left-color: #8b5cf6; } /* Interior Design - Purple */
#scope-selection-container .document-category:nth-child(5) { border-left-color: #ef4444; } /* Tender Documents - Red */
#scope-selection-container .document-category:nth-child(6) { border-left-color: #ec4899; } /* Supervision Works - Pink */
#scope-selection-container .document-category:nth-child(7) { border-left-color: #06b6d4; } /* Consultant's Duties - Cyan */
#scope-selection-container .document-category:nth-child(8) { border-left-color: #84cc16; } /* BIM Services - Lime */
#scope-selection-container .document-category:nth-child(9) { border-left-color: #14b8a6; } /* BIM LOD - Teal */
#scope-selection-container .document-category:nth-child(10) { border-left-color: #f97316; } /* Structural Review - Orange */
#scope-selection-container .document-category:nth-child(11) { border-left-color: #6366f1; } /* Principles of Calculation - Indigo */
#scope-selection-container .document-category:nth-child(12) { border-left-color: #d946ef; } /* Owner's Obligations - Fuchsia */
#scope-selection-container .document-category:nth-child(13) { border-left-color: #eab308; } /* Amendments - Yellow */
#scope-selection-container .document-category:nth-child(14) { border-left-color: #64748b; } /* Extension - Slate */

/* Paste Scope Content Panel - Purple */
.document-category:has(#scope-pasted-text) {
    border-left-color: #8b5cf6;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
}

/* Sign & Stamp Settings Panel - Amber/Gold */
.document-category:has(#scope-include-signature) {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
}

/* Brief Proposal Terms & Conditions Panel - Emerald */
.document-category:has(#brief-terms-container) {
    border-left-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
}

/* Manual Document Page Breaks Panel - Slate */
.document-category:has(.section-page-break[data-section-id="timeSpan"]) {
    border-left-color: #64748b;
    background: #f8fafc;
}

/* Fees Tab Panels */
#fees-tab .document-category {
    border-left-color: #8b5cf6;
}

#fees-tab .financial-summary {
    border-left-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
}

/* Payment Cert Tab Panels */
#payment-cert-tab .document-category {
    border-left-color: #ef4444;
}

/* Schedule Tab Panels */
#schedule-tab .document-category {
    border-left-color: #f59e0b;
}

/* Letters Tab Panels */
#project-letters-tab .tool-card {
    border-left: 4px solid #3b82f6;
}

#project-letters-tab .form-section {
    border-left: 3px solid;
    padding-left: 15px;
    margin-bottom: 20px;
}

#project-letters-tab .form-section:nth-child(1) { border-left-color: #3b82f6; }
#project-letters-tab .form-section:nth-child(2) { border-left-color: #10b981; }
#project-letters-tab .form-section:nth-child(3) { border-left-color: #f59e0b; }
#project-letters-tab .form-section:nth-child(4) { border-left-color: #8b5cf6; }

/* Invoicing Tab Panels */
#invoicing-tab .document-category {
    border-left-color: #ec4899;
}

/* Invoice Table Styling */
.document-table {
    border-collapse: collapse;
    width: 100%;
}

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

.document-table th {
    background-color: #f8fafc;
    font-weight: 600;
}

/* Progress Bar Styling */
.progress-bar-container {
    background-color: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    height: 8px;
}

.progress-bar {
    background-color: #3b82f6;
    height: 100%;
    transition: width 0.3s ease;
}

/* Status Badges */
.status-pending { color: #f59e0b; font-weight: bold; }
.status-in-progress { color: #3b82f6; font-weight: bold; }
.status-under-supervision { color: #8b5cf6; font-weight: bold; }
.status-completed { color: #10b981; font-weight: bold; }
.status-on-hold { color: #ef4444; font-weight: bold; }
.status-cancelled { color: #64748b; font-weight: bold; }
.status-raised { color: #f59e0b; font-weight: bold; }
.status-paid { color: #10b981; font-weight: bold; }
.status-draft { color: #64748b; font-weight: bold; }

/* Additional styling for section headers with colored borders */
.scope-section h4 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 2px solid;
    margin-bottom: 15px;
}

.scope-section h4 span:first-child {
    font-weight: 700;
}

/* Inherit border color from parent for section headers */
.scope-section {
    border-left: 4px solid;
}

.scope-section h4 {
    border-bottom-color: inherit;
}

/* Make the border colors more vibrant on hover */
.document-category:hover,
.scope-section:hover {
    border-left-width: 5px;
    transition: border-left-width 0.1s ease;
}

/* Dark theme adjustments */
[data-theme="dark"] .document-category,
@media (prefers-color-scheme: dark) {
    .document-category {
        background: var(--surface-color);
    }
    
    .document-category:has(#scope-pasted-text),
    .document-category:has(#scope-include-signature),
    .document-category:has(#brief-terms-container) {
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0%, var(--surface-color) 100%);
    }
}

/* Print styles - preserve border colors for identification */
@media print {
    .document-category,
    .scope-section {
        border-left-width: 2px !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
/* Add this to your theme-premium-minimal.css or style.css */

/* ========================================================
   PANEL STYLES FOR MAIN TAB (Scope-like appearance)
   ======================================================== */

/* Main Tab - Group related fields into panels */
#main-tab .input-group-grid,
#main-tab .input-group:not(.panel-group) {
    margin-bottom: 20px;
}

/* Create panel groups in Main tab */
#main-tab .panel-section {
    border-left: 4px solid;
    border-radius: 8px;
    margin-bottom: 24px;
    padding: 5px 0 5px 15px;
    background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0) 100%);
    transition: all 0.2s ease;
}

#main-tab .panel-section:hover {
    box-shadow: var(--shadow-sm);
}

/* Panel headers */
#main-tab .panel-section > h3 {
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid;
    border-bottom-color: inherit;
    font-size: 1.1em;
}

/* Section-specific colors for Main tab panels */
#main-tab .panel-section:nth-child(1) { border-left-color: #3b82f6; } /* Project Info */
#main-tab .panel-section:nth-child(2) { border-left-color: #10b981; } /* Client Details */
#main-tab .panel-section:nth-child(3) { border-left-color: #8b5cf6; } /* Client Account Department */
#main-tab .panel-section:nth-child(4) { border-left-color: #f59e0b; } /* Project Details */
#main-tab .panel-section:nth-child(5) { border-left-color: #ec4899; } /* Referral & Contractor */

/* Or use data attributes for more specific targeting */
#main-tab .panel-section[data-section="project-info"] { border-left-color: #3b82f6; }
#main-tab .panel-section[data-section="client-details"] { border-left-color: #10b981; }
#main-tab .panel-section[data-section="client-account"] { border-left-color: #8b5cf6; }
#main-tab .panel-section[data-section="project-details"] { border-left-color: #f59e0b; }
#main-tab .panel-section[data-section="referral"] { border-left-color: #ec4899; }

/* ========================================================
   PANEL STYLES FOR FEES TAB (Scope-like appearance)
   ======================================================== */

/* Fees Tab - Group sections into panels */
#fees-tab .panel-section {
    border-left: 4px solid;
    border-radius: 8px;
    margin-bottom: 24px;
    padding: 5px 0 5px 15px;
    background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0) 100%);
    transition: all 0.2s ease;
}

#fees-tab .panel-section:hover {
    box-shadow: var(--shadow-sm);
}

#fees-tab .panel-section > h3 {
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid;
    border-bottom-color: inherit;
}

/* Section-specific colors for Fees tab panels */
#fees-tab .panel-section:first-child { border-left-color: #06b6d4; } /* Financials */
#fees-tab .panel-section:nth-child(2) { border-left-color: #3b82f6; } /* Fee Calculation */
#fees-tab .panel-section:nth-child(3) { border-left-color: #8b5cf6; } /* Fee Split */
#fees-tab .panel-section:nth-child(4) { border-left-color: #f59e0b; } /* Design Fee Milestones */
#fees-tab .panel-section:nth-child(5) { border-left-color: #ec4899; } /* Supervision Fee */
#fees-tab .panel-section:nth-child(6) { border-left-color: #10b981; } /* Timeline */
#fees-tab .panel-section:nth-child(7) { border-left-color: #ef4444; } /* Notes & Exclusions */

/* Financial Summary as a distinct card */
#fees-tab .financial-summary {
    border-left: 4px solid #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
}

/* ========================================================
   UTILITY CLASSES FOR PANELS
   ======================================================== */

/* Panel with different border styles */
.panel-primary { border-left-color: #3b82f6; }
.panel-success { border-left-color: #10b981; }
.panel-warning { border-left-color: #f59e0b; }
.panel-danger { border-left-color: #ef4444; }
.panel-info { border-left-color: #06b6d4; }
.panel-purple { border-left-color: #8b5cf6; }
.panel-pink { border-left-color: #ec4899; }
.panel-teal { border-left-color: #14b8a6; }

/* Collapsible panel headers */
.panel-collapsible {
    cursor: pointer;
    user-select: none;
}

.panel-collapsible:hover {
    opacity: 0.85;
}

.panel-collapsible::before {
    content: "▼";
    display: inline-block;
    font-size: 0.8em;
    margin-right: 8px;
    transition: transform 0.2s;
}

.panel-collapsible.collapsed::before {
    transform: rotate(-90deg);
}

.panel-content {
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

.panel-content.collapsed {
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Dark theme adjustments */
[data-theme="dark"] #main-tab .panel-section,
[data-theme="dark"] #fees-tab .panel-section,
@media (prefers-color-scheme: dark) {
    #main-tab .panel-section,
    #fees-tab .panel-section {
        background: linear-gradient(135deg, rgba(255,255,255,0.02) 0%, var(--surface-color) 100%);
    }
}

/* ========================================================
   INVOICING TAB PANELS
   ======================================================== */

#invoicing-tab .panel-section {
    border-left: 4px solid;
    border-radius: 8px;
    margin-bottom: 24px;
    padding: 5px 0 5px 15px;
}

#invoicing-tab .panel-section:first-child { border-left-color: #3b82f6; } /* Invoice History */
#invoicing-tab .panel-section:nth-child(2) { border-left-color: #f59e0b; } /* Create New Invoice */
#invoicing-tab .panel-section:nth-child(3) { border-left-color: #10b981; } /* Billable Design Milestones */
#invoicing-tab .panel-section:nth-child(4) { border-left-color: #ec4899; } /* Supervision Billing */
#invoicing-tab .panel-section:nth-child(5) { border-left-color: #8b5cf6; } /* Current Invoice Items */

/* ========================================================
   RESPONSIVE ADJUSTMENTS
   ======================================================== */

@media (max-width: 768px) {
    #main-tab .panel-section,
    #fees-tab .panel-section,
    #invoicing-tab .panel-section {
        padding-left: 10px;
        margin-bottom: 16px;
    }
    
    #main-tab .panel-section > h3,
    #fees-tab .panel-section > h3 {
        font-size: 1em;
    }
}

/* ========================================================
   PRINT STYLES - Preserve panel borders
   ======================================================== */

@media print {
    #main-tab .panel-section,
    #fees-tab .panel-section,
    #invoicing-tab .panel-section {
        border-left-width: 2px !important;
        page-break-inside: avoid;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
/* Fix for view-invoice-link small-button */
.view-invoice-link {
    text-decoration: underline;
    cursor: pointer;
    color: var(--primary-color);
    font-weight: bold;
}

/* Small button variant for invoice actions */
.small-button {
    padding: 4px 8px !important;
    font-size: 11px !important;
    margin: 0 !important;
    border-radius: 3px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

/* Specific styling for view-invoice-link when used as small-button */
.view-invoice-link.small-button {
    background-color: var(--primary-color) !important;
    color: white !important;
    text-decoration: none !important;
    border: none !important;
}

.view-invoice-link.small-button:hover {
    background-color: var(--primary-hover) !important;
    transform: translateY(-1px);
}

/* Success button (WhatsApp) */
.small-button.success {
    background-color: #25D366 !important;
    color: white !important;
    border: none !important;
}

.small-button.success:hover {
    background-color: #128C7E !important;
}

/* Info button (Email) */
.small-button.info {
    background-color: #3b82f6 !important;
    color: white !important;
    border: none !important;
}

.small-button.info:hover {
    background-color: #2563eb !important;
}

/* Danger button for delete actions */
.danger-button.small-button {
    background-color: #ef4444 !important;
    color: white !important;
    border: none !important;
    padding: 2px 6px !important;
}

.danger-button.small-button:hover {
    background-color: #dc2626 !important;
}

/* Invoice history table action buttons container */
#invoice-history-body td:last-child {
    white-space: nowrap;
}

#invoice-history-body .small-button {
    margin: 0 2px !important;
}

/* Payment details styling */
.payment-details {
    font-size: 0.75em;
    line-height: 1.4;
    color: #555;
    margin-top: 4px;
    padding: 4px;
    background: #f9f9f9;
    border-radius: 4px;
}

/* Record payment button */
.record-payment-btn {
    background-color: #f59e0b !important;
    color: white !important;
    border: none !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    margin: 0 !important;
    border-radius: 3px !important;
    cursor: pointer !important;
}

.record-payment-btn:hover {
    background-color: #d97706 !important;
}

/* Invoice status badges */
.status-raised {
    color: #f59e0b;
    font-weight: bold;
}

.status-paid {
    color: #10b981;
    font-weight: bold;
}

.status-pending {
    color: #ef4444;
    font-weight: bold;
}

.status-draft {
    color: #64748b;
    font-weight: bold;
}
/* Client Info Options Styling */
.client-info-options {
    margin: 15px 0;
    padding: 12px 15px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 8px;
    border-left: 3px solid #8b5cf6;
}

.client-info-options label {
    font-weight: 600;
    margin-bottom: 10px;
    display: block;
    color: #1e293b;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.client-info-options .checkbox-group {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
}

.client-info-options .checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.client-info-options .checkbox-item:hover {
    background: #e2e8f0;
}

.client-info-options input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: #8b5cf6;
}

.client-info-options .checkbox-item span {
    font-size: 0.85rem;
    color: #334155;
}

.client-info-options .help-text {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 8px;
    margin-bottom: 0;
    font-style: italic;
}

/* Dark theme support */
[data-theme="dark"] .client-info-options {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

[data-theme="dark"] .client-info-options .checkbox-item:hover {
    background: #334155;
}

[data-theme="dark"] .client-info-options .checkbox-item span {
    color: #cbd5e1;
}
#project-list-table th,
#project-list-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

#project-list-table th {
    background-color: var(--highlight-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

#project-list-table tbody tr:hover {
    background-color: #f9f9f9;
    cursor: pointer;
}

.status-in-progress {
    color: #d98d00;
    font-weight: bold;
}

.status-completed {
    color: green;
    font-weight: bold;
}

.status-on-hold {
    color: red;
    font-weight: bold;
}

.status-under-supervision {
    color: #00529B;
    font-weight: bold;
}

.status-pending {
    color: #666;
}

#project-list-table button {
    padding: 5px 10px;
    font-size: 12px;
    margin: 0 5px 0 0;
}

.invoice-reminder {
    margin-top: 8px;
    padding: 5px;
    background-color: #fffbe6;
    border: 1px solid #ffe58f;
    border-radius: 3px;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.invoice-reminder .raise-dashboard-invoice-btn {
    font-size: 11px;
    padding: 3px 8px;
    margin-left: 10px;
}

.invoice-status-dropdown,
.invoice-details-input,
.cheque-details-input {
    width: 100%;
    padding: 4px;
    font-size: 10pt;
    box-sizing: border-box;
    border-radius: 3px;
    border: 1px solid #ccc;
    margin-top: 2px;
}

.view-invoice-link {
    cursor: pointer;
    color: var(--primary-color);
    text-decoration: underline;
    font-weight: bold;
}

.invoice-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 8px;
    font-size: 10pt;
    padding: 2px 0;
    border-bottom: 1px solid #f0f0f0;
}

.invoice-row:last-child {
    border-bottom: none;
}


/* Project View Styles */
.container {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.controls {
    width: 550px;
    padding: 20px;
    background-color: var(--page-bg);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

#resizer {
    width: 6px;
    background: var(--border-color);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
}

#resizer:hover {
    background-color: var(--primary-color);
}

.container.is-resizing {
    cursor: col-resize;
    user-select: none;
}

.container.is-resizing .preview-area {
    pointer-events: none;
}

.preview-area {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--bg-color);
}

.preview-controls {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.preview-controls select,
.preview-controls button {
    padding: 8px;
}

.document-preview {
    background-color: var(--page-bg);
    margin: 0 auto;
    padding: 10mm;
    /* Reduced padding for mobile */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    color: #333;
    /* Dark Grey for text visibility */
    font-size: 10pt;
    line-height: 1.5;
    width: 100%;
    /* Make width fluid */
    max-width: 210mm;
    /* But constrain it on larger screens */
    height: auto;
}

.document-preview.full-width {
    max-width: none;
    width: 100%;
}

.document-preview.letter {
    max-width: 215.9mm;
}

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 30px;
}

.logo {
    font-size: 2.5em;
    color: var(--primary-color);
    font-weight: bold;
    font-family: sans-serif;
}

.company-name {
    text-align: center;
}

.company-name h1 {
    margin: 0;
    color: var(--primary-color);
    font-size: 16pt;
}

.company-name h2 {
    margin: 5px 0 0;
    font-size: 10pt;
    font-weight: normal;
}

.doc-header .arabic-name {
    font-size: 14pt;
    font-family: 'Amiri', serif;
}

h2,
h3,
h4 {
    color: var(--primary-color);
}

.controls h2,
.controls h3 {
    margin-top: 0;
}

.input-group,
details {
    margin-bottom: 15px;
}

.input-group label,
summary {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.input-group-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Default to 1 column */
    gap: 15px;
}

.other-input-container {
    display: none;
    margin-top: 8px;
}

.financial-summary {
    border: 1px solid var(--highlight-color);
    background-color: #fcfcfc;
    padding: 10px;
    border-radius: 4px;
    margin-top: 15px;
}

.financial-summary .summary-line {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.financial-summary .summary-line:not(:last-child) {
    border-bottom: 1px dashed #eee;
}

.financial-summary .summary-line span:first-child {
    font-weight: bold;
    color: #555;
}

.financial-summary .summary-line span:last-child {
    font-weight: bold;
}

summary {
    cursor: pointer;
    padding: 5px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 4px;
}

details>div {
    padding: 10px;
    border: 1px solid #eee;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

input,
select,
textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
}

.input-with-actions {
    position: relative;
}

.input-with-actions input,
.input-with-actions textarea {
    padding-right: 85px !important;
}

.format-actions {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 3px;
    z-index: 5;
}

/* Adjust for textarea where top alignment is better */
.input-with-actions textarea + .format-actions {
    top: 15px;
    transform: none;
}

.format-btn {
    background: #f0f0f0;
    color: #555;
    border: 1px solid #ccc;
    border-radius: 3px;
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    line-height: 1;
    transition: all 0.2s;
}

.format-btn:hover {
    background: #e0e0e0;
    border-color: #999;
    color: #000;
}

.format-btn:active {
    background: #d0d0d0;
    transform: translateY(1px);
}

.checkbox-group label,
.milestone-percent-group {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-weight: normal;
}

.milestone-percent-group input[type="number"] {
    width: 70px;
    margin-left: auto;
    text-align: right;
    -moz-appearance: textfield;
    appearance: textfield;
}

.milestone-percent-group input::-webkit-outer-spin-button,
.milestone-percent-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.checkbox-group input {
    width: auto;
    margin-right: 10px;
    flex-shrink: 0;
}

.nested-group {
    margin-left: 25px;
}

button {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
    margin-top: 0;
}

button:hover {
    opacity: 0.9;
}

.secondary-button {
    background-color: #6c757d;
}

.remove-btn {
    background-color: #dc3545;
    font-size: 10px;
    padding: 2px 6px;
    margin: 0;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.tab-button {
    padding: 10px 15px;
    cursor: pointer;
    border: none;
    background: #5a6268;
    color: #ffffff;
    border-bottom: 3px solid transparent;
    font-size: 12px;
    font-weight: 600;
    margin-right: 2px;
    border-radius: 4px 4px 0 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.tab-button:hover:not(.active) {
    background: #3d4449;
    color: #ffffff;
}

.tab-button.active {
    background: var(--page-bg);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    border-bottom: 3px solid var(--primary-color);
    font-weight: bold;
}

.tab-button.active:hover {
    background: var(--page-bg);
    color: var(--primary-color);
    opacity: 1;
}

.tab-content,
.preview-tab-content,
.sub-tab-content {
    display: none;
}

.tab-content {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 10px;
}

.tab-content.active,
.preview-tab-content.active,
.sub-tab-content.active {
    display: block;
}

.output-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.output-table th,
.output-table td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: left;
    font-size: 10pt;
}

.output-table th {
    background-color: #f2f2f2;
}

.preview-footer {
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
    padding-top: 10px;
    text-align: center;
    font-size: 9pt;
}

.signature-block {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 50px;
}

.signature-block>div {
    width: 100%;
}

#qr-code {
    margin-top: 10px;
}

.bank-details {
    border: 1px solid var(--primary-color);
    padding: 10px;
    margin-top: 25px;
    border-radius: 5px;
    font-size: 10pt;
}

#supervision-billing-monthly-container,
#supervision-billing-progress-container,
#supervision-billing-extended-container {
    display: none;
}

#supervision-progress-info,
#extended-supervision-info {
    font-size: 10pt;
    color: #555;
    margin-top: 5px;
}

#supervision-progress-info .progress-summary-line {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #888;
}

.modal-close-btn:hover {
    color: #000;
}

/* Gantt Chart Styles */

#villa-schedule-preview1 {
    border: 1px solid rgb(204, 204, 204);
    height: 100%;
    overflow: hidden;

    display: flex;
    flex-direction: column;
    width: 100%;
}

#villa-schedule-preview2 {
    border: 1px solid rgb(204, 204, 204);
    height: 100%;
    overflow: hidden;

    display: flex;
    flex-direction: column;
    width: 55vw;



}

/* ===================================================================================
// RESPONSIVE STYLES
// ===================================================================================*/

/* Tablet and smaller desktop */
@media (max-width: 992px) {

    body,
    html {
        overflow: auto;
        /* Allow scrolling on the body for mobile */
    }

    .view {
        height: auto;
        /* Allow view to grow with content */
    }

    /* Project View: Stack controls and preview vertically */
    .container {
        flex-direction: column;
        height: auto;
    }

    .controls {
        width: 100%;
        padding: 15px;
        flex-shrink: 1;
        border-bottom: 2px solid var(--border-color);
    }

    #resizer {
        display: none;
    }

    .preview-area {
        width: 100%;
        padding: 15px;
    }

    .input-group-grid {
        grid-template-columns: 1fr 1fr;
        /* Go back to 2 columns for tablets */
    }

}


/* Mobile phones */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-summary-container {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 10px;
        margin-left: 0;
        padding-right: 0;
    }

    .dashboard-header-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .input-group-grid {
        grid-template-columns: 1fr;
        /* Stack grid items */
    }

    .signature-block {
        flex-direction: column;
        gap: 40px;
    }

    /* Responsive Table to Card List */
    #project-list-table thead {
        display: none;
        /* Hide table headers */
    }

    #project-list-table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 4px;
        padding: 10px;
    }

    #project-list-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        /* Align data to the right */
        padding: 8px;
        border-bottom: 1px dashed #eee;
    }

    #project-list-table td:last-child {
        border-bottom: none;
    }

    #project-list-table td::before {
        content: attr(data-label);
        /* Use data-label for the 'header' */
        font-weight: bold;
        text-align: left;
        margin-right: 10px;
        /* Space between label and data */
    }

    #project-list-table td[data-label="Invoice Details"] {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .invoice-row {
        grid-template-columns: 1fr;
        /* Stack invoice details */
        width: 100%;
        text-align: left;
    }

    #project-list-table td[data-label="Actions"] {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* --- Rich Text Editor & Toolbar Styles --- */
.rich-text-editor-container {
    border: 1px solid #ced4da;
    border-radius: 4px;
    overflow: hidden;
    background: white;
    margin-top: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.editor-toolbar {
    background: #f8f9fa;
    border-bottom: 1px solid #ced4da;
    padding: 6px;
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-btn {
    border: 1px solid #dee2e6 !important;
    background: white !important;
    padding: 2px 10px !important;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9em;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333 !important;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: #e9ecef !important;
    border-color: #adb5bd !important;
    color: var(--primary-color) !important;
}

.toolbar-sep {
    color: #dee2e6;
    margin: 0 4px;
    font-size: 1.2em;
    user-select: none;
}

.toolbar-select {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.85em;
    padding: 4px;
    height: 32px;
    background: white;
    cursor: pointer;
}

.letter-content-editor {
    min-height: 400px;
    padding: 20px;
    outline: none;
    line-height: 1.6;
    font-family: 'Times New Roman', serif;
    font-size: 16px;
    background: white;
}

.letter-content-editor:focus {
    background: #fff;
}

.badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: bold;
    text-transform: uppercase;
}

.badge.success {
    background: #d4edda;
    color: #155724;
}

.badge.danger {
    background: #f8d7da;
    color: #721c24;
}

.badge.info {
    background: #d1ecf1;
    color: #0c5460;
}

/* ===================================================================================
// PRINT STYLES
// ===================================================================================*/
@media print {

    body,
    html,
    .view,
    .container {
        height: auto !important;
        overflow: visible !important;
        background: white !important;
    }

    .sidebar,
    .dashboard-header-controls,
    .dashboard-controls,
    .preview-controls,
    .controls,
    #resizer,
    .app-header,
    .tabs,
    .dashboard-summary-container,
    .tools-container>header {
        display: none !important;
    }

    .preview-area {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        background: white !important;
    }

    .document-preview {
        box-shadow: none !important;
        border: none !important;
        padding: 10mm !important;
        width: 210mm !important;
        margin: 0 auto !important;
        page-break-after: always;
    }

    .document-preview:last-child {
        page-break-after: auto;
    }

    .tool-card {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin-bottom: 0 !important;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* ===================================================================================
// PDF CAPTURE ISOLATION
// ===================================================================================*/
.pdf-capture {
    /* width: removed to allow JS dynamic setting */
    padding: 0px !important;
    background: white !important;
    box-shadow: none !important;
    border: none !important;
    font-size: 10.5pt !important;
    line-height: 1.5 !important;
    color: black !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
}

.pdf-capture * {
    max-width: 100% !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
}

.pdf-capture table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    font-size: 10pt !important;
}

.pdf-capture th,
.pdf-capture td {
    padding: 8px !important;
    border-bottom: 1px solid #eee !important;
    word-break: break-word !important;
}

/* Prevent layout tables (used for formatting bullet lists) from receiving grid borders and padding */
.pdf-capture table[style*="border: none"] th,
.pdf-capture table[style*="border: none"] td {
    padding: 0 !important;
    border-bottom: none !important;
    border: none !important;
}

.pdf-capture .company-name h1 {
    font-size: 16pt !important;
}

.pdf-capture .arabic-name {
    font-size: 14pt !important;
}

.pdf-capture .doc-header h3 {
    font-size: 12pt !important;
    margin-top: 10px !important;
}

/* Ensure nested structural components scroll gracefully locally without clipping */
.view, .tab-content, .sub-tab-content, .dashboard-main-content, .hr-dashboard, #dashboard-view, #project-view {
    overflow-y: auto;
}