/* ============================================================================
   RECIPRO — Modern SaaS Dashboard Stylesheet
   Single-file app companion stylesheet (replaces the inline <style>).
   ----------------------------------------------------------------------------
   THEMING CONTRACT (do not rename):
     JS sets on :root (documentElement) via style.setProperty:
       --color-primary  --color-secondary  --color-bg-base  --color-text-main
     JS toggles body.theme-dark for the dark system.
   All surfaces, borders, shadows and muted text are DERIVED from those 4 vars
   with color-mix(), so the three systems (rose / sage / dark) stay cohesive.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. DESIGN TOKENS
   ---------------------------------------------------------------------------- */
:root {
  /* --- JS-controlled (defaults = Recipro / Carrot brand) --- */
  --color-primary:   #F47A1F;
  --color-secondary: #39A845;
  --color-bg-base:   #FBF7EE;
  --color-text-main: #2A2520;

  /* --- Recipro brand tokens (Carrot orange + leaf green) --- */
  --brand:      #F47A1F;
  --brand-dark: #E0660C;
  --brand-soft: #FFE6D2;
  --green:      #39A845;
  --green-dark: #2C8C38;
  --green-soft: #DDF3DF;
  --bg-warm:    #FFF3DC;
  --on-brand:   #FFFFFF;

  /* --- Fonts (Poppins headings + Sarabun Thai body) --- */
  --font-head: 'Poppins', 'Sarabun', system-ui, sans-serif;
  --font-body: 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* --- Derived text --- */
  --color-text-muted: color-mix(in srgb, var(--color-text-main) 52%, var(--color-bg-base));
  --color-text-soft:  color-mix(in srgb, var(--color-text-main) 72%, var(--color-bg-base));

  /* --- Surfaces (derived from base so every theme is cohesive) --- */
  --surface-1: color-mix(in srgb, var(--color-bg-base) 60%, #ffffff);   /* cards          */
  --surface-2: color-mix(in srgb, var(--color-bg-base) 82%, #ffffff);   /* sidebar / app  */
  --surface-3: color-mix(in srgb, var(--color-bg-base) 40%, #ffffff);   /* inputs / hover */
  --surface-hover: color-mix(in srgb, var(--color-primary) 7%, var(--surface-1));

  /* --- Glass (legacy var names kept; used by JS inline templates) --- */
  --glass-background: color-mix(in srgb, #ffffff 70%, transparent);
  --glass-border: color-mix(in srgb, var(--color-text-main) 12%, transparent);

  /* --- Borders / rings --- */
  --border-soft:   color-mix(in srgb, var(--color-text-main) 10%, transparent);
  --border-strong: color-mix(in srgb, var(--color-text-main) 18%, transparent);
  --ring: color-mix(in srgb, var(--color-primary) 22%, transparent);

  /* --- Primary tints --- */
  --primary-soft:   color-mix(in srgb, var(--color-primary) 10%, transparent);
  --primary-softer: color-mix(in srgb, var(--color-primary) 6%, transparent);
  --primary-strong: color-mix(in srgb, var(--color-primary) 88%, #000);

  /* --- Ambient blobs (kept for the .glow-* markup) --- */
  --blob-color-1: color-mix(in srgb, var(--color-primary) 16%, transparent);
  --blob-color-2: color-mix(in srgb, var(--color-secondary) 13%, transparent);

  /* --- Status palette (semantic, theme-independent) --- */
  --ok-bg:   #d1fae5; --ok-fg:   #065f46;
  --warn-bg: #fef3c7; --warn-fg: #92400e;
  --bad-bg:  #fee2e2; --bad-fg:  #991b1b;
  --info-bg: #dbeafe; --info-fg: #1e40af;
  --danger:  #ef4444;

  /* --- Elevation --- */
  --shadow-sm: 0 1px 2px rgba(15, 18, 45, 0.05), 0 1px 3px rgba(15, 18, 45, 0.06);
  --shadow:    0 8px 24px -8px rgba(15, 18, 45, 0.16), 0 2px 6px rgba(15, 18, 45, 0.06);
  --shadow-lg: 0 24px 60px -18px rgba(15, 18, 45, 0.30), 0 6px 16px rgba(15, 18, 45, 0.10);
  --shadow-primary: 0 10px 24px -8px color-mix(in srgb, var(--color-primary) 45%, transparent);

  /* --- Radii --- */
  --r-large: 24px;
  --r-medium: 16px;
  --r-small: 11px;
  --r-pill: 999px;

  /* --- Motion --- */
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* --- Layout metrics --- */
  --sidebar-w: 264px;
  --sidebar-rail: 68px;

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14.5px;
  --fs-lg: 16px;
}

/* Dark system overrides (body.theme-dark, set by applyTheme('dark')) */
body.theme-dark {
  --color-text-muted: color-mix(in srgb, var(--color-text-main) 46%, var(--color-bg-base));
  --color-text-soft:  color-mix(in srgb, var(--color-text-main) 66%, var(--color-bg-base));

  --surface-1: color-mix(in srgb, var(--color-bg-base) 85%, #ffffff);
  --surface-2: color-mix(in srgb, var(--color-bg-base) 93%, #ffffff);
  --surface-3: color-mix(in srgb, var(--color-bg-base) 75%, #ffffff);
  --surface-hover: color-mix(in srgb, var(--color-primary) 14%, var(--surface-1));

  --glass-background: color-mix(in srgb, var(--color-bg-base) 72%, transparent);
  --glass-border: color-mix(in srgb, #ffffff 12%, transparent);

  --border-soft:   color-mix(in srgb, #ffffff 9%, transparent);
  --border-strong: color-mix(in srgb, #ffffff 16%, transparent);

  --primary-soft:   color-mix(in srgb, var(--color-primary) 20%, transparent);
  --primary-softer: color-mix(in srgb, var(--color-primary) 12%, transparent);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 10px 28px -10px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 28px 70px -20px rgba(0, 0, 0, 0.7);

  /* tone status pills so they read on dark */
  --ok-bg:   color-mix(in srgb, #10b981 22%, var(--surface-1)); --ok-fg:   #6ee7b7;
  --warn-bg: color-mix(in srgb, #f59e0b 22%, var(--surface-1)); --warn-fg: #fcd34d;
  --bad-bg:  color-mix(in srgb, #ef4444 24%, var(--surface-1)); --bad-fg:  #fca5a5;
  --info-bg: color-mix(in srgb, #3b82f6 24%, var(--surface-1)); --info-fg: #93c5fd;
}

/* ----------------------------------------------------------------------------
   2. RESET & BASE
   ---------------------------------------------------------------------------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.55;
  background-color: var(--color-bg-base);
  color: var(--color-text-main);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, .title-brand {
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 0 0 10px 0;
  color: var(--color-text-main);
}
h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

p { margin: 0 0 10px 0; }
a { color: var(--color-primary); }
b, strong { font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--border-soft); margin: 20px 0; }

.title-brand {
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

::selection { background: color-mix(in srgb, var(--color-primary) 25%, transparent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--color-text-main) 22%, transparent);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--color-text-main) 34%, transparent); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }

/* Numbers / money */
.num, .stat-val, .lst td.r, table.bd td.r, [id^="sum"], #rCost, #rProfit, #rMargin {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ----------------------------------------------------------------------------
   3. ICON SYSTEM (Lucide stroke icons via icon('name'))
   ---------------------------------------------------------------------------- */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vertical-align: -0.125em;
}
/* legacy emoji span — neutralised so it stays inline & sized if still present */
.em { font-style: normal; line-height: 1; display: inline-flex; align-items: center; }

/* ----------------------------------------------------------------------------
   4. AMBIENT BACKGROUND
   ---------------------------------------------------------------------------- */
.glow-container {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.glow-blob {
  position: absolute;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.9;
}
.blob-1 {
  top: -140px; left: -120px;
  background: radial-gradient(circle, var(--blob-color-1) 0%, transparent 70%);
  animation: float1 20s infinite alternate ease-in-out;
}
.blob-2 {
  bottom: -180px; right: -120px;
  background: radial-gradient(circle, var(--blob-color-2) 0%, transparent 70%);
  animation: float2 24s infinite alternate ease-in-out;
}
@keyframes float1 { 0% { transform: translate(0,0) scale(1); } 100% { transform: translate(80px,50px) scale(1.15); } }
@keyframes float2 { 0% { transform: translate(0,0) scale(1.1); } 100% { transform: translate(-100px,-60px) scale(.9); } }

/* ----------------------------------------------------------------------------
   5. CARDS
   ---------------------------------------------------------------------------- */
.glass-card {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-medium);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}
.glass-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.glass-card > h2,
.glass-card > h3 { display: flex; align-items: center; gap: 9px; white-space: nowrap; overflow: hidden; }
.glass-card > h2:first-child,
.glass-card > h3:first-child { margin-top: 0; }

.hint, p.hint {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin: -2px 0 14px;
}

/* ----------------------------------------------------------------------------
   6. FORMS — inputs, textarea, native select, labels, checkbox
   ---------------------------------------------------------------------------- */
label {
  display: block;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--color-text-soft);
  margin-bottom: 6px;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

input, select, textarea {
  font-family: inherit;
  font-size: var(--fs-base);
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border-soft);
  border-radius: var(--r-small);
  background: var(--surface-3);
  color: var(--color-text-main);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--color-text-muted) 80%, transparent); }

input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }

input:focus, select:focus, textarea:focus {
  border-color: var(--color-primary);
  background: var(--surface-1);
  box-shadow: 0 0 0 4px var(--ring);
}
input:disabled, select:disabled, textarea:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: color-mix(in srgb, var(--color-text-main) 5%, var(--surface-3));
}
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }

/* checkbox */
input[type="checkbox"] {
  width: 18px; height: 18px;
  flex: none;
  padding: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
  vertical-align: -0.2em;
}
input[type="file"] { padding: 8px; }
input[type="date"] { cursor: pointer; }

/* native <select> beautified — custom chevron, no native arrow */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 38px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%237C3AED' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
}
body.theme-dark select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23818CF8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}
select option { color: #111; background: #fff; }
/* optional explicit wrapper if markup adopts <span class="select"> */
.select { position: relative; display: block; }

/* ----------------------------------------------------------------------------
   7. BUTTONS — variants + sizes + leading icon
   ---------------------------------------------------------------------------- */
.btn {
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  padding: 11px 18px;
  border-radius: var(--r-small);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  line-height: 1.2;
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.btn:active { transform: translateY(1px); }
.btn .icon { font-size: 1.05em; }

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--primary-strong));
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 14px 30px -8px color-mix(in srgb, var(--color-primary) 55%, transparent); }

.btn-secondary {
  background: linear-gradient(135deg, var(--color-secondary), color-mix(in srgb, var(--color-secondary) 80%, #000));
  color: #fff;
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--color-secondary) 50%, transparent);
}
.btn-secondary:hover { filter: brightness(1.07); }

.btn-ghost {
  background: var(--surface-3);
  color: var(--color-text-soft);
  border-color: var(--border-soft);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: color-mix(in srgb, var(--color-primary) 35%, var(--border-strong));
  color: var(--color-primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--danger) 55%, transparent);
}
.btn-danger:hover { filter: brightness(1.06); }

/* formalized small size (was inline-only) */
.btn-sm {
  font-size: var(--fs-sm);
  padding: 7px 12px;
  border-radius: 9px;
  width: auto;
  gap: 6px;
}

/* auto-width helpers used inline already remain valid; segmented groups */
.btn[style*="flex:1"] { width: auto; }

/* ----------------------------------------------------------------------------
   8. APP LAYOUT (sidebar + main); shown by JS via display:flex
   ---------------------------------------------------------------------------- */
.app-layout {
  display: none;            /* JS sets to flex */
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface-2);
  border-right: 1px solid var(--border-soft);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.26s var(--ease-out), transform 0.26s var(--ease-out), padding 0.26s var(--ease-out);
}

.main-container {
  flex: 1 1 auto;
  margin-left: var(--sidebar-w);
  padding: 26px 34px 90px;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-w));
  transition: margin-left 0.26s var(--ease-out), width 0.26s var(--ease-out);
}

/* Brand + shop identity */
.brand-logo-area {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 18px;
  padding: 4px 8px;
  background: none;
  border: none;
  font-family: var(--font-body);
  color: var(--color-text-main);
  cursor: pointer;
  border-radius: var(--r-medium);
  width: 100%;
  transition: background 0.15s;
}
.brand-logo-area:hover { background: var(--surface-hover); }
.brand-logo-area img { width: 38px; height: 38px; flex: none; }
body.theme-dark .brand-logo-area img { filter: drop-shadow(0 0 2px rgba(244,122,31,0.4)); }

.shop-name-display {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 8px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------------------------
   9. NAV MENU
   ---------------------------------------------------------------------------- */
.nav-menu {
  list-style: none;
  padding: 0; margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r-small);
  color: var(--color-text-soft);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--fs-base);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}
