/* Retail POS — app styles. Clean light UI (dark mode available), RTL first.
   Colours live in the tokens below; change --primary to re-brand. Money is never coloured specially:
   numbers use tabular figures so columns line up. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f3f4f6;
  --line: #e5e7eb;
  --line-2: #d1d5db;
  --text: #111827;
  --muted: #4b5563;
  --faint: #6b7280;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-line: #bfdbfe;
  --on-primary: #ffffff;

  --ok: #15803d;   --ok-soft: #dcfce7;   --ok-line: #bbf7d0;   --ok-bar: #16a34a;
  --bad: #b91c1c;  --bad-soft: #fee2e2;  --bad-line: #fecaca;  --bad-bar: #dc2626;
  --warn: #b45309; --warn-soft: #fef3c7; --warn-line: #fde68a;
  --info: #6d28d9; --info-soft: #ede9fe; --info-line: #ddd6fe;

  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px -12px rgba(16, 24, 40, .25);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --sb-w: 248px;
  --top-h: 56px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --surface-2: #1c2027;
  --surface-3: #232831;
  --line: #2a2f38;
  --line-2: #3a404b;
  --text: #e8eaed;
  --muted: #b4b9c2;
  --faint: #8b929d;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: rgba(59, 130, 246, .14);
  --primary-line: rgba(59, 130, 246, .35);

  --ok: #4ade80;   --ok-soft: rgba(34, 197, 94, .14);  --ok-line: rgba(34, 197, 94, .3);  --ok-bar: #22c55e;
  --bad: #f87171;  --bad-soft: rgba(239, 68, 68, .14); --bad-line: rgba(239, 68, 68, .3); --bad-bar: #ef4444;
  --warn: #fbbf24; --warn-soft: rgba(245, 158, 11, .14); --warn-line: rgba(245, 158, 11, .3);
  --info: #a78bfa; --info-soft: rgba(139, 92, 246, .16); --info-line: rgba(139, 92, 246, .32);

  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 24px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.small { font-size: 12.5px; }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.mono { font-family: var(--mono); font-size: .95em; }
.center { text-align: center; }
.g { color: var(--primary); }
.bad-text { color: var(--bad); }
.ok-text { color: var(--ok); }
.move-in { color: var(--ok); }
.move-out { color: var(--bad); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fx { display: none; }
.icon { flex: none; display: block; }

/* ---------- App shell: sidebar (right, RTL) + top bar ---------- */
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 30;
  width: var(--sb-w);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
}
.shell { min-height: 100svh; }
.has-sidebar .shell { margin-inline-start: var(--sb-w); }

.sb-brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 12px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand .mark {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--primary); color: var(--on-primary);
  font-weight: 700; font-size: 16px;
}
.brand .word { display: flex; flex-direction: column; font-weight: 700; font-size: 15px; line-height: 1.25; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: var(--faint); font-weight: 500; font-size: 11.5px; }

.sb-nav { flex: 1; overflow-y: auto; padding: 8px 10px 12px; }
.sb-section { margin: 14px 8px 6px; font-size: 11.5px; font-weight: 600; color: var(--faint); letter-spacing: .02em; }
.sb-link {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; margin-bottom: 2px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted);
  font: 500 14px var(--font); text-align: start; cursor: pointer;
}
.sb-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.sb-link.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sb-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sb-foot { border-top: 1px solid var(--line); padding: 10px; }
.sb-foot form { margin: 0; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; }
.avatar {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 700;
}
.who-name { display: flex; flex-direction: column; line-height: 1.3; font-weight: 600; font-size: 13.5px; min-width: 0; }
.who-name small { color: var(--faint); font-weight: 500; font-size: 12px; }
.theme-light { display: none; }
:root[data-theme="dark"] .theme-light { display: block; }
:root[data-theme="dark"] .theme-dark { display: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* Collapsed (icons only) */
.sb-collapsed .sidebar { width: 68px; }
.sb-collapsed .has-sidebar .shell, .sb-collapsed body.has-sidebar .shell { margin-inline-start: 68px; }
.sb-collapsed .sidebar .word, .sb-collapsed .sidebar .sb-section, .sb-collapsed .sidebar .sb-link span,
.sb-collapsed .sidebar .who-name, .sb-collapsed .sidebar .theme-label { display: none; }
.sb-collapsed .sb-brand { flex-direction: column; padding: 12px 8px; }
.sb-collapsed .sb-link { justify-content: center; padding: 10px; }
.sb-collapsed .sb-user { justify-content: center; padding: 6px 0 10px; }
.sb-collapsed .sb-nav { padding-inline: 8px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--top-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-end { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }
.branch-switch { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); }
.branch-switch select, .branch-pill {
  padding: 6px 10px; border-radius: var(--radius-sm); font: 600 13.5px var(--font);
  background: var(--surface); color: var(--text); border: 1px solid var(--line-2);
}
.branch-pill { display: inline-flex; align-items: center; gap: 6px; }
.sb-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(17, 24, 39, .45); }

