/* ==============================================================================
 * SHADCN / TWEAKCN ERP DESIGN SYSTEM
 * Theme variables are loaded canonically via packages/ui/src/styles/theme.css
 * ============================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
}

body {
  height: 100%;
  font-family: var(--font-sans, 'Inter', -apple-system, sans-serif);
  font-size: 13.5px;
  line-height: 1.5;
  background-color: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

[dir="rtl"], [dir="rtl"] body, html[lang="ar"], html[dir="rtl"] {
  font-family: var(--font-arabic, 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}
[dir="rtl"] button, [dir="rtl"] input, [dir="rtl"] select, [dir="rtl"] textarea {
  font-family: var(--font-arabic, 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

.mono { font-family: var(--font-mono, 'JetBrains Mono', monospace); }
.tabular-nums { font-variant-numeric: tabular-nums; }

/* Layout Shell */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 52px 1fr;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.app-shell.collapsed,
.app-shell.sidebar-collapsed { grid-template-columns: 64px 1fr; }
[dir="rtl"] .app-shell { direction: rtl; }

/* Topbar */
.topbar {
  grid-column: 2;
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.page-heading { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--foreground); }

/* Sidebar */
.sidebar {
  grid-row: 1 / 3;
  background: var(--sidebar);
  border-inline-end: 1px solid var(--sidebar-border);
  color: var(--sidebar-foreground);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 30;
  transition: width 0.2s ease;
}
.sidebar-brand {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  white-space: nowrap;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--sidebar-primary, var(--primary));
  color: var(--sidebar-primary-foreground, var(--primary-foreground));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.brand-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--sidebar-foreground); }

.sidebar-scroll {
  overflow-y: auto;
  padding: 10px 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Nav Link (Top-level) */
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: calc(var(--radius) - 2px);
  color: var(--sidebar-foreground);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.nav-link:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.nav-link.active {
  background: var(--sidebar-accent, var(--secondary));
  color: var(--sidebar-accent-foreground, var(--secondary-foreground));
  font-weight: 600;
}
.nav-link .icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }

/* Collapsible Module Group */
details.nav-group { margin-bottom: 2px; }
details.nav-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 10px;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
  transition: all 0.15s ease;
}
details.nav-group > summary::-webkit-details-marker,
details.nav-group > summary::marker {
  display: none !important;
}
details.nav-group > summary:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.group-left { display: flex; align-items: center; gap: 8px; }
.group-left .icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.chevron-icon { width: 14px; height: 14px; opacity: 0.7; transition: transform 0.15s ease; flex-shrink: 0; }
details[open] > summary .chevron-icon { transform: rotate(90deg); }
[dir="rtl"] details:not([open]) > summary .chevron-icon { transform: rotate(180deg); }
[dir="rtl"] details[open] > summary .chevron-icon { transform: rotate(90deg); }

