@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --bg-input: #1e293b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(56, 189, 248, 0.4);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-glow: rgba(2, 132, 199, 0.35);
  --accent: #6366f1;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 20px rgba(2, 132, 199, 0.1);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.6;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(2, 132, 199, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.1) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Container & Layout */
.app-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 28px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px var(--primary-glow);
}

.brand-logo svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

.brand-info h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: #334155;
  border-color: var(--text-muted);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: #ef4444;
  color: #fff;
}

.btn-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background: #10b981;
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* Modern Sleek Theme Switcher */
.theme-toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 10px;
  border-radius: var(--radius-full);
  background: rgba(17, 24, 39, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  user-select: none;
}

.theme-toggle-switch:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 12px rgba(2, 132, 199, 0.2);
  transform: translateY(-1px);
}

.theme-switch-icon-box {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle-switch:hover .theme-switch-icon-box {
  transform: rotate(20deg) scale(1.1);
}

.theme-switch-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.01em;
  transition: color 0.2s;
}

.theme-toggle-switch:hover .theme-switch-label {
  color: var(--text-main);
}

@media (max-width: 640px) {
  .theme-switch-label {
    display: none;
  }
  .theme-toggle-switch {
    padding: 5px;
    border-radius: 50%;
  }
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.stat-icon.blue { background: rgba(2, 132, 199, 0.2); color: #38bdf8; }
.stat-icon.purple { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.stat-icon.green { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.stat-icon.amber { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

.stat-info .stat-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.stat-info .stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Control Bar (Search & Filter) */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-box input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 42px 10px 16px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box svg {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.filter-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-tag {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
}

.filter-tag.active, .filter-tag:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Inline code & Empty State Cards */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(2, 132, 199, 0.12);
  color: #38bdf8;
  direction: ltr;
  display: inline-block;
}

.empty-state-card {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  background: rgba(17, 24, 39, 0.4);
  border-radius: 20px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  transition: var(--transition);
}

/* Personnel Grid */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
}

.user-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.user-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.user-card-top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.user-avatar {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
  background: #1e293b;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.user-main-info {
  flex: 1;
  min-width: 0;
}

.user-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.user-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-title {
  font-size: 0.88rem;
  color: #38bdf8;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-company {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Quick contact pills inside card */
.user-contacts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(15, 23, 42, 0.5);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.contact-row svg {
  width: 15px;
  height: 15px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.contact-row span {
  direction: ltr;
  text-align: right;
  font-family: inherit;
}

/* Mini QR preview card area */
.user-qr-preview-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  color: #0f172a;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  cursor: pointer;
  transition: var(--transition);
}

.user-qr-preview-box:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.15);
}

.qr-thumb-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.qr-thumb-canvas {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: #fff;
}

.qr-thumb-meta {
  display: flex;
  flex-direction: column;
}

.qr-label-display {
  font-weight: 800;
  font-size: 0.95rem;
  color: #0f172a;
}

.qr-type-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #0284c7;
}

.qr-preview-hint {
  font-size: 0.78rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Card Actions footer */
.user-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
  margin-top: auto;
}

.user-card-actions .btn {
  flex: 1;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-y: auto;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s ease;
  overflow: hidden;
  margin: auto;
}

.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
}

.modal-lg {
  max-width: 960px;
}

/* Ensure forms inside modals stretch and allow child modal-body to scroll */
#userForm,
.modal-container form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-input);
  color: #fff;
}

