/* ============================================
   POS — Soft Modern Theme
   Warm neutrals · gentle shadows · rounded
   ============================================ */

:root {
  /* Brand / accent (overridable via Tweaks) */
  --accent: #ea580c;
  --accent-soft: #fff1e6;
  --accent-deep: #c2410c;
  --accent-fg: #ffffff;

  /* Warm neutral palette */
  --bg: #faf7f2;             /* warm cream */
  --surface: #ffffff;
  --surface-2: #f5f1ea;
  --surface-3: #ede7dc;
  --border: #e8e1d3;
  --border-strong: #d8cfbd;

  --text: #2a241d;           /* warm near-black */
  --text-muted: #756c5f;
  --text-soft: #9a9183;

  /* Sidebar dark */
  --side-bg: #1f1b16;
  --side-bg-2: #2a241d;
  --side-text: #ece6db;
  --side-text-muted: #8a8275;
  --side-border: #3a342c;
  --side-active: #ea580c;

  /* States */
  --success: #15803d;
  --success-soft: #e6f4ea;
  --danger:  #b91c1c;
  --danger-soft: #fde9e9;
  --warning: #b45309;
  --warning-soft: #fdf1da;
  --info:    #1d4ed8;
  --info-soft: #e7eefe;

  /* Shape */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* Shadows (minimal, flat) */
  --shadow-sm: 0 1px 2px rgba(60, 40, 20, 0.03);
  --shadow-md: 0 2px 8px rgba(60, 40, 20, 0.05);
  --shadow-lg: 0 8px 20px rgba(60, 40, 20, 0.08);
  --shadow-xl: 0 16px 40px rgba(60, 40, 20, 0.12);

  /* Density — compact-first for speed */
  --pad-1: 4px;
  --pad-2: 8px;
  --pad-3: 12px;
  --pad-4: 16px;
  --pad-5: 20px;
  --pad-6: 28px;
  --row-h: 38px;

  --side-w: 210px;
  --topbar-h: 52px;

  --font-en: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-ar: 'Cairo', 'Inter', system-ui, sans-serif;
  --font: var(--font-ar);
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

html[lang="en"] { --font: var(--font-en); }

html[data-density="compact"] {
  --pad-1: 3px; --pad-2: 6px; --pad-3: 8px; --pad-4: 12px; --pad-5: 16px; --pad-6: 20px;
  --row-h: 34px;
  --side-w: 190px;
  --topbar-h: 46px;
}

html[data-density="cozy"] {
  --pad-1: 6px; --pad-2: 10px; --pad-3: 14px; --pad-4: 18px; --pad-5: 24px; --pad-6: 32px;
  --row-h: 44px;
  --side-w: 240px;
  --topbar-h: 64px;
}

/* ============== Dark theme ============== */
html[data-theme="dark"] {
  --bg: #15120e;
  --surface: #1f1b16;
  --surface-2: #26211b;
  --surface-3: #2f2922;
  --border: #332d25;
  --border-strong: #443c31;

  --text: #f5efe4;
  --text-muted: #b3a994;
  --text-soft: #847b6c;

  --side-bg: #100e0b;
  --side-bg-2: #181511;
  --side-text: #ece6db;
  --side-text-muted: #7a7263;
  --side-border: #2a251f;

  --accent-soft: #3a1f10;

  --success-soft: #102a18;
  --danger-soft:  #2d0e0e;
  --warning-soft: #2b1c08;
  --info-soft:    #0d1834;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.7);
}

/* ============== Base ============== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button { font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ============== Buttons / inputs ============== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--row-h);
  padding: 0 var(--pad-3);
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-fg);
}
.btn--primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); }

.btn--danger { color: var(--danger); border-color: color-mix(in oklab, var(--danger), transparent 70%); background: transparent; }
.btn--danger:hover { background: var(--danger-soft); }

.btn--success { background: var(--success); border-color: var(--success); color: #fff; }
.btn--success:hover { background: color-mix(in oklab, var(--success), black 8%); }

.btn--lg { height: calc(var(--row-h) + 12px); font-size: 16px; padding: 0 var(--pad-5); }
.btn--xl { height: calc(var(--row-h) + 22px); font-size: 18px; padding: 0 var(--pad-6); border-radius: var(--r-lg); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn--icon { width: var(--row-h); padding: 0; }

.input, .select, .textarea {
  height: var(--row-h);
  padding: 0 var(--pad-3);
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  width: 100%;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  outline: none;
}
.textarea { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent), transparent 85%);
}
.input--lg { height: calc(var(--row-h) + 8px); font-size: 15px; }
.input--xl { height: calc(var(--row-h) + 16px); font-size: 17px; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); }

.input-icon {
  position: relative;
  display: flex; align-items: center;
}
.input-icon > .input { padding-inline-start: 42px; }
.input-icon > i {
  position: absolute; inset-inline-start: 14px;
  color: var(--text-soft);
  pointer-events: none;
}

/* ============== Cards / surfaces ============== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.card__head {
  padding: var(--pad-3) var(--pad-4);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.card__title { font-weight: 700; font-size: 13.5px; margin: 0; }
.card__body { padding: var(--pad-3) var(--pad-4); }

/* Page chrome */
.page { padding: var(--pad-4) var(--pad-5); }
.page__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: var(--pad-4);
  flex-wrap: wrap;
}
.page__title { font-size: 18px; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.page__sub { color: var(--text-muted); margin-top: 2px; font-size: 12px; }

/* ============== Badges / chips ============== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--danger  { background: var(--danger-soft); color: var(--danger); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--info    { background: var(--info-soft); color: var(--info); }
.badge--accent  { background: var(--accent-soft); color: var(--accent-deep); }
.badge--ghost   { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ============== Tables ============== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  padding: 10px 14px;
  text-align: start;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-weight: 600; color: var(--text-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--surface-2);
  position: sticky; top: 0;
}
.table tbody tr { transition: background 0.1s ease; }
.table tbody tr:hover { background: color-mix(in oklab, var(--accent), transparent 96%); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ============== Auth — Premium split layout ============== */
[hidden] { display: none !important; }

.auth-root {
  position: fixed; inset: 0;
  z-index: 100;
  background: var(--bg);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  overflow: hidden;
}
@media (max-width: 860px) {
  .auth-root { grid-template-columns: 1fr; }
  .auth-hero { display: none !important; }
}

/* ----- Hero side (brand) ----- */
.auth-hero {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(120% 80% at 0% 0%, #2a1a0e 0%, #1a120a 35%, #0e0905 80%);
  color: var(--side-text);
  display: flex; flex-direction: column;
  padding: 36px 40px 28px;
  overflow: hidden;
}
.auth-hero__grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 45%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 45%, black 30%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}
.auth-hero__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
.auth-hero__glow--1 {
  width: 420px; height: 420px;
  inset-inline-start: -120px; top: 30%;
  background: radial-gradient(circle, color-mix(in oklab, var(--accent), transparent 30%) 0%, transparent 70%);
  opacity: 0.55;
  animation: heroGlow 9s ease-in-out infinite alternate;
}
.auth-hero__glow--2 {
  width: 520px; height: 520px;
  inset-inline-end: -180px; bottom: -120px;
  background: radial-gradient(circle, color-mix(in oklab, var(--accent), transparent 55%) 0%, transparent 70%);
  opacity: 0.6;
  animation: heroGlow 11s ease-in-out infinite alternate-reverse;
}
@keyframes heroGlow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(20px, -10px) scale(1.08); }
}

