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

:root {
  --bg-primary: #020617;
  --bg-secondary: #0a0f1a;
  --bg-surface: rgba(10, 15, 26, 0.85);
  --bg-surface-elevated: rgba(15, 23, 42, 0.9);

  --accent-cyan: #22d3ee;
  --accent-cyan-dim: #0891b2;
  --accent-green: #34d399;
  --accent-green-dim: #059669;
  --accent-amber: #fbbf24;
  --accent-red: #f87171;
  --accent-purple: #a78bfa;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-subtle: rgba(34, 211, 238, 0.12);
  --border-active: rgba(34, 211, 238, 0.4);
  --border-success: rgba(52, 211, 153, 0.4);

  --glow-cyan: rgba(34, 211, 238, 0.25);
  --glow-green: rgba(52, 211, 153, 0.25);
  --glow-amber: rgba(251, 191, 36, 0.2);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-glow: 0 0 30px var(--glow-cyan);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html, body {
  height: 100%;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(34, 211, 238, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(52, 211, 153, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.app-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

.header-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan-dim), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--glow-cyan);
}

.logo-icon img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
}

.logo-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.logo-title {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-subtitle {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--accent-cyan); }
  50% { opacity: 0.5; box-shadow: 0 0 4px var(--accent-cyan); }
}

.glass-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
}

.card {
  padding: 24px;
}

.card-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0;
}

.drop-zone {
  border: 2px dashed var(--border-active);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s var(--ease-out-expo);
  background: rgba(34, 211, 238, 0.03);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent-cyan);
  background: rgba(34, 211, 238, 0.08);
  box-shadow: var(--shadow-glow);
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.drop-zone-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  opacity: 0.6;
}

.drop-zone-text {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.drop-zone-hint {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.preview-container {
  display: none;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-active);
  box-shadow: var(--shadow-glow);
}

.preview-container.visible {
  display: block;
  animation: preview-enter 0.4s var(--ease-out-back);
}

@keyframes preview-enter {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.preview-container video,
.preview-container img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  display: block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan-dim) 0%, var(--accent-cyan) 100%);
  color: var(--bg-primary);
  font-weight: 700;
  box-shadow: 0 4px 20px var(--glow-cyan);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 30px var(--glow-cyan);
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-active);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-green-dim) 0%, var(--accent-green) 100%);
  color: var(--bg-primary);
  font-weight: 700;
  box-shadow: 0 4px 24px var(--glow-green);
}

.btn-success:hover:not(:disabled) {
  box-shadow: 0 6px 32px var(--glow-green);
  transform: translateY(-2px);
}

.btn-success:disabled {
  background: rgba(52, 211, 153, 0.2);
  color: var(--text-muted);
  box-shadow: none;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
}

.phases-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.phase-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.phase-item.active {
  background: rgba(34, 211, 238, 0.08);
  border-color: var(--border-active);
}

.phase-item.done {
  background: rgba(52, 211, 153, 0.06);
  border-color: var(--border-success);
}

.phase-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.phase-icon.pending {
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-muted);
  border: 1px solid rgba(100, 116, 139, 0.3);
}

.phase-icon.active {
  background: rgba(34, 211, 238, 0.15);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 0 12px var(--glow-cyan);
  animation: pulse-glow 1.5s ease-in-out infinite;
}

.phase-icon.done {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

.phase-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.phase-item.active .phase-label {
  color: var(--text-primary);
}

.phase-item.done .phase-label {
  color: var(--accent-green);
}

.phase-detail {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.frame-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
}

.frame-thumbnail {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.frame-info {
  padding: 12px;
}

.frame-timestamp {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  margin-bottom: 8px;
}

.object-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(34, 211, 238, 0.2);
}

.tag-warn {
  background: rgba(251, 191, 36, 0.12);
  color: var(--accent-amber);
  border-color: rgba(251, 191, 36, 0.2);
}

.tag-category {
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent-purple);
  border-color: rgba(167, 139, 250, 0.2);
}

