/* =====================================================================
   Cashier POS - design system
   Built for shop hardware: modest screens, sometimes a touch monitor,
   often bright fluorescent light. Hence large hit targets, high contrast,
   and no thin grey-on-grey text.
   Direction is driven by [dir] on <html>; all spacing uses logical
   properties so Arabic mirrors without a second stylesheet.
   ===================================================================== */

/* Native controls - checkboxes, dropdowns, date pickers, scrollbars - follow
   this, not the operating system. Without it a till set to light shows dark
   checkboxes on a machine whose OS is in dark mode. */
:root { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

:root {
  --bg:            #f4f6f9;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-3:     #eef2f7;
  --border:        #dbe2ea;
  --border-strong: #c3cedb;
  --text:          #12212f;
  --text-2:        #56687d;
  --text-3:        #8496a8;

  --brand:         #1668d6;
  --brand-hover:   #1157b4;
  --brand-soft:    #e8f1fd;
  --success:       #0f8a4d;
  --success-soft:  #e6f6ed;
  --warn:          #b8690a;
  --warn-soft:     #fdf3e3;
  --danger:        #c8352c;
  --danger-soft:   #fdecea;
  --info:          #6b3fd4;
  --info-soft:     #f0ebfd;

  --radius:   10px;
  --radius-s: 7px;
  --radius-l: 16px;
  --shadow-1: 0 1px 2px rgba(16,32,48,.06), 0 1px 3px rgba(16,32,48,.05);
  --shadow-2: 0 4px 12px rgba(16,32,48,.09), 0 2px 4px rgba(16,32,48,.05);
  --shadow-3: 0 16px 40px rgba(16,32,48,.16);

  --sidebar-w: 236px;
  --header-h:  58px;

  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-ar: "Noto Naskh Arabic", "Segoe UI", "Tahoma", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg:            #0e151d;
  --surface:       #161f2a;
  --surface-2:     #1c2733;
  --surface-3:     #24313f;
  --border:        #2a3745;
  --border-strong: #3a4a5c;
  --text:          #e8eef5;
  --text-2:        #9fb0c2;
  --text-3:        #708095;

  --brand:         #4d9bff;
  --brand-hover:   #6faeff;
  --brand-soft:    #16283f;
  --success:       #3dc47e;
  --success-soft:  #122c1f;
  --warn:          #e0a54a;
  --warn-soft:     #2e2314;
  --danger:        #f26d63;
  --danger-soft:   #331917;
  --info:          #a184f0;
  --info-soft:     #221b3a;

  --shadow-1: 0 1px 2px rgba(0,0,0,.3);
  --shadow-2: 0 4px 12px rgba(0,0,0,.4);
  --shadow-3: 0 16px 40px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body.rtl { font-family: var(--font-ar); }

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: .98rem; }
p  { margin: 0 0 .6em; }
a  { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ------------------------------------------------------------- layout */
#app { height: 100vh; display: flex; flex-direction: column; }

.shell { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding-inline: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--info));
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.sidebar-brand .shop-name {
  font-weight: 680; font-size: .95rem; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-nav { padding: 10px 8px; flex: 1; }
.nav-group-label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-3);
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; margin-bottom: 2px;
  border-radius: var(--radius-s);
  color: var(--text-2); font-weight: 550; font-size: .9rem;
  cursor: pointer; user-select: none;
  border: none; background: none; width: 100%;
  text-align: start; font-family: inherit;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 640; }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge { margin-inline-start: auto; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  height: var(--header-h); flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding-inline: 18px;
}
.topbar h1 { font-size: 1.06rem; }
.topbar-spacer { flex: 1; }

.content { flex: 1; overflow-y: auto; padding: 20px; }
.content.flush { padding: 0; }

/* ------------------------------------------------------------ surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-head h2, .card-head h3 { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1180px) { .grid.cols-4 { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 900px)  { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }

/* --------------------------------------------------------------- stats */
.stat { padding: 15px 16px; }
.stat .label {
  font-size: .74rem; font-weight: 640; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-3); margin-bottom: 7px;
}
.stat .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .value.sm { font-size: 1.25rem; }
.stat .sub { font-size: .8rem; color: var(--text-2); margin-top: 5px; }
.stat.accent-brand   { border-inline-start: 3px solid var(--brand); }
.stat.accent-success { border-inline-start: 3px solid var(--success); }
.stat.accent-warn    { border-inline-start: 3px solid var(--warn); }
.stat.accent-danger  { border-inline-start: 3px solid var(--danger); }

