:root {
  --paper: #fbfaf7;
  --panel: #ffffff;
  --ink: #202426;
  --muted: #687076;
  --line: #d9dfdc;
  --teal: #1f766f;
  --teal-dark: #14514c;
  --amber: #c07b24;
  --coral: #bf5148;
  --leaf: #567c3b;
  --smoke: #eef2f0;
  --shadow: 0 18px 55px rgba(32, 36, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
}

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

button {
  cursor: pointer;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  padding: 14px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.94);
  backdrop-filter: blur(14px);
}

.brand-block,
.header-actions,
.form-nav,
.panel-tabs,
.progress-label,
.status-band,
.visual-caption {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid #113b38;
  border-radius: 8px;
  background: var(--teal-dark);
  color: #ffffff;
  font-weight: 800;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2.7vw, 2.3rem);
  line-height: 1.08;
}

h3 {
  margin-bottom: 10px;
  font-size: 0.98rem;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--teal-dark);
  border-radius: 8px;
  background: var(--teal-dark);
  color: #ffffff;
  font-weight: 800;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.icon-button.subtle {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.icon-button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(218px, 0.72fr) minmax(420px, 1.72fr) minmax(312px, 0.96fr);
  gap: 18px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px clamp(16px, 3vw, 34px) 36px;
}

.process-rail,
.workspace-panel,
.review-panel {
  min-width: 0;
}

.process-rail,
.review-panel {
  align-self: start;
  position: sticky;
  top: 94px;
}

.status-band {
  gap: 8px;
  width: fit-content;
  margin-bottom: 14px;
  padding: 7px 10px;
  border: 1px solid rgba(86, 124, 59, 0.3);
  border-radius: 999px;
  background: rgba(86, 124, 59, 0.08);
  color: #3a5c27;
  font-size: 0.82rem;
  font-weight: 800;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--leaf);
}

.legal-note {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

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

.step-button {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.step-button span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
}

.step-button strong {
  overflow-wrap: anywhere;
}

.step-button.active {
  border-color: rgba(31, 118, 111, 0.32);
  background: rgba(31, 118, 111, 0.09);
}

.step-button.active span {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.progress-wrap {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.progress-label {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-label strong {
  color: var(--ink);
}

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

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 180ms ease;
}

.rail-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.rail-metrics div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.rail-metrics span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.rail-metrics strong {
  font-size: 1.25rem;
}

.workspace-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.workspace-visual {
  position: relative;
  min-height: 182px;
  background: #e9eeeb;
}

.workspace-visual img {
  display: block;
  width: 100%;
  height: 230px;
  object-fit: cover;
}

.visual-caption {
  position: absolute;
  right: 16px;
  bottom: 14px;
  left: 16px;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(32, 36, 38, 0.12);
  backdrop-filter: blur(8px);
}

.visual-caption span,
.visual-caption strong {
  overflow-wrap: anywhere;
}

.intake-form {
  padding: clamp(18px, 3vw, 30px);
}

.section-heading {
  margin-bottom: 22px;
}

.form-step {
  display: none;
}

.form-step.active {
  display: block;
}

.upload-zone {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 154px;
  margin-bottom: 20px;
  padding: 22px;
  border: 2px dashed rgba(31, 118, 111, 0.36);
  border-radius: 8px;
  background: rgba(31, 118, 111, 0.06);
  text-align: center;
}

.upload-zone.dragging {
  border-color: var(--amber);
  background: rgba(192, 123, 36, 0.09);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-zone svg {
  width: 34px;
  height: 34px;
  color: var(--teal-dark);
}

.upload-zone span {
  font-weight: 800;
}

.upload-zone small {
  color: var(--muted);
}

.field-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

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

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid.compact {
  gap: 10px;
  margin-bottom: 10px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: #394146;
  font-size: 0.86rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd4d0;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

input,
select {
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 11px 12px;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(31, 118, 111, 0.24);
  outline-offset: 2px;
}

.wide-field {
  display: block;
  margin-bottom: 16px;
}

.extract-box,
.handoff-box,
.score-card,
.mini-section,
.review-notes-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.extract-box {
  display: grid;
  grid-template-columns: minmax(160px, 0.72fr) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.extract-box h3 {
  margin-bottom: 0;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.check-grid label,
.experiment-list label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-weight: 700;
}

.check-grid input,
.experiment-list input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  flex: 0 0 auto;
  accent-color: var(--teal);
}

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

.summary-tile {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--smoke);
}

.summary-tile span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-tile strong {
  display: block;
  font-size: 1.12rem;
  overflow-wrap: anywhere;
}

.handoff-box {
  padding: 16px;
}

.form-nav {
  justify-content: space-between;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.review-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(32, 36, 38, 0.08);
}

.panel-tabs {
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  flex: 1 1 0;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab-button.active {
  border-color: rgba(31, 118, 111, 0.28);
  background: rgba(31, 118, 111, 0.09);
  color: var(--teal-dark);
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.active {
  display: block;
}

.score-card {
  padding: 16px;
  background: #f7faf8;
}

.score-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--teal-dark);
  font-size: 1.24rem;
}

.score-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.42;
}

.mini-section {
  margin-top: 12px;
  padding: 14px;
}

.compact-list,
.activity-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.compact-list li {
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--smoke);
  color: #394146;
  line-height: 1.35;
}

.compact-list li.warn {
  background: rgba(192, 123, 36, 0.12);
}

.compact-list li.danger {
  background: rgba(191, 81, 72, 0.12);
}

.activity-list li {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.activity-list strong {
  display: block;
  margin-bottom: 4px;
}

.activity-list span {
  color: var(--muted);
  font-size: 0.78rem;
}

.review-notes-form {
  padding: 14px;
}

.sync-banner {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--smoke);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.sync-banner.ok {
  border-color: rgba(86, 124, 59, 0.28);
  background: rgba(86, 124, 59, 0.08);
  color: #3a5c27;
}

.sync-banner.warn {
  border-color: rgba(192, 123, 36, 0.32);
  background: rgba(192, 123, 36, 0.1);
  color: #7c4d16;
}

.experiment-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(340px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(31, 118, 111, 0.28);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .review-panel {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 780px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions .icon-button {
    flex: 1 1 auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .process-rail {
    position: static;
  }

  .step-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .step-button {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 76px;
    text-align: center;
  }

  .step-button strong {
    font-size: 0.78rem;
  }

  .field-grid.two,
  .field-grid.three,
  .extract-box,
  .check-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .workspace-visual img {
    height: 190px;
  }

  .visual-caption {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .icon-button {
    min-height: 42px;
    padding: 0 11px;
  }

  .header-actions .icon-button span {
    display: none;
  }

  .step-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .intake-form,
  .tab-panel {
    padding: 14px;
  }
}
