/* Tocchetta design system (v0.17.0) — aliases over tokens.css, base, components. Logical properties everywhere so RTL/LTR both work. */
:root {
  /* Tocchetta brand: values come from tokens.css (--tq-*, light + dark). Everything below is a semantic alias so pages never hard-code a brand colour.
     Fill buttons carry charcoal text on orange (white on #DF8537 is only 2.78:1); white text is reserved for --primary-strong. */
  --primary: var(--tq-primary); --on-primary: var(--tq-on-primary); --primary-hover: var(--tq-primary-hover);
  --primary-strong: var(--tq-primary-strong); --on-primary-strong: var(--tq-on-primary-strong);
  --primary-text: var(--tq-accent);              /* links, outline buttons, accents drawn on a surface (5.72:1 light / 7+:1 dark) */
  --primary-soft: var(--tq-primary-100); --primary-soft-hover: var(--tq-primary-200); --primary-tint: var(--tq-primary-50); --on-soft: var(--tq-primary-900);
  --amber: var(--tq-warning); --on-amber: var(--tq-on-warning);
  --ok: var(--tq-success); --on-ok: var(--tq-on-success); --ok-bg: var(--tq-success-bg); --ok-ink: var(--tq-success-text);
  --warn: var(--tq-warning); --warn-bg: var(--tq-warning-bg); --warn-ink: var(--tq-warning-text);
  --bad: var(--tq-danger); --on-bad: var(--tq-on-danger); --bad-bg: var(--tq-danger-bg); --bad-ink: var(--tq-danger-text);
  --info: var(--tq-info); --info-bg: var(--tq-info-bg); --info-ink: var(--tq-info-text);
  --ink: var(--tq-ink); --ink-deep: var(--tq-ink-deep); --muted: var(--tq-muted); --line: var(--tq-border);
  --bg: var(--tq-background); --surface: var(--tq-surface); --surface-2: var(--tq-surface-2);
  --r-sm: 12px; --r-md: 16px; --r-lg: 24px; --r-pill: 999px;
  --sh-1: 0 8px 24px rgba(32, 31, 26, .08); --sh-2: 0 16px 40px rgba(32, 31, 26, .12);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --font: 'Outfit', 'Tajawal', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --font-display: 'Alexandria', 'Outfit', 'Tajawal', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --focus: 0 0 0 3px rgba(157, 83, 0, .4);
  --grad-brand: linear-gradient(135deg, #F39648 0%, #DF8537 100%);
}
html[dir="rtl"] { --font: 'Tajawal', 'Outfit', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.55; font-size: 16px; font-variant-numeric: tabular-nums lining-nums; min-height: 100vh; min-height: 100dvh; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; } h2 { font-size: 1.125rem; font-weight: 700; } h3 { font-size: 1rem; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-text); }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .xs { font-size: .78rem; }
.row { display: flex; align-items: center; gap: var(--s3); } .grow { flex: 1 1 auto; min-width: 0; } .col { display: flex; flex-direction: column; gap: var(--s3); }
.num { font-weight: 700; font-variant-numeric: tabular-nums lining-nums; direction: ltr; unicode-bidi: isolate; letter-spacing: .01em; }

/* Tocchetta chrome: surface bar, logo + shop name (no coloured card, keeps the logo clear space), tidy pill actions. */
.topbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px var(--s3);
  padding: 12px var(--s4);
  background: var(--surface);
  color: var(--ink);
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 8px 28px rgba(32, 31, 26, .07);
}
.topbar .brand {
  display: flex; align-items: center; gap: var(--s2);
  font-weight: 700;
  min-width: 0; flex: 0 1 auto;
  color: var(--ink);
  padding: 2px 4px;
}
.topbar .brand img { width: 32px; height: 32px; border-radius: 10px; }
.topbar .brand > div { min-width: 0; overflow-wrap: anywhere; }
.topbar .sub { font-size: .8rem; opacity: 1; font-weight: 500; color: var(--muted); }
.topbar .btn.ghost, .topbar .btn.ghost.dark {
  background: var(--primary-soft);
  color: var(--on-soft);
  border: 0;
  border-radius: var(--r-pill);
  min-height: 36px;
  padding: 0 14px;
  font-weight: 700;
  box-shadow: none;
}
@media (hover: hover) and (pointer: fine) {
  .topbar .btn.ghost:hover, .topbar .btn.ghost.dark:hover { background: var(--primary-soft-hover); }
}

