:root {
    --bg-main: #FAFAFA;
    --bg-card: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --text-light: #9CA3AF;
    --border-color: #E5E7EB;
    /* Primary brand/accent color. We use a deep UI black/indigo mix for premium feel */
    --accent: #0F172A;
    --accent-hover: #1E293B;
    --primary-blue: #2563EB;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    --shadow-focus: 0 0 0 3px rgba(15, 23, 42, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
}

.app-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header */
.main-header {
    text-align: center;
    margin-bottom: 50px;
    animation: fadeInDown 0.6s ease;
}

.logo-container {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: #fff;
    box-shadow: var(--shadow-md);
    margin-bottom: 16px;
    overflow: hidden;
    padding: 8px;
}

.logo-container img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.header-title {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--accent);
}

/* Step Mechanism */
.step {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.step.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Form Styles */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: fadeInUp 0.5s ease backwards;
}

.card-header {
    padding: 24px 32px 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.card-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.card-body {
    padding: 24px 32px;
}

.form-group {
    margin-bottom: 20px;
}
.form-group:last-child {
    margin-bottom: 0;
}

.row-group {
    display: flex;
    gap: 20px;
}
.row-group .col {
    flex: 1;
}

label {
    display: block;
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-main);
}
.req {
    color: #ef4444;
}

input[type="text"], input[type="email"], input[type="tel"], input[type="number"], 
select, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 15px;
    color: var(--text-main);
    background: var(--bg-main);
    transition: all 0.2s ease;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}

input::placeholder, textarea::placeholder {
    color: var(--text-light);
}

.mt-24 { margin-top: 24px; }

/* Service Checklist & Pricing */
.services-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.service-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    transition: all 0.2s ease;
}

.service-row:hover {
    border-color: #d1d5db;
    box-shadow: var(--shadow-sm);
}
.service-row.active {
    border-color: var(--primary-blue);
    background: #eff6ff;
}

.service-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
}

.service-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.custom-check {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    border-radius: var(--radius-sm);
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: #fff;
}

.service-checkbox input:checked ~ .custom-check {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
}

.service-checkbox input:checked ~ .custom-check::after {
    content: "";
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.service-price-wrapper {
    position: relative;
    width: 140px;
}

.service-price-wrapper input {
    padding-right: 30px;
    text-align: right;
    font-weight: 500;
}
.service-price-wrapper input:disabled {
    background: #f3f4f6;
    opacity: 0.6;
    cursor: not-allowed;
}
.service-price-wrapper .currency {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.live-calculation-box {
    margin-top: 24px;
    padding: 16px 20px;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.calc-row:last-child {
    margin-bottom: 0;
}

.calc-row span {
    font-weight: 500;
}

.calc-val {
    color: var(--text-main);
    font-weight: 600;
}

.calc-grand {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
    font-size: 16px;
    color: var(--accent);
}

.calc-grand .calc-val {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.form-actions {
    margin-top: 32px;
    display: flex;
    justify-content: flex-end;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
    width: 100%;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(15, 23, 42, 0.2);
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 rgba(15, 23, 42, 0.25);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}
.btn-ghost:hover {
    background: #f3f4f6;
    color: var(--text-main);
}

/* Loading Screen */
#step-loading {
    display: none; /* Controlled by JS */
    opacity: 0;
    min-height: 50vh;
}
#step-loading.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 1;
}

.loader-container {
    text-align: center;
    max-width: 320px;
    width: 100%;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 24px;
    animation: spin 1s linear infinite;
}

#loading-text {
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 16px;
    font-size: 16px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: var(--primary-blue);
    transition: width 0.3s ease;
}

/* Result & PDF Layout container */
#step-result {
    display: none;
}
#step-result.active {
    display: block;
}

.result-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
}

/* This is the element we pass to html2pdf */
.a4-container {
    background: #fff;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: 0 auto;
    /* Visual preview constraints */
    border: 1px solid var(--border-color);
}

