:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

html,
body {
  min-height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, #0f172a 0%, #14532d 120%);
  color: var(--text);
}

body {
  padding: 1rem;
  padding-bottom: 5rem;
}

.container {
  max-width: 480px;
  margin: 0 auto;
}

.brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.brand h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.card {
  background: rgba(30, 41, 59, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input,
button,
select {
  font: inherit;
}

input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--surface-2);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.85rem;
}

input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #052e16;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  width: auto;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
}

.field-group {
  margin-bottom: 0.25rem;
}

.hidden {
  display: none !important;
}

.alert {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.alert-success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}

.alert-info {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #bfdbfe;
}

.alert-warn {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

.steps {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.step-dot {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}

.step-dot.active {
  background: var(--accent);
}

.step-dot.done {
  background: #4ade80;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-awaiting_face { background: #713f12; color: #fde68a; }
.status-active { background: #14532d; color: #bbf7d0; }
.status-checkout { background: #1e3a8a; color: #bfdbfe; }
.status-paid { background: #065f46; color: #6ee7b7; }
.status-exit_pending { background: #581c87; color: #e9d5ff; }
.status-exited { background: #374151; color: #d1d5db; }

.cart-list {
  list-style: none;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

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

.cart-item .name {
  font-weight: 600;
  font-size: 0.95rem;
}

.cart-item .meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  font-size: 1.15rem;
  font-weight: 800;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.scan-area {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4/3;
  margin-bottom: 0.75rem;
}

.scan-area video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-overlay {
  position: absolute;
  inset: 20% 10%;
  border: 2px dashed rgba(34, 197, 94, 0.8);
  border-radius: 8px;
  pointer-events: none;
}

.toolbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  padding: 0.75rem 1rem;
  backdrop-filter: blur(8px);
}

.toolbar .container {
  display: flex;
  gap: 0.5rem;
}

.toolbar .btn {
  flex: 1;
}

.user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.user-bar strong {
  color: var(--text);
}

.link {
  color: var(--accent);
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.token-display {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  word-break: break-all;
  background: var(--bg);
  padding: 0.5rem;
  border-radius: 8px;
  color: var(--muted);
}

.otp-display {
  text-align: center;
  background: var(--bg);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  margin-bottom: 1rem;
}

.otp-display-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.otp-display-code {
  font-family: ui-monospace, monospace;
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.otp-display-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 600px) {
  body { padding: 2rem; }
}
