:root {
  color-scheme: light;
  --blue-950: #08152c;
  --blue-900: #102448;
  --blue-700: #2472d0;
  --blue-100: #dcecff;
  --blue-50: #eef6ff;
  --green-700: #12663e;
  --green-600: #198754;
  --green-50: #e9f8f1;
  --orange-700: #a65300;
  --orange-600: #d97706;
  --orange-50: #fff4df;
  --red-700: #9f2424;
  --red-600: #c73636;
  --red-50: #fff0f0;
  --violet-700: #5b4ab8;
  --violet-50: #f1efff;
  --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;
}

* {
  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.35rem;
}

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);
}

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

.brand img {
  display: block;
  width: min(210px, 42vw);
  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);
  white-space: nowrap;
}

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

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 24px;
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.lead {
  max-width: 760px;
  margin-top: 9px;
  color: #50627d;
  font-size: 1.06rem;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 430px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.status-strip span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 13px 15px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.status-strip span + span {
  border-left: 1px solid var(--line);
}

.status-strip strong {
  color: var(--blue-950);
  font-size: 1.28rem;
  line-height: 1;
}

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

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

.input-panel {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 16px;
  padding: 20px;
}

.result-stack {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.summary-panel,
.matrix-panel,
.questions-panel,
.routes-panel {
  padding: 20px;
}

.panel-heading {
  align-items: flex-start;
}

.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: "";
}

.mode-chip {
  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;
}

.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 {
  color: var(--blue-950);
  font-size: 0.95rem;
  font-weight: 850;
}

.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,
.upload-zone h3,
.compact-file span {
  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: 94px;
  resize: none;
  padding: 12px;
  line-height: 1.45;
}

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

  .input-panel {
    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;
  }

  #main-text {
    height: 92px;
  }
}

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

.upload-zone {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--soft);
}

.upload-zone p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

.drop-box {
  display: grid;
  gap: 7px;
  place-items: center;
  min-height: 178px;
  border: 1.5px dashed #b2cae9;
  border-radius: var(--radius);
  padding: 20px;
  background: linear-gradient(180deg, rgba(245, 247, 251, 0.88), #ffffff);
  color: var(--blue-950);
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-box input,
.compact-file input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-box:hover,
.drop-box.dragging {
  border-color: var(--blue-700);
  background: #eef6ff;
  transform: translateY(-1px);
}

.drop-box.has-file {
  border-color: rgba(25, 135, 84, 0.42);
  background: rgba(25, 135, 84, 0.05);
}

.drop-icon {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 999px;
  color: var(--blue-950);
  background: #e8f2ff;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}

.drop-box small {
  color: var(--muted);
}

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

.compact-file {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 94px;
  border: 1px dashed #b2cae9;
  border-radius: var(--radius);
  padding: 12px;
  color: var(--blue-700);
  background: #f8fbff;
  text-align: center;
}

.compact-file:hover,
.compact-file.has-file {
  border-color: var(--blue-700);
  background: var(--blue-50);
}

.compact-file small {
  color: var(--muted);
  font-size: 0.78rem;
}

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

.primary-button,
.secondary-button,
.ghost-button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 820;
  white-space: nowrap;
}

.primary-button {
  border: 1px solid var(--blue-700);
  color: #ffffff;
  background: var(--blue-700);
  box-shadow: 0 12px 26px rgba(36, 114, 208, 0.24);
}

.primary-button:hover {
  background: #1c63b7;
}

.secondary-button,
.ghost-button,
.small-button {
  border: 1px solid var(--line);
  color: var(--blue-950);
  background: var(--white);
}

.secondary-button:hover,
.ghost-button:hover,
.small-button:hover {
  border-color: #b9cbe1;
  background: var(--blue-50);
}

.small-button {
  min-height: 36px;
  padding: 0 11px;
  font-size: 0.88rem;
}

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

.summary-text {
  margin-top: 8px;
  color: #50627d;
}

.score-badge {
  display: grid;
  flex: 0 0 116px;
  width: 116px;
  min-height: 96px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--soft);
  text-align: center;
}

.score-badge strong {
  color: var(--blue-950);
  font-size: 2.1rem;
  line-height: 1;
}

.score-badge span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.score-badge.good {
  border-color: rgba(25, 135, 84, 0.24);
  background: var(--green-50);
}

.score-badge.warning {
  border-color: rgba(217, 119, 6, 0.26);
  background: var(--orange-50);
}

.score-badge.bad {
  border-color: rgba(199, 54, 54, 0.24);
  background: var(--red-50);
}

.score-badge.unknown {
  background: var(--blue-50);
}

.metric-grid {
  margin-top: 18px;
}

.metric-tile {
  min-width: 0;
  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.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-tile strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--blue-950);
}

