/* ===== Nama Medical ERP - Design System ===== */

#errorMsg:not(.show) {
  display: none !important;
}

/* ---------- CSS Variables / Themes ---------- */
:root {
  /* Default: Stitch Premium RTL Brand Colors */
  --bg: #f8f9fa;
  --sidebar: #001629;
  --header: #ffffff;
  --accent: #006970;
  --accent-hover: #004f54;
  --accent-glow: rgba(0, 105, 112, 0.1);
  --text: #191c1d;
  --text-dim: #42474d;
  --border: rgba(0, 0, 0, 0.08);
  --selected-bg: rgba(0, 105, 112, 0.1);
  --selected-fg: #006970;
  --hover: rgba(0, 0, 0, 0.02);
  --input: #ffffff;
  --input2: #f3f4f5;
  --card-bg: #ffffff;
  --alt-row: rgba(0, 0, 0, 0.02);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ba1a1a;
  --info: #006970;
  --shadow: rgba(0, 22, 41, 0.05);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --font: 'IBM Plex Sans Arabic', 'Tajawal', 'Inter', -apple-system, sans-serif;
  --font-en: 'IBM Plex Sans', 'Inter', -apple-system, sans-serif;
  --sidebar-width: 260px;
  --header-height: 64px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Theme 1: Dark Green */
[data-theme="1"] {
  --bg: #052e16;
  --sidebar: #14532d;
  --header: #166534;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-glow: rgba(34, 197, 94, 0.15);
  --text: #dcfce7;
  --text-dim: #86efac;
  --border: rgba(255, 255, 255, 0.12);
  --selected-bg: rgba(34, 197, 94, 0.2);
  --selected-fg: #4ade80;
  --card-bg: #14532d;
  --success: #a3e635;
}

/* Theme 2: Purple */
[data-theme="2"] {
  --bg: #1e1033;
  --sidebar: #2e1065;
  --header: #3b0764;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.15);
  --text: #ede9fe;
  --text-dim: #c4b5fd;
  --border: rgba(255, 255, 255, 0.1);
  --selected-bg: rgba(139, 92, 246, 0.2);
  --selected-fg: #a78bfa;
  --card-bg: #2e1065;
  --success: #c084fc;
}

/* Theme 3: Red */
[data-theme="3"] {
  --bg: #1a0000;
  --sidebar: #2d0a0a;
  --header: #450a0a;
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --accent-glow: rgba(239, 68, 68, 0.15);
  --text: #fecaca;
  --text-dim: #f87171;
  --border: rgba(255, 255, 255, 0.1);
  --selected-bg: rgba(239, 68, 68, 0.2);
  --selected-fg: #f87171;
  --card-bg: #2d0a0a;
  --success: #fb923c;
}

/* Theme 4: Gold */
[data-theme="4"] {
  --bg: #1c1207;
  --sidebar: #2c1e0e;
  --header: #3d2a14;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-glow: rgba(245, 158, 11, 0.15);
  --text: #fef3c7;
  --text-dim: #fbbf24;
  --border: rgba(255, 255, 255, 0.1);
  --selected-bg: rgba(245, 158, 11, 0.2);
  --selected-fg: #fbbf24;
  --card-bg: #2c1e0e;
  --success: #a3e635;
}

/* Theme 5: Light Classic (Stitch Theme) */
[data-theme="5"] {
  --bg: #f8f9fa;
  --sidebar: #001629;
  --header: #ffffff;
  --accent: #006970;
  --accent-hover: #004f54;
  --accent-glow: rgba(0, 105, 112, 0.1);
  --text: #191c1d;
  --text-dim: #42474d;
  --border: rgba(0, 0, 0, 0.08);
  --selected-bg: rgba(0, 105, 112, 0.1);
  --selected-fg: #006970;
  --hover: rgba(0, 0, 0, 0.02);
  --input: #ffffff;
  --input2: #f3f4f5;
  --card-bg: #ffffff;
  --alt-row: rgba(0, 0, 0, 0.02);
  --shadow: rgba(0, 22, 41, 0.05);
  --success: #22c55e;
}

/* Theme 6: Light Blue */
[data-theme="6"] {
  --bg: #eff6ff;
  --sidebar: #dbeafe;
  --header: #bfdbfe;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.1);
  --text: #1e3a5f;
  --text-dim: #3b82f6;
  --border: rgba(0, 0, 0, 0.08);
  --selected-bg: rgba(37, 99, 235, 0.15);
  --selected-fg: #1d4ed8;
  --hover: rgba(0, 0, 0, 0.05);
  --input: rgba(255, 255, 255, 0.8);
  --input2: rgba(255, 255, 255, 0.5);
  --card-bg: #dbeafe;
  --alt-row: rgba(0, 0, 0, 0.03);
  --shadow: rgba(0, 0, 0, 0.08);
  --success: #059669;
}

/* Theme 7: Light Green */
[data-theme="7"] {
  --bg: #f0fdf4;
  --sidebar: #dcfce7;
  --header: #bbf7d0;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-glow: rgba(22, 163, 74, 0.1);
  --text: #14532d;
  --text-dim: #4ade80;
  --border: rgba(0, 0, 0, 0.08);
  --selected-bg: rgba(22, 163, 74, 0.15);
  --selected-fg: #15803d;
  --hover: rgba(0, 0, 0, 0.05);
  --input: rgba(255, 255, 255, 0.8);
  --input2: rgba(255, 255, 255, 0.5);
  --card-bg: #dcfce7;
  --alt-row: rgba(0, 0, 0, 0.03);
  --shadow: rgba(0, 0, 0, 0.08);
  --success: #0284c7;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ---------- Base ---------- */
html,
body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

/* LTR Override */
[dir="ltr"] {
  font-family: var(--font-en);
}

/* ---------- App Layout ---------- */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  transition: var(--transition);
  z-index: 100;
  position: relative;
}

[dir="ltr"] #sidebar {
  border-left: none;
  border-right: 1px solid var(--border);
}

