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

:root {
  --primary: #1a73e8;
  --positive: #0d904f;
  --negative: #d32f2f;
  --unknown: #f9a825;
  --bg: #f0f2f5;
  --card: #fff;
  --text: #333;
  --text-light: #888;
  --border: #e0e0e0;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-overflow-scrolling: touch;
}

html {
  height: -webkit-fill-available;
}

/* Header */
.header {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 { font-size: 18px; font-weight: 600; }
.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.header-user .name { opacity: 0.9; }
.btn-logout {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

/* Header - iOS safe area */
.header {
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

/* Bottom Navigation */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  font-size: 11px;
  color: var(--text-light);
  cursor: pointer;
  transition: color 0.2s;
  border: none;
  background: none;
}
.nav-item.active { color: var(--primary); }
.nav-item .icon { font-size: 22px; margin-bottom: 2px; }

/* Tab Content */
.tab { display: none; padding: 16px; }
.tab.active { display: block; }

/* Scanner Tab */
#scanner-container {
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  margin-bottom: 16px;
  position: relative;
}
#scanner-container video {
  width: 100%;
  display: block;
  filter: grayscale(100%) contrast(1.6) brightness(1.1);
}

/* Kamera-Flash Overlay (innerhalb Scanner-Container) */
.camera-flash {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 10;
  animation: cameraFlash 0.8s ease-out forwards;
}
.camera-flash.positive {
  background: radial-gradient(circle, rgba(13,144,79,0.7) 0%, rgba(13,144,79,0.3) 60%, transparent 100%);
  box-shadow: inset 0 0 60px rgba(13,144,79,0.5);
}
.camera-flash.negative {
  background: radial-gradient(circle, rgba(211,47,47,0.7) 0%, rgba(211,47,47,0.3) 60%, transparent 100%);
  box-shadow: inset 0 0 60px rgba(211,47,47,0.5);
}
.camera-flash.unknown {
  background: radial-gradient(circle, rgba(249,168,37,0.6) 0%, rgba(249,168,37,0.2) 60%, transparent 100%);
  box-shadow: inset 0 0 60px rgba(249,168,37,0.4);
}
@keyframes cameraFlash {
  0% { opacity: 1; }
  40% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* Erkennungs-Label im Kamera-View */
.camera-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 16px 28px;
  border-radius: 16px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  z-index: 11;
  pointer-events: none;
  animation: cameraLabelPop 0.8s ease-out forwards;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.camera-label.positive { background: rgba(13,144,79,0.9); color: #fff; }
.camera-label.negative { background: rgba(211,47,47,0.9); color: #fff; }
.camera-label.unknown { background: rgba(249,168,37,0.9); color: #fff; }
.camera-label .label-code { font-size: 14px; font-weight: 400; opacity: 0.9; margin-top: 4px; }
@keyframes cameraLabelPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  30% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

.scan-result {
  padding: 20px;
  border-radius: var(--radius);
  text-align: center;
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 16px;
  display: none;
  animation: fadeIn 0.3s;
}
.scan-result.positive { background: #e8f5e9; color: var(--positive); border: 2px solid var(--positive); }
.scan-result.negative { background: #ffebee; color: var(--negative); border: 2px solid var(--negative); }
.scan-result.unknown { background: #fff8e1; color: #f57f17; border: 2px solid var(--unknown); }
.scan-result .status-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.scan-result .article-info { font-size: 14px; font-weight: 400; margin-top: 8px; color: var(--text); }

.recent-scans h3 {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Cards & Lists */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text-light); }
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.positive { background: #e8f5e9; color: var(--positive); }
.badge.negative { background: #ffebee; color: var(--negative); }
.badge.unknown { background: #fff8e1; color: #f57f17; }

/* Buttons */
.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--negative); color: #fff; }
.btn-outline {
  background: none;
  border: 2px solid var(--border);
  color: var(--text);
}
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
  font-weight: 500;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  background: var(--card);
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn { flex: 1; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stat-number {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label { font-size: 12px; color: var(--text-light); text-transform: uppercase; }
.stat-card.positive .stat-number { color: var(--positive); }
.stat-card.negative .stat-number { color: var(--negative); }

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  flex: 1;
  min-width: 120px;
  background: var(--card);
}

/* Action Buttons in List */
.action-btns {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.action-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  background: var(--card);
}
.action-btn.delete { color: var(--negative); border-color: var(--negative); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.flash-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 150;
  pointer-events: none;
  animation: flash 0.6s ease-out;
}
.flash-overlay.positive { background: rgba(13, 144, 79, 0.3); }
.flash-overlay.negative { background: rgba(211, 47, 47, 0.3); }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* Scan item in recent list */
.scan-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border-radius: 10px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.scan-item .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.scan-item .dot.positive { background: var(--positive); }
.scan-item .dot.negative { background: var(--negative); }
.scan-item .dot.unknown { background: var(--unknown); }
.scan-item .info { flex: 1; }
.scan-item .info .number { font-weight: 600; font-size: 14px; }
.scan-item .info .time { font-size: 11px; color: var(--text-light); }

/* Sorted out label */
.sorted-out-label {
  background: var(--negative);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

/* User table */
.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.user-item .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
}
.user-item .role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e3f2fd;
  color: var(--primary);
}
.user-item .role-badge.admin { background: #fce4ec; color: var(--negative); }
.user-item.inactive { opacity: 0.5; }

/* Scanner Actions */
.scanner-actions {
  margin: 10px 0;
}

/* OCR Result */
.ocr-result {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  animation: fadeIn 0.3s;
}
.ocr-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.ocr-text {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 150px;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', monospace;
  margin-bottom: 10px;
}
.ocr-extracted {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ocr-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}
.ocr-tag:active { opacity: 0.7; }
.ocr-tag.article { background: #e3f2fd; color: var(--primary); }
.ocr-tag.ean { background: #f3e5f5; color: #7b1fa2; }
.ocr-tag.number { background: #e8f5e9; color: var(--positive); }

/* OCR Loading */
.ocr-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  color: var(--text-light);
  font-size: 14px;
}
.ocr-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