.nav-item .icon, .nav-item .em { font-size: 1.18em; flex: none; width: 1.18em; text-align: center; }

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--color-primary);
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--color-primary);
  font-weight: 700;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 22px;
  border-radius: 0 4px 4px 0;
  background: var(--color-primary);
}

/* runtime low-stock pill appended to menuStock */
.badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: var(--r-pill);
  font-weight: 700;
  margin-left: auto;
}

/* sidebar footer (email + sign-out) */
#userEmailDisplay {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-bottom: 10px;
  word-break: break-all;
  padding: 0 6px;
}

/* ----------------------------------------------------------------------------
   10. COLLAPSIBLE SIDEBAR
   ----------------------------------------------------------------------------
   Mechanism:
     - Desktop rail : add class  "sidebar-collapsed"  to .app-layout
     - Mobile drawer: add class  "sidebar-open"        to .app-layout
   Persist the collapsed state in localStorage from JS.
   ---------------------------------------------------------------------------- */
.app-layout.sidebar-collapsed .sidebar {
  width: var(--sidebar-rail);
  padding: 22px 10px;
}
.app-layout.sidebar-collapsed .main-container {
  margin-left: var(--sidebar-rail);
  width: calc(100% - var(--sidebar-rail));
}

/* hide text in rail mode, keep icons centered */
.app-layout.sidebar-collapsed .title-brand,
.app-layout.sidebar-collapsed .shop-name-display,
.app-layout.sidebar-collapsed #shopStatusBadge,
.app-layout.sidebar-collapsed #userEmailDisplay,
.app-layout.sidebar-collapsed .nav-item > span:not(.em):not(.icon):not(.ico):not(.badge),
.app-layout.sidebar-collapsed .nav-item .badge {
  display: none;
}
/* keep the icon wrapper visible + centered in rail mode */
.app-layout.sidebar-collapsed .nav-item .ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25em;
}
.app-layout.sidebar-collapsed .brand-logo-area { justify-content: center; padding: 4px 0; }
.app-layout.sidebar-collapsed .nav-item { justify-content: center; padding: 11px 0; }
.app-layout.sidebar-collapsed .nav-item.active::before { left: -10px; }
.app-layout.sidebar-collapsed .sidebar > div:last-child .btn span:not(.icon) { display: none; }
.app-layout.sidebar-collapsed .sidebar > div:last-child .btn { padding: 11px 0; }
.app-layout.sidebar-collapsed .user-card { justify-content: center; padding: 9px 0; }
.app-layout.sidebar-collapsed .user-card-info,
.app-layout.sidebar-collapsed .user-card-chevron { display: none; }