.main { max-width: 1320px; margin: 0 auto; padding: 24px 24px 56px; }

@media (max-width: 960px) {
  .has-sidebar .shell, .sb-collapsed body.has-sidebar .shell { margin-inline-start: 0; }
  .sidebar { display: none; box-shadow: var(--shadow-lg); width: min(var(--sb-w), 86vw) !important; }
  body.sb-open .sidebar { display: flex; }
  .sb-collapsed .sidebar .word, .sb-collapsed .sidebar .sb-section, .sb-collapsed .sidebar .sb-link span,
  .sb-collapsed .sidebar .who-name, .sb-collapsed .sidebar .theme-label { display: revert; }
  .sb-collapse { display: none; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .main { padding: 16px 16px 48px; }
}

/* ---------- Page heading ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .h2 { margin: 0; }
.h2 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.h3 { font-size: 16px; font-weight: 700; margin: 24px 0 12px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-block; padding: 2px 10px; margin-bottom: 10px;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 600;
}

/* ---------- Cards ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
section.panel, .report-grid .panel { margin-bottom: 16px; }
.panel > .h3:first-child, .panel > h2:first-child { margin-top: 0; }

/* KPI tiles */
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 45%), 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text);
}
a.stat:hover { border-color: var(--primary-line); text-decoration: none; }
.stat > .faint:first-child, .stat .stat-label { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat strong { font-size: 26px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat small { font-size: 12.5px; }
.stat .stat-icon {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
}
.stat .stat-icon.ok { background: var(--ok-soft); color: var(--ok); }
.stat .stat-icon.bad { background: var(--bad-soft); color: var(--bad); }
.stat .stat-icon.warn { background: var(--warn-soft); color: var(--warn); }
.stat .stat-icon.info { background: var(--info-soft); color: var(--info); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 16px;
  border: 1px solid var(--primary); border-radius: var(--radius-sm);
  background: var(--primary); color: var(--on-primary);
  font: 600 14px var(--font); line-height: 1.2; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { background: var(--bad-bar); border-color: var(--bad-bar); color: #fff; }
.btn.danger:hover { filter: brightness(.95); }
.btn.sm { min-height: 32px; padding: 5px 12px; font-size: 13px; }
.btn.tiny { min-height: 28px; padding: 2px 9px; font-size: 13px; }
.btn.block { display: flex; width: 100%; }
.btn.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span, fieldset.field legend { font-weight: 600; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, input.qty, .scan-bar input, .discount-custom input, .pay-row input, .discount-custom select {
  width: 100%; padding: 9px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: 500 14px var(--font);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { resize: vertical; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus, input.qty:focus, .scan-bar input:focus,
.discount-custom input:focus, .pay-row input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field select:disabled, .field input:disabled { opacity: .6; background: var(--surface-3); }
.field input.pin { letter-spacing: .6em; text-align: center; font-size: 22px; }
.field input[type=file] { padding: 8px; font-size: 13px; }
fieldset.field, fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain { display: grid; gap: 16px; }
fieldset.field legend { margin-bottom: 6px; }
.err { color: var(--bad); font-weight: 500; font-size: 12.5px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-top: 10px; }
.grid-3[hidden] { display: none; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 16px; }
.field[hidden] { display: none; }
form.inline { display: inline; margin: 0; }

.checks-inline { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 7px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); font-size: 13.5px;
  background: var(--surface);
}
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.check:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.checks-inline.sizes .check { min-width: 60px; justify-content: center; }

.perm-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.perm-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; display: grid; gap: 4px; align-content: start; background: var(--surface-2); }
.perm-group legend { padding: 0 6px; font-weight: 700; color: var(--text); }
.perm-group .check { border: 0; padding: 4px 6px; background: transparent; }

.search-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; padding: 14px 16px; }
.search-bar .grow { flex: 1 1 260px; }
.search-bar .field select { min-width: 150px; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px 0; margin-top: 8px;
  background: linear-gradient(transparent, var(--bg) 30%);
}

/* ---------- Tabs (segmented) ---------- */
.tabs {
  display: inline-flex; gap: 2px; padding: 3px; margin: 0 0 16px;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 10px;
  max-width: 100%; overflow-x: auto;
}
.tabs a {
  padding: 6px 14px; border-radius: 7px; white-space: nowrap;
  color: var(--muted); font-weight: 600; font-size: 13.5px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.main > .tabs { display: flex; width: fit-content; }
.tabs.wrap { flex-wrap: wrap; }

/* ---------- Alerts ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 500; font-size: 13.5px; border: 1px solid; margin: 0 0 14px; }
.alert.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.alert.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.alert.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.alert ul { margin: 6px 0 0; padding-inline-start: 20px; }
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }
.panel.alert { padding: 12px 16px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel .table-wrap { box-shadow: none; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { background: var(--surface-2); color: var(--faint); font-weight: 600; font-size: 12.5px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.inactive td { opacity: .55; }
.table .num { text-align: center; font-variant-numeric: tabular-nums; }
.table tr.group-row td { background: var(--surface-3); font-weight: 700; padding-top: 7px; padding-bottom: 7px; }
.table caption { text-align: start; padding: 8px 12px; }
.panel > .table { margin: -4px 0; }
tr.short td { color: var(--bad); }

/* Status labels */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface-3); color: var(--muted);
  font-size: 12px; font-weight: 600; line-height: 1.7; white-space: nowrap;
}
.tag.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.tag.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.tag.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }

/* ---------- Status checklist (home) ---------- */
.checks { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.checks li {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.checks .dot { width: 8px; height: 8px; border-radius: 50%; grid-row: span 2; }
.checks .ok .dot { background: var(--ok-bar); }
.checks .bad .dot { background: var(--bad-bar); }
.checks .label { font-weight: 600; font-size: 13px; color: var(--muted); }
.checks .value { font-size: 14px; overflow-wrap: anywhere; }
.checks .bad .value { color: var(--bad); }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.dash-head .h2 { margin: 0 0 2px; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head .h3 { margin: 0; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.mix-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 8px 0; }
.mix-row + .mix-row { border-top: 1px solid var(--line); }
.mix-row .bar { grid-column: 1 / -1; }
.empty-note { color: var(--faint); padding: 8px 0; }

/* ---------- Errors (debug only) ---------- */
.debug {
  margin-top: 24px; padding: 16px; direction: ltr; text-align: left;
  white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 var(--mono);
  background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--muted);
}

/* ---------- Auth pages ---------- */
.auth-page { background: var(--bg); }
.auth-wrap {
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 24px 16px max(24px, env(safe-area-inset-bottom));
}
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand .mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px;
  background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 18px;
}
.auth-brand .word { display: flex; flex-direction: column; font-weight: 700; font-size: 18px; line-height: 1.25; }
.auth-brand small { color: var(--faint); font-weight: 500; font-size: 12px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px; }
.auth-card .tabs { display: flex; width: 100%; }
.auth-card .tabs a { flex: 1; text-align: center; }

/* ---------- Products ---------- */
.thumb-cell { width: 56px; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; border: 1px solid var(--line); }
.image-panel { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.product-photo { width: 200px; max-width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); }
.product-photo.empty { display: grid; place-items: center; background: var(--surface-2); color: var(--faint); border-style: dashed; }
.image-actions { display: grid; gap: 12px; flex: 1 1 260px; }
input.qty { width: 76px; padding: 5px 8px; font-weight: 600; text-align: center; }

/* ---------- Documents ---------- */
.doc-meta { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-bottom: 16px; }
.doc-meta .wide { flex-basis: 100%; }
.doc-meta .faint { margin-inline-end: 4px; }
.scan-box { font-family: var(--mono); font-size: 16px; line-height: 1.6; }
.danger-zone { margin-top: 20px; border-color: var(--bad-line); }
.danger-zone summary { cursor: pointer; font-weight: 600; color: var(--bad); }
.danger-zone[open] summary { margin-bottom: 10px; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .pos { grid-template-columns: 1fr; } }
.pos-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.pos-head .h2 { margin: 0; }
.scan-bar { display: flex; gap: 8px; }
.scan-bar input { flex: 1; font-size: 20px; padding: 10px 14px; font-family: var(--mono); }
.pos-msg { min-height: 1.6em; margin: 8px 0; font-weight: 600; }
.pos-msg.ok { color: var(--ok); }
.pos-msg.bad { color: var(--bad); }
.pos-cart td { vertical-align: middle; }
.pos-cart .btn.tiny { min-width: 28px; padding: 0 6px; }
.pos-side { position: sticky; top: calc(var(--top-h) + 16px); display: flex; flex-direction: column; gap: 12px; }
.pos-side > * { min-width: 0; }
.customer-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.customer-row input { width: 100%; min-width: 0; }
#cust-phone { font-family: var(--mono); }
.pos-total {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  margin: -20px -20px 4px; padding: 18px 16px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0;
}
.pos-total strong { font-size: 42px; font-weight: 700; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; }
.quick-cash { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quick-cash .btn { min-width: 0; padding-inline: 4px; }
.pos-change { margin: 0; font-size: 16px; }
.pos-change strong { font-size: 18px; }
.pos-sell { min-height: 48px; font-size: 17px; }
.pos-done { border: 1px solid var(--ok-line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--ok-soft); color: var(--ok); }
.pos-done p { margin: 0 0 4px; }
.print-frame { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }
.pos-discount, .pos-pay { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px 10px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.pos-discount legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.pos-pay { display: block; }
.pos-pay summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
.discount-custom { display: flex; gap: 6px; }
.discount-custom input { flex: 1; min-width: 0; }
.discount-custom select { width: auto; }
.pay-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 6px; align-items: center; margin-top: 8px; }
.pay-row .pay-ref { grid-column: 2 / -1; font-size: 12.5px; }
.hold-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hold-buttons .btn { padding-inline: 6px; }
#held-count:empty { display: none; }
.offline-bar { border: 1px solid var(--bad-line); background: var(--bad-soft); color: var(--bad); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 10px; }
.offline-bar p { margin: 4px 0; }
.offline-bar ul { margin: 4px 0; padding-inline-start: 18px; }
.offline-bar li { margin-bottom: 6px; }
.ret-box { margin-top: 14px; border: 1px dashed var(--info-line); background: var(--info-soft); border-radius: var(--radius-sm); padding: 8px 12px; }
.ret-box .h3 { margin: 4px 0 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.exchange-line { font-weight: 600; color: var(--info); }
.ex-group { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 10px; }

/* Dialogs */
dialog.panel { padding: 20px; color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(17, 24, 39, .45); }
.held-dialog { width: min(520px, calc(100vw - 32px)); }
.held-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.held-list li { display: flex; gap: 8px; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.held-list .who { display: flex; flex-direction: column; }
.search-dialog { width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.search-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.search-head .h3 { margin: 0; }
.search-head .tabs { margin: 0; }
.search-dialog .table td.here { background: var(--primary-soft); font-weight: 700; }

/* ---------- Z report & reports ---------- */
.z h3 { font-size: 13px; font-weight: 700; margin: 16px 0 6px; color: var(--faint); }
.z h3:first-child { margin-top: 0; }
.z dl { margin: 0; }
.z dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.z dl > div:last-child { border-bottom: 0; }
.z dt { color: var(--muted); }
.z dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }
.z .strong dt, .z .strong dd { font-weight: 700; color: var(--text); }
.z .diff dd { color: var(--bad); }
.close-grid, .report-grid { align-items: start; }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .3s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Print (reports) ---------- */
@media print {
  .sidebar, .topbar, .sb-backdrop, .no-print { display: none !important; }
  .has-sidebar .shell { margin: 0 !important; }
  .main { padding: 0; max-width: none; }
  body { background: #fff !important; color: #000 !important; }
  .panel, .stat, .table-wrap { box-shadow: none !important; border-color: #bbb !important; background: #fff !important; }
}
.dash-sub { margin: 0; }
.scan-bar input::placeholder { font-family: var(--font); font-size: 15px; }
html, body { overflow-x: clip; }
/* Always keep room for the scrollbar so pages do not shift when one page is taller (e.g. POS). */
html { overflow-y: auto; scrollbar-gutter: stable; }

/* ---------- loyalty ---------- */
.reward-row { border-top: 1px solid var(--line); padding: 12px 0; }
.reward-row:first-of-type { border-top: 0; }
.reward-row.inactive .reward-head > :not(form) { opacity: .55; }
.reward-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.reward-head form { margin-inline-start: auto; }
.reward-row details summary { cursor: pointer; color: var(--muted); margin-top: 6px; }
.reward-row .reward-form { margin-top: 10px; }
.loyalty-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.loyalty-box[hidden] { display: none; }
.loyalty-box .points { font-weight: 700; font-variant-numeric: tabular-nums; }
.loyalty-box select { flex: 1 1 200px; min-width: 0; }