.sidebar-header {
  padding: 24px 20px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-img {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  margin-bottom: 8px;
  box-shadow: 0 4px 15px var(--accent-glow);
  object-fit: cover;
}

.sidebar-title {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--selected-fg));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Nav */
#navList {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin: 2px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  transition: var(--transition);
  -webkit-user-select: none;
  user-select: none;
}

.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--selected-bg);
  color: var(--selected-fg);
  font-weight: 600;
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.user-role {
  font-size: 11px;
  color: var(--text-dim);
}

.logout-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ---------- Main ---------- */
#mainContent {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Header ---------- */
#topHeader {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  width: 300px;
  height: 38px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-box:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

.lang-toggle-btn {
  height: 38px;
  min-width: 38px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.lang-toggle-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: scale(1.05);
}

.lang-toggle-btn:active {
  transform: scale(0.95);
}

.theme-select {
  height: 38px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 12px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.theme-select:focus {
  border-color: var(--accent);
}

/* ---------- Page Content ---------- */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Cards ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--accent-glow);
  box-shadow: 0 4px 20px var(--shadow);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--selected-fg);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Stats Cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  /* RTL: right */
  width: 4px;
  height: 100%;
  background: var(--stat-color, var(--accent));
  border-radius: 0 4px 4px 0;
}

[dir="rtl"] .stat-card::after {
  left: auto;
  right: 0;
  border-radius: 4px 0 0 4px;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px var(--shadow);
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--stat-color, var(--accent));
}

.stat-icon {
  position: absolute;
  top: 16px;
  left: 20px;
  font-size: 32px;
  opacity: 0.15;
}

[dir="rtl"] .stat-icon {
  left: auto;
  right: 20px;
}

/* ---------- Tables ---------- */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  min-width: 600px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table thead th {
  background: var(--header);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 8px 12px;
  text-align: start;
  border-bottom: 2px solid var(--accent);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  transition: var(--transition);
}

.data-table tbody tr:hover td {
  background: var(--hover);
}

.data-table tbody tr:nth-child(even) td {
  background: var(--alt-row);
}

.data-table tbody tr:nth-child(even):hover td {
  background: var(--hover);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: var(--hover);
  border-color: var(--text-dim);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: none;
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.btn-danger:hover {
  background: #ef4444;
  color: white;
}

.btn-success {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.3);
  color: #4ade80;
}

.btn-success:hover {
  background: #22c55e;
  color: white;
}

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.form-input,
.form-select,
.form-textarea {
  height: 40px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0 12px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
  color: var(--text-dim);
  opacity: 0.5;
}

.form-textarea {
  height: 80px;
  padding: 10px 12px;
  resize: vertical;
}