/* tooltip on hover in rail mode (uses title="" or data-tip="") */
.app-layout.sidebar-collapsed .nav-item[title]:hover::after,
.app-layout.sidebar-collapsed .nav-item[data-tip]:hover::after {
  content: attr(data-tip);
  content: attr(title);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-text-main);
  color: var(--color-bg-base);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: var(--shadow);
  z-index: 200;
  pointer-events: none;
}

/* backdrop element (add a <div class="sidebar-backdrop"> in markup, or JS) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.5);
  backdrop-filter: blur(2px);
  z-index: 99;
}

/* sidebar toggle button helper (optional, if markup adds one) */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--r-small);
  border: 1.5px solid var(--border-soft);
  background: var(--surface-3);
  color: var(--color-text-soft);
  cursor: pointer;
  flex: none;
  transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--surface-hover); color: var(--color-primary); border-color: var(--color-primary); }
.sidebar-toggle .icon { font-size: 1.25em; }

/* ----------------------------------------------------------------------------
   11. TOP BAR
   ---------------------------------------------------------------------------- */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.top-bar h2, #currentPageTitle {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  color: var(--color-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ----------------------------------------------------------------------------
   12. SYNC INDICATOR
   ---------------------------------------------------------------------------- */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-secondary);
  background: color-mix(in srgb, var(--color-secondary) 12%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--color-secondary) 22%, transparent);
  padding: 6px 12px;
  border-radius: var(--r-pill);
}
.sync-indicator::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-secondary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-secondary) 25%, transparent);
}

/* ----------------------------------------------------------------------------
   13. STATUS BADGES
   ---------------------------------------------------------------------------- */
.shop-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  line-height: 1.4;
}
.shop-status-badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.status-active    { background: var(--ok-bg);   color: var(--ok-fg); }
.status-trial     { background: var(--warn-bg); color: var(--warn-fg); }
.status-suspended { background: var(--bad-bg);  color: var(--bad-fg); }

/* ----------------------------------------------------------------------------
   14. GRIDS & STAT CARDS
   ---------------------------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.dash-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

.stat-card {
  text-align: center;
  padding: 20px 14px;
  border-radius: var(--r-medium);
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-card .stat-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  margin: 0 auto 8px;
  border-radius: 13px;
  font-size: 22px;
  background: var(--primary-soft);
  color: var(--color-primary);
}
.stat-card .stat-ico .icon { font-size: 22px; }
.stat-card .stat-val { font-size: 28px; font-weight: 800; margin: 4px 0 2px; line-height: 1.1; }
.stat-card .stat-lab { font-size: var(--fs-sm); color: var(--color-text-muted); font-weight: 600; }
.stat-card .stat-sub { font-size: 11px; color: var(--color-text-muted); margin-top: 4px; }

/* ----------------------------------------------------------------------------
   15. TABLES (.lst app tables)
   ---------------------------------------------------------------------------- */
table.lst {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: var(--fs-base);
}
table.lst th, table.lst td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
table.lst th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-1);
  color: var(--color-text-muted);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1.5px solid var(--border-strong);
  white-space: nowrap;
}
table.lst tbody tr { transition: background 0.14s ease; }
table.lst tbody tr:hover { background: var(--surface-hover); }
table.lst tbody tr.row-selected { background: rgba(234,88,12,0.07); }
.item-card.card-selected { border-color: var(--color-primary); background: rgba(234,88,12,0.04); }
table.lst tbody tr:last-child td { border-bottom: 0; }
table.lst td.r, table.lst th.r { text-align: right; }
table.lst td.c, table.lst th.c { text-align: center; }
/* action-cell buttons sit nicely together */
table.lst td .btn { display: inline-flex; vertical-align: middle; }
table.lst td .btn + .btn { margin-left: 6px; }

/* ----------------------------------------------------------------------------
   16. SUB-TABS (inside cards)
   ---------------------------------------------------------------------------- */
.sub-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-small);
}
.sub-tab {
  padding: 8px 16px;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--color-text-soft);
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}
.sub-tab:hover { color: var(--color-primary); }
.sub-tab.active {
  background: var(--surface-1);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* ----------------------------------------------------------------------------
   17. PAGE ENTRANCE ANIMATION
   ---------------------------------------------------------------------------- */
.page-section {
  animation: slideUp 0.45s var(--ease-out) both;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .page-section, .glow-blob { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}

/* ----------------------------------------------------------------------------
   18. RECIPE / BILL DYNAMIC ROWS
   ---------------------------------------------------------------------------- */
.recipe-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1.2fr 44px;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

/* ----------------------------------------------------------------------------
   19. AUTH SCREEN
   ---------------------------------------------------------------------------- */
.auth-container { display: flex; min-height: 100vh; width: 100%; background: var(--color-bg-base); }

/* LEFT HERO — warm cream + decorative blobs */
.auth-hero {
  flex: 1.05;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 64px 56px;
  background:
    radial-gradient(720px 520px at 10% 6%, var(--brand-soft) 0%, transparent 56%),
    radial-gradient(720px 620px at 92% 102%, var(--green-soft) 0%, transparent 56%),
    var(--bg-warm);
}
.auth-blob { position: absolute; border-radius: 50%; pointer-events: none; }
.auth-blob-1 { top: -90px; left: -70px; width: 300px; height: 300px;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand) 30%, transparent), transparent 70%); }
.auth-blob-2 { bottom: -110px; right: -50px; width: 360px; height: 360px;
  background: radial-gradient(circle, color-mix(in srgb, var(--green) 26%, transparent), transparent 70%); }