/* Submenu Child Hierarchy Guide Line */
.sub-menu {
  margin-inline-start: 18px;
  padding-inline-start: 10px;
  border-inline-start: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
  margin-bottom: 4px;
}
.sub-link {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 8px;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.sub-link:hover { background: var(--sidebar-accent); color: var(--foreground); }
.sub-link.active {
  background: var(--sidebar-accent);
  color: var(--foreground);
  font-weight: 600;
  box-shadow: 0 1px 2px 0 rgba(0,0,0,0.04);
}
.sub-link .sub-icon { width: 14px; height: 14px; opacity: 0.75; flex-shrink: 0; }

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

/* ==============================================================================
 * COLLAPSED / MINI SIDEBAR REFINEMENT (PROPER PARENT ICONS)
 * ============================================================================== */
.collapsed .sidebar-brand,
.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
.collapsed .brand-title,
.sidebar-collapsed .brand-title { display: none !important; }
.collapsed .nav-text,
.sidebar-collapsed .nav-text { display: none !important; }
.collapsed .group-title,
.sidebar-collapsed .group-title { display: none !important; }
.collapsed .sub-menu,
.sidebar-collapsed .sub-menu { display: none !important; }
.collapsed .chevron-icon,
.sidebar-collapsed .chevron-icon { display: none !important; }

.collapsed .nav-link,
.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 0;
  width: 38px;
  height: 38px;
  margin: 2px auto;
}
.collapsed details.nav-group,
.sidebar-collapsed details.nav-group {
  margin: 2px auto;
  display: flex;
  justify-content: center;
}
.collapsed details.nav-group > summary,
.sidebar-collapsed details.nav-group > summary {
  justify-content: center;
  align-items: center;
  padding: 0;
  width: 38px;
  height: 38px;
  margin: 0 auto;
  border-radius: var(--radius);
}
.collapsed details.nav-group.active > summary,
.collapsed details.nav-group > summary.active,
.sidebar-collapsed details.nav-group.active > summary,
.sidebar-collapsed details.nav-group > summary.active {
  background: var(--sidebar-accent);
  color: var(--foreground);
}
.collapsed details.nav-group > summary .group-left,
.sidebar-collapsed details.nav-group > summary .group-left {
  gap: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.collapsed details.nav-group > summary .icon,
.sidebar-collapsed details.nav-group > summary .icon {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}
.collapsed .sidebar-footer .nav-link,
.sidebar-collapsed .sidebar-footer .nav-link { width: 38px; height: 38px; margin: 0 auto; }

/* Main Content Area */
.main-scroll {
  grid-column: 2;
  overflow-y: auto;
  background-color: var(--background);
}
.main-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ==============================================================================
 * SHADCN UI BUTTONS
 * ============================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--input-height, 34px);
  padding: 0 14px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 2px 0 rgba(0,0,0,0.06);
}
.btn-primary:hover { opacity: 0.92; }
.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--accent); color: var(--accent-foreground); }
.btn-ghost {
  background: transparent;
  color: var(--foreground);
}
.btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); }
.btn-icon {
  width: var(--input-height, 34px);
  height: var(--input-height, 34px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--card);
}
.btn-icon:hover { background: var(--accent); }

/* ==============================================================================
 * SHADCN UI CUSTOM SELECT POPOVER COMPONENT (NO NATIVE HTML SELECT)
 * ============================================================================== */
.shadcn-select-container {
  position: relative;
  display: inline-block;
  width: 100%;
}
.shadcn-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--input-height, 34px);
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  background-color: var(--card);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground);
  box-shadow: 0 1px 2px 0 rgba(0,0,0,0.04);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.shadcn-select-trigger:focus, .shadcn-select-trigger:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 1px var(--ring);
}
.shadcn-select-trigger .chevron {
  width: 14px;
  height: 14px;
  opacity: 0.6;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.shadcn-select-container.open .shadcn-select-trigger .chevron {
  transform: rotate(180deg);
}
.shadcn-select-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  min-width: 180px;
  background-color: var(--popover, #ffffff);
  color: var(--popover-foreground, #0f172a);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 6px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  padding: 4px;
  z-index: 500;
  display: none;
  animation: popIn 0.15s ease-out;
  max-height: 260px;
  overflow-y: auto;
}
.dark .shadcn-select-popover {
  background-color: var(--popover, #18181b);
  color: var(--popover-foreground, #f4f4f5);
  border-color: var(--border, #27272a);
}
.shadcn-select-container.open .shadcn-select-popover { display: block; }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.shadcn-select-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 12.5px;
  border-radius: calc(var(--radius) - 3px);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s, color 0.12s;
  color: var(--foreground);
}
.shadcn-select-item:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
}
.shadcn-select-item.selected {
  background-color: var(--accent);
  font-weight: 600;
}
.shadcn-select-item .check-icon {
  width: 14px;
  height: 14px;
  opacity: 0;
  color: var(--primary);
}
.shadcn-select-item.selected .check-icon { opacity: 1; }

/* ==============================================================================
 * SHADCN UI DATE PICKER POPOVER COMPONENT (NO NATIVE CALENDAR INPUT)
 * ============================================================================== */
.shadcn-datepicker-container {
  position: relative;
  display: inline-block;
  width: 100%;
}
.shadcn-date-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--input-height, 34px);
  width: 100%;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  background-color: var(--card);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground);
  box-shadow: 0 1px 2px 0 rgba(0,0,0,0.04);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.shadcn-date-trigger:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 1px var(--ring);
}
.shadcn-date-trigger svg { width: 14px; height: 14px; opacity: 0.7; flex-shrink: 0; }

