/* ============ Variables ============ */
:root {
  --bg-primary: #eef2ff;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f8faff;
  --bg-sidebar: linear-gradient(165deg, #0a1e5e 0%, #1e40af 45%, #3730a3 100%);
  --bg-app-gradient: radial-gradient(at 0% 0%, rgba(99,102,241,0.08) 0px, transparent 50%),
                     radial-gradient(at 100% 0%, rgba(236,72,153,0.05) 0px, transparent 50%),
                     radial-gradient(at 100% 100%, rgba(59,130,246,0.06) 0px, transparent 50%),
                     radial-gradient(at 0% 100%, rgba(168,85,247,0.05) 0px, transparent 50%);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-light: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(79,70,229,0.35);
  --secondary: #ec4899;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --gold: #daa520;
  --gold-light: #f4c430;
  --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #8b5cf6 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  --gradient-info: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --gradient-gold: linear-gradient(135deg, #f4c430 0%, #b8860b 100%);
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.04), 0 1px 2px rgba(15,23,42,0.06);
  --shadow: 0 4px 6px -1px rgba(15,23,42,0.08), 0 2px 4px -2px rgba(15,23,42,0.04);
  --shadow-lg: 0 10px 30px -5px rgba(15,23,42,0.12), 0 8px 16px -8px rgba(15,23,42,0.08);
  --shadow-xl: 0 25px 50px -12px rgba(15,23,42,0.2);
  --shadow-glow: 0 0 30px rgba(79,70,229,0.15);
  --glass-bg: rgba(255,255,255,0.7);
  --glass-border: rgba(255,255,255,0.5);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  --bg-primary: #020617;
  --bg-secondary: #0f172a;
  --bg-tertiary: #1e293b;
  --bg-sidebar: linear-gradient(165deg, #020617 0%, #0f172a 50%, #1e1b4b 100%);
  --bg-app-gradient: radial-gradient(at 0% 0%, rgba(99,102,241,0.15) 0px, transparent 50%),
                     radial-gradient(at 100% 0%, rgba(236,72,153,0.08) 0px, transparent 50%),
                     radial-gradient(at 100% 100%, rgba(59,130,246,0.1) 0px, transparent 50%),
                     radial-gradient(at 0% 100%, rgba(168,85,247,0.08) 0px, transparent 50%);
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border: #1e293b;
  --border-strong: #334155;
  --glass-bg: rgba(15,23,42,0.7);
  --glass-border: rgba(99,102,241,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 30px -5px rgba(0,0,0,0.5);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.6);
}

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

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Cairo', 'Tajawal', sans-serif;
  background: var(--bg-primary);
  background-image: var(--bg-app-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}

/* Animated background blobs */
body::before {
  content: '';
  position: fixed;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(79,70,229,0.08) 0%, transparent 70%);
  border-radius: 50%;
  z-index: -1;
  animation: floatBlob 20s ease-in-out infinite;
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  bottom: -200px;
  left: -200px;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(236,72,153,0.06) 0%, transparent 70%);
  border-radius: 50%;
  z-index: -1;
  animation: floatBlob 25s ease-in-out infinite reverse;
  pointer-events: none;
}

@keyframes floatBlob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(50px, -30px) scale(1.1); }
  66% { transform: translate(-30px, 30px) scale(0.95); }
}

/* ============ Login Screen ============ */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0a1e5e 0%, #1e1b4b 50%, #312e81 100%);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

.login-screen.hidden { display: none !important; }

.login-bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.6;
  animation: floatBlob 15s ease-in-out infinite;
  pointer-events: none;
}

.bg-blob-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #f4c430, transparent);
  top: -100px; right: -100px;
}

.bg-blob-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #ec4899, transparent);
  bottom: -150px; left: -150px;
  animation-delay: -5s;
  opacity: 0.4;
}

.bg-blob-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #06b6d4, transparent);
  top: 50%; left: 50%;
  animation-delay: -10s;
  opacity: 0.3;
}