.auth-hero-inner { position: relative; max-width: 470px; z-index: 1; }

.auth-wordmark-row { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.auth-logo { width: 54px; height: 54px; }
.auth-wordmark { font-family: var(--font-head); font-weight: 800; font-size: 35px; letter-spacing: -0.02em; color: var(--color-text-main); }
.hl { color: var(--brand); }

.auth-headline { font-family: var(--font-head); font-weight: 800; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.16; letter-spacing: -0.02em; color: var(--color-text-main); margin: 0 0 14px; }
.auth-sub { font-size: 17px; color: var(--color-text-soft); margin: 0 0 18px; }
.auth-accent { width: 66px; height: 5px; border-radius: 99px; background: var(--brand); margin-bottom: 38px; }

.auth-features { display: flex; flex-direction: column; gap: 22px; }
.auth-feature { display: flex; gap: 16px; align-items: flex-start; }
.auth-feat-ico { flex: none; width: 50px; height: 50px; border-radius: 15px; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; background: #fff; box-shadow: var(--shadow-sm); }
.auth-feat-ico.brand { color: var(--brand); background: var(--brand-soft); }
.auth-feat-ico.green { color: var(--green-dark); background: var(--green-soft); }
.auth-feat-t { font-family: var(--font-head); font-weight: 700; font-size: 16.5px; color: var(--color-text-main); }
.auth-feat-d { font-size: 13.5px; color: var(--color-text-soft); margin-top: 2px; line-height: 1.5; }

/* RIGHT — card */
.auth-form-container { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card {
  width: 100%; max-width: 440px; border-radius: var(--r-large);
  background: var(--surface-1); border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-lg); padding: 34px 36px;
}
.auth-card h2 { color: var(--color-text-main); }
#mockModeTag { box-shadow: var(--shadow); }

.auth-welcome { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; background: var(--brand-soft); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.auth-avatar img { width: 30px; height: 30px; }
.auth-welcome-sub { margin: 3px 0 0; font-size: 13.5px; color: var(--color-text-muted); }

/* input with leading icon (+ optional eye toggle) */
.auth-input { position: relative; }
.auth-input .auth-input-ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }
.auth-input input { width: 100%; padding-left: 42px; }
.auth-input:has(.auth-eye) input { padding-right: 44px; }
.auth-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 6px; cursor: pointer; color: var(--color-text-muted); border-radius: 8px; display: inline-flex; }
.auth-eye:hover { color: var(--color-primary); background: var(--surface-hover); }

.auth-link { color: var(--color-secondary); font-size: 13px; font-weight: 600; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-link.strong { font-weight: 700; }

.auth-submit { margin-top: 4px; font-size: 15.5px; padding: 13px 18px; }

.auth-divider { display: flex; align-items: center; gap: 14px; margin: 20px 0; color: var(--color-text-muted); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }

.auth-google { width: 100%; background: #fff; color: var(--color-text-main); border: 1.5px solid var(--border-strong); gap: 10px; }
.auth-google:hover { background: var(--surface-hover); filter: none; }
.g-mark { width: 18px; height: 18px; flex: none; }
.auth-switch { text-align: center; font-size: 13.5px; color: var(--color-text-muted); margin-top: 20px; }

/* ----------------------------------------------------------------------------
   20. SUSPENDED OVERLAY
   ---------------------------------------------------------------------------- */
.suspended-overlay {
  display: none;            /* JS toggles to flex */
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--color-bg-base) 30%, rgba(11, 15, 25, 0.78));
  z-index: 1000;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.suspended-overlay .glass-card { box-shadow: var(--shadow-lg); }

/* ----------------------------------------------------------------------------
   21. BILLING PLAN CARDS / SUMMARY TILES (JS-rendered)
   ---------------------------------------------------------------------------- */
#plansSelectionGrid .glass-card { transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
#plansSelectionGrid .glass-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--color-primary) 40%, transparent) !important;
  box-shadow: var(--shadow);
}

/* ----------------------------------------------------------------------------
   22. BILL PRINT DOCUMENT (renderDoc) — class names preserved
   ---------------------------------------------------------------------------- */
.bill-stage {
  background: color-mix(in srgb, var(--color-text-main) 14%, var(--surface-2));
  padding: 18px;
  border-radius: var(--r-medium);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}
.bill-document-preview {
  background: #fff;
  color: #111;
  font-family: 'Sarabun', 'Sarabun', sans-serif;
  max-width: 780px;
  margin: 0 auto;
  padding: 34px 38px;
  border-radius: 8px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35);
  font-size: 14.5px;
  line-height: 1.5;
}
.bd-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 2px solid #111;
  padding-bottom: 11px;
}
.bd-head { display: flex; gap: 12px; align-items: flex-start; max-width: 62%; }
.bd-head img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex: none; }
.bd-shop .nm { font-family: 'Sarabun', sans-serif; font-size: 20px; font-weight: 700; }
.bd-shop .meta { font-size: 13px; color: #333; margin-top: 3px; white-space: pre-line; }
.bd-title { text-align: right; }
.bd-title .t { font-family: 'Sarabun', sans-serif; font-size: 19px; font-weight: 700; }
.bd-title .ts { font-size: 11px; letter-spacing: 1px; color: #555; }
.bd-title .doc { font-size: 13px; margin-top: 7px; }
.bd-cust { display: flex; justify-content: space-between; gap: 18px; margin: 14px 0 8px; font-size: 13.5px; }
.bd-cust .lbl { color: #555; font-weight: 600; }

table.bd { width: 100%; border-collapse: collapse; }
table.bd th, table.bd td { border: 1px solid #111; padding: 7px 8px; font-size: 13.5px; }
table.bd th { background: #f0f0f0; font-weight: 700; text-align: center; }
table.bd td.c { text-align: center; }
table.bd td.r { text-align: right; font-variant-numeric: tabular-nums; }
table.bd tfoot td { font-weight: 700; }
table.bd tfoot td.r { text-align: right; }

.bd-words { margin-top: 8px; font-size: 13px; border: 1px dashed #888; padding: 6px 10px; border-radius: 4px; background: #fafafa; }
.bd-pay { margin-top: 10px; font-size: 13px; border: 1px solid #111; padding: 9px 11px; border-radius: 4px; }
.bd-pay b { font-family: 'Sarabun', sans-serif; }
.bd-sign { display: flex; justify-content: space-between; gap: 28px; margin-top: 34px; text-align: center; }
.bd-sign .box { flex: 1; }
.bd-sign .line { border-top: 1px dotted #111; margin: 34px 12px 6px; }
.bd-sign .cap { font-size: 12.5px; color: #333; }

/* ----------------------------------------------------------------------------
   23. RESPONSIVE
   ---------------------------------------------------------------------------- */

/* tablet / small laptop: tighten dashboards */
/* ----------------------------------------------------------------------------
   BOTTOM DOCK (มือถือ) + โลโก้แบรนด์ในแถบบนมือถือ
   ---------------------------------------------------------------------------- */
.bottom-dock {
  display: none;   /* แสดงเฉพาะ ≤820px */
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 950;
  align-items: stretch;
  background: color-mix(in srgb, var(--surface-1) 90%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -6px 24px -12px rgba(0, 0, 0, 0.22);
  padding-bottom: env(safe-area-inset-bottom);
}
.dock-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: 0; cursor: pointer; padding: 7px 1px 5px; min-height: 52px;
  color: var(--color-text-muted); font-family: var(--font-body); font-size: 9.5px; font-weight: 600;
  position: relative; -webkit-tap-highlight-color: transparent; transition: color 0.15s ease, transform 0.1s ease;
}
.dock-item .ico { font-size: 20px; line-height: 1; }
.dock-item.active { color: var(--color-primary); }
.dock-item.active::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--color-primary);
}
.dock-item:active { transform: scale(0.93); }
.avatar.avatar-dock { width: 24px; height: 24px; min-width: 24px; font-size: 10px; border-radius: 50%; }

.mobile-topbar-logo { display: none; width: 30px; height: 30px; flex: none; }

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* below 992px: auto-collapse the desktop rail (labels hidden) */
@media (max-width: 992px) and (min-width: 821px) {
  .sidebar { width: var(--sidebar-rail); padding: 22px 10px; }
  .main-container { margin-left: var(--sidebar-rail); width: calc(100% - var(--sidebar-rail)); }
  .title-brand,
  .shop-name-display,
  #shopStatusBadge,
  #userEmailDisplay,
  .nav-item > span:not(.em):not(.icon):not(.ico):not(.badge) { display: none; }
  .nav-item .ico { display: inline-flex; align-items: center; justify-content: center; font-size: 1.25em; }
  .brand-logo-area { justify-content: center; padding: 4px 0; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .sidebar > div:last-child .btn span:not(.icon) { display: none; }
  .sidebar > div:last-child .btn { padding: 11px 0; }
}

/* มือถือ (≤820px): ซ่อน sidebar เดสก์ท็อป ใช้ bottom dock แทน — layout ต่างจากคอม */
@media (max-width: 820px) {
  /* ซ่อน sidebar ด้วย visibility (ไม่ใช่ display:none) เพื่อให้ #accountMenu โผล่เป็น bottom sheet ได้ */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 0;
    visibility: hidden; pointer-events: none; overflow: hidden;
    padding: 0; box-shadow: none; border: 0;
  }
  .sidebar-backdrop { display: none; }

  .main-container {
    margin-left: 0; width: 100%;
    padding: 14px 14px calc(78px + env(safe-area-inset-bottom));
  }

  .bottom-dock { display: flex; }
  .mobile-topbar-logo { display: block; }

  .top-bar { margin-bottom: 14px; gap: 10px; padding-top: env(safe-area-inset-top); }
  #currentPageTitle { font-size: 18px; }
  .topbar-right .sync-indicator { display: none; }   /* ประหยัดพื้นที่บนจอเล็ก */

  .grid-2, .grid-3, .grid-4, .dash-grid { grid-template-columns: 1fr; }
  #dashKpiRow { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
}

@media (max-width: 540px) {
  #dashKpiRow { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
}

/* very small: auth becomes single-column */
@media (max-width: 768px) {
  .auth-container { flex-direction: column; }
  .auth-hero { display: none; }
  .auth-card { box-shadow: var(--shadow); }
  .recipe-row { grid-template-columns: 1fr 1fr; }
  .bd-top, .bd-cust, .bd-sign { flex-direction: column; }
  .bd-title { text-align: left; }
  .bd-head { max-width: 100%; }
}

/* ----------------------------------------------------------------------------
   24. PRINT
   ---------------------------------------------------------------------------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff !important; color: #000 !important; font-size: 13px; }
  .sidebar, .sidebar-backdrop, .top-bar, .glow-container, .btn, .suspended-overlay,
  .sub-tabs, #authScreen,
  .app-layout > main > section:not(#posPage),
  .glass-card:not(:has(#billDoc)),
  h2, h3, hr, p.hint, .bill-stage {
    display: none !important;
  }
  .app-layout { display: block !important; }
  .main-container { margin-left: 0 !important; width: 100% !important; padding: 0 !important; }
  .glass-card:has(#billDoc) { border: 0 !important; box-shadow: none !important; padding: 0 !important; background: #fff !important; }
  .bill-document-preview {
    box-shadow: none !important;
    border-radius: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #000 !important;
  }
  .bd-head img { filter: grayscale(1); }
  table.bd th, .bd-words { background: #fff !important; }
}

/* ============================================================================
   25. SIDEBAR RESTRUCTURE — brand zone, nav zone, user card, account menu
   ----------------------------------------------------------------------------
   Layout contract:
     .sidebar is already display:flex / flex-direction:column / justify-content:
     space-between. We keep TWO direct children:
       1) .sidebar-top   — brand + nav-section-label + .nav-menu  (scrolls)
       2) .sidebar-bottom — wraps #userCardBtn + #accountMenu      (pinned)
   If the markup keeps plain <div>s instead of these classes, the existing
   `justify-content:space-between` already pins the last child to the bottom,
   so these helpers are additive, not required.
   ============================================================================ */

.sidebar-top {
  display: flex;
  flex-direction: column;
  min-height: 0;            /* allow the nav to shrink + scroll */
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-bottom {
  flex: none;
  position: relative;       /* anchor for #accountMenu popover */
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

/* small muted section divider label ('เมนู') above the nav items */
.nav-section-label {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 6px 0 6px;
  padding: 0 14px;
  user-select: none;
  white-space: nowrap;
}

/* ----------------------------------------------------------------------------
   25a. AVATAR (shared by user card + account menu head)
   ---------------------------------------------------------------------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-primary), var(--primary-strong));
  color: var(--on-brand);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
/* logo variant: an <img> inside .avatar fills the square */
.avatar img,
.avatar.has-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar.avatar-lg { width: 46px; height: 46px; border-radius: 14px; font-size: 16px; }

/* ----------------------------------------------------------------------------
   25b. USER ACCOUNT CARD (#userCardBtn) — framed clickable button, full width
   ---------------------------------------------------------------------------- */
.user-card {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: var(--r-medium);
  border: 1px solid var(--border-soft);
  background: var(--surface-1);
  color: var(--color-text-main);
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.user-card:hover {
  background: var(--surface-hover);
  border-color: color-mix(in srgb, var(--color-primary) 32%, var(--border-strong));
  box-shadow: var(--shadow-sm);
}
.user-card:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.user-card:active { transform: translateY(1px); }
.user-card.open,
.user-card[aria-expanded="true"] {
  background: var(--primary-softer);
  border-color: color-mix(in srgb, var(--color-primary) 40%, var(--border-strong));
}

.user-card-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}
.user-card-info .user-card-name {
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* the status badge sits in the card; keep it compact */
.user-card .shop-status-badge { align-self: flex-start; font-size: 10.5px; padding: 2px 8px; }

/* chevron hint that the card opens a menu */
.user-card-chevron {
  flex: none;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: transform 0.2s var(--ease-out), color 0.16s ease;
}
.user-card-chevron .ico, .user-card-chevron .icon { font-size: 1.05em; }
.user-card:hover .user-card-chevron { color: var(--color-primary); }
.user-card.open .user-card-chevron,
.user-card[aria-expanded="true"] .user-card-chevron { transform: rotate(180deg); color: var(--color-primary); }

/* ----------------------------------------------------------------------------
   25c. ACCOUNT MENU POPOVER (#accountMenu)
   ----------------------------------------------------------------------------
   Toggle mechanism: #accountMenu.open  (JS adds/removes .open).
   Default hidden; .open reveals it anchored ABOVE the user card.
   ---------------------------------------------------------------------------- */
#accountMenu {
  position: absolute;
  bottom: calc(100% + 8px);   /* float above the .sidebar-bottom card */
  left: 0;
  right: 0;
  z-index: 160;
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-medium);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  /* hidden state */
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.98);
  transform-origin: bottom center;
  transition: opacity 0.16s ease, transform 0.18s var(--ease-out), visibility 0.16s ease;
}
#accountMenu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* head: avatar + name + email */
.account-menu-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 6px;
}
.account-menu-head .account-menu-id { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.account-menu-head .account-menu-name {
  font-size: var(--fs-base);
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* email moves here; relax the legacy sidebar-footer rules for this context */
.account-menu-head #userEmailDisplay {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin: 0;
  padding: 0;
  word-break: break-all;
  line-height: 1.3;
}

/* plan row: status badge + upgrade button */
.account-plan-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 8px 10px;
  margin: 0 2px 6px;
  border-radius: var(--r-small);
  background: var(--primary-softer);
}
.account-plan-row .btn-sm { flex: none; }

.account-menu-sep { height: 1px; background: var(--border-soft); margin: 6px 2px; border: 0; }

/* item rows */
.account-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r-small);
  background: transparent;
  color: var(--color-text-soft);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.14s ease, color 0.14s ease;
}
.account-item .ico, .account-item .icon { font-size: 1.12em; flex: none; width: 1.12em; text-align: center; color: var(--color-text-muted); }
.account-item:hover { background: var(--surface-hover); color: var(--color-primary); }
.account-item:hover .ico, .account-item:hover .icon { color: var(--color-primary); }
.account-item:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.account-item span:last-child { flex: 1 1 auto; }

/* danger (sign out) — red text + tint on hover */
.account-item.danger { color: var(--danger); }
.account-item.danger .ico, .account-item.danger .icon { color: var(--danger); }
.account-item.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.account-item.danger:hover .ico, .account-item.danger:hover .icon { color: var(--danger); }

/* disabled (switch shop — coming soon) */
.account-item.disabled,
.account-item:disabled {
  color: var(--color-text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}
.account-item.disabled:hover,
.account-item:disabled:hover { background: transparent; color: var(--color-text-muted); }
.account-item.disabled .ico, .account-item.disabled .icon,
.account-item:disabled .ico, .account-item:disabled .icon { color: var(--color-text-muted); }

/* optional click-catch backdrop (JS may add .open; outside-click also works) */
.account-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 155;
  background: transparent;
}
.account-menu-backdrop.open { display: block; }

/* ----------------------------------------------------------------------------
   25d. COLLAPSED-RAIL adjustments for the new sidebar bits
   ---------------------------------------------------------------------------- */
.app-layout.sidebar-collapsed .nav-section-label { display: none; }

/* user card shows ONLY the avatar in rail mode */
.app-layout.sidebar-collapsed .user-card {
  justify-content: center;
  padding: 9px 0;
  gap: 0;
}
.app-layout.sidebar-collapsed .user-card-info,
.app-layout.sidebar-collapsed .user-card-chevron,
.app-layout.sidebar-collapsed .user-card .shop-status-badge { display: none; }

/* account menu opens to the RIGHT of the rail instead of stretching the card */
.app-layout.sidebar-collapsed #accountMenu {
  left: calc(100% + 10px);
  right: auto;
  bottom: 0;
  width: 264px;
  transform-origin: bottom left;
}

/* ----------------------------------------------------------------------------
   26. DRAWER SYSTEM — slide-in right panel for add/edit forms
   ----------------------------------------------------------------------------
   Toggle mechanism (match these in JS):
     open  -> add .open to BOTH the .drawer-overlay AND the .drawer
     close -> remove .open from both
     wide recipe form -> .drawer.drawer-wide
   ---------------------------------------------------------------------------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 960;
  background: rgba(11, 15, 25, 0.46);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s var(--ease-out), visibility 0.24s var(--ease-out);
}
.drawer-overlay.open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 970;
  width: min(440px, 100vw);
  max-width: 100vw;
  height: 100vh;
  background: var(--surface-1);
  border-left: 1px solid var(--border-soft);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s var(--ease-out), visibility 0.3s var(--ease-out);
}
.drawer.open { transform: translateX(0); visibility: visible; }

/* wider variant for the recipe form (ingredient rows + cost summary + steps) */
.drawer.drawer-wide { width: min(680px, 100vw); }

/* header: title + close button */
.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-1);
}
.drawer-header h3,
.drawer-title {
  margin: 0;
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--r-small);
  border: 1px solid var(--border-soft);
  background: var(--surface-3);
  color: var(--color-text-soft);
  cursor: pointer;
  transition: var(--transition);
}
.drawer-close:hover { background: var(--surface-hover); color: var(--color-primary); border-color: var(--color-primary); }
.drawer-close:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.drawer-close .ico, .drawer-close .icon { font-size: 1.2em; }