/* Disable iOS double-tap zoom on tappable controls; pinch-zoom stays available. */
button, a, .btn, [role="button"], .chip-btn, .pos-item, .tile, .qty-btn, .seg button,
.nav-items a, .dash-card, .order-head, summary, input[type="button"], input[type="submit"] {
  touch-action: manipulation;
}
input, select, textarea { font-size: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4); border: 2px solid transparent; border-radius: var(--r-pill); background: var(--primary); color: var(--on-primary); font-weight: 700; cursor: pointer; transition: transform .08s, background .15s, opacity .15s, box-shadow .15s, border-color .15s, color .15s; -webkit-tap-highlight-color: transparent; text-decoration: none; box-shadow: 0 8px 18px rgba(157, 83, 0, .28); }
.btn:active { transform: scale(.97); } @media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--primary-hover); } }
.btn[disabled], .btn[aria-disabled=true] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.secondary { background: var(--surface); color: var(--primary-text); border-color: var(--primary-text); box-shadow: none; } @media (hover: hover) and (pointer: fine) { .btn.secondary:hover { background: var(--primary-soft); color: var(--on-soft); } }
.btn.ok { background: var(--primary); color: var(--on-primary); border-color: transparent; box-shadow: 0 8px 18px rgba(157, 83, 0, .28); } @media (hover: hover) and (pointer: fine) { .btn.ok:hover { background: var(--primary-hover); } }
.btn.warn { background: var(--amber); color: var(--on-amber); box-shadow: 0 8px 18px rgba(223, 133, 55, .28); } @media (hover: hover) and (pointer: fine) { .btn.warn:hover { filter: brightness(.94); } }
.btn.danger { background: var(--bad); color: var(--on-bad); border-color: transparent; box-shadow: 0 8px 18px rgba(192, 53, 43, .22); } @media (hover: hover) and (pointer: fine) { .btn.danger:hover { filter: brightness(.92); } }
.btn.ghost { background: transparent; color: inherit; border-color: transparent; box-shadow: none; min-height: 36px; padding: 0 var(--s3); font-weight: 500; }
.btn.ghost.dark { color: var(--on-soft); background: var(--primary-soft); }
.btn.lg { min-height: 56px; font-size: 1.1rem; border-radius: var(--r-pill); } .btn.sm { min-height: 36px; padding: 0 var(--s3); font-size: .875rem; } .btn.block { width: 100%; }
.btn .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--surface); border: 0; border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: var(--s4); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--r-pill); font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 0; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok-ink); } .chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.bad { background: var(--bad-bg); color: var(--bad-ink); } .chip.info { background: var(--primary-soft); color: var(--on-soft); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; padding: 4px 12px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink); font-weight: 700; box-shadow: 0 2px 8px rgba(32, 31, 26, .05); }
.conn[data-s=live] .dot { background: var(--ok); } .conn[data-s=reconnecting] .dot, .conn[data-s=connecting] .dot { background: var(--amber); animation: pulse 1s infinite; } .conn[data-s=offline] .dot, .conn[data-s=fatal] .dot { background: var(--bad); }
@keyframes pulse { 50% { opacity: .25; } }
.field { display: flex; flex-direction: column; gap: 6px; } .field label { font-weight: 700; font-size: .9rem; }
.input { min-height: 46px; padding: 0 var(--s3); border: 0; border-radius: var(--r-md); background: var(--surface-2); width: 100%; font-size: 16px; }
.input:focus { outline: none; background: var(--surface); box-shadow: var(--focus); } .input[aria-invalid=true] { box-shadow: 0 0 0 2px var(--bad); }
.field-error { color: var(--bad-ink); font-size: .85rem; min-height: 1.2em; }
.seg { display: inline-flex; background: var(--surface-2); border: 0; border-radius: var(--r-pill); padding: 4px; gap: 3px; }
.seg button { border: 0; background: transparent; min-height: 38px; padding: 0 var(--s4); border-radius: var(--r-pill); font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--on-soft); box-shadow: 0 4px 14px rgba(32, 31, 26, .08); }
.banner { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); font-size: .9rem; font-weight: 500; border-radius: 0; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); } .banner.bad { background: var(--bad-bg); color: var(--bad-ink); } .banner.info { background: var(--primary-soft); color: var(--on-soft); }
.empty { text-align: center; color: var(--muted); padding: var(--s6) var(--s4); border: 0; border-radius: var(--r-lg); background: var(--surface-2); }
.empty .big { font-size: 2.2rem; display: block; margin-bottom: var(--s2); }
.errbox { text-align: center; padding: var(--s6) var(--s4); } .errbox h2 { margin-bottom: var(--s2); } .errbox .big { font-size: 3rem; display: block; margin-bottom: var(--s3); }
.skeleton { background: linear-gradient(90deg, var(--primary-tint) 25%, var(--surface-2) 37%, var(--primary-tint) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-md); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 45;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -12px 40px rgba(32, 31, 26, .12);
  padding: var(--s5) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom));
}