.auth-hero__top {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 14px;
}
.auth-hero__mark {
  width: 52px; height: 52px;
  background: linear-gradient(155deg, #fff 0%, #f6e8d8 100%);
  border-radius: 14px;
  display: grid; place-items: center;
  padding: 6px;
  overflow: hidden;
  box-shadow:
    0 12px 28px -10px rgba(234, 88, 12, 0.5),
    0 2px 0 0 rgba(255,255,255,0.08) inset,
    0 -2px 0 0 rgba(0,0,0,0.06) inset;
  border: 1px solid rgba(255,255,255,0.4);
}
.auth-hero__brand-name { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.auth-hero__brand-tag { font-size: 12px; color: var(--side-text-muted); margin-top: 2px; }

.auth-hero__center {
  flex: 1;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 28px;
  position: relative; z-index: 2;
}

/* ----- 3D Logo stage ----- */
.logo-stage {
  position: relative;
  width: 280px; height: 280px;
  perspective: 1100px;
  cursor: pointer;
  align-self: center;
}
.logo-stage__card {
  position: absolute; inset: 0;
  margin: auto;
  width: 240px; height: 240px;
  border-radius: 36px;
  background:
    linear-gradient(155deg, #fff5e9 0%, #ffe7cc 35%, #f5b988 75%, #c2410c 100%);
  box-shadow:
    /* outer accent halo */
    0 40px 80px -30px rgba(234, 88, 12, 0.55),
    0 24px 50px -20px rgba(0, 0, 0, 0.6),
    /* rim light */
    inset 0 2px 0 rgba(255, 255, 255, 0.85),
    inset 0 -3px 0 rgba(120, 50, 10, 0.25),
    inset 6px 0 18px rgba(255, 255, 255, 0.3),
    inset -6px -8px 18px rgba(120, 50, 10, 0.2);
  transform: rotateX(8deg) rotateY(-10deg);
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
  animation: stageFloat 6s ease-in-out infinite alternate;
}
@keyframes stageFloat {
  0%   { transform: rotateX(8deg) rotateY(-10deg) translateY(0); }
  100% { transform: rotateX(6deg) rotateY(-6deg) translateY(-6px); }
}
.logo-stage__ring {
  position: absolute; inset: 10px;
  border-radius: 28px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(120, 50, 10, 0.18);
  pointer-events: none;
}
.logo-stage__light {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0) 55%);
  pointer-events: none;
  mix-blend-mode: screen;
  transition: background 0.2s ease;
}
.logo-stage__img {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 70%; height: 70%;
  object-fit: contain;
  filter:
    drop-shadow(0 2px 0 rgba(255,255,255,0.6))
    drop-shadow(0 6px 0 rgba(120, 50, 10, 0.18))
    drop-shadow(0 14px 22px rgba(80, 30, 5, 0.45));
  transform: translateZ(40px);
  user-select: none;
  -webkit-user-drag: none;
}
.logo-stage__reflection {
  position: absolute;
  inset-inline: 0; bottom: 0;
  height: 40%;
  background: linear-gradient(to top, rgba(255,255,255,0.18), rgba(255,255,255,0));
  pointer-events: none;
}
.logo-stage__plinth {
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  width: 78%;
  height: 28px;
  background:
    radial-gradient(ellipse at center, rgba(234, 88, 12, 0.35) 0%, rgba(234, 88, 12, 0) 70%);
  filter: blur(8px);
  pointer-events: none;
}
.logo-stage__remove {
  position: absolute;
  top: 10px; inset-inline-end: 10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border: 0; cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  font-size: 11px;
  backdrop-filter: blur(4px);
  z-index: 5;
}
.logo-stage:hover .logo-stage__remove { display: flex; }
.logo-stage.dragover .logo-stage__card {
  box-shadow:
    0 0 0 3px var(--accent),
    0 40px 80px -30px rgba(234, 88, 12, 0.8);
}

.auth-hero__welcome {
  font-size: 40px; font-weight: 800; line-height: 1.1;
  letter-spacing: -0.02em;
  max-width: 460px;
  color: #f7efe2;
}
.auth-hero__welcome span {
  background: linear-gradient(135deg, #ffb27a 0%, #ea580c 60%, #ffd4a3 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-hero__sub {
  color: rgba(236, 230, 219, 0.65);
  font-size: 15px; line-height: 1.7;
  max-width: 460px;
}

.auth-hero__foot {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  color: rgba(236, 230, 219, 0.6);
  font-size: 12px;
}
.auth-hero__copy { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.auth-hero__chips { display: flex; gap: 8px; }
.auth-hero__chip {
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px; font-weight: 500;
  color: rgba(236, 230, 219, 0.85);
  display: inline-flex; align-items: center; gap: 7px;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}
.auth-hero__chip:hover {
  background: rgba(234, 88, 12, 0.08);
  border-color: rgba(234, 88, 12, 0.3);
  transform: translateY(-1px);
}
.auth-hero__chip i { color: var(--accent); font-size: 11px; }

/* ----- Form side ----- */
.auth-pane {
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 48px 40px;
  position: relative;
  background:
    radial-gradient(80% 60% at 100% 0%, color-mix(in oklab, var(--accent), transparent 92%) 0%, transparent 60%),
    radial-gradient(80% 60% at 0% 100%, color-mix(in oklab, var(--accent), transparent 95%) 0%, transparent 60%),
    var(--bg);
}
.auth-pane__top {
  position: absolute;
  top: 24px; inset-inline-end: 24px;
  display: flex; gap: 8px;
}
.topbar-btn--icon { padding: 0; width: 38px; justify-content: center; }
.auth-pane__inner {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.auth-pane__inner--form { max-width: 400px; text-align: start; }
.auth-pane__inner--form .auth-title,
.auth-pane__inner--form .auth-sub { text-align: start; }

.auth-pane__eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  color: var(--accent-deep);
  background: var(--accent-soft);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 18px;
  border: 1px solid color-mix(in oklab, var(--accent), transparent 80%);
}
.auth-pane__dot {
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent), transparent 75%);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

.auth-title { font-size: 30px; font-weight: 800; margin: 0 0 6px; letter-spacing: -0.025em; }
.auth-sub { color: var(--text-muted); margin: 0 0 28px; font-size: 14.5px; }

/* Login form */
.auth-form {
  display: flex; flex-direction: column;
  gap: 16px;
  text-align: start;
}
.auth-form.shake { animation: shake 0.4s; }
.auth-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.auth-label i {
  width: 14px; text-align: center;
  font-size: 12px;
  color: var(--accent);
}

.pw-wrap {
  position: relative;
  display: flex; align-items: center;
}
.pw-wrap .input { padding-inline-end: 48px; }
.pw-toggle {
  position: absolute;
  inset-inline-end: 6px;
  width: 38px; height: 38px;
  border: 0; background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-size: 14px;
  transition: all 0.15s ease;
}
.pw-toggle:hover { background: var(--surface-2); color: var(--text); }

.auth-error {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 600;
  border-inline-start: 3px solid var(--danger);
  animation: fadeIn 0.2s ease;
}
.auth-error::before {
  content: '\f071';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
}

.auth-submit {
  margin-top: 8px;
  height: 52px !important;
  font-size: 15px !important;
  width: 100%;
  justify-content: center;
}
.auth-submit i {
  transition: transform 0.18s ease;
}
.auth-submit:hover i { transform: translateX(4px); }
html[dir="rtl"] .auth-submit:hover i { transform: translateX(-4px); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.auth-pane__inner--form { max-width: 400px; text-align: start; }
.auth-pane__inner--form .auth-title,
.auth-pane__inner--form .auth-sub { text-align: start; }

/* Demo credentials helper */
.auth-demo {
  margin-top: 24px;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.auth-demo__label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.auth-demo__label::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
}
.auth-demo__rows { display: flex; flex-direction: column; gap: 6px; }
.auth-demo__row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px dashed var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  text-align: start;
  color: var(--text);
}
.auth-demo__row:hover {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.auth-demo__role {
  font-size: 12px; font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.auth-demo__creds {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
  justify-content: flex-end;
}
.auth-demo__creds code {
  background: transparent;
  padding: 0;
  color: var(--text);
  font-weight: 600;
}
.auth-demo__sep { opacity: 0.5; }
.auth-demo__row > i {
  font-size: 12px;
  color: var(--accent);
  opacity: 0.55;
  transition: all 0.18s ease;
}
.auth-demo__row:hover > i { opacity: 1; transform: translateX(3px); }
html[dir="rtl"] .auth-demo__row > i { transform: scaleX(-1); }
html[dir="rtl"] .auth-demo__row:hover > i { transform: scaleX(-1) translateX(3px); }

/* Boot fatal fallback */
.boot-fatal {
  position: fixed; inset: 0;
  z-index: 9999;
  display: grid; place-items: center;
  padding: 40px;
  background: var(--bg);
}
.boot-fatal__card {
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  padding: 32px;
  text-align: center;
}
.boot-fatal__icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  display: grid; place-items: center;
  font-size: 26px;
  margin: 0 auto 16px;
}
.boot-fatal__card h2 { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.boot-fatal__card p { margin: 0 0 16px; color: var(--text-muted); font-size: 14px; }
.boot-fatal__card pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: start;
  overflow: auto;
  margin: 0 0 18px;
  max-height: 120px;
  font-family: var(--mono);
}

/* ============== App shell ============== */
.app-root {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  height: 100vh;
}
/* RTL grid handled automatically by direction inheritance */

.sidebar {
  background: var(--side-bg);
  color: var(--side-text);
  display: flex; flex-direction: column;
  border-inline-end: 1px solid var(--side-border);
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--side-border);
}
.side-brand__mark {
  width: 34px; height: 34px;
  background: linear-gradient(155deg, #fff 0%, #f6e8d8 100%);
  border-radius: 8px;
  display: grid; place-items: center;
  padding: 3px;
  overflow: hidden;
  border: 1px solid rgba(234, 88, 12, 0.18);
}
.side-brand__name { font-weight: 700; font-size: 13.5px; }
.side-brand__sub { font-size: 10.5px; color: var(--side-text-muted); margin-top: 1px; }

.side-nav {
  flex: 1;
  padding: 8px 8px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px;
}
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--side-text-muted);
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  border: 0;
  background: transparent;
  text-align: start;
  width: 100%;
  transition: all 0.12s ease;
}
.side-link i { width: 18px; text-align: center; font-size: 14px; }
.side-link:hover { background: var(--side-bg-2); color: var(--side-text); }
.side-link.active {
  background: color-mix(in oklab, var(--accent), transparent 82%);
  color: var(--accent);
  font-weight: 600;
}
.side-link.active i { color: var(--accent); }

.side-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--side-border);
  font-size: 10.5px; color: var(--side-text-muted);
  display: flex; align-items: center; justify-content: space-between;
  opacity: 0.6;
}