/* scrollable body */
.drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px;
}

/* optional sticky footer for primary save action */
.drawer-footer {
  flex: none;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding: 16px 22px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-1);
}

/* mobile: drawers go full-width */
@media (max-width: 820px) {
  .drawer,
  .drawer.drawer-wide { width: 100vw; max-width: 100vw; border-left: 0; }
  .drawer-body { padding: 18px 16px; }
  .drawer-header { padding: 16px; }
  .drawer-footer { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }

  /* เมนูบัญชีบนมือถือ = bottom sheet ลอยเหนือ dock (เปิดจากปุ่ม "บัญชี" ใน dock) */
  .app-layout #accountMenu {
    position: fixed; left: 10px; right: 10px; top: auto;
    bottom: calc(82px + env(safe-area-inset-bottom)); width: auto; z-index: 1000;
    transform-origin: bottom center;
  }
}

/* ----------------------------------------------------------------------------
   CUSTOM DIALOGS & TOASTS (replace native alert/confirm/prompt)
   ---------------------------------------------------------------------------- */
.ui-modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: color-mix(in srgb, var(--color-text-main) 45%, transparent);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .18s ease;
}
.ui-modal-overlay.open { opacity: 1; }
.ui-modal {
  width: 100%; max-width: 400px; text-align: center;
  background: var(--surface-1); border: 1px solid var(--border-soft);
  border-radius: var(--r-large); box-shadow: var(--shadow-lg);
  padding: 28px 26px 22px;
  transform: translateY(10px) scale(.97); transition: transform .2s var(--ease-out);
}
.ui-modal-overlay.open .ui-modal { transform: none; }
.ui-modal-icon {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 14px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 26px;
}
.ui-modal-icon.brand { color: var(--brand); background: var(--brand-soft); }
.ui-modal-icon.danger { color: var(--bad-fg); background: var(--bad-bg); }
.ui-modal-icon.warn { color: var(--warn-fg); background: var(--warn-bg); }
.ui-modal-icon.success { color: var(--ok-fg); background: var(--ok-bg); }
.ui-modal-title { font-family: var(--font-head); font-weight: 700; font-size: 18px; color: var(--color-text-main); margin-bottom: 6px; }
.ui-modal-msg { font-size: 14.5px; color: var(--color-text-soft); line-height: 1.55; }
.ui-modal-input { width: 100%; margin-top: 16px; text-align: left; }
.ui-modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.ui-modal-actions .btn { flex: 1; width: auto; }

