/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  line-height: 1.6;
  min-height: 100vh;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
#navbar {
  position: sticky; top: 0; z-index: 100;
  background: #1e40af; color: white;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
#navbar.hidden { display: none; }
.nav-brand { font-weight: 700; font-size: 1.1rem; }
.nav-free { color: #ef4444; }
.nav-dot { color: #93c5fd; }
.nav-right { display: flex; align-items: center; gap: 1rem; }
.nav-progress { font-size: 0.85rem; opacity: .8; }

#app-layout { display: flex; align-items: flex-start; justify-content: center; }

#sidebar {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: 57px;
  max-height: calc(100vh - 57px);
  overflow-y: auto;
  padding: 1.5rem 0.75rem;
  border-right: 1px solid #e2e8f0;
  background: #f8fafc;
}
#sidebar.hidden { display: none; }
.sidebar-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: #475569;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  gap: 0.2rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar-item:hover { background: #e2e8f0; color: #1e293b; }
.sidebar-item.active { background: #dbeafe; color: #1e40af; font-weight: 600; }
.sidebar-item.complete { color: #16a34a; }
.sidebar-fn-label { font-weight: 600; font-size: 0.8rem; letter-spacing: 0.03em; }
.sidebar-fn-progress { font-size: 0.75rem; opacity: 0.7; }

#main {
  max-width: 720px;
  padding: 1.5rem 1rem 4rem;
}

/* ── App header (intro only) ─────────────────────────────────────────────── */
.app-header {
  text-align: center;
  padding: 2.5rem 1rem 2rem;
  margin-bottom: 1.5rem;
}
.app-header h1 {
  font-size: 2.5rem; font-weight: 800; color: #1e40af;
  letter-spacing: -0.5px;
}
.header-sub { font-size: 1.1rem; color: #475569; margin-top: 0.25rem; }
.header-desc { color: #64748b; margin-top: 0.5rem; max-width: 500px; margin-left: auto; margin-right: auto; }

/* ── Panel ────────────────────────────────────────────────────────────────── */
.panel {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
  margin-top: 1rem;
}
.panel h2 { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.5rem; }
.panel h3 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.75rem; }
.panel-animated { animation: slideUp .18s ease; }
@keyframes slideUp { from { opacity:.6; transform:translateY(8px); } to { opacity:1; transform:none; } }

/* ── Typography helpers ───────────────────────────────────────────────────── */
.helper { color: #64748b; font-size: 0.95rem; margin-bottom: 1rem; }
.helper-sm { color: #94a3b8; font-size: 0.8rem; margin-bottom: 0.75rem; }
.helper-sm kbd { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 3px; padding: 1px 5px; font-size: .78rem; }
.optional { color: #94a3b8; font-size: .85em; }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0 0.4rem;
  font-size: 0.85rem; color: #64748b;
}
.progress-bar {
  height: 4px; background: #e2e8f0; border-radius: 2px; overflow: hidden;
  margin-bottom: 1rem;
}
.progress-fill { height: 100%; background: #1e40af; transition: width .3s ease; }
.progress-label { font-weight: 600; color: #1e40af; }
.progress-steps { color: #94a3b8; }

/* ── Back button ──────────────────────────────────────────────────────────── */
.btn-rewind {
  background: none; border: none; cursor: pointer;
  color: #64748b; font-size: 0.85rem; padding: 0.25rem 0.5rem;
  border-radius: 6px; transition: background .15s;
}
.btn-rewind:hover { background: #f1f5f9; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1.1rem; }
.field span, .field > label { font-size: 0.9rem; font-weight: 500; color: #374151; }
.field input, .field select, .field textarea {
  border: 1.5px solid #d1d5db; border-radius: 8px;
  padding: 0.6rem 0.85rem; font-size: 1rem; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
  background: white;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: #1e40af; box-shadow: 0 0 0 3px rgba(30,64,175,.12);
}
.input-full { width: 100%; }
.checkbox-field { flex-direction: row; align-items: flex-start; gap: .6rem; }
.checkbox-field input { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; accent-color: #1e40af; }
.checkbox-field a { color: #1e40af; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  background: #1e40af; color: white;
  border: none; border-radius: 8px;
  padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .1s;
}
.btn-primary:hover:not(:disabled) { background: #1d3a9e; }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary {
  background: white; color: #1e40af;
  border: 1.5px solid #1e40af; border-radius: 8px;
  padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-secondary:hover:not(:disabled) { background: #eff6ff; }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost {
  background: rgba(255,255,255,.15); color: white;
  border: 1px solid rgba(255,255,255,.3); border-radius: 6px;
  padding: 0.35rem 0.9rem; font-size: 0.85rem; cursor: pointer;
  transition: background .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,.25); }
.btn-sm { padding: 0.3rem 0.75rem; }
.btn-link { background: none; border: none; color: #1e40af; cursor: pointer; font-size: .9rem; text-decoration: underline; padding: 0; }
.btn-link-subtle { background: none; border: none; color: #64748b; cursor: pointer; font-size: .9rem; text-decoration: none; padding: 0; }
.btn-link-subtle:hover { color: #475569; }
.signin-text { text-align: center; margin-top: 1rem; }
.contact-terms { text-align: center; margin-top: 1rem; font-size: 0.8rem; color: #94a3b8; }
.contact-terms a { color: #94a3b8; text-decoration: underline; }
.btn-full { width: 100%; }

.panel-actions { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.5rem; }
.contact-actions { flex-direction: row; flex-wrap: wrap; }
.contact-actions .btn-primary, .contact-actions .btn-secondary { flex: 1; min-width: 180px; }

.restore-section { background: #f8fafc; border-radius: 8px; padding: 1rem; margin: 1rem 0; }

/* ── Choice cards (intake) ────────────────────────────────────────────────── */
.choice-card {
  display: flex; align-items: center; gap: 0.75rem;
  border: 1.5px solid #e2e8f0; border-radius: 10px;
  padding: 0.9rem 1rem; margin-bottom: 0.6rem;
  cursor: pointer; transition: border-color .15s, background .15s;
  background: white;
}
.choice-card:hover { border-color: #1e40af; background: #eff6ff; }
.choice-card.selected { border-color: #1e40af; background: #eff6ff; }
.choice-label { font-size: 1rem; font-weight: 500; flex: 1; }

/* ── Framework cards ──────────────────────────────────────────────────────── */
.framework-card {
  display: flex; align-items: flex-start; gap: 0.75rem;
  border: 1.5px solid #e2e8f0; border-radius: 10px;
  padding: 1rem; margin-bottom: 0.6rem;
  cursor: pointer; transition: border-color .15s, background .15s;
  background: white;
}
.framework-card:hover { border-color: #1e40af; background: #eff6ff; }
.framework-card.selected { border-color: #1e40af; background: #eff6ff; }
.fw-body { display: flex; flex-direction: column; gap: 0.2rem; }
.fw-body strong { font-size: 1rem; }
.fw-desc { font-size: 0.85rem; color: #64748b; }

/* ── Hotkey key ───────────────────────────────────────────────────────────── */
.hotkey-key { display: none; }
.hotkey-spacer { display: none; }

/* ── Answer/option cards ──────────────────────────────────────────────────── */
.option-card {
  display: flex; align-items: flex-start; gap: 0.75rem;
  border: 1.5px solid #e2e8f0; border-radius: 10px;
  padding: 0.9rem 1rem; margin-bottom: 0.6rem;
  cursor: pointer; transition: border-color .15s, background .15s;
  background: white;
}
.option-card:hover { border-color: #1e40af; background: #eff6ff; }
.option-card.selected { border-color: #1e40af; background: #eff6ff; }
.option-body { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.option-label { font-size: 1rem; }
.option-guidance { font-size: 0.82rem; color: #64748b; }

/* ── Question meta ────────────────────────────────────────────────────────── */
.q-id { font-size: 0.8rem; font-weight: 700; color: #64748b; letter-spacing: .5px; margin-bottom: .4rem; text-transform: uppercase; }

/* ── Evidence card ────────────────────────────────────────────────────────── */
.evidence-card {
  background: #fffbeb; border: 1px solid #fcd34d; border-radius: 10px;
  padding: 1.1rem; margin-top: 1rem;
}
.evidence-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.75rem; margin-top: 0; color: #92400e; }
.evidence-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 480px) { .evidence-grid { grid-template-columns: 1fr; } }

/* ── Review table ─────────────────────────────────────────────────────────── */
.review-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .9rem; }
.review-table th { text-align: left; padding: 0.5rem 0.75rem; background: #f8fafc; color: #64748b; font-weight: 600; border-bottom: 1px solid #e2e8f0; }
.review-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #f1f5f9; }

/* ── Result / Summary ─────────────────────────────────────────────────────── */
.summary-panel { background: white; border-radius: 12px; padding: 2rem; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.summary-header { margin-bottom: 1.5rem; }
.summary-header h2 { font-size: 1.5rem; }
.summary-header p { color: #64748b; margin-top: .25rem; }
.summary-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: 1.5rem 0; }

.risk-badge {
  display: inline-flex; flex-direction: column; align-items: center;
  border-radius: 12px; padding: 1.25rem 2rem;
  margin: 1rem 0;
}
.risk-badge.risk-low { background: #dcfce7; color: #166534; }
.risk-badge.risk-moderate { background: #fef3c7; color: #92400e; }
.risk-badge.risk-high { background: #fee2e2; color: #991b1b; }
.risk-score { font-size: 2.5rem; font-weight: 800; line-height: 1; }
.risk-level { font-size: 1rem; font-weight: 600; margin-top: .25rem; }
.narrative { color: #475569; margin: 1rem 0; line-height: 1.7; }

.tag-list { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; margin-bottom: 1rem; }
.tag { background: #dbeafe; color: #1e40af; border-radius: 6px; padding: .2rem .7rem; font-size: .85rem; font-weight: 600; }
.skipped-list { list-style: none; display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.skipped-list li { background: #fef3c7; border-radius: 8px; padding: .5rem .85rem; font-size: .9rem; }

.answer-list { list-style: none; display: flex; flex-direction: column; gap: .1rem; }
.answer-row { padding: .75rem 0; border-bottom: 1px solid #f1f5f9; }
.answer-row:last-child { border-bottom: none; }
.answer-row-id { font-size: .75rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: .4px; }
.answer-row-prompt { font-size: .9rem; color: #374151; margin: .15rem 0 .3rem; }
.answer-chip { display: inline-block; font-size: .8rem; font-weight: 600; border-radius: 5px; padding: .15rem .55rem; }
.answer-chip.implemented { background: #dcfce7; color: #166534; }
.answer-chip.partial { background: #fef3c7; color: #92400e; }
.answer-chip.not_implemented { background: #fee2e2; color: #991b1b; }
.answer-chip.unanswered { background: #f1f5f9; color: #94a3b8; }
.evidence-meta { font-size: .78rem; color: #64748b; margin-top: .2rem; }

/* ── Auth modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  padding: 1rem;
}
.modal {
  background: white; border-radius: 14px;
  padding: 2rem; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  position: relative;
}
.modal h2 { font-size: 1.3rem; margin-bottom: .25rem; }
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; font-size: 1.4rem; cursor: pointer; color: #94a3b8;
  line-height: 1; padding: .2rem;
}
.modal-close:hover { color: #374151; }
.auth-tabs { display: flex; gap: .5rem; margin: 1rem 0; }
.auth-tab {
  flex: 1; padding: .55rem; border: 1.5px solid #e2e8f0; border-radius: 8px;
  background: white; cursor: pointer; font-size: .9rem; font-weight: 500;
  transition: all .15s;
}
.auth-tab.active { border-color: #1e40af; background: #eff6ff; color: #1e40af; }
.success { color: #166534; background: #dcfce7; border-radius: 8px; padding: 1rem; }

/* ── Loading overlay ──────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
.spinner {
  width: 36px; height: 36px; border: 4px solid #e2e8f0;
  border-top-color: #1e40af; border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ────────────────────────────────────────────────────────────────── */
.error { color: #dc2626; font-size: .9rem; margin-top: .5rem; }
.error.hidden { display: none; }
.error-banner {
  background: #fee2e2; color: #991b1b; padding: .75rem 1.25rem;
  display: flex; justify-content: space-between; align-items: center;
  font-size: .9rem; font-weight: 500;
}
.error-banner button { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: #991b1b; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .panel { padding: 1.25rem; }
  .summary-panel { padding: 1.25rem; }
  .app-header h1 { font-size: 1.8rem; }
  .contact-actions { flex-direction: column; }
}
