/* Thermal receipt roll printers (58mm / 80mm) */
.receipt-thermal {
    box-sizing: border-box;
    margin: 0;
    padding: 2mm 3mm;
    background: #fff;
    color: #000;
    font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    line-height: 1.35;
}

.receipt-thermal .rt-logo {
    display: block;
    margin: 0 auto 2mm;
    max-width: 18mm;
    height: auto;
}

.receipt-thermal .rt-brand {
    text-align: center;
    font-weight: 700;
    font-size: 1.1em;
    margin: 0;
}

.receipt-thermal .rt-brand-ar {
    text-align: center;
    font-size: 0.95em;
    margin: 1mm 0 2mm;
}

.receipt-thermal .rt-meta {
    text-align: center;
    font-size: 0.85em;
    margin: 0 0 2mm;
}

.receipt-thermal .rt-divider {
    border: none;
    border-top: 1px dashed #000;
    margin: 2mm 0;
}

.receipt-thermal .rt-title {
    text-align: center;
    font-weight: 700;
    font-size: 1em;
    margin: 0 0 1mm;
}

.receipt-thermal .rt-lines {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.receipt-thermal .rt-lines th,
.receipt-thermal .rt-lines td {
    padding: 1mm 0;
    vertical-align: top;
    text-align: start;
}

.receipt-thermal .rt-lines th {
    border-bottom: 1px solid #000;
    font-size: 0.8em;
}

.receipt-thermal .rt-lines .rt-num {
    text-align: end;
    white-space: nowrap;
}

.receipt-thermal .rt-lines .rt-qty {
    text-align: center;
    width: 8mm;
}

.receipt-thermal .rt-totals {
    font-size: 0.95em;
}

.receipt-thermal .rt-totals div {
    display: flex;
    justify-content: space-between;
    gap: 2mm;
    padding: 0.5mm 0;
}

.receipt-thermal .rt-totals .rt-grand {
    font-weight: 700;
    font-size: 1.15em;
    border-top: 1px solid #000;
    margin-top: 1mm;
    padding-top: 2mm;
}

.receipt-thermal .rt-invoice-due,
.invoice-a4 .a4-invoice-due {
    font-weight: 700;
}

.receipt-thermal .rt-account-due,
.invoice-a4 .a4-account-due {
    font-weight: 700;
    margin-top: 1mm;
    padding-top: 1.5mm;
    border-top: 1px dashed #000;
}

[data-receipt-async-slot] {
    display: contents;
}

.receipt-thermal .rt-footer {
    text-align: center;
    font-size: 0.85em;
    margin-top: 3mm;
}

.receipt-thermal .rt-ticket-barcode {
    text-align: center;
    margin: 3mm 0;
    min-height: 18mm;
    padding: 2mm 0;
}
.receipt-thermal .rt-ticket-barcode .barcode-svg {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    min-height: 14mm;
    height: 16mm;
}
.receipt-thermal .rt-barcode-text {
    margin-top: 1.5mm;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

.receipt-thermal .rt-line-sub {
    font-size: 0.8em;
    opacity: 0.75;
}

/* Kitchen prep tickets (no prices) */
.kitchen-tickets-print-root {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.kitchen-ticket .kt-banner {
    text-align: center;
    font-weight: 800;
    font-size: 1.15em;
    letter-spacing: 0.04em;
    margin: 1mm 0 2mm;
}

.kitchen-ticket .kt-station {
    text-align: center;
    font-weight: 800;
    font-size: 1.35em;
    text-transform: uppercase;
    margin: 0 0 1mm;
}

.kitchen-ticket .kt-order-no {
    text-align: center;
    font-weight: 800;
    font-size: 1.4em;
    margin: 1mm 0;
    letter-spacing: 0.02em;
}

.kitchen-ticket .kt-subhead {
    font-weight: 800;
    margin: 2mm 0 1mm;
    border-bottom: 1px dashed #000;
    padding-bottom: 0.5mm;
}

.kitchen-ticket .kt-item-name {
    font-weight: 700;
}

.kitchen-ticket .kt-mods {
    font-size: 0.88em;
    margin-top: 0.4mm;
}

.kitchen-ticket .kt-mods span {
    display: block;
}

.kitchen-ticket .kt-prep {
    font-size: 0.85em;
    font-style: italic;
    margin-top: 0.3mm;
}

.kitchen-ticket .kt-note {
    font-size: 0.9em;
    font-weight: 700;
    margin-top: 0.5mm;
}

.kitchen-ticket .kt-note.sev-2 {
    text-decoration: underline;
}

.kitchen-ticket .kt-footer {
    text-align: center;
    font-size: 0.78em;
    opacity: 0.85;
    margin: 1mm 0 0;
}

.kitchen-ticket .kt-printer {
    font-size: 0.8em;
    opacity: 0.8;
}

.kitchen-ticket--cancel .kt-banner,
.kitchen-ticket--cancel .kt-line-cancel .kt-item-name {
    text-decoration: line-through;
}

.kitchen-ticket--cancel .kt-banner {
    border: 2px solid #000;
    padding: 1mm;
}

.kitchen-ticket--add .kt-banner {
    border-bottom: 2px double #000;
}

.kitchen-printer-map {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.35rem;
}

.kitchen-printer-row {
    display: grid;
    grid-template-columns: minmax(5rem, 8rem) 1fr;
    gap: 0.5rem;
    align-items: center;
}

.kitchen-printer-st {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Product labels */
.labels-print-area {
    display: flex;
    flex-wrap: wrap;
    gap: 2mm;
    align-content: flex-start;
}

.label-sheet {
    box-sizing: border-box;
    border: 1px dashed #ccc;
    padding: 1.5mm;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    text-align: center;
    background: #fff;
    color: #000;
    font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    page-break-inside: avoid;
    break-inside: avoid;
}
.label-sheet .lbl-top {
    flex-shrink: 0;
    width: 100%;
}

.label-sheet .lbl-name {
    font-weight: 700;
    font-size: 9px;
    line-height: 1.25;
    max-height: 2.5em;
    overflow: hidden;
    width: 100%;
    word-wrap: break-word;
    unicode-bidi: plaintext;
}

.label-sheet .lbl-name-ar {
    font-size: 8px;
    opacity: 0.9;
    direction: rtl;
    unicode-bidi: isolate;
}

.label-sheet .lbl-price {
    font-weight: 700;
    font-size: 10px;
    margin: 0.5mm 0;
}

.label-sheet .lbl-batch {
    font-weight: 600;
    font-size: 8px;
    margin: 0.3mm 0;
    letter-spacing: 0.01em;
    unicode-bidi: plaintext;
}

.label-sheet .lbl-code {
    font-size: 7px;
    letter-spacing: 0.02em;
}

.label-sheet svg.barcode-svg {
    max-width: 100%;
    height: auto;
    max-height: 12mm;
}

.label-sheet canvas.qr-canvas {
    max-width: 14mm;
    max-height: 14mm;
}

.label-sheet .lbl-codes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5mm;
    width: 100%;
    flex-shrink: 0;
    margin-top: auto;
}

/* Screen preview */
.print-settings-panel {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(128, 0, 64, 0.08);
}

.print-settings-panel h3 {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    color: var(--magenta);
}

.preset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.preset-chip {
    border: 1.5px solid var(--input-border, var(--bg-alt));
    background: var(--input-bg, var(--bg));
    color: var(--text);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: 0.2s;
}

.preset-chip:hover:not(.active) {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--input-border, var(--bg-alt)));
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--input-bg, var(--bg)));
}

