:root {
  color-scheme: light;
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-2: #f7f8f6;
  --text-primary: #14151a;
  --text-secondary: #52514e;
  --muted: #898781;
  --border: rgba(11, 11, 11, 0.09);
  --border-strong: #dfded7;
  --gridline: #e1e0d9;
  --accent: #2a78d6;
  --accent-2: #1c5cab;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --accent-contrast: #ffffff;
  --good: #0ca30c;
  --good-soft: rgba(12, 163, 12, 0.10);
  --critical: #d03b3b;
  --critical-soft: rgba(208, 59, 59, 0.10);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 21, 26, 0.04);
  --shadow-md: 0 10px 30px -12px rgba(20, 21, 26, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101110;
    --surface: #1a1a19;
    --surface-2: #201f1d;
    --text-primary: #f5f5f3;
    --text-secondary: #c3c2b7;
    --muted: #93918a;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: #34332f;
    --gridline: #2c2c2a;
    --accent: #3987e5;
    --accent-2: #6ba8ee;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --accent-contrast: #ffffff;
    --good: #29c729;
    --good-soft: rgba(41, 199, 41, 0.14);
    --critical: #e66767;
    --critical-soft: rgba(230, 103, 103, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 16px 36px -14px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101110;
  --surface: #1a1a19;
  --surface-2: #201f1d;
  --text-primary: #f5f5f3;
  --text-secondary: #c3c2b7;
  --muted: #93918a;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: #34332f;
  --gridline: #2c2c2a;
  --accent: #3987e5;
  --accent-2: #6ba8ee;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --accent-contrast: #ffffff;
  --good: #29c729;
  --good-soft: rgba(41, 199, 41, 0.14);
  --critical: #e66767;
  --critical-soft: rgba(230, 103, 103, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 16px 36px -14px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

/* Brand header */
.site-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 0 20px;
}

.brand-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.brand-icon svg { width: 24px; height: 24px; }

.site-header h1 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 0;
}

.site-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 2px 0 0;
  line-height: 1.5;
}

.site-footer {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  margin-top: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px 20px 26px;
}

@media (min-width: 560px) {
  .card { padding: 30px 32px 32px; }
}

/* Progress */
.progress {
  margin: 0 0 18px;
}

.progress-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 0.82rem;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.progress-step {
  font-weight: 700;
  color: var(--accent);
  flex: none;
}

.progress-name {
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--gridline);
  overflow: hidden;
}

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

/* Sections & fields */
.section-title {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  margin: 30px 0 16px;
  box-shadow: var(--shadow-sm);
}

.section-title:first-child { margin-top: 0; }

.subsection {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 26px 0 12px;
  padding-left: 12px;
  border-left: 4px solid var(--accent);
  color: var(--text-primary);
}

.field {
  margin-bottom: 22px;
}

.field > .field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.5;
}

.field .hint {
  display: block;
  font-weight: 400;
  color: var(--text-secondary);
  font-size: 0.83rem;
  margin-top: 3px;
}

.req {
  color: var(--critical);
  font-weight: 700;
  margin-left: 2px;
}

/* Choice cards (radio / checkbox) */
.choice-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.choice-group.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 380px) {
  .choice-group.cols-2 { grid-template-columns: 1fr; }
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 12px 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, transform .08s ease;
  -webkit-tap-highlight-color: transparent;
}

.choice:hover { border-color: var(--accent); }
.choice:active { transform: scale(0.98); }

.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.choice-mark {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  display: grid;
  place-items: center;
  transition: border-color .15s ease;
}

.choice-mark::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform .15s ease;
}

.choice.is-checkbox .choice-mark {
  border-radius: 7px;
}

.choice.is-checkbox .choice-mark::after {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice:has(input:checked) .choice-mark { border-color: var(--accent); }
.choice:has(input:checked) .choice-mark::after { transform: scale(1); }

.choice:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.choice-text {
  flex: 1;
  line-height: 1.45;
  font-size: 0.96rem;
}

/* Consent banner */
.consent-box {
  background: var(--surface-2);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 22px;
}

.consent-box .choice { border: none; background: transparent; align-items: flex-start; }
.consent-box .choice:has(input:checked) { background: var(--accent-soft); border-radius: var(--radius-md); }
.consent-box .choice-mark { margin-top: 2px; }

/* Intro / info card */
.intro-card {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 22px;
  font-size: 0.92rem;
}

.intro-card p { margin: 0 0 10px; }
.intro-card p:last-child { margin-bottom: 0; }
.intro-card strong { color: var(--accent-2); }

/* Likert scale component */
.likert-legend {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 18px;
}

.likert-legend .req-note {
  display: inline-block;
  margin-top: 6px;
  font-weight: 600;
  color: var(--accent);
}

.likert-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--surface);
}

