@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;650&display=swap");

:root {
  --bg: #080a0f;
  --bg-elevated: #0e1118;
  --surface: #131720;
  --surface2: #1a2030;
  --surface-hover: #222a3d;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef0f4;
  --muted: #9aa3b2;
  --dim: #6b7280;
  --accent: #7c9cff;
  --accent-dim: rgba(124, 156, 255, 0.14);
  --green: #6bcb8f;
  --green-dim: rgba(107, 203, 143, 0.12);
  --yellow: #e8b949;
  --yellow-dim: rgba(232, 185, 73, 0.12);
  --red: #f08080;
  --red-dim: rgba(240, 128, 128, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 60% at 50% -30%, rgba(124, 156, 255, 0.1), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 80%, rgba(107, 203, 143, 0.05), transparent);
  pointer-events: none;
  z-index: -1;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.95rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}

button:hover,
a.btn:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.18);
}

button:active {
  transform: scale(0.98);
}

button.danger {
  background: var(--red-dim);
  border-color: rgba(240, 128, 128, 0.35);
  color: var(--red);
}

button.danger:hover {
  background: rgba(240, 128, 128, 0.18);
}

button.primary,
button[type="submit"] {
  background: linear-gradient(180deg, #5c7cff 0%, #4a68e8 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(74, 104, 232, 0.35);
}

button.primary:hover,
button[type="submit"]:hover {
  background: linear-gradient(180deg, #6e8aff 0%, #5572f0 100%);
}

button[type="submit"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="search"],
input[type="date"],
select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  width: 100%;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(124, 156, 255, 0.55);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.section-label {
  font-size: 0.6875rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-pill.live {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(107, 203, 143, 0.3);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 0.75rem;
}

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.empty-state-icon {
  font-size: 2rem;
  opacity: 0.4;
  margin-bottom: 0.75rem;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.85rem;
  min-width: 5.5rem;
}

.stat-pill .val {
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-pill .lbl {
  font-size: 0.6875rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-pill.warn .val { color: var(--yellow); }
.stat-pill.danger .val { color: var(--red); }

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 1rem 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent) 0%, #4a68e8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  box-shadow: 0 4px 16px rgba(74, 104, 232, 0.4);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand .sub {
  color: var(--muted);
  font-size: 0.8125rem;
  margin-top: 0.15rem;
}

.header-stats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.view-fade {
  animation: fadeUp 0.35s var(--ease) both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Capture page ── */
.capture-page video,
.capture-page canvas {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  z-index: -9999 !important;
  visibility: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
}

.capture-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.capture-card {
  background: rgba(19, 23, 32, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 2rem 1.75rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.capture-card h1 {
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: 0.45rem;
}

.capture-card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.reward-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--green-dim);
  color: #a8e6bc;
  border: 1px solid rgba(107, 203, 143, 0.25);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.reward-badge::before {
  content: none;
}

.status-block {
  margin-top: 1.5rem;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  flex-shrink: 0;
  animation: pulse 1.4s ease-in-out infinite;
}

.status-dot.ok {
  background: var(--green);
  animation: none;
  box-shadow: 0 0 8px rgba(107, 203, 143, 0.5);
}

.status-dot.err {
  background: var(--red);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.92); }
}

.progress-track {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, var(--accent), #4a68e8);
  border-radius: 999px;
  animation: progress 1.8s ease-in-out infinite;
}

@keyframes progress {
  0% { width: 8%; margin-left: 0; }
  50% { width: 55%; margin-left: 22%; }
  100% { width: 8%; margin-left: 92%; }
}

.progress-fill.done {
  width: 100%;
  margin-left: 0;
  animation: none;
  background: var(--green);
}

.success-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--green-dim);
  border: 2px solid rgba(107, 203, 143, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--green);
  animation: popIn 0.4s var(--ease) both;
}

@keyframes popIn {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.capture-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

.capture-form {
  margin-top: 1.25rem;
  display: grid;
  gap: 0.85rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn-secondary {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-secondary[hidden] {
  display: none;
}

.trust-line {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--dim);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.center { text-align: center; }

.hidden-view[hidden] { display: none !important; }

@media (max-width: 900px) {
  .app-header {
    grid-template-columns: 1fr;
  }
  .header-stats {
    width: 100%;
  }
  .actions {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
  .capture-card { padding: 1.5rem 1.25rem; }
}
