/* ===============================================
   POS APPLICATION - REFINED UTILITARIAN DESIGN
   Professional, Cohesive, Business-Grade
   =============================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* -----------------------------------------------
   DESIGN TOKENS
   ----------------------------------------------- */
:root {
  /* Brand - the theme's primary color */
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-light: #eff6ff;
  --brand-50: #dbeafe;
  --brand-deep: #1e3a5f;

  /* Money / Success - always green for financial positivity */
  --money: #059669;
  --money-hover: #047857;
  --money-light: #ecfdf5;
  --money-dark: #064e3b;

  /* Danger - always red for destructive actions */
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: #fef2f2;

  /* Warning - always amber for caution */
  --warning: #d97706;
  --warning-hover: #b45309;
  --warning-light: #fffbeb;

  /* Neutral Palette */
  --slate-950: #020617;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;

  /* Semantic */
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-mid: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* Sidebar — deep shade of brand */
  --sidebar-bg: #0f2547;
  --sidebar-border: rgba(255,255,255,.08);
  --sidebar-text: #8ab4e8;
  --sidebar-text-hover: #c7ddf5;
  --sidebar-hover-bg: rgba(255,255,255,.07);
  --sidebar-active-bg: rgba(96,165,250,.2);
  --sidebar-active-text: #bfdbfe;
  --sidebar-active-icon: #60a5fa;
  --sidebar-section: #5b8cc5;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow: 0 4px 6px -1px rgba(15,23,42,.06), 0 2px 4px -2px rgba(15,23,42,.04);
  --shadow-md: 0 10px 15px -3px rgba(15,23,42,.06), 0 4px 6px -4px rgba(15,23,42,.03);
  --shadow-lg: 0 20px 25px -5px rgba(15,23,42,.08), 0 8px 10px -6px rgba(15,23,42,.04);

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* Type */
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;

  /* Motion */
  --ease: cubic-bezier(.4,0,.2,1);
  --speed: 180ms;

  /* Layout */
  --sidebar-w: 240px;
  --touch: 44px;

  /* Legacy aliases */
  --primary-color: var(--brand);
  --primary-dark: var(--brand-hover);
  --success-color: var(--money);
  --success-dark: var(--money-hover);
  --info-color: #0ea5e9;
  --warning-color: var(--warning);
  --danger-color: var(--danger);
  --light-bg: var(--slate-50);
  --text-primary: var(--slate-900);
  --text-secondary: var(--slate-500);
  --text-muted: var(--slate-400);
  --border-color: var(--border);
}

/* -----------------------------------------------
   THEMES — every theme is a complete, harmonious palette
   ----------------------------------------------- */

