:root {
    --primary-color: #4318FF;
    --primary-hover: #3311cc;
    --bg-color: #F4F7FE;
    --sidebar-bg: #FFFFFF;
    --card-bg: #FFFFFF;
    --text-main: #2B3674;
    --text-muted: #A3AED0;
    --border-light: #E0E5F2;
    --input-bg: #F4F7FE;
    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-soft: 0px 4px 20px rgba(0, 0, 0, 0.03);
    --transition: all 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; }
body { background-color: var(--bg-color); color: var(--text-main); display: flex; height: 100vh; overflow: hidden; }

/* Login Overlay Styles */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color);
    display: flex; justify-content: center; align-items: center;
    z-index: 9999;
}
.login-card {
    background: white; padding: 40px; border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); width: 100%; max-width: 400px;
    text-align: center;
}
.login-card h2 { margin-bottom: 10px; font-size: 24px; }
.login-card p { color: var(--text-muted); margin-bottom: 25px; font-size: 14px; }
.login-card .logo { justify-content: center; margin-bottom: 20px; }

/* Sidebar Styles */
.sidebar { width: 260px; background-color: var(--sidebar-bg); padding: 30px 20px; display: flex; flex-direction: column; box-shadow: 2px 0 10px rgba(0,0,0,0.02); z-index: 10; }
.logo { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; color: var(--text-main); margin-bottom: 40px; padding: 0 10px; }
.logo i { color: var(--primary-color); background: #E9E3FF; padding: 8px; border-radius: 50%; }
.nav-links { list-style: none; display: flex; flex-direction: column; gap: 10px; flex-grow: 1;}
.nav-item { padding: 12px 20px; border-radius: var(--radius-md); cursor: pointer; display: flex; align-items: center; gap: 15px; color: var(--text-muted); font-weight: 600; transition: var(--transition); }
.nav-item:hover { background-color: var(--input-bg); color: var(--text-main); }
.nav-item.active { background-color: var(--primary-color); color: white; box-shadow: 0 4px 15px rgba(67, 24, 255, 0.3); }
.nav-item.create-new { background-color: var(--primary-color); color: white; margin-bottom: 20px; justify-content: center; box-shadow: 0 4px 15px rgba(67, 24, 255, 0.3); }

/* Main Content Area */
.main-content { flex-grow: 1; padding: 40px; overflow-y: auto; position: relative; }
.view-section { display: none; animation: fadeIn 0.4s ease-out; max-width: 1000px; margin: 0 auto;}
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.page-header { margin-bottom: 30px; display: flex; justify-content: space-between; align-items: center;}
.page-header h1 { font-size: 30px; font-weight: 700; margin-bottom: 8px; }
.page-header p { color: var(--text-muted); font-weight: 500; }

/* Cards and Forms */
.card { background: var(--card-bg); border-radius: var(--radius-lg); padding: 30px; box-shadow: var(--shadow-soft); margin-bottom: 30px; }
.no-padding { padding: 0 !important; overflow: hidden; }
.mb-20 { margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.form-grid.two-cols { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.form-group label { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
input, select { width: 100%; padding: 12px 15px; border: 1px solid var(--border-light); border-radius: var(--radius-md); background-color: var(--input-bg); color: var(--text-main); font-size: 14px; font-weight: 500; transition: var(--transition); outline: none; }
input:focus, select:focus { border-color: var(--primary-color); background-color: #fff; box-shadow: 0 0 0 3px rgba(67, 24, 255, 0.1); }

.info-banner { background: var(--bg-color); padding: 15px; border-radius: var(--radius-md); margin-bottom: 20px; border-left: 4px solid var(--primary-color); }
.info-banner p { font-size: 13px; font-weight: 600; color: var(--text-main); }
.info-banner i { color: var(--primary-color); margin-right: 8px; }

/* Buttons */
.btn { padding: 12px 24px; border-radius: var(--radius-md); border: none; font-weight: 600; font-size: 14px; cursor: pointer; transition: var(--transition); display: inline-flex; align-items: center; gap: 8px; }
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: #E2E8F0; color: var(--text-main); }
.btn-secondary:hover { background-color: #CBD5E1; }
.btn-light { background-color: #E9E3FF; color: var(--primary-color); }
.btn-light:hover { background-color: #D6CCFF; }
.btn-success { background-color: #059669; color: white; }
.btn-success:hover { background-color: #047857; }
.btn-danger { background-color: #FFE2E5; color: #F64E60; }
.btn-danger:hover { background-color: #F64E60; color: white;}

/* Line Items Section */
.line-items-wrapper { background-color: var(--input-bg); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 30px; }
.line-items-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.line-item-row { display: grid; grid-template-columns: 3fr 1fr 1fr 1.5fr auto; gap: 15px; margin-bottom: 15px; align-items: center; background: white; padding: 10px; border-radius: var(--radius-md); }
.delete-btn { background: #FFE2E5; color: #F64E60; border: none; padding: 10px; border-radius: 6px; cursor: pointer; transition: var(--transition); }
.delete-btn:hover { background: #F64E60; color: white; }
.actions-footer { display: flex; gap: 15px; padding-top: 20px; border-top: 1px dashed var(--border-light); }

/* Data Tables for Quotes/Invoices */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 15px; color: var(--text-muted); font-size: 12px; text-transform: uppercase; border-bottom: 2px solid var(--border-light); }
.data-table td { padding: 15px; border-bottom: 1px solid var(--border-light); font-weight: 500; }
.data-table tr { transition: background 0.2s; cursor: pointer;}
.data-table tbody tr:hover { background: var(--input-bg); }
.status-badge { padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.status-pending { background: #FFF4DE; color: #FFA800; }
.status-completed { background: #E1FCEF; color: #059669; }
.edit-link { color: var(--primary-color); text-decoration: none; font-weight: 700; }

/* --- PRINT/PREVIEW DOCUMENT STYLES --- */
.preview-actions { display: flex; justify-content: space-between; margin-bottom: 20px; }
#preview-wrapper { background: #E2E8F0; padding: 20px; border-radius: var(--radius-md); max-height: 70vh; overflow-y: auto; }

#preview-container { 
    background: white; 
    padding: 40px; 
    max-width: 800px; 
    margin: 0 auto; 
    color: black; 
    font-family: 'Times New Roman', Times, serif; 
    line-height: 1.4;
}

.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.doc-table th, .doc-table td { border: 1px solid black; padding: 6px 10px; vertical-align: top; font-size: 13px; }
.doc-title { text-align: center; font-weight: bold; font-size: 18px; margin-bottom: 10px; text-transform: uppercase; }

.half-width { width: 50%; }
.company-header-cell { padding: 10px !important; }
.company-name-title { font-size: 15px; font-weight: bold; display: block; margin-bottom: 5px; }
.link-text { color: blue; text-decoration: underline; }
.address-box { display: block; max-width: 280px; margin-bottom: 5px; }
.logo-cell { padding: 0 !important; vertical-align: middle !important; text-align: center; background: #011E3D; }
.real-logo { max-width: 100%; max-height: 110px; object-fit: contain; display: block; width: 100%; height: 100%; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.totals-row td { font-weight: bold; }
.totals-row-bg { background: #f4f4f4; }
.signature-section { 
    margin-top: 40px; 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-end;
    page-break-inside: avoid;
}
.auth-sign-box { display: flex; flex-direction: column; width: 250px; }
.real-signature { max-width: 150px; height: auto; margin-top: 15px; margin-bottom: 5px; min-height: 50px; }
.real-stamp { max-width: 130px; height: auto; object-fit: contain; min-height: 80px; margin-right: 20px; }