/* Topbar */
.app-main { display: grid; grid-template-rows: var(--topbar-h) 1fr; min-width: 0; overflow: hidden; height: 100%; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--pad-5);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar__left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__title { font-weight: 700; font-size: 13.5px; }
.topbar__date { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.topbar__right { display: flex; align-items: center; gap: 6px; }

.topbar-btn {
  height: 32px; min-width: 32px;
  padding: 0 10px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px; font-weight: 500;
  color: var(--text);
  transition: all 0.12s ease;
}
.topbar-btn:hover { background: var(--surface-2); }
.topbar-btn i { font-size: 12px; color: var(--text-muted); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 500;
}
html[dir="rtl"] .user-chip { padding: 4px 4px 4px 10px; }
.user-chip__avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent); color: var(--accent-fg);
  display: grid; place-items: center;
  font-weight: 700; font-size: 10px;
}
.user-chip__role { color: var(--text-muted); font-size: 10.5px; }

.view { overflow-y: auto; overflow-x: hidden; min-height: 0; position: relative; background: var(--bg); -webkit-overflow-scrolling: touch; }
.view > * { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============== Dashboard ============== */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--pad-3);
  margin-bottom: var(--pad-4);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--pad-3) var(--pad-4);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.12s ease;
}
.stat:hover { box-shadow: var(--shadow-md); }
.stat__icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-size: 15px;
  margin-bottom: 8px;
}
.stat__label { color: var(--text-muted); font-size: 11.5px; font-weight: 500; }
.stat__value { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-top: 1px; }
.stat__delta { font-size: 11px; font-weight: 600; margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; }
.stat__delta.up { color: var(--success); }
.stat__delta.down { color: var(--danger); }

