:root {
  --ink: #12343b;
  --ink-2: #3d5c63;
  --muted: #74898e;
  --line: #d9e9ec;
  --bg: #f3f9fa;
  --card: #ffffff;
  --accent: #c2438a;
  --accent-ink: #ffffff;
  --accent-soft: #fbe6f1;
  --teal: #47b6c9;
  --teal-deep: #1b5d69;
  --teal-soft: #e2f4f7;
  --gold: #f0c054;
  --ok: #2f7d5b;
  --ok-soft: #e3f3ea;
  --warn: #a66300;
  --warn-soft: #fff3d6;
  --bad: #c0392b;
  --bad-soft: #fbe5e2;
  --side: linear-gradient(180deg, #2a8ea0 0%, #1b5d69 100%);
  --side-ink: #e6f6f9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 52, 59, .06), 0 6px 24px rgba(18, 52, 59, .06);
  --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.boot { display: grid; place-items: center; height: 100vh; background: var(--teal); }
.boot img { width: 160px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 10px 14px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand img { width: 112px; height: auto; display: block; }
.brand small { display: block; font: 500 12px var(--font); color: #bfe6ee; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .06); }
.nav a.active { background: #fff; color: var(--teal-deep); font-weight: 700; box-shadow: inset -4px 0 0 var(--accent); }
.nav a .badge { margin-inline-start: auto; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 13px; }
.side-foot .who { font-weight: 600; color: #fff; }
.side-foot .links { display: flex; gap: 12px; margin-top: 8px; }
.side-foot a { color: #ffe08f; cursor: pointer; }
.main { padding: 26px 30px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 24px; font-weight: 700; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 10px; overflow-x: auto; }
  .brand { padding: 0 4px; border: 0; }
  .brand img { width: 46px; }
  .brand small, .side-foot .who, .side-foot .muted { display: none; }
  .nav { flex-direction: row; margin: 0; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .nav a span.lbl { display: none; }
  .nav a.active span.lbl { display: inline; }
  .side-foot { margin: 0; border: 0; padding: 0; }
  .side-foot .links { margin: 0; white-space: nowrap; }
  .main { padding: 18px 16px 60px; }
}

/* ---------- components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2, .card h3 { margin: 0 0 12px; font-size: 16px; }
.grid { display: grid; gap: 16px; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.kpi.accent { background: var(--teal-deep); color: #fff; border-color: var(--teal-deep); background-image: linear-gradient(135deg, #2a8ea0, #1b5d69); }
.kpi.accent .label { color: #c5ecf3; }
.two { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: #b9dbe1; background: #f7fcfd; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.dark { background: var(--teal-deep); border-color: var(--teal-deep); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 14px 18px; font-size: 17px; border-radius: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 12px; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--teal-deep); color: #fff; }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 10px; border-bottom: 1px solid #e9f3f5; vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: var(--teal-soft); }
.t td.actions { white-space: nowrap; text-align: end; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--teal-soft); color: var(--teal-deep); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent); color: #fff; }
.qty-low { color: var(--bad); font-weight: 700; }
.alert { border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert.warn { background: var(--warn-soft); color: #6b4300; }
.alert.info { background: var(--accent-soft); color: #6d2340; }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(18, 52, 59, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 18px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-start; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
#toast-root { position: fixed; bottom: 20px; left: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); max-width: 380px; animation: pop .18s ease-out; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: #47b6c9 url('/img/logo-full.jpg') left center / contain no-repeat; position: relative; display: flex; flex-direction: column; justify-content: flex-end; padding: 32px 40px; }
.login-art::after { content: ''; position: absolute; inset: auto 0 0 0; height: 6px; background: linear-gradient(90deg, var(--accent), var(--gold), var(--accent)); }
.login-art p { color: #fff; max-width: 420px; margin: 0; font-weight: 500; text-shadow: 0 1px 2px rgba(0,0,0,.18); position: relative; z-index: 1; }
.login-form { display: grid; place-items: center; padding: 24px; }
.login-form form { width: min(360px, 100%); display: grid; gap: 14px; }
.login-form h2 { margin: 0 0 4px; font-size: 22px; }
@media (max-width: 800px) { .login { grid-template-columns: 1fr; } .login-art { padding: 20px; min-height: 260px; } .login-art p { display: none; } }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .pos { grid-template-columns: 1fr; } }
.scan { position: relative; }
.scan .input { font-size: 20px; padding: 14px 48px 14px 14px; border-width: 2px; border-color: var(--teal); border-radius: 14px; }
.scan .scan-ico { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.suggest { position: absolute; top: calc(100% + 4px); inset-inline: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 10; max-height: 320px; overflow: auto; }
.suggest button { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 10px 14px; border: 0; background: none; cursor: pointer; text-align: start; border-bottom: 1px solid #e9f3f5; }
.suggest button:hover, .suggest button.sel { background: var(--accent-soft); }
.cart-item .name { font-weight: 600; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { border: 0; background: var(--teal-soft); width: 32px; height: 32px; cursor: pointer; font-size: 18px; }
.stepper input { width: 44px; text-align: center; border: 0; outline: none; height: 32px; }
.summary .row { display: flex; justify-content: space-between; padding: 6px 0; }
.summary .total { font-size: 28px; font-weight: 700; border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 12px; }
.pay-methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pay-methods button { padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 600; font-size: 13px; }
.pay-methods button.on { border-color: var(--teal-deep); background: var(--teal-deep); color: #fff; }

/* ---------- receipt (screen + print) ---------- */
.receipt { width: 76mm; margin: 0 auto; font-size: 12px; line-height: 1.5; color: #000; background: #fff; padding: 4mm 2mm; }
.receipt .r-brand { text-align: center; }
.receipt .r-brand img { width: 34mm; height: auto; }
.receipt .r-center { text-align: center; }
.receipt hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td, .receipt th { padding: 2px 0; vertical-align: top; font-size: 12px; }
.receipt th { text-align: start; border-bottom: 1px solid #000; }
.receipt .r-total { font-size: 16px; font-weight: 700; }
.receipt .void-stamp { border: 2px solid #c00; color: #c00; text-align: center; font-weight: 700; padding: 4px; margin: 6px 0; }
.receipt-frame { background: var(--teal-soft); padding: 14px; border-radius: 12px; max-height: 60vh; overflow: auto; }

/* labels */
.bc-label { width: 50mm; height: 30mm; padding: 1.5mm 2mm; display: flex; flex-direction: column; align-items: center; justify-content: space-between; overflow: hidden; color: #000; background: #fff; }
.bc-label .l-name { font-size: 9px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bc-label .l-price { font-size: 11px; font-weight: 700; }
.bc-label svg { width: 100%; height: 15mm; }
.labels-a4 { display: grid; grid-template-columns: repeat(4, 50mm); gap: 2mm; justify-content: center; }
.labels-a4 .bc-label { border: 1px dashed #bbb; }

/* bars */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar i { display: block; width: 100%; max-width: 34px; background: var(--accent); border-radius: 5px 5px 0 0; min-height: 2px; }
.bars .bar span { font-size: 10px; color: var(--muted); margin-top: 4px; }
.bars .bar:hover i { background: var(--teal-deep); }

#print-root { display: none; }
@media print {
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  .bc-label { page-break-after: always; break-after: page; }
  .labels-a4 .bc-label { page-break-after: auto; break-after: auto; break-inside: avoid; }
  .print-report .card { box-shadow: none; break-inside: avoid; }
}
.card h2 svg, .alert svg { width: 18px; height: 18px; flex: none; }
.receipt th, .receipt td { padding-inline: 2px; }
/* 3 printer dots per module on 203-dpi label printers → crisp, scannable bars */
.bc-label svg[data-ean] { width: 43.125mm; }

.side { box-shadow: inset 1px 0 0 rgba(255,255,255,.08); }
.topbar h1 { color: var(--teal-deep); }
.nav { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.nav a { padding: 8px 12px; }
@media (max-width: 900px) { .nav { overflow: visible; flex: none; } }