.proposal-doc {
    /* Standard A4 dimensions mapped loosely to pixels for web preview */
    width: 100%;
    max-width: 794px; /* A4 width roughly at 96dpi is 794px */
    margin: 0 auto;
    padding: 60px 50px;
    color: #1a1a1a;
    font-family: 'Inter', sans-serif;
    font-size: 13pt;
    line-height: 1.6;
    background-color: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Document Internal Styling */
.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #000;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.doc-logo {
    height: 40px;
}

.doc-meta {
    text-align: right;
}

.doc-meta h1 {
    font-size: 18pt;
    font-weight: 700;
    margin: 0 0 5px 0;
    letter-spacing: -0.02em;
}

.doc-date {
    color: #666;
    font-size: 11pt;
}

.doc-cover-details {
    display: flex;
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 40px;
}

.detail-box {
    flex: 1;
}

.detail-label {
    display: block;
    font-size: 10pt;
    color: #64748b;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.detail-box strong {
    font-size: 13pt;
    font-weight: 600;
    color: #0f172a;
}

.doc-section {
    margin-bottom: 40px;
}

.section-title {
    font-size: 15pt;
    font-weight: 700;
    color: #000;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.subsection-title {
    font-size: 12pt;
    font-weight: 600;
    margin: 20px 0 10px;
    color: #334155;
}

.entry-letter {
    font-size: 12.5pt;
    color: #334155;
    text-align: justify;
}

.whitespace-pre {
    white-space: pre-wrap;
}

.pricing-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.pricing-table th {
    background: #f1f5f9;
    color: #475569;
    text-transform: uppercase;
    font-size: 9pt;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #cbd5e1;
}

.pricing-table td {
    padding: 14px 15px;
    border-bottom: 1px solid #e2e8f0;
    color: #1e293b;
}

.pricing-table th.text-right, .pricing-table td.text-right {
    text-align: right;
}

.pricing-table tfoot td {
    padding: 12px 15px;
    background: #fafaf9;
    font-size: 11pt;
    border-bottom: 1px solid #e2e8f0;
}

.pricing-table .tfoot-grand td {
    padding: 16px 15px;
    font-size: 14pt;
    border-top: 2px solid #000;
    border-bottom: 2px solid #000;
}

