/* Printed bills (A4): plain white paper, colour only on thin lines and text,
   one faint symbol in the middle. Nothing depends on background colours,
   so a printer that skips background graphics still gives a clean bill. */

.bill-doc {
    --a: #1a7f5a;
    --ink: #1b1f27;
    --mute: #5d6675;
    --line: #c9ced6;
    --soft: #dde1e7;
    position: relative;
    display: block;
    width: 190mm;
    max-width: 100%;
    margin: 0 auto;
    padding: 8mm 9mm 5mm;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid var(--line);
    border-top: 1.2mm solid var(--a);
    background: #fff;
    color: var(--ink);
    font-family: 'IRANSans', sans-serif;
    font-size: 10pt;
    line-height: 1.7;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.bill-doc * {
    box-sizing: border-box;
}

.bill-doc > *:not(.bill-wm):not(.bill-stamp) {
    position: relative;
    z-index: 1;
}

.bill-doc bdi {
    direction: ltr;
    unicode-bidi: isolate;
    font-family: Arial, sans-serif;
    font-variant-numeric: tabular-nums;
}

/* ---------- faint symbol in the middle ---------- */
.bill-wm {
    position: absolute;
    z-index: 0;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    color: color-mix(in srgb, var(--a) 8%, #fff);
}

.bill-wm i {
    font-size: 78mm;
    line-height: 1;
}

/* ---------- header: title right, logo centre, date and time left ---------- */
.bill-head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 5mm;
    padding-bottom: 3.5mm;
    border-bottom: 1px solid var(--line);
}

.bill-logo-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5mm;
    text-align: center;
}

.bill-logo-box b {
    font-size: 11pt;
    font-weight: 800;
    line-height: 1.3;
}

.bill-logo-box > span {
    font-size: 8pt;
    letter-spacing: .5px;
    color: var(--mute);
}

.bill-logo {
    width: 24mm;
    height: 24mm;
    display: grid;
    place-items: center;
    flex: none;
    border: .6mm solid var(--a);
    border-radius: 50%;
    font-size: 30pt;
    color: var(--a);
}

.bill-doc .print-logo {
    width: 40mm;
    height: 40mm;
    flex: none;
    object-fit: contain;
}

.bill-title {
    text-align: start;
}

.bill-title h1 {
    margin: 0;
    font-size: 27pt;
    font-weight: 800;
    line-height: 1.05;
    color: var(--a);
}

.bill-title small {
    display: block;
    margin-top: .5mm;
    font-size: 10.5pt;
    font-weight: 700;
    color: var(--ink);
}

.bill-no {
    display: inline-block;
    margin-top: 1.5mm;
    padding: 0 3mm;
    border: .3mm solid var(--a);
    border-radius: 99px;
    font-size: 8.5pt;
    font-weight: 700;
    color: var(--a);
}

.bill-when {
    display: grid;
    gap: 2.5mm;
    justify-items: end;
}

.bill-when > div {
    text-align: end;
}

.bill-when b {
    font-size: 10.5pt;
    font-weight: 800;
}

/* ---------- meta strip ---------- */
.bill-meta {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    border-bottom: 1px solid var(--line);
}

.bill-meta > div {
    padding: 2.2mm 3mm;
    border-inline-end: 1px solid var(--line);
}

.bill-meta > div:last-child {
    border-inline-end: 0;
}

.bill-k {
    display: block;
    font-size: 8.5pt;
    font-weight: 700;
    color: var(--mute);
}

.bill-meta b {
    font-size: 10pt;
    font-weight: 800;
}

/* ---------- sections ---------- */
.bill-extra {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4mm;
}

.bill-sec {
    margin-top: 4mm;
}

.bill-h {
    display: flex;
    align-items: center;
    gap: 2mm;
    margin: 0 0 2mm;
    font-size: 10pt;
    font-weight: 800;
    color: var(--a);
}

.bill-h i {
    font-size: 12pt;
}

.bill-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4mm;
}

.bill-box {
    padding: 2.2mm 3mm;
    border: 1px solid var(--line);
    border-radius: 1.2mm;
}

.bill-box b {
    display: block;
    font-size: 10pt;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.bill-tag {
    display: inline-flex;
    align-items: center;
    gap: 1.2mm;
    padding: 0 2.5mm;
    border: .3mm solid var(--f, var(--line));
    border-radius: 99px;
    font-size: 8.5pt;
    font-weight: 800;
    color: var(--f, var(--ink));
}

/* ---------- table ---------- */
.bill-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
}

.bill-tbl th {
    padding: 1.8mm 2.2mm;
    text-align: start;
    font-size: 8.5pt;
    font-weight: 800;
    color: var(--a);
    border-top: .45mm solid var(--a);
    border-bottom: .45mm solid var(--a);
}

.bill-tbl td {
    padding: 2.2mm;
    border-bottom: 1px solid var(--soft);
    font-weight: 700;
}

.bill-tbl tr.is-struck td {
    color: #8a93a1;
    text-decoration: line-through;
}

/* the three rows of a correction, each in the colour it has on screen */
.bill-tbl tr.is-original td {
    color: #7656D9;
    text-decoration-color: #7656D9;
}

.bill-tbl tr.is-original td:first-child {
    text-decoration: none;
}

.bill-tbl tr.is-reversal td {
    color: #c93f3f;
}

