/* In-page confirm dialog and toasts (dialogs.js). */
.app-confirm { width: min(420px, calc(100% - 32px)); padding: 24px; border: 1px solid #e0e9ee; border-radius: 12px; background: #fff; color: #102235; box-shadow: 0 24px 80px #10223535; }
.app-confirm::backdrop { background: #10223588; }
.app-confirm p { margin: 0 0 20px; font-size: 15px; line-height: 1.7; }
.app-confirm-actions { display: flex; gap: 10px; }
.app-confirm-actions button { flex: 1; min-height: 44px; border-radius: 8px; font: inherit; font-weight: 700; }
.app-confirm-ok { border: 0; background: #087e91; color: #fff; }
.app-confirm-ok.danger { background: #c64e43; }
.app-confirm-cancel { border: 1px solid #d6e1e7; background: #fff; color: #3f5c6e; }
.app-toasts { position: fixed; inset-inline: 0; bottom: 20px; z-index: 50; display: grid; justify-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.app-toast { display: flex; align-items: center; gap: 10px; max-width: 520px; padding: 6px 6px 6px 16px; padding-inline: 16px 6px; border-radius: 10px; background: #142838; color: #fff; font-size: 14px; line-height: 1.6; box-shadow: 0 12px 32px #10223540; pointer-events: auto; }
.app-toast.error { background: #a23c33; }
.app-toast button { flex: none; width: 44px; height: 44px; border: 0; border-radius: 6px; background: transparent; color: inherit; font-size: 20px; }

/* Product image picker with Arabic wording instead of the browser's own button. */
.new-product-file { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.new-product-file input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.new-product-file-button { min-height: 44px; display: inline-flex; align-items: center; padding: 0 16px; border: 1px solid #b7d5dc; border-radius: 8px; background: #f2f9fa; color: #087e91; font-weight: 700; cursor: pointer; }
.new-product-file input[type="file"]:focus-visible + .new-product-file-button { outline: 3px solid #5fc4d1; outline-offset: 3px; }
.new-product-file-name { color: #607985; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-product-image-field { display: block; }
.new-product-image-label { display: block; font-size: 13px; font-weight: 700; color: #263746; }

/* Point of sale: the cart keeps the height, options and totals stay compact. */
.pos-item-count { display: block; margin-top: 2px; color: #647f8e; font-size: 12px; font-weight: 400; }
.pos-item-count:empty { display: none; }
.pos-cart-items { min-height: 0; }
.pos-sale-options { flex: 0 1 auto; min-height: 0; overflow: auto; padding-block: 8px; gap: 8px; }
.pos-summary { flex: none; padding-top: 10px; }
.pos-payment-row .pos-option-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pos-total { padding: 8px 14px; }
.pos-cash-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; color: #647f8e; }
.pos-cash-row[hidden] { display: none; }
.pos-cash-row label { flex: none; }
.pos-cash-row input { flex: 0 1 110px; min-width: 0; min-height: 40px; padding: 0 10px; border: 1px solid #dce7ec; border-radius: 7px; background: #fff; color: #102235; font: inherit; font-size: 14px; text-align: left; }
.pos-cash-row input::placeholder { text-align: right; direction: rtl; font-size: 12px; }
.pos-cash-row input:focus { outline: 0; border-color: #087e91; box-shadow: 0 0 0 3px #087e911a; }
.pos-cash-row strong { flex: 1; color: #1f6b4a; font-size: 14px; text-align: left; }
.pos-cash-row strong.short { color: #b55144; }
.pos-mobile-bar { display: none; }
@media all {
  .pos-line { grid-template-columns: minmax(0, 1fr) auto minmax(72px, auto); gap: 0 10px; padding: 8px 18px; }
  .pos-line-controls { display: contents; }
  .pos-line-name { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
  .pos-quantity { grid-column: 2; grid-row: 1 / span 2; align-self: center; height: 42px; }
  .pos-quantity button { width: 38px; height: 40px; }
  .pos-quantity input { width: 46px; height: 40px; }
  .pos-line-total { grid-column: 3; grid-row: 1; align-self: end; }
  .pos-remove { grid-column: 3; grid-row: 2; justify-self: end; min-height: 28px; padding: 0; border: 0; background: none; text-decoration: underline; }
}
/* Every card says how many of it are already in the cart. */
.pos-product-count { display: block; margin-top: 4px; color: #087e91; font-size: 12px; font-weight: 700; }
.pos-product-count[hidden] { display: none; }
.pos-product.in-cart { border-color: #087e91; box-shadow: 0 0 0 1px #087e91 inset; }
.pos-cart-close { display: none; }

/* Phone: products fill the screen; the invoice is a full-screen sheet opened from the bottom bar. */
@media (max-width: 760px) {
  .pos { padding-bottom: 84px; }
  .pos-header { height: auto; min-height: 56px; padding: 8px 12px; gap: 8px; }
  .pos-heading { gap: 8px; min-width: 0; flex: 1; }
  .pos-heading > div { min-width: 0; flex: 1; }
  .pos-heading h1 { font-size: 16px; margin: 0; }
  .pos-heading p { margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pos-back { flex: none; min-height: 44px; height: 44px; padding: 0 10px; white-space: nowrap; }
  .pos-brand { display: none; }
  .pos-layout { padding: 10px 12px; }
  .pos-products .pos-search { position: sticky; top: 8px; z-index: 5; box-shadow: 0 6px 18px #1022351a; }
  .pos-mobile-bar { display: block; position: fixed; inset-inline: 12px; bottom: 12px; z-index: 20; min-height: 56px; border: 0; border-radius: 12px; background: #087e91; color: #fff; font: inherit; font-size: 16px; font-weight: 700; box-shadow: 0 10px 28px #10223550; }
  .pos-mobile-bar:disabled { background: #8aa4af; opacity: 1; box-shadow: none; }
  .pos-mobile-bar[hidden], .pos.cart-open .pos-mobile-bar { display: none; }
  .pos .pos-cart { display: none; }
  .pos.cart-open { padding-bottom: 0; }
  .pos.cart-open .pos-cart { display: flex; position: fixed; inset: 0; z-index: 30; min-height: 0; max-height: none; height: 100dvh; border: 0; border-radius: 0; order: 0; }
  .pos.cart-open .pos-cart-items { flex: 1 1 0; min-height: 80px; max-height: none; overflow: auto; }
  .pos.cart-open .pos-sale-options { flex: 0 1 auto; max-height: 38dvh; }
  .pos.cart-open .pos-summary { padding-bottom: max(14px, env(safe-area-inset-bottom)); box-shadow: 0 -8px 20px #1022350f; }
  .pos-cart-heading { gap: 10px; justify-content: flex-start; }
  .pos-cart-heading > div { flex: 1; min-width: 0; }
  .pos-cart-close { display: inline-flex; align-items: center; gap: 4px; flex: none; min-height: 44px; padding: 0 12px; border: 1px solid #d6e1e7; border-radius: 8px; background: #fff; color: #3f5c6e; font: inherit; font-size: 14px; white-space: nowrap; }
  .pos-customer-phone { flex-wrap: nowrap; }
  .pos-customer-phone input { flex: 1 1 0; min-width: 0; }
  .pos-customer-phone button { padding: 0 10px; }
  .pos-remove { min-height: 36px; }
}

/* Sign-in and store setup. */
#code-view .text-button { display: block; }
#resend-code:disabled { color: #8395a1; cursor: default; opacity: 1; }
.setup-coords { margin-top: 10px; }
.setup-coords summary { min-height: 44px; display: inline-flex; align-items: center; color: #087e91; font-size: 13px; cursor: pointer; }
.setup-coords .setup-grid { margin-top: 6px; }

/* Phone navigation: one labelled button opens the full section list. */
.nav-toggle { display: none; }
@media (max-width: 760px) {
  .sidebar { position: sticky; top: 0; z-index: 15; }
  .sidebar-brand { padding-bottom: 0; }
  .nav-toggle { display: inline-flex; align-items: center; gap: 8px; margin-inline-start: auto; min-height: 44px; padding: 0 14px; border: 1px solid #ffffff30; border-radius: 8px; background: #15516a; color: #fff; font: inherit; font-size: 14px; font-weight: 700; }
  .sidebar .section-nav { display: none; }
  .sidebar.nav-open .section-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding-top: 12px; overflow: visible; }
  .sidebar.nav-open .section-tab { width: 100%; min-height: 46px; }
  /* Staff cards: the table has seven columns, so name the cells for this table and not the short accounts one. */
  #members-section .employees-table tbody td:nth-child(1)::before { content: 'الاسم'; }
  #members-section .employees-table tbody td:nth-child(2)::before { content: 'الوظيفة'; }
  #members-section .employees-table tbody td:nth-child(3)::before { content: 'الهاتف'; }
  #members-section .employees-table tbody td:nth-child(4)::before { content: 'الفروع'; }
  #members-section .employees-table tbody td:nth-child(5)::before { content: 'الدخول للنظام'; }
  #members-section .employees-table tbody td:nth-child(6)::before { content: 'الراتب الشهري'; }
  #members-section .employees-table tbody td:nth-child(7)::before { content: 'الحالة'; }
  #members-section .employees-table tbody td:nth-child(8)::before { content: none; }
  #members-section .employees-table tbody td:nth-child(8) { grid-column: 1 / -1; }
}

/* Product editing dialog and inline category creation. */
.catalog-row-editable { cursor: pointer; }
.catalog-row-editable:hover td { background: #f5fafb; }
.product-edit { width: min(560px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid #e0e9ee; border-radius: 12px; background: #fff; color: #102235; box-shadow: 0 24px 80px #10223535; }
.product-edit::backdrop { background: #10223588; }
.product-edit-form { padding: 20px 24px 24px; }
.product-edit-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.product-edit-kicker { margin: 0 0 4px; color: #087e91; font-size: 12px; font-weight: 700; }
.product-edit-head h3 { margin: 0; font-size: 19px; }
.product-edit-close { flex: none; width: 44px; height: 44px; border: 1px solid #e0e9ee; border-radius: 8px; background: #fff; color: #617a88; font-size: 22px; }
.product-edit-message { min-height: 22px; margin: 10px 0; color: #607985; font-size: 13px; }
.product-edit-message.error { color: #b55144; }
.product-edit-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.product-edit-fields .wide { grid-column: 1 / -1; }
.product-edit-fields label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: #263746; }
.product-edit-fields label small { font-weight: 400; color: #8395a1; }
.product-edit-fields input[type="text"], .product-edit-fields select, .product-edit-fields textarea, .new-category-name { width: 100%; min-height: 44px; padding: 8px 11px; border: 1px solid #dce7ec; border-radius: 7px; background: #fff; color: #102235; font: inherit; font-size: 14px; font-weight: 400; }
.product-edit-fields input:focus, .product-edit-fields select:focus, .product-edit-fields textarea:focus, .new-category-name:focus { outline: 0; border-color: #087e91; box-shadow: 0 0 0 3px #087e911a; }
.product-edit-category, .product-edit-category-new { display: flex; align-items: end; gap: 8px; }
.product-edit-category[hidden], .product-edit-category-new[hidden], .product-edit-new-category[hidden] { display: none; }
.product-edit-category label, .product-edit-category-new label { flex: 1; }
.product-edit-category button, .product-edit-category-new button, .new-product-category-add button { min-height: 44px; padding: 0 14px; border: 1px solid #b7d5dc; border-radius: 8px; background: #f2f9fa; color: #087e91; font: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; }
.product-edit-category-cancel, .new-category-cancel { border-color: #d6e1e7 !important; background: #fff !important; color: #3f5c6e !important; }
.product-edit-active { display: flex !important; align-items: flex-start; gap: 10px; font-weight: 500 !important; }
.product-edit-active input { width: 20px; height: 20px; margin-top: 2px; accent-color: #087e91; }
.product-edit-active small { display: block; margin-top: 2px; }
.product-edit-stock { margin: 0; padding: 10px 12px; border-radius: 8px; background: #f5f8fa; color: #607985; font-size: 13px; line-height: 1.7; }
.product-edit-stock:empty { display: none; }
.product-edit-actions { display: flex; gap: 10px; margin-top: 18px; }
.product-edit-actions button { min-height: 46px; padding: 0 20px; border-radius: 8px; font: inherit; font-weight: 700; }
.product-edit-save { flex: 1; border: 0; background: #087e91; color: #fff; }
.product-edit-cancel { border: 1px solid #d6e1e7; background: #fff; color: #3f5c6e; }
.new-product-category-add { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; align-self: end; }
.new-product-category-add[hidden], .new-category-fields[hidden], .new-category-open[hidden] { display: none; }
.new-category-fields { display: flex; gap: 8px; flex: 1; }
.new-category-name { flex: 1; min-width: 140px; }
@media (max-width: 560px) { .product-edit-fields { grid-template-columns: minmax(0, 1fr); } .product-edit-category, .product-edit-category-new { flex-wrap: wrap; } }

/* One place for a section's main action: the page header line, where «إضافة منتج» already sits.
   72px is the distance from the section body up to that line (title block + its bottom margin). */
@media (min-width: 761px) {
  .purchases-head, .expenses-head { position: relative; }
  .purchases-head .purchases-actions, .expenses-head .expenses-new { position: absolute; top: -72px; inset-inline-end: 0; }
  .expenses-head { min-height: 0; margin: 0; padding: 0; }
}
.new-product-category-cell { display: grid; gap: 6px; align-content: start; min-width: 0; }
.new-product-category-add .new-category-open { min-height: 32px; padding: 0; border: 0; background: none; text-decoration: underline; }
.new-product-form .new-product-file .new-product-file-name { color: #607985; }
.new-product-form .new-product-file .new-product-file-button { color: #087e91; }
.pos-product.out-of-stock { opacity: .6; }
.pos-product.out-of-stock .pos-product-stock { color: #b55144; font-weight: 700; }
.pos-product.out-of-stock .pos-product-add { visibility: hidden; }
@media (max-width: 760px) { .app-toasts { bottom: 84px; } }

/* Finished sale: one clear confirmation that owns the invoice panel. */
.pos-success { flex: 1; flex-direction: column; justify-content: center; gap: 6px; margin: 0; padding: 24px 18px; border-radius: 0; background: #fff; color: #102235; text-align: center; }
.pos-success-icon { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 6px; border-radius: 50%; background: #e5f5ee; color: #1f6b4a; font-size: 32px; font-weight: 700; }
.pos-success-title { font-size: 20px; }
.pos-success-total { color: #1f6b4a; font-size: 32px; font-weight: 700; line-height: 1.3; }
.pos-success-detail { color: #647f8e; font-size: 14px; }
.pos-success-change { margin-top: 6px; padding: 8px 14px; border-radius: 8px; background: #fff6e0; color: #7a5200; font-size: 16px; font-weight: 700; }
.pos-success-change:empty, .pos-success-total:empty { display: none; }
.pos-success-actions { display: grid; gap: 10px; width: 100%; max-width: 320px; margin-top: 18px; }
.pos-success .pos-success-actions button { width: 100%; height: auto; min-height: 52px; border-radius: 8px; font: inherit; font-size: 16px; font-weight: 700; }
.pos-success .pos-success-new { border: 0; background: #087e91; color: #fff; }
.pos-success .pos-success-print { border: 1px solid #b7d5dc; background: #fff; color: #087e91; }
.pos-cart.sale-done .pos-cart-items, .pos-cart.sale-done .pos-empty, .pos-cart.sale-done .pos-sale-options, .pos-cart.sale-done .pos-summary, .pos-cart.sale-done .pos-undo, .pos-cart.sale-done .pos-clear, .pos-cart.sale-done .pos-item-count { display: none; }
.pos.cart-open .pos-cart.sale-done .pos-cart-items { display: none; }

/* Folded invoice options. Wide screens keep them inline; a phone shows one chip each and opens a bottom sheet. */
.pos-option-chips, .pos-sheet-head, .pos-sheet-backdrop { display: none; }
#pos-customer-block { display: contents; }
@media (max-width: 760px) {
  .pos-option-chips { display: flex; gap: 8px; flex-wrap: wrap; }
  .pos-option-chips button { flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid #dce7ec; border-radius: 22px; background: #f9fbfc; color: #647f8e; font: inherit; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pos-option-chips button.is-set { border-color: #087e91; background: #e8f5f6; color: #087e91; font-weight: 700; }
  .pos-option-chips button:disabled { opacity: .55; }
  .pos-option-chips button[hidden] { display: none; }
  .pos .pos-option-block, .pos #pos-customer-block { display: none; }
  .pos .pos-cart[data-sheet="customer"] #pos-customer-block,
  .pos-cart[data-sheet="discount"] [data-sheet-block="discount"],
  .pos-cart[data-sheet="received"] [data-sheet-block="received"] { display: grid; gap: 12px; position: fixed; inset-inline: 0; bottom: 0; z-index: 45; margin: 0; padding: 16px 16px max(20px, env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; background: #fff; box-shadow: 0 -16px 40px #10223540; }
  .pos-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .pos-sheet-head strong { font-size: 17px; color: #102235; }
  .pos-sheet-done { min-height: 44px; padding: 0 20px; border: 0; border-radius: 8px; background: #087e91; color: #fff; font: inherit; font-weight: 700; }
  .pos-sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: #10223588; }
  .pos-sheet-backdrop[hidden] { display: none; }
  .pos-option-block .pos-discount-toggle { display: none; }
  .pos-cart[data-sheet="received"] .pos-cash-row { grid-template-columns: minmax(0, 1fr); }
  .pos-cart[data-sheet="received"] .pos-cash-row label { font-size: 14px; }
  .pos-cart[data-sheet="received"] .pos-cash-row input { width: 100%; min-height: 52px; font-size: 20px; flex: none; }
  .pos-cart[data-sheet="received"] .pos-cash-row strong { font-size: 18px; text-align: right; min-height: 28px; }
  .pos-cart[data-sheet="discount"] .pos-discount-controls { display: flex; gap: 8px; }
  .pos-cart[data-sheet="discount"] .pos-discount-controls input { flex: 1; min-height: 52px; font-size: 18px; }
  .pos-cart[data-sheet="discount"] .pos-discount-controls select { min-height: 52px; }
}

/* Bankak transfer image picker with Arabic wording. */
.pos-file { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pos-file input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pos-file-button { flex: none; min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border: 1px solid #b7d5dc; border-radius: 8px; background: #f2f9fa; color: #087e91; font-size: 14px; font-weight: 700; cursor: pointer; }
.pos-file input:focus-visible + .pos-file-button { outline: 3px solid #5fc4d1; outline-offset: 3px; }
.pos-file input:disabled + .pos-file-button { opacity: .55; cursor: not-allowed; }
.pos-file-name { min-width: 0; color: #607985; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
