:root {
  --background: #f2f6fb;
  --surface: #ffffff;
  --surface-muted: #f6f9fd;
  --text: #101820;
  --text-muted: #4d5b6a;
  --border: #d2deec;
  --border-strong: #9fb4cd;
  --accent: #346fbd;
  --accent-dark: #245797;
  --accent-soft: #e7f0fc;
  --error: #a0222f;
  --error-soft: #fff1f2;
  --focus: #005aaf;
  --shadow: 0 16px 40px rgba(35, 78, 128, 0.1);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

input {
  min-width: 0;
}

.container {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-header {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.page-header::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 34%;
  height: 5px;
  background: var(--accent);
  content: "";
}

.header-content {
  position: relative;
  padding-block: 64px 56px;
}

.brand-logo {
  position: absolute;
  top: 50%;
  right: 0;
  width: 190px;
  height: auto;
  transform: translateY(-50%);
}

.title-prefix {
  display: block;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(1.85rem, 5vw, 3.35rem);
  line-height: 1.07;
  letter-spacing: -0.035em;
}

.lead {
  max-width: 760px;
  margin: 24px 0 0;
  color: var(--text-muted);
  font-size: clamp(1rem, 2vw, 1.16rem);
}

.applied-by {
  margin: 18px 0 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 750;
}

#test-form {
  padding-block: 40px 64px;
}

.registration-section {
  margin-block: 40px 32px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.registration-copy {
  margin: -8px 0 22px;
  color: var(--text-muted);
}

.registration-form {
  display: grid;
  gap: 18px;
}

.registration-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr;
  gap: 14px;
}

.field-label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
}

.field-label input {
  min-height: 48px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
}

.field-label input:focus {
  border-color: var(--accent);
}

.registration-actions {
  display: flex;
  justify-content: flex-end;
}

.participant-summary {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
}

.form-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 24px rgba(35, 78, 128, 0.08);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.progress-track {
  flex: 1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7e9ed;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.questions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.question-card {
  min-width: 0;
  margin: 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(35, 78, 128, 0.045);
  scroll-margin-top: 84px;
}

.question-card legend {
  float: left;
  width: 100%;
  margin: 0 0 15px;
  padding: 0;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.35;
}

.question-card legend + * {
  clear: both;
}

.question-card.is-missing {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(160, 34, 47, 0.1);
}

.options-list {
  display: grid;
  gap: 8px;
}

.option-label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  align-items: start;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.option-label:hover {
  border-color: var(--border);
  background: var(--surface-muted);
}

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

.option-label input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.option-text {
  min-width: 0;
}

.option-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.45rem;
  margin-right: 4px;
  border-radius: 5px;
  background: #eceef1;
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1;
  vertical-align: 0.08em;
}

.option-label:has(input:checked) .option-code {
  background: var(--accent);
  color: #fff;
}

.notice {
  margin-bottom: 22px;
  padding: 14px 16px;
  border-radius: 10px;
  font-weight: 650;
}

.notice-error {
  border: 1px solid #e5a3aa;
  background: var(--error-soft);
  color: #7f1824;
}

.submit-panel {
  display: flex;
  justify-content: flex-end;
  margin-top: 28px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  scroll-margin-top: 84px;
}

.primary-button {
  min-width: 180px;
  min-height: 50px;
  padding: 12px 24px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  box-shadow: 0 6px 18px rgba(52, 111, 189, 0.24);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.result-section {
  margin-bottom: 72px;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.15rem);
  letter-spacing: -0.025em;
}

.section-heading-compact {
  margin-top: 44px;
}

.section-heading-compact h3 {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.7rem);
  letter-spacing: -0.025em;
}

.score-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.score-heading h3 {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
}

.score-heading p {
  margin: 0;
  color: var(--accent-dark);
  font-weight: 800;
  text-align: right;
}

.save-status {
  margin: -4px 0 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.score-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.score-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
}

.score-card.is-dominant {
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px rgba(52, 111, 189, 0.12);
}

.score-card-header,
.score-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.score-card h3 {
  margin: 0;
  font-size: 1.2rem;
  white-space: nowrap;
}

.profile-title {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.result-marker {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
}

.brain-side {
  color: var(--text-muted);
  font-size: 0.83rem;
  text-align: right;
}

.score-line {
  margin-top: 12px;
}

.score-equation {
  color: var(--text-muted);
  font-weight: 650;
}

.score-percentage {
  font-size: 1.8rem;
  font-weight: 850;
  letter-spacing: -0.04em;
}

.score-bar {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1e4e8;
}

.score-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.interpretation-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  font-size: 0.9rem;
}

