/* ===== CSS Variables & Design System ===== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(18, 18, 30, 0.85);
  --bg-card-hover: rgba(24, 24, 40, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-input: rgba(255, 255, 255, 0.05);

  --text-primary: #f0f0f5;
  --text-secondary: #8a8a9a;
  --text-muted: #55556a;
  --text-accent: #818cf8;

  --accent-primary: #818cf8;
  --accent-secondary: #6366f1;
  --accent-glow: rgba(129, 140, 248, 0.15);
  --accent-gradient: linear-gradient(135deg, #818cf8 0%, #6366f1 50%, #4f46e5 100%);

  --success: #34d399;
  --success-glow: rgba(52, 211, 153, 0.15);
  --warning: #fbbf24;
  --error: #f87171;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(129, 140, 248, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(129, 140, 248, 0.1);

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ===== Animated Background ===== */
.bg-gradient {
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(129, 140, 248, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(79, 70, 229, 0.03) 0%, transparent 70%);
  z-index: 0;
  pointer-events: none;
}

.bg-noise {
  position: fixed;
  inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
  pointer-events: none;
}

.floating-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 20s infinite ease-in-out;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: rgba(99, 102, 241, 0.07);
  top: -100px;
  left: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 300px;
  height: 300px;
  background: rgba(129, 140, 248, 0.05);
  bottom: -50px;
  right: -50px;
  animation-delay: -7s;
}

.orb-3 {
  width: 250px;
  height: 250px;
  background: rgba(79, 70, 229, 0.06);
  top: 50%;
  left: 50%;
  animation-delay: -13s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(15px, 15px) scale(1.02); }
}

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.logo-text {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f0f0f5 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  background: var(--accent-gradient);
  color: white;
  border-radius: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  font-family: var(--font-main);
  position: relative;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.history-count {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  background: var(--accent-primary);
  color: white;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ===== Main ===== */
.main-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== Steps Bar ===== */
.steps-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
  padding: 16px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(10px);
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
}

.step.active {
  background: var(--accent-glow);
}

.step.active .step-number {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 0 15px rgba(129, 140, 248, 0.3);
}

.step.active .step-label {
  color: var(--accent-primary);
  font-weight: 600;
}

.step.completed .step-number {
  background: var(--success);
  color: white;
}

.step.completed .step-label {
  color: var(--success);
}

.step-number {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  transition: all var(--transition-normal);
}

.step-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--transition-normal);
}

.step-connector {
  width: 40px;
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
  margin: 0 4px;
  border-radius: 1px;
  transition: background var(--transition-normal);
}

.step-connector.active {
  background: var(--accent-primary);
}

/* ===== Content Grid ===== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
  .steps-bar {
    flex-wrap: wrap;
    gap: 4px;
  }
  .step-label {
    display: none;
  }
  .step-connector {
    width: 24px;
  }
}

/* ===== Panel ===== */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: 28px;
  backdrop-filter: blur(10px);
  transition: all var(--transition-normal);
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

.panel:hover {
  border-color: rgba(255, 255, 255, 0.08);
}

.panel-header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.panel-header h2 svg {
  color: var(--accent-primary);
}

.panel-desc {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  padding: 4px;
  cursor: pointer;
  transition: all var(--transition-normal);
  margin-bottom: 14px;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent-primary);
  background: var(--accent-glow);
}

.drop-zone:hover .drop-zone-inner,
.drop-zone.dragover .drop-zone-inner {
  background: rgba(129, 140, 248, 0.05);
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  border-radius: var(--radius-lg);
  transition: all var(--transition-normal);
  text-align: center;
}

.drop-icon {
  color: var(--text-muted);
  margin-bottom: 16px;
  transition: all var(--transition-normal);
}

.drop-zone:hover .drop-icon,
.drop-zone.dragover .drop-icon {
  color: var(--accent-primary);
  transform: translateY(-4px);
}

.drop-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.drop-subtext {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.drop-subtext strong {
  color: var(--accent-primary);
}

.drop-subtext kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
}

.drop-formats {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 20px;
}

/* ===== Camera Button ===== */
.camera-btn {
  background: var(--accent-gradient) !important;
  color: white !important;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.camera-btn:hover {
  box-shadow: 0 6px 25px rgba(99, 102, 241, 0.35);
  transform: translateY(-2px);
}

/* ===== Action Button ===== */
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  font-family: var(--font-main);
}

.action-btn:active {
  transform: scale(0.98);
}

.export-btn {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.export-btn:hover {
  box-shadow: 0 6px 25px rgba(16, 185, 129, 0.35);
  transform: translateY(-2px);
}

.reset-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.reset-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* ===== Preview ===== */
.preview-container {
  display: none;
  position: relative;
  margin-top: 16px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.3);
  aspect-ratio: 3/2;
}

