:root {
  color-scheme: light;
  --blue-950: #08152c;
  --blue-900: #102448;
  --blue-800: #1a5faf;
  --blue-700: #2472d0;
  --blue-100: #dcecff;
  --blue-50: #eef6ff;
  --green-600: #198754;
  --green-50: #e9f8f1;
  --orange-600: #d97706;
  --orange-50: #fff4df;
  --red-600: #c73636;
  --red-50: #fff0f0;
  --ink: #101828;
  --muted: #64748b;
  --line: #dbe4f0;
  --soft: #f7f9fc;
  --white: #ffffff;
  --shadow: 0 18px 55px rgba(36, 114, 208, 0.12);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

@media (min-width: 980px) and (min-height: 680px) {
  .workspace {
    gap: 20px;
  }

  .finder-form {
    gap: 12px;
    padding: 18px;
  }

  .field-grid,
  .metric-grid {
    gap: 10px;
  }

  input,
  select {
    min-height: 42px;
    padding-inline: 12px;
  }

  textarea {
    height: 68px;
    min-height: 68px;
    padding: 10px 12px;
  }

  #questionnaire {
    height: 92px;
  }

  .data-box {
    gap: 8px;
    padding: 11px;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0, #f5f9ff 520px, #ffffff 100%);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  color: var(--blue-950);
  letter-spacing: 0;
  line-height: 1.12;
}

h1 {
  margin-top: 4px;
  font-size: 2.25rem;
}

h2 {
  font-size: 1.45rem;
}

h3 {
  font-size: 1rem;
}

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(219, 228, 240, 0.95);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 28px rgba(36, 114, 208, 0.08);
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--blue-950);
  font-weight: 850;
}

.brand img {
  display: block;
  width: 210px;
  max-width: 100%;
  height: auto;
}

.brand span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-left: 1px solid var(--line);
  padding-left: 12px;
  color: var(--blue-700);
}

.top-actions,
.form-actions,
.panel-heading,
.summary-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.mode-chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 11px;
  color: #40516a;
  background: var(--white);
  font-size: 0.88rem;
  font-weight: 750;
  white-space: nowrap;
}

.shell {
  width: min(1240px, calc(100% - 24px));
  min-width: 0;
  margin: 0 auto;
  padding: 28px 0 68px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.finder-form {
  position: sticky;
  top: 92px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 20px;
  min-width: 0;
}

.result-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
}

.step-progress {
  display: grid;
  grid-template-columns: 34px minmax(48px, 1fr) 34px;
  align-items: center;
  gap: 10px;
}

.step-dot {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #52657f;
  background: var(--white);
  font-weight: 850;
}

.step-dot.is-active {
  border-color: var(--blue-700);
  color: var(--white);
  background: var(--blue-700);
}

.step-line {
  height: 1px;
  background: var(--line);
}

.form-step {
  display: grid;
  gap: 14px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.form-step[hidden] {
  display: none;
}

.form-step > legend {
  margin-bottom: 2px;
  color: var(--blue-950);
  font-size: 0.95rem;
  font-weight: 850;
}

.section-head {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.section-head p:last-child,
.summary-text {
  color: #50627d;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--blue-700);
  font-size: 0.85rem;
  font-weight: 850;
}

.eyebrow::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-600);
  content: "";
}

.field-grid,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field.wide {
  grid-column: 1 / -1;
}

.field span,
.option-box legend {
  color: #172033;
  font-size: 0.9rem;
  font-weight: 780;
}

.field strong {
  color: var(--red-600);
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  color: var(--blue-950);
  background: var(--white);
  box-shadow: inset 0 1px 0 rgba(8, 21, 44, 0.02), 0 2px 8px rgba(8, 21, 44, 0.03);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input,
select {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  min-height: 84px;
  resize: none;
  padding: 12px;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder {
  color: #7a8494;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-700);
  box-shadow: 0 0 0 4px rgba(36, 114, 208, 0.14);
}

.option-box {
  display: grid;
  gap: 10px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--soft);
}

.option-box legend {
  padding: 0 6px;
}

.check-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  color: #2d3a50;
  font-size: 0.9rem;
  font-weight: 720;
}

.check-option input {
  width: 18px;
  min-height: 18px;
  margin: 2px 0 0;
  accent-color: var(--blue-700);
  box-shadow: none;
}

.primary-button,
.secondary-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: var(--radius);
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 820;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
  flex: 1 1 220px;
  color: var(--white);
  background: var(--blue-700);
  box-shadow: 0 14px 28px rgba(36, 114, 208, 0.24);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(36, 114, 208, 0.24);
}

.secondary-button,
.copy-button {
  color: var(--blue-700);
  border-color: #bfd3ee;
  background: var(--white);
}

.secondary-button:hover,
.copy-button:hover {
  border-color: var(--blue-700);
  background: var(--blue-50);
}

.copy-button.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.step-actions {
  justify-content: flex-end;
}

.summary-panel,
.variables-panel,
.tests-panel,
.output-panel {
  padding: 20px;
}

.summary-main {
  align-items: flex-start;
}

.summary-main > div:first-child {
  min-width: 0;
}