.toasts { position: fixed; inset-inline: 0; bottom: var(--s4); display: flex; flex-direction: column; align-items: center; gap: var(--s2); z-index: 60; pointer-events: none; padding: 0 var(--s4); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r-md); box-shadow: var(--sh-2); font-weight: 500; max-width: 480px; animation: rise .2s ease-out; pointer-events: auto; } .toast.bad { background: var(--bad); color: var(--on-bad); } .toast.ok { background: var(--ok); color: var(--on-ok); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.switch { position: relative; width: 48px; height: 28px; flex: none; } .switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; background: var(--tq-border); border-radius: var(--r-pill); transition: background .15s; } .switch .track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: var(--sh-1); }
.switch input:checked + .track { background: var(--primary); } .switch input:checked + .track::after { transform: translateX(20px); } [dir=rtl] .switch input:checked + .track::after { transform: translateX(-20px); }
.switch input:disabled + .track { opacity: .45; } .switch input:focus-visible + .track { box-shadow: var(--focus); }

.status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--r-pill); font-weight: 700; font-size: 1rem; }
.status.preparing { background: var(--warn-bg); color: var(--warn-ink); } .status.ready { background: var(--ok-bg); color: var(--ok-ink); } .status.picked_up, .status.cancelled { background: var(--surface-2); color: var(--muted); }
.stepper { display: flex; align-items: center; justify-content: space-between; position: relative; padding: 0 var(--s2); }
.stepper .step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; font-size: .8rem; color: var(--muted); font-weight: 600; position: relative; z-index: 1; text-align: center; }
.stepper .step i { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-style: normal; color: var(--muted); font-size: .8rem; }
.stepper .step.done i { background: var(--primary); color: var(--on-primary); } .stepper .step.now i { background: var(--amber); color: var(--on-amber); box-shadow: 0 0 0 5px rgba(223,133,55,.3); } .stepper .step.now.ready i { background: var(--ok); color: var(--on-ok); box-shadow: 0 0 0 5px rgba(27,127,82,.25); } .stepper .step.now { color: var(--ink); }
.stepper::before { content: ''; position: absolute; top: 14px; inset-inline: 16%; height: 3px; background: var(--surface-2); z-index: 0; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; } }

/* Cheap motion + paint path for kiosk/WebView tablets and prefers-reduced-motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
html.lite { --sh-1: 0 0 0 transparent; --sh-2: 0 0 0 transparent; }
html.lite .btn, html.lite .btn.ok, html.lite .btn.warn, html.lite .btn.danger, html.lite .btn.secondary,
html.lite .card, html.lite .toast, html.lite .conn, html.lite .topbar,
html.lite .ocard, html.lite .switch .track::after { box-shadow: none; }
/* Never set background on `html.lite .btn` alone: that selector (0,2,1) beats `.btn.danger` / `.btn.secondary` and painted every WebView button the same medium teal. */
html.lite .btn, html.lite .btn.ok { background: var(--primary); color: var(--on-primary); border-color: transparent; transition: none; }
html.lite .btn.secondary { background: var(--surface); color: var(--primary-text); border-color: var(--primary-text); }
html.lite .btn.danger { background: var(--bad); color: var(--on-bad); border-color: transparent; }
html.lite .btn.warn { background: var(--amber); color: var(--on-amber); }
html.lite .btn.ghost { background: transparent; color: inherit; border-color: transparent; }
html.lite .btn.ghost.dark { background: var(--primary-soft); color: var(--on-soft); }
html.lite .topbar .btn.ghost, html.lite .topbar .btn.ghost.dark { background: var(--primary-soft); color: var(--on-soft); }
html.lite .btn:active { transform: none; }
html.lite .ocard { contain: content; }