.likert-code {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.likert-question {
  font-weight: 600;
  margin: 0 0 14px;
  line-height: 1.5;
  font-size: 0.96rem;
}

.scale {
  display: flex;
  gap: 6px;
}

@media (min-width: 480px) {
  .scale { gap: 8px; }
}

.scale-opt {
  flex: 1;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.scale-opt input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.scale-opt span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  font-weight: 700;
  font-size: 0.95rem;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease, color .15s ease, box-shadow .15s ease;
}

.scale-opt:hover span { border-color: var(--accent); }

.scale-opt:has(input:checked) span {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 14px -4px rgba(42, 120, 214, 0.5);
}

.scale-opt:has(input:focus-visible) span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.scale-caption {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 8px;
  gap: 8px;
}

.scale-caption span:last-child { text-align: right; }

/* Text inputs */
textarea, input[type="text"], input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  transition: border-color .15s ease;
}

textarea:focus, input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Buttons */
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 24px;
  border-radius: 999px;
  border: none;
  font: inherit;
  font-weight: 700;
  font-size: 0.96rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform .08s ease, box-shadow .15s ease, opacity .15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(42, 120, 214, 0.55);
}

.btn-primary:hover { opacity: 0.94; }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border-strong);
}

.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-block { width: 100%; }

@media (max-width: 480px) {
  .actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .actions .btn { width: 100%; }
}

/* Alerts */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.alert p { margin: 0 0 6px; }
.alert p:last-child { margin-bottom: 0; }

.alert-error {
  background: var(--critical-soft);
  color: var(--critical);
  border: 1px solid var(--critical);
}

.alert-success {
  background: var(--good-soft);
  color: var(--good);
  border: 1px solid var(--good);
}

.alert-info {
  background: var(--accent-soft);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.result-icon {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
}

.alert-success .result-icon { background: var(--good); }
.alert-info .result-icon { background: var(--accent); }
.alert-error .result-icon { background: var(--critical); }

.code-chip {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  letter-spacing: .03em;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
}

/* Admin dashboard */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.stat-tile .stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-tile .stat-label {
  color: var(--text-secondary);
  font-size: 0.83rem;
  margin-top: 2px;
}

.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 90px;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.bar-row .bar-name {
  color: var(--text-secondary);
}

.bar-track {
  background: var(--gridline);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.bar-fill {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  height: 100%;
  border-radius: 999px;
}

.bar-value {
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-align: right;
  font-weight: 600;
}

.likert-meter .bar-track { background: var(--accent-soft); }

.admin-block {
  margin-bottom: 34px;
}

.admin-block h2 {
  font-size: 1.02rem;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 0.88rem;
}

.admin-nav a { color: var(--accent); font-weight: 600; text-decoration: none; }
.admin-nav a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .bar-row { grid-template-columns: 96px 1fr 64px; font-size: 0.78rem; }
}

/* Login form */
.login-form {
  max-width: 340px;
  margin: 0 auto;
}

/* Filter tabs */
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-tabs a {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.filter-tabs a.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Response list table */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px 6px;
}

.resp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 560px;
}

.resp-table th, .resp-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--gridline);
  text-align: left;
  white-space: nowrap;
}

.resp-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
}

.resp-table a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.resp-table a:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-completed { background: var(--good-soft); color: var(--good); }
.badge-screened { background: var(--gridline); color: var(--text-secondary); }

/* Pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.pagination a {
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text-primary);
}

.pagination a.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Detail rows (single-response view) */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--gridline);
  font-size: 0.9rem;
}

.detail-row:last-child { border-bottom: none; }

.detail-row .k {
  color: var(--text-secondary);
  flex: 1;
}

.detail-row .v {
  font-weight: 600;
  text-align: right;
  flex: none;
  max-width: 55%;
}

@media (max-width: 520px) {
  .detail-row { flex-direction: column; gap: 4px; }
  .detail-row .v { text-align: left; max-width: 100%; }
}

.score-chip {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
  background: var(--accent-soft);
  color: var(--accent-2);
}

.score-chip.is-empty {
  background: var(--gridline);
  color: var(--muted);
}