.dash-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--pad-3);
  margin-bottom: var(--pad-4);
}
.dash-row.bottom { grid-template-columns: 1fr 1fr; }

/* CSS bar chart */
.chart {
  display: flex; align-items: flex-end; gap: 14px;
  height: 200px;
  padding: 12px 4px;
}
.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.chart__bar {
  width: 100%; max-width: 48px;
  background: linear-gradient(180deg, var(--accent), color-mix(in oklab, var(--accent), black 18%));
  border-radius: 8px 8px 4px 4px;
  position: relative;
  min-height: 4px;
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.chart__bar::after {
  content: attr(data-value);
  position: absolute;
  top: -22px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--text-muted); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chart__label { font-size: 11px; color: var(--text-muted); }

.top-list { display: flex; flex-direction: column; }
.top-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.top-row:last-child { border-bottom: 0; }
.top-row__rank {
  width: 24px; height: 24px;
  background: var(--surface-2);
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 11px; color: var(--text-muted);
  flex-shrink: 0;
}
.top-row__rank.gold { background: #fef3c7; color: #92400e; }
.top-row__rank.silver { background: #e5e7eb; color: #4b5563; }
.top-row__rank.bronze { background: #fed7aa; color: #9a3412; }
.top-row__main { flex: 1; min-width: 0; }
.top-row__name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-row__sub { font-size: 11px; color: var(--text-muted); }
.top-row__val { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* ============== POS screen ============== */
.pos {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: 100%;
  gap: 0;
  background: var(--bg);
}
html[data-density="cozy"] .pos { grid-template-columns: 1fr 420px; }
html[data-density="compact"] .pos { grid-template-columns: 1fr 340px; }

.pos__left {
  display: flex; flex-direction: column;
  padding: var(--pad-4) var(--pad-5);
  gap: var(--pad-3);
  min-width: 0;
  overflow: hidden;
}
.pos__scan {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--pad-3);
}
.pos__cats {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.cat-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.cat-chip:hover { background: var(--surface-2); }
.cat-chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.pos__grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--pad-3);
  padding: 4px;
  min-height: 0;
}
.prod-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex; flex-direction: column;
  position: relative;
  text-align: start;
}
.prod-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.prod-tile:active { transform: translateY(0); }
.prod-tile.oos { opacity: 0.55; cursor: not-allowed; }
.prod-tile__img {
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-size: 32px;
  color: var(--text-soft);
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}
.prod-tile__name { font-weight: 600; font-size: 13px; line-height: 1.3; min-height: 2.6em; overflow: hidden; }
.prod-tile__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.prod-tile__price { font-weight: 800; font-size: 14px; color: var(--accent); font-variant-numeric: tabular-nums; }
.prod-tile__stock { font-size: 11px; color: var(--text-muted); }
.prod-tile__stock.low { color: var(--warning); font-weight: 600; }
.prod-tile__stock.out { color: var(--danger); font-weight: 600; }

/* Cart */
.pos__cart {
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0;
}
.cart__head { padding: var(--pad-4) var(--pad-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.cart__title { font-weight: 700; font-size: 16px; }
.cart__items {
  flex: 1;
  overflow-y: auto;
  padding: var(--pad-3) var(--pad-4);
  min-height: 0;
}
.cart-empty {
  height: 100%;
  display: grid; place-items: center; text-align: center;
  color: var(--text-soft);
  padding: 40px 20px;
}
.cart-empty i { font-size: 44px; margin-bottom: 12px; opacity: 0.5; }
.cart-empty p { margin: 0; font-size: 13px; }

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 12px 8px;
  border-bottom: 1px dashed var(--border);
  animation: slideIn 0.2s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.cart-item__name { font-weight: 600; font-size: 13.5px; grid-column: 1; }
.cart-item__remove { background: transparent; border: 0; color: var(--text-soft); cursor: pointer; padding: 4px; font-size: 13px; }
.cart-item__remove:hover { color: var(--danger); }
.cart-item__meta { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qty {
  display: flex; align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.qty button {
  width: 28px; height: 28px;
  border: 0; background: var(--surface);
  cursor: pointer; font-size: 13px; color: var(--text-muted);
}
.qty button:hover { background: var(--surface-2); color: var(--accent); }
.qty span { min-width: 32px; text-align: center; font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.cart-item__price { font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cart-item__unit { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.cart__totals { padding: var(--pad-4) var(--pad-5); border-top: 1px solid var(--border); background: var(--surface-2); }
.tot-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; font-size: 13.5px; }
.tot-row.muted { color: var(--text-muted); font-size: 12.5px; }
.tot-row.grand { font-size: 18px; font-weight: 800; padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--border); }
.tot-row .num { font-variant-numeric: tabular-nums; }

.pay-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  margin-top: 12px;
}
.pay-btn {
  padding: 10px 6px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all 0.15s ease;
}
.pay-btn i { font-size: 14px; }
.pay-btn:hover { border-color: var(--accent); }
.pay-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); }

.pos__discount { display: grid; grid-template-columns: 80px 1fr; gap: 6px; margin-top: 10px; }
.pos__discount .select { padding-inline: 8px; height: 38px; font-size: 13px; }
.pos__discount .input { height: 38px; font-size: 13px; }
.pos__cash { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }

.complete-btn {
  width: 100%;
  margin-top: 10px;
  background: var(--success);
  border: 0; color: white;
  height: 48px;
  border-radius: var(--r-md);
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.12s ease;
}
.complete-btn:hover { background: color-mix(in oklab, var(--success), black 10%); }
.complete-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.clear-btn {
  width: 100%;
  margin-top: 6px;
  background: transparent;
  border: 1px solid color-mix(in oklab, var(--danger), transparent 70%);
  color: var(--danger);
  height: 36px;
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.clear-btn:hover { background: var(--danger-soft); }

/* ============== Toasts ============== */
.toasts {
  position: fixed; top: 20px;
  inset-inline-end: 20px;
  z-index: 9000;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 360px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px; font-weight: 500;
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  border-inline-start: 4px solid var(--accent);
}
@keyframes toastIn { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }
html[dir="rtl"] @keyframes toastIn { from { transform: translateX(-120%); opacity: 0; } }
.toast.out { animation: toastOut 0.25s ease forwards; }
@keyframes toastOut { to { transform: translateX(120%); opacity: 0; } }
.toast i { font-size: 16px; }
.toast--success { border-inline-start-color: var(--success); }
.toast--success i { color: var(--success); }
.toast--danger { border-inline-start-color: var(--danger); }
.toast--danger i { color: var(--danger); }
.toast--warning { border-inline-start-color: var(--warning); }
.toast--warning i { color: var(--warning); }
.toast--info { border-inline-start-color: var(--info); }
.toast--info i { color: var(--info); }

/* ============== Modal ============== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 15, 10, 0.5);
  backdrop-filter: blur(4px);
  z-index: 8000;
  display: grid; place-items: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: min(560px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal.large { width: min(880px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(10px); } to { opacity: 1; transform: none; } }
.modal__head {
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal__title { font-weight: 700; font-size: 15px; }
.modal__close { background: transparent; border: 0; cursor: pointer; font-size: 14px; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.modal__close:hover { background: var(--surface-2); color: var(--text); }
.modal__body { padding: 18px; overflow-y: auto; }
.modal__foot { padding: 12px 18px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--border); background: var(--surface-2); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .field.full { grid-column: 1 / -1; }

/* ============== Tweaks panel ============== */
.tweaks-panel {
  position: fixed;
  inset-inline-end: 20px;
  bottom: 20px;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  z-index: 7000;
  overflow: hidden;
}
.tweaks-panel__head {
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.tweaks-panel__title { font-weight: 700; font-size: 13.5px; }
.tweaks-panel__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 16px; }
.tweak-row { display: flex; flex-direction: column; gap: 6px; }
.tweak-row__label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.tweak-swatches { display: flex; gap: 8px; }
.tweak-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tweak-swatch:hover { transform: scale(1.1); }
.tweak-swatch.active { border-color: var(--text); transform: scale(1.1); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
.tweak-seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 3px;
}
.tweak-seg button {
  border: 0; background: transparent;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}
.tweak-seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ============== Receipt (print) ============== */
.receipt-print-root {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  width: 300px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: #000;
  background: #fff;
}
.receipt h3 { text-align: center; margin: 0 0 4px; font-size: 16px; }
.receipt .center { text-align: center; }
.receipt hr { border: 0; border-top: 1px dashed #333; margin: 8px 0; }
.receipt table { width: 100%; border-collapse: collapse; font-size: 11px; }
.receipt table th, .receipt table td { padding: 2px 0; text-align: start; }
.receipt .right { text-align: end; }
.receipt .row { display: flex; justify-content: space-between; padding: 1px 0; }
.receipt .total { font-weight: 700; font-size: 13px; border-top: 1px solid #000; padding-top: 4px; margin-top: 4px; }

@media print {
  body * { visibility: hidden; }
  .receipt-print-root, .receipt-print-root * { visibility: visible; }
  .receipt-print-root {
    position: fixed; inset: 0;
    left: 0 !important; right: 0 !important;
    width: 100%; max-width: 280px;
    margin: 0 auto;
    padding: 6mm;
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    font-size: 11px;
    color: #000;
    background: #fff;
  }
  @page { margin: 6mm; size: auto; }
  .rcp-sep { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
  .rcp-sep2 { text-align: center; font-size: 9px; letter-spacing: 3px; color: #333; margin: 4px 0; }
  .rcp-sn { font-family: 'Traditional Arabic','Simplified Arabic','Sakkal Majalla',serif; font-size: 32px; font-weight: bold; line-height: 1.2; }
  .rcp-c { text-align: center; }
  .rcp-st { font-size: 12px; font-weight: 700; }
  .rcp-sa { font-size: 10px; color: #444; margin-top: 2px; }
  .rcp-badge { display: inline-block; padding: 1px 8px; border: 1px solid #000; border-radius: 3px; font-size: 9px; font-weight: 700; margin-top: 4px; }
  .rcp-rn { font-size: 16px; font-weight: 900; letter-spacing: 1px; margin: 2px 0; }
  .rcp-rl { font-size: 9px; color: #666; }
  .rcp-meta { display: flex; justify-content: space-between; font-size: 10px; color: #444; margin: 4px 0; }
  .rcp-item { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dotted #ccc; font-size: 11px; }
  .rcp-item span:first-child { font-weight: 600; }
  .rcp-price { font-weight: 700; white-space: nowrap; }
  .rcp-sr { display: flex; justify-content: space-between; padding: 3px 0; font-size: 11px; color: #444; }
  .rcp-dr { display: flex; justify-content: space-between; padding: 3px 0; font-size: 11px; color: #c00; font-weight: 700; }
  .rcp-gt { text-align: center; padding: 8px 0; }
  .rcp-gl { font-size: 13px; font-weight: 800; }
  .rcp-gv { font-size: 24px; font-weight: 900; }
  .rcp-ft { text-align: center; padding: 6px 0; }
  .rcp-ty { font-size: 12px; font-weight: 800; }
  .rcp-ts { font-size: 10px; color: #888; margin-top: 2px; }
}

/* ============== Toolbars / filter bars ============== */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: var(--pad-4);
  flex-wrap: wrap;
}
.toolbar > .input-icon { flex: 1; min-width: 220px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--pad-4); }
.tabs button {
  padding: 10px 16px;
  border: 0; background: transparent;
  font-weight: 600; font-size: 13.5px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s ease;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-state i { font-size: 44px; opacity: 0.3; margin-bottom: 8px; }
.empty-state p { margin: 0; font-size: 14px; max-width: 280px; line-height: 1.5; }

/* Stock status pills */
.stock-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stock-pill.ok { background: var(--success-soft); color: var(--success); }
.stock-pill.low { background: var(--warning-soft); color: var(--warning); }
.stock-pill.out { background: var(--danger-soft); color: var(--danger); }

/* Confetti success */
.success-flash {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9500;
  display: grid; place-items: center;
}
.success-flash__icon {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  display: grid; place-items: center;
  font-size: 56px;
  box-shadow: 0 20px 60px -10px color-mix(in oklab, var(--success), transparent 40%);
  animation: pop 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

/* small helpers */
.hstack { display: flex; align-items: center; gap: 10px; }
.vstack { display: flex; flex-direction: column; gap: 10px; }
.mute { color: var(--text-muted); }
.bold { font-weight: 700; }
.tabular { font-variant-numeric: tabular-nums; }
.right { text-align: end; }
.center { text-align: center; }
.grow { flex: 1; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* Two-col content rows */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--pad-4); }
@media (max-width: 1100px) {
  .two-col, .dash-row, .dash-row.bottom { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  #rep-stats { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ============== Sidebar grouping ============== */
.side-nav__sep {
  height: 1px;
  background: var(--side-border);
  margin: 6px 12px;
  opacity: 0.5;
}
.side-nav__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--side-text-muted);
  padding: 10px 14px 4px;
  opacity: 0.7;
}

/* ============== POS v2 layout ============== */
.pos2 {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--pad-3) var(--pad-4);
  gap: var(--pad-2);
  overflow: hidden;
}
.pos2__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.pos2__head-left { display: flex; align-items: center; gap: 12px; }
.pos2__head-right { display: flex; align-items: center; gap: 6px; }
.pos2__title { font-size: 16px; font-weight: 800; margin: 0; }
.pos2__receipt {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px;
}

.pos2__scan {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--r-md);
  padding: 4px 12px;
  flex-shrink: 0;
}
.pos2__scan-icon {
  font-size: 18px;
  color: var(--accent);
  flex-shrink: 0;
}
.pos2__scan-input {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 14px;
  font-weight: 600;
  height: 36px;
  padding: 0 !important;
}
.pos2__scan-input:focus {
  box-shadow: none !important;
}
.pos2__scan-kbd {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.pos2__grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--pad-3);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.pos2__table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.pos2__theader {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.pos2__lines {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.pos2__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}
.pos2__row:hover { background: color-mix(in oklab, var(--accent), transparent 96%); }
.pos2__row:last-child { border-bottom: 0; }

.pos2__row-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}
.pos2__row-meta { flex: 1; min-width: 0; }
.pos2__row-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos2__row-cat { font-size: 11px; color: var(--text-muted); }
.pos2__row-bar { font-size: 11px; color: var(--text-soft); font-family: var(--mono); }

.pos2__qty {
  display: flex; align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  flex-shrink: 0;
}
.pos2__qbtn {
  width: 30px; height: 30px;
  border: 0; background: var(--surface);
  cursor: pointer; font-size: 14px;
  color: var(--text-muted);
  display: grid; place-items: center;
  transition: all 0.12s ease;
}
.pos2__qbtn:hover { background: var(--surface-2); color: var(--accent); }
.pos2__qval {
  min-width: 36px; text-align: center;
  font-weight: 700; font-size: 13px;
}

.pos2__remove {
  background: transparent; border: 0;
  color: var(--text-soft);
  cursor: pointer; padding: 6px;
  font-size: 13px; border-radius: 6px;
  flex-shrink: 0;
  transition: all 0.12s ease;
}
.pos2__remove:hover { color: var(--danger); background: var(--danger-soft); }

.pos2__empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 20px;
  text-align: center;
  flex: 1;
}
.pos2__empty-icon {
  font-size: 48px;
  color: var(--text-soft);
  opacity: 0.35;
  margin-bottom: 14px;
}
.pos2__empty-title { font-weight: 700; font-size: 15px; color: var(--text-muted); }
.pos2__empty-sub { font-size: 13px; color: var(--text-soft); margin-top: 4px; }

.pos2__summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  padding: var(--pad-3);
  gap: 6px;
  overflow-y: auto;
  min-height: 0;
}
.pos2__sum-title {
  font-weight: 700; font-size: 13.5px;
  margin-bottom: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.pos2__sum-row {
  display: flex; align-items: center;
  justify-content: space-between;
  font-size: 13px;
  padding: 2px 0;
}
.pos2__sum-disc {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 6px;
  margin-top: 4px;
}
.pos2__disc-type {
  padding-inline: 8px !important;
  height: 36px !important;
  font-size: 12.5px !important;
}
.pos2__disc-input {
  height: 36px !important;
  font-size: 13px !important;
}
.pos2__sum-grand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 800;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 2px solid var(--border-strong);
}
.pos2__confirm {
  width: 100%;
  margin-top: auto;
  padding-top: 10px;
  background: var(--success);
  border: 0; color: white;
  height: 44px;
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center;
  justify-content: center; gap: 8px;
  transition: all 0.12s ease;
}
.pos2__confirm:hover { background: color-mix(in oklab, var(--success), black 10%); }
.pos2__confirm:disabled { opacity: 0.45; cursor: not-allowed; }
.pos2__confirm-kbd {
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.2);
  font-size: 11px;
}
.pos2__hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 6px;
}

/* POS discount row layout */
.pos2__disc-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Scan flash */
.pos2__scan.flash-ok { animation: flashOk 0.4s ease; }
.pos2__scan.flash-error { animation: flashErr 0.4s ease; }
@keyframes flashOk { 0%,100% { box-shadow: none; } 50% { box-shadow: 0 0 0 3px color-mix(in oklab, var(--success), transparent 60%); } }
@keyframes flashErr { 0%,100% { box-shadow: none; } 50% { box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger), transparent 60%); } }

/* Row just-added highlight */
.pos2__row.just-added, .prod-bulk__row.just-added {
  animation: rowFlash 0.5s ease;
}
@keyframes rowFlash { 0% { background: color-mix(in oklab, var(--accent), transparent 85%); } 100% { background: transparent; } }

/* Stock pill (products table) */
.stock-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; padding: 2px 8px;
  border-radius: 20px; font-weight: 700; font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.stock-pill.ok { background: var(--success-soft); color: var(--success); }
.stock-pill.low { background: var(--warning-soft); color: var(--warning); }
.stock-pill.out { background: var(--danger-soft); color: var(--danger); }

/* ============== Product bulk-add ============== */
.prod-bulk { overflow: hidden; }
.prod-bulk__head {
  flex-wrap: wrap;
}
.prod-bulk__head-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 14px;
  flex-shrink: 0;
}
.prod-bulk__body {
  padding: 0;
}
.prod-bulk__theader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.prod-bulk__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}
.prod-bulk__row:hover { background: color-mix(in oklab, var(--accent), transparent 97%); }
.prod-bulk__rnum {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}
.prod-bulk__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.prod-bulk__stats {
  display: flex;
  align-items: center;
  gap: 20px;
}
.prod-bulk__stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* ============== Damages / Returns v2 ============== */
.dr2-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--pad-3);
  margin-bottom: var(--pad-3);
}
.dr2-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--pad-3) var(--pad-4);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.dr2-stat__icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 15px;
  flex-shrink: 0;
}

.dr2-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: var(--pad-3);
}
.dr2-toggle__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  transition: all 0.12s ease;
  flex: 1;
}
.dr2-toggle__btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.dr2-toggle__btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.dr2-toggle__btn i { font-size: 16px; }