.modal-body {
  padding: 24px;
  overflow-y: auto !important;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

.modal-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.col-span-2 {
  grid-column: span 2;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Tabs */
.tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  gap: 6px;
  margin-bottom: 20px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* QR Studio Layout */
.qr-studio-layout {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 28px;
  align-items: start;
}

@media (max-width: 768px) {
  .qr-studio-layout {
    grid-template-columns: 1fr;
  }
}

/* The Printable Canvas & Container */
.qr-canvas-preview-card {
  background: #ffffff;
  color: #0f172a;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  position: sticky;
  top: 10px;
}

.qr-code-mount {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 280px;
  height: 280px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}

.qr-code-mount canvas,
.qr-code-mount svg {
  max-width: 100% !important;
  max-height: 100% !important;
}

.qr-label-under {
  margin-top: 16px;
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  text-align: center;
  letter-spacing: -0.01em;
  font-family: var(--font-family);
  direction: rtl;
}

.qr-meta-sub {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 4px;
  text-align: center;
}

/* Export Buttons Box */
.export-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  margin-top: 20px;
}

.export-actions-row .btn {
  flex: 1;
  min-width: 120px;
}

/* Toggle Switch */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* Print Mode */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .app-header, .stats-row, .controls-bar, .user-card-actions, .export-actions-row, .modal-footer, .modal-header, .qr-controls-pane {
    display: none !important;
  }
  .modal-overlay {
    position: static !important;
    background: none !important;
    display: block !important;
    opacity: 1 !important;
    padding: 0 !important;
  }
  .modal-container {
    border: none !important;
    box-shadow: none !important;
    background: none !important;
    max-width: 100% !important;
  }
  .qr-canvas-preview-card {
    border: 2px dashed #94a3b8 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    width: 320px;
    margin: 20px auto;
  }
}

/* ===================================================
   Anti-Fraud & Device Scan Analytics Styles
   =================================================== */

.modal-xl {
  max-width: 960px !important;
}

/* Scan Pill on Personnel Grid Card */
.user-scans-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition);
}

.user-scans-badge:hover {
  background: rgba(2, 132, 199, 0.16);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.scans-count-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.scans-count-pill strong {
  color: #38bdf8;
  font-weight: 700;
  font-size: 1rem;
}

.scans-count-pill .scan-unique {
  font-size: 0.76rem;
  color: var(--text-dim);
}

.btn-scan-details {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.btn-scan-details:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Anti-Fraud Alert Box */
.fraud-alert-box {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.fraud-alert-box.info {
  background: rgba(2, 132, 199, 0.1);
  border-color: rgba(2, 132, 199, 0.3);
  color: #e0f2fe;
}

.fraud-alert-box.warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fef3c7;
}

.fraud-alert-box.danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fee2e2;
}

.fraud-alert-box.success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #d1fae5;
}

.fraud-alert-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  line-height: 1;
}

.fraud-alert-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 2px;
}

/* Scan Logs Table */
.scan-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.5);
  max-height: 380px;
  overflow-y: auto;
}

.scan-logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: right;
}

.scan-logs-table th {
  background: #1e293b;
  color: var(--text-muted);
  padding: 12px 14px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.scan-logs-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  vertical-align: middle;
}

.scan-logs-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge.valid {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.duplicate {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.device-badge-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-icon-tag {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.device-text-main {
  font-weight: 600;
  color: #fff;
}

.device-text-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.code-cell {
  font-family: monospace;
  direction: ltr;
  text-align: right;
  font-size: 0.78rem;
  color: #94a3b8;
}

/* ===================================================
   Dynamic Multi-Phone & Multi-Website Rows Builder
   =================================================== */

.dynamic-rows-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 6px;
}

.phone-builder-row, .website-builder-row {
  display: grid;
  grid-template-columns: 140px 1fr 100px 38px;
  gap: 8px;
  align-items: center;
  background: rgba(30, 41, 59, 0.5);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  animation: fadeIn 0.2s ease;
}

.website-builder-row {
  grid-template-columns: 180px 1fr 38px;
}

@media (max-width: 640px) {
  .phone-builder-row {
    grid-template-columns: 1fr 1fr;
  }
  .website-builder-row {
    grid-template-columns: 1fr 38px;
  }
}

.phone-builder-row select, .phone-builder-row input,
.website-builder-row input {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
  width: 100%;
}

.phone-builder-row select:focus, .phone-builder-row input:focus,
.website-builder-row input:focus {
  border-color: var(--primary);
}

.btn-remove-row {
  width: 36px;
  height: 36px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition);
}

.btn-remove-row:hover {
  background: #ef4444;
  color: #fff;
}

/* ==========================================================================
   Avatar Feature Card in Modal
   ========================================================================== */
.avatar-feature-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  background: rgba(2, 132, 199, 0.08);
  border: 1px dashed rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: var(--transition);
}

.avatar-feature-card.drag-over {
  background: rgba(2, 132, 199, 0.2);
  border-color: var(--primary);
  border-style: solid;
  transform: scale(1.01);
}

