:root {
  --primary: #1e3a5f;
  --primary-light: #2a4f7c;
  --accent: #e63946;
  --success: #2d6a4f;
  --bg: #f5f7fa;
  --white: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
}

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Nav */
nav {
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
nav .logo { font-weight: 700; font-size: 1.1rem; flex: 1; }
nav a { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.9rem; padding: 6px 10px; border-radius: 6px; }
nav a:hover, nav a.active { background: rgba(255,255,255,0.15); color: #fff; }

/* Container */
.container { max-width: 640px; margin: 0 auto; padding: 20px 16px; }

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-full { width: 100%; }
.btn-lg { padding: 16px 24px; font-size: 1.1rem; }

/* Forms */
label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
  background: var(--white);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.form-group { margin-bottom: 16px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1a1a2e;
  color: #fff;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 500;
  z-index: 100;
  transition: transform 0.3s ease;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--accent); }

/* Badge */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e8f4fd;
  color: var(--primary);
}

/* Scan item row */
.scan-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.scan-row:last-child { border-bottom: none; }
.scan-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #e8f4fd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.scan-info { flex: 1; min-width: 0; }
.scan-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* QR section */
.qr-box {
  text-align: center;
  padding: 24px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-top: 20px;
}
.qr-box canvas { border-radius: 8px; }
.qr-label { margin-top: 12px; font-weight: 700; font-size: 1.1rem; }
.qr-sub { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

/* Video scanner */
#video-container {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 1;
  max-width: 400px;
  margin: 0 auto;
}
#video { width: 100%; height: 100%; object-fit: cover; }
#canvas { display: none; }
.scan-line {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 2px;
  background: rgba(230, 57, 70, 0.8);
  animation: scan-anim 2s ease-in-out infinite;
}
@keyframes scan-anim {
  0%, 100% { top: 20%; }
  50% { top: 80%; }
}
.corner {
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: #fff;
  border-style: solid;
}
.corner.tl { top: 12px; left: 12px; border-width: 3px 0 0 3px; }
.corner.tr { top: 12px; right: 12px; border-width: 3px 3px 0 0; }
.corner.bl { bottom: 12px; left: 12px; border-width: 0 0 3px 3px; }
.corner.br { bottom: 12px; right: 12px; border-width: 0 3px 3px 0; }

/* Status chip */
.status-success {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #d1fae5;
  color: #065f46;
  padding: 8px 16px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.9rem;
}
.status-error {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fee2e2;
  color: #991b1b;
  padding: 8px 16px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.9rem;
}

h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
p.sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 20px; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 0.95rem; }

@media print {
  nav, .no-print { display: none !important; }
  body { background: #fff; }
  .qr-box { border: 1px solid #ccc; }
}