.dr2-form { overflow: hidden; }
.dr2-scan {
  font-size: 16px !important;
  font-weight: 600;
}
.dr2-detail {
  padding: var(--pad-4) var(--pad-5);
  min-height: 140px;
}
.dr2-detail__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  text-align: center;
  color: var(--text-soft);
  gap: 6px;
}
.dr2-detail__empty i { font-size: 32px; opacity: 0.4; }

.dr2-prodcard {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  margin-bottom: 14px;
}
.dr2-prodcard__icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--surface), var(--surface-3));
  display: grid; place-items: center;
  font-size: 20px;
  color: var(--text-soft);
  flex-shrink: 0;
}
.dr2-prodcard__meta { flex: 1; min-width: 0; }
.dr2-prodcard__name { font-weight: 700; font-size: 14px; }
.dr2-prodcard__stock { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.dr2-receipt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  margin-bottom: 14px;
}
.dr2-receipt__icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.dr2-refund {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--success-soft);
  border-radius: var(--r-md);
  margin-top: 12px;
  font-weight: 700;
  color: var(--success);
}


/* ============================================================
   RESPONSIVE — Mobile (≤ 768px) & Tablet (769px – 1024px)
   ============================================================ */

/* ---- Hamburger toggle button (hidden on desktop) ---- */
.topbar-menu-toggle {
  display: none;
  height: 32px; width: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
  transition: background 0.12s ease;
}
.topbar-menu-toggle:hover { background: var(--surface-2); color: var(--text); }

