:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #2a2e38;
  --text: #e6e8ec;
  --muted: #9aa1ac;
  --accent: #5b8def;
  --success: #3fbf7f;
  --error: #e55b5b;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  padding: 2rem 1.5rem 1rem;
  max-width: 900px;
  margin: 0 auto;
}

h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
.subtitle { color: var(--muted); margin: 0; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

h2 { margin-top: 0; font-size: 1.2rem; }
h3 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.field { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 140px; }

label { font-size: 0.9rem; color: var(--muted); }

input, textarea, select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font-family: inherit;
  font-size: 0.95rem;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.hint { margin: 0; font-size: 0.78rem; color: var(--muted); }

.source-guidance {
  margin-top: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.82rem;
  color: var(--muted);
}

.source-guidance p { margin: 0 0 0.3rem; }
.source-guidance p:last-of-type { margin-bottom: 0.3rem; }
.source-guidance ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }

.actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }

button {
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--accent);
  color: white;
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button:disabled { opacity: 0.6; cursor: not-allowed; }

#status-section p { margin: 0; }
#status-section.loading { border-color: var(--accent); }
#status-section.error { border-color: var(--error); color: var(--error); }
#status-section.success { border-color: var(--success); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0 0 1.25rem;
}

.summary-grid dt { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }
.summary-grid dd { margin: 0.15rem 0 0; font-size: 1.1rem; }

.download-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.download-bar span { color: var(--muted); }
.download-bar a { color: var(--accent); text-decoration: none; }
.download-bar a:hover { text-decoration: underline; }

.opportunities-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }

.opportunity-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.opportunity-card .score {
  font-weight: 600;
  color: var(--accent);
}

.opportunity-card .headline { font-size: 1rem; margin: 0.25rem 0 0.5rem; }
.opportunity-card ul { margin: 0.4rem 0; padding-left: 1.2rem; color: var(--muted); font-size: 0.9rem; }
.opportunity-card .cta-offer { font-size: 0.85rem; color: var(--text); margin-bottom: 0.35rem; }
.opportunity-card .meta { font-size: 0.8rem; color: var(--muted); word-break: break-all; }

.opportunity-card .recurrence { font-size: 0.78rem; margin-top: 0.35rem; }
.opportunity-card .recurrence.new { color: var(--muted); }
.opportunity-card .recurrence.recurring { color: var(--success); }

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.history-title { font-size: 0.95rem; }
.history-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.history-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.history-actions button { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

.brief {
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.85rem;
  max-height: 500px;
  overflow-y: auto;
}

@media (max-width: 600px) {
  header, main { padding-left: 1rem; padding-right: 1rem; }
  .field-row { flex-direction: column; }
}