/* --- Steel: Grey sidebar + soft blue accents (2-3 muted colors) --- */
[data-theme="steel"] {
  --brand: #3a5fa8;
  --brand-hover: #2f4d8a;
  --brand-light: #f0f4fa;
  --brand-50: #e1e9f4;
  --brand-deep: #1e3a5f;
  --money: #2f6f4f;
  --money-hover: #245a3f;
  --money-light: #e6f4ec;
  --money-dark: #18603b;
  --warning: #b7791f;
  --warning-hover: #975a16;
  --warning-light: #fbeccc;
  --danger: #c53030;
  --danger-hover: #9b2c2c;
  --danger-light: #fde8e8;
  --info-color: #2c7a7b;
  --text-muted: #64748b;
  --sidebar-bg: #2d3748;
  --sidebar-border: rgba(255,255,255,.06);
  --sidebar-text: #a0aec0;
  --sidebar-text-hover: #cbd5e0;
  --sidebar-hover-bg: rgba(255,255,255,.04);
  --sidebar-active-bg: rgba(107,140,206,.15);
  --sidebar-active-text: #bfcfe8;
  --sidebar-active-icon: #8babd8;
  --sidebar-section: #a0aec0;
  --primary-color: var(--brand);
  --primary-dark: var(--brand-hover);
}
/* Steel: semantic text utilities (AA contrast on white) */
[data-theme="steel"] .text-primary { color: #3a5fa8 !important; }
[data-theme="steel"] .text-success { color: #2f6f4f !important; }
[data-theme="steel"] .text-info { color: #2c7a7b !important; }
[data-theme="steel"] .text-warning { color: #8a5a00 !important; }
[data-theme="steel"] .border-primary { border-color: #c7d5ea !important; }
[data-theme="steel"] .border-success { border-color: #c7d5ea !important; }
[data-theme="steel"] .border-info { border-color: #d1d5db !important; }
[data-theme="steel"] .border-warning { border-color: #c7d5ea !important; }

/* Steel: light card headers — soft tints, not bold colors */
[data-theme="steel"] .card-header.bg-primary {
  background: #e8eef6 !important;
  color: #4b5563 !important;
}
[data-theme="steel"] .card-header.bg-primary i { color: #6b8cce !important; }
[data-theme="steel"] .card-header.bg-success {
  background: #e8eef6 !important;
  color: #4b5563 !important;
}
[data-theme="steel"] .card-header.bg-success i { color: #6b8cce !important; }
[data-theme="steel"] .card-header.bg-info {
  background: #f1f5f9 !important;
  color: #4b5563 !important;
}
[data-theme="steel"] .card-header.bg-info i { color: #94a3b8 !important; }
[data-theme="steel"] .card-header.bg-warning {
  background: #e8eef6 !important;
  color: #4b5563 !important;
}
[data-theme="steel"] .card-header.bg-warning i { color: #7c9bd4 !important; }
[data-theme="steel"] .card-header.bg-secondary {
  background: #f1f5f9 !important;
  color: #4b5563 !important;
}
[data-theme="steel"] .card-header.bg-secondary i { color: #94a3b8 !important; }
[data-theme="steel"] .card-header.bg-dark {
  background: #e8eef6 !important;
  color: #4b5563 !important;
}
[data-theme="steel"] .card-header.bg-dark i { color: #6b8cce !important; }

/* Solid colored summary cards (e.g. Purchase Orders stat cards) — accessible
   backgrounds so their white text meets AA (Bootstrap's defaults don't). */
/* Use the `background` shorthand (not background-color) so it also clears any
   gradient background-image set by individual views, which often end in a
   too-light stop that fails contrast with the cards' white text. */
[data-theme="steel"] .card.bg-primary { background: #3a5fa8 !important; }
[data-theme="steel"] .card.bg-info { background: #2c7a7b !important; }
[data-theme="steel"] .card.bg-success { background: #2f855a !important; }
[data-theme="steel"] .card.bg-warning { background: #8a5a00 !important; }
[data-theme="steel"] .card.bg-danger { background: #c53030 !important; }
[data-theme="steel"] .card.bg-primary *, [data-theme="steel"] .card.bg-info *,
[data-theme="steel"] .card.bg-success *, [data-theme="steel"] .card.bg-warning *,
[data-theme="steel"] .card.bg-danger * { color: #fff !important; }

/* SKU / inline code: readable neutral chip instead of Bootstrap's pink */
code {
  color: #334155;
  background: var(--slate-100);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .85em;
}

/* Steel: soft, pill-shaped buttons */
[data-theme="steel"] .btn {
  border-radius: 9999px;
  font-weight: 500;
  letter-spacing: .01em;
  box-shadow: none;
}
[data-theme="steel"] .btn-primary {
  background: #3a5fa8 !important;
  border-color: #3a5fa8 !important;
  color: #fff !important;
}
[data-theme="steel"] .btn-primary:hover:not(:disabled) {
  background: #2f4d8a !important;
  border-color: #2f4d8a !important;
  box-shadow: 0 2px 8px rgba(58,95,168,.3);
}
[data-theme="steel"] .btn-success {
  background: #2f855a !important;
  color: #fff !important;
  border-color: #2f855a !important;
}
[data-theme="steel"] .btn-success:hover:not(:disabled) {
  background: #276749 !important;
  color: #fff !important;
  border-color: #276749 !important;
  box-shadow: none;
}
[data-theme="steel"] .btn-info {
  background: #2c7a7b !important;
  color: #fff !important;
  border-color: #2c7a7b !important;
}
[data-theme="steel"] .btn-info:hover:not(:disabled) {
  background: #236566 !important;
  color: #fff !important;
  border-color: #236566 !important;
  box-shadow: none;
}
[data-theme="steel"] .btn-warning {
  background: #d69e2e !important;
  color: #1a202c !important;
  border-color: #d69e2e !important;
}
[data-theme="steel"] .btn-warning:hover:not(:disabled) {
  background: #b7791f !important;
  color: #1a202c !important;
  border-color: #b7791f !important;
  box-shadow: none;
}
[data-theme="steel"] .btn-dark {
  background: #4b5563 !important;
  border-color: #4b5563 !important;
}
[data-theme="steel"] .btn-dark:hover:not(:disabled) {
  background: #374151 !important;
  border-color: #374151 !important;
  box-shadow: 0 2px 8px rgba(75,85,99,.2);
}
[data-theme="steel"] .btn-secondary {
  background: #fff !important;
  color: #6b7280 !important;
  border-color: #e5e7eb !important;
}
[data-theme="steel"] .btn-secondary:hover:not(:disabled) {
  background: #f9fafb !important;
  color: #374151 !important;
  border-color: #d1d5db !important;
}
[data-theme="steel"] .btn-danger {
  background: #fde8e8 !important;
  color: #c53030 !important;
  border-color: #f5c6c6 !important;
}
[data-theme="steel"] .btn-danger:hover:not(:disabled) {
  background: #e87171 !important;
  color: #fff !important;
  border-color: #e87171 !important;
}
[data-theme="steel"] .btn-outline-primary {
  border: 1.5px solid #3a5fa8 !important;
  color: #3a5fa8 !important;
  background: transparent !important;
}
[data-theme="steel"] .btn-outline-primary:hover:not(:disabled) {
  background: #3a5fa8 !important;
  color: #fff !important;
  border-color: #3a5fa8 !important;
}
[data-theme="steel"] .btn-outline-success {
  border: 1.5px solid #2f855a !important;
  color: #2f6f4f !important;
  background: transparent !important;
}
[data-theme="steel"] .btn-outline-success:hover:not(:disabled) {
  background: #2f855a !important; color: #fff !important; border-color: #2f855a !important;
}
[data-theme="steel"] .btn-outline-info {
  border: 1.5px solid #2c7a7b !important;
  color: #2c7a7b !important;
  background: transparent !important;
}
[data-theme="steel"] .btn-outline-info:hover:not(:disabled) {
  background: #2c7a7b !important; color: #fff !important; border-color: #2c7a7b !important;
}
[data-theme="steel"] .btn-outline-warning {
  border: 1.5px solid #b7791f !important;
  color: #8a5a00 !important;
  background: transparent !important;
}
[data-theme="steel"] .btn-outline-warning:hover:not(:disabled) {
  background: #b7791f !important; color: #fff !important; border-color: #b7791f !important;
}
[data-theme="steel"] .btn-outline-danger {
  border: 1.5px solid #f5c6c6 !important;
  color: #c53030 !important;
  background: transparent !important;
}
[data-theme="steel"] .btn-outline-danger:hover:not(:disabled) {
  background: #fde8e8 !important;
  color: #b91c1c !important;
  border-color: #e87171 !important;
}
[data-theme="steel"] .btn-sm {
  border-radius: 9999px;
  padding: 4px 12px;
}

/* Steel: these list tables render a DARK gradient header (set in each view's
   own CSS), so their column titles must be WHITE. The previous rule forced
   dark slate text on the dark header => unreadable column titles. */
[data-theme="steel"] .products-table thead th,
[data-theme="steel"] .table thead.bg-primary th,
[data-theme="steel"] .customers-table thead th,
[data-theme="steel"] .orders-table thead th,
[data-theme="steel"] .suppliers-table thead th,
[data-theme="steel"] .invoices-table thead th {
  color: #fff !important;
}

/* Steel: muted stat cards */
[data-theme="steel"] .stat-card.bg-primary { background: #e1e9f4 !important; color: #4b5563 !important; }
[data-theme="steel"] .stat-card.bg-success { background: #e8eef6 !important; color: #4b5563 !important; }
[data-theme="steel"] .stat-card.bg-info { background: #f1f5f9 !important; color: #4b5563 !important; }
[data-theme="steel"] .stat-card.bg-warning { background: #edf2fa !important; color: #4b5563 !important; }
/* secondary + danger were missing — without a light bg, the forced dark text below failed AA
   (e.g. dark text on #6c757d ≈ 3.1:1). Give them light tints like the others. */
[data-theme="steel"] .stat-card.bg-secondary { background: #e9edf2 !important; color: #4b5563 !important; }
[data-theme="steel"] .stat-card.bg-danger { background: #f6e7ea !important; color: #4b5563 !important; }
[data-theme="steel"] .stat-card .stat-icon { color: #a8bdd8 !important; }
/* When a stat-card ALSO carries the generic .card class, the `.card.bg-* *` rule
   (which assumes a dark card background) would force its text white — but stat-cards
   have a LIGHT steel background, so that text becomes invisible. Force the numbers and
   labels back to dark. Specificity (0,4,0) beats `.card.bg-* *` (0,3,0). */
[data-theme="steel"] .stat-card[class*="bg-"] .stat-number,
[data-theme="steel"] .stat-card[class*="bg-"] .stat-label,
[data-theme="steel"] .stat-card[class*="bg-"] .card-body { color: #1f2937 !important; }

/* Steel: soft, readable badge colors (AA contrast). !important overrides Bootstrap's
   .bg-* utilities which otherwise force a solid background and clash with the text color. */
[data-theme="steel"] .badge.bg-success,
[data-theme="steel"] .badge-success { background: #d6f0e0 !important; color: #18603b !important; }
[data-theme="steel"] .badge.bg-info,
[data-theme="steel"] .badge-info { background: #d9e6f7 !important; color: #2c5390 !important; }
[data-theme="steel"] .badge.bg-secondary,
[data-theme="steel"] .badge-secondary { background: #e7ebf0 !important; color: #475569 !important; }
[data-theme="steel"] .badge.bg-warning,
[data-theme="steel"] .badge-warning { background: #fbeccc !important; color: #8a5a00 !important; }
[data-theme="steel"] .badge.bg-danger,
[data-theme="steel"] .badge-danger { background: #fbdada !important; color: #b02525 !important; }
[data-theme="steel"] .badge.bg-primary,
[data-theme="steel"] .badge-primary { background: #dce6f6 !important; color: #2f4d8a !important; }

/* -----------------------------------------------
   RESET
   ----------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  font-size: .875rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

/* -----------------------------------------------
   APP SHELL
   ----------------------------------------------- */
.app-layout { display: flex; min-height: 100vh; }

/* -----------------------------------------------
   SIDEBAR
   ----------------------------------------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform var(--speed) var(--ease);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  text-decoration: none;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: var(--brand);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: .95rem;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--white);
  letter-spacing: -.02em;
}

.sidebar-brand-text span { color: var(--sidebar-text); font-weight: 600; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--sidebar-section);
  padding: 18px 10px 6px;
  white-space: nowrap;
}

.nav-item { list-style: none; margin-bottom: 1px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: .8125rem;
  transition: all var(--speed) var(--ease);
  white-space: nowrap;
  min-height: 38px;
}

.nav-link i {
  width: 18px;
  text-align: center;
  font-size: .9rem;
  flex-shrink: 0;
  opacity: .7;
}

.nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
}

.nav-link:hover i { opacity: 1; }

.nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.nav-link.active i { opacity: 1; color: var(--sidebar-active-icon); }

/* POS Launch Button */
.nav-link.pos-link {
  background: var(--brand);
  color: var(--white);
  font-weight: 700;
  font-size: .8125rem;
  margin: 4px 0 6px;
  padding: 10px;
}

.nav-link.pos-link i { opacity: 1; color: var(--white); }

.nav-link.pos-link:hover {
  background: var(--brand-hover);
  color: var(--white);
}

/* Bootstrap tabs/pills (e.g. Product Details) must NOT inherit the sidebar's
   light-on-dark .nav-link colors — they sit on light card headers. */
.nav-tabs .nav-link,
.nav-pills .nav-link,
.card-header-tabs .nav-link {
  color: var(--slate-600);
  background: transparent;
  font-weight: 600;
  border-radius: var(--r-sm);
}
.nav-tabs .nav-link:hover,
.nav-pills .nav-link:hover,
.card-header-tabs .nav-link:hover {
  color: var(--brand);
  background: var(--slate-50);
}
.nav-tabs .nav-link.active,
.card-header-tabs .nav-link.active {
  color: var(--brand);
  background: var(--surface);
  border-color: var(--border) var(--border) var(--white);
  font-weight: 700;
}
.nav-pills .nav-link.active {
  color: #fff;
  background: var(--brand);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

/* Sidebar user box + logout */
.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--sidebar-hover-bg); color: var(--sidebar-text);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-user-meta { display: flex; flex-direction: column; overflow: hidden; }
.sidebar-user-name { color: var(--white); font-weight: 600; font-size: .8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: var(--sidebar-section); font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; }
.sidebar-logout-form { margin: 0; }
.sidebar-logout-btn {
  width: 100%; display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 8px 10px; border-radius: var(--r-sm);
  background: transparent; color: var(--sidebar-text);
  border: 1px solid var(--sidebar-border); cursor: pointer;
  font-size: .8125rem; font-weight: 600; transition: all var(--speed) var(--ease);
}
.sidebar-logout-btn:hover { background: var(--sidebar-hover-bg); color: var(--white); }

/* -----------------------------------------------
   SIDEBAR OVERLAY (mobile)
   ----------------------------------------------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 1039;
}

.sidebar-overlay.show { display: block; }

/* -----------------------------------------------
   TOPBAR (mobile/tablet)
   ----------------------------------------------- */
.topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 1030;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
}

.topbar-toggle {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--slate-600);
  font-size: 1rem;
  cursor: pointer;
}

.topbar-toggle:hover { background: var(--slate-50); }

.topbar-brand { font-weight: 700; font-size: 1rem; color: var(--slate-900); }
.topbar-brand span { color: var(--brand); }

/* -----------------------------------------------
   MAIN CONTENT
   ----------------------------------------------- */
.main-content {
  flex: 1;
  /* min-width:0 lets this flex item shrink below its content's intrinsic width,
     so wide tables scroll inside .table-responsive instead of overflowing the page. */
  min-width: 0;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left var(--speed) var(--ease);
}

.main-content > .container { max-width: 100%; padding: 0; min-width: 0; }
.main-content > .container > main { padding: 0; }

.page-container {
  padding: 24px 28px;
  max-width: 1400px;
  margin: 0 auto;
}

/* -----------------------------------------------
   PAGE HEADER
   ----------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--slate-900);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -.02em;
}

.page-title i { color: var(--brand); font-size: 1.125rem; }

/* -----------------------------------------------
   CARDS
   ----------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 16px;
  overflow: hidden;
  transition: box-shadow var(--speed) var(--ease);
}

.card:hover { box-shadow: var(--shadow-sm); }

.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 700;
  font-size: .875rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header h2, .card-header h3, .card-header h4, .card-header h5 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  color: inherit !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header i { font-size: 1.0625rem; }

/* Colored card headers — use brand-harmonious colors */
.card-header.bg-primary {
  background: var(--brand-deep) !important;
  color: #fff !important;
  border-bottom: none;
}
.card-header.bg-primary i { color: rgba(255,255,255,.8) !important; opacity: 1; }

.card-header.bg-success {
  background: var(--money-dark, #064e3b) !important;
  color: #fff !important;
  border-bottom: none;
}
.card-header.bg-success i { color: rgba(255,255,255,.8) !important; opacity: 1; }

.card-header.bg-info {
  background: var(--brand) !important;
  color: #fff !important;
  border-bottom: none;
}
.card-header.bg-info i { color: rgba(255,255,255,.8) !important; opacity: 1; }

.card-header.bg-warning {
  background: var(--warning-hover, #b45309) !important;
  color: #fff !important;
  border-bottom: none;
}
.card-header.bg-warning i { color: rgba(255,255,255,.8) !important; opacity: 1; }

.card-header.bg-secondary {
  background: var(--sidebar-bg) !important;
  color: #fff !important;
  border-bottom: none;
}
.card-header.bg-secondary i { color: var(--sidebar-text) !important; opacity: 1; }

.card-header.bg-dark {
  background: var(--brand-deep) !important;
  color: #fff !important;
  border-bottom: none;
}
.card-header.bg-dark i { color: rgba(255,255,255,.7) !important; opacity: 1; }

.card-body { padding: 18px; }

.card-footer {
  background: var(--slate-50);
  border-top: 1px solid var(--border);
  padding: 12px 18px;
}

/* Dashboard Cards */
.dashboard-card {
  height: 100%;
  transition: all var(--speed) var(--ease);
  border: 1px solid var(--border);
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.dashboard-card .card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 160px;
}

.dashboard-card .card-body p {
  color: var(--slate-600);
  flex-grow: 1;
  margin: 0;
  font-size: .875rem;
  line-height: 1.6;
}

/* -----------------------------------------------
   BUTTONS
   ----------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  min-height: var(--touch);
  white-space: nowrap;
  font-family: inherit;
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn:disabled, .btn.disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn i { font-size: .875rem; }

/* Action buttons — each uses its semantic color */
.btn-primary {
  background: var(--brand) !important;
  color: #fff !important;
  border-color: var(--brand) !important;
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover) !important;
  color: #fff !important;
  border-color: var(--brand-hover) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.btn-success {
  background: var(--money) !important;
  color: #fff !important;
  border-color: var(--money) !important;
}
.btn-success:hover:not(:disabled) {
  background: var(--money-hover) !important;
  color: #fff !important;
  border-color: var(--money-hover) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.btn-info {
  background: var(--brand-deep) !important;
  color: #fff !important;
  border-color: var(--brand-deep) !important;
}
.btn-info:hover:not(:disabled) {
  background: var(--brand) !important;
  color: #fff !important;
  border-color: var(--brand) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.btn-warning {
  background: var(--warning) !important;
  color: #fff !important;
  border-color: var(--warning) !important;
}
.btn-warning:hover:not(:disabled) {
  background: var(--warning-hover) !important;
  color: #fff !important;
  border-color: var(--warning-hover) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.btn-dark {
  background: var(--brand-deep) !important;
  color: #fff !important;
  border-color: var(--brand-deep) !important;
}
.btn-dark:hover:not(:disabled) {
  background: var(--sidebar-bg) !important;
  color: #fff !important;
  border-color: var(--sidebar-bg) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

/* Danger stays red for destructive actions */
.btn-danger {
  background: var(--danger) !important;
  color: var(--white) !important;
  border-color: var(--danger) !important;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover) !important;
  color: var(--white) !important;
  border-color: var(--danger-hover) !important;
}

/* Secondary - Neutral outline */
.btn-secondary {
  background: var(--surface) !important;
  color: var(--slate-700) !important;
  border-color: var(--border) !important;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--slate-50) !important;
  border-color: var(--slate-300) !important;
}

/* Light */
.btn-light {
  background: var(--slate-100) !important;
  color: var(--slate-600) !important;
  border-color: var(--slate-200) !important;
}
.btn-light:hover:not(:disabled) {
  background: var(--slate-200) !important;
  color: var(--slate-700) !important;
}

/* Outline buttons — subtle with brand-aware hovers */
.btn-outline-primary {
  background: transparent !important;
  color: var(--brand) !important;
  border: 1.5px solid var(--brand) !important;
}
.btn-outline-primary:hover:not(:disabled) {
  background: var(--brand) !important;
  color: #fff !important;
  border-color: var(--brand) !important;
}

.btn-outline-success {
  background: transparent !important;
  color: var(--money) !important;
  border: 1.5px solid var(--money) !important;
}
.btn-outline-success:hover:not(:disabled) {
  background: var(--money) !important;
  color: #fff !important;
  border-color: var(--money) !important;
}

.btn-outline-info {
  background: transparent !important;
  color: var(--brand-deep) !important;
  border: 1.5px solid var(--brand-deep) !important;
}
.btn-outline-info:hover:not(:disabled) {
  background: var(--brand-deep) !important;
  color: #fff !important;
  border-color: var(--brand-deep) !important;
}

.btn-outline-warning {
  background: transparent !important;
  color: var(--warning) !important;
  border: 1.5px solid var(--warning) !important;
}
.btn-outline-warning:hover:not(:disabled) {
  background: var(--warning) !important;
  color: #fff !important;
  border-color: var(--warning) !important;
}

/* Outline danger - subtle red for alerts */
.btn-outline-danger {
  background: transparent !important;
  color: var(--danger) !important;
  border: 1.5px solid #fecaca !important;
}
.btn-outline-danger:hover:not(:disabled) {
  background: var(--danger-light) !important;
  color: var(--danger-hover) !important;
  border-color: var(--danger) !important;
}

/* Sizes */
.btn-sm {
  padding: 5px 10px;
  font-size: .75rem;
  min-height: 32px;
  border-radius: var(--r-xs);
}
.btn-sm i { font-size: .8125rem; }

.btn-lg {
  padding: 11px 22px;
  font-size: .9375rem;
  min-height: 48px;
  border-radius: var(--r);
}

.btn-block { width: 100%; display: flex; }

/* -----------------------------------------------
   FORMS
   ----------------------------------------------- */
.form-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  font-size: .75rem;
  color: var(--slate-600);
  letter-spacing: .02em;
}

.form-control, .form-select, select.form-control {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: .8125rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
  min-height: var(--touch);
  font-family: inherit;
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-light);
}

.form-control::placeholder { color: var(--slate-400); }
.form-group { margin-bottom: 14px; }
.form-text { display: block; margin-top: 4px; font-size: .75rem; color: var(--text-mid); }

/* Input Group */
.input-group { display: flex; width: 100%; }

.input-group-text {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-mid);
  background: var(--slate-50);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
}

.input-group-prepend .input-group-text {
  border-right: none;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}

.input-group-append .input-group-text {
  border-left: none;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.input-group .form-control { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

textarea.form-control { min-height: 100px; resize: vertical; }

/* -----------------------------------------------
   TABLES
   ----------------------------------------------- */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-md);
}

.table {
  width: 100%;
  margin-bottom: 0;
  color: var(--text);
  background: var(--surface);
  border-collapse: collapse;
}

.table thead {
  background: var(--slate-50);
}

.table thead th {
  background: inherit;
  color: var(--slate-600);
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-size: .8125rem;
}

.table tbody tr { transition: background var(--speed) var(--ease); }
.table-hover tbody tr:hover { background: var(--slate-50); }

.products-table thead,
.table thead.bg-primary {
  background: var(--brand-deep);
}

.products-table thead th,
.table thead.bg-primary th {
  color: var(--white) !important;
  border-bottom: none;
}

/* Mobile table */
@media (max-width: 767px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
  }
  .table-stack td {
    text-align: right;
    padding: 6px 10px;
    padding-left: 45%;
    position: relative;
    border: none;
  }
  .table-stack td::before {
    content: attr(data-label);
    position: absolute;
    left: 10px;
    font-weight: 700;
    text-transform: uppercase;
    font-size: .625rem;
    color: var(--text-mid);
    letter-spacing: .04em;
  }
}

/* -----------------------------------------------
   BADGES
   ----------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  font-size: .6875rem;
  font-weight: 700;
  line-height: 1.4;
  border-radius: var(--r-full);
  letter-spacing: .01em;
}

.badge-primary, .bg-primary.badge { background: var(--brand-light); color: var(--brand); }
.badge-success, .bg-success.badge { background: var(--money-light); color: var(--money); }
.badge-danger, .bg-danger.badge { background: var(--danger-light); color: var(--danger); }
.badge-warning, .bg-warning.badge { background: var(--warning-light); color: var(--warning); }
.badge-info, .bg-info.badge { background: var(--brand-light); color: var(--brand); }
.badge-secondary { background: var(--slate-100); color: var(--slate-600); }
.badge-light { background: var(--slate-100); color: var(--slate-600); }
.badge-dark { background: var(--slate-800); color: var(--white); }

/* -----------------------------------------------
   ALERTS
   ----------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--r);
  border-left: 3px solid;
  margin-bottom: 14px;
  display: flex;
  align-items: start;
  gap: 8px;
  font-size: .8125rem;
}

.alert-success { background: var(--money-light); color: var(--money-dark); border-left-color: var(--money); }
.alert-danger { background: var(--danger-light); color: var(--danger-hover); border-left-color: var(--danger); }
.alert-warning { background: var(--warning-light); color: var(--warning-hover); border-left-color: var(--warning); }
.alert-info { background: var(--brand-light); color: var(--brand-hover); border-left-color: var(--brand); }

/* -----------------------------------------------
   MODALS
   ----------------------------------------------- */
.modal-content {
  border: none;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  background: var(--brand-deep);
  color: #fff;
  padding: 16px 20px;
  border-bottom: none;
}

.modal-header .modal-title { color: #fff; font-weight: 700; font-size: 1rem; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); gap: 6px; }
.btn-close { filter: brightness(0) invert(1); }

/* -----------------------------------------------
   TYPOGRAPHY
   ----------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--slate-900);
  margin-top: 0;
  margin-bottom: 14px;
  letter-spacing: -.02em;
}

h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.0625rem; }
h5 { font-size: .9375rem; }
h6 { font-size: .8125rem; }

.display-4 { font-size: 2rem; font-weight: 800; line-height: 1.1; letter-spacing: -.03em; }
.lead { font-size: 1.0625rem; font-weight: 400; color: var(--text-mid); }
p { margin-top: 0; margin-bottom: 10px; }

@media (max-width: 767px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  .display-4 { font-size: 1.5rem; }
  .lead { font-size: .9375rem; }
}

/* -----------------------------------------------
   UTILITIES
   ----------------------------------------------- */
.text-primary { color: var(--brand) !important; }
.text-success { color: var(--money) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--brand) !important; }
.text-muted { color: var(--text-mid) !important; }
.text-secondary { color: var(--text-mid) !important; }
.text-white { color: var(--white) !important; }
.text-dark { color: var(--slate-900) !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.bg-light { background-color: var(--slate-50) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-5 { margin-bottom: 20px !important; }
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mt-5 { margin-top: 20px !important; }
.mt-auto { margin-top: auto !important; }
.pb-3 { padding-bottom: 12px !important; }
.list-unstyled { list-style: none; padding-left: 0; }

/* -----------------------------------------------
   SCROLLBAR
   ----------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

/* -----------------------------------------------
   ANIMATIONS
   ----------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

.fade-in { animation: fadeIn .3s var(--ease) both; }
.slide-up { animation: fadeIn .3s var(--ease) both; }

/* -----------------------------------------------
   STAT CARDS (Dashboard)
   ----------------------------------------------- */
.stat-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--speed) var(--ease);
  text-decoration: none;
}

.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.stat-icon.primary { background: var(--brand-light); color: var(--brand); }
.stat-icon.success { background: var(--money-light); color: var(--money); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.info { background: var(--brand-light); color: var(--brand); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }

.stat-content { flex: 1; min-width: 0; }
.stat-value { font-size: 1.125rem; font-weight: 800; color: var(--slate-900); line-height: 1.2; letter-spacing: -.01em; }
.stat-label { font-size: .7rem; color: #475569; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }

/* KPI / valuation cards — clean white card + colored icon chip (consistent across themes) */
.val-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; height: 100%;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 14px;
    box-shadow: 0 1px 2px rgba(16,24,40,.05);
    transition: box-shadow .15s ease, transform .15s ease;
}
.val-card:hover { box-shadow: 0 4px 12px rgba(16,24,40,.10); transform: translateY(-1px); }
.val-icon {
    width: 46px; height: 46px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px; font-size: 1.15rem;
}
.val-body { min-width: 0; }
.val-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: #64748b; margin-bottom: 2px; }
.val-number { font-size: 1.3rem; font-weight: 800; color: #1f2937; line-height: 1.15; white-space: nowrap; }
.val-sub { font-size: .72rem; font-weight: 700; color: #15803d; margin-top: 1px; }
/* Subtle developer credit shown at the bottom of every app page */
.app-credit { text-align: center; padding: 14px 12px 18px; font-size: .72rem; color: #5b6470; letter-spacing: .02em; }

/* Caisse.pro "Cp" brand mark (inline SVG) */
.cp-mark { display: block; width: 100%; height: 100%; }
.sidebar-brand-mark { width: 38px; height: 38px; flex: 0 0 auto; display: inline-flex; }
.brand-mark-sm { width: 26px; height: 26px; flex: 0 0 auto; display: inline-flex; vertical-align: middle; margin-inline-end: 8px; }
.topbar-brand { display: inline-flex; align-items: center; }
.val-units  .val-icon { background: #eef2f7; color: #475569; }
.val-cost   .val-icon { background: #fef3e2; color: #d97706; }
.val-retail .val-icon { background: #e7f0fb; color: #2563eb; }
.val-profit .val-icon { background: #e7f6ec; color: #16a34a; }
@media (max-width: 575.98px) {
    .val-card { padding: 10px 12px; gap: 10px; }
    .val-icon { width: 38px; height: 38px; font-size: 1rem; }
    .val-number { font-size: 1.05rem; }
}
[dir="rtl"] .val-card { text-align: right; }

/* Variant attribute value list (reorderable) */
.value-list .value-row { padding: 4px 0; border-bottom: 1px solid var(--border-light); }
.value-list .value-row:last-child { border-bottom: 0; }
.value-reorder .btn[disabled] { opacity: .35; }

/* -----------------------------------------------
   POS TERMINAL
   ----------------------------------------------- */

/* POS hides sidebar for full-screen experience */
.pos-fullscreen .sidebar { transform: translateX(-100%); }
.pos-fullscreen .main-content { margin-left: 0; }
.pos-fullscreen .topbar { display: flex; }

/* RTL: POS sidebar off-screen to the right */
[dir="rtl"] .pos-fullscreen .sidebar { transform: translateX(100%); }
[dir="rtl"] .pos-fullscreen .main-content { margin-right: 0; }

/* Auto-detect POS page via :has() and hide sidebar */
.app-layout:has(.pos-layout) .sidebar { transform: translateX(-100%); }
.app-layout:has(.pos-layout) .main-content { margin-left: 0; }
[dir="rtl"] .app-layout:has(.pos-layout) .sidebar { transform: translateX(100%); }
[dir="rtl"] .app-layout:has(.pos-layout) .main-content { margin-right: 0; }
.app-layout:has(.pos-layout) ~ .topbar,
.app-layout:has(.pos-layout) + .topbar { display: flex; }

/* Show topbar on POS page */
body:has(.pos-layout) .topbar { display: flex !important; }
body:has(.pos-layout) .main-content { margin-left: 0 !important; padding-top: 52px; }

/* Hamburger toggle must reveal the sidebar at ANY width.
   Without this, the .open class only worked inside the ≤991px media query,
   so on the POS page (sidebar hidden by .pos-fullscreen / :has(.pos-layout))
   the toggle did nothing on desktop. !important beats those higher-specificity
   rules regardless of viewport width. */
.sidebar.open { transform: translateX(0) !important; }
[dir="rtl"] .sidebar.open { transform: translateX(0) !important; }

.pos-layout {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* Products Panel */
.pos-products {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
}

.pos-search {
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.pos-search .search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
}
.pos-returns-btn { white-space: nowrap; flex: 0 0 auto; }
@media (max-width: 640px) { .pos-returns-label { display: none; } }

.pos-search .search-icon {
  position: absolute;
  left: 12px;
  color: var(--slate-400);
  font-size: .9rem;
  pointer-events: none;
}

.pos-search .barcode-icon {
  position: absolute;
  right: 12px;
  color: var(--slate-300);
  font-size: .9rem;
  pointer-events: none;
}

.pos-search input {
  padding-left: 38px;
  padding-right: 38px;
  border-radius: var(--r);
  background: var(--slate-50);
  border-color: var(--slate-200);
  font-size: .875rem;
  height: 44px;
}

.pos-search input:focus {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

/* Product Grid */
.pos-product-grid {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  grid-auto-rows: min-content; /* rows size to image + info so nothing is clipped */
  gap: 10px;
  align-content: start;
}

/* ---- POS quick-access section tabs ---- */
.pos-section-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 18px 0;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: thin;
}
.section-tab {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--slate-600);
  font-size: .8125rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--speed) var(--ease);
}
.section-tab:hover { border-color: var(--brand); color: var(--brand); }
.section-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.section-tab-add { color: var(--brand); font-weight: 700; padding: 6px 12px; }
.section-new-input {
  border: 1px solid var(--brand) !important;
  outline: none;
  min-width: 130px;
  color: var(--slate-800);
}

/* ---- Star toggle on product cards ---- */
.section-star {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 2;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  color: var(--slate-400);
  font-size: .75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: all var(--speed) var(--ease);
}
.section-star:hover { color: #d69e2e; transform: scale(1.1); }
.section-star.active { color: #d69e2e; }

/* ---- Floating section toggle menu ---- */
.section-menu {
  position: fixed;
  z-index: 1060;
  width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  padding: 8px;
}
.section-menu-title { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-500); padding: 4px 6px 8px; }
.section-menu-item { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: var(--r-sm); cursor: pointer; font-size: .8125rem; color: var(--slate-700); margin: 0; }
.section-menu-item:hover { background: var(--slate-50); }
.section-menu-empty { font-size: .8125rem; color: var(--slate-500); padding: 6px; }

/* Product Card */
.pos-product-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pos-product-card:hover {
  border-color: var(--slate-400);
  box-shadow: var(--shadow);
}

.pos-product-card.out-of-stock {
  opacity: .45;
  pointer-events: none;
}

.pos-product-card .product-img {
  height: 110px;
  flex: 0 0 110px; /* don't let the grid row shrink the image area to nothing */
  background: var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.pos-product-card .product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pos-product-card .product-img .no-img {
  color: var(--slate-300);
  font-size: 1.5rem;
}

.pos-product-card .variant-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background: var(--brand-deep);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--r-full);
}

.pos-product-card .product-info {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
}

.pos-product-card .product-name {
  font-weight: 600;
  font-size: .75rem;
  color: var(--slate-700);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pos-product-card .product-price {
  font-weight: 800;
  font-size: .9375rem;
  color: var(--slate-900);
  letter-spacing: -.01em;
}

.pos-product-card .product-stock {
  font-size: .625rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.pos-product-card .product-stock .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--money);
  flex-shrink: 0;
}
.pos-product-card .product-stock .dot.low { background: var(--warning); }
.pos-product-card .product-stock .dot.out { background: var(--danger); }
.pos-product-card .product-expired {
  font-size: .625rem;
  font-weight: 700;
  color: var(--danger);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* -----------------------------------------------
   CART PANEL
   ----------------------------------------------- */
.pos-cart {
  width: 360px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
  overflow: hidden; /* contain the scrollable items list; footer never overflows the viewport */
}

.pos-cart-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.pos-cart-header h3 {
  margin: 0;
  font-size: .9375rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--slate-800);
}

.pos-cart-header h3 i { color: var(--slate-500); font-size: .9rem; }

.cart-badge {
  background: var(--slate-100);
  color: var(--slate-600);
  font-size: .6875rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
}

/* Cart Items */
.pos-cart-items {
  flex: 1;
  min-height: 0; /* allow the list to shrink & scroll so the footer (Review/Hold/Clear) stays visible */
  overflow-y: auto;
  padding: 0;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--speed) var(--ease);
}

.cart-item:hover { background: var(--slate-50); }

/* Brief highlight when +/- keyboard shortcut bumps a line's quantity */
.cart-item.qty-bump { background: #fff3cd; }

.cart-item-info { flex: 1; min-width: 0; }

.cart-item-name {
  font-weight: 600;
  font-size: .75rem;
  color: var(--slate-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-variant { font-size: .6875rem; color: var(--text-muted); }

.cart-item-price { font-size: .6875rem; color: var(--slate-500); }

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.cart-item-qty .qty-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-100);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--slate-600);
  font-size: .625rem;
  transition: all var(--speed) var(--ease);
  padding: 0;
}

.cart-item-qty .qty-btn:first-child { border-radius: var(--r-xs) 0 0 var(--r-xs); }
.cart-item-qty .qty-btn:last-child { border-radius: 0 var(--r-xs) var(--r-xs) 0; }

.cart-item-qty .qty-btn:hover {
  background: var(--slate-200);
  color: var(--slate-800);
}

.cart-item-qty .qty-value {
  width: 34px;
  height: 26px;
  text-align: center;
  font-weight: 700;
  font-size: .75rem;
  color: var(--text);
  border: 1px solid var(--border);
  border-left: none;
  border-right: none;
  border-radius: 0;
  padding: 0;
  background: var(--surface);
  font-family: inherit;
}

.cart-item-total {
  font-weight: 700;
  font-size: .8125rem;
  color: var(--slate-800);
  min-width: 58px;
  text-align: right;
  flex-shrink: 0;
}

.cart-item-remove {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--slate-300);
  cursor: pointer;
  border-radius: var(--r-xs);
  transition: all var(--speed) var(--ease);
  flex-shrink: 0;
  padding: 0;
  font-size: .75rem;
}

.cart-item-remove:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Empty Cart */
.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 18px;
  text-align: center;
  flex: 1;
}

.cart-empty i {
  font-size: 2.5rem;
  color: var(--slate-200);
  margin-bottom: 10px;
}

.cart-empty p {
  color: var(--text-muted);
  font-size: .8125rem;
  margin: 0;
}

/* Cart Footer */
.pos-cart-footer {
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  flex-shrink: 0;
  background: var(--slate-50);
}

.cart-customer { margin-bottom: 10px; }
.cart-customer label { margin-bottom: 3px; }
.cart-customer select {
  font-size: .75rem;
  padding: 7px 10px;
  min-height: 36px;
}

.cart-discount { margin-bottom: 10px; }
.cart-discount label { margin-bottom: 3px; }
.cart-discount .input-group input {
  min-height: 36px;
  font-size: .75rem;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}
.cart-discount .input-group select {
  min-height: 36px;
  font-size: .75rem;
  max-width: 56px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  border-left: none;
}

/* Totals */
.totals-section {
  background: var(--surface);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  font-size: .75rem;
  color: var(--slate-500);
  font-weight: 500;
}

.totals-row.discount { color: var(--danger); }

.totals-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

.totals-row.grand-total {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--slate-900);
  padding: 3px 0 0;
  letter-spacing: -.01em;
}

.totals-row.grand-total .total-amount { color: var(--money); }

/* Cart Action Buttons */
.cart-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cart-actions .btn-process {
  background: var(--money) !important;
  color: var(--white) !important;
  font-weight: 700;
  font-size: .9375rem;
  padding: 13px;
  border-radius: var(--r);
  border: none !important;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-family: inherit;
  letter-spacing: -.01em;
}

.cart-actions .btn-process:hover:not(:disabled) {
  background: var(--money-hover) !important;
  box-shadow: 0 2px 8px rgba(5,150,105,.25);
}

.cart-actions .btn-process:disabled {
  opacity: .35;
  cursor: not-allowed;
}

/* Override unified button style for POS action-specific buttons */
.cart-actions .action-row .btn-warning {
  background: var(--warning) !important;
  border-color: var(--warning) !important;
}
.cart-actions .action-row .btn-warning:hover:not(:disabled) {
  background: var(--warning-hover) !important;
  border-color: var(--warning-hover) !important;
}

.cart-actions .action-row {
  display: flex;
  gap: 6px;
}

.cart-actions .action-row .btn {
  flex: 1;
  font-size: .75rem;
  min-height: 38px;
}

/* Held Sales */
.held-sales-bar {
  background: var(--brand-light);
  border-bottom: 1px solid var(--brand-50);
  padding: 8px 18px;
  flex-shrink: 0;
}

.held-sales-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.held-sales-toggle h5 {
  margin: 0;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 6px;
}

.held-sales-toggle .toggle-icon { color: var(--brand); font-size: .75rem; }

.held-sales-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 2px;
  scrollbar-width: thin;
}

.held-sale-card {
  background: var(--surface);
  border: 1px solid var(--brand-50);
  border-radius: var(--r);
  padding: 8px 12px;
  min-width: 170px;
  flex-shrink: 0;
}

.held-sale-card .hs-customer { font-weight: 600; font-size: .75rem; color: var(--slate-800); margin-bottom: 2px; }
.held-sale-card .hs-meta { font-size: .6875rem; color: var(--text-muted); margin-bottom: 4px; }
.held-sale-card .hs-total { font-weight: 700; font-size: .8125rem; color: var(--money); margin-bottom: 6px; }
.held-sale-card .hs-actions { display: flex; gap: 4px; }
.held-sale-card .hs-actions .btn { flex: 1; min-height: 28px; font-size: .6875rem; padding: 3px 6px; }

/* -----------------------------------------------
   MOBILE POS TABS
   ----------------------------------------------- */
.pos-mobile-tabs {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pos-mobile-tabs .tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  font-weight: 600;
  font-size: .8125rem;
  color: var(--slate-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--speed) var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
}

.pos-mobile-tabs .tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.pos-mobile-tabs .tab-btn .count {
  background: var(--brand-light);
  color: var(--brand);
  font-size: .625rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-full);
}

/* -----------------------------------------------
   RESPONSIVE
   ----------------------------------------------- */
@media (min-width: 992px) {
  /* The POS top bar (52px) is always shown and main-content is padded for it,
     so the layout must fit in the remaining height — not a full 100vh (which
     overflowed by 52px and pushed the cart footer/actions below the fold). */
  .pos-layout { height: calc(100vh - 52px); }
  .pos-cart { width: 360px; }
}

/* --- Tablet (≤991px) --- */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0) !important; }
  .topbar { display: flex; }
  .main-content { margin-left: 0; padding-top: 52px; max-width: 100vw; overflow-x: hidden; }
  .page-container { padding: 18px 14px; max-width: 100%; overflow-x: hidden; }
  .pos-layout { height: calc(100vh - 52px); }
  .pos-cart { width: 320px; }

  /* Page headers: stack title and buttons */
  .page-header { flex-direction: column; align-items: flex-start; }

  /* Row button groups in page headers wrap */
  h2 + .text-end,
  .col-md-6.text-end,
  .col-md-6.text-right {
    text-align: left !important;
    width: 100%;
    margin-top: 8px;
  }

  /* Form rows should stack earlier */
  .row > [class*="col-md-"],
  .row > [class*="col-lg-"] {
    margin-bottom: 8px;
  }
}

/* --- Mobile (≤767px) --- */
@media (max-width: 767px) {
  /* POS specific */
  .pos-layout { flex-direction: column; height: calc(100vh - 52px); }
  .pos-mobile-tabs { display: flex; }
  .pos-products { display: none; flex: 1; min-height: 0; }
  .pos-products.active { display: flex; }
  .pos-cart { display: none; width: 100%; border-left: none; flex: 1; min-height: 0; }
  .pos-cart.active { display: flex; }
  .pos-product-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    padding: 10px;
  }
  .pos-product-card .product-img { height: 80px; flex: 0 0 80px; }

  /* General layout */
  .page-container { padding: 14px 12px; }
  .btn { width: auto; }
  .btn-block { width: 100%; }
  .dashboard-card:hover { transform: none; }

  /* Page titles smaller */
  .page-title, h1, h2 { font-size: 1.25rem !important; }
  h3, h4, h5 { font-size: 1rem !important; }

  /* Force header action buttons to wrap and be full-width */
  .row > .col-md-6:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .row > .col-md-6:last-child .btn {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .75rem;
    padding: 6px 10px;
  }

  /* Stat/summary cards: ensure text visible */
  .stat-card {
    padding: 10px 12px;
    gap: 8px;
  }
  .stat-icon {
    width: 34px;
    height: 34px;
    font-size: .8rem;
    flex-shrink: 0;
  }
  .stat-value { font-size: .9375rem; }
  .stat-label { font-size: .6rem; }

  /* Cards */
  .card { margin-bottom: 12px; }
  .card-header { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .card-header h4, .card-header h3, .card-header h2 {
    font-size: .9375rem !important;
  }

  /* Tables: ensure horizontal scroll works */
  .table-responsive { margin: 0 -14px; padding: 0 14px; }
  .table { font-size: .75rem; }
  .table thead th { font-size: .65rem; padding: 8px 8px; }
  .table tbody td { padding: 8px 8px; font-size: .75rem; }

  /* Action button columns in tables - make compact */
  .table .btn-sm {
    padding: 3px 6px;
    min-height: 28px;
    font-size: .65rem;
  }
  .table .btn-sm i { font-size: .7rem; }

  /* Forms */
  .form-control, .form-select, select.form-control {
    font-size: .8125rem;
    padding: 8px 10px;
  }
  .form-label { font-size: .75rem; }

  /* Inline button groups */
  .d-flex.gap-2 { flex-wrap: wrap; }

  /* Filter/search sections */
  .input-group { flex-wrap: nowrap; }

  /* Badge sizing */
  .badge { font-size: .625rem; padding: 2px 6px; }

  /* Modal sizing */
  .modal-dialog { margin: 10px; max-width: calc(100vw - 20px); }
  .modal-body { padding: 14px; }
  .modal-header { padding: 12px 14px; }
  .modal-footer { padding: 10px 14px; flex-wrap: wrap; gap: 6px; }
  .modal-footer .btn { flex: 1; }

  /* Alert sizing */
  .alert { font-size: .75rem; padding: 10px 12px; }

  /* Overflow protection */
  .page-container { overflow-x: hidden; max-width: 100%; }
  .card { max-width: 100%; overflow: hidden; }
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
}

/* --- Small mobile extras (≤575px) --- */
@media (max-width: 575px) {
  /* Stat card rows: col-6 gives 2-up via Bootstrap; just tighten padding */
  .row > .col-6 {
    padding-left: 4px !important;
    padding-right: 4px !important;
  }

  /* Buttons breathing room on phones: an inline run of buttons with no flex-gap container
     crowds (no vertical space) when it wraps. Give every button a small bottom margin, then
     cancel it where a gap/group/input-group/footer already spaces its buttons (so it never
     doubles up). Explicit mb-* utilities (!important) still win over this. */
  .btn { margin-bottom: 6px; }
  .d-flex[class*="gap-"] > .btn,
  .d-grid > .btn,
  .row[class*="g-"] .btn,
  .btn-group > .btn,
  .btn-group-vertical > .btn,
  .input-group > .btn,
  .modal-footer > .btn,
  .pos-cart-footer .btn,
  .ofl-cart-actions > .btn,
  .ofl-customer > .btn,
  .col-md-6 .btn,
  .qty-pad-key,
  .pagination .page-link { margin-bottom: 0; }
  /* A lone button shouldn't leave a dangling gap before whatever follows it. */
  .card-body > .btn:last-child,
  form > .btn:last-child { margin-bottom: 0; }

  /* CSS-only fallback: force 2-up for stat card rows (col-md-3 groups) */
  .row:has(> .col-md-3 > .card),
  .row:has(> .col-md-3 > .stat-card) {
    display: flex !important;
    flex-wrap: wrap !important;
    margin: 0 !important;
    width: 100% !important;
    padding: 0 !important;
  }
  .row:has(> .col-md-3 > .card) > .col-md-3,
  .row:has(> .col-md-3 > .stat-card) > .col-md-3 {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    padding: 4px !important;
    margin: 0 !important;
  }

  /* Stat-like cards inside narrow cols */
  .col-md-3 .card-body,
  .col-lg-3 .card-body { padding: 10px 8px; }
  .col-md-3 .card-body h5,
  .col-lg-3 .card-body h5 { font-size: .65rem !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .col-md-3 .card-body h2,
  .col-lg-3 .card-body h2 { font-size: 1.125rem !important; margin: 0; }

  /* Dashboard module cards single column */
  .row > .col-sm-6.col-lg-4 { flex: 0 0 100% !important; max-width: 100% !important; }

  /* Header buttons full-width stacked */
  .row > .col-md-6 .btn,
  .row > .col-md-4 .btn,
  .page-header .btn {
    font-size: .7rem;
    padding: 6px 8px;
    min-height: 34px;
  }

  /* Fix any overflowing header rows */
  .page-container > .row:first-child {
    flex-direction: column;
  }
  .page-container > .row:first-child > [class*="col-"] {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .page-container > .row:first-child > [class*="col-"]:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
  }
  .page-container > .row:first-child > [class*="col-"]:last-child .btn {
    flex: 1 1 auto;
  }
}

/* --- Small phones (≤480px) --- */
@media (max-width: 480px) {
  .pos-product-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; padding: 8px; }
  .pos-cart-footer { padding: 10px 14px; }
  .pos-search { padding: 10px 14px; }

  .page-container { padding: 10px 10px; }

  /* Stack form/content columns but NOT stat card rows */
  .row:not(:has(> .col-md-3 > .card)):not(:has(> .col-md-3 > .stat-card)) > [class*="col-md-"]:not(.col-6):not(.col-sm-6),
  .row:not(:has(> .col-md-3 > .card)):not(:has(> .col-md-3 > .stat-card)) > [class*="col-lg-"]:not(.col-6):not(.col-sm-6):not(.col-lg-3) {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Even smaller stat cards */
  .stat-card { padding: 8px 10px; }
  .stat-icon { width: 30px; height: 30px; font-size: .75rem; }
  .stat-value { font-size: .8125rem; }

  /* Full-width buttons - but not inside stat/summary card rows */
  .page-header .btn:not(.btn-sm),
  .card-body > .btn:not(.btn-sm):not(.dropdown-toggle) { width: 100%; justify-content: center; }

  /* Table even more compact */
  .table thead th { font-size: .6rem; padding: 6px 6px; }
  .table tbody td { padding: 6px 6px; font-size: .7rem; }
}

/* -----------------------------------------------
   DROPDOWN (Bootstrap override)
   ----------------------------------------------- */
.dropdown-menu {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--r);
  padding: 4px;
  background: var(--surface);
}

.dropdown-item {
  padding: 8px 12px;
  color: var(--slate-600);
  font-weight: 500;
  border-radius: var(--r-xs);
  transition: all var(--speed) var(--ease);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8125rem;
}

.dropdown-item i { width: 16px; text-align: center; color: var(--slate-400); }
.dropdown-item:hover { background: var(--slate-50); color: var(--slate-800); }
.dropdown-item:hover i { color: var(--slate-600); }
.dropdown-divider { border-color: var(--border-light); margin: 3px 0; }

/* -----------------------------------------------
   GRID (Bootstrap augment)
   ----------------------------------------------- */
.row { margin-left: -8px; margin-right: -8px; }
.row > * { padding-left: 8px; padding-right: 8px; }
@media (min-width: 768px) {
  .row { margin-left: -10px; margin-right: -10px; }
  .row > * { padding-left: 10px; padding-right: 10px; }
}
.g-3 > * { padding: 8px; }

/* -----------------------------------------------
   TOAST NOTIFICATIONS
   ----------------------------------------------- */
.pos-toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  min-width: 260px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8125rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideInRight .25s var(--ease) both;
}

.pos-toast.toast-success { background: var(--money); color: var(--white); }
.pos-toast.toast-error { background: var(--danger); color: var(--white); }
.pos-toast.toast-warning { background: var(--warning); color: var(--white); }
.pos-toast.toast-info { background: var(--brand-deep); color: #fff; }

/* -----------------------------------------------
   PRINT
   ----------------------------------------------- */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; padding-top: 0 !important; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* -----------------------------------------------
   SELECT2
   ----------------------------------------------- */
.select2-container--bootstrap-5 .select2-selection {
  min-height: var(--touch);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
}

.select2-container--bootstrap-5 .select2-selection:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

/* -----------------------------------------------
   LANGUAGE PICKER
   ----------------------------------------------- */
.lang-picker {
  padding: 12px 14px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  margin-bottom: 4px;
}

.lang-picker .theme-picker-label {
  color: var(--sidebar-active-text);
  font-size: .65rem;
  opacity: .85;
}

.lang-swatches {
  display: flex;
  gap: 6px;
}

.lang-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 28px;
  border-radius: var(--r-sm);
  font-size: .7rem;
  font-weight: 700;
  text-decoration: none;
  color: #cbd5e0;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  letter-spacing: .02em;
}

.lang-swatch:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
  border-color: rgba(255,255,255,.15);
}

/* !important overrides the layout's scoped-CSS `a { color:#0077cc }` which otherwise
   wins by attribute-specificity and made the inactive swatches low-contrast blue. */
.lang-swatch { color: #cbd5e0 !important; }
.lang-swatch.active {
  background: var(--brand);
  color: #fff !important;
  border-color: var(--brand);
}

/* -----------------------------------------------
   RTL SUPPORT (Arabic)
   ----------------------------------------------- */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

/* Sidebar flips to the right */
[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  inset: 0 0 0 auto;
}

[dir="rtl"] .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-w);
}

/* Topbar adjustments */
[dir="rtl"] .topbar-toggle { order: 2; }
[dir="rtl"] .topbar-brand { order: 1; }

/* Nav link icon spacing */
[dir="rtl"] .nav-link i {
  margin-left: 8px;
  margin-right: 0;
}

/* Nav active border flips */
[dir="rtl"] .nav-link.active {
  border-left: none;
  border-right: 3px solid var(--sidebar-active-icon);
}

/* Page header alignment. NOTE: do NOT force flex-direction:row-reverse — with
   dir=rtl + bootstrap.rtl, flex rows already flow right-to-left; reversing again
   double-flips them back to LTR (the classic "delete button on the wrong side" bug). */
[dir="rtl"] .page-title { text-align: right; }

/* Buttons gap direction */
[dir="rtl"] .btn i { margin-left: 6px; margin-right: 0; }

/* Card header icon */
[dir="rtl"] .card-header { flex-direction: row; }

/* Table text alignment */
[dir="rtl"] .table { text-align: right; }
[dir="rtl"] .table th,
[dir="rtl"] .table td { text-align: right; }

/* Form labels */
[dir="rtl"] .form-label { text-align: right; }
[dir="rtl"] .form-check { padding-left: 0; padding-right: 1.5em; }
[dir="rtl"] .form-check-input { float: right; margin-left: 0; margin-right: -1.5em; }

/* Input group */
[dir="rtl"] .input-group-prepend .input-group-text {
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  border-right: 1.5px solid var(--border);
  border-left: none;
}
[dir="rtl"] .input-group .form-control {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}

/* Alerts */
[dir="rtl"] .alert { border-left: none; border-right: 3px solid; }

/* Badge direction */
[dir="rtl"] .badge { direction: rtl; }

/* Stat card icons */
[dir="rtl"] .stat-card { text-align: right; }

/* Modal: bootstrap.rtl + dir=rtl already flip the header and close button. */

/* Mobile sidebar from right */
@media (max-width: 991px) {
  [dir="rtl"] .main-content { margin-right: 0; }

  [dir="rtl"] .sidebar {
    transform: translateX(100%);
    left: auto;
    right: 0;
  }

  [dir="rtl"] .sidebar.open {
    transform: translateX(0);
  }
}

/* Font for Arabic text — system Arabic fonts */
[dir="rtl"] body {
  font-family: 'Segoe UI', 'Tahoma', 'Arial', sans-serif;
}

/* POS quantity-edit numeric keypad */
.cart-item { cursor: pointer; }
.qty-edit-display {
  font-size: 2.2rem;
  font-weight: 700;
  text-align: center;
  background: #f1f5f9;
  border: 2px solid #2563eb;
  border-radius: 10px;
  padding: .45rem;
  margin-bottom: .75rem;
  color: #0f172a;
  min-height: 3.2rem;
  letter-spacing: .04em;
}
.qty-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
}
.qty-pad-key {
  font-size: 1.4rem;
  font-weight: 600;
  padding: .7rem 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
  transition: background .12s ease, transform .05s ease;
}
.qty-pad-key:hover { background: #e2e8f0; }
.qty-pad-key:active { transform: scale(.96); }
.qty-pad-action { background: #f1f5f9; color: #334155; }

/* Sales report tables: self-contained dark header (readable in all themes) */
.report-table thead th {
  background: #1e3a5f;
  color: #ffffff !important;
  border-color: #1e3a5f;
  font-weight: 600;
}
.report-table tbody td { vertical-align: middle; }

/* RTL: mirror directional arrow/chevron icons so "back/forward" point the right way */
[dir="rtl"] .fa-arrow-left,
[dir="rtl"] .fa-arrow-right,
[dir="rtl"] .fa-long-arrow-alt-left,
[dir="rtl"] .fa-long-arrow-alt-right,
[dir="rtl"] .fa-arrow-right-long,
[dir="rtl"] .fa-arrow-left-long,
[dir="rtl"] .fa-chevron-left,
[dir="rtl"] .fa-chevron-right,
[dir="rtl"] .fa-angle-left,
[dir="rtl"] .fa-angle-right,
[dir="rtl"] .fa-arrow-right-from-bracket {
  transform: scaleX(-1);
}

/* Quantity keypad: product photo */
.qty-edit-photo { max-height: 84px; max-width: 100%; border-radius: 8px; object-fit: contain; display: none; }

/* Review/confirmation page: show items are clickable (open the quantity keypad) */
.review-row { cursor: pointer; }
.review-row:hover { background-color: rgba(37, 99, 235, 0.06); }

/* POS multiple-cart tabs */
.cart-tabs { display: flex; flex-wrap: wrap; gap: 5px; padding: 7px 10px; border-bottom: 1px solid #e2e8f0; }
.cart-tab { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f1f5f9; color: #334155; font-size: .8rem; font-weight: 600; cursor: pointer; transition: background .12s ease; }
.cart-tab:hover { background: #e2e8f0; }
.cart-tab.active { background: #2563eb; color: #ffffff; border-color: #2563eb; }
.cart-tab-count { background: #cbd5e1; color: #1e293b; border-radius: 10px; padding: 0 7px; font-size: .7rem; line-height: 1.4; }
.cart-tab.active .cart-tab-count { background: rgba(255,255,255,.9); color: #1e3a5f; }
.cart-tab-close { opacity: .65; font-weight: 700; font-size: 1rem; line-height: 1; padding: 0 2px; }
.cart-tab-close:hover { opacity: 1; }
.cart-tab-add { border: 1px dashed #94a3b8; background: #fff; color: #2563eb; border-radius: 8px; padding: 4px 11px; cursor: pointer; font-size: .85rem; }
.cart-tab-add:hover { background: #eff6ff; }

/* Sidebar nav badge (e.g. pending online orders count) */
/* #ef4444 with white was 3.76:1 (below AA); #c81e1e ≈ 5.3:1 keeps it clearly red and readable. */
.nav-badge { display: inline-block; background: #c81e1e; color: #fff; font-size: .68rem; font-weight: 700; min-width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 999px; padding: 0 5px; margin-inline-start: 6px; vertical-align: middle; }

/* ---- Sortable table headers + clickable rows + product thumbnails ---- */
.th-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sortable:hover { filter: brightness(1.12); }
.sort-ind { font-size: .8em; }
tr[data-href] { cursor: pointer; }
.product-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #f1f5f9; vertical-align: middle; }
.product-thumb-ph { width: 40px; height: 40px; border-radius: 8px; background: #f1f5f9; display: inline-flex; align-items: center; justify-content: center; color: #cbd5e1; vertical-align: middle; }
.product-name-cell { display: flex; align-items: center; gap: 10px; }
.product-brand { margin-top: 2px; }
.product-brand i { color: var(--slate-400); margin-inline-end: 3px; }
.product-tags { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.product-tag-chip { display: inline-block; font-size: .68rem; font-weight: 600; color: #475569; background: #eef2f7; border: 1px solid #e2e8f0; border-radius: 999px; padding: 1px 8px; text-decoration: none; }
a.product-tag-chip:hover { background: #2563eb; border-color: #2563eb; color: #fff; }
.th-sub { font-weight: 400; font-size: .8em; opacity: .85; }

/* ---- POS keyboard-shortcuts help button ---- */
.pos-help-btn { position: fixed; bottom: 18px; inset-inline-start: 18px; width: 46px; height: 46px; border-radius: 50%; border: 0; background: #1e3a5f; color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.28); z-index: 1040; cursor: pointer; font-size: 1.15rem; display: flex; align-items: center; justify-content: center; }
.pos-help-btn:hover { background: #2563eb; }
#shortcutsModal kbd { background: #1f2937; color: #fff; border-radius: 6px; padding: 2px 8px; font-size: .85rem; }

/* ---- Help / in-app guide ---- */
.help-cat-title { margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border-light); color: #1f2937; }
.help-topic { border: 1px solid var(--border-light); border-radius: var(--r-md); transition: box-shadow var(--speed) var(--ease); }
.help-topic:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.help-topic-title { font-size: 1.05rem; margin-bottom: 10px; color: #1f2937; }
.help-steps { margin: 0; padding-inline-start: 20px; color: #374151; }
.help-steps li { margin-bottom: 6px; line-height: 1.5; }
/* Table of contents */
.help-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.help-toc-link { font-size: .8125rem; font-weight: 600; color: #1d4ed8; background: #eef4ff; border: 1px solid #d6e2fb; border-radius: 999px; padding: 4px 12px; text-decoration: none; }
.help-toc-link:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
/* Topic intro paragraph */
.help-intro { color: #475569; font-size: .9rem; line-height: 1.5; margin-bottom: 10px; }
/* Tips / callouts */
.help-tips { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.help-tip { background: #fff8e6; border: 1px solid #f6e6b8; border-radius: 8px; padding: 8px 10px; font-size: .82rem; line-height: 1.45; color: #6b5408; display: flex; gap: 8px; align-items: flex-start; }
.help-tip i { color: #b7791f; margin-top: 2px; }

/* ---- Courier "My Deliveries" (mobile-first cards) ---- */
.courier-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.courier-card { background: #fff; border: 1px solid var(--border-light); border-radius: var(--r-md); padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); display: flex; flex-direction: column; gap: 10px; }
.courier-card-top { display: flex; align-items: center; justify-content: space-between; }
.courier-order-no { font-weight: 700; font-size: 1.05rem; color: #1f2937; }
.courier-customer { display: flex; flex-direction: column; gap: 4px; }
.courier-customer .cc-name { font-weight: 600; color: #1f2937; }
.courier-customer .cc-phone { font-size: 1.05rem; font-weight: 600; color: #1d4ed8; text-decoration: none; }
.courier-customer .cc-phone:hover { text-decoration: underline; }
.courier-customer .cc-address { color: #374151; }
.courier-customer i { width: 16px; color: #6b7280; }
.courier-items { list-style: none; margin: 0; padding: 8px 0; border-top: 1px dashed var(--border-light); border-bottom: 1px dashed var(--border-light); display: flex; flex-direction: column; gap: 4px; }
.courier-items li { color: #1f2937; }
.courier-items .ci-qty { display: inline-block; min-width: 34px; font-weight: 700; color: #1d4ed8; }
.courier-note, .courier-deliverynote { background: #fff8e1; border-radius: var(--r-xs); padding: 6px 10px; color: #5b4500; font-size: .92rem; }
.courier-deliverynote { background: #eef2ff; color: #1e3a5f; }
.courier-collect { display: flex; align-items: center; justify-content: space-between; background: #ecfdf5; border-radius: var(--r-xs); padding: 8px 12px; }
.courier-collect span { color: #065f46; font-weight: 600; }
.courier-collect strong { color: #065f46; font-size: 1.2rem; }
.courier-collected { color: #065f46; }
.courier-shipping { color: #6b7280; font-size: .9rem; }
.courier-actions { display: flex; flex-direction: column; gap: 8px; }
.courier-panel { background: var(--slate-50); border-radius: var(--r-sm); padding: 12px; margin-top: 8px; }
@media (max-width: 600px) { .courier-list { grid-template-columns: 1fr; } }

/* POS search/scan-driven grid empty states */
.pos-grid-empty { text-align: center; color: #6b7280; padding: 48px 16px; }
.pos-grid-empty i { font-size: 40px; opacity: .35; display: block; margin-bottom: 10px; }
.pos-grid-empty p { margin: 4px 0; }
.pos-loc-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px; background: #eef2ff; color: #1e3a5f; font-size: .85rem; white-space: nowrap; }

/* User permission toggles: highlight rows customised away from the role default */
.perm-row.perm-custom { background: #fff8e1; border-radius: 4px; padding-inline: 4px; }

/* -----------------------------------------------
   SETTINGS — sidebar-tab dashboard (no endless scroll). Token-driven
   (inherits the active theme's surfaces/accents). RTL-safe.
   ----------------------------------------------- */
.settings-layout { display: grid; grid-template-columns: 248px 1fr; gap: 22px; align-items: start; }
.settings-nav {
  position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 8px; box-shadow: var(--shadow-xs);
}
.settings-nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: start;
  padding: 9px 12px; border: 0; background: transparent; color: var(--text-mid);
  font-size: .82rem; font-weight: 600; border-radius: var(--r); cursor: pointer;
  font-family: inherit; text-decoration: none; transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.settings-nav-item i { width: 18px; text-align: center; color: var(--text-muted); flex: none; }
.settings-nav-item:hover { background: var(--slate-50); color: var(--text); }
.settings-nav-item.active { background: var(--brand-50); color: var(--brand); }
.settings-nav-item.active i { color: var(--brand); }
.settings-nav-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.settings-content { min-width: 0; }
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: settingsFade .18s var(--ease); }
@keyframes settingsFade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.settings-panel-head { margin: 0 0 14px; }
.settings-panel-head h3 { font-size: 1.05rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 9px; }
.settings-panel-head p { color: var(--text-muted); font-size: .82rem; margin: 4px 0 0; }
.settings-save-bar {
  position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 12px 2px; margin-top: 8px; z-index: 5;
}
@media (max-width: 860px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .settings-nav-item { width: auto; }
  .settings-nav-sep { display: none; }
}

/* Product Add/Edit form tabs — keep them on a single scrollable row on phones instead of
   wrapping the long "Images et codes-barres" tab onto an ugly second line. */
#productTabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
#productTabs::-webkit-scrollbar { height: 3px; }
#productTabs::-webkit-scrollbar-thumb { background: #c7ced6; border-radius: 3px; }
#productTabs .nav-item { flex: 0 0 auto; }
#productTabs .nav-link { white-space: nowrap; }
@media (max-width: 575.98px) {
  #productTabs .nav-link { padding: 0.45rem 0.7rem; font-size: 0.85rem; }
  #productTabs .nav-link i { margin-right: 0.15rem; }
}