.form-select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.form-input-readonly {
  background: var(--input2);
  color: var(--selected-fg);
  font-weight: 600;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #92400e;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.badge-info {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

.badge-purple {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

/* ---------- Barcode ---------- */
.barcode-svg {
  max-width: 120px;
  height: auto;
  display: block;
}

.search-filter {
  width: 100%;
  padding: 8px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--hover);
  color: var(--text);
  font-size: 13px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.w-full {
  width: 100%;
}

/* ---------- Page Title ---------- */
.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Layout Helpers ---------- */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.gap-24 {
  gap: 24px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.mt-16 {
  margin-top: 16px;
}

.w-full {
  width: 100%;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
}

.grid-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.split-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 20px;
}

[dir="rtl"] .split-layout {
  grid-template-columns: 1fr 350px;
}

[dir="rtl"] .split-layout> :first-child {
  order: 2;
}

[dir="rtl"] .split-layout> :last-child {
  order: 1;
}

/* ---------- Search Filter ---------- */
.search-filter {
  width: 100%;
  height: 38px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  margin-bottom: 12px;
}

.search-filter:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-filter::placeholder {
  color: var(--text-dim);
  opacity: 0.5;
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 14px;
}

/* ---------- Toast / Notification ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 24px;
  font-size: 14px;
  color: var(--text);
  box-shadow: 0 10px 30px var(--shadow);
  z-index: 10000;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast-success {
  border-color: rgba(74, 222, 128, 0.3);
}

.toast-error {
  border-color: rgba(239, 68, 68, 0.3);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  min-width: 400px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px var(--shadow);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 3px;
  opacity: 0.5;
}

::-webkit-scrollbar-thumb:hover {
  opacity: 1;
}

/* ---------- Sidebar Overlay (Mobile) ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 999;
  animation: fadeIn 0.2s ease;
}

.sidebar-overlay.show {
  display: block;
}

/* ---------- Responsive: Tablet (max-width: 1024px) ---------- */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }

  .search-box {
    width: 200px;
  }

  .split-layout {
    grid-template-columns: 300px 1fr !important;
  }

  [dir="rtl"] .split-layout {
    grid-template-columns: 1fr 300px !important;
  }
}

/* ---------- Responsive: Mobile (max-width: 768px) ---------- */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  /* Off-canvas sidebar */
  #sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: 280px;
    min-width: 280px;
    transform: translateX(100%);
    z-index: 1000;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.3);
  }

  [dir="ltr"] #sidebar {
    right: auto;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.3);
  }

  #sidebar.open {
    transform: translateX(0) !important;
  }

  /* Show menu toggle */
  .menu-toggle {
    display: block;
  }

  /* Header compact */
  #topHeader {
    padding: 0 12px;
    gap: 8px;
  }

  .header-title {
    font-size: 15px;
  }

  .header-right {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .search-box {
    width: 100%;
    order: 3;
    display: none;
  }

  .lang-select,
  .theme-select {
    height: 34px;
    font-size: 11px;
    padding: 0 8px;
  }

  /* Content */
  .page-content {
    padding: 16px 12px;
  }

  .page-title {
    font-size: 18px;
    margin-bottom: 14px;
  }

  /* Stack all grid layouts */
  .split-layout,
  [dir="rtl"] .split-layout,
  .grid-2,
  .grid-equal {
    grid-template-columns: 1fr !important;
  }

  [dir="rtl"] .split-layout> :first-child,
  [dir="rtl"] .split-layout> :last-child {
    order: unset;
  }

  /* Cards compact */
  .card {
    padding: 14px;
    margin-bottom: 12px;
  }

  .card-title {
    font-size: 14px;
    margin-bottom: 12px;
  }

  /* Stats grid 2 cols */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-value {
    font-size: 22px;
  }

  .stat-label {
    font-size: 11px;
  }

  .stat-icon {
    font-size: 26px;
    top: 10px;
  }

  /* Table scrollable */
  .data-table {
    min-width: 500px;
  }

  .data-table thead th {
    padding: 8px 10px;
    font-size: 11px;
  }

  .data-table tbody td {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* Forms touch-friendly */
  .form-input,
  .form-select,
  .form-textarea {
    height: 44px;
    font-size: 14px;
  }

  /* Inline add rows stack */
  .flex.gap-8 {
    flex-wrap: wrap;
  }

  .flex.gap-8>* {
    min-width: 120px;
  }

  /* Buttons touch-friendly */
  .btn {
    height: 40px;
    font-size: 13px;
  }

  .btn-sm {
    height: 34px;
    padding: 0 14px;
  }

  /* Modal full width */
  .modal {
    min-width: unset;
    width: calc(100vw - 32px);
    padding: 20px;
  }

  /* Toast bottom safe */
  .toast {
    bottom: 16px;
    width: calc(100vw - 32px);
    font-size: 13px;
    padding: 12px 16px;
  }
}

/* ---------- Responsive: Small Phone (max-width: 480px) ---------- */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-icon {
    display: none;
  }

  .page-content {
    padding: 12px 8px;
  }

  .page-title {
    font-size: 16px;
    gap: 6px;
  }

  .header-title {
    font-size: 13px;
  }

  .lang-select {
    display: none;
  }

  /* Stack inline forms fully */
  .flex.gap-8 {
    flex-direction: column;
  }

  .flex.gap-8>* {
    flex: 1 1 100% !important;
    min-width: 100%;
  }

  .data-table {
    min-width: 450px;
  }

  .card {
    padding: 12px;
    border-radius: var(--radius-sm);
  }

  .form-group.mb-12 {
    margin-bottom: 8px;
  }
}