/* ---- Sidebar overlay backdrop ---- */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeInBack 0.2s ease;
}
@keyframes fadeInBack { from { opacity: 0; } to { opacity: 1; } }
.sidebar-backdrop.visible { display: block; }

/* ---- Bottom navigation bar (mobile only) ---- */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 58px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 150;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.bottom-nav__inner {
  display: flex;
  align-items: stretch;
  height: 100%;
  gap: 0;
}
.bottom-nav__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 10px;
  padding: 4px 2px;
  transition: all 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav__btn i { font-size: 18px; line-height: 1; }
.bottom-nav__btn.active { color: var(--accent); }
.bottom-nav__btn.active i {
  background: var(--accent-soft);
  padding: 6px 10px;
  border-radius: 10px;
}
.bottom-nav__btn span { font-size: 10px; }

/* POS cart toggle button for mobile */
.pos-cart-toggle {
  display: none;
  position: fixed;
  bottom: 70px;
  inset-inline-end: 16px;
  z-index: 140;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: 0;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  display: none;
  align-items: center; justify-content: center;
  transition: transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.pos-cart-toggle:active { transform: scale(0.94); }
.pos-cart-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--danger);
  color: white;
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid var(--surface);
}

/* ============================================================
   TABLET  769px – 1024px
   ============================================================ */
