/* ===============================================
   ZEQVA INVOICE SYSTEM
   =============================================== */

:root {
    --navy: #0A3660;
    --navy-light: #124a7a;
    --gold: #E28714;
    --text: #1A1A2E;
    --muted: #6B7C93;
    --line: #E6DFD4;
    --soft: #F8F5EF;
    --white: #ffffff;
    --paid-bg: #E8F7EE;
    --paid-text: #146C43;
    --paid-border: #A3D9B1;
    --border: #e2e8f0;
    --primary: #0A3660;
    --primary-light: #124a7a;
    --accent: #E28714;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Helvetica, Arial, sans-serif;
    font-size: 13px;
    color: var(--text);
    background: #eef1f5;
    padding: 15px;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--white);
    padding: 40px 36px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
}

.login-box h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--navy);
    margin: 0 0 4px 0;
    text-align: center;
}

.login-subtitle {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    margin-bottom: 28px;
}

.login-form .field {
    margin-bottom: 16px;
}

.login-form .field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
}

.login-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.login-form input:focus {
    outline: none;
    border-color: var(--navy);
}

.login-error {
    color: #dc2626;
    font-size: 12px;
    margin-bottom: 12px;
    min-height: 18px;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: var(--navy);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-login:hover {
    background: var(--navy-light);
}

/* ===== HOME PAGE ===== */
.invoice-home {
    max-width: 420px;
    margin: 100px auto;
    text-align: center;
    background: var(--white);
    padding: 48px 44px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 10px 20px -5px rgba(0,0,0,0.08);
}

.invoice-home h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--navy);
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
}

.invoice-home p {
    color: var(--muted);
    margin-bottom: 28px;
    font-size: 14px;
}

.invoice-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.invoice-links a {
    display: block;
    padding: 14px 24px;
    background: var(--navy);
    color: var(--white);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s, box-shadow 0.2s;
}

.invoice-links a:hover {
    background: var(--navy-light);
    box-shadow: 0 4px 12px rgba(10, 54, 96, 0.25);
}

.invoice-links a:last-child {
    background: transparent;
    color: var(--navy);
    border: 2px solid var(--navy);
}

.invoice-links a:last-child:hover {
    background: rgba(10, 54, 96, 0.04);
}

/* ===== INVOICE PAGE ===== */
.invoice-page {
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
    background: var(--white);
    padding: 0 48px 36px;
    box-shadow: 0 2px 8px rgba(15, 41, 66, 0.06), 0 24px 48px -12px rgba(0,0,0,0.1);
    border-radius: 4px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 30px);
}

.invoice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.invoice-actions .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s, transform 0.15s;
    font-family: inherit;
}

.invoice-actions .btn:hover {
    opacity: 0.92;
    transform: translateY(-0.5px);
}

.btn-print  { background: var(--navy); color: var(--white); }
.btn-shipping { background: var(--gold); color: var(--white); }
.btn-back   { background: #e8edf2; color: var(--text); }

/* ===== ZEQVA INVOICE LAYOUT ===== */
.invoice-top-bar {
    height: 5px;
    background: var(--navy);
    margin: 0 -48px 28px;
}

.zeqva-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 28px;
}

.zeqva-brand .invoice-logo {
    max-height: 72px;
    width: auto;
    object-fit: contain;
    display: block;
}

.zeqva-title-block {
    text-align: right;
}

.zeqva-title-block .invoice-type {
    font-size: 28px;
    font-weight: 700;
    color: var(--navy);
    margin: 0 0 6px;
    letter-spacing: 0.04em;
    line-height: 1;
}

.invoice-number-display {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 10px;
    word-break: break-all;
    max-width: 280px;
    margin-left: auto;
}

.status-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.status-badge.paid {
    background: var(--paid-bg);
    color: var(--paid-text);
    border: 1px solid var(--paid-border);
}

.section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold);
    margin: 0 0 10px;
}

.zeqva-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin-bottom: 28px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    padding-top: 22px;
}

.from-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 6px;
}

.from-line {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.55;
}

.detail-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}

.detail-label {
    flex: 0 0 110px;
    font-size: 12px;
    color: var(--muted);
}

