/* ============================================================
   main.css — design system for the fashion & footwear store app
   RTL-first. No external fonts/icons/CSS frameworks required.
   ============================================================ */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef0ff;
  --violet: #7c3aed;
  --blue: #2563eb;
  --emerald: #0f9d68;
  --emerald-light: #e8f9f1;
  --amber: #b45309;
  --amber-bg: #fff3dd;
  --amber-strong: #f59e0b;
  --red: #dc2626;
  --red-light: #fdecec;
  --ink: #12172b;
  --ink-soft: #4b5468;
  --muted: #8a91a6;
  --border: #e6e8f0;
  --border-soft: #f0f1f6;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --sidebar-bg: #171233;
  --sidebar-bg-2: #1f1a45;
  --sidebar-text: #b9b3dd;
  --sidebar-text-active: #ffffff;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 50, 0.06);
  --shadow-md: 0 6px 20px rgba(30, 24, 70, 0.08);
  --shadow-lg: 0 16px 40px rgba(30, 24, 70, 0.14);
  --sidebar-w: 250px;
  --topbar-h: 68px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, "Geeza Pro", "Arial", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--primary-light); }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

/* ---------- Layout shell ---------- */
#app { min-height: 100%; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2) 90%);
  color: var(--sidebar-text);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px 10px;
}
.sidebar-brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #818cf8, #a78bfa 60%, #f472b6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar-brand-name { color: #fff; font-weight: 700; font-size: 15.5px; }
.sidebar-brand-sub { color: #a29bcf; font-size: 12px; margin-top: 1px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 14.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: start;
}
.nav-item .icon { flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.nav-item.active .icon { opacity: 1; color: #c7bfff; }
.nav-item .badge-count {
  margin-inline-start: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 10px 6px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 10px; }

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

.topbar {
  height: var(--topbar-h);
  background: rgba(244,245,250,0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  padding: 9px 14px 9px 14px;
  padding-inline-start: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13.5px;
}
.topbar-search .icon { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar-search-results {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 340px;
  overflow-y: auto;
  z-index: 60;
}
.search-result-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg); }
.search-result-kind { font-size: 11px; color: var(--muted); }

.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--ink-soft);
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn .dot-badge {
  position: absolute; top: -2px; inset-inline-end: -2px;
  width: 9px; height: 9px; border-radius: 999px; background: var(--red);
  border: 2px solid #fff;
}

.role-pill {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.role-pill .avatar {
  width: 26px; height: 26px; border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--violet));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

.main-content { padding: 24px 28px 60px; max-width: 1400px; width: 100%; margin: 0 auto; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 800; color: var(--ink); }
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13.8px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.06s ease, box-shadow 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #6d5cf3); color: #fff; box-shadow: 0 8px 18px rgba(79,70,229,0.28); }
.btn-primary:hover { box-shadow: 0 10px 22px rgba(79,70,229,0.36); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-soft { background: var(--primary-light); color: var(--primary-dark); }
.btn-soft:hover { background: #e2e5ff; }
.btn-danger { background: #fff; color: var(--red); border-color: #f3caca; }
.btn-danger:hover { background: var(--red-light); }
.btn-danger-solid { background: var(--red); color: #fff; }
.btn-success { background: var(--emerald); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon-only { padding: 9px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); gap: 12px; }
.card-title { font-weight: 700; font-size: 15px; }
.card-body { padding: 18px 20px; }

/* ---------- KPI stat cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-icon { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 800; margin-top: 4px; letter-spacing: -0.3px; }
.kpi-delta { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; margin-top: 6px; }
.kpi-delta.up { color: var(--emerald); }
.kpi-delta.down { color: var(--red); }
.tone-indigo { background: var(--primary-light); color: var(--primary); }
.tone-emerald { background: var(--emerald-light); color: var(--emerald); }
.tone-amber { background: var(--amber-bg); color: var(--amber); }
.tone-red { background: var(--red-light); color: var(--red); }
.tone-violet { background: #f3ecff; color: var(--violet); }
.tone-blue { background: #e8f1ff; color: var(--blue); }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space:nowrap;}
.badge-emerald { background: var(--emerald-light); color: var(--emerald); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-gray { background: #eef0f5; color: var(--ink-soft); }
.badge-indigo { background: var(--primary-light); color: var(--primary-dark); }
.badge-violet { background: #f3ecff; color: var(--violet); }
.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.dot-emerald { background: var(--emerald); }
.dot-amber { background: var(--amber-strong); }
.dot-red { background: var(--red); }
.dot-gray { background: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.6px; }
table.tbl th {
  text-align: start;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #fafafe;
  position: sticky; top: 0;
}
table.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.tbl tbody tr:hover { background: #fafaff; }
table.tbl tbody tr:last-child td { border-bottom: none; }
.row-clickable { cursor: pointer; }
.cell-strong { font-weight: 700; }
.cell-muted { color: var(--muted); }
.td-num { font-variant-numeric: tabular-nums; }

/* product cell */
.prod-cell { display: flex; align-items: center; gap: 10px; }
.prod-thumb {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}
.prod-thumb-lg { width: 84px; height: 84px; border-radius: 16px; font-size: 34px; }
.prod-name { font-weight: 700; font-size: 13.8px; }
.prod-meta { color: var(--muted); font-size: 12px; margin-top: 1px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab-btn {
  padding: 10px 6px; margin-inline-end: 18px;
  border: none; background: none; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: 13.8px;
  border-bottom: 2.5px solid transparent; white-space: nowrap;
}
.tab-btn.active { color: var(--primary); border-color: var(--primary); }
.pill-tabs { display: inline-flex; background: #eef0f5; padding: 4px; border-radius: 999px; gap: 2px; }
.pill-tab { padding: 7px 16px; border-radius: 999px; border: none; background: none; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.pill-tab.active { background: #fff; color: var(--primary-dark); box-shadow: var(--shadow-sm); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }
label.flabel { font-size: 12.8px; font-weight: 700; color: var(--ink-soft); }
.input, select.input, textarea.input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.input:focus, select.input:focus, textarea.input:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.input-icon-wrap { position: relative; }
.input-icon-wrap .input { padding-inline-start: 36px; }
.input-icon-wrap .icon { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.help-text { font-size: 11.8px; color: var(--muted); }
.error-text { font-size: 11.8px; color: var(--red); font-weight: 600; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }

/* size / color chip selectors */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  min-width: 46px;
  text-align: center;
  position: relative;
}
.chip:hover { border-color: var(--primary); }
.chip.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.chip.disabled { opacity: 0.4; cursor: not-allowed; text-decoration: line-through; }
.chip-stock { font-size: 10px; font-weight: 600; color: var(--muted); display: block; margin-top: 2px; }
.color-chip { display: flex; align-items: center; gap: 7px; }
.swatch { width: 15px; height: 15px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px rgba(0,0,0,0.28); flex-shrink:0; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,15,35,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px; backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: var(--radius-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.16s ease;
}
.modal.modal-lg { max-width: 860px; }
.modal.modal-xl { max-width: 1100px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.98);} to { opacity:1; transform: translateY(0) scale(1);} }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); }
.modal-title { font-weight: 800; font-size: 16.5px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .icon { color: #c7cadb; margin-bottom: 14px; }
.empty-state-title { font-weight: 700; color: var(--ink-soft); font-size: 15px; margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; }

/* ---------- Toasts ---------- */
#toast-holder { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 9px;
  background: #1c1836; color: #fff; padding: 12px 16px;
  border-radius: var(--radius-md); font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #0d3d2c; }
.toast-error { background: #4a1414; }
.toast-icon { flex-shrink: 0; display:flex; }

.toast-text { flex: 1; }
.toast-close {
  background: rgba(255,255,255,0.12); border: none; color: #fff; cursor: pointer;
  width: 24px; height: 24px; border-radius: 999px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; padding: 0;
}
.toast-close:hover { background: rgba(255,255,255,0.24); }
@keyframes toastPulse {
  0% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
  100% { transform: translateX(0); }
}
.toast-pulse { animation: toastPulse 0.28s ease; }

/* ---------- Persistent in-modal error banner ---------- */
.modal-error {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--red-light); color: #8c1d1d;
  border: 1px solid #f3caca; border-radius: var(--radius-sm);
  padding: 11px 13px; margin-bottom: 16px;
  font-size: 13.4px; font-weight: 600; line-height: 1.5;
}
.modal-error-icon { color: var(--red); flex-shrink: 0; display: flex; margin-top: 1px; }
.modal-error-text { flex: 1; }
.modal-error-close {
  background: none; border: none; cursor: pointer; color: #8c1d1d;
  padding: 0; display: flex; flex-shrink: 0; opacity: 0.6;
}
.modal-error-close:hover { opacity: 1; }

/* ---------- Matrix (size x color) ---------- */
.matrix-wrap { overflow-x: auto; }
table.matrix { border-collapse: collapse; font-size: 13px; }
table.matrix th, table.matrix td { padding: 8px 10px; text-align: center; }
table.matrix th { color: var(--muted); font-size: 11.5px; font-weight: 700; }
table.matrix td:first-child, table.matrix th:first-child { text-align: start; font-weight: 700; color: var(--ink); }
.matrix-cell {
  min-width: 52px; border-radius: 10px; padding: 7px 6px; font-weight: 800; font-size: 13px;
  display: inline-block; min-width: 44px;
}
.matrix-cell.healthy { background: var(--emerald-light); color: var(--emerald); }
.matrix-cell.low { background: var(--amber-bg); color: var(--amber); }
.matrix-cell.critical { background: var(--red); color: #fff; }
.matrix-cell.out { background: var(--red-light); color: var(--red); }

/* ---------- Incoming-order alert ---------- */
#order-alert-holder {
  position: fixed; top: 14px; inset-inline-start: 50%; transform: translateX(50%);
  z-index: 300; display: flex; flex-direction: column; gap: 10px; align-items: center;
  width: min(460px, calc(100vw - 24px)); pointer-events: none;
}
html[dir="rtl"] #order-alert-holder { transform: translateX(50%); }
.order-alert {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
  background: linear-gradient(135deg, #16324f, #12263d);
  color: #fff; padding: 14px 16px; border-radius: var(--radius-lg);
  box-shadow: 0 18px 44px rgba(10, 20, 45, 0.4);
  border: 1px solid rgba(255,255,255,0.12);
  opacity: 0; transform: translateY(-14px) scale(0.97);
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.order-alert.show { opacity: 1; transform: translateY(0) scale(1); }
.order-alert-icon {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, #34d399, #059669);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.order-alert-body { flex: 1; min-width: 0; }
.order-alert-title { font-weight: 800; font-size: 14.5px; }
.order-alert-meta { font-size: 12.5px; color: #b9cbe0; margin-top: 2px; }
.order-alert-items { font-size: 12px; color: #dce8f5; margin-top: 5px; line-height: 1.45; }
.order-alert-warn {
  font-size: 11.5px; color: #ffd28a; margin-top: 6px;
  display: flex; align-items: center; gap: 4px;
}
.order-alert .icon-btn {
  background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.14);
  color: #cfe0f0; width: 30px; height: 30px;
}
.order-alert .icon-btn:hover { background: rgba(255,255,255,0.16); }

/* ---------- POS layout ---------- */
.pos-grid { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: flex-start; }
.pos-browser { min-width: 0; }
.pos-toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.pos-products { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.pos-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px; cursor: pointer; transition: box-shadow 0.15s, border-color .15s;
  display: flex; flex-direction: column; gap: 8px;
}
.pos-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.pos-card-thumb { height: 74px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 30px; }
.pos-card-name { font-weight: 700; font-size: 12.8px; line-height: 1.3; min-height: 32px; }
.pos-card-price { font-weight: 800; color: var(--primary-dark); font-size: 13.5px; }
.pos-card-stock { font-size: 11px; color: var(--muted); }

.cart-panel {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  position: sticky; top: calc(var(--topbar-h) + 14px);
  display: flex; flex-direction: column; max-height: calc(100vh - var(--topbar-h) - 28px);
  box-shadow: var(--shadow-sm);
}
.cart-head { padding: 16px 18px; border-bottom: 1px solid var(--border-soft); font-weight: 800; display:flex; align-items:center; justify-content:space-between; }
.cart-items { overflow-y: auto; padding: 10px 14px; flex: 1; }
.cart-line { display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border-soft); align-items: center; }
.cart-line:last-child { border-bottom: none; }
.cart-line-thumb { width: 40px; height: 40px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.cart-line-info { flex: 1; min-width: 0; }
.cart-line-name { font-weight: 700; font-size: 12.8px; }
.cart-line-variant { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.qty-stepper { display: flex; align-items: center; gap: 6px; }
.qty-stepper button { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: pointer; display:flex; align-items:center; justify-content:center; }
.cart-line-price { font-weight: 700; font-size: 12.8px; white-space: nowrap; }
.cart-foot { padding: 16px 18px; border-top: 1px solid var(--border-soft); }
.summary-row { display: flex; justify-content: space-between; font-size: 13.2px; margin-bottom: 8px; color: var(--ink-soft); }
.summary-row.total { font-size: 16.5px; font-weight: 800; color: var(--ink); margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.pay-methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(62px, 1fr)); gap: 6px; margin: 10px 0; }
.pay-method-btn { border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: #fff; padding: 8px 4px; font-size: 11.6px; font-weight: 700; cursor: pointer; display:flex; flex-direction:column; align-items:center; gap:4px; color: var(--ink-soft); }
.pay-method-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }

/* ---------- Misc utility classes ---------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2,1fr); }
.grid-3 { grid-template-columns: repeat(3,1fr); }
.grid-4 { grid-template-columns: repeat(4,1fr); }
.w-full { width: 100%; }
.text-xs { font-size: 11.5px; } .text-sm { font-size: 13px; } .text-base { font-size: 15px; }
.text-lg { font-size: 17px; } .text-xl { font-size: 20px; } .text-2xl { font-size: 26px; } .text-3xl { font-size: 32px; }
.font-medium { font-weight: 600; } .font-semibold { font-weight: 700; } .font-bold { font-weight: 800; }
.text-muted { color: var(--muted); } .text-soft { color: var(--ink-soft); }
.text-emerald { color: var(--emerald); } .text-red { color: var(--red); } .text-amber { color: var(--amber); } .text-primary { color: var(--primary); }
.rounded-sm { border-radius: var(--radius-sm); } .rounded-md { border-radius: var(--radius-md); } .rounded-lg { border-radius: var(--radius-lg); } .rounded-full { border-radius: 999px; }
.p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; }
.mt-1{margin-top:4px;} .mt-2{margin-top:8px;} .mt-3{margin-top:12px;} .mt-4{margin-top:16px;} .mt-6{margin-top:24px;}
.mb-1{margin-bottom:4px;} .mb-2{margin-bottom:8px;} .mb-3{margin-bottom:12px;} .mb-4{margin-bottom:16px;}
.hidden { display: none !important; }
.relative { position: relative; }
.overflow-auto { overflow: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cursor-pointer { cursor: pointer; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.link-btn { background: none; border: none; color: var(--primary); font-weight: 700; cursor: pointer; font-size: 13px; padding: 0; }
.section-title { font-weight: 800; font-size: 15px; margin-bottom: 2px; }
.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; align-items: flex-start; }
.stack-list > * + * { margin-top: 10px; }
.avatar-sm { width: 30px; height: 30px; border-radius: 999px; display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; color:#fff; flex-shrink:0; }
.progress-track { height: 7px; border-radius: 999px; background: var(--border-soft); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; }
.mini-bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.mini-bar { flex: 1; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #8b7cf6, var(--primary)); position: relative; min-height: 3px; }
.perm-grid td, .perm-grid th { text-align: center; }
.perm-grid td:first-child, .perm-grid th:first-child { text-align: start; }

/* ---------------- Auth gate ---------------- */
.auth-gate {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #171233, #1f1a45 60%, #3d2f6b);
}
.auth-card { width: 100%; max-width: 420px; padding: 28px 26px; }

/* ---------- Toggle switch ---------- */
.switch {
  width: 44px; height: 25px; border-radius: 999px; border: none;
  background: #d6d9e3; position: relative; cursor: pointer; flex-shrink: 0;
  transition: background 0.18s ease; padding: 0;
}
.switch.on { background: var(--emerald); }
.switch-knob {
  position: absolute; top: 3px; inset-inline-start: 3px;
  width: 19px; height: 19px; border-radius: 999px; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
  transition: transform 0.18s ease;
}
html[dir="rtl"] .switch.on .switch-knob { transform: translateX(-19px); }
html[dir="ltr"] .switch.on .switch-knob { transform: translateX(19px); }
.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.text-start { text-align: start; }
.block { display: block; }

/* ---------- Responsive ---------- */
.sidebar-overlay { display: none; }
.hamburger-btn { display: none; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .pos-grid { grid-template-columns: 1fr; }
  .cart-panel { position: static; max-height: none; }
  .pos-products { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-inline-start: 0; top: 0; height: 100vh; width: 250px;
    transform: translateX(-110%);
    transition: transform 0.2s ease;
  }
  html[dir="rtl"] .sidebar { transform: translateX(110%); }
  .sidebar.open, html[dir="rtl"] .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; background: rgba(10,10,25,0.45); z-index: 39; }
  .hamburger-btn { display: flex; }
  .main-content { padding: 16px 14px 50px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-search { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .pos-products { grid-template-columns: repeat(2, 1fr); }
  .field-row { flex-direction: column; gap: 0; }
}

/* ============================================================
   80mm thermal receipt (ESC/POS roll printers)
   ------------------------------------------------------------
   Printed width for an 80mm roll is ~72mm of usable paper. We set an
   explicit @page size so the browser doesn't try to lay the receipt out on
   A4 and leave a huge blank tail, which is the usual reason thermal prints
   come out with three feet of empty paper after them.
   ============================================================ */
.receipt-80mm {
  width: 72mm;
  margin: 0 auto;
  padding: 2mm 1mm;
  font-family: "Tahoma", "Segoe UI", monospace;
  color: #000;
  background: #fff;
  font-size: 11.5px;
  line-height: 1.45;
}
.receipt-80mm .r-center { text-align: center; }
.receipt-80mm .r-store { font-size: 15px; font-weight: 800; letter-spacing: -0.2px; }
.receipt-80mm .r-sub { font-size: 10.5px; }
.receipt-80mm .r-rule { border-top: 1px dashed #000; margin: 6px 0; }
.receipt-80mm .r-row { display: flex; justify-content: space-between; gap: 6px; }
.receipt-80mm .r-row span:last-child { white-space: nowrap; }
.receipt-80mm table { width: 100%; border-collapse: collapse; font-size: 11px; }
.receipt-80mm th {
  text-align: start; font-weight: 700; padding: 2px 0;
  border-bottom: 1px solid #000; font-size: 10.5px;
}
.receipt-80mm td { padding: 3px 0; vertical-align: top; }
.receipt-80mm .r-sku { font-size: 9.5px; color: #333; }
.receipt-80mm .r-num { text-align: end; white-space: nowrap; }
.receipt-80mm .r-total {
  font-size: 14px; font-weight: 800;
  border-top: 1px solid #000; border-bottom: 3px double #000;
  padding: 4px 0; margin-top: 4px;
}
.receipt-80mm .r-foot { font-size: 10px; margin-top: 8px; }
.receipt-80mm .r-barcode {
  font-family: monospace; letter-spacing: 2px; font-size: 13px; margin-top: 6px;
}

/* On-screen preview: show the receipt on a paper-like card so what the
   cashier sees matches what the roll will produce. */
.receipt-preview {
  background: #fff;
  box-shadow: 0 2px 14px rgba(0,0,0,0.14);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 0;
  max-height: 58vh;
  overflow-y: auto;
}

@media print {
  @page { size: 80mm auto; margin: 0; }
  html, body { width: 80mm; margin: 0 !important; padding: 0 !important; background: #fff; }
  body * { visibility: hidden; }
  .receipt-80mm, .receipt-80mm * { visibility: visible; }
  .receipt-80mm {
    position: absolute; inset-inline-start: 0; top: 0;
    width: 72mm; max-height: none; overflow: visible;
    box-shadow: none; border: none; border-radius: 0; padding: 0 2mm;
  }
  .receipt-preview { max-height: none; overflow: visible; box-shadow: none; border: none; }
  .no-print, .modal-overlay, .modal-header, .modal-foot, .sidebar, .topbar,
  #toast-holder, #order-alert-holder, .sidebar-overlay { display: none !important; }
  .modal, .modal-body { box-shadow: none !important; border: none !important; padding: 0 !important; max-height: none !important; overflow: visible !important; }
  .modal-overlay { position: static !important; background: none !important; padding: 0 !important; display: block !important; }
}

/* ---------------- invoice ---------------- */
.invoice-head { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 14px; border-bottom: 2px dashed var(--border); margin-bottom: 14px; }
.invoice-brand { font-weight: 800; font-size: 17px; }
.invoice-meta { text-align: end; font-size: 12.5px; color: var(--ink-soft); }
.invoice-meta b { color: var(--ink); }
table.invoice-tbl { width: 100%; border-collapse: collapse; font-size: 12.8px; margin: 10px 0; }
table.invoice-tbl th { text-align: start; background: var(--bg); padding: 8px 10px; font-size: 11px; color: var(--muted); }
table.invoice-tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); }
.invoice-totals { margin-inline-start: auto; width: 260px; margin-top: 10px; }

/* ============================================================
   Mobile landscape (المود العرضي)
   ------------------------------------------------------------
   A phone held sideways has plenty of width but very little height, so the
   usual vertical stacking wastes the screen. Here we keep the POS grid
   side-by-side, shrink the chrome, and let the product grid and cart each
   scroll independently so the checkout button is always reachable without
   scrolling the whole page.
   ============================================================ */
@media (max-height: 560px) and (orientation: landscape) {
  :root { --topbar-h: 52px; }
  .main-content { padding: 12px 14px 24px; }
  .page-header { margin-bottom: 12px; }
  .page-title { font-size: 18px; }
  .page-sub { display: none; }

  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
  .kpi-card { padding: 10px 12px; }
  .kpi-icon { width: 28px; height: 28px; margin-bottom: 6px; border-radius: 8px; }
  .kpi-value { font-size: 18px; }
  .kpi-label { font-size: 11px; }

  /* POS stays two-column in landscape — that's the whole point of turning
     the phone sideways at the register. */
  .pos-grid { grid-template-columns: 1fr 290px; gap: 12px; align-items: stretch; }
  .pos-products { grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: calc(100vh - var(--topbar-h) - 150px); overflow-y: auto; }
  .pos-card { padding: 8px; gap: 5px; }
  .pos-card-thumb { height: 46px; font-size: 21px; }
  .pos-card-name { font-size: 11.5px; min-height: 28px; }
  .cart-panel { position: sticky; top: calc(var(--topbar-h) + 8px); max-height: calc(100vh - var(--topbar-h) - 24px); }
  .cart-items { max-height: 30vh; }
  .pos-toolbar { margin-bottom: 8px; }
  .pill-tabs { padding: 3px; }
  .pill-tab { padding: 5px 11px; font-size: 12px; }

  .modal { max-height: 94vh; }
  .modal-header { padding: 11px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 11px 16px; }
  .field { margin-bottom: 10px; }

  table.tbl th { padding: 8px 10px; }
  table.tbl td { padding: 8px 10px; }
  .two-col { grid-template-columns: 1fr 1fr; }
}

/* Touch targets: on any touch device make the interactive bits finger-sized
   without changing the desktop look. */
@media (pointer: coarse) {
  .chip { min-height: 42px; padding: 9px 15px; }
  .qty-stepper button { width: 32px; height: 32px; }
  .icon-btn { width: 42px; height: 42px; }
  .pay-method-btn { padding: 11px 5px; }
  .switch { width: 50px; height: 29px; }
  .switch-knob { width: 23px; height: 23px; }
  html[dir="rtl"] .switch.on .switch-knob { transform: translateX(-21px); }
  table.tbl td { padding: 14px; }
}
