/* ARIDO Dishdasha — the shared styles of the shop's screens (sale, items, stock, agents, money) on top of the design system (app.css).
   Same tokens, same 8px grid. Screens add their own small blocks here instead of inline styles so phones, tablets and prints stay alike. */

/* ───────── money and quantities ───────── */
/* money columns: Latin digits, thousands separators, aligned on the left edge like a ledger (SPEC §3) */
.money { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.money .cur { font-size: .82em; font-weight: 600; color: var(--muted); margin-inline-start: 3px; }
.money.neg, .money.debt { color: var(--red); } .money.credit { color: var(--green); } .money.zero { color: var(--faint); }
.money.lg { font-size: 20px; font-weight: 800; color: var(--ink); }
.money.xl { font-size: 30px; font-weight: 800; color: var(--ink); letter-spacing: -.5px; }
.tbl td.money, .tbl th.money { text-align: left; }
.tbl .total-row td { font-weight: 800; background: var(--head); }

/* «3 صناديق + 5 قطع» (core.js cartons()) */
.cartons { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; font-weight: 700; color: var(--ink); white-space: nowrap; }
.cartons .ct { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 7px; background: #DCE6F4; color: var(--navy-3); font-size: 12.5px; }
.cartons .pc { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 7px; background: var(--sky-soft); color: var(--sky-2); font-size: 12.5px; }
.cartons .plus { color: var(--faint); font-weight: 600; }
.cartons svg { width: 14px; height: 14px; }
.cartons.none { color: var(--faint); font-weight: 600; }
.cartons.low .ct, .cartons.low .pc { background: var(--amber-soft); color: var(--amber); }
.cartons.out .ct, .cartons.out .pc { background: var(--red-soft); color: var(--red); }
.pcs-total { font-size: 11.5px; color: var(--muted); direction: rtl; }

/* quantity chips (−  12  +) and the صندوق / قطعة toggle */
.qty-chip { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; height: 40px; }
.qty-chip button { width: 36px; height: 100%; border: 0; background: var(--card-2); color: var(--navy-3); cursor: pointer; display: grid; place-items: center; }
.qty-chip button:hover { background: var(--sky-soft); }
.qty-chip button:disabled { color: var(--faint); cursor: default; background: var(--card-2); }
.qty-chip button svg { width: 16px; height: 16px; }
.qty-chip input { width: 56px; height: 100%; border: 0; text-align: center; font-weight: 800; font-size: 16px; direction: ltr; outline: none; font-variant-numeric: tabular-nums; }
.qty-chip.sm { height: 32px; } .qty-chip.sm button { width: 28px; } .qty-chip.sm input { width: 44px; font-size: 14px; }
.unit-toggle { display: inline-flex; background: #EDEAE3; border-radius: 10px; padding: 3px; gap: 2px; }
.unit-toggle button { border: 0; background: transparent; height: 34px; padding: 0 14px; border-radius: 8px; font-weight: 700; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.unit-toggle button svg { width: 16px; height: 16px; }
.unit-toggle button.on { background: var(--navy); color: #fff; box-shadow: var(--shadow); }

/* size chips: one per size with its stock (the «مشكّل» chip for a mixed carton) */
.size-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.size-chip { min-width: 64px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: #fff; cursor: pointer; color: var(--text); font: inherit; line-height: 1.2; transition: border-color .1s, background .1s; }
.size-chip .lb { font-size: 17px; font-weight: 800; direction: ltr; }
.size-chip .st { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.size-chip:hover { border-color: var(--sky-light); background: #F7FBFF; }
.size-chip.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.size-chip.on .st { color: #B9D6F2; }
.size-chip.low:not(.on) { border-color: #F6D9A3; } .size-chip.low:not(.on) .st { color: var(--amber); }
.size-chip.out:not(.on) { background: #FFF8F8; border-color: #F5CACA; } .size-chip.out:not(.on) .st { color: var(--red); }
.size-chip.mixed .lb { font-size: 14px; direction: rtl; }
.size-chip:disabled { opacity: .45; cursor: not-allowed; }
.size-chip kbd { font-size: 10px; color: var(--faint); font-family: var(--font); }

/* item code and description cells */
.code { font-family: var(--font); font-weight: 800; direction: ltr; unicode-bidi: isolate; color: var(--navy-3); letter-spacing: .3px; }
.code-badge { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 7px; background: #DCE6F4; color: var(--navy-3); font-weight: 800; direction: ltr; unicode-bidi: isolate; font-size: 13px; }
.item-desc { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.item-desc .nm { font-weight: 700; } .item-desc .meta { font-size: 11.5px; color: var(--muted); }
.thumb { width: 44px; height: 44px; border-radius: 9px; background: var(--sky-soft); color: var(--sky-2); display: grid; place-items: center; overflow: hidden; flex: none; border: 1px solid var(--border-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 22px; height: 22px; }

/* status stamps of documents */
.doc-status { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 6px; font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.doc-status.final { background: var(--green-soft); color: var(--green); }
.doc-status.cancelled { background: var(--red-soft); color: var(--red); text-decoration: line-through; }
.doc-status.open, .doc-status.held { background: var(--amber-soft); color: var(--amber); }
.doc-status.converted, .doc-status.done { background: #DCE6F4; color: var(--navy-3); }
.pay-type { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pay-type.cash { background: var(--green-soft); color: var(--green); }
.pay-type.credit { background: var(--red-soft); color: var(--red); }
.pay-type.partial { background: var(--amber-soft); color: var(--amber); }
.mode-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.mode-badge.wholesale { background: #DCE6F4; color: var(--navy-3); } .mode-badge.retail { background: var(--sky-soft); color: var(--sky-2); }

/* an agent's balance next to the limit */
.balance-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.balance-box > div { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--card-2); }
.balance-box span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.balance-box b { font-size: 17px; }
.balance-box .over { border-color: #F5CACA; background: #FFF8F8; } .balance-box .over b { color: var(--red); }
.limit-bar { height: 6px; border-radius: 6px; background: #EDEAE3; overflow: hidden; } .limit-bar > i { display: block; height: 100%; background: var(--sky); }
.limit-bar.warn > i { background: var(--amber); } .limit-bar.over > i { background: var(--red); }

/* ───────── the sale screen (SPEC §11: keyboard first; one column on phones) ───────── */
.sale-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; align-items: start; }
.sale-grid .sale-side { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 12px; }
.sale-entry { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px 16px; }
.sale-entry .code-in { height: 52px; font-size: 22px; font-weight: 800; text-align: center; direction: ltr; letter-spacing: .5px; }
.sale-lines .tbl td { padding-top: 8px; padding-bottom: 8px; }
.sale-lines .tbl tr.just-added td { animation: flash 1s ease-out; }
@keyframes flash { from { background: #FFF7D6; } }
.sale-totals { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.sale-totals .ln { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sale-totals .ln.net { padding-top: 8px; margin-top: 4px; border-top: 2px solid var(--border-2); font-size: 18px; font-weight: 800; color: var(--ink); }
.sale-keys { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.sale-bar { display: none; }
@media (max-width: 1100px) { .sale-grid { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 860px) {
  .sale-grid { grid-template-columns: 1fr; padding-bottom: 76px; }
  .sale-grid .sale-side { position: static; }
  .sale-entry { grid-template-columns: 1fr; }
  .sale-bar { display: flex; position: fixed; inset: auto 0 0 0; z-index: 30; gap: 10px; align-items: center; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(11, 37, 69, .1); }
  .sale-bar .money { font-size: 20px; font-weight: 800; color: var(--ink); }
  .sale-bar .btn { margin-inline-start: auto; height: 48px; padding: 0 22px; }
}

/* ───────── invoice preview (the PNG / PDF the server draws) ───────── */
.doc-frame { background: #E9E6DF; border-radius: var(--radius-lg); padding: 16px; display: flex; justify-content: center; overflow: auto; max-height: 75vh; }
.doc-frame img, .doc-frame iframe { background: #fff; box-shadow: 0 6px 24px rgba(15, 23, 42, .18); border: 0; max-width: 100%; }
.doc-frame.a4 img, .doc-frame.a4 iframe { width: 794px; }
.doc-frame.r80 img, .doc-frame.r80 iframe { width: 302px; }
.doc-frame iframe { height: 1123px; }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.paper-toggle { display: inline-flex; background: #EDEAE3; border-radius: 10px; padding: 3px; gap: 2px; }
.paper-toggle button { border: 0; background: transparent; height: 32px; padding: 0 12px; border-radius: 8px; font-weight: 700; color: var(--muted); cursor: pointer; }
.paper-toggle button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.stamp { display: inline-block; padding: 2px 12px; border: 2px solid currentColor; border-radius: 6px; font-weight: 800; transform: rotate(-6deg); }
.stamp.cancelled { color: var(--red); } .stamp.copy { color: var(--navy-3); } .stamp.preview { color: var(--amber); }

/* ───────── home (the first dashboard) ───────── */
.hero { position: relative; border-radius: var(--radius-lg); overflow: hidden; color: #fff; margin-bottom: 14px; background: radial-gradient(900px 300px at 0% 0%, rgba(56, 189, 248, .45), transparent 60%), linear-gradient(120deg, var(--navy) 0%, var(--navy-2) 45%, var(--navy-3) 100%); box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; left: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; border: 40px solid rgba(224, 242, 254, .07); }
.hero .hero-in { position: relative; z-index: 1; display: flex; align-items: center; gap: 16px; padding: 20px 22px; flex-wrap: wrap; }
.hero h2 { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.3; }
.hero .tag { color: #B9D6F2; font-weight: 600; margin-top: 2px; }
.hero .hero-logo { width: 64px; height: 64px; border-radius: 14px; background: rgba(255, 255, 255, .96); display: grid; place-items: center; flex: none; overflow: hidden; }
.hero .hero-logo img { width: 56px; height: 56px; object-fit: contain; }
.hero .hero-logo.plain { background: transparent; } .hero .hero-logo.plain img { width: 64px; height: 64px; }
.hero .hero-act { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.hero .btn { border-color: rgba(255, 255, 255, .3); }
.hero .btn.glass { background: rgba(255, 255, 255, .12); color: #fff; } .hero .btn.glass:hover { background: rgba(255, 255, 255, .22); }
@media (max-width: 760px) { .hero .hero-in { padding: 16px; } .hero h2 { font-size: 19px; } .hero .hero-logo { width: 52px; height: 52px; } .hero .hero-logo img { width: 46px; height: 46px; } .hero .hero-act { margin-inline-start: 0; width: 100%; } .hero .hero-act .btn { flex: 1; } }
.dash-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
@media (max-width: 980px) { .dash-2 { grid-template-columns: 1fr; } }
.quick-acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.quick-act { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: #fff; color: var(--text); font-weight: 700; }
.quick-act:hover { border-color: var(--sky-light); box-shadow: var(--shadow-md); color: var(--ink); }
.quick-act .ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--sky-soft); color: var(--sky-2); }
.quick-act .ic svg { width: 22px; height: 22px; }
.quick-act small { font-weight: 500; color: var(--muted); font-size: 12px; }

/* ───────── print-friendly ───────── */
.print-only { display: none; }
@media print {
  body { overflow: visible; background: #fff; }
  .app { display: block; height: auto; }
  .topbar, .sidebar, .group-tabs, .offline-banner, .toasts, .no-print, .ph .actions, .btn, .nav-backdrop { display: none !important; }
  .main { overflow: visible; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ccc; }
  .tbl th { position: static; background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block; }
  a { color: inherit; }
}

/* ───────── picture dialog (camera.js: an agent's ID card, an item photo) ───────── */
.cam-box { position: relative; width: min(100%, calc(min(50vh, 420px) * 4 / 3)); align-self: center; aspect-ratio: 4 / 3; background: #0B1220; border-radius: 12px; overflow: hidden; display: grid; place-items: center; }
.cam-box video, .cam-box img, .cam-box canvas { width: 100%; height: 100%; object-fit: contain; }
.cam-box .guide { position: absolute; pointer-events: none; border: 2px dashed rgba(255, 255, 255, .6); }
.cam-box .guide.face { inset: 12% 28%; border-radius: 50% / 42%; }
.cam-box .guide.card { inset: 18% 10%; border-radius: 14px; }   /* an ID card is 85.6 × 54 mm */
.cam-box .msg { color: #E2E8F0; padding: 24px; text-align: center; }
.cam-box .msg svg { width: 40px; height: 40px; color: #94A3B8; }
.drop { border: 2px dashed var(--border); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); background: var(--card-2); transition: border-color .12s, background .12s; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--sky-light); background: #F5FBFF; }
.drop svg { width: 30px; height: 30px; color: var(--sky-2); }

/* ───────── settings ← المحل: the live document preview (POST /api/docs/sample → PNG, drawn by the server, SPEC §9) ───────── */
.doc-preview { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.doc-preview .dp-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.doc-preview .seg.sm button { height: 30px; padding: 0 10px; font-size: 12.5px; }
.doc-preview .dp-paper { position: relative; background: #E7E3DA; border: 1px solid var(--border); border-radius: 10px; padding: 14px; min-height: 220px;
  display: flex; justify-content: center; align-items: flex-start; }
.doc-preview .dp-paper img { width: 100%; max-width: 640px; height: auto; background: #fff; box-shadow: 0 2px 10px rgba(15, 23, 42, .18); display: block; }
.doc-preview .dp-paper.roll img { max-width: 300px; }
.doc-preview .dp-paper.busy img { opacity: .55; transition: opacity .2s; }
.doc-preview .dp-wait { padding: 60px; }
/* the print switches next to the preview (what the paper shows) */
[data-print-show] .switch.show-opt { align-items: flex-start; }
[data-print-show] .switch.show-opt .tr { margin-top: 2px; }
[data-print-show] .switch.show-opt .col { gap: 1px; }
@media (max-width: 640px) {
  .doc-preview .dp-bar .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .doc-preview .dp-paper { padding: 8px; }
}

/* ───────── items and stock (SPEC §11: #/items, #/item/{id|new}, #/stock) ───────── */
/* the server's stock text («3 صناديق + 5 قطع») coloured by its state */
.stock-txt { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--navy-3); white-space: nowrap; }
.stock-txt svg { width: 15px; height: 15px; flex: none; color: var(--sky-2); }
.stock-txt.low { color: var(--amber); } .stock-txt.low svg { color: var(--amber); }
.stock-txt.out { color: var(--red); } .stock-txt.out svg { color: var(--red); }
/* the sizes of a list row: label + pieces, low / out coloured */
.mini-sizes { display: flex; flex-wrap: wrap; gap: 4px; }
.mini-sizes .ms { display: inline-flex; align-items: baseline; gap: 3px; height: 22px; padding: 0 7px; border-radius: 6px; background: var(--card-2); border: 1px solid var(--border-2); font-size: 12px; font-weight: 800; direction: ltr; color: var(--text); }
.mini-sizes .ms i { font-style: normal; font-weight: 600; color: var(--muted); font-size: 11px; }
.mini-sizes .ms.low { background: var(--amber-soft); border-color: #F6D9A3; } .mini-sizes .ms.low i { color: var(--amber); }
.mini-sizes .ms.out { background: var(--red-soft); border-color: #F5CACA; } .mini-sizes .ms.out i { color: var(--red); }
/* the items list: a table from tablets up, one card per item on phones */
.item-cards { display: none; }
.item-cardrow { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--border-2); background: #fff; text-align: right; cursor: pointer; font: inherit; color: inherit; }
.item-cardrow:hover { background: var(--row); }
.item-cardrow.dim { opacity: .6; }
@media (max-width: 760px) { .items-table { display: none; } .item-cards { display: block; } }
/* the item card */
.ic-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.ic-pic { width: 112px; height: 112px; border-radius: 12px; overflow: hidden; flex: none; border: 1px solid var(--border-2); background: var(--sky-soft); display: grid; place-items: center; color: var(--sky-2); }
.ic-pic img { width: 100%; height: 100%; object-fit: cover; } .ic-pic.none svg { width: 40px; height: 40px; }
.ic-prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 4px; }
.ic-prices > div { padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--card-2); }
.ic-prices span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.ic-total { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--sky-soft); }
.ic-total .stock-txt { font-size: 17px; }
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.sg-cell { border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; background: #fff; display: flex; flex-direction: column; gap: 2px; }
.sg-cell .sg-l { font-size: 20px; font-weight: 800; color: var(--navy); direction: ltr; text-align: right; }
.sg-cell .sg-q { font-weight: 700; } .sg-cell .sg-q small { color: var(--muted); font-weight: 600; }
.sg-cell .sg-t { font-size: 12px; color: var(--navy-3); font-weight: 700; } .sg-cell .sg-m { font-size: 11px; color: var(--muted); }
.sg-cell.low { border-color: #F6D9A3; background: #FFFBF3; } .sg-cell.low .sg-t { color: var(--amber); }
.sg-cell.out { border-color: #F5CACA; background: #FFF8F8; } .sg-cell.out .sg-t { color: var(--red); }
.sg-cell.off { opacity: .55; }
.move-kind { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.move-kind svg { width: 15px; height: 15px; } .move-kind.in svg { color: var(--green); } .move-kind.out svg { color: var(--red); }
/* the item editor: the form on the right, picture / carton / prices on the left; one column on phones */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; align-items: start; }
@media (max-width: 1100px) { .editor-grid { grid-template-columns: 1fr; } }
.sizes-editor td { padding-top: 4px; padding-bottom: 4px; }
.mix-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.mix-cell { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border-2); border-radius: 10px; padding: 4px 8px; background: var(--card-2); }
.mix-cell .lb { font-weight: 800; direction: ltr; min-width: 26px; }
.mix-cell .input { height: 32px; }
/* the code entry of the stock documents and the stocktake */
.code-entry { display: flex; flex-direction: column; gap: 10px; }
.ce-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ce-code { width: 200px; flex: none; } .ce-code .input { font-weight: 800; letter-spacing: .5px; }
.ce-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; background: var(--sky-soft); min-width: 0; flex: 1 1 260px; }
.entry-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.doc-totals { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-top: 1px solid var(--border-2); background: var(--card-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.doc-totals > div { display: flex; flex-direction: column; padding: 2px 10px; border-inline-end: 1px solid var(--border-2); }
.doc-totals > div span { font-size: 11.5px; color: var(--muted); font-weight: 600; } .doc-totals > div b { font-size: 17px; }
.doc-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.doc-head > div { padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--card-2); }
.doc-head span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.doc-status.applied { background: var(--green-soft); color: var(--green); }
.count-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.cg-cell { border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; background: #fff; display: flex; flex-direction: column; gap: 4px; }
.cg-cell .cg-l { font-size: 20px; font-weight: 800; color: var(--navy); direction: ltr; text-align: right; }
.cg-cell .input { height: 36px; font-weight: 800; }
@media (max-width: 760px) {
  .ce-code { width: 100%; } .ce-top .btn { flex: 1; }
  .entry-row > * { flex: 1 1 140px; } .entry-row .unit-toggle, .entry-row .seg { flex: 1 1 100%; justify-content: stretch; }
  .entry-row .unit-toggle button, .entry-row .seg button { flex: 1; justify-content: center; }
  .doc-totals .btn { width: 100%; }
  .ic-pic { width: 84px; height: 84px; }
}

/* ───────── agents, debts, expenses, cash box (Agents + Money screens) ───────── */
/* an amount inside .balance-box keeps its own look (the box's label rule «.balance-box span» is for the captions only) */
.balance-box .money { display: inline; font-size: inherit; font-weight: 800; }
.balance-box .money .cur { display: inline; font-size: .72em; font-weight: 600; color: var(--muted); }
.balance-box .money.debt { color: var(--red); } .balance-box .money.credit { color: var(--green); } .balance-box .money.zero { color: var(--faint); }
.balance-box b.big { font-size: 24px; }
/* the agent picker of the payment dialog */
.agent-picker { position: relative; }
.agent-picker .ap-list { min-width: 0; }
.ap-chosen { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--sky-light); border-radius: 10px; background: #F5FBFF; }
.ap-chosen .ap-ic { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--sky-soft); color: var(--sky-2); flex: none; }
.ap-chosen .ap-ic svg { width: 20px; height: 20px; }
.ap-chosen .ap-bal { display: flex; flex-direction: column; align-items: flex-end; }
/* «فقط مئة ألف دينار عراقي لا غير» under an amount */
.words-preview { padding: 8px 12px; border-radius: 9px; background: var(--sky-soft); color: #0C4A6E; font-weight: 600; line-height: 1.6; }
.pay-done { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px; background: var(--green-soft); color: #166534; }
.pay-done svg { width: 30px; height: 30px; flex: none; }

/* the agent card's header */
.agent-head { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.agent-head .ah-main { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.agent-head h1 { margin: 0; font-size: 20px; color: var(--ink); line-height: 1.3; }
.agent-head .ah-ava { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy), var(--navy-3)); color: #fff; flex: none; }
.agent-head .ah-ava svg { width: 26px; height: 26px; }
.agent-head .ah-act { display: flex; gap: 8px; flex-wrap: wrap; margin-inline-start: auto; }
.agent-head .ah-main > .grow { flex: 1 1 260px; }
@media (max-width: 640px) { .agent-head .ah-act { width: 100%; } .agent-head .ah-act .btn { flex: 1; } }

/* aging: one bar split in the four buckets */
.aging-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #EDEAE3; }
.aging-bar.lg { height: 20px; border-radius: 8px; }
.aging-bar i { display: block; height: 100%; min-width: 0; }
.aging-bar i.b0_30, .aging-legend i.b0_30 { background: var(--sky); }
.aging-bar i.b30_60, .aging-legend i.b30_60 { background: #F59E0B; }
.aging-bar i.b60_90, .aging-legend i.b60_90 { background: #EA580C; }
.aging-bar i.b90, .aging-legend i.b90 { background: var(--red); }
.aging-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12.5px; }
.aging-legend span { display: inline-flex; align-items: center; gap: 6px; }
.aging-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.aging-mini { border-top: 1px dashed var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.debts-tbl tr.overdue-row td:first-child { box-shadow: inset -3px 0 0 var(--red); }

/* statement and cash tables */
.tbl tr.opening-row td { background: var(--card-2); color: var(--muted); }
.statement-tbl td.num, .statement-tbl th.num { min-width: 92px; }
.id-thumb { width: 220px; max-width: 100%; aspect-ratio: 85.6 / 54; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--card-2); cursor: zoom-in; }
.id-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* expenses: totals by shop / category as small bars */
.bar-line { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.bar-line .bl-bar { height: 8px; border-radius: 6px; background: #EDEAE3; overflow: hidden; }
.bar-line .bl-bar i { display: block; height: 100%; background: var(--navy-3); }
.bar-line .bl-bar.amber i { background: #F59E0B; }
.shop-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.shop-card.dim { opacity: .6; }
.shop-card .sc-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--sky-soft); color: var(--sky-2); flex: none; }
.shop-card .sc-ic svg { width: 20px; height: 20px; }

/* the cash box: the moves beside the totals by kind */
.cash-grid { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
@media (max-width: 1100px) { .cash-grid { grid-template-columns: minmax(0, 1fr); } }

/* ───────── the sale screen (sell.js) ───────── */
.sell-page { padding-top: 12px; }
.sell-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sell-head .sh-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sell-head h1 { margin: 0; font-size: 19px; color: var(--ink); line-height: 1.2; }
.sell-head .sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.sell-head .sub svg { color: var(--sky-2); }
.mode-toggle button { height: 40px; padding: 0 18px; font-size: 15px; }
.mode-toggle button.on { background: var(--navy); color: #fff; }
.sell-keys { margin-inline-start: auto; display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.sell-keys span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.sell-customer { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.agent-strip { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.agent-strip > div { display: flex; flex-direction: column; justify-content: center; padding: 4px 12px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--card-2); min-width: 104px; }
.agent-strip > div > span { font-size: 11px; color: var(--muted); font-weight: 600; }
.agent-strip > div b { font-size: 15px; }
.agent-strip .sp { flex-direction: row; align-items: center; gap: 6px; background: var(--sky-soft); border-color: #BAE6FD; color: var(--sky-2); font-weight: 700; font-size: 12.5px; }
.agent-strip .sp svg, .agent-strip .red svg { width: 16px; height: 16px; }
.agent-strip .red { flex-direction: row; align-items: center; gap: 6px; background: var(--red-soft); border-color: #F5CACA; }
.walkin-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.walkin-row .input { flex: 1 1 180px; height: 36px; }
.walkin-row .badge { height: 28px; padding: 0 10px; font-size: 12.5px; }
.sale-entry2 { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 14px; padding: 14px 16px; align-items: start; }
.se-code { position: relative; display: flex; flex-direction: column; gap: 5px; }
.se-code .code-in { height: 54px; font-size: 24px; font-weight: 800; text-align: center; direction: ltr; letter-spacing: .5px; padding-inline-start: 34px; }
.se-suggest { width: 380px; inset-inline-end: auto; }
.se-suggest .it .code-badge { flex: none; }
.se-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.se-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; background: var(--sky-soft); min-width: 0; }
.se-price { display: flex; flex-direction: column; align-items: flex-end; padding: 0 8px; border-inline-start: 1px solid #BAE6FD; }
.se-price span { font-size: 11px; color: var(--muted); font-weight: 600; } .se-price small { font-size: 11px; font-weight: 700; }
.se-msg { min-height: 54px; display: flex; align-items: center; gap: 6px; }
.se-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.se-row .se-size { width: 96px; } .se-row .se-size .input { height: 48px; font-size: 18px; font-weight: 800; }
.se-row .se-qty { width: 110px; } .se-row .se-qty .input { font-weight: 800; text-align: center; }
.se-row .unit-toggle button { height: 42px; }
.se-pcs { display: flex; flex-direction: column; justify-content: center; min-width: 70px; color: var(--muted); padding-bottom: 4px; }
.se-row .btn.lg { margin-inline-start: auto; }
.sale-side .sale-totals { padding: 12px 14px; gap: 5px; }
.sale-side .sale-totals .ln.net { padding-top: 6px; margin-top: 2px; }
.sale-side .sale-totals .input { height: 36px; }
.sale-side .pay-chip { height: 38px; }
.sell-msg > .row > svg { flex: none; margin-top: 2px; }
.sale-tbl th, .sale-tbl td { padding-inline: 8px; }
.sale-tbl td.det { min-width: 180px; }
.sale-tbl .sm-in, .sale-totals .sm-in { height: 34px; padding: 0 8px; font-weight: 700; }
.sale-tbl .price-cell .sm-in { width: 110px; } .sale-tbl .qty-cell .sm-in.qty { width: 64px; text-align: center; }
.sale-tbl td.num .sm-in { width: 92px; }
.sale-tbl .note-cell .sm-in { min-width: 110px; font-weight: 500; }
.sale-tbl tr.sel td { background: #F5FBFF; } .sale-tbl tr.sel td:first-child { box-shadow: inset -3px 0 0 var(--sky); }
.sale-tbl tr.just-added td { animation: flash 1s ease-out; }
.sale-tbl tr.short td { background: #FFF5F5; }
.sale-tbl .link-btn.tiny { font-size: 11px; }
.sale-totals .ln.disc-ln, .sale-totals .ln.paid-ln { gap: 6px; }
.sale-totals .disc-in, .sale-totals .paid-in { width: 130px; }
.sale-totals .words { line-height: 1.5; text-align: center; }
.seg.mini { padding: 2px; } .seg.mini button { height: 30px; padding: 0 9px; font-size: 12.5px; }
.pay-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0; }
.pay-chip { height: 40px; border-radius: 10px; border: 1px solid var(--border); background: #fff; font-weight: 800; cursor: pointer; color: var(--muted); }
.pay-chip:hover:not(:disabled) { border-color: var(--sky-light); }
.pay-chip.on.cash { background: var(--green); border-color: var(--green); color: #fff; }
.pay-chip.on.credit { background: var(--red); border-color: var(--red); color: #fff; }
.pay-chip.on.partial { background: var(--amber); border-color: var(--amber); color: #fff; }
.pay-chip:disabled { opacity: .45; cursor: not-allowed; }
.alert.compact { padding: 8px 10px; font-size: 12.5px; } .alert.compact svg { width: 17px; height: 17px; }
.sell-msg { padding: 12px 14px; border-color: #F5CACA; background: #FFFBFB; }
.sell-msg .short-list { margin: 6px 0 0; padding-inline-start: 18px; font-size: 12.5px; line-height: 1.9; }
.sell-actions { display: flex; flex-direction: column; gap: 8px; }
.sell-actions .btn .kbd { background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .3); color: inherit; }
.sell-actions .btn:not(.primary) .kbd { background: var(--card-2); border-color: #D3CEC3; color: #475569; }
.pay-done.big b { font-size: 18px; }
.kind-chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 800; white-space: nowrap; background: #DCE6F4; color: var(--navy-3); }
.kind-chip svg { width: 13px; height: 13px; }
.kind-chip.return { background: var(--amber-soft); color: var(--amber); }
.pin-box { font-size: 26px; letter-spacing: 10px; font-weight: 800; }
.keypad.sm button { height: 50px; font-size: 20px; }
@media (max-width: 1100px) { .sale-entry2 { grid-template-columns: 150px minmax(0, 1fr); } .sell-keys { display: none; } }
@media (max-width: 860px) {
  .sale-entry2 { grid-template-columns: 1fr; }
  .se-suggest { width: auto; inset-inline: 0; }
  .se-row .se-size, .se-row .se-qty { flex: 1 1 90px; width: auto; }
  .se-row .unit-toggle { flex: 1 1 100%; } .se-row .unit-toggle button { flex: 1; }
  .se-row .btn.lg { width: 100%; }
  .sale-tbl .price-cell .sm-in, .sale-tbl td.num .sm-in { width: 86px; }
  .sell-actions { margin-bottom: 8px; }
  .sale-bar > div { display: flex; flex-direction: column; }
}

/* ───────── one invoice (invoice.js) ───────── */
.inv-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 12px; align-items: start; }
@media (max-width: 1100px) { .inv-grid { grid-template-columns: 1fr; } }
.inv-info b a { color: var(--navy-3); }
.inv-lines th { background: var(--navy); color: #fff; }
.inv-lines tbody tr:nth-child(even) td { background: #F8FAFC; }
.inv-lines td { border-inline-start: 1px solid var(--border-2); }
.inv-totals { width: 100%; border-collapse: collapse; }
.inv-totals th, .inv-totals td { padding: 8px 14px; border-bottom: 1px solid var(--border-2); text-align: right; }
.inv-totals th { color: var(--muted); font-weight: 600; width: 50%; background: var(--card-2); }
.inv-totals td { text-align: left; }
.inv-totals tr.net th, .inv-totals tr.net td { background: var(--sky-soft); color: var(--ink); font-weight: 800; font-size: 16px; }
.m-12 { margin: 12px; }
/* the official statement under every sales and return invoice (SPEC §9): navy box, gold rules */
.statement-box { margin: 12px; padding: 12px 14px 14px; background: var(--navy); color: #fff; font-weight: 800; text-align: center; font-size: 15px; line-height: 1.6;
  border-top: 2px solid #B8964E; border-bottom: 6px solid #B8964E; border-radius: 4px; }
.cancel-banner { display: flex; align-items: center; gap: 14px; padding: 12px 16px; margin-bottom: 12px; border-radius: var(--radius-lg); background: #FFF5F5; border: 1px solid #F5CACA; }
.cancel-banner .stamp { font-size: 18px; }
.hist { max-height: 300px; overflow: auto; }
.hist-row { padding: 8px 14px; border-bottom: 1px solid var(--border-2); }
.hist-row:last-child { border-bottom: 0; }
.return-tbl tr.rt-line td { background: var(--card-2); border-top: 1px solid var(--border); }
.return-tbl .sm-in { width: 76px; height: 32px; }

/* ───────── drafts and quotes ───────── */
.drafts-tbl tr.fresh td { animation: flash 2.5s ease-out; }
.drafts-tbl tr.fresh td:first-child { box-shadow: inset -3px 0 0 var(--sky); }