/* ---------- Tab System ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ---------- RESPONSIVE DESIGN ---------- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stat-value { font-size: 22px; }
  .page-content { padding: 16px; }
  .split-layout { grid-template-columns: 1fr !important; }
  .grid-equal { grid-template-columns: 1fr !important; }
  .search-box { width: 180px; }
}

@media (max-width: 768px) {
  #sidebar {
    position: fixed; top: 0; right: -280px;
    width: 280px; min-width: 280px; height: 100vh;
    z-index: 1000; transition: right 0.3s ease;
    box-shadow: -5px 0 20px rgba(0,0,0,0.3);
  }
  [dir="ltr"] #sidebar { right: auto; left: -280px; transition: left 0.3s ease; }
  #sidebar.open { right: 0; }
  [dir="ltr"] #sidebar.open { left: 0; }
  .sidebar-overlay.active {
    display: block; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 999;
  }
  .menu-toggle { display: flex !important; }
  #topHeader { padding: 0 12px; gap: 8px; }
  .header-title { font-size: 14px; }
  .search-box { width: 120px; height: 34px; font-size: 12px; }
  .lang-select, .theme-select { height: 34px; font-size: 11px; }
  .page-content { padding: 12px; }
  .card { padding: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 20px; }
  .data-table { min-width: 500px; }
  .data-table thead th { padding: 6px 8px; font-size: 10px; }
  .data-table tbody td { padding: 5px 8px; font-size: 11px; }
  .btn { height: 34px; padding: 0 12px; font-size: 12px; }
  .btn-sm { height: 28px; padding: 0 8px; font-size: 11px; }
  .form-input, .form-select, .form-textarea { height: 36px; font-size: 12px; }
  .flex { flex-wrap: wrap !important; }
  .split-layout, .grid-equal { grid-template-columns: 1fr !important; }
  .badge { font-size: 10px; padding: 2px 8px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 18px; }
  .search-box { width: 90px; }
  .header-title { font-size: 13px; }
  .page-content { padding: 8px; }
  .card { padding: 10px; margin-bottom: 10px; }
}

@media print {
  #sidebar, #topHeader, .btn, .menu-toggle, .sidebar-overlay { display: none !important; }
  #mainContent { margin: 0; }
  .page-content { padding: 0; overflow: visible; }
  .card { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; overflow: visible; }
}

/* ===== STITCH PREMIUM SIDEBAR OVERRIDES ===== */
#sidebar {
  background: #001629 !important;
  color: #e2e8f0 !important;
  border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
}
[dir="ltr"] #sidebar {
  border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-left: none !important;
}
#sidebar .sidebar-title {
  background: linear-gradient(135deg, #7af1fc, #7df4ff) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  font-family: 'IBM Plex Sans Arabic', sans-serif !important;
  font-weight: 800 !important;
}
#sidebar .sidebar-subtitle {
  color: rgba(255, 255, 255, 0.6) !important;
}
#sidebar .nav-item {
  color: rgba(255, 255, 255, 0.7) !important;
  transition: all 0.2s ease !important;
}
#sidebar .nav-item:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
}
#sidebar .nav-item.active {
  background: rgba(122, 241, 252, 0.15) !important;
  color: #7af1fc !important;
  font-weight: 600 !important;
}
#sidebar .sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}
#sidebar .user-name {
  color: #ffffff !important;
  font-weight: 600 !important;
}
#sidebar .user-role {
  color: rgba(255, 255, 255, 0.6) !important;
}
#sidebar .logout-btn {
  color: rgba(255, 255, 255, 0.6) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}
