html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

.login-layout {
    display: flex !important; 
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #2c3e50;
}

/* ==========================================================================
   1. GLOBAL & BASE STYLES
   ========================================================================== */
* { box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background-color: #f4f4f5; color: #333; padding: 20px; margin: 0; }

/* ==========================================================================
   2. UTILITIES & BUTTONS
   ========================================================================== */
.hidden-body { visibility: hidden; }
.action-buttons { text-align: center; margin-top: 20px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.bottom-nav { text-align: center; margin-top: 15px; margin-bottom: 30px; }
button { color: white; border: none; padding: 10px 15px; cursor: pointer; border-radius: 4px; font-weight: bold; transition: background-color 0.2s; }
.btn-green { background-color: #2ecc71; }
.btn-blue { background-color: #3498db; }
.btn-yellow { background-color: #f1c40f; color: #333; }
.btn-dark { background-color: #34495e; }
.btn-whatsapp { background-color: #25D366; }
.btn-red { background-color: #e74c3c; }
.btn-gray { background-color: #7f8c8d; padding: 12px 20px; width: 100%; max-width: 800px; }
.view-btn { background: #3498db; padding: 6px 12px; font-size: 12px; border-radius: 4px; }
.view-btn:hover { background: #2980b9; }
.delete-btn { background-color: #e74c3c; padding: 6px 10px; }
input, textarea, select { border: 1px solid #ccc; padding: 8px; border-radius: 4px; font-size: 14px; width: 100%; }

/* ==========================================================================
   3. GLOBAL LOADER
   ========================================================================== */
.loader-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: #f4f4f5; display: flex; justify-content: center; align-items: center; z-index: 10000; visibility: visible; }
.spinner { width: 40px; height: 40px; border: 4px solid rgba(0,0,0,0.1); border-top: 4px solid #3498db; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ==========================================================================
   4. AUTH & LOGIN PAGE
   ========================================================================== */
.auth-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background-color: #2c3e50; margin: 0; }
.login-box { background: white; padding: 40px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); width: 100%; max-width: 350px; text-align: center; }
.login-logo { max-width: 120px; margin-bottom: 20px; }
.login-box input { margin-bottom: 15px; box-sizing: border-box; }
#login-btn { width: 100%; background: #3498db; }

/* ==========================================================================
   5. DASHBOARD & TABS (VERTICAL LAYOUT)
   ========================================================================== */
.dashboard-box { max-width: 1100px; margin: auto; background: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); border-top: 6px solid #3498db; }
.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; border-bottom: 1px solid #eee; padding-bottom: 15px; }
.dashboard-layout { display: flex; gap: 30px; align-items: flex-start; }
.tab-container { display: flex; flex-direction: column; width: 220px; flex-shrink: 0; border-right: 1px solid #ddd; padding-right: 15px; gap: 5px; }
.tab-btn { background: transparent; padding: 12px 15px; font-size: 15px; color: #7f8c8d; border-radius: 6px; border: 1px solid transparent; text-align: left; transition: 0.3s; font-weight: 600; cursor: pointer; }
.tab-btn:hover { background: #f8f9fa; color: #2c3e50; }
.tab-btn.active { background: #e0f0fa; color: #3498db; border-left: 4px solid #3498db; border-radius: 0 6px 6px 0; padding-left: 11px; } 
.content-area { flex-grow: 1; min-width: 0; }
.tab-content { display: none; animation: fadeIn 0.3s; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.dash-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dash-table th, .dash-table td { padding: 12px 10px; border-bottom: 1px solid #eee; text-align: left; }
.dash-table th { background: #f8f9fa; font-weight: 600; border-top: 1px solid #eee;}
.dash-table tr:hover { background: #f0f7ff; }

/* ==========================================================================
   6. PORTFOLIO ADMIN (DRAG & DROP)
   ========================================================================== */
.img-preview-box { position: relative; width: 100px; height: 100px; border: 3px solid #ccc; cursor: grab; border-radius: 6px; overflow: visible; transition: 0.2s; background: #fff; }
.img-preview-box:active { cursor: grabbing; }
.img-preview-box img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.img-preview-box:hover { border-color: #3498db; }
.img-preview-box.is-cover { border-color: #2ecc71; transform: scale(1.05); box-shadow: 0 4px 10px rgba(46, 204, 113, 0.4); }
.img-preview-box.drag-over { border: 3px dashed #3498db; opacity: 0.6; transform: scale(0.95); }
.cover-badge { position: absolute; top: 0; left: 0; width: 100%; background: rgba(46, 204, 113, 0.95); color: white; font-size: 11px; text-align: center; padding: 4px 0; display: none; z-index: 2; border-radius: 2px 2px 0 0; }
.img-preview-box.is-cover .cover-badge { display: block; }
.remove-img-btn { position: absolute; top: -8px; right: -8px; background: #e74c3c; color: white; border-radius: 50%; width: 22px; height: 22px; font-size: 12px; display: none; align-items: center; justify-content: center; z-index: 10; box-shadow: 0 2px 5px rgba(0,0,0,0.3); }
.remove-img-btn:hover { background: #c0392b; transform: scale(1.1); }
.img-preview-box:hover .remove-img-btn { display: flex; }

/* ==========================================================================
   7. PROJECT LIGHTBOX
   ========================================================================== */
.hidden-gallery { display: none; }
.p-lightbox { display: none; position: fixed; z-index: 5000; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 15, 15, 0.98); backdrop-filter: blur(10px); }
.p-lightbox-content { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 20px; }
#active-p-img { max-width: 90%; max-height: 80vh; object-fit: contain; border: 1px solid #b08d55; box-shadow: 0 0 50px rgba(0,0,0,0.5); transition: opacity 0.3s ease, transform 0.3s ease; }
#p-caption { color: #b08d55; margin-top: 20px; font-family: 'Century Gothic', sans-serif; letter-spacing: 2px; text-transform: uppercase; font-weight: bold; }
.nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: none; font-size: 40px; padding: 20px; z-index: 5001; border: none; color: white; cursor: pointer; }
.nav-btn:hover { color: #b08d55; }
.prev-btn { left: 10px; }
.next-btn { right: 10px; }
.close-p-lightbox { position: absolute; top: 20px; right: 30px; font-size: 40px; color: white; cursor: pointer; z-index: 5001; }

/* ==========================================================================
   8. INVOICE MODULE
   ========================================================================== */
.invoice-box { max-width: 800px; margin: auto; background: #fff; padding: 40px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); border-top: 6px solid #2c3e50; }
.invoice-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 25px; }
.header-left { display: flex; flex-direction: column; gap: 15px; }
.company-logo { max-width: 150px; margin-bottom: 5px; display: block; }
.company-info h1 { margin: 0 0 2px 0; color: #2c3e50; font-size: 28px; }
.company-info p { margin: 2px 0; color: #7f8c8d; font-size: 13px; line-height: 1.4;}
.header-right { display: flex; flex-direction: column; align-items: flex-end; }
.invoice-title-text { text-align: right; margin: 0 0 15px 0; color: #e74c3c; font-size: 32px; letter-spacing: 2px; }

.invoice-meta-grid { display: table; border-collapse: separate; border-spacing: 0 8px; width: 250px; }
.meta-row { display: table-row; }
.meta-label { display: table-cell; font-weight: bold; color: #555; font-size: 14px; width: 90px; text-align: left; vertical-align: middle; }
.meta-value { display: table-cell; vertical-align: middle; }
.meta-value input, .meta-value select { width: 150px; border: 1px solid #ccc; background: transparent; padding: 6px; border-radius: 4px; font-size: 14px; box-sizing: border-box; }

.search-box { margin-bottom: 20px; position: relative; background: #f8f9fa; padding: 15px; border-radius: 6px; border: 1px solid #ddd; }
.search-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #ddd; z-index: 1000; display: none; box-shadow: 0 4px 8px rgba(0,0,0,0.1); max-height: 200px; overflow-y: auto;}
.search-item { padding: 10px; border-bottom: 1px solid #eee; cursor: pointer; }
.search-item:hover { background: #f0f7ff; }

.client-info { margin-bottom: 25px; }
.client-info h3 { margin-bottom: 15px; color: #2c3e50; border-bottom: 1px solid #eee; padding-bottom: 5px; }
.customer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-group label { display: block; font-size: 11px; color: #7f8c8d; margin-bottom: 3px; text-transform: uppercase; font-weight: bold; }

.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 15px; }
.invoice-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.invoice-table th, .invoice-table td { padding: 12px; border-bottom: 1px solid #eee; text-align: left; }
.invoice-table th { background-color: #f8f9fa; color: #2c3e50; font-weight: 600; }
.invoice-table td.amount { text-align: right; font-weight: bold; }
.invoice-table input, .invoice-table select, .invoice-table textarea { border: 1px solid transparent; background: transparent; }
.invoice-table input:hover, .invoice-table input:focus, .invoice-table textarea:hover, .invoice-table textarea:focus { border: 1px solid #3498db; background: #fff; }

.invoice-footer-split { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 40px; margin-top: 20px;}
.terms-box { width: 55%; color: #555; }
.terms-box h4 { margin: 0 0 10px 0; color: #2c3e50; font-size: 14px; text-transform: uppercase;}
.terms-box ol { margin: 0; padding-left: 15px; font-size: 12px; line-height: 1.6;}
.invoice-summary { width: 40%; }
.summary-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #eee; }
.discount-container { display: flex; align-items: center; justify-content: flex-end; }
.discount-dropdown { width: auto !important; margin-right: 5px; padding: 4px; }
.discount-container input { width: 80px; text-align: right; border: 1px solid #ccc; padding: 4px; }
.summary-row.total { font-size: 18px; font-weight: bold; border-top: 2px solid #2c3e50; padding-top: 15px; border-bottom: none; }

/* ==========================================================================
   9. RESPONSIVE QUERIES
   ========================================================================== */
@media screen and (max-width: 768px) {
    body { padding: 10px; }
    .dashboard-header { flex-direction: column; gap: 15px; text-align: center; }
    .dashboard-layout { flex-direction: column; gap: 15px; }
    .tab-container { width: 100%; border-right: none; padding-right: 0; flex-direction: row; overflow-x: auto; white-space: nowrap; border-bottom: 1px solid #ddd; padding-bottom: 10px; gap: 10px; }
    .tab-btn { border-left: none; text-align: center; padding: 10px 15px; border-bottom: 2px solid transparent; flex-shrink: 0; }
    .tab-btn.active { border-left: none; border-bottom: 2px solid #3498db; border-radius: 4px 4px 0 0; background: #e0f0fa; padding-left: 15px; }
    .tab-content { padding: 0; }
    .invoice-box { padding: 20px; }
    .invoice-header { flex-direction: column; gap: 20px; }
    .header-right { align-items: flex-start; }
    .invoice-title-text { text-align: left; }
    .customer-grid { grid-template-columns: 1fr; }
    .invoice-footer-split { flex-direction: column; gap: 30px; }
    .terms-box, .invoice-summary { width: 100%; }
    .action-buttons { flex-direction: column; gap: 10px; }
    button { width: 100%; padding: 15px; font-size: 16px; }
}

/* ==========================================================================
   10. PRINT MEDIA
   ========================================================================== */
@media print {
    .hide-on-print { display: none !important; }
    .print-only { display: inline !important; } 
    body { background-color: #fff; padding: 0; font-size: 14px; color: #000; }
    .invoice-box { box-shadow: none; border: none; padding: 0; max-width: 100%; margin: 0; }
    .company-logo { max-width: 90px; margin-bottom: 5px; } 
    .company-info h1 { font-size: 22px; margin-bottom: 2px; }
    .company-info p { font-size: 12px; margin: 0; }
    .invoice-header { margin-bottom: 20px; display: flex; flex-direction: row; justify-content: space-between; }
    .header-right { align-items: flex-end; }
    .invoice-title-text { font-size: 24px; margin-bottom: 10px; text-align: right; }
    .invoice-meta-grid { width: 250px; }
    .meta-label { width: 90px !important; min-width: 90px; }
    .meta-value input, .discount-container input { border: none; padding: 0; background: transparent; }
    .client-info { margin-bottom: 20px; }
    .client-info h3 { margin-bottom: 8px; font-size: 16px; padding-bottom: 2px; border-bottom: 1px solid #ccc; }
    .customer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 5px; }
    .table-responsive { overflow-x: visible; }
    .invoice-table { min-width: 100%; margin-bottom: 15px; }
    .invoice-table th, .invoice-table td { padding: 6px 8px; border-bottom: 1px solid #ddd; font-size: 14px; } 
    .invoice-table th { background-color: #eee !important; -webkit-print-color-adjust: exact; }
    input, select { border: none; background: transparent; padding: 0; appearance: none; -webkit-appearance: none; font-size: 14px; color: #000; }
    
    /* FIX: Allow textareas to expand naturally in PDF */
    .auto-expand { overflow: visible !important; height: max-content !important; white-space: pre-wrap; word-wrap: break-word; }
    textarea { border: none; background: transparent; padding: 0; font-size: 14px; color: #000; resize: none; overflow: visible !important; height: max-content !important; }
    
    .invoice-footer-split { display: flex; flex-direction: row; justify-content: space-between; margin-bottom: 0;}
    .terms-box { width: 50%; }
    .invoice-summary { width: 45%; margin-top: 0; }
    .summary-row { padding: 5px 0; font-size: 14px; border-bottom: 1px solid #ddd;}
    .summary-row.total { padding-top: 8px; font-size: 16px; border-top: 2px solid #000; }
    @page { margin: 1cm; size: A4 portrait; }
}

/* ==========================================================================
   11. PAGINATION & PAYMENT STATUS
   ========================================================================== */
.pagination-container { display: flex; justify-content: flex-end; gap: 6px; margin-top: 15px; flex-wrap: wrap;}
.page-btn { padding: 6px 12px; border: 1px solid #ddd; background: #fff; cursor: pointer; border-radius: 4px; font-size: 13px; color: #333; transition: 0.2s;}
.page-btn:hover { background: #f0f7ff; border-color: #3498db; }
.page-btn.active { background: #3498db; color: white; border-color: #3498db; font-weight: bold; }

/* ==========================================================================
   12. MODALS & PROJECT CARDS
   ========================================================================== */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 9999; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.modal-overlay.active { display: flex; animation: fadeIn 0.2s ease-out; }
.modal-box { background: #fff; padding: 25px; border-radius: 8px; width: 90%; max-width: 800px; max-height: 85vh; overflow-y: auto; position: relative; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.modal-close { position: absolute; top: 15px; right: 20px; font-size: 28px; cursor: pointer; color: #7f8c8d; transition: 0.2s; line-height: 1; }
.modal-close:hover { color: #e74c3c; }
.project-card { background: #f8f9fa; border: 1px solid #e1e8ed; padding: 15px; border-radius: 6px; margin-bottom: 15px; }
.project-card h4 { margin-top: 0; color: #2980b9; border-bottom: 2px solid #3498db; padding-bottom: 8px; margin-bottom: 10px; display: flex; justify-content: space-between;}
.mini-tag { background: #ecf0f1; color: #2c3e50; padding: 2px 8px; border-radius: 12px; font-size: 11px; margin-right: 5px; border: 1px solid #bdc3c7; display: inline-block; margin-bottom: 3px; }

/* ==========================================================================
   MODERN AUTO-EXPANDING TEXTAREAS & BORDERLESS INPUTS
   ========================================================================== */
.auto-expand { 
    width: 100%; 
    font-family: inherit; 
    font-size: 14px; 
    line-height: 1.5; 
    border: 1px solid transparent; 
    background: transparent; 
    border-radius: 4px; 
    padding: 6px; 
    resize: none; 
    outline: none; 
    field-sizing: content; 
    min-height: 33px;
}
.auto-expand:hover, .auto-expand:focus { background: #fdfdfd; border: 1px solid #eee; }

.meta-input { width: 120px; border: 1px solid transparent; background: transparent; font-size: 14px; padding: 2px 5px; color: #333; outline: none; }
.meta-input:hover, .meta-input:focus { background: #fdfdfd; border: 1px solid #eee; border-radius: 4px;}

/* ==========================================================================
   INVOICE / PROPOSAL PRINT SPECIFIC STYLES
   ========================================================================== */
.letterhead-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #b08d55; padding-bottom: 10px; margin-bottom: 15px; }
.letterhead-logo { max-height: 70px; width: auto; }
.letterhead-info { text-align: right; font-size: 12px; color: #555; line-height: 1.4; }
.letterhead-info h1 { margin: 0 0 2px 0; color: #2c3e50; font-size: 18px; text-transform: uppercase; letter-spacing: 1px; }
.invoice-section { margin-bottom: 20px; page-break-inside: avoid; break-inside: avoid; clear: both; }
.invoice-section h3 { color: #2c3e50; border-bottom: 1px solid #eee; padding-bottom: 4px; margin-bottom: 10px; font-size: 16px; text-transform: uppercase; letter-spacing: 0.5px; }

.invoice-summary-wrapper { display: flex; justify-content: flex-end; margin-bottom: 20px; clear: both; }
.footer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.footer-box { background: #fdfdfd; border: 1px solid #eee; padding: 15px; border-radius: 6px; }
.footer-box h4 { margin: 0 0 10px 0; color: #2c3e50; font-size: 13px; text-transform: uppercase; border-bottom: 1px solid #ddd; padding-bottom: 5px;}
.vendor-tag { background: #34495e; color: white; padding: 4px 10px; border-radius: 15px; font-size: 12px; display: inline-flex; align-items: center; gap: 8px; margin-top: 5px;}
.vendor-tag span { cursor: pointer; color: #e74c3c; font-weight: bold; transition: 0.3s;}

/* ==========================================================================
   13. PDF PRINT STRICT GRID FIX
   ========================================================================== */
@media print {
    .invoice-table {
        table-layout: fixed !important;
        width: 100% !important;
    }

    .invoice-table th, .invoice-table td {
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        padding: 6px 8px !important;
        vertical-align: top !important;
    }

    .invoice-table input, 
    .invoice-table select, 
    .invoice-table textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        resize: none !important;
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
}