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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #f3f4f6;
  color: #111827;
  min-height: 100vh;
}

/* ── Layout ── */
.app-header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 20px 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.app-header-left h1 {
  font-size: 1.375rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
}

.app-header-left p {
  font-size: 0.82rem;
  color: #6b7280;
  max-width: 560px;
  line-height: 1.5;
}

.app-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: #f9fafb; border-color: #9ca3af; }

.btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.btn-primary:disabled {
  background: #93c5fd;
  border-color: #93c5fd;
  cursor: not-allowed;
}

.app-body {
  display: flex;
  height: calc(100vh - 97px);
}

/* ── Sidebar ── */
.sidebar {
  width: 244px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-section-title {
  padding: 14px 16px 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
}

.sidebar-nav { list-style: none; padding: 0 8px 8px; }

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-nav button:hover { background: #f3f4f6; }

.sidebar-nav button.active {
  background: #2563eb;
  color: #fff;
}

.sidebar-nav button .section-check {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.sidebar-nav button.completed .section-check {
  background: #22c55e;
  color: #fff;
}

.sidebar-nav button.active.completed .section-check {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

.sidebar-progress {
  padding: 14px 16px;
  border-top: 1px solid #e5e7eb;
  margin-top: auto;
}

.sidebar-progress-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.progress-track {
  height: 6px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 99px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.73rem;
  color: #6b7280;
}

.sidebar-legend {
  padding: 12px 16px 16px;
  border-top: 1px solid #e5e7eb;
}

.sidebar-legend-title {
  font-size: 0.73rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.sidebar-legend ul {
  list-style: none;
  font-size: 0.72rem;
  color: #6b7280;
  line-height: 1.7;
}

/* ── Main content ── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

.section-header {
  margin-bottom: 24px;
}

.section-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}

.section-header p {
  font-size: 0.82rem;
  color: #6b7280;
}

.question-list { display: flex; flex-direction: column; gap: 18px; }

.question-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px 20px;
}

.question-id {
  display: inline-block;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  margin-bottom: 10px;
  border: 1px solid #e5e7eb;
  letter-spacing: 0.03em;
}

.question-text {
  font-size: 0.9rem;
  color: #1f2937;
  line-height: 1.5;
  margin-bottom: 14px;
}

.likert-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.likert-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  background: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}

.likert-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
  background: #eff6ff;
}

.likert-btn.selected {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

/* ── Section navigation ── */
.section-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

.section-nav .nav-spacer { flex: 1; }

/* ── Results view ── */
.results-view { max-width: 680px; }

.results-view h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.score-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}

.score-card h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  margin-bottom: 8px;
}

.score-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: #2563eb;
  line-height: 1;
  margin-bottom: 4px;
}

.score-max { font-size: 0.82rem; color: #9ca3af; }

.score-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
}

.score-badge.low { background: #fee2e2; color: #dc2626; }
.score-badge.mid { background: #fef3c7; color: #d97706; }
.score-badge.high { background: #dcfce7; color: #16a34a; }

.interpretation-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}

.interpretation-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #1f2937;
}

.interpretation-card p {
  font-size: 0.85rem;
  color: #4b5563;
  line-height: 1.6;
  margin-bottom: 8px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric-chip {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px;
}

.metric-chip .label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.metric-chip .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1f2937;
}

.results-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* ── Error / loading ── */
.calc-error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 14px 18px;
  color: #b91c1c;
  font-size: 0.85rem;
  margin-top: 20px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

/* ── Export/Import modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 420px;
  max-width: 90vw;
}

.modal h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.modal textarea {
  width: 100%;
  height: 160px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-family: monospace;
  resize: vertical;
  color: #374151;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .app-body { flex-direction: column; height: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid #e5e7eb; }
  .main { padding: 16px; }
}

/* ======================== LOGIN ======================== */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f9fafb;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}
.login-card h1 { font-size: 22px; margin: 0 0 8px 0; color: #111827; }
.login-sub { color: #6b7280; font-size: 14px; margin: 0 0 24px 0; line-height: 1.5; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: #374151; }
.login-form input {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.login-form input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.login-error {
  padding: 10px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 13px;
}
.login-btn { width: 100%; margin-top: 4px; padding: 10px; font-size: 14px; }
.login-hint { color: #9ca3af; font-size: 12px; margin: 16px 0 0 0; text-align: center; }
.login-hint code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; color: #374151; }
