:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #1a1d23;
  --muted: #5b6270;
  --accent: #2454ff;
  --accent-hover: #1a3fd6;
  --border: #e2e4ea;
  --error-bg: #fdecec;
  --error-text: #a3221b;
  --success-bg: #e8f7ee;
  --success-text: #1a7a41;
  --tag-bg: #eaefff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --card-bg: #1a1d23;
    --text: #eef0f3;
    --muted: #9aa1ad;
    --accent: #5b82ff;
    --accent-hover: #7d9cff;
    --border: #2b2f38;
    --error-bg: #3a1c1c;
    --error-text: #ff8a80;
    --success-bg: #123322;
    --success-text: #5fd88a;
    --tag-bg: #1d2547;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.site-header {
  height: 60px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
}

.site-logo {
  height: 24px;
  width: auto;
  display: block;
}

.site-tagline {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.page {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  max-width: 560px;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.25;
  margin: 0 0 1rem;
}

.lede {
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 1.5rem;
}

.intake-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  font-size: 0.875rem;
  font-weight: 600;
}

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

input[type="text"]:focus,
input[type="number"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

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

.additional-notes {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.additional-notes label {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.85rem;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-label {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0 0 1.5rem;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 400;
  font-size: 0.95rem;
}

.option-item:hover {
  border-color: var(--accent);
}

.option-item input {
  accent-color: var(--accent);
  width: 1.1rem;
  height: 1.1rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover { background: var(--accent-hover); }

.fineprint {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 1.25rem;
  margin-bottom: 0;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.readiness-box {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.readiness-badge {
  flex-shrink: 0;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.readiness-box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.tldr-box {
  padding: 1rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 1.25rem;
}

.tldr-box .report-subhead {
  margin-top: 0;
}

.results-card {
  max-width: 680px;
}

.report-card {
  max-width: 820px;
}

.report-subhead {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 1.25rem 0 0.6rem;
}

.report-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

table.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.report-table th,
table.report-table td {
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.report-table tbody tr:last-child th,
table.report-table tbody tr:last-child td {
  border-bottom: none;
}

table.report-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--bg);
}

table.report-table tbody th {
  font-weight: 600;
  white-space: nowrap;
  width: 1%;
  background: var(--bg);
}

.report-bullets {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.report-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

@media (max-width: 560px) {
  .report-grid-2 {
    grid-template-columns: 1fr;
  }
}

.cta-box {
  margin: 2rem 0 0;
  padding: 1.25rem 1.5rem;
  background: var(--tag-bg);
  border-radius: 12px;
}

.cta-box p {
  margin: 0 0 1rem;
  color: var(--text);
  line-height: 1.55;
}

.cta-box .btn-primary {
  display: inline-block;
  text-decoration: none;
}

.results-card h2 {
  font-size: 1.05rem;
  margin: 2rem 0 0.9rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.rec-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rec-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}

.rec-item h3 {
  font-size: 0.95rem;
  margin: 0 0 0.4rem;
}

.rec-item p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 0.6rem;
}

.rec-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--tag-bg);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
}

.results-actions {
  margin: 1.5rem 0;
}

.btn-secondary {
  display: inline-block;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

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

.depth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.depth-actions button {
  flex: 1 1 auto;
}

.email-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.email-form h2 {
  margin-top: 0;
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.feedback-form h2 {
  margin-top: 0;
}

.rating-options {
  display: flex;
  gap: 0.5rem;
}

.rating-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
}

.rating-item:hover {
  border-color: var(--accent);
}

.rating-item input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.rating-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--tag-bg);
  color: var(--accent);
}

textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* --- Admin dashboard --- */

.admin-body {
  margin: 0;
}

.admin-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.admin-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -2rem -1.5rem;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.admin-header h1 {
  margin: 0;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.admin-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  min-width: 90px;
  text-align: center;
}

.stat-value {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-label {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.admin-filters input[type="text"] {
  width: auto;
  flex: 1 1 260px;
}

select {
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

.admin-table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: var(--bg);
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  color: var(--accent);
  background: var(--tag-bg);
}

.status-completed { color: var(--success-text); background: var(--success-bg); }
.status-failed { color: var(--error-text); background: var(--error-bg); }

.admin-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.admin-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.admin-panel-wide {
  grid-column: 1 / -1;
}

.admin-panel h2 {
  font-size: 1rem;
  margin: 0 0 1rem;
}

.admin-panel h3 {
  font-size: 0.9rem;
  margin: 1.25rem 0 0.75rem;
}

.admin-dl {
  margin: 0 0 1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

.admin-dl dt {
  color: var(--muted);
  font-weight: 600;
}

.admin-dl dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.admin-summary {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.admin-trends {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-qa {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.admin-qa:last-child {
  border-bottom: none;
}

.admin-qa-q {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 0.25rem;
}

.admin-qa-a {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

@media (max-width: 720px) {
  .admin-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Loading overlay --- */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.loading-box {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: 320px;
  text-align: center;
}

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

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

.loading-message {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}