.ui-toasts { position: fixed; top: 18px; right: 18px; z-index: 9100; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.ui-toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 360px;
  background: var(--surface-1); color: var(--color-text-main);
  border: 1px solid var(--border-soft); border-left: 4px solid var(--color-secondary);
  border-radius: var(--r-medium); box-shadow: var(--shadow);
  padding: 12px 16px; font-size: 14px; font-weight: 600;
  transform: translateX(120%); opacity: 0; transition: all .25s var(--ease-out);
}
.ui-toast.open { transform: none; opacity: 1; }
.ui-toast .icon { flex: none; }
.ui-toast-success { border-left-color: var(--green); } .ui-toast-success .icon { color: var(--green); }
.ui-toast-error { border-left-color: var(--danger); } .ui-toast-error .icon { color: var(--danger); }
.ui-toast-warning { border-left-color: #f59e0b; } .ui-toast-warning .icon { color: #f59e0b; }
@media (max-width: 820px) { .ui-toasts { left: 12px; right: 12px; } .ui-toast { max-width: none; } }

/* ----------------------------------------------------------------------------
   LANG TOGGLE BUTTON
   ---------------------------------------------------------------------------- */
.sidebar-lang-row { padding: 2px 12px 8px; }
.lang-toggle-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 1px solid var(--border-soft);
  border-radius: 20px; padding: 4px 11px;
  font-size: 12px; font-weight: 600; color: var(--color-text-muted);
  cursor: pointer; transition: var(--transition);
}
.lang-toggle-btn:hover { background: var(--surface-hover); color: var(--color-text-main); }

