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

/* ─── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg:          #0a0a0a;
  --bg-card:     #111111;
  --bg-card-alt: #161616;
  --border:      #1e1e1e;
  --border-mid:  #2a2a2a;
  --text:        #e8e8e8;
  --text-muted:  #666;
  --text-dim:    #444;
  --accent:      #5b8def;
  --accent-glow: rgba(91, 141, 239, 0.15);
  --accent-dark: #3b6dcf;
  --green:       #3ecf8e;
  --green-dim:   rgba(62, 207, 142, 0.12);
  --amber:       #f5a623;
  --amber-dim:   rgba(245, 166, 35, 0.12);
  --purple:      #9b7fe8;
  --purple-dim:  rgba(155, 127, 232, 0.12);
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
  --font-sans:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  --max-w:       800px;
}

/* ─── Base ───────────────────────────────────────────────────── */
html { font-size: 16px; -webkit-font-smoothing: antialiased; }

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

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

/* ─── App Shell ──────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────── */
.header {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-icon {
  font-size: 18px;
  color: var(--accent);
}

.logo-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ─── Main ───────────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Hero ───────────────────────────────────────────────────── */
.hero { margin-bottom: 8px; }

.hero-title {
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 12px;
}

.hero-sub {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 520px;
}

/* ─── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ─── Form ───────────────────────────────────────────────────── */
.form-card { padding: 28px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-field { display: flex; flex-direction: column; }
.form-field.full { grid-column: 1 / -1; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

.textarea, .select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}

.textarea {
  resize: vertical;
  line-height: 1.6;
}

.textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.select option { background: var(--bg-card); }

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  white-space: nowrap;
  font-family: var(--font-sans);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-mid);
}
.btn-ghost:hover {
  background: var(--bg-card-alt);
  color: var(--text);
}

.btn-scan {
  padding: 12px 28px;
  font-size: 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #7c5cbf);
  color: #fff;
}
.btn-scan:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-icon { font-size: 16px; }

.btn-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ─── Loading / Scan Animation ───────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 64px 24px;
}

.scan-animation {
  position: relative;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--accent);
  opacity: 0.5;
  animation: scan-pulse 1.8s ease-out infinite;
}

.scan-ring-2 {
  animation-delay: 0.9s;
}

@keyframes scan-pulse {
  0%   { transform: scale(0.6); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

.scan-icon {
  font-size: 24px;
  color: var(--accent);
  z-index: 1;
  animation: scan-icon-pulse 1.8s ease-in-out infinite;
}

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

.loading-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.loading-text span:first-child {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.loading-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── Results Header ─────────────────────────────────────────── */
.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.results-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.results-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.results-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-top: 4px;
}

/* ─── Summary Badges ─────────────────────────────────────────── */
.summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

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

.badge-green {
  background: var(--green-dim);
  border-color: rgba(62, 207, 142, 0.2);
  color: var(--green);
}

.badge-amber {
  background: var(--amber-dim);
  border-color: rgba(245, 166, 35, 0.2);
  color: var(--amber);
}

.badge-purple {
  background: var(--purple-dim);
  border-color: rgba(155, 127, 232, 0.2);
  color: var(--purple);
}

.badge-blue {
  background: var(--accent-glow);
  border-color: rgba(91, 141, 239, 0.25);
  color: var(--accent);
}

/* ─── Tier Sections ──────────────────────────────────────────── */
.tier-section { margin-bottom: 8px; }

.tier-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.tier-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.tier-quick .tier-dot { background: var(--green); }
.tier-strategic .tier-dot { background: var(--purple); }

/* ─── Opportunity Cards ──────────────────────────────────────── */
.opportunity-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.opp-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color 0.15s;
}

.opp-card:hover { border-color: var(--border-mid); }

.opp-card.quick-win {
  border-left: 3px solid var(--green);
}

.opp-card.strategic-bet {
  border-left: 3px solid var(--purple);
}

.opp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.opp-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.opp-category {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 3px;
}

.opp-rank {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dim);
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}

.opp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.opp-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.opp-pill .pill-label {
  color: var(--text-dim);
  font-size: 10px;
}

.opp-description {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 10px;
}

.opp-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tool-tag {
  font-size: 11px;
  padding: 2px 7px;
  background: var(--accent-glow);
  border: 1px solid rgba(91, 141, 239, 0.2);
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--font-mono);
}

/* ─── Full Brief ─────────────────────────────────────────────── */
.full-brief-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ─── Output Content (markdown) ──────────────────────────────── */
.output-content {
  font-size: 14px;
  line-height: 1.8;
}

.output-content h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
  letter-spacing: -0.02em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.output-content h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 20px 0 8px;
}

.output-content p { color: var(--text); margin-bottom: 10px; }

.output-content ul, .output-content ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.output-content li { color: var(--text); margin-bottom: 4px; }

.output-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 13px;
}

.output-content th {
  background: var(--bg-card-alt);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.output-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.output-content tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}

.output-content strong { color: var(--text); font-weight: 600; }

.output-content code {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}

/* ─── Output Footer ──────────────────────────────────────────── */
.output-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

/* ─── Footer ─────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--text); }

/* ─── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .main { padding: 32px 16px 48px; }
  .form-grid { grid-template-columns: 1fr; }
  .results-header { flex-direction: column; gap: 12px; }
  .results-actions { width: 100%; }
  .output-footer { flex-direction: column; align-items: flex-start; }
}