.preview-container.visible {
  display: block;
  animation: fadeSlideIn 0.4s ease;
}

.preview-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.preview-close:hover {
  background: rgba(248, 113, 113, 0.8);
}

/* ===== MRZ Guide ===== */
.mrz-guide {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  background: rgba(129, 140, 248, 0.06);
  border: 1px solid rgba(129, 140, 248, 0.1);
  border-radius: var(--radius-md);
  margin-top: 16px;
}

.guide-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.guide-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.guide-text strong {
  color: var(--accent-primary);
}

.guide-text em {
  color: var(--text-primary);
  font-style: normal;
  font-weight: 600;
}

/* ===== Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px 20px;
}

.empty-icon {
  color: var(--text-muted);
  margin-bottom: 20px;
  opacity: 0.5;
  animation: pulse 3s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== Processing State ===== */
.processing-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 20px;
}

.processing-animation {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 24px;
}

.processing-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}

.scan-line {
  position: absolute;
  left: 10%;
  width: 80%;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--accent-primary) 50%, transparent 100%);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--accent-primary);
  animation: scanLine 2s infinite ease-in-out;
}

@keyframes scanLine {
  0% { top: 10%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 90%; opacity: 0; }
}

.progress-ring-container {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 20px;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 5;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 0.3s ease;
  filter: drop-shadow(0 0 6px rgba(129, 140, 248, 0.4));
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

.processing-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ===== Result State ===== */
.result-state {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeSlideIn 0.5s ease;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.result-badge {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #059669, #34d399);
  border-radius: 50%;
  color: white;
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.3);
}

.result-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--success);
}

.result-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Passport Card ===== */
.passport-card {
  background: linear-gradient(145deg, #1a1a2e 0%, #16162a 100%);
  border: 1px solid rgba(129, 140, 248, 0.15);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.passport-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: rgba(129, 140, 248, 0.08);
  border-bottom: 1px solid rgba(129, 140, 248, 0.1);
}

.passport-type {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent-primary);
}

.passport-country {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.passport-photo-area {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
}

.passport-photo {
  width: 80px;
  height: 100px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  overflow: hidden;
}

.passport-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.passport-info-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.passport-field label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.passport-field span {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.passport-field span.mono {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.passport-field-row {
  display: flex;
  gap: 12px;
}

.passport-field-row .passport-field {
  flex: 1;
  min-width: 0;
}

.passport-mrz {
  padding: 10px 20px 14px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== Edit Section ===== */
.edit-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.edit-section h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.edit-section h4 svg {
  color: var(--accent-primary);
}

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.edit-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.edit-field input,
.edit-field select {
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: var(--font-main);
  transition: all var(--transition-fast);
  outline: none;
}

.edit-field input:focus,
.edit-field select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.edit-field select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238a8a9a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.edit-field select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ===== Result Actions ===== */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

/* ===== Export Success ===== */
.export-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px 20px;
  animation: fadeSlideIn 0.5s ease;
}

.success-animation {
  margin-bottom: 24px;
}

.checkmark {
  width: 80px;
  height: 80px;
}

.checkmark-circle {
  stroke: var(--success);
  stroke-width: 2;
  stroke-dasharray: 157;
  stroke-dashoffset: 157;
  animation: circleAnim 0.6s ease forwards;
}

.checkmark-check {
  stroke: var(--success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: checkAnim 0.4s 0.5s ease forwards;
}

@keyframes circleAnim {
  to { stroke-dashoffset: 0; }
}

@keyframes checkAnim {
  to { stroke-dashoffset: 0; }
}

.export-success h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 8px;
}

.export-success p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== History Sidebar ===== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  transition: opacity var(--transition-normal);
}

.sidebar-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.history-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform var(--transition-slow);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
}

.history-sidebar.hidden {
  transform: translateX(100%);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.sidebar-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-close:hover {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
}

.empty-history {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-accent);
}

.history-item-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-glow);
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.history-item-info {
  flex: 1;
  min-width: 0;
}

.history-item-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.history-item-delete {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.history-item-delete:hover {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  animation: toastIn 0.4s ease, toastOut 0.4s ease 3s forwards;
  min-width: 280px;
  max-width: 400px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--accent-primary); }

.toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.toast-message {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

@keyframes toastIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100px); opacity: 0; }
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ===== Loading for export button ===== */
.action-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.action-btn.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .header-content {
    padding: 10px 16px;
  }

  .btn-label {
    display: none;
  }

  .main-container {
    padding: 12px;
  }

  .panel {
    padding: 20px;
    min-height: 400px;
  }

  .drop-zone-inner {
    padding: 30px 16px;
  }

  .edit-grid {
    grid-template-columns: 1fr;
  }

  .passport-photo-area {
    flex-direction: column;
    align-items: center;
  }

  .passport-photo {
    width: 100px;
    height: 120px;
  }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--error);
}