/* ----------------------------------------------------------------------------
   CATEGORY CHIPS (filter) + BADGE
   ---------------------------------------------------------------------------- */
.cat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-1); border: 1.5px solid var(--border-soft);
  color: var(--color-text-soft); border-radius: var(--r-pill);
  padding: 6px 12px; font-family: var(--font-body); font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: var(--transition); -webkit-tap-highlight-color: transparent;
}
.cat-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.cat-chip.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.cat-chip-n { font-size: 11px; opacity: .75; background: color-mix(in srgb, currentColor 16%, transparent); padding: 0 6px; border-radius: var(--r-pill); }
.cat-chip.active .cat-chip-n { background: rgba(255, 255, 255, 0.25); opacity: 1; }
.cat-badge {
  display: inline-block; vertical-align: middle;
  background: var(--color-primary); color: #fff;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-pill); white-space: nowrap;
}

/* ----------------------------------------------------------------------------
   GENERIC MODAL OVERLAY (.modal-overlay) — used by receipt, categories, etc.
   ---------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 5000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.52);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface-1); border: 1px solid var(--border-soft);
  border-radius: var(--r-large); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  animation: modalIn .18s ease;
}
@keyframes modalIn {
  from { transform: translateY(14px) scale(.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; background: var(--surface-1); z-index: 1;
}
.modal-header h3 { margin: 0; font-size: 16px; font-family: var(--font-head); }
.modal-close {
  background: none; border: 0; cursor: pointer; font-size: 20px; line-height: 1;
  color: var(--color-text-muted); padding: 2px 8px; border-radius: 6px;
  transition: background .15s;
}
.modal-close:hover { background: var(--surface-hover); }
.modal-body { padding: 16px 18px; }
.modal-footer {
  padding: 12px 18px 16px; display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--border-soft);
}
@media (max-width: 820px) {
  /* bottom sheet style on mobile */
  #posReceiptOverlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #posReceiptOverlay .pos-receipt {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 18px 18px 0 0 !important;
    margin: 0 !important;
    padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
  }
  .rc-actions {
    padding: 4px 0 0 !important;
  }
}

/* ----------------------------------------------------------------------------
   IMPORT REVIEW MODAL (editable preview before commit)
   ---------------------------------------------------------------------------- */
