:root {
  --bg: #f0f4fa;
  --surface: #ffffff;
  --border: #dce4ef;
  --text: #1a2843;
  --muted: #5a6e8a;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success-bg: #dcfce7;
  --success-fg: #166534;
  --success-border: #86efac;
  --danger-bg: #fee2e2;
  --danger-fg: #991b1b;
  --danger-border: #fca5a5;
  --warning-bg: #fef9c3;
  --warning-fg: #713f12;
  --step-line: #bcd3f5;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

body {
  margin: 0;
  background: linear-gradient(160deg, #e8effc 0%, #f0f4fa 60%);
  min-height: 100vh;
}

header.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 1px 6px rgba(30,60,120,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

header.site-header .logo-mark {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}

header.site-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

header.site-header p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 2px 14px rgba(20,50,100,0.07);
  padding: 1.35rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  text-align: center;
  box-shadow: 0 1px 4px rgba(20,50,100,0.05);
}

.stat-chip .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.stat-chip .stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hero-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.hero-sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.lookup-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.lookup-form input {
  font-size: 0.95rem;
  padding: 0.65rem 0.9rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  outline: none;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
}

.lookup-form input:focus {
  border-color: var(--primary);
  background: #fff;
}

.lookup-form button,
.btn {
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  padding: 0.65rem 1.2rem;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.lookup-form button:hover,
.btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 10px rgba(37,99,235,0.25);
}

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

.batch-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.batch-row input {
  flex: 1;
  font-size: 0.88rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--bg);
}

.scan-box {
  margin-top: 1rem;
  background: #f0f5ff;
  border: 1px dashed #a9c0f5;
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.scan-box a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

/* Authenticity banner */
.authenticity-banner {
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.1rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.authenticity-banner.green {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-fg);
}

.authenticity-banner.red {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-fg);
}

.authenticity-banner .auth-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.authenticity-banner .auth-text small {
  font-weight: 400;
  font-size: 0.82rem;
  opacity: 0.8;
  display: block;
}

.recall-alert {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  color: var(--danger-fg);
  font-size: 0.88rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.product-header {
  margin-bottom: 1rem;
}

.product-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 0.2rem;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.badge {
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e8f0fe;
  color: var(--primary);
  border: 1px solid #c7d9fb;
}

.badge.recalled { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-border); }
.badge.compromised { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge.active { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-border); }

section-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

/* Custody stepper */
.custody-stepper {
  position: relative;
  padding: 0;
  list-style: none;
  margin: 0;
}

.custody-step {
  display: flex;
  gap: 0.75rem;
  padding-bottom: 1.1rem;
  position: relative;
}

.custody-step:last-child {
  padding-bottom: 0;
}

.step-line-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 20px;
}

.step-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
  flex-shrink: 0;
  z-index: 1;
}

.step-dot.register { background: #7c3aed; box-shadow: 0 0 0 2px #7c3aed; }
.step-dot.transfer { background: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.step-dot.verify { background: #059669; box-shadow: 0 0 0 2px #059669; }
.step-dot.flag { background: #dc2626; box-shadow: 0 0 0 2px #dc2626; }

.step-connector {
  flex: 1;
  width: 2px;
  background: var(--step-line);
  margin: 2px 0;
}

.step-body {
  flex: 1;
  padding-top: 0;
}

.step-action {
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.role-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #e8f0fe;
  color: var(--primary);
  text-transform: uppercase;
}

.role-badge.manufacturer { background: #f3e8ff; color: #6d28d9; }
.role-badge.distributor { background: #dbeafe; color: #1e40af; }
.role-badge.retailer { background: #d1fae5; color: #065f46; }
.role-badge.consumer { background: #fef9c3; color: #713f12; }

.step-actor {
  font-size: 0.8rem;
  color: var(--muted);
}

.step-time {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* Batch results */
.batch-results {
  margin-top: 1rem;
}

.batch-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.batch-item:last-child { border-bottom: none; }

.dot-green { color: var(--success-fg); font-size: 1rem; }
.dot-red { color: var(--danger-fg); font-size: 1rem; }

.error { border-left: 4px solid #dc2626; }
.hidden { display: none; }

/* QR panel */
.qr-panel {
  margin-top: 1rem;
  padding: 1rem;
  background: #f0f5ff;
  border: 1px solid #c7d9fb;
  border-radius: 10px;
}

.qr-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.qr-panel-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
  margin: 0;
}

.qr-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}
.qr-close-btn:hover { background: #dce4ef; }

.qr-code-display {
  display: flex;
  justify-content: center;
  padding: 0.5rem;
}

.qr-code-display svg,
.qr-code-display img {
  width: 180px;
  height: 180px;
  border: 3px solid var(--primary);
  border-radius: 8px;
}

.qr-loading {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem;
}

.qr-panel-sub {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}