.matrix-list,
.question-list,
.route-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.matrix-card,
.question-card,
.route-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--white);
}

.matrix-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.matrix-title {
  display: grid;
  gap: 4px;
}

.matrix-title strong,
.route-head strong {
  color: var(--blue-950);
  font-size: 1rem;
}

.matrix-title span {
  color: var(--muted);
  font-size: 0.86rem;
}

.status-pill,
.priority-pill,
.effort-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.good {
  color: var(--green-700);
  background: var(--green-50);
}

.status-pill.bad {
  color: var(--red-700);
  background: var(--red-50);
}

.status-pill.unclear {
  color: var(--orange-700);
  background: var(--orange-50);
}

.status-pill.unchecked {
  color: var(--violet-700);
  background: var(--violet-50);
}

.evidence-block {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.evidence-block span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.evidence-block p {
  color: #324159;
}

.evidence-quote {
  border-left: 3px solid var(--blue-700);
  padding-left: 11px;
  color: #24344d;
  background: linear-gradient(90deg, rgba(238, 246, 255, 0.9), rgba(238, 246, 255, 0));
}

.improvement {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.question-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
}

.question-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  color: var(--orange-700);
  background: var(--orange-50);
  font-weight: 900;
}

.question-card strong {
  color: var(--blue-950);
}

.question-card p {
  margin-top: 3px;
  color: #50627d;
}

.route-card {
  display: grid;
  gap: 10px;
}

.route-head {
  align-items: flex-start;
}

.route-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.priority-pill.high {
  color: var(--red-700);
  background: var(--red-50);
}

.priority-pill.medium {
  color: var(--orange-700);
  background: var(--orange-50);
}

.priority-pill.low {
  color: var(--green-700);
  background: var(--green-50);
}

.effort-pill {
  color: #40516a;
  background: var(--blue-50);
}

.route-card p {
  color: #40516a;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 32px));
  border: 1px solid rgba(16, 36, 72, 0.1);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--blue-950);
  background: var(--white);
  box-shadow: 0 18px 44px rgba(8, 21, 44, 0.16);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 1120px) {
  .tool-header {
    display: grid;
  }

  .status-strip {
    min-width: 0;
    width: 100%;
  }

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

  .input-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    padding: 12px 16px;
  }

  .brand {
    align-items: flex-start;
    gap: 9px;
  }

  .brand img {
    width: 168px;
  }

  .brand span {
    display: none;
  }

  .top-actions {
    gap: 8px;
  }

  .ghost-button span {
    display: none;
  }

  .app-shell {
    width: min(100% - 22px, 760px);
    padding-top: 18px;
  }

  .title-lockup {
    align-items: flex-start;
  }

  h1 {
    font-size: 1.85rem;
  }

  h2 {
    font-size: 1.22rem;
  }

  .lead {
    font-size: 1rem;
  }

  .status-strip,
  .field-grid,
  .metric-grid,
  .supplement-grid {
    grid-template-columns: 1fr;
  }

  .status-strip span + span {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

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

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

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

  .matrix-head {
    grid-template-columns: 1fr;
  }
}