.bill-tbl tr.is-replacement td {
    color: #1b8059;
    font-weight: 800;
}

.bill-tbl tr.is-last td {
    border-bottom: .45mm solid var(--ink);
    font-weight: 800;
}

.bill-kv > div {
    display: flex;
    justify-content: space-between;
    gap: 4mm;
    padding: 1.8mm 0;
    border-bottom: 1px dotted #aab1bc;
}

.bill-kv span {
    font-weight: 700;
    color: var(--mute);
}

.bill-kv b {
    font-weight: 800;
    text-align: end;
}

/* ---------- total, note, qr ---------- */
.bill-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4mm;
    margin-top: 4mm;
    align-items: stretch;
}

.bill-qr {
    display: flex;
    align-items: center;
    gap: 3mm;
    padding: 2.2mm 3mm;
    border: 1px solid var(--line);
    border-radius: 1.2mm;
    background: #fff;
}

.bill-qr img {
    width: 20mm;
    height: 20mm;
    flex: none;
    border: 1px solid var(--soft);
    image-rendering: pixelated;
}

.bill-qr bdi {
    font-size: 10pt;
    font-weight: 900;
    letter-spacing: .6px;
}

.bill-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3mm;
    margin-top: 4mm;
    padding: 3mm 4.5mm;
    border: .7mm solid var(--a);
    border-radius: 1.2mm;
    background: #fff;
}

.bill-bottom .bill-total {
    margin-top: 0;
}

.bill-total span {
    font-size: 10.5pt;
    font-weight: 800;
}

.bill-total strong {
    font-size: 17pt;
    font-weight: 800;
    color: var(--a);
}

.bill-total small {
    margin-inline-start: 1.2mm;
    font-size: 8.5pt;
    font-weight: 700;
    color: var(--ink);
}

.bill-total em {
    display: block;
    font-size: 8pt;
    font-style: normal;
    font-weight: 700;
    color: var(--mute);
}

.bill-note {
    margin-top: 3mm;
    padding: 2mm 3mm;
    border: .3mm dashed var(--a);
    border-radius: 1.2mm;
    font-size: 9.5pt;
    font-weight: 700;
}

.bill-note b {
    display: block;
    font-size: 8.5pt;
    color: var(--a);
}

/* ---------- people and flow ---------- */
.bill-person {
    display: flex;
    align-items: center;
    gap: 3mm;
}

.bill-ava {
    width: 12mm;
    height: 12mm;
    display: grid;
    place-items: center;
    flex: none;
    border: .5mm solid var(--a);
    border-radius: 50%;
    font-size: 15pt;
    font-weight: 800;
    color: var(--a);
}

.bill-person b {
    display: block;
    font-size: 12pt;
    font-weight: 800;
}

.bill-flow {
    display: grid;
    grid-template-columns: 1fr 9mm 1fr;
    gap: 2mm;
    align-items: center;
}

.bill-arrow {
    display: grid;
    place-items: center;
    font-size: 17pt;
    color: var(--a);
}

/* A rubber stamp below the logo: only its lines and word are inked,
   whatever sits under the inside of it stays readable. */
.bill-stamp {
    position: absolute;
    z-index: 2;
    top: 58mm;
    inset-inline-end: 16mm;
    padding: 1mm 5mm;
    border: .7mm solid #6a4fe0;
    border-radius: 2mm;
    outline: .3mm solid #6a4fe0;
    outline-offset: .9mm;
    font-size: 15pt;
    font-weight: 800;
    letter-spacing: .4mm;
    color: #6a4fe0;
    background: transparent;
    rotate: -8deg;
}

/* ---------- signatures and footer ---------- */
.bill-signs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14mm;
    margin-top: 10mm;
}

.bill-signs > div {
    padding-top: 1mm;
    border-top: .3mm solid var(--ink);
    text-align: center;
    font-size: 8.5pt;
    font-weight: 700;
    color: var(--mute);
}

.bill-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2mm 5mm;
    margin-top: 4mm;
    padding-top: 2.5mm;
    border-top: 1px solid var(--line);
    font-size: 8.5pt;
    font-weight: 700;
    color: var(--mute);
}

.bill-foot i {
    margin-inline-end: 1mm;
}

.bill-attachment {
    max-width: 190mm;
    margin: 0 auto;
    padding-top: 6mm;
    page-break-before: always;
    break-before: page;
}

.bill-attachment p {
    margin: 0 0 3mm;
    font-size: 9pt;
    font-weight: 700;
    color: var(--mute);
}

.bill-attachment img {
    display: block;
    max-width: 100%;
    max-height: 250mm;
    margin: 0 auto;
    object-fit: contain;
}

/* ---------- print: one A4 page, isolated from the narrow receipt rules ---------- */
@media print {
    @page bill-sheet {
        size: A4 portrait;
        margin: 10mm;
    }
    html:has(#receiptTemplate .bill-doc),
    body:has(#receiptTemplate .bill-doc) {
        width: auto !important;
        min-width: 0 !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }
    body:has(#receiptTemplate .bill-doc) > *:not(#receiptTemplate) {
        display: none !important;
    }
    #receiptTemplate:has(.bill-doc) {
        display: block !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }
    #receiptTemplate .bill-doc {
        page: bill-sheet;
        width: 190mm !important;
        max-width: 190mm !important;
        margin: 0 auto !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