.login-card {
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(20px);
  border-radius: 28px;
  padding: 50px 44px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.5);
  position: relative;
  z-index: 2;
  animation: loginCardIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes loginCardIn {
  from { transform: translateY(40px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.login-logo {
  width: 100px;
  height: 100px;
  margin: 0 auto 20px;
  background: white;
  border-radius: 24px;
  padding: 12px;
  box-shadow: 0 12px 30px rgba(244,196,48,0.4), inset 0 0 0 2px rgba(244,196,48,0.3);
  animation: logoFloat 4s ease-in-out infinite;
}

.login-logo img { width: 100%; height: 100%; }

.login-card h1 {
  text-align: center;
  font-size: 36px;
  font-weight: 900;
  color: #1e3a8a;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  text-align: center;
  color: #64748b;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 32px;
}

.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-field {
  position: relative;
}

.login-field > i:first-child {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 14px;
}

.login-field input {
  width: 100%;
  padding: 15px 48px 15px 48px;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  background: #f8faff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  transition: var(--transition);
  color: #0f172a;
}

.login-field input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 4px rgba(79,70,229,0.15);
  background: white;
}

.toggle-pwd {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
}

.login-error {
  background: rgba(239,68,68,0.1);
  color: #dc2626;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(239,68,68,0.2);
  animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.login-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 10px 25px rgba(79,70,229,0.4);
  transition: var(--transition-bounce);
  margin-top: 8px;
}

.login-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 35px rgba(79,70,229,0.55);
}

.login-footer {
  text-align: center;
  margin-top: 30px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
}

.login-footer strong { color: #4f46e5; }

/* Change password overlay */
.change-pwd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.7);
  backdrop-filter: blur(8px);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.change-pwd-overlay[hidden] { display: none !important; }
[hidden] { display: none !important; }

.change-pwd-modal {
  background: white;
  border-radius: 24px;
  padding: 36px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4);
  animation: scaleIn 0.4s ease;
}

.change-pwd-modal h2 {
  font-size: 22px;
  margin-bottom: 8px;
  color: #0f172a;
}

.change-pwd-modal p {
  color: #64748b;
  margin-bottom: 22px;
  font-size: 14px;
}

.change-pwd-modal form { display: flex; flex-direction: column; gap: 14px; }

/* User management role cards */
.role-info {
  padding: 16px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  text-align: center;
}

.role-info i {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
}

.role-info strong {
  display: block;
  font-size: 16px;
  margin-bottom: 6px;
}

