:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #22c55e;
  --green-bg: #0c2f1c;
  --red: #ef4444;
  --red-bg: #3a1212;
  --amber: #f59e0b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.topbar h1 { font-size: 1.25rem; margin: 0; }

.pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.pill--idle { color: var(--muted); }
.pill--scanning { color: #fff; background: var(--primary); border-color: var(--primary); }
.pill--loading { color: #fff; background: var(--amber); border-color: var(--amber); }

.scanner-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
}
#reader { width: 100%; height: 100%; }
#reader video { width: 100% !important; height: 100% !important; object-fit: cover; }

.scan-hint {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text);
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  text-align: center;
}

.controls {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  flex-wrap: wrap;
}

.btn {
  flex: 1 1 auto;
  min-height: 48px;
  padding: 0 16px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); }

.select {
  flex: 1 1 100%;
  min-height: 48px;
  padding: 0 12px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
}
.select:empty { display: none; }

.result {
  margin-top: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.result.hidden, .hidden { display: none; }

.result-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  font-size: 1.15rem;
  font-weight: 700;
}
.result-icon { font-size: 1.6rem; line-height: 1; }
.result--paid .result-banner { background: var(--green-bg); color: var(--green); }
.result--unpaid .result-banner { background: var(--red-bg); color: var(--red); }
.result--unknown .result-banner { background: #2a2410; color: var(--amber); }
.result--loading .result-banner { color: var(--amber); }
.result--error .result-banner { background: var(--red-bg); color: var(--red); }

.result-grid {
  margin: 0;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.result-grid .full { grid-column: 1 / -1; }
.result-grid dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}
.result-grid dd { margin: 0; font-size: 1.05rem; font-weight: 600; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; font-size: 0.9rem; }

#next-btn { margin: 0 20px 20px; width: calc(100% - 40px); }

.error {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 12px;
  font-size: 0.9rem;
}