.preset-chip.active {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
}

.labels-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

.label-qty-input {
    width: 70px;
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    border: 1px solid #ddd;
    text-align: center;
    font-family: inherit;
}

.label-preview-wrap {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    max-height: 320px;
    overflow: auto;
}

@media print {
    body.print-receipt,
    body.print-labels,
    body.print-report {
        margin: 0;
        padding: 0;
        background: #fff;
    }

    /* Always hide screen-only controls in the print iframe */
    .no-print {
        display: none !important;
    }

    .payroll-voucher {
        page-break-inside: avoid;
        break-inside: avoid;
        page-break-after: always;
        break-after: page;
    }
    .payroll-voucher:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    #traderVouchersAll .print-voucher-page {
        page-break-inside: avoid;
        break-inside: avoid;
        page-break-after: always;
        break-after: page;
    }
    #traderVouchersAll .print-voucher-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    #expenseVouchersAll .print-voucher-page {
        page-break-inside: avoid;
        break-inside: avoid;
        page-break-after: always;
        break-after: page;
    }
    #expenseVouchersAll .print-voucher-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    body.print-report {
        width: 100%;
    }

    /* Professional trader receipt/payment vouchers */
    .ledger-voucher-pro .lvp-frame {
        border: 2px solid #1e3a5f !important;
    }
    .ledger-voucher-pro .lvp-amount {
        font-size: 18pt;
        font-weight: 800;
    }
    .ledger-voucher-pro .lvp-signs {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
    }

    body.print-receipt {
        width: auto;
    }

    .receipt-thermal {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    .labels-print-area {
        display: block;
        gap: 0;
        margin: 0;
        padding: 0;
    }

    body.print-labels .label-sheet {
        border: none;
        padding: 0.6mm 0.8mm !important;
        page-break-after: avoid;
        break-after: avoid;
    }

    body.print-labels .label-sheet + .label-sheet {
        page-break-before: always;
        break-before: page;
    }
}

