.heading-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.wholesale-modal{width:min(100%,980px);max-height:min(92svh,900px);overflow:auto}.sale-customer-row{display:flex;align-items:flex-end;gap:10px;margin-bottom:13px}.sale-customer-row>label{flex:1}.sale-customer-row label,.receipt-header label{display:grid;gap:6px;font-size:10px;color:#526057}.sale-customer-row select,.receipt-header input,.inline-customer input,.inline-product input{height:39px;border:1px solid #e1e8e4;border-radius:6px;padding:0 10px;background:#fff;color:#45524b;min-width:0}.inline-customer,.inline-product,.receipt-header{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:9px;margin:0 0 12px}.receipt-header{grid-template-columns:2fr 1fr 1fr}.invoice-product-picker{display:grid;grid-template-columns:minmax(130px,1fr) minmax(150px,1.35fr) 90px auto auto auto;gap:8px;margin:13px 0}.invoice-product-picker input,.invoice-product-picker select,.invoice-lines input{height:36px;min-width:0;border:1px solid #e2e9e5;border-radius:5px;padding:0 8px;background:#fff;font-size:11px;color:#45524b}.invoice-lines-wrap{overflow:auto;border:1px solid #e9eeeb;border-radius:6px;max-height:340px}.invoice-lines{width:100%;min-width:780px;border-collapse:collapse}.invoice-lines th{position:sticky;top:0;background:#f6f8f7;z-index:1}.invoice-lines td{height:51px}.invoice-lines td:first-child{white-space:normal;min-width:190px}.invoice-lines td:first-child .table-product-name{display:block;margin-top:4px}.invoice-lines input{width:86px}.invoice-lines td:first-child input{width:100%}.line-stock{display:block;color:#87948c;font-size:9px;margin-top:4px}.remove-line{border:0;color:#a25447;background:#f8efed;width:29px;height:29px}.invoice-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:13px 0}.invoice-fields label{display:grid;gap:6px;font-size:10px;color:#526057}.invoice-fields input{height:37px;border:1px solid #e1e8e4;border-radius:5px;padding:0 9px;font-size:11px}.invoice-totals{display:flex;justify-content:flex-end;gap:24px;padding:12px 4px;color:#7b8880;font-size:11px}.invoice-totals strong{color:#28714f;margin-left:6px;font-size:15px}.print-invoice{display:none}.type-pill.debt{background:#fbf1e4;color:#a9772e}.type-pill.payment{background:#e8f0f6;color:#467195}
@media(max-width:760px){.heading-actions{width:100%;justify-content:flex-end}.wholesale-modal{max-height:calc(100svh - 16px);padding:16px}.sale-customer-row{align-items:stretch}.sale-customer-row .outline-button{white-space:nowrap;padding:0 10px}.invoice-product-picker{grid-template-columns:minmax(0,1fr) 82px auto}.invoice-product-picker input:first-child{grid-column:1/-1}.invoice-product-picker select{grid-column:1/3}.invoice-product-picker #createProductFromReceipt{grid-column:1/-1}.receipt-header{grid-template-columns:1fr 1fr}.receipt-header label:first-child{grid-column:1/-1}.inline-customer,.inline-product{grid-template-columns:1fr 1fr}.inline-customer button,.inline-product button{grid-column:1/-1}.invoice-fields{grid-template-columns:1fr 1fr}.invoice-fields label:last-child{grid-column:1/-1}.invoice-totals{gap:12px;flex-wrap:wrap}.invoice-totals strong{font-size:14px}.page-heading>.heading-actions{width:auto}.page-heading>.heading-actions .outline-button{display:none}.page-heading:has(#printLastInvoice) .heading-actions #printLastInvoice:not(.hidden){display:inline-flex}}
@media(max-width:390px){.invoice-product-picker{grid-template-columns:minmax(0,1fr) 72px}.invoice-product-picker select{grid-column:1/-1}.invoice-product-picker button{min-height:36px}.sale-customer-row{display:grid;grid-template-columns:1fr}.inline-customer,.inline-product,.receipt-header{grid-template-columns:1fr}.receipt-header label:first-child,.inline-customer button,.inline-product button{grid-column:auto}.page-heading:has(#printLastInvoice) .heading-actions #printLastInvoice:not(.hidden){display:none}}
.sale-customer-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end}.sale-customer-row>label{margin:0}.sale-customer-row .outline-button{box-sizing:border-box;height:39px;min-height:39px;padding:0 10px;align-self:end;white-space:nowrap}.invoice-product-picker #addInvoiceItem{box-sizing:border-box;height:36px;min-height:36px;padding:0 12px;align-self:end;white-space:nowrap}
@media(max-width:390px){.sale-customer-row{grid-template-columns:minmax(0,1fr) auto;align-items:end}.sale-customer-row .outline-button{padding:0 8px;font-size:10px}}
.inline-edit-input{box-sizing:border-box;width:100%;min-width:72px;height:36px;border:1px solid #b8d9c8;border-radius:5px;padding:0 8px;background:#fff;color:#334039;font:inherit}.inline-edit-actions{display:flex;align-items:center;gap:5px}.inline-edit-actions .primary-button,.inline-edit-actions .outline-button{min-height:32px;height:32px;padding:0 8px;font-size:9px;white-space:nowrap}body[data-theme=dark] .inline-edit-input{background:#141d18;border-color:#547863;color:#e1e9e3}
@page{size:A4;margin:14mm}
@media print{body{background:#fff!important;color:#111!important}.login-screen,.app-shell,.modal-backdrop,.toast{display:none!important}.print-invoice{display:block!important;font-family:Arial,"Noto Sans Armenian",sans-serif;color:#111;font-size:11pt}.print-invoice header{display:flex;justify-content:space-between;align-items:flex-start;border-bottom:2px solid #333;padding-bottom:12px;margin-bottom:18px}.print-invoice h1{font-size:18pt;margin:0 0 7px}.print-invoice p{margin:7px 0}.print-invoice table{width:100%;border-collapse:collapse;margin:20px 0}.print-invoice th,.print-invoice td{border:1px solid #888;padding:7px;text-align:left;font-size:9pt}.print-invoice th{background:#eee!important;color:#111}.print-totals{width:70%;margin-left:auto;text-align:right}.print-totals p{padding:5px 0;border-bottom:1px solid #ddd}.print-invoice footer{border-top:1px solid #aaa;padding-top:12px;white-space:pre-wrap}}
.invoice-lines th{font-size:11px;height:42px;white-space:normal}
.invoice-lines td{height:68px;font-size:14px}
.invoice-lines input{width:100px;height:42px;font-size:14px}
.invoice-lines td:first-child{min-width:230px}
.invoice-lines .code-label{font-size:12px;padding:5px 7px}
.invoice-lines .table-product-name{font-size:14px;line-height:1.4}
.invoice-lines .line-stock{font-size:11px}
.invoice-lines .line-total{font-size:14px;font-weight:700}
@media(min-width:761px){
  #movementModal{display:block;overflow-x:hidden;overflow-y:auto;padding:0;overscroll-behavior:contain}
  #movementModal .wholesale-modal{display:flex;flex-direction:column;width:100vw;height:100vh;height:100dvh;min-height:0;max-width:none;max-height:100vh;max-height:100dvh;overflow:hidden;border-radius:0;padding:24px 30px}
  #movementModal .modal-heading,#movementModal .document-date,#movementModal .sale-customer-row,#movementModal .receipt-header,#movementModal .inline-customer,#movementModal .inline-product,#movementModal .invoice-product-picker,#movementModal .invoice-fields,#movementModal .invoice-totals,#movementModal .form-error,#movementModal .modal-actions{flex:0 0 auto}
  #movementModal .invoice-product-picker{position:sticky;top:0;z-index:3;background:#fff;padding:8px 0;margin:0}
  #movementModal .invoice-lines th{top:0}
  #movementModal .invoice-lines-wrap{flex:1 1 auto;height:auto;min-height:180px;max-height:none;overflow:auto;overscroll-behavior:contain}
}
@media(max-width:760px){#movementModal .invoice-lines-wrap{height:min(40svh,340px);min-height:160px;max-height:340px;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}}
/* Space the optional quick-add row from the product picker above it. */
.inline-product{margin-top:8px}
/* Վերադարձի վերջնական գրանցումը առանձին գործողություն է․ ընտրված տողերը նախ երևում են հաստատման ցանկում։ */
#movementModal #registerReturn:not(.hidden){background:#b7443b;border-color:#b7443b;color:#fff}
#movementModal #registerReturn:not(.hidden):hover{background:#9f382f;border-color:#9f382f}
#movementModal .invoice-lines [data-remove-return-line]{background:#b7443b;color:#fff}
@media(min-width:761px){#movementModal #inlineProduct{grid-template-columns:repeat(4,minmax(0,1fr))}}

/* Նոր գնորդի արագ ավելացման դաշտերը՝ 30% ավելի կարճ և համաչափ դասավորված */
@media(min-width:761px){#movementModal .inline-customer{width:70%;grid-template-columns:1.5fr 1fr .8fr auto;align-items:end;}#movementModal .inline-customer input{width:100%;box-sizing:border-box;}#movementModal .inline-customer button{white-space:nowrap;min-height:39px;}}

/* Mobile: sales/receipt dialogs fit every phone width without horizontal clipping. */
@media (max-width: 760px) {
  #movementModal { overflow-x: hidden; }
  #movementModal .wholesale-modal {
    box-sizing: border-box;
    width: calc(100vw - 10px);
    max-width: calc(100vw - 10px);
    margin: 5px auto;
    max-height: calc(100dvh - 10px);
    padding: 12px;
    overflow-x: hidden;
  }
  #movementModal .modal-heading { gap: 8px; }
  #movementModal .modal-heading h2 { font-size: 17px; }
  #movementModal .close-modal { flex: 0 0 32px; }

  #movementModal .sale-customer-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }
  #movementModal .sale-customer-row .outline-button {
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 7px;
    font-size: 10px;
  }

  #movementModal .receipt-header,
  #movementModal .inline-customer,
  #movementModal .inline-product,
  #movementModal .invoice-fields {
    width: 100%;
    box-sizing: border-box;
    gap: 6px;
  }
  #movementModal .receipt-header { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
  #movementModal .receipt-header label:first-child { grid-column: 1 / -1; }
  #movementModal .inline-customer { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  #movementModal .inline-customer input,
  #movementModal .inline-product input,
  #movementModal .receipt-header input,
  #movementModal .invoice-fields input { box-sizing: border-box; width: 100%; min-width: 0; }
  #movementModal .inline-customer button,
  #movementModal .inline-product button { width: 100%; min-width: 0; }

  #movementModal .invoice-product-picker {
    width: 100%;
    box-sizing: border-box;
    grid-template-columns: minmax(0, 1fr) minmax(62px, 72px) auto;
    gap: 5px;
  }
  #movementModal .invoice-product-picker input,
  #movementModal .invoice-product-picker select,
  #movementModal .invoice-product-picker button {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  #movementModal .invoice-product-picker input:first-child { grid-column: 1 / -1; }
  #movementModal .invoice-product-picker select { grid-column: 1 / 2; }
  #movementModal #invoiceQty { grid-column: 2 / 3; }
  #movementModal #addInvoiceItem { grid-column: 3 / 4; padding: 0 8px; }
  #movementModal #createProductFromReceipt { grid-column: 1 / -1; width: 100%; }

  #movementModal .invoice-lines-wrap { width: 100%; box-sizing: border-box; }
  #movementModal .invoice-lines { min-width: 650px; }
  #movementModal .invoice-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  #movementModal .invoice-fields label:last-child { grid-column: 1 / -1; }

  #movementModal .invoice-totals { justify-content: space-between; gap: 6px; padding: 9px 2px; }
  #movementModal .modal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  #movementModal .modal-actions button { min-width: 0; width: 100%; padding-left: 6px; padding-right: 6px; font-size: 10px; }
}

@media (max-width: 430px) {
  #movementModal .wholesale-modal { width: calc(100vw - 6px); max-width: calc(100vw - 6px); margin: 3px auto; padding: 9px; }
  #movementModal .sale-customer-row { grid-template-columns: minmax(0, 1fr) auto; }
  #movementModal .sale-customer-row .outline-button { max-width: 31vw; font-size: 9px; }
  #movementModal .receipt-header,
  #movementModal .inline-customer,
  #movementModal .inline-product,
  #movementModal .invoice-fields { grid-template-columns: minmax(0, 1fr); }
  #movementModal .receipt-header label:first-child,
  #movementModal .inline-customer button,
  #movementModal .inline-product button,
  #movementModal .invoice-fields label:last-child { grid-column: auto; }
  #movementModal .invoice-product-picker { grid-template-columns: minmax(0, 1fr) 66px; }
  #movementModal .invoice-product-picker select { grid-column: 1 / -1; }
  #movementModal #invoiceQty { grid-column: 1 / 2; }
  #movementModal #addInvoiceItem { grid-column: 2 / 3; }
  #movementModal .invoice-lines { min-width: 610px; }
  #movementModal .modal-actions { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 360px) {
  #movementModal .wholesale-modal { padding: 7px; }
  #movementModal .modal-heading h2 { font-size: 15px; }
  #movementModal .sale-customer-row { grid-template-columns: 1fr; }
  #movementModal .sale-customer-row .outline-button { max-width: none; width: 100%; }
  #movementModal .invoice-product-picker { grid-template-columns: minmax(0, 1fr); }
  #movementModal .invoice-product-picker select,
  #movementModal #invoiceQty,
  #movementModal #addInvoiceItem { grid-column: 1 / -1; }
  #movementModal .invoice-lines { min-width: 590px; }
  #movementModal .modal-actions { grid-template-columns: 1fr; }
}


/* Sales history of a buyer: card layout on phones (rows, inline editing and the "+" free row) */
@media (max-width: 760px) {
  .buyer-detail-row > td { padding: 8px 6px; }
  #outRows .buyer-history-table { overflow: visible; border: 0; background: transparent; }
  #outRows .buyer-history-table table, #outRows .buyer-history-table tbody { display: block; width: 100%; min-width: 0; background: transparent; }
  #outRows .buyer-history-table thead { display: none; }
  #outRows .buyer-history-table tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px;
    margin-bottom: 10px; padding: 12px; border: 1px solid #dfe9e3; border-radius: 10px; background: #fff;
  }
  #outRows .buyer-history-table td { display: block; height: auto; padding: 0; border: 0; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
  #outRows .buyer-history-table td::before { display: block; margin-bottom: 3px; color: #6a7a70; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
  #outRows .buyer-history-table td:nth-child(1), #outRows .buyer-history-table td:nth-child(3), #outRows .buyer-history-table td:nth-child(9) { grid-column: 1 / -1; }
  #outRows .buyer-history-table td:nth-child(1)::before { content: 'Ամսաթիվ / համար'; }
  #outRows .buyer-history-table td:nth-child(2)::before { content: 'Կոդ'; }
  #outRows .buyer-history-table td:nth-child(3)::before { content: 'Ապրանք / գործողություն'; }
  #outRows .buyer-history-table td:nth-child(4)::before { content: 'Միավոր'; }
  #outRows .buyer-history-table td:nth-child(5)::before { content: 'Քանակ'; }
  #outRows .buyer-history-table td:nth-child(6)::before { content: 'Գումար'; }
  #outRows .buyer-history-table td:nth-child(7)::before { content: 'Զեղչ'; }
  #outRows .buyer-history-table td:nth-child(8)::before { content: 'Տեսակ'; }
  #outRows .buyer-history-table td:nth-child(9)::before { content: 'Փոփոխել'; }
  #outRows .buyer-history-table td:nth-child(10)::before { content: 'Տպել'; }
  #outRows .buyer-history-table td:empty { display: none; }
  #outRows .buyer-history-table .inline-edit-input { min-width: 0; height: 44px; font-size: 16px; } /* 16px stops iOS zooming into the field */
  #outRows .buyer-history-table .inline-edit-actions { flex-wrap: wrap; gap: 8px; }
  #outRows .buyer-history-table .inline-edit-actions .primary-button, #outRows .buyer-history-table .inline-edit-actions .outline-button { flex: 1 1 120px; height: 44px; min-height: 44px; font-size: 13px; }
  #outRows .buyer-history-table .record-actions { gap: 8px; }
  #outRows .buyer-history-table .record-actions .icon-button { width: 44px; height: 44px; }
  #outRows .buyer-history-table .history-print-button { height: 40px; }
  #outRows .buyer-summary-row .record-actions .icon-button { width: 40px; height: 40px; }
  body[data-theme=dark] #outRows .buyer-history-table tr { background: #1b231e; border-color: #35423a; }
  body[data-theme=dark] #outRows .buyer-history-table td::before { color: #a9b9af; }
}

/* Sales list on phones: buyers as cards so nothing is wider than the screen */
@media (max-width: 760px) {
  table:has(> #outRows) { display: block; width: 100%; min-width: 0 !important; }
  table:has(> #outRows) > thead { display: none; }
  #outRows { display: block; width: 100%; }
  #outRows > tr.buyer-summary-row {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; align-items: start;
    margin-bottom: 8px; padding: 12px; border: 1px solid #dfe9e3; border-radius: 10px; background: #fff;
  }
  #outRows > tr.buyer-summary-row > td { display: block; height: auto; padding: 0; border: 0; min-width: 0; font-size: 14px; }
  #outRows > tr.buyer-summary-row > td::before { display: block; margin-bottom: 2px; color: #6a7a70; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
  #outRows > tr.buyer-summary-row > td:nth-child(1) { grid-column: 1; grid-row: 1; }
  #outRows > tr.buyer-summary-row > td:nth-child(7) { grid-column: 2; grid-row: 1; justify-self: end; }
  #outRows > tr.buyer-summary-row > td:nth-child(2)::before { content: 'Փաստաթղթեր'; }
  #outRows > tr.buyer-summary-row > td:nth-child(3)::before { content: 'Ապրանքային տողեր'; }
  #outRows > tr.buyer-summary-row > td:nth-child(4)::before { content: 'Վերջին ամսաթիվ'; }
  #outRows > tr.buyer-summary-row > td:nth-child(5)::before { content: 'Վաճառքի գումար'; }
  #outRows > tr.buyer-summary-row > td:nth-child(6) { display: none; }
  #outRows .buyer-expand-button { padding: 4px 0; font-size: 15px; text-align: left; }
  #outRows > tr.buyer-detail-row { display: block; width: 100%; height: auto; }
  #outRows > tr.buyer-detail-row > td { display: block; width: 100%; height: auto; min-height: 0; padding: 0 0 6px; background: transparent; border: 0; }
  #outRows .buyer-history-table, #outRows .buyer-history-table tr { height: auto; min-height: 0; }
  #outRows .buyer-history-table td, #outRows .buyer-history-table .record-actions { height: auto; }
  #outRows .buyer-history-table .history-print-button { white-space: nowrap; }
  body[data-theme=dark] #outRows > tr.buyer-summary-row { background: #1b231e; border-color: #35423a; }
}

.add-sale-line{font-size:20px;line-height:1;font-weight:700}

/* "+" next to ՏՊԵԼ inside an invoice list: adds lines to that same invoice */
.history-invoice-actions{display:inline-flex;align-items:center;gap:6px;flex-wrap:nowrap}
.history-add-button.icon-button{width:30px;height:30px;min-height:30px;padding:0;font-size:18px;line-height:1;font-weight:700;flex:0 0 auto}
@media (max-width: 760px) {
  #outRows .buyer-history-table .history-invoice-actions { gap: 8px; }
  #outRows .buyer-history-table .history-add-button.icon-button { width: 44px; height: 40px; }
}
