/* ============================================================
   Delta Panel — Global Design System
   Developer: MAO for Software Solutions
   Dark Glassmorphism | RTL | Cairo Font
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --bg-base:        #080c18;
  --bg-surface:     #0e1220;
  --bg-card:        rgba(255,255,255,0.04);
  --bg-card-hover:  rgba(255,255,255,0.07);
  --bg-input:       rgba(255,255,255,0.06);
  --bg-input-focus: rgba(255,255,255,0.09);
  --primary:        #6366f1;
  --primary-dark:   #4f46e5;
  --primary-light:  rgba(99,102,241,0.15);
  --primary-glow:   rgba(99,102,241,0.4);
  --success:        #10b981;
  --success-light:  rgba(16,185,129,0.15);
  --warning:        #f59e0b;
  --warning-light:  rgba(245,158,11,0.15);
  --danger:         #ef4444;
  --danger-light:   rgba(239,68,68,0.15);
  --info:           #3b82f6;
  --info-light:     rgba(59,130,246,0.15);
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;
  --border:         rgba(255,255,255,0.08);
  --border-hover:   rgba(255,255,255,0.15);
  --glass-bg:       rgba(14,18,32,0.7);
  --glass-border:   rgba(255,255,255,0.1);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:      0 8px 48px rgba(0,0,0,0.5);
  --shadow-primary: 0 4px 24px var(--primary-glow);
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 9999px;
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --sidebar-w: 260px;
}

/* ── Light Mode ─────────────────────────────────────────────── */
[data-theme="light"],
html[data-theme="light"] {
  --bg-base:        #f0f4f8;
  --bg-surface:     #ffffff;
  --bg-card:        rgba(255,255,255,0.95);
  --bg-card-hover:  #ffffff;
  --bg-input:       #f1f5f9;
  --bg-input-focus: #ffffff;
  --text-primary:   #1e293b;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --border:         rgba(0,0,0,0.1);
  --border-hover:   rgba(0,0,0,0.2);
  --glass-bg:       rgba(255,255,255,0.9);
  --glass-border:   rgba(0,0,0,0.1);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 24px rgba(0,0,0,0.12);
  --shadow-lg:      0 8px 48px rgba(0,0,0,0.16);
  --primary-light:  rgba(99,102,241,0.1);
  --success-light:  rgba(16,185,129,0.1);
  --warning-light:  rgba(245,158,11,0.1);
  --danger-light:   rgba(239,68,68,0.1);
  --info-light:     rgba(59,130,246,0.1);
}