.detail-value {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.detail-input {
    flex: 1;
    min-width: 0;
    border: none;
    border-bottom: 1px dashed transparent;
    background: transparent;
    padding: 2px 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    font-family: inherit;
}

.detail-input:hover,
.detail-input:focus {
    outline: none;
    border-bottom-color: var(--line);
}

.zeqva-billto {
    margin-bottom: 28px;
    padding-top: 4px;
}

.bill-name-input {
    display: block;
    width: 100%;
    max-width: 360px;
    border: none;
    background: transparent;
    padding: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    font-family: inherit;
    margin-bottom: 4px;
}

.bill-name-input:focus {
    outline: none;
    border-bottom: 1px dashed var(--line);
}

.bill-email-input {
    display: block;
    width: 100%;
    max-width: 360px;
    border: none;
    background: transparent;
    padding: 0;
    font-size: 13px;
    color: #2563eb;
    font-family: inherit;
}

.bill-email-input:focus {
    outline: none;
    border-bottom: 1px dashed var(--line);
}

.zeqva-services {
    margin-bottom: 28px;
}

.invoice-table-wrap {
    overflow-x: auto;
}

.btn-add-row {
    margin-top: 10px;
}

/* ===== TABLE ===== */
.zeqva-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    border: none;
}

.zeqva-table th,
.zeqva-table td {
    padding: 12px 14px;
    border: none;
    text-align: left;
    color: var(--text);
}

.zeqva-table thead th {
    background: var(--navy);
    color: var(--white);
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.zeqva-table thead th:first-child {
    border-radius: 3px 0 0 3px;
}

.zeqva-table thead th:last-child {
    border-radius: 0 3px 3px 0;
    text-align: right;
}

.zeqva-table tbody tr {
    background: var(--soft);
}

.zeqva-table tbody tr:nth-child(even) {
    background: #f3efe8;
}

.zeqva-table tbody td:last-child {
    text-align: right;
    font-weight: 700;
    white-space: nowrap;
}

.zeqva-table input {
    width: 100%;
    padding: 4px 0;
    border: none;
    background: transparent;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
}

.zeqva-table input:focus {
    outline: none;
    border-bottom: 1px dashed var(--gold);
}

.zeqva-table .col-desc  { width: auto; }
.zeqva-table .col-price { width: 110px; text-align: right; }
.zeqva-table .col-qty   { width: 70px;  text-align: center; }
.zeqva-table .col-amount{ width: 120px; text-align: right; }

.zeqva-table thead th.col-price,
.zeqva-table thead th.col-qty {
    text-align: right;
}

.zeqva-table tbody td:nth-child(2),
.zeqva-table tbody td:nth-child(3) {
    text-align: right;
}

.zeqva-table tbody td:nth-child(2) input,
.zeqva-table tbody td:nth-child(3) input {
    text-align: right;
}

/* ===== SUMMARY + SEAL ===== */
.zeqva-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 36px;
}

.invoice-seal {
    flex: 0 0 auto;
}

.invoice-seal img {
    max-width: 220px;
    width: 220px;
    height: auto;
    display: block;
}

.summary-box {
    width: 240px;
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 14px 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
    gap: 12px;
}

.summary-row span:last-child {
    color: var(--text);
    font-weight: 500;
}

.summary-row.discount-row {
    margin-top: 8px;
}

.summary-row.discount-row input {
    width: 70px;
    padding: 2px 4px;
    border: 1px solid var(--line);
    border-radius: 3px;
    text-align: right;
    font-size: 12px;
    font-family: inherit;
    background: var(--white);
}

.summary-divider {
    height: 1px;
    background: var(--line);
    margin: 12px 0;
}

.summary-row.total-paid {
    font-size: 13px;
}

.summary-row.total-paid span:first-child {
    font-weight: 700;
    color: var(--navy);
}

.summary-row.total-paid span:last-child {
    font-weight: 700;
    font-size: 15px;
    color: var(--gold);
}

/* ===== FOOTER ===== */
.zeqva-footer {
    border-top: 1px solid var(--line);
    padding-top: 14px;
    margin-top: auto;
    text-align: center;
}

.zeqva-footer p {
    font-size: 10px;
    color: var(--muted);
    line-height: 1.5;
}

/* Legacy fallbacks (shipping.html etc.) */
.company-name-top {
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 12px;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-row .invoice-type {
    font-size: 18px;
    font-weight: 700;
    color: var(--navy);
    margin: 0;
}

.header-row .invoice-logo {
    max-height: 52px;
    width: auto;
    object-fit: contain;
}

.header-line {
    height: 2px;
    background: var(--navy);
    margin: 16px 0 24px 0;
}

.invoice-body-purchase {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 20px;
}

.invoice-block h3 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold);
    margin: 0 0 12px 0;
}