.shadcn-calendar-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 270px;
  background-color: var(--popover, #ffffff);
  color: var(--popover-foreground, #0f172a);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 6px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  padding: 12px;
  z-index: 500;
  display: none;
  animation: popIn 0.15s ease-out;
}
.dark .shadcn-calendar-popover {
  background-color: var(--popover, #18181b);
  color: var(--popover-foreground, #f4f4f5);
  border-color: var(--border, #27272a);
}
.shadcn-datepicker-container.open .shadcn-calendar-popover { display: block; }

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-month { font-size: 13px; font-weight: 600; }
.cal-btn {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; border: 1px solid var(--border); background: transparent;
  cursor: pointer; color: var(--foreground);
}
.cal-btn:hover { background: var(--accent); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-day-name { font-size: 11px; font-weight: 600; color: var(--muted-foreground); padding: 4px 0; }
.cal-day {
  height: 28px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; border-radius: calc(var(--radius) - 3px); cursor: pointer; user-select: none;
}
.cal-day:hover { background: var(--accent); color: var(--accent-foreground); }
.cal-day.selected { background: var(--primary); color: var(--primary-foreground); font-weight: 700; }
.cal-day.today { font-weight: 700; border: 1px solid var(--border); }

/* Form Controls & Inputs */
.form-control {
  height: var(--input-height, 34px);
  padding: 0 12px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input);
  background: var(--card);
  color: var(--foreground);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 1px 2px 0 rgba(0,0,0,0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 1px var(--ring);
}
textarea.form-control { height: 80px; padding: 8px 12px; resize: vertical; }

/* Cards & Tables */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px 0 rgba(0,0,0,0.04);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 18px; }

.table { width: 100%; border-collapse: collapse; text-align: start; }
.table th {
  text-align: start;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  background: color-mix(in srgb, var(--muted) 35%, transparent);
}
.table td {
  padding: 0 14px;
  height: var(--table-row-height, 34px);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table tr:hover td { background: color-mix(in srgb, var(--accent) 50%, transparent); }
.table td.num { text-align: end; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 22px;
  height: auto;
  padding: 2px 9px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap !important;
  flex-shrink: 0;
  width: max-content;
}
.badge-muted { background: var(--muted); color: var(--muted-foreground); }
.badge-info { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.badge-success { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.badge-warning { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); border: 1px solid color-mix(in srgb, var(--warning) 25%, transparent); }
.badge-destructive { background: color-mix(in srgb, var(--destructive) 14%, transparent); color: var(--destructive); }
.table td:has(.badge), .table td.cell-badge { white-space: nowrap; }


/* Status Tabs Strip */
.status-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--border)) transparent;
  -webkit-overflow-scrolling: touch;
}
.status-strip::-webkit-scrollbar {
  height: 3px;
}
.status-strip::-webkit-scrollbar-track {
  background: transparent;
}
.status-strip::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 9999px;
}
.status-strip::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--primary));
}
.status-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.status-tab:hover { background: var(--accent); color: var(--foreground); }
.status-tab.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  font-weight: 600;
}
.status-tab .count-badge {
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(0,0,0,0.08);
  font-weight: 600;
}
.status-tab.active .count-badge { background: rgba(255,255,255,0.25); }

/* KPI Row */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-tile {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
  will-change: transform, box-shadow;
}
.kpi-tile:hover {
  border-color: var(--ring);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
}
.kpi-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted-foreground); }
.kpi-value { font-size: 20px; font-weight: 600; color: var(--foreground); }
.kpi-delta { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--destructive); }

/* Shimmer Loading Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--muted) 25%, var(--border) 37%, var(--muted) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 4px;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.split { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 1000;
  padding: 16px; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  width: 92%; max-width: 680px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden;
  animation: modalPop .15s ease-out;
}
@keyframes modalPop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-body { padding: 20px; max-height: calc(100vh - 170px); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.modal-body .shadcn-select-popover,
.modal-body .shadcn-calendar-popover {
  z-index: 1050;
}
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: color-mix(in srgb, var(--card) 96%, var(--border)); flex-shrink: 0; }

/* Toast */
.toast-msg {
  position: fixed; bottom: 20px; right: 20px; background: var(--card); border: 1px solid var(--border);
  border-left: 4px solid var(--success); padding: 12px 18px; border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); display: none; align-items: center; gap: 10px; z-index: 1100;
  font-size: 13px; font-weight: 500;
}
.toast-msg.show { display: flex; animation: toastSlide .2s ease-out; }
@keyframes toastSlide { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.view-pane { display: none; flex-direction: column; gap: 16px; width: 100%; }
.view-pane.active { display: flex !important; }

/* Top Indeterminate Loading Progress Bar (Lazy Loading Simulation) */
.top-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  z-index: 9999;
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  pointer-events: none;
  box-shadow: 0 0 8px var(--primary);
}

