/* NexPos: white base, orange (brand) + green / red / blue accents. One light theme. */
:root {
  --brand: #f97316; --brand-ink: #111827;
  --orange: #f97316; --green: #16a34a; --red: #dc2626; --blue: #2563eb;
  --bg: #ffffff; --card: #ffffff; --soft: #f8fafc; --text: #111827; --muted: #6b7280; --line: #e5e7eb; --hover: #fff7ed;
  --ok: var(--green); --warn: #c2410c; --bad: var(--red); --link: var(--blue); --bar: var(--blue);
  --side: 232px; color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }
h1, h2, h3 { margin: 0; line-height: 1.25; } h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 15px; }
a { color: var(--link); } .muted { color: var(--muted); } small { color: var(--muted); font-size: 12px; font-weight: 400; }
.hide { display: none !important; } .right { text-align: end; } .nowrap { white-space: nowrap; }
.dot { width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); display: inline-grid; place-items: center; font-weight: 800; flex: none; }

/* controls */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; min-height: 38px; }
input[type=checkbox] { width: auto; min-height: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
button { padding: 8px 14px; border-radius: 8px; border: 1px solid #d1d5db; background: #fff; cursor: pointer; min-height: 38px; }
button:hover:not(:disabled) { background: var(--hover); } button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; } button.primary:hover:not(:disabled) { filter: brightness(.95); background: var(--brand); }
button.success { background: var(--green); color: #fff; border-color: var(--green); font-weight: 600; } button.success:hover:not(:disabled) { filter: brightness(.95); background: var(--green); }
button.danger { background: var(--red); color: #fff; border-color: var(--red); } button.danger:hover:not(:disabled) { filter: brightness(.95); background: var(--red); }
button.info { background: var(--blue); color: #fff; border-color: var(--blue); } button.info:hover:not(:disabled) { filter: brightness(.95); background: var(--blue); }
button.sm { padding: 3px 9px; min-height: 28px; font-size: 12px; }
.icon-btn { border: 0; background: transparent; font-size: 22px; line-height: 1; padding: 2px 8px; min-height: 0; }
label { display: block; font-size: 12px; font-weight: 600; color: #4b5563; } label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; color: var(--text); }
label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 400; color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; } .grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
form > * + * { margin-top: 12px; } .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.err { color: var(--red); min-height: 1.3em; margin: 6px 0 0; }

/* shell */
#shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
#side { background: #fff; border-inline-end: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
#side .logo { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; font-weight: 700; font-size: 16px; }
#side .logo img, .brandmark img { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
#side a.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; border-inline-start: 3px solid transparent; }
#side a.nav:hover { background: var(--soft); } #side a.nav.on { background: var(--hover); font-weight: 600; border-inline-start-color: var(--brand); }
#side svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
/* the four-colour pattern on nav icons */
#side a.nav:nth-of-type(4n+1) svg { color: var(--orange); } #side a.nav:nth-of-type(4n+2) svg { color: var(--green); }
#side a.nav:nth-of-type(4n+3) svg { color: var(--blue); } #side a.nav:nth-of-type(4n+4) svg { color: var(--red); }
#side .foot { margin-top: auto; padding: 8px; font-size: 12px; color: var(--muted); }
#top { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
#top .spacer { flex: 1; } #menu-btn { display: none; }
#top::after { content: ''; position: absolute; inset-inline: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--orange) 0 25%, var(--green) 25% 50%, var(--blue) 50% 75%, var(--red) 75% 100%); }
#content { padding: 20px; max-width: 1200px; width: 100%; margin: 0 auto; }
.banner { padding: 9px 20px; font-size: 13px; border-bottom: 1px solid var(--line); } .banner.warn { background: #fff7ed; color: #9a3412; } .banner.bad { background: #fef2f2; color: #991b1b; }

/* content blocks */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); } .card + .card { margin-top: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat b { display: block; font-size: 22px; line-height: 1.2; } .stat span { color: var(--muted); font-size: 12px; }
.stats .card { border-top: 3px solid var(--orange); } .stats .card:nth-child(4n+2) { border-top-color: var(--green); } .stats .card:nth-child(4n+3) { border-top-color: var(--blue); } .stats .card:nth-child(4n+4) { border-top-color: var(--red); }
.stats .card:nth-child(4n+1) b { color: #c2410c; } .stats .card:nth-child(4n+2) b { color: #15803d; } .stats .card:nth-child(4n+3) b { color: #1d4ed8; } .stats .card:nth-child(4n+4) b { color: #b91c1c; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; } .toolbar > label { min-width: 140px; } .toolbar .grow { flex: 1; min-width: 200px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 8px 12px; } .tabs button.on { border-color: var(--brand); color: var(--text); font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; } th, td { padding: 9px 10px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--soft); } td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: var(--hover); } tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; } tr.tot td { font-weight: 700; background: var(--soft); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; border: 1px solid currentColor; } .pill.ok { color: var(--green); background: #f0fdf4; } .pill.warn { color: #c2410c; background: #fff7ed; } .pill.bad { color: var(--red); background: #fef2f2; } .pill.mute { color: var(--muted); } .pill.info { color: var(--blue); background: #eff6ff; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; direction: ltr; } .chart .bar { fill: var(--bar); } .chart .axis { fill: var(--muted); font-size: 11px; }
.list-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); } .list-row:last-child { border: 0; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; } .two-col > .card + .card { margin-top: 0; }
.neg { color: var(--red); } .pos-n { color: var(--green); }

/* modal + toast */
dialog.modal { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: #fff; color: var(--text); width: min(520px, 94vw); max-height: 92vh; box-shadow: 0 20px 50px rgba(0, 0, 0, .2); } dialog.modal.wide { width: min(820px, 96vw); }
dialog.modal::backdrop { background: rgba(17, 24, 39, .45); } .modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 3px solid var(--brand); } .modal-body { padding: 18px; overflow: auto; max-height: calc(92vh - 60px); }
#toasts { position: fixed; inset-inline-end: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; } .toast { background: var(--green); color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 340px; box-shadow: 0 4px 16px rgba(0, 0, 0, .2); } .toast.err { background: var(--red); }

/* login */
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, #fff, var(--soft)); } #login .card { width: min(380px, 100%); border-top: 4px solid var(--brand); }
.brandmark { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 18px; font-weight: 700; } .brandmark img { width: 40px; height: 40px; }
.portal-switch { text-align: center; margin: 12px 0 0; font-size: 13px; }

/* scanner */
.scan-box { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; } .scan-box video { width: 100%; height: 100%; object-fit: cover; }
.scan-box::after { content: ''; position: absolute; inset: 18% 12%; border: 2px solid var(--orange); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.scan-line { position: absolute; z-index: 2; inset-inline: 14%; height: 2px; background: var(--red); top: 50%; animation: scan 1.8s ease-in-out infinite alternate; }
@keyframes scan { from { top: 24%; } to { top: 74%; } } @media (prefers-reduced-motion: reduce) { .scan-line { animation: none; } }

/* ---------- staff point of sale ---------- */
body.posmode { background: var(--soft); }
.pos { display: grid; grid-template-columns: 1fr 390px; height: 100vh; }
.pos-main { display: flex; flex-direction: column; min-width: 0; background: var(--soft); }
.pos-top { display: flex; gap: 8px; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); align-items: center; position: relative; flex-wrap: wrap; }
.pos-top::after { content: ''; position: absolute; inset-inline: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--orange) 0 25%, var(--green) 25% 50%, var(--blue) 50% 75%, var(--red) 75% 100%); }
.pos-top .grow { flex: 1; min-width: 180px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.chip { border-radius: 99px; padding: 4px 14px; min-height: 32px; white-space: nowrap; } .chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; overflow: auto; flex: 1; align-content: start; }
.pcard { text-align: start; padding: 10px; border-radius: 12px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--orange); min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.pcard:nth-child(4n+2) { border-top-color: var(--green); } .pcard:nth-child(4n+3) { border-top-color: var(--blue); } .pcard:nth-child(4n+4) { border-top-color: var(--red); }
.pcard b { font-size: 14px; line-height: 1.25; } .pcard .pr { font-weight: 700; font-size: 15px; } .pcard.out { opacity: .6; }
.cart { display: flex; flex-direction: column; background: #fff; border-inline-start: 1px solid var(--line); height: 100vh; min-height: 0; }
.cart-head { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cart-lines { flex: 1; overflow: auto; }
.cline { padding: 9px 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.cline .nm { font-weight: 600; } .cline .meta { color: var(--muted); font-size: 12px; } .cline .amt { font-weight: 700; text-align: end; font-variant-numeric: tabular-nums; }
.step { display: inline-flex; align-items: center; gap: 4px; } .step button { padding: 0; width: 30px; min-height: 30px; font-size: 18px; line-height: 1; } .step input { width: 56px; text-align: center; min-height: 30px; padding: 2px; }
.cart-foot { border-top: 2px solid var(--line); padding: 10px 12px; background: var(--soft); }
.sum-row { display: flex; justify-content: space-between; padding: 2px 0; } .sum-row.big { font-size: 20px; font-weight: 800; padding-top: 6px; }
.cart-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; } .cart-btns .pay { grid-column: 1 / -1; min-height: 50px; font-size: 17px; }
.mcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; } .mcards button { min-height: 52px; font-weight: 600; } .mcards button.on { outline: 3px solid var(--brand); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
#cart-toggle { display: none; }
@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; height: auto; min-height: 100vh; } .pos-main { min-height: 100vh; padding-bottom: 76px; }
  .cart { position: fixed; inset: 0; z-index: 30; height: 100vh; transform: translateY(100%); transition: transform .2s; } .cart.open { transform: none; }
  #cart-toggle { display: flex; position: fixed; inset-inline: 10px; bottom: 10px; z-index: 20; justify-content: space-between; min-height: 52px; font-size: 16px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
}

/* print: only the receipt / report / labels */
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; } #print-area { display: block !important; color: #000; background: #fff; padding: 12px; }
  #print-area table { font-size: 12px; } #print-area th, #print-area td { border-color: #bbb; background: #fff; }
  .receipt { width: 80mm; margin: 0 auto; font: 12px/1.35 ui-monospace, monospace; } .receipt h2 { text-align: center; } .receipt hr { border: 0; border-top: 1px dashed #000; } .receipt .row { display: flex; justify-content: space-between; gap: 8px; }
  .labels { display: flex; flex-wrap: wrap; gap: 2mm; } .lbl { width: 58mm; height: 32mm; border: 1px dashed #999; padding: 1.5mm 2mm; break-inside: avoid; text-align: center; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; align-items: center; }
  .lbl .n { font: 700 11px/1.2 system-ui, sans-serif; max-height: 2.4em; overflow: hidden; } .lbl .p { font: 800 15px system-ui, sans-serif; } .lbl svg { max-width: 100%; height: 14mm; }
}

@media (max-width: 820px) {
  #shell { grid-template-columns: 1fr; } #side { position: fixed; z-index: 20; width: 250px; inset-inline-start: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0, 0, 0, .15); }
  [dir=rtl] #side { transform: translateX(100%); } #side.open, [dir=rtl] #side.open { transform: none; } #menu-btn { display: inline-block; } #content { padding: 14px 12px; }
  .grid2, .grid3, .grid4, .two-col { grid-template-columns: 1fr; } #top { padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) { #side, .cart { transition: none; } }

/* right-to-left (Arabic) */
[dir=rtl] input[type=email], [dir=rtl] input[type=tel], [dir=rtl] input[type=number], [dir=rtl] input[type=url], [dir=rtl] input[type=password], [dir=rtl] input[type=date] { direction: ltr; text-align: right; }
[dir=rtl] code, [dir=rtl] .receipt { direction: ltr; unicode-bidi: plaintext; }
[dir=rtl] td.num, [dir=rtl] th.num { direction: ltr; text-align: left; unicode-bidi: isolate; }
[dir=rtl] .pill { unicode-bidi: plaintext; } [dir=rtl] .cline .amt { text-align: left; direction: ltr; }
.lang-btn { font-size: 12px; }

/* manual POS (web) */
.cat-area { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.pos-tabs { margin: 0; padding: 0 12px; background: #fff; }
.mfilters { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); } .mfilters label { flex: 1; min-width: 110px; }
.mwrap { overflow: auto; flex: 1; padding: 0 12px 12px; background: #fff; } .mwrap th { position: sticky; top: 0; z-index: 1; }