.import-modal-overlay {
  position: fixed; inset: 0; z-index: 9200; display: flex; align-items: center; justify-content: center;
  padding: 18px; background: color-mix(in srgb, var(--color-text-main) 45%, transparent);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.import-modal {
  width: 100%; max-width: 1160px; max-height: 90vh; display: flex; flex-direction: column;
  background: var(--surface-1); border: 1px solid var(--border-soft);
  border-radius: var(--r-large); box-shadow: var(--shadow-lg); overflow: hidden;
}
.import-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.import-modal-body { padding: 8px 12px; overflow: auto; }
.import-modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.import-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.import-tbl th { text-align: left; padding: 8px 8px; color: var(--color-text-muted); font-weight: 600; position: sticky; top: 0; background: var(--surface-1); }
.import-tbl td { padding: 4px 6px; border-top: 1px solid var(--border-soft); }
.import-tbl input { width: 100%; padding: 7px 8px; font-size: 13px; }
.import-tbl input.bad { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.import-row-del { background: none; border: 0; color: var(--danger); cursor: pointer; padding: 6px; border-radius: 8px; }
.import-row-del:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.import-warn { color: var(--warn-fg); font-size: 12.5px; }
@media (max-width: 820px) { .import-modal { max-width: 100%; max-height: 94vh; } .import-tbl { font-size: 12px; } }

/* ============================================================
   POS QUICK SELL — ขายด่วน
   ============================================================ */
.pos-subtab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--surface-1);
  border-radius: var(--r-small);
  padding: 4px;
}
.pos-subtab-bar .btn { flex: 1; font-size: 13px; }

/* ----------------------------------------------------------------------------
   MOBILE CARD LIST — replaces table rows on ≤820px
   ---------------------------------------------------------------------------- */
.item-cards-mobile { display: none; }
@media (max-width: 820px) {
  .lst-desktop-wrap { display: none !important; }
  .item-cards-mobile { display: block; }
}
.item-card {
  background: var(--surface-1); border: 1px solid var(--border-soft);
  border-radius: var(--r-medium); margin-bottom: 10px; overflow: hidden;
}
.item-card-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px 8px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.item-card-row:active { background: var(--surface-hover); }
.item-card-title {
  font-weight: 700; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-card-sub {
  font-size: 12px; color: var(--color-text-muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-card-stats {
  display: flex; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft);
}
.item-card-stat {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 7px 4px; gap: 2px; min-width: 0;
  border-right: 1px solid var(--border-soft); text-decoration: none;
}
.item-card-stat:last-child { border-right: none; }
.item-card-stat span { font-size: 10px; color: var(--color-text-muted); }
.item-card-stat b { font-size: 13px; font-weight: 700; }
.item-card-actions { display: flex; }
.item-card-actions .btn {
  flex: 1; border-radius: 0 !important; border: none !important;
  border-right: 1px solid var(--border-soft) !important;
  font-size: 12px; padding: 9px 4px; min-height: 42px;
}
.item-card-actions .btn:last-child { border-right: none !important; }

.pos-qs-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: flex-start;
}
@media (max-width: 820px) { .pos-qs-layout { grid-template-columns: 1fr; } }

.pos-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
}

.pos-product-card {
  background: var(--surface-1);
  border-radius: var(--r-medium);
  padding: 14px 12px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.14s;
  text-align: center;
  user-select: none;
}
.pos-product-card:hover { border-color: var(--color-primary); background: var(--surface-2); transform: translateY(-2px); }
.pos-product-card.out-of-stock { opacity: 0.42; cursor: not-allowed; }
.pos-product-card .ppc-name { font-weight: 700; font-size: 13px; margin-bottom: 6px; line-height: 1.3; }
.pos-product-card .ppc-price { font-size: 17px; font-weight: 800; color: var(--color-primary); margin-bottom: 4px; }
.pos-product-card .ppc-stock { font-size: 11px; font-weight: 600; }
.pos-product-card .ppc-opts-badge {
  display: inline-block; font-size: 9px; font-weight: 700;
  background: var(--color-primary); color: #fff;
  border-radius: 20px; padding: 1px 6px; margin-bottom: 4px;
  letter-spacing: 0.3px;
}

/* POS category filter bar */
.pos-cat-chip {
  padding: 5px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border-soft); background: var(--surface-1); color: var(--color-text-soft);
  cursor: pointer; white-space: nowrap; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pos-cat-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.pos-cat-chip.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* POS option sheet chips */
.pos-opt-chip {
  padding: 7px 16px; border-radius: 20px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--border-soft); background: var(--surface-1); color: var(--color-text-soft);
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pos-opt-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.pos-opt-chip.selected { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.pos-cart-panel { position: sticky; top: 80px; }

.pos-cart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.pos-cart-item .pci-name { font-size: 13px; font-weight: 600; }
.pos-cart-item .pci-opts { font-size: 10px; color: var(--color-text-muted); margin-top: 2px; }
.pos-cart-item .pci-qty { display: flex; align-items: center; gap: 4px; }
.pos-cart-item .pci-qty button {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--color-primary); background: transparent;
  color: var(--color-primary); font-size: 14px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.pos-cart-item .pci-qty button:hover { background: var(--color-primary); color: #fff; }
.pos-cart-item .pci-qty span { min-width: 22px; text-align: center; font-weight: 700; }
.pos-cart-item .pci-total { font-weight: 700; font-size: 13px; min-width: 68px; text-align: right; }

.pos-cart-footer { padding-top: 14px; margin-top: 4px; }
.pos-cart-grand { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.pos-cart-grand .label { font-size: 14px; color: var(--color-text-muted); }
.pos-cart-grand .amount { font-size: 24px; font-weight: 800; color: var(--color-primary); }

/* ===== Thermal Receipt Modal ===== */
.pos-receipt {
  background: #fff;
  color: #111;
  font-family: 'Courier New', Courier, monospace;
  width: 320px;
  max-width: 95vw;
  border-radius: 8px;
  padding: 24px 20px 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.28);
  margin: auto;
  position: relative;
}
.rc-header { text-align: center; margin-bottom: 10px; }
.rc-shop { font-size: 16px; font-weight: 800; letter-spacing: 0.5px; }
.rc-sub { font-size: 11px; color: #555; margin-top: 2px; }
.rc-divider { border: none; border-top: 1px dashed #999; margin: 10px 0; }
.rc-items { width: 100%; border-collapse: collapse; font-size: 12px; }
.rc-items th { font-size: 11px; color: #555; border-bottom: 1px solid #ddd; padding-bottom: 4px; }
.rc-items td, .rc-items th { padding: 3px 2px; }
.rc-items .rc-c { text-align: center; width: 36px; }
.rc-items .rc-r { text-align: right; width: 72px; }
.rc-total { display: flex; justify-content: space-between; font-size: 15px; font-weight: 800; margin-top: 4px; }
.rc-footer { text-align: center; font-size: 11px; color: #777; margin: 10px 0 14px; }
.rc-actions { display: flex; gap: 8px; }
.rc-actions .btn { flex: 1; font-size: 13px; }

@media print {
  body > *:not(#posReceiptOverlay) { display: none !important; }
  #posReceiptOverlay { position: static !important; background: none !important; padding: 0 !important; }
  .pos-receipt { box-shadow: none !important; border-radius: 0 !important; width: 80mm !important; }
  .no-print { display: none !important; }
}
