:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #1a2332;
  --text-muted: #5b6b82;
  --primary: #2f5d9e;
  --primary-dark: #234878;
  --accent: #3d8b7a;
  --border: #d8e1ef;
  --shadow: 0 12px 40px rgba(26, 35, 50, 0.08);
  --radius: 16px;
  --success: #2d7a4f;
  --warning: #b7791f;
  --neutral: #5b6b82;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(47, 93, 158, 0.12), transparent 40%),
    radial-gradient(circle at bottom left, rgba(61, 139, 122, 0.1), transparent 35%),
    var(--bg);
  line-height: 1.5;
}

.app {
  width: min(920px, calc(100% - 2rem));
  margin: 2rem auto 3rem;
}

.app--wide {
  width: min(1200px, calc(100% - 2rem));
}

.section-title {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.02em;
}

.header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 3vw, 2rem);
}

.screen[hidden] {
  display: none !important;
}

.instruction {
  margin-bottom: 1.75rem;
  color: var(--text-muted);
  white-space: pre-line;
}

.scale-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.scale-legend-item {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.scale-legend-item strong {
  color: var(--primary);
  margin-right: 0.35rem;
}

.form-select {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 0.9rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #eef3fa;
  color: var(--primary);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-form {
  text-align: left;
  background: linear-gradient(135deg, #eef4fb, #f8fbff);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-form span {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
}

.test-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.test-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--primary);
}

.progress-wrap {
  margin-bottom: 1.5rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.progress-track {
  height: 8px;
  background: #e8eef7;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.25s ease;
}

.question-card {
  margin-bottom: 1.5rem;
}

.question-number {
  display: inline-block;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #eef4fb;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
}

.question-text {
  margin: 0;
  font-size: clamp(1.05rem, 2.5vw, 1.25rem);
  font-weight: 600;
}

.scale-options {
  display: grid;
  gap: 0.65rem;
}

.scale-option {
  display: grid;
  grid-template-columns: auto 3rem 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.scale-option:hover {
  border-color: #b7c9e4;
  background: #f8fbff;
}

.scale-option.selected {
  border-color: var(--primary);
  background: #eef4fb;
}

.scale-option input {
  accent-color: var(--primary);
}

.scale-value {
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

.scale-label {
  color: var(--text);
}

.question-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.nav-dot {
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-dot.current {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef4fb;
}

.nav-dot.answered {
  background: #e8f5ef;
  border-color: #b7dccf;
  color: var(--success);
}

.test-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.results-hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.result-badge {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.result-badge--success {
  background: #e8f5ef;
  color: var(--success);
}

.result-badge--avoidance {
  background: #fff4e5;
  color: var(--warning);
}

.result-badge--neutral {
  background: #eef2f7;
  color: var(--neutral);
}

.score-display {
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.score-display small {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}

.results-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.info-block {
  padding: 1rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.info-block h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.info-block p {
  margin: 0;
  color: var(--text-muted);
}

.footer-note {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.footer-note--inline {
  margin-top: 1.25rem;
}

.footer-note a {
  color: var(--primary);
  text-decoration: none;
}

.footer-note a:hover {
  text-decoration: underline;
}

.profile-form {
  display: grid;
  gap: 1rem;
  max-width: 420px;
}

.profile-form--narrow {
  max-width: 360px;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.field-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: white;
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 93, 158, 0.12);
}

.form-error {
  margin: 0;
  color: #b42318;
  font-size: 0.9rem;
}

.save-status {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
}

.save-status--pending {
  background: #eef4fb;
  color: var(--primary);
}

.save-status--success {
  background: #e8f5ef;
  color: var(--success);
}

.save-status--error {
  background: #fdecec;
  color: #b42318;
}

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

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  padding: 1rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.stat-card--success {
  background: #e8f5ef;
  border-color: #b7dccf;
}

.stat-card--warning {
  background: #fff4e5;
  border-color: #f0d7a8;
}

.stat-card--neutral {
  background: #eef2f7;
}

.stat-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.stat-label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.table-wrap {
  overflow-x: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

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

.results-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.results-table tbody tr:hover {
  background: #f8fafc;
}

.table-badge {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.table-badge--success {
  background: #e8f5ef;
  color: var(--success);
}

.table-badge--avoidance {
  background: #fff4e5;
  color: var(--warning);
}

.table-badge--neutral {
  background: #eef2f7;
  color: var(--neutral);
}

.btn-small {
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
}

.btn-danger {
  background: #fdecec;
  color: #b42318;
}

.btn-danger:hover:not(:disabled) {
  background: #f8d5d5;
}

.empty-state {
  margin: 1rem 0 0;
  text-align: center;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .test-actions,
  .dashboard-header,
  .dashboard-actions {
    flex-direction: column;
  }

  .scale-option {
    grid-template-columns: auto 2.5rem 1fr;
  }
}