.interpretation-table th,
.interpretation-table td {
  padding: 14px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.interpretation-table tr:last-child th,
.interpretation-table tr:last-child td {
  border-bottom: 0;
}

.interpretation-table th:last-child,
.interpretation-table td:last-child {
  border-right: 0;
}

.interpretation-table thead th {
  background: #edf3fa;
  font-size: 1rem;
  text-align: left;
}

.table-profile-name {
  display: block;
}

.interpretation-table .is-dominant-column {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 var(--accent), inset -2px 0 var(--accent);
}

.interpretation-table thead .is-dominant-column {
  box-shadow: inset 2px 0 var(--accent), inset -2px 0 var(--accent), inset 0 2px var(--accent);
}

.interpretation-table tbody tr:last-child .is-dominant-column {
  box-shadow: inset 2px 0 var(--accent), inset -2px 0 var(--accent), inset 0 -2px var(--accent);
}

.interpretation-table thead .result-marker {
  margin-top: 8px;
}

.interpretation-table .row-heading {
  width: 15%;
  background: var(--surface-muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.trait-lead {
  display: block;
  margin-bottom: 3px;
  font-weight: 850;
}

.trait-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.trait-list li + li {
  margin-top: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.interpretation-mobile {
  display: none;
}

.result-guide {
  margin: -8px 0 18px;
  color: var(--text-muted);
}

.profile-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.profile-card.is-dominant {
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(52, 111, 189, 0.12);
}

.profile-card + .profile-card {
  margin-top: 14px;
}

.profile-card > h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 16px;
  background: #edf3fa;
  font-size: 1.15rem;
}

.profile-section {
  padding: 16px;
}

.profile-section + .profile-section {
  border-top: 1px solid var(--border);
}

.profile-section h4 {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source {
  margin: 30px 0 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.result-actions {
  margin-top: 32px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-muted);
}

.result-actions-copy {
  display: grid;
  grid-template-columns: minmax(180px, 0.38fr) minmax(0, 1fr);
  gap: 18px;
  align-items: baseline;
}

.result-actions-copy h3 {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
}

.result-actions-copy p,
.result-action-note,
.result-action-status {
  margin: 0;
}

.result-actions-copy p {
  color: var(--text-muted);
}

.result-actions-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.action-button {
  min-height: 48px;
  padding: 11px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-weight: 780;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.action-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.action-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.action-button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.action-button-primary:hover {
  background: var(--accent-dark);
  color: #fff;
}

.action-button-danger {
  border-color: #d19aa1;
  color: var(--error);
}

.action-button-danger:hover {
  border-color: var(--error);
  background: var(--error-soft);
}

.result-action-status {
  min-height: 1.5em;
  margin-top: 12px;
  color: var(--accent-dark);
  font-weight: 750;
}

.result-action-note {
  color: var(--text-muted);
  font-size: 0.83rem;
}

.confirm-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(16, 24, 32, 0.28);
  color: var(--text);
}

.confirm-dialog::backdrop {
  background: rgba(16, 24, 32, 0.58);
  backdrop-filter: blur(2px);
}

.confirm-dialog form {
  padding: 26px;
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 1.45rem;
}

.confirm-dialog p {
  margin: 12px 0 0;
  color: var(--text-muted);
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.page-footer {
  padding-block: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
}

.page-footer a {
  color: #fff;
  font-weight: 750;
  text-underline-offset: 3px;
}

.admin-header .header-content {
  padding-block: 48px 42px;
}

.admin-main {
  padding-bottom: 64px;
}
.admin-results > .section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

.admin-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.admin-tabs button { border: 0; border-bottom: 3px solid transparent; background: transparent; padding: 14px 22px; font: inherit; font-weight: 700; color: var(--text-muted); cursor: pointer; }
.admin-tabs button[aria-selected="true"] { color: var(--accent-dark); border-bottom-color: var(--accent); }
.dashboard-heading { display: flex; align-items: end; flex-wrap: wrap; gap: 16px; }
.dashboard-heading > div { flex: 1 1 260px; }
.dashboard-heading h2 { margin: 0; }
.dashboard-heading p, .dashboard-card > p, .dashboard-note { color: var(--text-muted); font-size: .9rem; }
.dashboard-heading select { font: inherit; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text); background: white; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 24px 0; }
.dashboard-metric { display: flex; flex-direction: column; padding: 20px; gap: 8px; background: var(--accent-soft); border-radius: 12px; border-top: 3px solid var(--accent); }
.dashboard-metric > span { font-size: .9rem; color: var(--accent-dark); font-weight: 600; }
.dashboard-metric > strong { font-size: clamp(1.2rem, 2vw, 1.8rem); line-height: 1.3; overflow-wrap: anywhere; }
.dashboard-metric > small { font-size: .8rem; color: var(--text-muted); }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.dashboard-card { min-width: 0; border: 1px solid var(--border); border-radius: 12px; padding: 24px; background: var(--surface); }
.dashboard-card h3 { font-size: 1.1rem; margin: 0 0 6px; }
.dashboard-card > p { margin: 0 0 24px; }
.dashboard-bar-row + .dashboard-bar-row { margin-top: 19px; }
.dashboard-bar-heading { display: flex; justify-content: space-between; gap: 12px; font-size: .95rem; margin-bottom: 7px; }
.dashboard-bar-track { height: 12px; border-radius: 4px; background: var(--background); overflow: hidden; }
.dashboard-bar-fill { height: 100%; border-radius: 4px; }
.dashboard-timeline { grid-column: 1 / -1; }
#dashboard-timeline { overflow-x: auto; }
.dashboard-columns { display: flex; gap: 10px; padding: 8px 2px 14px; min-width: 100%; width: max-content; }
.dashboard-column { flex: 1 0 44px; min-width: 44px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: .8rem; }
.dashboard-column-track { height: 130px; width: 28px; display: flex; align-items: end; background: var(--surface-muted); }
.dashboard-column-fill { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.dashboard-column-label { white-space: nowrap; }
.dashboard-note { margin-top: 20px; }
@media (max-width: 900px) { .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard-card { padding: 18px; }
  .dashboard-metric { padding: 14px; }
  .dashboard-heading .field-label, .dashboard-heading > button { width: 100%; }
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

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

.admin-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.9rem;
}

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

.admin-table th {
  background: #edf3fa;
  color: var(--text);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.admin-answer-list {
  margin: 10px 0 0;
  padding-left: 22px;
}

.admin-answer-list li + li {
  margin-top: 4px;
}

@media (max-width: 920px) and (min-width: 761px) {
  .header-content {
    padding-right: 160px;
  }

  .brand-logo {
    width: 125px;
  }

  .registration-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field-label:first-child {
    grid-column: 1 / -1;
  }
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .container {
    width: min(100% - 28px, 1120px);
  }

  .header-content {
    padding-block: 42px 38px;
  }

  .brand-logo {
    position: static;
    display: block;
    width: 104px;
    margin: 0 0 20px auto;
    transform: none;
  }

  #test-form {
    padding-block: 24px 48px;
  }

  .registration-section {
    margin-block: 24px;
    padding: 24px 16px;
  }

  .registration-grid {
    grid-template-columns: 1fr;
  }

  .form-toolbar {
    gap: 12px;
    margin-inline: -3px;
    font-size: 0.78rem;
  }

  .questions-grid,
  .score-summary {
    grid-template-columns: 1fr;
  }

  .score-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .score-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .score-heading p {
    text-align: left;
  }

  .brain-side {
    text-align: left;
  }

  .question-card {
    padding: 18px 15px;
  }

  .option-label {
    padding: 11px 8px;
  }

  .submit-panel {
    padding: 18px;
  }

  .primary-button {
    width: 100%;
  }

  .result-section {
    margin-inline: -4px;
    padding: 24px 16px;
  }

  .result-actions {
    padding: 18px 14px;
  }

  .result-actions-copy,
  .result-actions-buttons,
  .admin-toolbar {
    grid-template-columns: 1fr;
  }

  .result-actions-copy {
    gap: 8px;
  }

  .confirm-dialog-actions {
    flex-direction: column;
  }

  .confirm-dialog-actions .action-button {
    width: 100%;
  }

  .interpretation-desktop {
    display: none;
  }

  .interpretation-mobile {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    background: #fff;
  }

  .page-header,
  #test-form,
  .page-footer,
  .result-actions {
    display: none;
  }

  .result-section {
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
}