/* Explicit overrides for light mode elements */
html[data-theme="light"] body            { background: #f0f4f8 !important; color: #1e293b !important; }
html[data-theme="light"] .sidebar        { background: #ffffff !important; border-color: rgba(0,0,0,0.1) !important; }
html[data-theme="light"] .sidebar-nav a  { color: #475569 !important; }
html[data-theme="light"] .nav-item:hover { background: rgba(99,102,241,0.08) !important; color: #1e293b !important; }
html[data-theme="light"] .nav-item.active{ background: rgba(99,102,241,0.12) !important; color: var(--primary) !important; }
html[data-theme="light"] .topbar         { background: rgba(255,255,255,0.95) !important; border-color: rgba(0,0,0,0.08) !important; }
html[data-theme="light"] .card           { background: rgba(255,255,255,0.95) !important; border-color: rgba(0,0,0,0.08) !important; }
html[data-theme="light"] .form-control   { background: #f1f5f9 !important; color: #1e293b !important; border-color: rgba(0,0,0,0.12) !important; }
html[data-theme="light"] .form-control:focus { background: #ffffff !important; }
html[data-theme="light"] table           { background: transparent; }
html[data-theme="light"] thead th        { background: rgba(0,0,0,0.03) !important; color: #475569 !important; }
html[data-theme="light"] tbody tr:hover  { background: rgba(99,102,241,0.04) !important; }
html[data-theme="light"] .btn-ghost      { background: rgba(0,0,0,0.04) !important; color: #475569 !important; border-color: rgba(0,0,0,0.1) !important; }
html[data-theme="light"] .sidebar-footer { background: #f8fafc !important; border-color: rgba(0,0,0,0.08) !important; }
html[data-theme="light"] .sidebar-user-avatar { background: var(--primary) !important; }
html[data-theme="light"] ::-webkit-scrollbar-track { background: #e2e8f0 !important; }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15) !important; }
html[data-theme="light"] .theme-toggle   { background: #f1f5f9 !important; color: #475569 !important; border-color: rgba(0,0,0,0.12) !important; }
html[data-theme="light"] .page-content   { background: transparent !important; }
html[data-theme="light"] .inv-row        { background: #ffffff !important; }
html[data-theme="light"] .stat-card      { background: #ffffff !important; }
html[data-theme="light"] .nav-section-label { color: #94a3b8 !important; }


/* ── Theme Toggle Button ─────────────────────────────────────── */
.theme-toggle {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.theme-toggle:hover { background: var(--bg-card-hover); color: var(--primary); border-color: var(--primary); }

/* ── Item Type Badge ─────────────────────────────────────────── */
.badge-board   { background: rgba(16,185,129,.12); color: #059669; }
.badge-press   { background: rgba(99,102,241,.12);  color: var(--primary); }
.badge-other   { background: rgba(148,163,184,.12); color: var(--text-secondary); }

/* ── Customer Card ─────────────────────────────────────────── */
.customer-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  transition: all var(--transition-base); display: flex; gap: 14px;
  text-decoration: none; color: inherit;
}
.customer-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); color: inherit; }
.customer-avatar {
  width: 48px; height: 48px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #fff;
}

/* ── Audit Timeline ─────────────────────────────────────────── */
.audit-timeline { display: flex; flex-direction: column; gap: 0; }
.audit-entry { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.audit-entry:last-child { border-bottom: none; }
.audit-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.audit-dot.created  { background: var(--success); }
.audit-dot.updated  { background: var(--warning); }
.audit-dot.deleted  { background: var(--danger); }
.audit-dot.restored { background: var(--info); }

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Cairo', sans-serif;
  direction: rtl;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 15px;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: #818cf8; }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: var(--radius-full); }

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

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; right: 0;
  z-index: 100;
  transition: transform var(--transition-base);
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}

.sidebar-logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-primary);
  flex-shrink: 0;
}

.sidebar-logo-text h2 { font-size: 16px; font-weight: 700; line-height: 1.2; }
.sidebar-logo-text span { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 8px 10px 4px; margin-top: 8px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  transition: all var(--transition-fast); margin-bottom: 2px;
  position: relative; text-decoration: none;
}

.nav-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.nav-item.active {
  background: var(--primary-light); color: var(--primary); font-weight: 600;
}

.nav-item.active::before {
  content: ''; position: absolute; right: 0; top: 20%; bottom: 20%;
  width: 3px; background: var(--primary);
  border-radius: var(--radius-full) 0 0 var(--radius-full);
}

.nav-item .nav-icon { font-size: 18px; flex-shrink: 0; width: 20px; text-align: center; }

.nav-badge {
  margin-right: auto;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: var(--radius-full);
}

.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--border); }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-md); margin-bottom: 8px; }
.sidebar-user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info .name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-info .role { font-size: 11px; color: var(--text-muted); }

.main-content { flex: 1; margin-right: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  height: 64px; background: var(--glass-bg);
  backdrop-filter: blur(20px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 28px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.page-content { padding: 28px; flex: 1; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  backdrop-filter: blur(10px);
  transition: border-color var(--transition-fast);
}

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 16px; font-weight: 700; }
.card-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ── Stats ─────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  display: flex; align-items: flex-start; gap: 16px;
  transition: all var(--transition-base); position: relative; overflow: hidden;
}

.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: var(--stat-color, var(--primary));
  opacity: 0; transition: opacity var(--transition-base);
}

.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card:hover::before { opacity: 1; }

.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; margin: 4px 0 2px; }

.stat-primary { --stat-color: var(--primary); }
.stat-success { --stat-color: var(--success); }
.stat-warning { --stat-color: var(--warning); }
.stat-danger  { --stat-color: var(--danger); }

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

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 20px; border-radius: var(--radius-md);
  font-family: inherit; font-size: 14px; font-weight: 600;
  transition: all var(--transition-fast); cursor: pointer;
  border: 1px solid transparent; text-decoration: none; white-space: nowrap;
}

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 2px 12px var(--primary-glow); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--primary-glow); color: #fff; }

.btn-success { background: var(--success-light); color: var(--success); border-color: rgba(16,185,129,0.3); }
.btn-warning { background: var(--warning-light); color: var(--warning); border-color: rgba(245,158,11,0.3); }
.btn-danger  { background: var(--danger-light);  color: var(--danger);  border-color: rgba(239,68,68,0.3); }
.btn-ghost   { background: var(--bg-card); color: var(--text-secondary); border-color: var(--border); }

.btn-success:hover, .btn-warning:hover, .btn-danger:hover, .btn-ghost:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-right: 3px; }

.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-family: inherit; font-size: 14px;
  transition: all var(--transition-fast); outline: none; appearance: none;
}

.form-control::placeholder { color: var(--text-muted); }
.form-control:focus { background: var(--bg-input-focus); border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-hint  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
  padding: 13px 16px; text-align: right;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  background: rgba(255,255,255,0.02); border-bottom: 1px solid var(--border); white-space: nowrap;
}

tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: rgba(255,255,255,0.03); }
.table-actions { display: flex; gap: 6px; align-items: center; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-neutral { background: rgba(255,255,255,0.06); color: var(--text-secondary); }
.badge-info    { background: var(--info-light);    color: var(--info); }

/* ── Search ─────────────────────────────────────────────────── */
.search-wrapper { position: relative; }
.search-wrapper .search-icon { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-wrapper .form-control { padding-right: 38px; }

/* ── Dropdown ─────────────────────────────────────────────── */
.searchable-dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); right: 0; left: 0;
  background: var(--bg-surface); border: 1px solid var(--border-hover);
  border-radius: var(--radius-md); z-index: 200;
  max-height: 260px; overflow-y: auto; box-shadow: var(--shadow-lg); display: none;
}
.dropdown-menu.open { display: block; animation: fadeSlideDown 0.15s ease; }
.dropdown-item { padding: 10px 14px; cursor: pointer; transition: background var(--transition-fast); display: flex; align-items: center; gap: 10px; font-size: 14px; }
.dropdown-item:hover { background: var(--bg-card-hover); }
.dropdown-item-meta { font-size: 12px; color: var(--text-muted); }
.dropdown-empty { padding: 16px; color: var(--text-muted); text-align: center; font-size: 13px; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert { padding: 14px 18px; border-radius: var(--radius-md); font-size: 14px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--success-light); color: var(--success); border-color: rgba(16,185,129,.3); }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border-color: rgba(239,68,68,.3); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: rgba(245,158,11,.3); }
.alert-info    { background: var(--info-light);    color: var(--info);    border-color: rgba(59,130,246,.3); }