/* ADMIN LAYOUT - PREMIUM OVERHAUL */
.admin-body { display: flex; min-height: 100vh; margin: 0; background: #FAFAFB; overflow-x: hidden; font-family: 'Inter', sans-serif; color: #111827; }
.sidebar { width: 280px; background: #FFFFFF; border-right: 1px solid #E5E7EB; display: flex; flex-direction: column; flex-shrink: 0; position: relative; z-index: 10; }
.sidebar-logo { padding: 32px 24px; text-align: left; }
.sidebar-logo img { max-width: 130px; }
.sidebar-nav { padding: 10px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sidebar-nav a { display: flex; align-items: center; gap: 14px; text-decoration: none; color: #64748B; font-weight: 500; padding: 12px 16px; border-radius: 12px; transition: all 0.2s ease; font-size: 15px; }
.sidebar-nav a i { font-size: 22px; transition: 0.2s ease; }
.sidebar-nav a:hover { background: #F1F5F9; color: #0F172A; }
.sidebar-nav a.active { background: #0F172A; color: #FFFFFF; box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15); }
.sidebar-nav a.logout-link { color: #EF4444; margin-top: auto; margin-bottom: 24px; }
.sidebar-nav a.logout-link:hover { background: #FEF2F2; }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: #FAFAFB; }
.top-header { height: 80px; background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid #E5E7EB; display: flex; align-items: center; justify-content: space-between; padding: 0 40px; flex-shrink: 0; position: sticky; top: 0; z-index: 50; }
.header-title h2 { margin: 0; font-size: 20px; font-weight: 600; color: #0F172A; letter-spacing: -0.01em; }
.header-user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #64748B; font-weight: 500; }
.header-avatar { width: 36px; height: 36px; border-radius: 50%; background: #E2E8F0; display: flex; align-items: center; justify-content: center; color: #0F172A; font-weight: 600; font-size: 14px; }
.content-wrapper { padding: 40px; overflow-y: auto; flex: 1; overflow-x: hidden; }

/* Dashboard Cards Premium */
.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; margin-bottom: 32px; }
.stat-card { background: #FFFFFF; border-radius: 16px; padding: 28px; box-shadow: 0 2px 6px rgba(0,0,0,0.02); border: 1px solid #E5E7EB; transition: transform 0.3s ease, box-shadow 0.3s ease; position: relative; overflow: hidden; }
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(0,0,0,0.06); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; background: #F1F5F9; color: #0F172A; display: flex; align-items: center; justify-content: center; font-size: 24px; margin-bottom: 20px; }
.stat-icon.green { background: #DCFCE7; color: #16A34A; }
.stat-icon.blue { background: #DBEAFE; color: #2563EB; }
.stat-title { font-size: 13px; text-transform: uppercase; color: #64748B; letter-spacing: 0.05em; font-weight: 600; margin-bottom: 6px; display: block; }
.stat-val { font-size: 32px; font-weight: 700; color: #0F172A; letter-spacing: -0.02em; display: block; }

/* General Cards & Tables */
.card { background: #FFFFFF; border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.03); border: 1px solid #E5E7EB; margin-bottom: 24px; overflow: hidden; }
.card-header { padding: 24px 32px; border-bottom: 1px solid #F1F5F9; background: #FFFFFF; }
.card-header h2 { font-size: 18px; color: #0F172A; font-weight: 600; }
.card-body { padding: 32px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: #F8FAFC; color: #64748B; font-size: 12px; text-transform: uppercase; padding: 16px 24px; text-align: left; border-bottom: 1px solid #E5E7EB; letter-spacing: 0.05em; }
.data-table td { padding: 20px 24px; border-bottom: 1px solid #F1F5F9; vertical-align: middle; color: #111827; font-size: 14px; }
.data-table tr:hover { background: #F8FAFC; }

/* Premium Buttons */
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 8px; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s ease; cursor: pointer; border: 1px solid transparent; background: transparent; gap: 6px; }
.btn-sm.text-primary { color: #2563EB; background: #EFF6FF; }
.btn-sm.text-primary:hover { background: #DBEAFE; }
.btn-sm.text-danger { color: #EF4444; background: #FEF2F2; }
.btn-sm.text-danger:hover { background: #FEE2E2; }
.btn-sm.text-muted { color: #64748B; background: #F1F5F9; }
.btn-sm.text-muted:hover { background: #E2E8F0; color: #0F172A; }
.btn-sm.btn-ghost { border: 1px solid #E5E7EB; color: #111827; }
.btn-sm.btn-ghost:hover { background: #F1F5F9; border-color: #CBD5E1; }

.grand-total {
    color: #000;
    font-weight: 700;
}

.vat-note {
    font-size: 9pt;
    color: #94a3b8;
    text-align: right;
}

.terms-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    background: #f8fafc;
    padding: 24px;
    border-radius: 8px;
    font-size: 11pt;
}

.terms-grid h4 {
    font-size: 11pt;
    font-weight: 600;
    margin-bottom: 8px;
    color: #0f172a;
}

.doc-footer {
    text-align: center;
    border-top: 1px solid #e2e8f0;
    padding-top: 20px;
    margin-top: 60px;
    font-size: 9pt;
    color: #64748b;
}
.doc-footer span {
    margin: 0 8px;
    color: #cbd5e1;
}

/* Animations */
@keyframes spin {
    100% { transform: rotate(360deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 600px) {
    .row-group {
        flex-direction: column;
        gap: 15px;
    }
    .card-body {
        padding: 20px;
    }
    .service-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .service-price-wrapper {
        width: 100%;
    }
    .terms-grid {
        grid-template-columns: 1fr;
    }
}