#sidebar .logout-btn:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #ff8888 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

/* ===== BATCH C: SUPPLY CHAIN & LOGISTICS PREMIUM GLASS CARD & SCROLLBAR ===== */
.glass-card {
  background: rgba(255, 255, 255, 0.8) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(227, 209, 180, 0.3) !important;
  box-shadow: 0px 10px 30px rgba(0, 43, 73, 0.05) !important;
}
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #c3c7ce;
  border-radius: 10px;
}

/* ===== MEDICAL SYSTEM BATCH 1 ENHANCEMENTS ===== */
.medical-gradient {
  background: linear-gradient(135deg, #001629 0%, #004f54 50%, #006970 100%) !important;
}

.glass-card-premium {
  background: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(16px) saturate(120%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(120%) !important;
  border: 1px solid rgba(0, 105, 112, 0.12) !important;
  box-shadow: 0 8px 32px 0 rgba(0, 22, 41, 0.04) !important;
  border-radius: 20px !important;
  transition: all 0.3s ease !important;
}

.glass-card-premium:hover {
  box-shadow: 0 12px 40px 0 rgba(0, 22, 41, 0.08) !important;
  border-color: rgba(0, 105, 112, 0.2) !important;
  transform: translateY(-2px);
}

.shadow-medical {
  box-shadow: 0 4px 20px rgba(0, 22, 41, 0.05) !important;
}

/* Staging Warning Banners */
.staging-banner {
  background: repeating-linear-gradient(
    45deg,
    #f59e0b,
    #f59e0b 10px,
    #d97706 10px,
    #d97706 20px
  ) !important;
  color: #000000 !important;
  font-weight: 700 !important;
  text-align: center !important;
  padding: 6px 12px !important;
  font-size: 13px !important;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3) !important;
  z-index: 1000 !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  direction: rtl;
}

.staging-badge {
  background-color: #f59e0b !important;
  color: #000000 !important;
  font-weight: 700 !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  border: 1px solid #d97706 !important;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Badges */
.badge-medical {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}
.badge-medical-success {
  background-color: rgba(34, 197, 94, 0.1) !important;
  color: #22c55e !important;
  border: 1px solid rgba(34, 197, 94, 0.2) !important;
}
.badge-medical-warning {
  background-color: rgba(245, 158, 11, 0.1) !important;
  color: #f59e0b !important;
  border: 1px solid rgba(245, 158, 11, 0.2) !important;
}
.badge-medical-danger {
  background-color: rgba(186, 26, 26, 0.1) !important;
  color: #ba1a1a !important;
  border: 1px solid rgba(186, 26, 26, 0.2) !important;
}
.badge-medical-info {
  background-color: rgba(0, 105, 112, 0.1) !important;
  color: #006970 !important;
  border: 1px solid rgba(0, 105, 112, 0.2) !important;
}

/* Skeleton Loading */
.skeleton-loader {
  background: linear-gradient(90deg, #edeeef 25%, #f5f6f7 50%, #edeeef 75%);
  background-size: 200% 100%;
  animation: loading-skeleton 1.5s infinite;
  border-radius: var(--radius-sm);
  display: inline-block;
  width: 100%;
}
.skeleton-bar {
  height: 16px;
  margin-bottom: 8px;
}
.skeleton-bar.title {
  height: 24px;
  width: 60%;
}
.skeleton-circle {
  width: 48px;
  height: 48px;
  border-radius: 50% !important;
}

@keyframes loading-skeleton {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Empty State Card */
.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.5) !important;
  border: 1px dashed rgba(0, 105, 112, 0.2) !important;
  border-radius: var(--radius) !important;
  color: var(--text-dim) !important;
  gap: 12px;
}
.empty-state-icon {
  font-size: 48px !important;
  color: rgba(0, 105, 112, 0.3) !important;
}

/* Error State Card */
.error-card-premium {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  background: rgba(186, 26, 26, 0.03) !important;
  border: 1px solid rgba(186, 26, 26, 0.15) !important;
  border-radius: var(--radius) !important;
  color: #ba1a1a !important;
  gap: 12px;
  box-shadow: 0 4px 15px rgba(186, 26, 26, 0.05) !important;
}
.error-card-icon {
  font-size: 48px !important;
  color: #ba1a1a !important;
}