.delta { font-weight: 640; font-size: .8rem; }
.delta.up   { color: var(--success); }
.delta.down { color: var(--danger); }

/* -------------------------------------------------------------- inputs */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field > label { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: .78rem; color: var(--text-3); }

/* `input` with no type attribute is still a text box, and an attribute
   selector would not match it - so exclude the non-text types instead. */
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):not([type=color]):not([type=submit]):not([type=button]),
select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: .92rem;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input:disabled, select:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
input.big { padding: 13px 15px; font-size: 1.05rem; }
input.mono, .mono { font-family: var(--mono); }
textarea { resize: vertical; min-height: 70px; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.checkbox { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.checkbox input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--brand); cursor: pointer; flex-shrink: 0; }
.checkbox .text { flex: 1; }
.checkbox .text strong { display: block; font-weight: 600; font-size: .9rem; }
.checkbox .text span { font-size: .8rem; color: var(--text-2); }

/* toggle switch for feature flags */
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border-strong); border-radius: 12px; transition: background .16s;
}
.switch .track::before {
  content: ""; position: absolute; height: 18px; width: 18px;
  inset-inline-start: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform .16s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::before { transform: translateX(18px); }
[dir=rtl] .switch input:checked + .track::before { transform: translateX(-18px); }
.switch input:disabled + .track { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font-family: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger  { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost   { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn.big { padding: 14px 22px; font-size: 1.02rem; }
.btn.xl  { padding: 18px 24px; font-size: 1.15rem; font-weight: 700; }
.btn.sm  { padding: 5px 10px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn .icon { width: 16px; height: 16px; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-inline-start: -1px; }
.btn-group .btn:first-child { border-start-start-radius: var(--radius-s); border-end-start-radius: var(--radius-s); margin-inline-start: 0; }
.btn-group .btn:last-child  { border-start-end-radius: var(--radius-s); border-end-end-radius: var(--radius-s); }
.btn-group .btn.active { background: var(--brand); border-color: var(--brand); color: #fff; z-index: 1; }

/* Filter toolbars. Inputs default to width:100%, which makes a row of them
   stretch into full-width bars; here they size to their content instead. */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 14px;
}
.filter-bar input, .filter-bar select { width: auto; min-width: 148px; max-width: 260px; }
.filter-bar input[type=search] { min-width: 210px; }
.filter-bar input[type=date] { min-width: 152px; }

/* -------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: .74rem; font-weight: 650; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.badge.brand   { background: var(--brand-soft); color: var(--brand); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warn    { background: var(--warn-soft); color: var(--warn); }
.badge.danger  { background: var(--danger-soft); color: var(--danger); }
.badge.info    { background: var(--info-soft); color: var(--info); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* -------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  text-align: start; font-weight: 640; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .045em; color: var(--text-3);
  padding: 10px 13px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
tbody td { padding: 10px 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.empty { padding: 44px 20px; text-align: center; color: var(--text-3); }
.empty .icon { width: 40px; height: 40px; margin-bottom: 10px; opacity: .5; }

/* -------------------------------------------------------------- modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10,20,30,.45);
  backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .12s ease;
}
.modal {
  background: var(--surface); border-radius: var(--radius-l);
  box-shadow: var(--shadow-3);
  width: min(560px, 100%); max-height: 88vh;
  display: flex; flex-direction: column;
  animation: pop .16s cubic-bezier(.2,.9,.3,1.1);
}
.modal.wide  { width: min(880px, 100%); }
.modal.large { width: min(1120px, 100%); }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.modal-head h2 { flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  background: var(--surface-2);
  border-end-start-radius: var(--radius-l); border-end-end-radius: var(--radius-l);
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop  { from { opacity: 0; transform: scale(.97) translateY(6px); } }

/* --------------------------------------------------------------- toast */
.toasts {
  position: fixed; z-index: 200; bottom: 20px; inset-inline-end: 20px;
  display: flex; flex-direction: column; gap: 9px; max-width: 380px;
}
.toast {
  padding: 12px 15px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  border-inline-start: 3px solid var(--brand);
  box-shadow: var(--shadow-2);
  font-size: .88rem; animation: slide .18s ease;
}
.toast.success { border-inline-start-color: var(--success); }
.toast.error   { border-inline-start-color: var(--danger); }
.toast.warn    { border-inline-start-color: var(--warn); }
.toast strong  { display: block; margin-bottom: 2px; }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------ POS view */
.pos {
  display: grid;
  grid-template-columns: 1fr 400px;
  height: 100%; min-height: 0;
}
body.rtl .pos { grid-template-columns: 400px 1fr; }
body.rtl .pos .pos-left  { order: 2; }
body.rtl .pos .pos-right { order: 1; }

.pos-left { display: flex; flex-direction: column; min-height: 0; padding: 16px; gap: 12px; }
.pos-scan { display: flex; gap: 10px; }
.pos-scan input { font-size: 1.05rem; padding: 13px 15px; }

/* The phone basket button: quiet until a phone has actually sent something. */
.pos-phone { position: relative; }
.pos-phone.waiting { border-color: var(--brand); color: var(--brand); }
.pos-phone-count:empty { display: none; }
.pos-phone-count {
  position: absolute; inset-block-start: -6px; inset-inline-end: -6px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--brand); color: #fff;
  font-size: .68rem; line-height: 17px; text-align: center;
  direction: ltr; unicode-bidi: isolate;
}

.pos-results { flex: 1; overflow-y: auto; min-height: 0; }
.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px;
}
.product-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px;
  cursor: pointer; text-align: start;
  display: flex; flex-direction: column; gap: 5px;
  transition: border-color .12s, box-shadow .12s, transform .06s;
  font-family: inherit; color: inherit;
}
.product-tile:hover { border-color: var(--brand); box-shadow: var(--shadow-2); }
.product-tile:active { transform: scale(.985); }
.product-tile .pname { font-weight: 620; font-size: .88rem; line-height: 1.3; }
.product-tile .pprice { font-weight: 700; color: var(--brand); font-size: 1rem; }
.product-tile .pmeta { font-size: .74rem; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.product-tile.out { opacity: .55; }

.pos-right {
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
body.rtl .pos-right { border-inline-start: none; border-inline-end: 1px solid var(--border); }
.basket { flex: 1; overflow-y: auto; min-height: 0; }
.basket-line {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
}
.basket-line .bname { font-weight: 600; font-size: .89rem; }
.basket-line .bsub { font-size: .78rem; color: var(--text-3); }
.basket-line .btotal { font-weight: 700; font-variant-numeric: tabular-nums; }
.qty-stepper { display: inline-flex; align-items: center; gap: 0; }
.qty-stepper button {
  width: 28px; height: 28px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer;
  font-size: 1rem; font-weight: 700; display: grid; place-items: center;
}
.qty-stepper button:first-child { border-start-start-radius: 6px; border-end-start-radius: 6px; }
.qty-stepper button:last-child  { border-start-end-radius: 6px; border-end-end-radius: 6px; }
.qty-stepper input {
  width: 52px; height: 28px; text-align: center; padding: 0;
  border-radius: 0; border-inline: none; font-variant-numeric: tabular-nums;
}
.pos-totals { border-top: 1px solid var(--border); padding: 14px; background: var(--surface-2); }
.total-line { display: flex; justify-content: space-between; padding: 3px 0; font-size: .9rem; color: var(--text-2); }
.total-line.grand {
  font-size: 1.5rem; font-weight: 750; color: var(--text);
  padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------- till keyboard shortcuts */
.key-legend {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-top: 10px; margin-top: auto;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.key-hint {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px; border-radius: var(--radius-s);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-family: inherit; font-size: .78rem; font-weight: 550;
  cursor: pointer; white-space: nowrap;
}
.key-hint:hover { background: var(--surface-3); color: var(--text); }
.key-hint.primary { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.key-hint .kbd { border-bottom-width: 2px; }

/* The highlighted basket line, so the arrow keys have something to point at. */
.basket-line.selected {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}
[dir=rtl] .basket-line.selected { box-shadow: inset -3px 0 0 var(--brand); }
.basket-line { cursor: pointer; }

/* Keys shown inside a button sit quietly beside the label. */
.btn .kbd { margin-inline-start: auto; opacity: .65; font-size: .7rem; padding: 0 5px; }
.btn.primary .kbd, .btn.xl .kbd {
  border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.14); color: #fff;
}

/* -------------------------------------------------- location finder */
.aisle-map { display: flex; flex-wrap: wrap; gap: 8px; }
.aisle-chip {
  padding: 9px 14px; border-radius: var(--radius-s);
  background: var(--surface-3); border: 1px solid var(--border);
  cursor: pointer; font-weight: 600; font-size: .86rem;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 74px; font-family: inherit; color: inherit;
}
.aisle-chip:hover  { border-color: var(--brand); }
.aisle-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.aisle-chip small { font-size: .7rem; opacity: .75; font-weight: 500; }

.location-hit {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.location-hit .where {
  font-family: var(--mono); font-size: 1.02rem; font-weight: 700;
  color: var(--brand); background: var(--brand-soft);
  padding: 9px 13px; border-radius: var(--radius-s); white-space: nowrap;
}
.location-parts { display: flex; gap: 7px; flex-wrap: wrap; }
.location-part {
  background: var(--surface-3); border-radius: 6px; padding: 4px 9px; font-size: .8rem;
}
.location-part b { font-weight: 700; margin-inline-start: 4px; }

/* --------------------------------------------------------------- misc */
.progress { height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; border-radius: 4px; transition: width .3s; background: var(--brand); }
.progress.warn > div   { background: var(--warn); }
.progress.danger > div { background: var(--danger); }

.chart { width: 100%; height: 190px; display: block; }
.chart .bar { fill: var(--brand); transition: fill .12s; }
.chart .bar:hover { fill: var(--brand-hover); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .glabel { fill: var(--text-3); font-size: 10px; }

.kbd {
  display: inline-block; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  background: var(--surface-2); font-family: var(--mono); font-size: .76rem; color: var(--text-2);
}
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.muted { color: var(--text-2); }
.dim   { color: var(--text-3); }
.small { font-size: .82rem; }
.strong{ font-weight: 650; }
.center{ text-align: center; }
.tabular { font-variant-numeric: tabular-nums; }

/* Numbers keep their own direction inside Arabic text. Without this a "-3"
   renders as "3-", because the minus sign is neutral and takes the direction
   of the paragraph around it. */
.tabular, .num, .m-figure .v, .m-timer, .kbd, .mono,
.stat .value, .total-line span:last-child, .m-qty input {
  direction: ltr;
  unicode-bidi: isolate;
}
[dir=rtl] .num, [dir=rtl] td.num { text-align: end; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------ auth / setup */
.auth-page {
  height: 100vh; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--bg) 0%, var(--surface-3) 100%);
  padding: 20px; overflow-y: auto;
}
.auth-card {
  width: min(430px, 100%); background: var(--surface);
  border-radius: var(--radius-l); box-shadow: var(--shadow-3);
  padding: 34px; border: 1px solid var(--border);
}
.auth-card.wide { width: min(660px, 100%); }
.auth-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--info));
  display: grid; place-items: center; color: #fff;
  font-weight: 800; font-size: 21px; margin: 0 auto 16px;
}
.mode-option {
  display: flex; gap: 12px; padding: 14px;
  border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; margin-bottom: 9px; transition: border-color .12s, background .12s;
}
.mode-option:hover { border-color: var(--border-strong); }
.mode-option.selected { border-color: var(--brand); background: var(--brand-soft); }
.mode-option input { margin-top: 3px; accent-color: var(--brand); flex-shrink: 0; }
.mode-option strong { display: block; font-size: .93rem; margin-bottom: 3px; }
.mode-option span { font-size: .82rem; color: var(--text-2); line-height: 1.45; }

/* ------------------------------------------------------------ receipt */
@media print {
  body { overflow: visible; background: #fff; }
  .sidebar, .topbar, .no-print, .toasts, .modal-foot { display: none !important; }
  .modal-backdrop { position: static; background: none; padding: 0; display: block; }
  .modal { box-shadow: none; max-height: none; width: 100%; border-radius: 0; }
  .content { overflow: visible; padding: 0; }
}
.receipt {
  font-family: var(--mono); font-size: 12px; line-height: 1.45;
  max-width: 320px; margin: 0 auto; color: #000; background: #fff; padding: 14px;
}
.receipt .r-center { text-align: center; }
.receipt .r-line { border-top: 1px dashed #999; margin: 7px 0; }
.receipt table { font-size: 11.5px; }
.receipt td { padding: 2px 0; border: none; }
.receipt .r-total { font-size: 15px; font-weight: 700; }

/* --------------------------------------------- till keyboard shortcuts */
.key-legend {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-top: 10px; margin-top: auto;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.key-hint {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px; border-radius: var(--radius-s);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-family: inherit; font-size: .78rem; font-weight: 550;
  cursor: pointer; white-space: nowrap;
}
.key-hint:hover { background: var(--surface-3); color: var(--text); }
.key-hint.primary { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.key-hint .kbd { border-bottom-width: 2px; }

/* The highlighted basket line, so the arrow keys have something to point at. */
.basket-line.selected {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}
[dir=rtl] .basket-line.selected { box-shadow: inset -3px 0 0 var(--brand); }
.basket-line { cursor: pointer; }

/* Keys shown inside a button sit quietly beside the label. */
.btn .kbd { margin-inline-start: auto; opacity: .65; font-size: .7rem; padding: 0 5px; }
.btn.primary .kbd, .btn.xl .kbd {
  border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.14); color: #fff;
}

/* -------------------------------------------------- location finder */
.aisle-map { display: flex; flex-wrap: wrap; gap: 8px; }
.aisle-chip {
  padding: 9px 14px; border-radius: var(--radius-s);
  background: var(--surface-3); border: 1px solid var(--border);
  cursor: pointer; font-weight: 600; font-size: .86rem;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 74px; font-family: inherit; color: inherit;
}
.aisle-chip:hover  { border-color: var(--brand); }
.aisle-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.aisle-chip small { font-size: .7rem; opacity: .75; font-weight: 500; }

.location-hit {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.location-hit .where {
  font-family: var(--mono); font-size: 1.02rem; font-weight: 700;
  color: var(--brand); background: var(--brand-soft);
  padding: 9px 13px; border-radius: var(--radius-s); white-space: nowrap;
}
.location-parts { display: flex; gap: 7px; flex-wrap: wrap; }
.location-part {
  background: var(--surface-3); border-radius: 6px; padding: 4px 9px; font-size: .8rem;
}
.location-part b { font-weight: 700; margin-inline-start: 4px; }

/* --------------------------------------------------------------- misc */
.progress { height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; border-radius: 4px; transition: width .3s; background: var(--brand); }
.progress.warn > div   { background: var(--warn); }
.progress.danger > div { background: var(--danger); }

.chart { width: 100%; height: 190px; display: block; }
.chart .bar { fill: var(--brand); transition: fill .12s; }
.chart .bar:hover { fill: var(--brand-hover); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .glabel { fill: var(--text-3); font-size: 10px; }

.kbd {
  display: inline-block; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  background: var(--surface-2); font-family: var(--mono); font-size: .76rem; color: var(--text-2);
}
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.muted { color: var(--text-2); }
.dim   { color: var(--text-3); }
.small { font-size: .82rem; }
.strong{ font-weight: 650; }
.center{ text-align: center; }
.tabular { font-variant-numeric: tabular-nums; }

/* Numbers keep their own direction inside Arabic text. Without this a "-3"
   renders as "3-", because the minus sign is neutral and takes the direction
   of the paragraph around it. */
.tabular, .num, .m-figure .v, .m-timer, .kbd, .mono,
.stat .value, .total-line span:last-child, .m-qty input {
  direction: ltr;
  unicode-bidi: isolate;
}
[dir=rtl] .num, [dir=rtl] td.num { text-align: end; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------ auth / setup */
.auth-page {
  height: 100vh; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--bg) 0%, var(--surface-3) 100%);
  padding: 20px; overflow-y: auto;
}
.auth-card {
  width: min(430px, 100%); background: var(--surface);
  border-radius: var(--radius-l); box-shadow: var(--shadow-3);
  padding: 34px; border: 1px solid var(--border);
}
.auth-card.wide { width: min(660px, 100%); }
.auth-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--info));
  display: grid; place-items: center; color: #fff;
  font-weight: 800; font-size: 21px; margin: 0 auto 16px;
}
.mode-option {
  display: flex; gap: 12px; padding: 14px;
  border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; margin-bottom: 9px; transition: border-color .12s, background .12s;
}
.mode-option:hover { border-color: var(--border-strong); }
.mode-option.selected { border-color: var(--brand); background: var(--brand-soft); }
.mode-option input { margin-top: 3px; accent-color: var(--brand); flex-shrink: 0; }
.mode-option strong { display: block; font-size: .93rem; margin-bottom: 3px; }
.mode-option span { font-size: .82rem; color: var(--text-2); line-height: 1.45; }

/* ------------------------------------------------------------ receipt */
@media print {
  body { overflow: visible; background: #fff; }
  .sidebar, .topbar, .no-print, .toasts, .modal-foot { display: none !important; }
  .modal-backdrop { position: static; background: none; padding: 0; display: block; }
  .modal { box-shadow: none; max-height: none; width: 100%; border-radius: 0; }
  .content { overflow: visible; padding: 0; }
}
.receipt {
  font-family: var(--mono); font-size: 12px; line-height: 1.45;
  max-width: 320px; margin: 0 auto; color: #000; background: #fff; padding: 14px;
}
.receipt .r-center { text-align: center; }
.receipt .r-line { border-top: 1px dashed #999; margin: 7px 0; }
.receipt table { font-size: 11.5px; }
.receipt td { padding: 2px 0; border: none; }
.receipt .r-total { font-size: 15px; font-weight: 700; }

/* -------------------------------------------------------- price labels */
/* Sizes are in millimetres so what is on screen is what comes out of the
   printer. Labels print black on white whatever theme the till is using -
   a sticker is ink on paper, not a screen. */
.sticker-preview { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.sticker-sheet {
  display: grid;
  justify-content: center;
  align-content: start;
  background: #fff;
  box-shadow: var(--shadow-2);
  border-radius: 4px;
}

.sticker {
  border: 1px dashed #d0d0d0;
  border-radius: 2px;
  padding: 1.4mm 1.6mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6mm;
  overflow: hidden;
  background: #fff;
  color: #000;
  text-align: center;
  box-sizing: border-box;
}
.sticker-shop    { font-size: 6.5pt; font-weight: 600; color: #444; line-height: 1.1; }
.sticker-name    { font-size: 8pt; font-weight: 700; line-height: 1.15;
                 display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sticker-name-ar { font-size: 7.5pt; font-weight: 600; line-height: 1.15; }
.sticker-price   { font-size: 12pt; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.sticker-bars    { width: auto; max-width: 100%; height: auto; max-height: 40%; }
.sticker-nocode  { font-size: 6.5pt; color: #b00; border: 1px dashed #b00; padding: 1mm 2mm; border-radius: 2px; }

/* While printing labels, everything except the sheets is taken off the page. */
@media print {
  body.printing-labels .sidebar,
  body.printing-labels .topbar,
  body.printing-labels .no-print,
  body.printing-labels .toasts { display: none !important; }
  body.printing-labels .content { padding: 0; overflow: visible; }
  body.printing-labels .sticker-preview { display: block; }
  body.printing-labels .sticker-sheet {
    box-shadow: none; border-radius: 0; margin: 0;
    break-after: page; page-break-after: always;
  }
  body.printing-labels .sticker-sheet:last-child { break-after: auto; page-break-after: auto; }
  /* Dashed cutting guides are for the screen; on paper they waste ink and
     confuse a die-cut sheet. */
  body.printing-labels .sticker { border-color: transparent; }
  body.printing-labels .sticker,
  body.printing-labels .sticker-sheet { background: #fff !important; color: #000 !important; }
}

/* ---------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; bottom: 0; z-index: 50;
             transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-3); }
  [dir=rtl] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .pos, body.rtl .pos { grid-template-columns: 1fr; }
  .pos-right { border: none; border-top: 1px solid var(--border); max-height: 46vh; }
}
@media (min-width: 1001px) { .menu-toggle { display: none; } }
