:root {
  --pass-bg: #ecfdf5;
  --pass-border: #10b981;
  --pass-text: #065f46;
  --fail-bg: #fef2f2;
  --fail-border: #ef4444;
  --fail-text: #991b1b;
  --neutral-bg: #f8fafc;
  --neutral-border: #94a3b8;
  --brand: #0f766e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Thai', sans-serif;
  background: #0b1220;
  color: #0f172a;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  background: linear-gradient(135deg, #0f766e, #115e59);
  color: #fff;
  padding: 1rem 1rem 0.85rem;
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  opacity: 0.9;
}

.app-main {
  padding: 0.75rem;
  max-width: 480px;
  margin: 0 auto;
}

.scan-section {
  background: #111827;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid #1f2937;
}

.reader-wrap {
  width: 100%;
  min-height: 280px;
}

.reader-wrap video {
  object-fit: cover !important;
}

.scan-hint {
  margin: 0;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
  color: #9ca3af;
  text-align: center;
  background: #111827;
}

.manual-section {
  margin-top: 0.75rem;
  background: #fff;
  border-radius: 0.85rem;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
}

.manual-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.manual-row {
  display: flex;
  gap: 0.5rem;
}

.manual-input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.6rem;
  font-size: 0.85rem;
  font-family: ui-monospace, monospace;
}

.btn {
  border: none;
  border-radius: 0.6rem;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}

.btn-block {
  width: 100%;
  margin-top: 0.75rem;
}

.result-section {
  margin-top: 0.75rem;
}

.result-section.hidden {
  display: none;
}

.result-card {
  border-radius: 1rem;
  padding: 1rem;
  border: 2px solid var(--neutral-border);
  background: var(--neutral-bg);
}

.result-card.pass {
  background: var(--pass-bg);
  border-color: var(--pass-border);
}

.result-card.fail {
  background: var(--fail-bg);
  border-color: var(--fail-border);
}

.result-card.notfound {
  background: #fff7ed;
  border-color: #fb923c;
}

.qc-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.qc-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.qc-value {
  font-size: 1.35rem;
  font-weight: 800;
}

.result-card.pass .qc-value { color: var(--pass-text); }
.result-card.fail .qc-value { color: var(--fail-text); }

.qc-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.card-code {
  font-family: ui-monospace, monospace;
  font-size: 0.95rem;
  font-weight: 700;
  word-break: break-all;
  margin-bottom: 0.75rem;
}

.card-grid {
  display: grid;
  gap: 0.6rem;
}

.card-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.card-row .k {
  color: #64748b;
  flex-shrink: 0;
}

.card-row .v {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.status-section {
  margin-top: 0.75rem;
  text-align: center;
}

.status-text {
  margin: 0;
  font-size: 0.75rem;
  color: #94a3b8;
}

.status-text.error { color: #f87171; }

.scan-section.paused {
  opacity: 0.45;
  pointer-events: none;
}