.score-badge {
  display: grid;
  flex: 0 0 104px;
  min-height: 104px;
  place-items: center;
  border: 1px solid rgba(25, 135, 84, 0.24);
  border-radius: var(--radius);
  background: var(--green-50);
  color: #10663f;
  text-align: center;
}

.score-badge strong {
  display: block;
  font-size: 1.85rem;
  line-height: 1;
}

.score-badge span {
  color: #44705c;
  font-size: 0.82rem;
  font-weight: 760;
}

.score-badge.tight {
  border-color: rgba(217, 119, 6, 0.28);
  background: var(--orange-50);
  color: #a15604;
}

.score-badge.critical {
  border-color: rgba(199, 54, 54, 0.28);
  background: var(--red-50);
  color: #9b2727;
}

.metric-grid {
  margin-top: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-tile {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--soft);
}

.metric-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 780;
}

.metric-tile strong {
  display: block;
  margin-top: 6px;
  color: var(--blue-950);
  font-size: 1.1rem;
}

.advice-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.advice-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: var(--white);
  color: #35465e;
}

.advice-dot {
  width: 10px;
  height: 10px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--blue-700);
}

.advice-item.warning .advice-dot {
  background: var(--orange-600);
}

.advice-item.critical .advice-dot {
  background: var(--red-600);
}

.advice-item strong {
  display: block;
  color: var(--blue-950);
}

.form-error {
  border: 1px solid rgba(199, 54, 54, 0.32);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--red-50);
  color: var(--red-600);
  font-weight: 750;
}

.panel-heading {
  margin-bottom: 16px;
  align-items: flex-start;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--white);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #40516a;
  background: #f0f6ff;
  font-size: 0.82rem;
  font-weight: 850;
}

td {
  color: #26364d;
  font-size: 0.93rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.scale-pill,
.role-pill,
.confidence-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: var(--radius);
  padding: 5px 9px;
  font-size: 0.82rem;
  font-weight: 820;
}

.scale-pill {
  color: #174a86;
  background: var(--blue-50);
}

.role-pill {
  color: #11623e;
  background: var(--green-50);
}

.confidence-pill {
  color: #8a4f05;
  background: var(--orange-50);
}

.test-list,
.plan-list,
.code-stack {
  display: grid;
  gap: 14px;
}

.test-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--white);
}

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

.test-head strong {
  display: block;
  color: var(--blue-950);
  font-size: 1.08rem;
}

.test-head p,
.test-meta,
.mini-list,
.empty-state p,
.plan-step p,
.code-block p {
  color: #50627d;
}

.rank-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 30px;
  border-radius: var(--radius);
  padding: 5px 10px;
  color: var(--white);
  background: var(--blue-700);
  font-size: 0.82rem;
  font-weight: 850;
}

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

.mini-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--soft);
}

.mini-box h3 {
  margin-bottom: 8px;
}

.mini-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.mini-list li::marker {
  color: var(--blue-700);
}

.answer-line {
  border-left: 3px solid var(--green-600);
  padding: 8px 10px;
  background: var(--green-50);
  color: #244534;
  font-weight: 720;
}

.empty-state {
  border: 1px dashed #bdd0e8;
  border-radius: var(--radius);
  padding: 16px;
  background: var(--soft);
}

.empty-state strong {
  color: var(--blue-950);
}

.plan-step {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: var(--white);
}

.plan-number {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: var(--radius);
  color: var(--white);
  background: var(--blue-700);
  font-weight: 900;
}

.code-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  overflow: hidden;
}

.code-block h3 {
  padding: 13px 14px 0;
}

.code-block p {
  padding: 5px 14px 10px;
}

pre {
  margin: 0;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  padding: 14px;
  background: #08152c;
  color: #eef6ff;
  font-size: 0.9rem;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--blue-950);
  color: var(--white);
  box-shadow: 0 18px 42px rgba(8, 21, 44, 0.22);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .finder-form {
    position: static;
  }

  .result-stack {
    position: static;
    max-height: none;
    overflow: visible;
    min-width: 0;
  }
}

@media (max-width: 760px) {
  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  .topbar,
  .top-actions,
  .form-actions,
  .panel-heading,
  .summary-main,
  .test-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
    padding: 14px 16px;
  }

  .brand {
    justify-content: space-between;
  }

  .brand span {
    display: none;
  }

  .shell {
    width: min(100% - 20px, 680px);
    padding-top: 16px;
  }

  .field-grid,
  .metric-grid,
  .test-grid {
    grid-template-columns: 1fr;
  }

  .copy-button,
  .secondary-button,
  .primary-button {
    width: 100%;
  }

  .score-badge {
    width: 100%;
    min-height: 82px;
  }
}

@media (min-width: 980px) and (min-height: 680px) {
  .workspace {
    gap: 20px;
  }

  .finder-form {
    gap: 12px;
    padding: 18px;
  }

  .result-stack {
    position: sticky;
    top: 92px;
    max-height: calc(100vh - 112px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .field-grid,
  .metric-grid {
    gap: 10px;
  }

  input,
  select {
    min-height: 42px;
    padding-inline: 12px;
  }

  textarea {
    height: 68px;
    min-height: 68px;
    padding: 10px 12px;
  }

  #questionnaire {
    height: 92px;
  }

  .data-box {
    gap: 8px;
    padding: 11px;
  }
}