.invoice-block input,
.invoice-block textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
}

.invoice-block label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
}

.invoice-block .field {
    margin-bottom: 10px;
}

.company-info {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.7;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.invoice-table th,
.invoice-table td {
    padding: 10px 14px;
    text-align: left;
}

.invoice-table thead th {
    background: var(--navy);
    color: #fff;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
}

.totals-table {
    width: 100%;
    max-width: 300px;
    margin-left: auto;
    margin-bottom: 24px;
    border-collapse: collapse;
}

.totals-table td {
    padding: 8px 12px;
}

.totals-table td:first-child { font-weight: 600; color: var(--muted); }
.totals-table td:last-child  { text-align: right; }

.totals-table .total-row td {
    font-weight: 700;
    color: var(--navy);
    background: var(--soft);
}

.invoice-footer {
    margin-top: 36px;
    padding-top: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.invoice-footer.no-border { border-top: none; }

/* ===============================================
   PRINT STYLES
   Same A4 output on laptop AND mobile — locked desktop layout
   =============================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    html {
        width: 820px !important;
        max-width: 820px !important;
    }

    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        width: 820px !important;
        min-width: 820px !important;
        max-width: 820px !important;
        font-size: 13px !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    .invoice-actions,
    .no-print {
        display: none !important;
    }

    .invoice-page,
    .invoice-page.zeqva-invoice {
        display: flex !important;
        flex-direction: column !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        max-width: 820px !important;
        width: 820px !important;
        min-width: 820px !important;
        padding: 0 48px 36px !important;
        min-height: 0 !important;
        overflow: visible !important;
        background: #fff !important;
        position: relative !important;
    }

    .invoice-top-bar {
        height: 5px !important;
        margin: 0 -48px 28px !important;
        background: #0A3660 !important;
    }

    /* Header: logo left + INVOICE right (same as laptop) */
    .zeqva-header {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 24px !important;
        margin-bottom: 28px !important;
    }

    .zeqva-brand .invoice-logo {
        max-height: 72px !important;
        width: auto !important;
        height: auto !important;
    }

    .zeqva-title-block {
        text-align: right !important;
        width: auto !important;
    }

    .zeqva-title-block .invoice-type {
        font-size: 28px !important;
        font-weight: 700 !important;
        color: #0A3660 !important;
        margin: 0 0 6px !important;
    }

    .invoice-number-display {
        font-size: 11px !important;
        color: #6B7C93 !important;
        max-width: 280px !important;
        margin-left: auto !important;
        text-align: right !important;
    }

    .status-badge.paid {
        background: #E8F7EE !important;
        color: #146C43 !important;
        border: 1px solid #A3D9B1 !important;
    }

    .section-label {
        font-size: 10px !important;
        color: #E28714 !important;
    }

    /* Two columns: FROM | DETAILS */
    .zeqva-meta-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 28px !important;
        margin-bottom: 28px !important;
        padding-top: 22px !important;
        border-top: 1px solid #E6DFD4 !important;
    }

    .detail-row {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: baseline !important;
        gap: 10px !important;
    }

    .detail-label {
        flex: 0 0 110px !important;
        font-size: 12px !important;
        color: #6B7C93 !important;
    }

    .detail-input,
    .detail-value {
        font-size: 12px !important;
        font-weight: 700 !important;
        color: #1A1A2E !important;
    }

    .detail-input,
    .bill-name-input,
    .bill-email-input,
    .zeqva-table input,
    .summary-row.discount-row input {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        outline: none !important;
    }

    .bill-name-input {
        font-size: 16px !important;
        font-weight: 700 !important;
        color: #1A1A2E !important;
        max-width: 360px !important;
    }

    .bill-email-input {
        font-size: 13px !important;
        color: #2563eb !important;
        max-width: 360px !important;
    }

    /* Table full desktop width */
    .invoice-table-wrap {
        overflow: visible !important;
        margin: 0 !important;
    }

    .zeqva-table {
        width: 100% !important;
        min-width: 0 !important;
        font-size: 13px !important;
        border-collapse: collapse !important;
    }

    .zeqva-table th,
    .zeqva-table td {
        padding: 12px 14px !important;
    }

    .zeqva-table thead th {
        background: #0A3660 !important;
        color: #fff !important;
    }

    .zeqva-table tbody tr {
        background: #F8F5EF !important;
    }

    /* Seal left + summary right */
    .zeqva-bottom {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 24px !important;
        margin-bottom: 36px !important;
    }

    .invoice-seal img {
        max-width: 220px !important;
        width: 220px !important;
        height: auto !important;
    }

    .summary-box {
        width: 240px !important;
        max-width: 240px !important;
        background: #F8F5EF !important;
        border: 1px solid #E6DFD4 !important;
        border-radius: 5px !important;
        padding: 14px 16px !important;
    }

    .summary-row.total-paid span:first-child {
        color: #0A3660 !important;
        font-weight: 700 !important;
    }

    .summary-row.total-paid span:last-child {
        color: #E28714 !important;
        font-weight: 700 !important;
        font-size: 15px !important;
    }

    .zeqva-footer {
        border-top: 1px solid #E6DFD4 !important;
        padding-top: 14px !important;
        margin-top: auto !important;
        text-align: center !important;
        width: 100% !important;
    }

    .zeqva-footer p {
        font-size: 10px !important;
        color: #6B7C93 !important;
        text-align: center !important;
    }
}