.timeline-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 8px;
}

.timeline-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan-dim), var(--accent-cyan));
  border-radius: var(--radius-full);
  transition: width 0.5s var(--ease-out-expo);
  box-shadow: 0 0 8px var(--glow-cyan);
}

.hidden {
  display: none !important;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-cyan {
  background: rgba(34, 211, 238, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(34, 211, 238, 0.3);
}

.badge-green {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.badge-amber {
  background: rgba(251, 191, 36, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-red {
  background: rgba(248, 113, 113, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.badge-neutral {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
  border: 1px solid rgba(107, 114, 128, 0.3);
}

.badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.report-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.report-title {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.summary-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.key-moments {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.safety-warn {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--accent-amber);
  font-size: 13px;
}

.frames-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 768px) {
  .frames-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .frames-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Layout / Section ── */
.video-preview {
  display: block;
  margin-top: 16px;
}

/* ── Disabled Button ── */
.btn:disabled,
.btn-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Progress Wrapper ── */
.progress {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

/* ── Phase List ── */
.phase-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── [hidden] polyfill ── */
[hidden] { display: none !important; }

/* ── Page centering wrapper ── */
.page-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

main { flex: 1; }

/* ── Upload card ── */
.upload-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.upload-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border-active);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease, box-shadow 200ms ease;
  background: rgba(34, 211, 238, 0.04);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent-cyan);
  background: rgba(34, 211, 238, 0.08);
  box-shadow: inset 0 0 20px var(--glow-cyan);
}

.drop-zone-icon {
  color: var(--accent-cyan);
  margin-bottom: 12px;
}

/* ── Video preview ── */
#video-preview {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

#preview-video {
  width: 100%;
  max-height: 200px;
  display: block;
  border-radius: var(--radius-md);
}

.file-name-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  padding: 8px;
}

/* ── Primary button ── */
.btn-primary {
  width: 100%;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-cyan-dim), var(--accent-cyan));
  color: var(--bg-primary);
  border: none;
  cursor: pointer;
  transition: opacity 200ms ease, transform 150ms ease, box-shadow 200ms ease;
  box-shadow: 0 0 20px var(--glow-cyan);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
  box-shadow: 0 0 30px var(--glow-cyan);
}

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

/* ── Phase list ── */
.phase-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: color 200ms ease;
}

.phase-item.done { color: var(--accent-green); }
.phase-item.active { color: var(--accent-cyan); }

.phase-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.phase-icon.done {
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
}

.phase-icon.active {
  background: rgba(34, 211, 238, 0.15);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  animation: pulse-glow 1.5s ease-in-out infinite;
}

.phase-icon.pending {
  background: rgba(100, 116, 139, 0.1);
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
}

.phase-detail-text {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}

/* Relatório page */
.report-wrapper {
  padding: 24px 16px;
  width: 100%;
}

.report-card {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.report-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  backdrop-filter: blur(20px);
}

.report-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.meta-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.3);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.badge-neutral {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
  border-color: rgba(107, 114, 128, 0.3);
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* Summary */
.summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px 32px;
  backdrop-filter: blur(20px);
}

.summary-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* Loading / error states */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px;
  color: var(--text-secondary);
}

.error-state {
  padding: 20px 24px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-lg);
  color: var(--accent-red);
  font-size: 14px;
}

.preview-video { width: 100%; max-height: 200px; display: block; border-radius: var(--radius-md); }
.file-name { font-size: 13px; color: var(--text-secondary); text-align: center; padding: 8px; }
.submit-btn { display: block; }
.video-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.frame-count { font-size: 12px; color: var(--text-secondary); }
.frames-section { }
.report-timeline { margin-top: 12px; }
.error-message { }

@media (max-width: 480px) {
  .upload-card { padding: 24px 16px !important; }
  .drop-zone { padding: 24px 16px !important; }
  .drop-zone-icon svg { width: 32px; height: 32px; }
  .report-header { padding: 20px 16px !important; }
  .report-card { gap: 16px; }
}