.role-info p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.role-admin { border-color: #f59e0b; background: rgba(245,158,11,0.05); }
.role-admin i { color: #f59e0b; }
.role-operator { border-color: #4f46e5; background: rgba(79,70,229,0.05); }
.role-operator i { color: #4f46e5; }
.role-viewer { border-color: #06b6d4; background: rgba(6,182,212,0.05); }
.role-viewer i { color: #06b6d4; }

/* Role badge in tables */
.role-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}
.role-badge-admin { background: rgba(245,158,11,0.15); color: #d97706; }
.role-badge-operator { background: rgba(79,70,229,0.15); color: #4f46e5; }
.role-badge-viewer { background: rgba(6,182,212,0.15); color: #0891b2; }

.status-active { color: var(--success); font-weight: 700; }
.status-inactive { color: var(--text-muted); }

.logout-btn:hover {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: white !important;
}

/* Activity log action icons */
.action-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

.action-login { background: rgba(16,185,129,0.15); color: #059669; }
.action-logout { background: rgba(100,116,139,0.15); color: #475569; }
.action-add { background: rgba(79,70,229,0.15); color: #4f46e5; }
.action-edit { background: rgba(245,158,11,0.15); color: #d97706; }
.action-delete { background: rgba(239,68,68,0.15); color: #dc2626; }
.action-export { background: rgba(6,182,212,0.15); color: #0891b2; }
.action-import { background: rgba(139,92,246,0.15); color: #7c3aed; }
.action-user { background: rgba(236,72,153,0.15); color: #db2777; }

/* ============ Sidebar ============ */
.sidebar {
  width: 285px;
  height: 100vh;
  max-height: 100vh;
  background: var(--bg-sidebar);
  color: var(--text-light);
  padding: 20px 0;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(15,23,42,0.2);
  z-index: 100;
  transition: var(--transition);
}

/* Decorative pattern overlay */
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(244,196,48,0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(139,92,246,0.1) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.sidebar > * { position: relative; z-index: 1; }

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 5px 25px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  animation: fadeInDown 0.6s ease;
  flex-shrink: 0;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-15px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.logo-icon-img {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(244,196,48,0.4), inset 0 0 0 2px rgba(244,196,48,0.3);
  padding: 6px;
  flex-shrink: 0;
  position: relative;
  animation: logoFloat 4s ease-in-out infinite;
}

.logo-icon-img::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 18px;
  background: linear-gradient(135deg, #f4c430, #b8860b);
  z-index: -1;
  opacity: 0.4;
  filter: blur(10px);
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.logo-icon-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-text h2 {
  background: linear-gradient(135deg, #f4c430, #ffffff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text h2 {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

.logo-text span {
  font-size: 12px;
  opacity: 0.75;
  font-weight: 500;
}

.nav-menu {
  padding: 20px 15px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.nav-menu::-webkit-scrollbar { width: 6px; }
.nav-menu::-webkit-scrollbar-track { background: transparent; }
.nav-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 6px; }
.nav-menu::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: 12px;
  background: transparent;
  color: rgba(255,255,255,0.8);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.nav-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  opacity: 0;
  transition: var(--transition);
  z-index: -1;
}

.nav-item:hover {
  color: white;
  transform: translateX(-4px);
}

.nav-item:hover::before { opacity: 1; }

.nav-item.active {
  background: linear-gradient(135deg, rgba(244,196,48,0.2), rgba(255,255,255,0.15));
  color: white;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.15);
  border: 1px solid rgba(244,196,48,0.3);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 70%;
  background: linear-gradient(180deg, #f4c430, #b8860b);
  border-radius: 5px 0 0 5px;
  box-shadow: -3px 0 10px rgba(244,196,48,0.6);
}

.nav-item i {
  width: 22px;
  text-align: center;
  font-size: 16px;
  transition: var(--transition);
}

.nav-item:hover i { transform: scale(1.15); color: var(--gold-light); }
.nav-item.active i { color: var(--gold-light); }

.sidebar-footer {
  padding: 15px 15px;
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.theme-toggle {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: white;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  transition: var(--transition);
  margin-bottom: 12px;
}

.theme-toggle:hover { background: rgba(255,255,255,0.2); }

.company-badge {
  text-align: center;
  font-size: 12px;
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.developer-badge {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  font-size: 11px;
  text-align: center;
}

.developer-badge .dev-name {
  color: rgba(255,255,255,0.8);
  margin-bottom: 6px;
  font-weight: 600;
}

.developer-badge .dev-name strong {
  color: #f4c430;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.developer-badge .dev-name i {
  margin-left: 4px;
  color: #f4c430;
}

.developer-badge .dev-phone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-weight: 700;
  background: rgba(255,255,255,0.1);
  padding: 5px 10px;
  border-radius: 8px;
  transition: var(--transition);
  direction: ltr;
}

.developer-badge .dev-phone:hover {
  background: #f4c430;
  color: #1e3a8a;
}

.developer-badge .dev-phone i {
  font-size: 10px;
}

/* Developer card in Settings > About */
.developer-card {
  margin-top: 25px;
  background: linear-gradient(135deg, rgba(37,99,235,0.08), rgba(99,102,241,0.06));
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.developer-card-header {
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: white;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.developer-card-body {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.dev-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, #b8860b, #daa520);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -1px;
  box-shadow: 0 4px 14px rgba(184,134,11,0.4);
  flex-shrink: 0;
}

.dev-info h4 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.dev-info p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.dev-contact {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  transition: var(--transition);
}

.dev-contact:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.dev-contact i { font-size: 13px; }

/* ============ Main Content ============ */
.main-content {
  flex: 1;
  margin-right: 280px;
  padding: 25px 30px;
  min-height: 100vh;
  transition: var(--transition);
}

.topbar {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 25px;
  box-shadow: var(--shadow);
  border: 1px solid var(--glass-border);
  position: sticky;
  top: 15px;
  z-index: 50;
  animation: fadeInDown 0.5s ease;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-primary);
}

.search-box {
  flex: 1;
  max-width: 500px;
  position: relative;
}

.search-box i {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 12px 45px 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg-tertiary);
  font-family: inherit;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
  background: var(--bg-secondary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
  transition: var(--transition-bounce);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.icon-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: -1;
}

.icon-btn:hover {
  color: white;
  border-color: var(--primary);
  transform: translateY(-3px) rotate(-5deg);
  box-shadow: 0 8px 20px var(--primary-glow);
}

.icon-btn:hover::before { opacity: 1; }

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 15px;
  border-right: 1px solid var(--border);
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  box-shadow: 0 6px 16px var(--primary-glow);
  position: relative;
}

.user-avatar::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
}

.user-text strong {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
}

.user-text small {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============ Pages ============ */
.page { display: none; animation: pageEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
.page.active { display: block; }

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 15px;
  animation: slideInRight 0.5s ease 0.1s backwards;
}

.page-header h1 {
  font-size: 30px;
  font-weight: 900;
  margin-bottom: 6px;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--text-primary), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

.page-actions {
  display: flex;
  gap: 10px;
}

/* ============ Stats Grid ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.stats-grid .stat-card {
  animation: scaleIn 0.5s ease backwards;
}
.stats-grid .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.15s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.2s; }

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: default;
}

.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, currentColor 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  color: var(--primary);
}

.stat-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-xl);
  border-color: transparent;
}

.stat-card:hover::after { opacity: 0.05; }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 4px;
  transition: height 0.3s ease;
}

.stat-card:hover::before { height: 6px; }

.stat-blue::before { background: linear-gradient(90deg, #3b82f6, #6366f1); }
.stat-green::before { background: linear-gradient(90deg, #10b981, #059669); }
.stat-orange::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.stat-purple::before { background: linear-gradient(90deg, #8b5cf6, #ec4899); }

.stat-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
  flex-shrink: 0;
  position: relative;
  transition: var(--transition-bounce);
}

.stat-icon::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 20px;
  background: inherit;
  opacity: 0.4;
  filter: blur(12px);
  z-index: -1;
}

.stat-card:hover .stat-icon {
  transform: rotate(-10deg) scale(1.1);
}

.stat-blue .stat-icon { background: linear-gradient(135deg, #3b82f6, #6366f1); box-shadow: 0 10px 25px rgba(59,130,246,0.4); }
.stat-green .stat-icon { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 10px 25px rgba(16,185,129,0.4); }
.stat-orange .stat-icon { background: linear-gradient(135deg, #f59e0b, #ef4444); box-shadow: 0 10px 25px rgba(245,158,11,0.4); }
.stat-purple .stat-icon { background: linear-gradient(135deg, #8b5cf6, #ec4899); box-shadow: 0 10px 25px rgba(139,92,246,0.4); }

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 32px;
  font-weight: 900;
  color: var(--text-primary);
  display: block;
  line-height: 1;
  letter-spacing: -1px;
  font-feature-settings: 'tnum';
}

.stat-trend {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  display: block;
}

/* ============ Dashboard Grid ============ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 25px;
}

@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ============ Cards ============ */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 22px;
  overflow: hidden;
  transition: var(--transition);
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: -0.2px;
}

.card-header h3 i {
  color: var(--primary);
  background: rgba(79,70,229,0.1);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.card-body { padding: 24px; }

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ============ Forms ============ */
.form-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: scaleIn 0.4s ease;
}

.form-section {
  padding: 25px;
  border-bottom: 1px solid var(--border);
}

.form-section:last-of-type { border-bottom: none; }

.section-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  padding-bottom: 14px;
  border-bottom: 3px solid;
  border-image: var(--gradient-primary) 1;
  width: fit-content;
  position: relative;
}

.section-title i {
  color: white;
  font-size: 16px;
  background: var(--gradient-primary);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px var(--primary-glow);
}

.sub-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-primary);
  padding: 8px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-right: 3px solid var(--primary);
}

.sub-section-title i {
  color: var(--primary);
  font-size: 13px;
}

.field-hint {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  min-height: 18px;
}

.field-hint.valid { color: var(--success); }
.field-hint.warning { color: var(--warning); }
.field-hint.expired { color: var(--danger); }

input[type="date"] {
  font-family: inherit;
  position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* Custom date wrapper */
.date-field {
  position: relative;
}

.date-field input.date-input {
  width: 100%;
  padding: 11px 14px;
  padding-left: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  direction: ltr;
  text-align: right;
  cursor: pointer;
}

.date-field input.date-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: var(--bg-secondary);
}

.date-field .date-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.date-field input.date-input.empty {
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.required { color: var(--danger); }

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.form-group input:hover:not(:focus),
.form-group select:hover:not(:focus),
.form-group textarea:hover:not(:focus) {
  border-color: var(--border-strong);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
  background: var(--bg-secondary);
  transform: translateY(-1px);
}

.form-actions {
  padding: 20px 25px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
}

/* ============ Buttons ============ */
.btn {
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-bounce);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.2px;
  isolation: isolate;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.25), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn:hover::before { opacity: 1; }
.btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.btn:active { transform: translateY(-1px) scale(0.98); }

/* Ripple effect */
.btn::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 50%;
  left: 50%;
  background: rgba(255,255,255,0.5);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.6s, opacity 0.6s;
  opacity: 0;
  pointer-events: none;
}

.btn:active::after {
  transform: translate(-50%, -50%) scale(2);
  opacity: 0;
  transition: 0s;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 6px 18px rgba(79,70,229,0.35);
}

.btn-primary:hover {
  box-shadow: 0 10px 30px rgba(79,70,229,0.5);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
  box-shadow: 0 6px 18px rgba(16,185,129,0.35);
}

.btn-success:hover { box-shadow: 0 10px 30px rgba(16,185,129,0.5); }

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 6px 18px rgba(239,68,68,0.35);
}

.btn-info {
  background: var(--gradient-info);
  color: white;
  box-shadow: 0 6px 18px rgba(6,182,212,0.35);
}

/* ============ Tables ============ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: var(--bg-primary);
}

.data-table th {
  padding: 14px 12px;
  text-align: right;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: linear-gradient(90deg, rgba(79,70,229,0.05), transparent);
  transform: scale(1.005);
  box-shadow: inset 4px 0 0 var(--primary);
}

.table-footer {
  padding: 15px 22px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-primary);
}

.action-btns {
  display: flex;
  gap: 6px;
}

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 13px;
}

.action-btn.view { background: rgba(6,182,212,0.15); color: #0891b2; }
.action-btn.edit { background: rgba(245,158,11,0.15); color: #d97706; }
.action-btn.delete { background: rgba(239,68,68,0.15); color: #dc2626; }
.action-btn:hover { transform: scale(1.1); }

/* ============ Filter Bar ============ */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-search {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.filter-search i {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.filter-search input {
  width: 100%;
  padding: 11px 45px 11px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
}

.filter-bar select,
.filter-bar input[type="date"] {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  min-width: 140px;
}

/* ============ Quick Load Driver ============ */
.quick-load-section {
  background: linear-gradient(135deg, rgba(37,99,235,0.05), rgba(99,102,241,0.05));
  border-bottom: 1px solid var(--border) !important;
}

.quick-load-search {
  position: relative;
}

.quick-load-search i.fa-search {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary);
  font-size: 16px;
  z-index: 2;
}

.quick-load-search input {
  width: 100%;
  padding: 14px 50px 14px 18px;
  border: 2px solid var(--primary);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  transition: var(--transition);
}

.quick-load-search input:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.15);
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.autocomplete-dropdown.active { display: block; }

.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg-primary); }

.autocomplete-item .ac-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;
}

.autocomplete-item .ac-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.autocomplete-item .ac-info {
  flex: 1;
  min-width: 0;
}

.autocomplete-item .ac-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.autocomplete-item .ac-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.autocomplete-item .ac-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.autocomplete-item .ac-count {
  background: rgba(37,99,235,0.1);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.autocomplete-empty {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
}

.loaded-driver-badge {
  margin-top: 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(16,185,129,0.12), rgba(5,150,105,0.08));
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.loaded-driver-badge > i {
  color: var(--success);
  font-size: 20px;
}

.loaded-driver-badge span {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 200px;
}

.btn-clear-driver {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-clear-driver:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* ============ Signature Pad ============ */
.signature-container {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 16px;
  background: var(--bg-tertiary);
}

.signature-pad-wrapper {
  position: relative;
  width: 100%;
  height: 200px;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--border);
  margin-bottom: 12px;
}

.signature-pad {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  display: block;
}

.signature-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  pointer-events: none;
  transition: opacity 0.3s;
}

.signature-placeholder i {
  font-size: 36px;
  margin-bottom: 8px;
  color: var(--primary);
  opacity: 0.4;
}

.signature-placeholder span {
  font-weight: 700;
  font-size: 16px;
}

.signature-pad-wrapper.has-signature .signature-placeholder {
  opacity: 0;
}

.signature-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.signature-status {
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
}

.signature-status.empty { color: var(--text-muted); }

.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ============ Status Badges ============ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pending { background: rgba(100,116,139,0.15); color: #475569; }
.status-loading { background: rgba(245,158,11,0.15); color: #d97706; }
.status-in_transit { background: rgba(6,182,212,0.15); color: #0891b2; }
.status-delivered { background: rgba(139,92,246,0.15); color: #7c3aed; }
.status-completed { background: rgba(16,185,129,0.15); color: #059669; }
.status-problem { background: rgba(239,68,68,0.15); color: #dc2626; }

/* ============ Firebase Status Indicator ============ */
.fb-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(245,158,11,0.05));
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 20px;
  color: #d97706;
  font-size: 12px;
  font-weight: 700;
}

.fb-status i {
  color: #f59e0b;
  animation: pulse 3s infinite;
}

.firebase-mode .fb-status {
  background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(16,185,129,0.05));
  border-color: rgba(16,185,129,0.3);
  color: #059669;
}

.firebase-mode .fb-status i {
  color: var(--success);
}

/* ============ Voice Input Button ============ */
.voice-btn {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  z-index: 2;
  box-shadow: 0 4px 12px var(--primary-glow);
  transition: var(--transition);
}

.voice-btn:hover { transform: translateY(-50%) scale(1.1); }

.voice-btn.listening {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  animation: pulse 1s infinite;
}

input[data-voice-added], textarea[data-voice-added] { padding-left: 44px !important; }

/* ============ Scanner File List ============ */
.scanner-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  font-family: inherit;
  text-align: right;
  transition: var(--transition);
}

.scanner-file-item:hover {
  background: var(--bg-primary);
  border-color: var(--primary);
  transform: translateX(-3px);
}

.scanner-file-item i { color: var(--info); font-size: 18px; }
.scanner-file-item span { flex: 1; font-weight: 600; }
.scanner-file-item small { color: var(--text-muted); font-size: 11px; }

/* ============ Status Banner in Modal ============ */
.status-banner {
  padding: 18px 22px;
  border-radius: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 2px solid;
  position: relative;
  overflow: hidden;
}

.status-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, currentColor 0%, transparent 60%);
  opacity: 0.08;
  pointer-events: none;
}

.status-banner-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.status-banner-value {
  font-size: 20px;
  font-weight: 800;
  margin-right: auto;
}

.status-banner.status-pending { border-color: #64748b; color: #475569; }
.status-banner.status-loading { border-color: #f59e0b; color: #d97706; background: linear-gradient(135deg, rgba(245,158,11,0.08), transparent); }
.status-banner.status-in_transit { border-color: #06b6d4; color: #0891b2; background: linear-gradient(135deg, rgba(6,182,212,0.08), transparent); }
.status-banner.status-delivered { border-color: #8b5cf6; color: #7c3aed; background: linear-gradient(135deg, rgba(139,92,246,0.08), transparent); }
.status-banner.status-completed { border-color: #10b981; color: #059669; background: linear-gradient(135deg, rgba(16,185,129,0.08), transparent); }
.status-banner.status-problem { border-color: #ef4444; color: #dc2626; background: linear-gradient(135deg, rgba(239,68,68,0.08), transparent); animation: pulse 2s infinite; }

/* Quick status change buttons */
.quick-status-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-radius: 12px;
  margin-bottom: 16px;
}

.quick-status-btn {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.quick-status-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
}

.quick-status-btn.active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 14px var(--primary-glow);
}

/* ============ Incident Severity ============ */
.severity-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.severity-low { background: rgba(16,185,129,0.15); color: #059669; }
.severity-medium { background: rgba(245,158,11,0.15); color: #d97706; }
.severity-high { background: rgba(239,68,68,0.15); color: #dc2626; }
.severity-critical { background: #dc2626; color: white; animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ============ Blacklist Warning ============ */
.blacklist-warning {
  background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(220,38,38,0.08));
  border: 2px solid var(--danger);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: shake 0.5s;
}

.blacklist-warning i {
  font-size: 24px;
  color: var(--danger);
}

.blacklist-warning strong {
  display: block;
  color: var(--danger);
  margin-bottom: 4px;
}

.blacklist-warning small {
  color: var(--text-secondary);
  font-size: 12px;
}

/* ============ Report Preview ============ */
.report-preview {
  margin-top: 25px;
}

.report-preview:empty { display: none; }

/* ============ Image Uploads ============ */
.image-uploads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.image-upload label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.img-drop {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
}

.img-drop:hover {
  border-color: var(--primary);
  background: rgba(37,99,235,0.05);
}

.img-drop.dragging {
  border-color: var(--success);
  background: rgba(16,185,129,0.05);
}

.img-drop i {
  font-size: 32px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.img-drop span {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 8px;
  text-align: center;
}

.img-drop.has-image i,
.img-drop.has-image span {
  display: none;
}

.img-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.img-remove {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(239,68,68,0.95);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: var(--shadow);
  z-index: 2;
  transition: var(--transition);
}

.img-remove:hover {
  background: var(--danger);
  transform: scale(1.1);
}

.img-view {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.expiry-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
}

.expiry-valid { background: rgba(16,185,129,0.15); color: #059669; }
.expiry-warning { background: rgba(245,158,11,0.2); color: #d97706; }
.expiry-expired { background: rgba(239,68,68,0.2); color: #dc2626; }

.image-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 30px;
}

.image-lightbox.active { display: flex; }

.image-lightbox img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.image-lightbox-close {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: white;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: #000;
}

/* ============ OCR ============ */
.ocr-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 25px;
}

@media (max-width: 1024px) {
  .ocr-container { grid-template-columns: 1fr; }
}

.ocr-upload, .ocr-results {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 25px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.upload-area {
  border: 3px dashed var(--border);
  border-radius: var(--radius);
  padding: 50px 30px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.upload-area:hover, .upload-area.dragging {
  border-color: var(--primary);
  background: rgba(37,99,235,0.05);
}

.upload-area i {
  font-size: 56px;
  color: var(--primary);
  margin-bottom: 18px;
}

.upload-area h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.upload-area p {
  color: var(--text-muted);
  margin-bottom: 8px;
}

.upload-area small {
  color: var(--text-muted);
  font-size: 12px;
}

.ocr-preview img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  margin-bottom: 18px;
}

.ocr-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ocr-progress {
  margin-top: 20px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #6366f1);
  width: 0%;
  transition: width 0.3s ease;
}

.extracted-text {
  background: var(--bg-primary);
  padding: 15px;
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  border: 1px solid var(--border);
}

.detected-fields {
  display: grid;
  gap: 10px;
}

.detected-field {
  display: flex;
  justify-content: space-between;
  padding: 12px 15px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.detected-field strong { color: var(--primary); }

/* ============ Import ============ */
.import-area { margin-bottom: 25px; }

.template-info {
  background: var(--bg-primary);
  padding: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.template-info h4 {
  margin-bottom: 12px;
  color: var(--text-primary);
}

.template-code {
  display: block;
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-family: monospace;
  direction: rtl;
}

/* ============ Settings ============ */
.settings-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.backup-status {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(5,150,105,0.05));
  border: 1.5px solid rgba(16,185,129,0.25);
  border-radius: 12px;
}

.backup-status.warning {
  background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(217,119,6,0.05));
  border-color: rgba(245,158,11,0.3);
}

.backup-status.danger {
  background: linear-gradient(135deg, rgba(239,68,68,0.08), rgba(220,38,38,0.05));
  border-color: rgba(239,68,68,0.3);
}

.backup-status > i {
  font-size: 24px;
  color: var(--success);
}

.backup-status.warning > i { color: var(--warning); }
.backup-status.danger > i { color: var(--danger); }

.backup-status strong {
  display: block;
  font-weight: 700;
  margin-bottom: 2px;
}

.backup-status small {
  color: var(--text-muted);
  font-size: 12px;
}

/* ============ Toast ============ */
.toast-container {
  position: fixed;
  bottom: 25px;
  left: 25px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-secondary);
  padding: 16px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 300px;
  border-right: 5px solid var(--primary);
  animation: slideInBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(20px);
  font-weight: 600;
}

@keyframes slideInBounce {
  from { transform: translateX(-120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-right-color: var(--success); }
.toast.error { border-right-color: var(--danger); }
.toast.warning { border-right-color: var(--warning); }

.toast i {
  font-size: 20px;
}

.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ Modal ============ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.65);
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: backdropIn 0.3s ease;
}

@keyframes backdropIn {
  from { background: rgba(15,23,42,0); backdrop-filter: blur(0); }
  to { background: rgba(15,23,42,0.65); backdrop-filter: blur(8px); }
}

.modal.active { display: flex; }

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  max-width: 750px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(15,23,42,0.4);
  animation: modalIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid var(--border);
}

@keyframes modalIn {
  from { transform: scale(0.85) translateY(30px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gradient-primary);
  color: white;
}

.modal-header h3 { color: white; }

.modal-header h3 { font-size: 18px; }

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: none;
  cursor: pointer;
  color: white;
  transition: var(--transition-bounce);
  backdrop-filter: blur(10px);
}

.modal-close:hover {
  background: var(--danger);
  color: white;
  transform: rotate(90deg) scale(1.1);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 18px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

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

.detail-item {
  padding: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.detail-item label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 4px;
}

.detail-item span {
  font-weight: 600;
  color: var(--text-primary);
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-right: 0;
  }
  .menu-toggle {
    display: block;
  }
}

@media (max-width: 640px) {
  .main-content { padding: 15px; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .user-info { display: none; }
}

/* ============ Print ============ */
@media print {
  .sidebar, .topbar, .form-actions, .page-actions,
  .filter-bar, .action-btns, .modal-footer { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
