:root {
  --bg: #0a0d12;
  --surface: #121820;
  --surface2: #1a2433;
  --border: #2a3548;
  --text: #eef2f8;
  --muted: #8b97ab;
  --accent: #5b9cff;
  --accent-dim: #3b6fd4;
  --gold: #d4af37;
  --gold-light: #f0dfa8;
  --gold-dim: #9a7b2c;
  --success: #34d399;
  --warn: #fbbf24;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.04) 0%, transparent 100%);
}

/* C3V brand */
.c3v-brand {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex: 1;
  min-width: 200px;
}
.c3v-brand--center {
  flex-direction: column;
  text-align: center;
  margin-bottom: 0.5rem;
}
.c3v-brand-logo {
  flex-shrink: 0;
  border-radius: 18px;
  display: block;
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.25),
    0 8px 28px rgba(0, 0, 0, 0.5),
    0 0 36px rgba(201, 162, 39, 0.15);
}
.c3v-brand-text { min-width: 0; }
.c3v-wordmark {
  font-weight: 800;
  letter-spacing: -0.08em;
  line-height: 1;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.c3v-brand--center .c3v-wordmark { font-size: 2rem; display: block; }
.c3v-tag {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-light);
  opacity: 0.9;
}
.c3v-header-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.6rem;
  margin: 0;
  line-height: 1.2;
}
.c3v-header-line .c3v-wordmark { font-size: 1.55rem; }
.brand-sub {
  font-weight: 500;
  color: var(--muted);
  font-size: 1.05rem;
}
.c3v-tagline {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.35rem;
  line-height: 1.5;
}
.c3v-kbd {
  display: inline-block;
  padding: 0.12em 0.45em;
  margin: 0 0.1em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gold-light);
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.user-pill {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  background: var(--surface2);
  border-radius: 999px;
  border: 1px solid var(--border);
}
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.85rem; }

/* Auth pages */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(201, 162, 39, 0.08) 0%, transparent 50%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}
.auth-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.auth-sub {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
}
.auth-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  margin-top: 0.75rem;
}
.auth-form label:first-of-type { margin-top: 0; }
.auth-form input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  font-family: inherit;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.auth-submit { width: 100%; margin-top: 1.25rem; }
.auth-error {
  color: #f87171;
  font-size: 0.88rem;
  margin-top: 0.75rem;
}
.auth-footer-link {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.auth-footer-link a { color: var(--accent); text-decoration: none; }
.auth-footer-link a:hover { text-decoration: underline; }

.logo-wrap {
  flex-shrink: 0;
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  overflow: hidden;
  text-decoration: none;
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.22),
    0 8px 28px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(201, 162, 39, 0.12);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.logo-wrap:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow:
    0 0 0 1px rgba(240, 223, 168, 0.35),
    0 12px 32px rgba(0, 0, 0, 0.6),
    0 0 48px rgba(201, 162, 39, 0.2);
}
.logo-svg {
  display: block;
  width: 64px;
  height: 64px;
}

.brand-text { min-width: 0; }
.header h1 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.65rem;
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.logo-title {
  font-weight: 800;
  letter-spacing: -0.06em;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 45%, var(--gold-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub {
  font-weight: 500;
  color: var(--muted);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.tagline {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.35rem;
  line-height: 1.45;
}
.tagline-mark {
  color: var(--gold-light);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.72rem;
}
.tagline-sep { margin: 0 0.35rem; opacity: 0.35; }

.session-banner {
  background: rgba(61, 139, 253, 0.12);
  border: 1px solid rgba(61, 139, 253, 0.35);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  color: #bfdbfe;
  margin-bottom: 1rem;
}

.footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.footer-logo {
  border-radius: 6px;
  opacity: 0.95;
  box-shadow: 0 0 12px rgba(201, 162, 39, 0.15);
}
.footer-mark {
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.footer-copy { color: var(--muted); }

.progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.progress-top h2 { margin-bottom: 0; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn.danger {
  background: #dc2626;
  color: #fff;
}
.btn.danger:hover:not(:disabled) { background: #b91c1c; }

.main { display: flex; flex-direction: column; gap: 1.25rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.panel h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.hint code {
  background: var(--surface2);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

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

textarea, input[type="number"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
}

textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(61, 139, 253, 0.2);
}

textarea { resize: vertical; min-height: 140px; margin-bottom: 1rem; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
}

.field { flex: 0 0 140px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, #4a7fd4 0%, #3b5fb8 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(59, 111, 212, 0.35);
}
.btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #5b8fe8 0%, #4468c9 100%);
  box-shadow: 0 4px 16px rgba(59, 111, 212, 0.45);
}
.btn.secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover:not(:disabled) { border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }

.formats-details { margin-top: 1.25rem; font-size: 0.85rem; color: var(--muted); }
.formats-details summary { cursor: pointer; color: var(--accent); }
.formats-list {
  margin-top: 0.5rem;
  padding-left: 1.25rem;
  columns: 2;
  gap: 0.25rem;
}

.hidden { display: none !important; }

.progress-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  transition: width 0.4s ease;
}

.progress-message { font-size: 1rem; }
.progress-meta { color: var(--muted); font-size: 0.85rem; margin-top: 0.35rem; }
.leads-live { margin-top: 0.75rem; font-size: 0.95rem; }
.leads-live strong { color: var(--success); }

.results-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.download-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.error-msg {
  color: #f87171;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.table-wrap {
  overflow: auto;
  max-height: 65vh;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1b4f72;
}

th, td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th { color: #fff; font-weight: 600; }
tbody tr:hover { background: var(--surface2); }

.score-high { background: rgba(52, 211, 153, 0.12); }
.score-mid { background: rgba(251, 191, 36, 0.08); }
.score-low { background: rgba(248, 113, 113, 0.08); }

td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .formats-list { columns: 1; }
  .row { flex-direction: column; align-items: stretch; }
  .field { flex: 1; }
}
