/* ================================================================
   SPI BatchFlow — Professional Bilingual Stylesheet
   Supports: Arabic (RTL) & English (LTR)
   ================================================================ */

/* ---- Custom Properties ---- */
:root {
  --primary:       #6C63FF;
  --primary-dark:  #5a52d5;
  --primary-light: #ede9ff;
  --success:       #27AE60;
  --success-light: #e8f8f0;
  --danger:        #E74C3C;
  --danger-light:  #fdecea;
  --warning:       #F5A623;
  --warning-light: #fff8ee;
  --info:          #4A90E2;
  --info-light:    #eaf2fd;
  --gray-50:       #F8F9FC;
  --gray-100:      #F0F2F8;
  --gray-200:      #E2E6EF;
  --gray-300:      #CBD2E0;
  --gray-400:      #9BA7C0;
  --gray-500:      #6B7A99;
  --gray-600:      #4B5773;
  --gray-700:      #2E3A59;
  --gray-800:      #1A2340;
  --gray-900:      #0D1526;
  --sidebar-w:     260px;
  --topbar-h:      64px;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --shadow:        0 2px 12px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 24px rgba(0,0,0,0.12);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.16);
  --transition:    0.2s ease;
  --font-ar:       'Tajawal', sans-serif;
  --font-en:       'Inter', sans-serif;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-ar);
  background: var(--gray-50);
  color: var(--gray-700);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
body.ltr { font-family: var(--font-en); }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  position: fixed;
  top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--gray-800);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}
.rtl .sidebar { right: 0; left: auto; }
.ltr .sidebar { left: 0; right: auto; }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.brand-logo svg { width: 40px; height: 40px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -0.3px; }
.brand-sub  { font-size: 11px; color: var(--gray-400); margin-top: 1px; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 16px 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--gray-400);
  font-weight: 500;
  font-size: 14px;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(108,99,255,0.35); }
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* Sidebar Footer */
.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-card { display: flex; align-items: center; gap: 12px; }
.user-avatar {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--gray-400); }

/* ================================================================
   MAIN WRAPPER
   ================================================================ */
.main-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.rtl .main-wrapper { margin-right: var(--sidebar-w); }
.ltr .main-wrapper { margin-left:  var(--sidebar-w); }