/* Skeleton Loading Helpers */
.skeleton-pulse {
  background: color-mix(in srgb, var(--muted) 80%, transparent);
  border-radius: var(--radius);
  animation: skeletonPulse 1.5s ease-in-out infinite;
}
@keyframes skeletonPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ==============================================================================
 * MOBILE DRAWER & RESPONSIVENESS (BREAKPOINTS: 1024px & 640px)
 * ============================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 990;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--sidebar-foreground);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  margin-inline-start: auto;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.sidebar-close-btn:hover {
  background: var(--sidebar-accent, var(--muted));
}

.card {
  max-width: 100%;
  min-width: 0;
}

.card:has(.table),
.card-table-scroll,
.table-wrap,
.table-container,
.table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  width: 100%;
  overscroll-behavior-x: contain;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 100% !important;
  }
  .app-shell.collapsed,
  .app-shell.sidebar-collapsed {
    grid-template-columns: 100% !important;
  }
  .topbar {
    grid-column: 1 !important;
    padding: 0 14px;
  }
  .main-scroll {
    grid-column: 1 !important;
    padding: 14px;
  }
  .sidebar {
    position: fixed !important;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: 280px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    z-index: 1000 !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  [dir="rtl"] .sidebar {
    transform: translateX(100%);
  }
  .app-shell.drawer-open .sidebar {
    transform: translateX(0) !important;
  }
  .sidebar-close-btn {
    display: inline-flex;
  }
  .split {
    grid-template-columns: 1fr !important;
  }
  .kpi-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 640px) {
  #themeToggleBtn {
    display: none !important;
  }
  .topbar {
    padding: 0 10px;
    gap: 8px;
  }
  .topbar-left {
    min-width: 0;
    flex: 1;
  }
  .topbar .page-heading {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .topbar-right {
    gap: 6px;
    flex-shrink: 0;
  }
  .topbar-right .shadcn-select-container {
    width: 90px !important;
  }
  .topbar-right .shadcn-select-trigger {
    padding: 0 6px !important;
    font-size: 11.5px !important;
  }
  .main-scroll {
    padding: 10px;
  }
  .kpi-row {
    grid-template-columns: 1fr !important;
  }
  .table {
    min-width: 650px;
  }
  .table th,
  .table td {
    white-space: nowrap;
  }
  .status-strip {
    width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  .btn {
    font-size: 12px;
  }
}

/* ==============================================================================
 * POS TERMINAL, THERMAL RECEIPT, ARABIC TYPOGRAPHY & KEYBOARD SHORTCUTS
 * ============================================================================== */

/* Universal Arabic Font Family Fallback */
:lang(ar), [lang="ar"], .ar-text, .font-arabic,
#recStoreAr, #recBadgeInvoice, #recQrCaption, #recFooterThanks,
.arabic-text {
  font-family: 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* POS Category Filter Pills */
.status-pill, .pos-category-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
  user-select: none;
  line-height: 1;
}
.status-pill:hover, .pos-category-pill:hover {
  background: var(--accent);
  color: var(--foreground);
  border-color: var(--ring);
}
.status-pill.active, .pos-category-pill.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* POS Product Cards */
.pos-prod-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  position: relative;
  user-select: none;
}
.pos-prod-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.pos-prod-card:active {
  transform: scale(0.98);
}

/* Receipt Modal Paper Scrollable Container */
#posReceiptModal .modal-card {
  max-height: calc(100vh - 40px) !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}
#receiptPaper {
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: calc(100vh - 160px);
  min-height: 0;
  font-family: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
}
#receiptPaper #recStoreAr,
#receiptPaper #recBadgeInvoice,
#receiptPaper #recQrCaption,
#receiptPaper #recFooterThanks {
  font-family: 'Cairo', sans-serif !important;
  font-weight: 700;
}

/* Keyboard Shortcut Badges */
.kbd-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  color: var(--muted-foreground);
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}
.kbd-badge-primary {
  color: var(--primary-foreground);
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
}