/* Pending card payment dialog (sales page + touch POS) */
.card-pending { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.card-pending-card { background: var(--surface); color: var(--ink); border-radius: 24px; padding: 24px; width: min(440px, 100%); gap: 10px; max-height: 100%; overflow-y: auto; }
.card-pending-card h2 { margin: 0; }
.card-pending-amount { font-size: 2rem; margin: 0; }
.card-ref-input { font-size: 1.4rem; letter-spacing: .08em; text-align: center; min-height: 52px; text-transform: uppercase; }
.card-opt { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; }
.card-opt[aria-checked="true"] { border-color: var(--primary-text); background: var(--primary-soft); }
.card-opt.is-disabled { opacity: .6; }
.card-opt .col { gap: 2px; }
.card-txns { display: flex; flex-direction: column; gap: 6px; }
.card-txn { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.card-txn .ref { font-weight: 700; letter-spacing: .04em; direction: ltr; unicode-bidi: isolate; }
.card-txn.is-refunded { opacity: .65; text-decoration: line-through; }
/* optional Nida «track your order» QR on the sale-done screens */
.nida-qr { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 10px 0; padding: 10px; border: 1px dashed var(--line); border-radius: 14px; text-align: start; }
.nida-qr img { width: 120px; height: 120px; background: #fff; border-radius: 8px; image-rendering: pixelated; flex: none; }
.nida-qr .col { gap: 2px; min-width: 0; }

/* Layout containment: tab rows and tables scroll inside themselves; long URLs wrap.
   Do not grow the document sideways (phones ~390px and desktop). Flex/grid children
   need min-width: 0 so overflow-x: auto on a wrapper can actually shrink. */
.page, main, .card, .col, .row, .add-fold, .add-fold-body, .detail-sheet, .detail-back, .order-body, .journey {
  min-width: 0;
}
.nav, .mod-switch, .tbl-wrap, .chips, .detail-tabs, #pf-tabs {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
/* Long unbroken strings (customer status URL, codes) wrap instead of widening the page. */
a, .num, .journey a, [data-testid="journey-public"] a {
  overflow-wrap: anywhere;
}

.w-6em { width: 6em; }
.theme-card { margin-bottom: var(--s4); }

/* Option B typography: body/nav/buttons use --font (Tajawal + Outfit). Headings keep Alexandria.
   Under RTL, heading sizes are ~12% smaller than the Latin scale (Ahmed found Alexandria a bit large). */
h1, h2, h3,
.page-head h1, .brand-name, .pos-title, .cat-head h2, .kds-title,
.dash-card h2, .card > h1, .card > h2, .card .row > h2, .login-brand h1 {
  font-family: var(--font-display);
}
html[dir="rtl"] h1 { font-size: 1.32rem; }            /* 1.5 * 0.88 */
html[dir="rtl"] .page-head h1 { font-size: 1.28rem; } /* 1.45 * 0.88 */
html[dir="rtl"] h2 { font-size: 1rem; }               /* 1.125 * 0.88 */
html[dir="rtl"] h3 { font-size: .88rem; }             /* 1.0 * 0.88 */
html[dir="rtl"] .cat-head h2 { font-size: .92rem; }   /* 1.05 * 0.88 */
html[dir="rtl"] .pos-title { font-size: 1.06rem; }    /* 1.2 * 0.88 */
html[dir="rtl"] .login-brand h1 { font-size: 1.1rem; }/* 1.25 * 0.88 */
html[dir="rtl"] .kds-title { font-size: 1.01rem; }    /* 1.15 * 0.88 */