/* ================================================================
   TOPBAR
   ================================================================ */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--gray-500); padding: 8px;
  border-radius: var(--radius-sm);
  display: none;
}
.sidebar-toggle svg { width: 22px; height: 22px; }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--gray-800); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.lang-switch { display: flex; align-items: center; gap: 2px; }
.lang-btn {
  padding: 5px 10px; font-size: 12px; font-weight: 600;
  border-radius: 6px; color: var(--gray-500);
  transition: all var(--transition);
}
.lang-btn:hover, .lang-btn.active { background: var(--primary); color: #fff; }

.icon-btn {
  background: none; border: none; cursor: pointer;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500);
  position: relative;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.icon-btn svg { width: 20px; height: 20px; }
.logout-btn:hover { background: var(--danger-light); color: var(--danger); }

.notif-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
.rtl .notif-badge { right: auto; left: 4px; }

/* ================================================================
   FLASH MESSAGES
   ================================================================ */
.flash-container { padding: 12px 24px 0; }
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideDown 0.3s ease;
}
.alert-success { background: var(--success-light); color: #1a6940; border: 1px solid #b7e4c7; }
.alert-danger  { background: var(--danger-light);  color: #a11; border: 1px solid #f5c6c6; }
@keyframes slideDown { from { opacity:0; transform:translateY(-10px); } to { opacity:1; transform:translateY(0); } }

/* ================================================================
   PAGE CONTENT
   ================================================================ */
.page-content { flex: 1; padding: 24px; }

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 16px; font-weight: 700; color: var(--gray-800); margin: 0; }
.card-action { font-size: 13px; color: var(--primary); font-weight: 600; }
.card-action:hover { text-decoration: underline; }
.card-body { padding: 20px; }
.card-body.p0 { padding: 0; }
.mt-4 { margin-top: 20px; }

/* ================================================================
   STATS GRID
   ================================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.stat-blue .stat-icon   { background: var(--info-light);    color: var(--info); }
.stat-green .stat-icon  { background: var(--success-light); color: var(--success); }
.stat-purple .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-red .stat-icon    { background: var(--danger-light);  color: var(--danger); }
.stat-blue .stat-value  { color: var(--info); }
.stat-green .stat-value { color: var(--success); }
.stat-purple .stat-value{ color: var(--primary); }
.stat-red .stat-value   { color: var(--danger); }

/* ================================================================
   DASHBOARD GRID
   ================================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

/* Pipeline */
.pipeline {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 0;
}
.pipeline-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 72px;
  text-align: center;
}
.pipeline-count {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--stage-color, #ccc);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  color: var(--stage-color, #aaa);
  background: color-mix(in srgb, var(--stage-color, #ccc) 10%, transparent);
  transition: all var(--transition);
}
.pipeline-count.has-batches {
  background: var(--stage-color, #ccc);
  color: #fff;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--stage-color, #ccc) 40%, transparent);
}
.pipeline-name {
  font-size: 10px;
  color: var(--gray-500);
  line-height: 1.3;
  max-width: 70px;
}
.pipeline-num { font-size: 10px; color: var(--gray-400); }
.pipeline-arrow { font-size: 18px; color: var(--gray-300); align-self: center; padding: 0 2px; }

/* Delay List */
.delay-list { list-style: none; }
.delay-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
}
.delay-item:last-child { border-bottom: none; }
.delay-badge {
  font-size: 11px; font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.delay-badge.red { background: var(--danger-light); color: var(--danger); }
.delay-info { flex: 1; min-width: 0; }
.delay-batch { font-weight: 600; color: var(--primary); display: block; }
.delay-stage { font-size: 12px; color: var(--gray-500); }

/* ================================================================
   BADGES
   ================================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.badge-lg { padding: 5px 14px; font-size: 13px; }
.badge-sm { padding: 2px 7px; font-size: 11px; }
.badge-active   { background: var(--success-light); color: var(--success); }
.badge-released { background: var(--primary-light); color: var(--primary); }
.badge-on_hold  { background: var(--warning-light); color: var(--warning); }
.badge-rejected { background: var(--danger-light);  color: var(--danger); }
.badge-green    { background: var(--success-light); color: var(--success); }
.badge-red      { background: var(--danger-light);  color: var(--danger); }
.badge-yellow   { background: var(--warning-light); color: var(--warning); }
.badge-gray     { background: var(--gray-100); color: var(--gray-500); }
.badge-scan-manual  { background: var(--gray-100);  color: var(--gray-600); }
.badge-scan-barcode { background: #e8f0fd; color: #3b67c7; }
.badge-scan-qr      { background: #f0f8e8; color: #3d8a1a; }

/* Role badges */
.badge-role-admin      { background: #ede9ff; color: #6C63FF; }
.badge-role-management { background: #e8f0fd; color: #4A90E2; }
.badge-role-planning   { background: #e8f8f0; color: #27AE60; }
.badge-role-production { background: #fff8ee; color: #F5A623; }
.badge-role-warehouse  { background: #fdecea; color: #E74C3C; }
.badge-role-qc         { background: #f0f8e8; color: #2E8B57; }
.badge-role-qa         { background: #fce4ec; color: #c2185b; }
.badge-role-viewer     { background: var(--gray-100); color: var(--gray-500); }

/* ================================================================
   STAGE CHIP
   ================================================================ */
.stage-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

/* ================================================================
   DELAY INDICATOR
   ================================================================ */
.delay-indicator {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.delay-indicator.green  { background: var(--success); box-shadow: 0 0 0 3px var(--success-light); }
.delay-indicator.yellow { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-light); }
.delay-indicator.red    { background: var(--danger);  box-shadow: 0 0 0 3px var(--danger-light); }

/* ================================================================
   DATA TABLE
   ================================================================ */
.table-responsive { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 14px;
}
.data-table thead tr { background: var(--gray-50); }
.data-table th {
  padding: 12px 16px;
  text-align: start;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.row-inactive { opacity: 0.55; }
.link-strong { color: var(--primary); font-weight: 600; }
.link-strong:hover { text-decoration: underline; }
.product-cell { display: flex; flex-direction: column; }
.product-code { font-size: 11px; color: var(--gray-400); }
.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.table-footer {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--gray-500);
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* Action buttons */
.action-btns { display: flex; align-items: center; gap: 6px; }
.btn-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gray-100);
  color: var(--gray-600);
  border: none; cursor: pointer;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--primary); color: #fff; }
.btn-icon svg { width: 15px; height: 15px; }
.btn-icon-danger:hover { background: var(--danger-light); color: var(--danger); }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn-primary   { background: var(--primary);  color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success   { background: var(--success);  color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(0.9); }
.btn-danger    { background: var(--danger);   color: #fff; border-color: var(--danger); }
.btn-outline   { background: transparent; color: var(--gray-700); border-color: var(--gray-300); }
.btn-outline:hover { background: var(--gray-100); }
.ms-auto { margin-inline-start: auto; }

/* ================================================================
   FORMS
   ================================================================ */
.form-card { max-width: 860px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.has-error .form-control { border-color: var(--danger); }
.form-label {
  font-size: 13px; font-weight: 600;
  color: var(--gray-600);
}
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  color: var(--gray-800);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}
.form-control-sm { padding: 7px 12px; font-size: 13px; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.field-error { font-size: 12px; color: var(--danger); }
.form-actions { display: flex; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--gray-100); }
.form-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.form-row .form-control { flex: 1; min-width: 120px; }
.filter-bar { margin-bottom: 20px; }
.filter-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-form .form-control { width: auto; flex: 1; min-width: 140px; }

/* Input icon */
.input-icon-wrap { position: relative; }
.input-icon {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--gray-400);
  pointer-events: none;
}
.rtl .input-icon { right: 14px; }
.ltr .input-icon { left: 14px; }
.rtl .input-icon-wrap .form-control { padding-right: 42px; }
.ltr .input-icon-wrap .form-control { padding-left:  42px; }
.toggle-password {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); padding: 4px;
}
.rtl .toggle-password { left: 10px; }
.ltr .toggle-password { right: 10px; }
.toggle-password svg { width: 16px; height: 16px; }

/* ================================================================
   BATCH DETAIL
   ================================================================ */
.batch-header {
  margin-bottom: 20px;
}
.batch-header .card-body { display: flex; flex-direction: column; gap: 16px; }
.batch-header-main {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.batch-number { font-size: 26px; font-weight: 800; color: var(--gray-800); }
.batch-product { font-size: 15px; color: var(--gray-500); margin-top: 2px; }
.batch-header-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.batch-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.delay-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.delay-badge.badge-green  { background: var(--success-light); color: var(--success); }
.delay-badge.badge-yellow { background: var(--warning-light); color: var(--warning); }
.delay-badge.badge-red    { background: var(--danger-light);  color: var(--danger); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Info list */
.info-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.info-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.info-item:nth-last-child(-n+2) { border-bottom: none; }
.info-item dt { font-size: 12px; color: var(--gray-400); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.info-item dd { font-size: 14px; color: var(--gray-800); font-weight: 500; }

/* Stage Progress (vertical stepper) */
.stage-progress {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.stage-step {
  display: flex; align-items: center; gap: 14px;
}
.step-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: #fff;
  color: var(--gray-400);
  font-size: 12px; font-weight: 700;
  position: relative; z-index: 1;
}
.stage-step.done .step-dot  { background: var(--success); border-color: var(--success); color: #fff; }
.stage-step.done .step-dot svg { stroke: #fff; }
.stage-step.current .step-dot { border-color: currentColor; color: #fff; }
.stage-step.current .step-label { font-weight: 700; color: var(--gray-800); }
.step-pulse {
  width: 10px; height: 10px;
  border-radius: 50%; background: #fff;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.7; }
}
.step-label { font-size: 13px; color: var(--gray-500); }
.step-connector {
  width: 2px; height: 20px;
  background: var(--gray-200);
  margin-inline-start: 15px;
}
.step-connector.done { background: var(--success); }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; padding: 4px 0; }
.timeline-item {
  display: flex; gap: 16px;
  padding-bottom: 20px;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  top: 32px;
  width: 2px; bottom: 0;
  background: var(--gray-200);
}
.rtl .timeline-item::before { right: 15px; }
.ltr .timeline-item::before { left:  15px; }
.timeline-item:last-child::before { display: none; }
.timeline-item.delayed .timeline-content { background: var(--danger-light); border-color: #f5c6c6; }
.timeline-dot {
  width: 32px; height: 32px;
  border-radius: 50%; flex-shrink: 0;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--gray-200);
  z-index: 1;
}
.timeline-content {
  flex: 1;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.timeline-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.timeline-header strong { font-size: 14px; color: var(--gray-800); }
.timeline-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--gray-500); }

/* Notes */
.note-form .form-row { flex-wrap: wrap; }
.notes-list { display: flex; flex-direction: column; gap: 10px; }
.note-item {
  border-radius: var(--radius-sm);
  padding: 12px;
  border-inline-start: 4px solid;
  background: var(--gray-50);
}
.note-delay      { border-color: var(--danger); }
.note-operational{ border-color: var(--info); }
.note-quality    { border-color: var(--success); }
.note-corrective { border-color: var(--warning); }
.note-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.note-type-badge {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
  background: var(--gray-200); color: var(--gray-600);
}
.note-meta span { font-size: 12px; color: var(--gray-500); }
.note-content { font-size: 14px; color: var(--gray-700); }

/* Attachments */
.file-drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
}
.file-drop-zone:hover, .file-drop-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }
.file-drop-zone svg { color: var(--gray-400); display: block; margin: 0 auto 10px; }
.file-label { color: var(--primary); cursor: pointer; text-decoration: underline; }
.file-hidden { display: none; }
.attach-list { display: flex; flex-direction: column; gap: 8px; }
.attach-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
}
.attach-item svg { color: var(--gray-400); flex-shrink: 0; }
.attach-info { flex: 1; }
.attach-name { font-size: 14px; color: var(--primary); font-weight: 500; }
.attach-meta { font-size: 12px; color: var(--gray-400); display: block; }

/* ================================================================
   MODAL
   ================================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 480px; max-width: 95%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity:0; } to { transform:translateY(0); opacity:1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 18px;
  cursor: pointer; color: var(--gray-400);
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--gray-100); }
.modal-body { padding: 24px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Scan tabs */
.scan-tabs { display: flex; gap: 4px; background: var(--gray-100); border-radius: 8px; padding: 4px; margin-bottom: 16px; }
.scan-tab {
  flex: 1; padding: 7px; border: none; border-radius: 6px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  background: none; color: var(--gray-500);
  transition: all var(--transition);
}
.scan-tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* Scan area */
.scan-area {
  position: relative; background: #000;
  border-radius: var(--radius-sm); overflow: hidden;
  aspect-ratio: 4/3;
}
#scanVideo { width: 100%; height: 100%; object-fit: cover; }
.scan-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.scan-frame {
  width: 200px; height: 200px;
  border: 3px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
  animation: scanPulse 2s infinite;
}
@keyframes scanPulse {
  0%, 100% { box-shadow: 0 0 0 9999px rgba(0,0,0,0.4), 0 0 20px rgba(108,99,255,0.5); }
  50% { box-shadow: 0 0 0 9999px rgba(0,0,0,0.4), 0 0 40px rgba(108,99,255,0.9); }
}
.next-stage-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin-top: 12px;
  border: 2px solid; border-radius: var(--radius-sm);
  font-size: 14px;
}

/* ================================================================
   REPORTS
   ================================================================ */
.reports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; }
.report-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  cursor: pointer;
}
.report-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.report-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.report-icon svg { width: 26px; height: 26px; }
.report-info { flex: 1; }
.report-info h4 { font-size: 15px; font-weight: 700; color: var(--gray-800); margin-bottom: 4px; }
.report-info p  { font-size: 13px; color: var(--gray-500); }
.report-arrow { width: 20px; height: 20px; color: var(--gray-400); }

/* Report tabs */
.report-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab-btn {
  padding: 9px 18px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: #fff; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--gray-600);
  transition: all var(--transition);
}
.tab-btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ================================================================
   NOTIFICATIONS
   ================================================================ */
.notif-full-list { list-style: none; }
.notif-full-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}
.notif-full-item:hover { background: var(--gray-50); }
.notif-full-item.unread { background: var(--primary-light); }
.notif-type-dot {
  width: 10px; height: 10px; border-radius: 50%;
  margin-top: 5px; flex-shrink: 0;
}
.notif-info { background: var(--info); }
.notif-batch\.created, .notif-batch\.stage { background: var(--primary); }
.notif-body { flex: 1; }
.notif-title { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.notif-msg   { font-size: 13px; color: var(--gray-500); margin-top: 2px; }
.notif-time  { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--gray-400);
  gap: 12px;
}
.empty-state svg { width: 56px; height: 56px; }
.empty-state p   { font-size: 15px; }
.empty-state.small { padding: 30px; }
.empty-state.small svg { width: 36px; }

/* ================================================================
   ERRORS
   ================================================================ */
.error-page {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 70vh; text-align: center; gap: 16px;
}
.error-code { font-size: 100px; font-weight: 900; color: var(--gray-200); line-height: 1; }
.error-page h2 { font-size: 28px; font-weight: 700; color: var(--gray-700); }
.error-page p  { color: var(--gray-500); max-width: 400px; }

/* ================================================================
   AUTH PAGE
   ================================================================ */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0D1526 0%, #1A2340 50%, #2E3A59 100%);
  display: flex; align-items: center; justify-content: center;
}
.auth-bg {
  position: fixed; inset: 0; overflow: hidden; pointer-events: none;
}
.auth-particles {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(108,99,255,0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(39,174,96,0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(74,144,226,0.08) 0%, transparent 60%);
}
.auth-container { position: relative; z-index: 1; width: 100%; max-width: 440px; padding: 20px; }
.auth-card {
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-brand { font-size: 26px; font-weight: 800; color: var(--gray-800); margin-top: 14px; }
.auth-tagline { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-lang { text-align: center; margin-top: 20px; font-size: 13px; color: var(--gray-400); display: flex; gap: 8px; justify-content: center; align-items: center; }
.auth-lang a { color: var(--gray-500); }
.auth-lang a.active, .auth-lang a:hover { color: var(--primary); font-weight: 600; }
.auth-hint { margin-top: 16px; padding: 12px; background: var(--gray-50); border-radius: var(--radius-sm); font-size: 13px; color: var(--gray-600); text-align: center; }

/* ================================================================
   SETTINGS / CATALOG TABS  (Products · Units · Lines page)
   ================================================================ */
.settings-tabs {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
  width: fit-content;
}
.settings-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  background: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.settings-tab:hover { color: var(--gray-700); background: rgba(255,255,255,0.6); }
.settings-tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
}
.settings-tab.active .tab-count { background: var(--primary); color: #fff; }

/* Import steps */
.import-steps { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.import-step  { display: flex; align-items: flex-start; gap: 14px; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}
.import-step strong { display: block; font-size: 14px; color: var(--gray-800); margin-bottom: 2px; }
.import-step p { font-size: 13px; color: var(--gray-500); margin: 0 0 6px; }

/* Import errors list */
.import-errors {
  background: var(--warning-light);
  border: 1px solid #f5c842;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.import-errors summary {
  cursor: pointer; font-weight: 600;
  color: #8a6000; font-size: 14px;
  list-style: none;
}
.import-errors summary::-webkit-details-marker { display: none; }
.import-errors summary::before { content: '▶ '; font-size: 11px; }
details[open] .import-errors summary::before { content: '▼ '; }
.import-error-list {
  margin: 10px 0 0; padding: 0;
  list-style: none;
  display: flex; flex-direction: column; gap: 4px;
  max-height: 200px; overflow-y: auto;
}
.import-error-list li {
  font-size: 13px; color: #6b4800;
  padding: 4px 8px;
  background: rgba(255,255,255,0.5);
  border-radius: 4px;
}

/* Product code badge (monospace pill) */
.product-code-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  background: var(--primary-light);
  color: var(--primary);
  letter-spacing: 0.5px;
}

/* ================================================================
   UTILITIES
   ================================================================ */
.text-muted  { color: var(--gray-400); }
.text-center { text-align: center; }
.text-start  { text-align: start; }
.text-warning{ color: var(--warning); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-grid, .detail-bottom-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .rtl .sidebar { transform: translateX(100%); }
  .ltr .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .rtl .main-wrapper, .ltr .main-wrapper { margin: 0; }
  .sidebar-toggle { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .info-list { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .batch-header-main { flex-direction: column; }
}