/* ── Toasts ─────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; left: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { min-width: 280px; max-width: 380px; background: var(--bg-surface); border: 1px solid var(--border-hover); border-radius: var(--radius-md); padding: 14px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-lg); pointer-events: all; animation: slideIn .3s ease; font-size: 14px; }
.toast.success { border-right: 3px solid var(--success); }
.toast.error   { border-right: 3px solid var(--danger); }
.toast.warning { border-right: 3px solid var(--warning); }
.toast-close   { margin-right: auto; cursor: pointer; color: var(--text-muted); font-size: 18px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 500; display: flex; align-items: center; justify-content: center; animation: fadeIn .2s ease; }
.modal { background: var(--bg-surface); border: 1px solid var(--border-hover); border-radius: var(--radius-xl); width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: scaleIn .2s ease; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close { font-size: 22px; color: var(--text-muted); cursor: pointer; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Invoice Builder ────────────────────────────────────────── */
.invoice-item-row { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; margin-bottom: 10px; transition: border-color var(--transition-fast); animation: fadeSlideDown .2s ease; }
.invoice-item-row:hover { border-color: var(--border-hover); }
.invoice-item-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.invoice-item-num { width: 28px; height: 28px; background: var(--primary-light); color: var(--primary); border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.invoice-press-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.press-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 8px; }

/* Toggle */
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-full); cursor: pointer; transition: background var(--transition-fast); }
.toggle-slider::before { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--text-muted); right: 3px; top: 50%; transform: translateY(-50%); transition: all var(--transition-fast); }
.toggle input:checked + .toggle-slider { background: var(--primary); border-color: var(--primary); }
.toggle input:checked + .toggle-slider::before { background: #fff; right: calc(100% - 17px); }

/* Totals */
.invoice-totals { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.totals-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 14px; }
.totals-row + .totals-row { border-top: 1px solid var(--border); }
.totals-row.grand-total { font-size: 18px; font-weight: 800; color: var(--primary); }

/* ── Factory ─────────────────────────────────────────────────── */
.factory-order-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; transition: all var(--transition-base); animation: fadeSlideDown .3s ease; }
.factory-order-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); }
.factory-order-card.status-pending     { border-right: 3px solid var(--warning); }
.factory-order-card.status-in_progress { border-right: 3px solid var(--info); }
.factory-order-card.status-completed   { border-right: 3px solid var(--success); opacity: 0.7; }
.order-item-line { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: rgba(255,255,255,.03); border-radius: var(--radius-sm); margin-bottom: 5px; font-size: 13px; }
.order-item-qty { width: 28px; height: 28px; background: var(--primary-light); color: var(--primary); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex-shrink: 0; }