@media (max-width: 1024px) and (min-width: 769px) {
  /* Compact sidebar */
  :root { --side-w: 58px; }
  html[data-density="cozy"] { --side-w: 58px; }
  html[data-density="compact"] { --side-w: 52px; }

  .side-brand__name,
  .side-brand__sub,
  .side-link span,
  .side-nav__label,
  .side-foot { display: none !important; }

  .side-brand { justify-content: center; padding: 12px 8px; }
  .side-link { justify-content: center; padding: 10px 8px; }
  .side-link i { width: auto; font-size: 16px; }

  /* Dashboard */
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row { grid-template-columns: 1fr; }
  .dash-row.bottom { grid-template-columns: 1fr 1fr; }

  /* POS */
  .pos { grid-template-columns: 1fr 300px; }
  html[data-density="cozy"] .pos { grid-template-columns: 1fr 320px; }
  html[data-density="compact"] .pos { grid-template-columns: 1fr 280px; }

  .pos__grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

  /* Two-col */
  .two-col { grid-template-columns: 1fr; }

  /* Modal full-width */
  .modal { width: min(700px, 96vw); }
}

/* ============================================================
   MOBILE  ≤ 768px
   ============================================================ */
@media (max-width: 768px) {
  /* Show toggle button */
  .topbar-menu-toggle { display: flex !important; }

  /* App shell: sidebar becomes fixed overlay */
  .app-root {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0;
    inset-inline-start: 0;
    width: 240px !important;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
  }
  html[dir="rtl"] .sidebar {
    inset-inline-start: auto;
    inset-inline-end: 0;
    transform: translateX(100%);
  }
  .sidebar.open {
    transform: translateX(0) !important;
  }

  /* Show bottom nav */
  .bottom-nav { display: flex; }

  /* Add bottom padding to view so content isn't hidden behind bottom nav */
  .view { padding-bottom: 68px !important; }

  /* Topbar adjustments */
  .topbar { padding: 0 var(--pad-3); }
  .topbar__date { display: none; }
  .user-chip__role { display: none; }
  .topbar-btn span { display: none; }

  /* Page padding */
  .page { padding: var(--pad-3) var(--pad-3); }
  .page__title { font-size: 16px; }

  /* Dashboard */
  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: var(--pad-2); }
  .stat__value { font-size: 18px; }
  .dash-row { grid-template-columns: 1fr !important; }
  .dash-row.bottom { grid-template-columns: 1fr !important; }

  /* POS — stacked layout */
  .pos {
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - var(--topbar-h) - 58px) !important;
    overflow: hidden;
  }
  .pos__left {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: var(--pad-2) var(--pad-3);
  }
  .pos__scan { grid-template-columns: 1fr; gap: var(--pad-2); }
  .pos__grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--pad-2); }
  .prod-tile { padding: 8px; }
  .prod-tile__img { font-size: 24px; }
  .prod-tile__name { font-size: 12px; }
  .prod-tile__price { font-size: 13px; }

  /* Cart: fixed panel sliding from bottom */
  .pos__cart {
    position: fixed;
    inset: 0;
    z-index: 180;
    background: var(--surface);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-inline-start: none !important;
    border-top: 1px solid var(--border);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    top: auto;
    height: 85vh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .pos__cart.cart-open {
    transform: translateY(0);
  }
  /* Cart drag handle */
  .pos__cart::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--border-strong);
    border-radius: 99px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  /* Show FAB toggle for cart */
  .pos-cart-toggle { display: flex !important; }

  /* POS v2 (pos2) mobile */
  .pos2 { padding: var(--pad-2) var(--pad-2); }
  .pos2__head { flex-wrap: wrap; gap: 8px; }
  .pos2__title { font-size: 14px; }

  /* Two-col */
  .two-col { grid-template-columns: 1fr !important; }

  /* Tables: horizontal scroll */
  .table-wrap, .card__body > .table { overflow-x: auto; }
  .table { min-width: 520px; }
  .table th, .table td { padding: 8px 10px; font-size: 12px; }

  /* Cards */
  .card__head { padding: var(--pad-2) var(--pad-3); flex-wrap: wrap; gap: 6px; }
  .card__body { padding: var(--pad-2) var(--pad-3); }

  /* Modals */
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: var(--r-xl) var(--r-xl) 0 0 !important;
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    max-height: 92vh;
    overflow-y: auto;
  }
  .modal-backdrop { align-items: flex-end; }
  .modal__body { padding: 14px; max-height: 60vh; overflow-y: auto; }
  .modal__foot { padding: 10px 14px; }

  /* Form grids */
  .field-row, .form-row { flex-direction: column !important; }
  .two-col .field { min-width: 100%; }

  /* Reports */
  #rep-stats { grid-template-columns: repeat(2, 1fr) !important; }

  /* Damages / returns */
  .dr2-stats { grid-template-columns: 1fr !important; }
  .dr2-toggle { flex-direction: column; }

  /* Toasts positioning */
  .toasts {
    bottom: 68px !important;
    top: auto !important;
    right: var(--pad-3) !important;
    left: var(--pad-3) !important;
    width: auto !important;
  }

  /* Scrollbars thinner on mobile */
  ::-webkit-scrollbar { width: 4px; height: 4px; }

  /* Auth */
  .auth-root { grid-template-columns: 1fr; min-height: 100dvh; }
  .auth-hero { display: none !important; }
  .auth-form-wrap { padding: var(--pad-4) var(--pad-3); }

  /* Users / settings tables */
  .page__head { flex-direction: column; align-items: flex-start; }
  .page__head > * { width: 100%; }
}