/* Screen-only mobile layout — print stays locked above */
@media screen and (max-width: 700px) {
    body {
        padding: 8px;
    }

    .login-box,
    .invoice-home {
        margin: 40px auto;
        padding: 28px 20px;
        width: auto;
        max-width: 100%;
    }

    .invoice-page {
        width: 100%;
        max-width: 100%;
        padding: 0 16px 24px;
        min-height: auto;
        border-radius: 8px;
    }

    .invoice-top-bar {
        margin: 0 -16px 18px;
    }

    .invoice-actions {
        margin: 12px 0 10px;
        gap: 8px;
    }

    .invoice-actions .btn {
        flex: 1 1 calc(50% - 8px);
        justify-content: center;
        padding: 11px 12px;
        font-size: 12px;
    }

    .zeqva-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        margin-bottom: 20px;
    }

    .zeqva-brand .invoice-logo {
        max-height: 56px;
        max-width: 180px;
    }

    .zeqva-title-block {
        text-align: left;
        width: 100%;
    }

    .zeqva-title-block .invoice-type {
        font-size: 22px;
    }

    .invoice-number-display {
        margin-left: 0;
        max-width: none;
        text-align: left;
        font-size: 11px;
        word-break: break-word;
    }

    .zeqva-meta-grid {
        grid-template-columns: 1fr;
        gap: 18px;
        margin-bottom: 20px;
        padding-top: 16px;
    }

    .detail-row {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        margin-bottom: 12px;
    }

    .detail-label {
        flex: none;
        min-width: 0;
        font-size: 11px;
    }

    .detail-input,
    .detail-value {
        width: 100%;
        font-size: 14px;
        padding: 8px 10px;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: #fff;
        font-weight: 600;
    }

    .detail-input:focus {
        outline: none;
        border-color: var(--navy);
        border-bottom-color: var(--navy);
    }

    .zeqva-billto {
        margin-bottom: 20px;
    }

    .bill-name-input,
    .bill-email-input {
        max-width: none;
        width: 100%;
        padding: 10px 12px;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: #fff;
        margin-bottom: 8px;
        font-size: 15px;
    }

    .bill-name-input:focus,
    .bill-email-input:focus {
        outline: none;
        border-color: var(--navy);
    }

    .invoice-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -4px 8px;
    }

    .zeqva-table {
        min-width: 520px;
        font-size: 13px;
    }

    .zeqva-table th,
    .zeqva-table td {
        padding: 10px 8px;
    }

    .zeqva-table input {
        font-size: 14px;
        padding: 6px 4px;
        min-height: 36px;
    }

    .zeqva-bottom {
        flex-direction: column;
        align-items: center;
        gap: 18px;
        margin-bottom: 20px;
    }

    .invoice-seal img {
        max-width: 150px;
        width: 150px;
    }

    .summary-box {
        width: 100%;
        max-width: none;
    }

    .summary-row {
        font-size: 13px;
    }

    .summary-row.discount-row input {
        width: 90px;
        padding: 6px 8px;
        font-size: 14px;
        min-height: 36px;
    }

    .zeqva-footer {
        text-align: center;
    }

    .zeqva-footer p {
        font-size: 9px;
        word-break: break-word;
    }
}

@media screen and (max-width: 400px) {
    .invoice-actions .btn {
        flex: 1 1 100%;
    }

    .zeqva-title-block .invoice-type {
        font-size: 20px;
    }
}