.view-toggle { display: inline-flex; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.view-toggle-btn { padding: 8px 18px; font-size: 13px; font-weight: 600; color: var(--text-secondary); transition: all var(--transition-fast); cursor: pointer; display: flex; align-items: center; gap: 6px; }
.view-toggle-btn.active { background: var(--primary-light); color: var(--primary); }

/* ── Login ─────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-base); position: relative; overflow: hidden; }
.login-bg-glow { position: absolute; width: 600px; height: 600px; border-radius: 50%; filter: blur(120px); pointer-events: none; }
.login-bg-glow-1 { top: -200px; right: -200px; background: rgba(99,102,241,.15); }
.login-bg-glow-2 { bottom: -200px; left: -200px; background: rgba(139,92,246,.1); }
.login-card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-xl); padding: 40px; width: 100%; max-width: 420px; backdrop-filter: blur(20px); box-shadow: var(--shadow-lg); position: relative; z-index: 1; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon { width: 64px; height: 64px; background: linear-gradient(135deg, var(--primary), #8b5cf6); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; font-size: 28px; margin: 0 auto 12px; box-shadow: var(--shadow-primary); }
.login-logo h1 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-logo p  { font-size: 13px; color: var(--text-secondary); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.page-btn { min-width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); font-size: 13px; font-weight: 600; background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary); transition: all var(--transition-fast); text-decoration: none; }
.page-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.page-btn.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ── Stock Bar ─────────────────────────────────────────────── */
.stock-bar-wrapper { display: flex; align-items: center; gap: 8px; }
.stock-bar { flex: 1; height: 5px; background: rgba(255,255,255,.08); border-radius: var(--radius-full); overflow: hidden; }
.stock-bar-fill { height: 100%; border-radius: var(--radius-full); transition: width .4s ease; }
.stock-bar-fill.good   { background: var(--success); }
.stock-bar-fill.medium { background: var(--warning); }
.stock-bar-fill.low    { background: var(--danger); }

/* ── Dev Footer ─────────────────────────────────────────────── */
.dev-footer { text-align: center; padding: 16px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); }
.dev-footer a { color: var(--primary); font-weight: 600; }

/* ── Print ─────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print, .btn { display: none !important; }
  .main-content { margin-right: 0 !important; }
  body { background: #fff !important; color: #000 !important; font-size: 13px; }
  .print-invoice { display: block !important; }
}
.print-invoice { display: none; }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn        { from { opacity: 0; }           to { opacity: 1; } }
@keyframes fadeSlideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn       { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes scaleIn       { from { opacity: 0; transform: scale(.95); }  to { opacity: 1; transform: scale(1); } }
@keyframes spin          { to { transform: rotate(360deg); } }
@keyframes pulse         { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

.animate-fade-in    { animation: fadeIn .4s ease; }
.animate-slide-down { animation: fadeSlideDown .3s ease; }
.spinner            { animation: spin 1s linear infinite; }
.pulse-danger       { animation: pulse 2s infinite; }

/* ── Utilities ─────────────────────────────────────────────── */
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.text-muted { color: var(--text-secondary); } .text-small { font-size: 12px; }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.mb-0 { margin-bottom: 0; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.w-full { width: 100%; } .text-center { text-align: center; }
.text-danger { color: var(--danger); } .text-success { color: var(--success); } .text-warning { color: var(--warning); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; }
  .page-content { padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .invoice-press-options { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 24px; margin: 16px; }
}

/* ── Item Type Badges ──────────────────────────────────────── */
.badge-board   { background: rgba(16,185,129,.15); color: var(--success); }
.badge-press   { background: rgba(99,102,241,.15);  color: var(--primary); }
.badge-other   { background: rgba(245,158,11,.15);  color: var(--warning); }

/* ── Customer Avatar (in reports / audit) ─────────────────── */
.customer-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; flex-shrink: 0;
}

/* ── Audit Timeline ───────────────────────────────────────── */
.audit-timeline { padding: 0 4px; }
.audit-entry {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.audit-entry:last-child { border-bottom: none; }

/* ── Compact Invoice Row ──────────────────────────────────── */
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.inv-row { animation: fadeSlideDown .2s ease; }

/* ── Stat Card Variants ───────────────────────────────────── */
.stat-card.stat-danger  { border-right: 3px solid var(--danger); }
.stat-card.stat-primary { border-right: 3px solid var(--primary); }
.stat-card.stat-success { border-right: 3px solid var(--success); }
.stat-card.stat-warning { border-right: 3px solid var(--warning); }
.stat-card.stat-info    { border-right: 3px solid var(--info, #3b82f6); }

/* ── Reports chart style ───────────────────────────────────── */
canvas { display: block; }

/* ── Searchable Dropdown (complete) ──────────────────────── */
.searchable-dropdown { position: relative; }
.dropdown-menu { position: absolute; z-index: 2000; width: 100%; top: calc(100% + 4px); right: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; display: none; }
.dropdown-menu.open { display: block; animation: fadeSlideDown 0.15s ease; }
.dropdown-empty { padding: 14px 16px; color: var(--text-muted); font-size: 13px; text-align: center; }