/* ============================================================
   SMALL MOBILE  ≤ 390px
   ============================================================ */
@media (max-width: 390px) {
  .dash-grid { grid-template-columns: 1fr 1fr; gap: var(--pad-2); }
  .stat__value { font-size: 16px; }
  .pos__grid { grid-template-columns: repeat(2, 1fr); }
  .pay-row { grid-template-columns: repeat(2, 1fr); }
  .topbar__title { font-size: 13px; }
}

/* ============================================================
   Safe area insets (iPhone notch / home bar)
   ============================================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .bottom-nav {
      height: calc(58px + env(safe-area-inset-bottom));
      padding-bottom: env(safe-area-inset-bottom);
    }
    .view { padding-bottom: calc(68px + env(safe-area-inset-bottom)) !important; }
  }
}

/* ============================================================
   POS v2 — Mobile overrides
   ============================================================ */
@media (max-width: 768px) {
  .pos2 {
    padding: var(--pad-2);
    gap: var(--pad-2);
    height: calc(100vh - var(--topbar-h) - 58px);
    overflow: hidden;
  }
  .pos2__head { gap: 6px; }
  .pos2__title { font-size: 14px; }
  .pos2__receipt { font-size: 11px; }
  .pos2__scan { padding: 2px 8px; }
  .pos2__scan-kbd { display: none; }
  .pos2__scan-row { flex-direction: column; gap: 6px; }

  /* Stack grid vertically; summary hidden by default, shown as slide-up */
  .pos2__grid {
    grid-template-columns: 1fr !important;
    gap: 0;
  }
  .pos2__table {
    border-radius: var(--r-md);
  }
  /* Summary panel: fixed slide-up on mobile */
  .pos2__summary {
    position: fixed;
    inset: 0;
    top: auto;
    z-index: 180;
    height: 75vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding-bottom: calc(var(--pad-4) + env(safe-area-inset-bottom, 0px));
    box-shadow: var(--shadow-xl);
  }
  .pos2__summary::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--border-strong);
    border-radius: 99px;
    margin: 10px auto 6px;
    flex-shrink: 0;
  }
  .pos2__summary.summary-open {
    transform: translateY(0);
  }

  /* Summary FAB */
  .pos2-summary-fab {
    position: fixed;
    bottom: 70px;
    inset-inline-end: 16px;
    z-index: 160;
    height: 50px;
    min-width: 130px;
    border-radius: var(--r-pill);
    background: var(--accent);
    color: white;
    border: 0;
    font-size: 13px; font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center; justify-content: center;
    gap: 8px;
    padding: 0 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    transition: transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .pos2-summary-fab:active { transform: scale(0.95); }
  .pos2-summary-fab i { font-size: 16px; }

  /* Compact table header on mobile */
  .pos2__theader { display: none; }
  .pos2__row-bar { display: none; }

  /* Smaller qty control */
  .pos2__qbtn { width: 26px; height: 26px; font-size: 12px; }
  .pos2__qval { min-width: 28px; font-size: 12px; }
}

/* ── Name search dropdown (POS / Online POS) ── */
.pos2__scan-row {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.pos2__scan-row > .pos2__scan {
  flex: 1;
}
.pos2__scan--name {
  border-color: #2563eb !important;
}
.pos2__name-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  inset-inline-start: 0;
  inset-inline-end: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 260px;
  overflow-y: auto;
  margin-top: 4px;
}
.pos2__name-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border-light, #f3f3f3);
}
.pos2__name-item:hover {
  background: var(--accent-soft, #fff7ed);
}
.pos2__name-item:last-child {
  border-bottom: none;
}
.pos2__name-search-wrap {
  position: relative;
  flex: 1;
}

/* ── Print receipt button (POS summary) ── */
.pos2__print-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  margin-top: 8px;
  border: 2px dashed var(--border-strong, #ccc);
  border-radius: var(--r-md, 10px);
  background: var(--surface-2, #f9fafb);
  color: var(--text-strong, #333);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.pos2__print-btn:hover:not(:disabled) {
  background: var(--accent-soft, #fff7ed);
  border-color: var(--accent, #ea580c);
  color: var(--accent, #ea580c);
}
.pos2__print-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pos2__print-btn i {
  font-size: 14px;
}

/* ── No-barcode products list panel (POS + Online POS) ── */
.pos2__name-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 10px);
  overflow: hidden;
  margin-bottom: 12px;
}
.pos2__name-list-header {
  display: flex;
  align-items: center;
  padding: 7px 14px;
  background: var(--surface-2, #f9fafb);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pos2__name-list-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
}
.pos2__name-list-search .input {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  height: 28px;
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  flex: 1;
}
.pos2__name-list-body {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  max-height: 120px;
  overflow-y: auto;
}
.pos2__name-list-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  background: var(--surface-2, #f9fafb);
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  user-select: none;
}
.pos2__name-list-item:hover {
  background: #eff6ff;
  border-color: #2563eb;
  transform: translateY(-1px);
}
.pos2__name-list-item:active {
  transform: scale(0.97);
}
.pos2__name-list-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong, #111);
}
.pos2__name-list-meta {
  display: flex;
  align-items: center;
  gap: 5px;
}
.pos2__name-list-meta .tabular {
  font-size: 11px;
  color: var(--text-muted);
}
.pos2__name-list-stock {
  font-size: 10px;
  font-weight: 700;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 10px;
  padding: 1px 6px;
}
.pos2__name-list-empty {
  width: 100%;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* ── Editable quantity input ── */
.pos2__qinput {
  width: 44px;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
  height: 30px;
  padding: 0 2px;
  cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}
.pos2__qinput:hover {
  border-color: var(--text-muted);
}
.pos2__qinput:focus {
  outline: none;
  border-color: var(--accent, #f97316);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.15);
}
