:root {
  --ink: #102a43;
  --ink-2: #1f3a5f;
  --muted: #66788a;
  --paper: #f7f8f4;
  --surface: #ffffff;
  --line: #d8e0e8;
  --line-strong: #8aa0b7;
  --teal: #0f766e;
  --teal-soft: #d8f3ee;
  --blue: #2456a6;
  --blue-soft: #dce8ff;
  --copper: #b86b35;
  --copper-soft: #fde7d6;
  --plum: #6f4ba8;
  --plum-soft: #eee6ff;
  --green: #18814a;
  --green-soft: #dff5e8;
  --rose: #b93567;
  --rose-soft: #fde6ef;
  --yellow-soft: #fff2bf;
  --shadow: 0 22px 70px rgba(16, 42, 67, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(247, 248, 244, 0.92)),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.is-hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.access-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.access-panel {
  width: min(720px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.access-panel h1,
.topbar h1,
.section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 2rem;
  line-height: 1.08;
}

.access-copy {
  max-width: 58ch;
  margin: 18px 0 24px;
  color: var(--muted);
  line-height: 1.65;
}

.license-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.license-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.license-row input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fbfcfd;
  color: var(--ink);
}

.license-row button,
#results-button,
#next-domain,
#print-button,
.primary-action {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.license-message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--rose);
  font-weight: 700;
}

.access-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.access-shop-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--blue);
  font-weight: 800;
  text-underline-offset: 3px;
}

.access-facts span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 0.88rem;
  font-weight: 800;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 26px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.top-actions,
.result-actions,
.step-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 96px;
}

.progress-box,
.assessment-view,
.results-view,
.chart-panel,
.domain-result,
.insight-section,
.summary-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 32px rgba(16, 42, 67, 0.08);
}

.progress-box {
  padding: 16px;
  margin-bottom: 14px;
}

#progress-label {
  display: block;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
  margin-bottom: 10px;
}

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

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.domain-nav {
  display: grid;
  gap: 8px;
}

.domain-button {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 48px;
  text-align: left;
  background: rgba(255, 255, 255, 0.82);
}

.domain-button.is-active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.domain-button small {
  color: var(--muted);
  font-weight: 800;
}

.assessment-view,
.results-view {
  padding: 22px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-description {
  max-width: 54ch;
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.question-list {
  display: grid;
  gap: 12px;
}

.question-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(340px, 430px);
  gap: 18px;
  align-items: center;
  min-height: 138px;
  padding: 18px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.question-row.is-complete {
  border-color: rgba(15, 118, 110, 0.36);
  background: linear-gradient(90deg, rgba(216, 243, 238, 0.42), #fbfcfd);
}

.facet {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--ink-2);
  font-size: 0.78rem;
  font-weight: 800;
}

.question-row h3 {
  margin: 10px 0 6px;
  font-size: 1rem;
}

.question-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.slider-stack {
  display: grid;
  gap: 14px;
}

.slider-line {
  display: grid;
  gap: 6px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-weight: 800;
}

.slider-value {
  min-width: 28px;
  text-align: right;
  color: var(--teal);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.76rem;
}

.step-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  min-height: 104px;
  padding: 16px;
}

.summary-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  margin-top: 10px;
  color: var(--ink);
  font-size: 1.75rem;
  line-height: 1.1;
}

.summary-card:nth-child(1) {
  background: var(--green-soft);
}

.summary-card:nth-child(2) {
  background: var(--blue-soft);
}

.summary-card:nth-child(3) {
  background: var(--plum-soft);
}

.summary-card:nth-child(4) {
  background: var(--yellow-soft);
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
  gap: 16px;
  align-items: start;
}

.chart-panel {
  min-height: 560px;
  display: grid;
  place-items: center;
  padding: 14px;
}

#spider-chart {
  width: 100%;
  max-width: 760px;
  height: auto;
}

.domain-results {
  display: grid;
  gap: 10px;
}

.domain-result {
  padding: 14px;
}

.domain-result h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.result-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.result-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
}

.band {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-2);
  font-weight: 800;
  font-size: 0.78rem;
}

.insight-section {
  margin-top: 16px;
  padding: 18px;
}

.insight-section h3 {
  margin: 0;
  font-size: 1.2rem;
}

.insight-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.review-date-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.review-date-field input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fbfcfd;
  color: var(--ink);
}

.insight-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.insight-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.insight-item strong {
  display: block;
  margin-bottom: 8px;
}

.insight-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.ai-companion {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 28px;
  margin-top: 22px;
  padding: 24px 2px 2px;
  border-top: 1px solid var(--line);
}

.ai-companion h3 {
  margin: 0;
  font-size: 1.35rem;
}

.ai-companion-copy > p:not(.eyebrow) {
  max-width: 64ch;
  margin: 12px 0;
  color: var(--muted);
  line-height: 1.6;
}

.privacy-note {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 7px 10px;
  border-left: 3px solid var(--teal);
  background: var(--teal-soft);
  color: var(--ink-2);
  font-size: 0.86rem;
  font-weight: 800;
}

.ai-actions {
  display: grid;
  gap: 9px;
}

.provider-link {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.provider-link:hover {
  border-color: var(--line-strong);
}

.ai-status,
.import-message {
  min-height: 22px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.4;
}

.ai-status[data-mode="success"],
.import-message[data-mode="success"] {
  color: var(--green);
}

.ai-status[data-mode="error"],
.import-message[data-mode="error"] {
  color: var(--rose);
}

.ai-dialog {
  width: min(720px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  margin: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.ai-dialog::backdrop {
  background: rgba(16, 42, 67, 0.58);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

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

.dialog-head button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-weight: 900;
}

.dialog-copy {
  margin: 16px 0;
  color: var(--muted);
  line-height: 1.55;
}

.import-field {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.import-field textarea {
  width: 100%;
  min-height: 230px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
}

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

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .domain-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .question-row,
  .result-layout,
  .summary-grid,
  .insight-list,
  .ai-companion {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .access-screen,
  .workspace {
    padding: 14px;
  }

  .access-panel,
  .assessment-view,
  .results-view {
    padding: 18px;
  }

  .topbar,
  .section-head,
  .license-row,
  .insight-heading {
    display: grid;
    grid-template-columns: 1fr;
  }

  .domain-nav {
    grid-template-columns: 1fr;
  }

  .question-row {
    min-height: 0;
    padding: 14px;
  }

  .result-actions {
    width: 100%;
  }

  .top-actions button,
  .result-actions button {
    flex: 1 1 auto;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media print {
  .access-screen,
  .topbar,
  .sidebar,
  .result-actions,
  .step-actions,
  .ai-companion {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .workspace {
    display: block;
    padding: 0;
  }

  .results-view {
    border: 0;
    box-shadow: none;
  }
}