.avatar-preview-wrapper {
  position: relative;
  width: 86px;
  height: 86px;
  min-width: 86px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  background: #1e293b;
}

.avatar-preview-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-overlay-hint {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #fff;
  font-size: 0.72rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  user-select: none;
}

.avatar-preview-wrapper:hover .avatar-overlay-hint {
  opacity: 1;
}

.avatar-actions-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.avatar-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.avatar-status-pill {
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.avatar-status-pill.custom {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

.avatar-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.avatar-buttons-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 640px) {
  .avatar-feature-card {
    flex-direction: column;
    text-align: center;
  }
  .avatar-title-row {
    justify-content: center;
  }
  .avatar-buttons-toolbar {
    justify-content: center;
  }
}

/* ==========================================================================
   Light Theme System
   ========================================================================== */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.96);
  --bg-card-hover: #ffffff;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-hover: rgba(2, 132, 199, 0.6);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-glow: rgba(2, 132, 199, 0.25);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.12), 0 0 15px rgba(2, 132, 199, 0.08);
}

[data-theme="light"] body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(2, 132, 199, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 40%);
}

[data-theme="light"] .brand-info h1 {
  color: #0f172a;
}

[data-theme="light"] .app-header {
  background: #ffffff;
  border-color: var(--border-color);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .stat-card {
  background: #ffffff;
  border-color: var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .stat-info .stat-num {
  color: #0f172a;
}

[data-theme="light"] .controls-bar {
  background: #ffffff;
  border-color: var(--border-color);
}

[data-theme="light"] .search-box input {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

[data-theme="light"] .filter-tag {
  background: #f1f5f9;
  color: #64748b;
  border-color: #e2e8f0;
}

[data-theme="light"] .filter-tag:hover {
  background: #e2e8f0;
  color: #0f172a;
}

[data-theme="light"] .filter-tag.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

[data-theme="light"] .user-card {
  background: #ffffff;
  border-color: var(--border-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .user-name {
  color: #0f172a;
}

[data-theme="light"] .user-title {
  color: #475569;
}

[data-theme="light"] .user-company {
  color: #64748b;
}

[data-theme="light"] .user-scans-badge {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #0f172a;
}

[data-theme="light"] .btn-scan-details {
  background: #ffffff;
  color: var(--primary);
  border-color: #cbd5e1;
}

[data-theme="light"] .user-contacts-list {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .user-contacts-list .contact-row {
  color: #334155;
}

[data-theme="light"] .qr-label-display {
  color: #0f172a;
}

[data-theme="light"] .user-qr-preview-box {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .btn-secondary {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

[data-theme="light"] .btn-secondary:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

[data-theme="light"] .theme-toggle-switch {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #0f172a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .theme-toggle-switch:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .theme-switch-icon-box {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
}

[data-theme="light"] .theme-switch-label {
  color: #64748b;
}

[data-theme="light"] .theme-toggle-switch:hover .theme-switch-label {
  color: #0f172a;
}

[data-theme="light"] .modal-overlay {
  background: rgba(15, 23, 42, 0.65);
}

[data-theme="light"] .modal-container {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .modal-header {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .modal-header h3 {
  color: #0f172a;
}

[data-theme="light"] .modal-footer {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .form-group label {
  color: #334155 !important;
}

[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="email"],
[data-theme="light"] input[type="number"],
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

[data-theme="light"] .phone-builder-row,
[data-theme="light"] .website-builder-row {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .phone-builder-row select,
[data-theme="light"] .phone-builder-row input,
[data-theme="light"] .website-builder-row input {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

[data-theme="light"] .avatar-feature-card {
  background: rgba(2, 132, 199, 0.05);
  border-color: rgba(2, 132, 199, 0.3);
}

[data-theme="light"] .avatar-preview-wrapper {
  background: #e2e8f0;
  border-color: #cbd5e1;
}

[data-theme="light"] .avatar-status-pill {
  background: #e2e8f0;
  color: #475569;
}

[data-theme="light"] .avatar-status-pill.custom {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

[data-theme="light"] .qr-canvas-preview-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .qr-controls-pane {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .scan-table-wrapper {
  border-color: #e2e8f0;
}

[data-theme="light"] .scan-logs-table th {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

[data-theme="light"] .scan-logs-table td {
  color: #1e293b;
  border-color: #e2e8f0;
}

[data-theme="light"] .scan-logs-table tr:hover td {
  background: #f8fafc;
}

[data-theme="light"] .modal-body::-webkit-scrollbar-track {
  background: #f1f5f9;
}
/* ==========================================================================
   Main Navigation Tabs Bar
   ========================================================================== */
.main-tabs-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
}

.main-tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.main-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .main-tab-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.main-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.main-tab-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ==========================================================================
   Documentation & User Guide View
   ========================================================================== */
.docs-view {
  display: none;
  flex-direction: column;
  gap: 24px;
}

.docs-view.active {
  display: flex;
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}

.docs-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.docs-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.docs-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
}

.docs-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(2, 132, 199, 0.15);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.docs-card-icon svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.docs-card-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.docs-card-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.8;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.docs-card-body p {
  margin: 0;
}

.docs-card-body ul, .docs-card-body ol {
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.docs-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(2, 132, 199, 0.15);
  color: #38bdf8;
}

[data-theme="light"] .docs-badge {
  color: var(--primary);
  background: rgba(2, 132, 199, 0.1);
}

.code-box {
  background: #0b0f19;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  direction: ltr;
  text-align: left;
  font-family: monospace;
  font-size: 0.85rem;
  color: #38bdf8;
  overflow-x: auto;
}

[data-theme="light"] .code-box {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0369a1;
}

.step-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  margin-left: 6px;
}




/* ==========================================================================
   Full Comprehensive Light Theme Contrast & Conflict Resolution
   ========================================================================== */

[data-theme="light"] code {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

[data-theme="light"] .empty-state-card {
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .stat-icon.blue { background: rgba(2, 132, 199, 0.12); color: #0284c7; }
[data-theme="light"] .stat-icon.purple { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }
[data-theme="light"] .stat-icon.green { background: rgba(16, 185, 129, 0.12); color: #059669; }
[data-theme="light"] .stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: #d97706; }

[data-theme="light"] .user-avatar {
  background: #f1f5f9;
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .contact-row svg {
  color: #64748b;
}

[data-theme="light"] .scans-count-pill strong {
  color: #0284c7;
}

[data-theme="light"] .user-qr-preview-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #0f172a;
}

[data-theme="light"] .user-qr-preview-box:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .modal-close {
  color: #64748b;
}

[data-theme="light"] .modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

[data-theme="light"] .tabs-nav {
  border-color: #e2e8f0;
}

[data-theme="light"] .tab-btn {
  color: #64748b;
}

[data-theme="light"] .tab-btn:hover {
  color: #0f172a;
}

[data-theme="light"] .tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

[data-theme="light"] .form-hint {
  color: #64748b;
}

[data-theme="light"] .toggle-group {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .slider {
  background-color: #cbd5e1;
}

[data-theme="light"] input:checked + .slider {
  background-color: var(--primary);
}

[data-theme="light"] .fraud-alert-box.info {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0369a1;
}

[data-theme="light"] .fraud-alert-box.warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

[data-theme="light"] .fraud-alert-box.danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

[data-theme="light"] .fraud-alert-box.success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

[data-theme="light"] .device-text-main {
  color: #0f172a;
}

[data-theme="light"] .device-icon-tag {
  background: #e2e8f0;
  color: #334155;
}

[data-theme="light"] .status-badge.valid {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

[data-theme="light"] .status-badge.duplicate {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

[data-theme="light"] .code-cell {
  color: #475569;
}

[data-theme="light"] .main-tabs-bar {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .main-tab-btn {
  color: #64748b;
}

[data-theme="light"] .main-tab-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

[data-theme="light"] .main-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}

[data-theme="light"] .docs-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .docs-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.08);
}

[data-theme="light"] .docs-card-header {
  border-color: #f1f5f9;
}

[data-theme="light"] .docs-card-title {
  color: #0f172a;
}

[data-theme="light"] .docs-card-body {
  color: #334155;
}

[data-theme="light"] .docs-card-icon {
  background: #e0f2fe;
  color: #0284c7;
}

[data-theme="light"] .toast {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .btn-remove-row {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

[data-theme="light"] .btn-remove-row:hover {
  background: #ef4444;
  color: #ffffff;
}
