* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    min-height: 100vh;
    background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 60%, #0f172a 100%);
    font-family: 'Georgia', 'Times New Roman', serif;
    padding: 28px 16px 48px;
}

/* ── Page header ── */
.page-header { text-align: center; margin-bottom: 26px; }
.main-logo { height: 60px; margin-bottom: 15px; }
.brand-pill {
    display: inline-block;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50px; padding: 5px 18px;
    font-size: 11px; color: #94a3b8;
    letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 12px;
}
.page-title { font-size: 34px; font-weight: 800; color: white; margin-bottom: 8px; letter-spacing: -0.02em; }
.page-sub   { color: #94a3b8; font-size: 15px; }

/* ── Card ── */
.card { background: white; border-radius: 20px; overflow: hidden; box-shadow: 0 25px 70px rgba(0,0,0,0.5); max-width: 1000px; margin: 0 auto; }

/* ── Section ── */
.section { padding: 28px 30px; border-bottom: 1px solid #f1f5f9; }
.section.alt { background: #fafbfc; }
.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.section-icon { width: 36px; height: 36px; background: #1e3a5f; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.section-title { font-size: 18px; font-weight: 700; color: #1e293b; }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-service { display: grid; grid-template-columns: 2fr 1fr 0.9fr 1fr 1fr 1fr 1.1fr; gap: 10px; }

/* Compact inputs inside service rows */
.service-row .field input {
    padding: 10px 10px;
    font-size: 13.5px;
}
.service-row .field label {
    font-size: 11px;
}

/* Read-only due amount styling */
.field input[readonly] {
    background: #f1f5f9 !important;
    color: #64748b !important;
    cursor: not-allowed;
    border-color: #e2e8f0 !important;
}

/* ── Input ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; }
.field label .req { color: #ef4444; margin-left: 4px; }
.field input, .field select {
    padding: 12px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px; font-size: 15.5px; color: #1e293b;
    background: #f8fafc; outline: none;
    font-family: inherit; width: 100%;
    transition: border-color 0.2s;
}
.field input:focus, .field select:focus { border-color: #3b82f6; }
.field.error input { border-color: #ef4444; background: #fff5f5; }

/* ── Service row ── */
.service-row { background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 12px 12px 10px; margin-bottom: 12px; }
.service-row-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.service-badge { background: #1e3a5f; color: white; border-radius: 5px; padding: 2px 10px; font-size: 11px; font-weight: 700; }
.btn-remove { background: #fee2e2; border: none; color: #ef4444; border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 12px; font-weight: 600; font-family: inherit; }

/* ── Total bar ── */
.total-bar { margin-top: 12px; background: #1e3a5f; color: white; border-radius: 10px; padding: 13px 18px; display: flex; justify-content: space-between; align-items: center; }
.total-bar span:first-child { font-size: 13px; font-weight: 600; }
.total-bar span:last-child  { font-size: 20px; font-weight: 800; }

/* ── Buttons ── */
.btn-add { padding: 7px 16px; background: #1e3a5f; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit; }
.btn-submit { padding: 15px 56px; background: linear-gradient(135deg,#1e3a5f,#2563eb); color: white; border: none; border-radius: 12px; font-size: 16px; font-weight: 800; cursor: pointer; font-family: inherit; box-shadow: 0 8px 28px rgba(37,99,235,0.4); }
.btn-submit:hover { opacity: 0.92; }
.submit-wrap { padding: 24px; text-align: center; }
.error-msg { color: #ef4444; font-size: 12px; margin-top: 8px; }

/* ── Preview Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 1000; overflow-y: auto; padding: 20px 12px; }
.modal-overlay.active { display: flex; align-items: flex-start; justify-content: center; }
.modal-box { background: white; border-radius: 20px; width: 100%; max-width: 820px; box-shadow: 0 30px 80px rgba(0,0,0,0.5); margin: 10px auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; background: #1e3a5f; border-radius: 20px 20px 0 0; }
.modal-header span { font-size: 17px; font-weight: 700; color: white; }
.btn-close { background: rgba(255,255,255,0.15); border: none; cursor: pointer; color: white; width: 32px; height: 32px; border-radius: 8px; font-size: 16px; }
.modal-body { overflow-x: auto; padding: 12px 8px; }
.modal-footer { padding: 18px 24px 20px; border-top: 1px solid #e2e8f0; background: #f8fafc; border-radius: 0 0 20px 20px; }
.action-btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.btn-pdf { display: flex; align-items: center; gap: 10px; padding: 14px 28px; background: linear-gradient(135deg,#1e3a5f,#2563eb); color: white; border: none; border-radius: 12px; font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer; min-width: 210px; justify-content: center; text-decoration: none; }
.btn-wa  { display: flex; align-items: center; gap: 10px; padding: 14px 28px; background: linear-gradient(135deg,#25d366,#128c7e); color: white; border: none; border-radius: 12px; font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer; min-width: 210px; justify-content: center; text-decoration: none; }
.info-box { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 10px; padding: 10px 16px; font-size: 12px; color: #92400e; line-height: 1.7; }

/* ── Receipt Preview (inside modal) ── */
.receipt { width: 850px; background: white; padding: 22px 26px; font-family: 'Times New Roman', Times, serif; margin: 0 auto; }
.receipt-orig   { text-align: center; font-size: 13px; margin-bottom: 5px; color: #333; }
.receipt-header-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 8px; }
.receipt-logo { height: 60px; }
.receipt-banner { background: #1e3a5f; color: white; text-align: center; padding: 6px; font-size: 17px; font-weight: bold; letter-spacing: 2.5px; width: 100%; }
.receipt-company{ text-align: center; font-size: 24px; font-weight: bold; padding: 10px 0 4px; }
.receipt-addr   { background: #d6e4f0; text-align: center; font-size: 13px; font-weight: bold; padding: 6px 10px; }
.receipt-sub    { text-align: center; font-size: 13px; padding: 4px 0; }
.receipt-bold   { text-align: center; font-size: 13px; font-weight: bold; padding: 2px 0; }
.receipt-hr     { border: none; border-top: 1.5px solid #333; margin: 6px 0 10px; }
.receipt-info   { border-collapse: collapse; width: 100%; margin-bottom: 12px; }
.receipt-info td { font-size: 13.5px; padding: 3px 0; text-align: left; }
.receipt-info td:first-child { font-weight: bold; width: 160px; color: #111; }
.receipt-table  { border-collapse: collapse; width: 100%; margin-bottom: 12px; }
.receipt-table th { border: 1px solid #444; padding: 8px 10px; font-size: 13px; text-align: center; background: #1e3a5f !important; color: white !important; font-weight: bold; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.receipt-table td { border: 1px solid #444; padding: 8px 10px; font-size: 13px; text-align: center; }
.receipt-table tr.alt { background: #f9fbfd; }
.receipt-table tr.total-row { background: #eaf0f8; }
.receipt-table tr.total-row td { font-weight: bold; font-size: 14px; }
.receipt-footer { border-collapse: collapse; width: 100%; }
.receipt-footer td { border: 1px solid #444; padding: 8px 10px; font-size: 13px; text-align: center; }

/* ── Receipt due/summary row colours ── */
.receipt-table tr.due-row { background: #fef3c7 !important; }
.receipt-table tr.due-row td { color: #b45309; font-weight: bold; font-size: 14px; }

@media (max-width: 700px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-service { grid-template-columns: 1fr 1fr; }
    .receipt { width: 100%; overflow-x: auto; }
}

/* ── Print styles ── */
@media print {
    /* Force print background and images */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        background: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Hide everything except the receipt preview */
    body > *:not(#previewModal),
    #previewModal > *:not(.modal-box),
    .modal-box > *:not(.modal-body),
    .modal-header, .modal-footer, .page-header, .card {
        display: none !important;
    }

    #previewModal, .modal-box, .modal-body {
        display: block !important;
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        background: white !important;
        overflow: visible !important;
    }

    .receipt {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 20px !important;
        border: none !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }

    .receipt-logo {
        display: block !important;
        margin: 0 auto 10px !important;
        height: 60px !important;
        max-width: 200px !important;
    }

    .receipt-banner {
        background: #1e3a5f !important;
        color: white !important;
    }

    .receipt-addr {
        background: #d6e4f0 !important;
    }

    /* Ensure tables print borders correctly */
    .receipt-table th, .receipt-table td, .receipt-info td, .receipt-footer td {
        border-color: #333 !important;
    }

    .receipt-table tr.due-row { background: #fef3c7 !important; }
    .receipt-table tr.due-row td { color: #b45309 !important; }
}