/* Help guide — used inside print iframe (body.print-report) */
body.print-report {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    font-size: 11pt;
    line-height: 1.45;
    color: #111;
    background: #fff;
    padding: 10mm 12mm;
}
body.print-report .help-print-cover {
    text-align: center;
    margin-bottom: 10mm;
    padding-bottom: 6mm;
    border-bottom: 2px solid #1e3a5f;
}
body.print-report .help-print-cover h1 {
    margin: 0 0 2mm;
    font-size: 18pt;
    color: #1e3a5f;
}
body.print-report .help-print-cover h2 {
    margin: 4mm 0 0;
    font-size: 13pt;
}
body.print-report .help-print-screen {
    page-break-inside: avoid;
    margin-bottom: 8mm;
    padding-bottom: 5mm;
    border-bottom: 1px solid #ddd;
}
body.print-report .help-print-screen h2 {
    margin: 0 0 2mm;
    font-size: 14pt;
    color: #1e3a5f;
}
body.print-report .help-print-summary {
    margin: 0 0 3mm;
    color: #444;
}
body.print-report .help-print-screen h3 {
    margin: 3mm 0 2mm;
    font-size: 11pt;
    color: #2563eb;
}
body.print-report .help-print-step { margin-bottom: 3mm; }
body.print-report .help-print-step h4 {
    margin: 0 0 1mm;
    font-size: 10.5pt;
}
body.print-report .help-print-step p {
    margin: 0;
    color: #333;
}
body.print-report .help-print-img {
    display: block;
    max-width: 100%;
    max-height: 55mm;
    margin-top: 2mm;
    border: 1px solid #ccc;
}
body.print-report .help-print-img-ph {
    margin-top: 2mm;
    padding: 4mm;
    border: 1px dashed #999;
    color: #666;
    font-size: 9pt;
    text-align: center;
}
body.print-report .muted { color: #666; }

/* ── Report sheets (print iframe + Save as PDF) ── */
body.print-report {
    padding: 0 !important;
    margin: 0;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    box-sizing: border-box;
}
body.print-report .report-document,
body.print-report .report-print-sheet,
body.print-report .panel-card {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: #fff;
    overflow: visible;
}
body.print-report .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow: visible;
    border: none;
}
body.print-report .report-table,
body.print-report .data-table {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
    border-collapse: collapse;
}
body.print-report .report-table th,
body.print-report .report-table td,
body.print-report .data-table th,
body.print-report .data-table td {
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    text-overflow: unset;
}
body.print-report .report-table.acc-tb-table {
    width: max-content !important;
    max-width: none !important;
    min-width: 0 !important;
    table-layout: auto !important;
    font-size: 6.5pt;
}
body.print-report .acc-tb-scroll {
    overflow: visible !important;
    max-width: none !important;
    border: none !important;
}
body.print-report .report-table.acc-tb-table th,
body.print-report .report-table.acc-tb-table td {
    white-space: nowrap !important;
    word-break: normal !important;
    padding: 0.15rem 0.25rem !important;
    font-size: 6.5pt;
}
body.print-report .report-table.acc-tb-table td.acc-tb-name,
body.print-report .report-table.acc-tb-table td.acc-tb-aname {
    white-space: normal !important;
    max-width: 9rem;
}
body.print-report .acc-tb-table .acc-tb-sticky,
body.print-report .acc-tb-table .acc-tb-sticky-2 {
    position: static !important;
    box-shadow: none !important;
}
/* Wide trial balance: landscape when the print root contains the TB table */
@page {
    margin: 10mm;
}
body.print-report .no-print,
body.print-report .related-chips,
body.print-report .related-chip,
body.print-report .pay-breakdown-bars,
body.print-report .sc-page-guide,
body.print-report .toolbar-icon-group,
body.print-report .report-toolbar,
body.print-report button,
body.print-report .icon-tool-btn {
    display: none !important;
}
body.print-report a {
    color: inherit;
    text-decoration: none;
}
body.print-report .print-hide-col {
    display: none !important;
}
