:root {
  --paper: #f1f3f2;
  --surface: #fbfcfb;
  --surface-strong: #ffffff;
  --ink: #142330;
  --ink-2: #263a48;
  --muted: #70808a;
  --line: #cfd7d9;
  --line-strong: #9facb1;
  --accent: #d58b32;
  --accent-dark: #9a5c14;
  --accent-pale: #f6e8d4;
  --blue-pale: #e5edf1;
  --green: #2f765d;
  --green-pale: #e2efe8;
  --danger: #9c4a34;
  --danger-pale: #f4e5df;
  --shadow: 0 20px 55px rgba(20, 35, 48, .1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --sans: Manrope, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(20, 35, 48, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 35, 48, .045) 1px, transparent 1px),
    var(--paper);
  background-size: 20px 20px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}

button,
input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.topbar {
  min-height: 76px;
  padding: 12px clamp(18px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(241, 243, 242, .92);
  border-bottom: 1px solid var(--line-strong);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--surface);
  background: var(--ink);
}

.brand-mark svg {
  width: 31px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.brand-copy strong,
.brand-copy small { display: block; }

.brand-copy strong {
  font-size: 16px;
  letter-spacing: .13em;
}

.brand-copy small,
.technical-label,
.spec-id {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 20px;
}

.safety {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.safety i,
.run-status i,
.dialog-status i {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-pale);
}

.plain-button {
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

main {
  width: min(1540px, calc(100% - 48px));
  margin: 0 auto;
  padding: clamp(36px, 5vw, 72px) 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  gap: clamp(40px, 7vw, 120px);
  align-items: end;
  margin-bottom: 48px;
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--accent-dark);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

h1 {
  max-width: 980px;
  margin: 0;
  font-size: clamp(43px, 6.2vw, 94px);
  font-weight: 680;
  letter-spacing: -.06em;
  line-height: .94;
}

.hero-copy {
  max-width: 500px;
  padding-bottom: 5px;
}

.hero-copy > p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: clamp(15px, 1.3vw, 18px);
}

.start-button {
  width: 100%;
  min-height: 62px;
  padding: 0;
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  border: 1px solid var(--ink);
  color: white;
  background: var(--ink);
  cursor: pointer;
  transition: transform .2s, background .2s;
}

.start-button:hover {
  background: var(--ink-2);
  transform: translateY(-2px);
}

.start-icon {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--accent);
}

.start-label {
  padding: 0 18px;
  text-align: left;
  font-weight: 800;
}

.start-time {
  padding-right: 18px;
  color: #b7c2c8;
  font-family: var(--mono);
  font-size: 11px;
}

.process {
  min-height: 90px;
  margin-bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  position: relative;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  background: rgba(251, 252, 251, .74);
}

.process-line {
  height: 3px;
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--line);
}

.process-line i {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--accent);
  transform: scaleX(var(--manual-progress, 0));
  transform-origin: left center;
  will-change: transform;
}

body.has-started .process-line i {
  animation: process-timeline 42s linear forwards;
  animation-play-state: paused;
}

body.has-started.is-playing .process-line i {
  animation-play-state: running;
}

body[data-stage="4"] .process-line i {
  animation: none;
  transform: scaleX(1);
}

@keyframes process-timeline {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.process-step {
  min-width: 0;
  padding: 17px 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-content: center;
  border: 0;
  border-right: 1px solid var(--line);
  color: #8c999f;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: color .55s var(--ease-soft), background .55s var(--ease-soft);
}

.process-step:last-of-type { border-right: 0; }
.process-step:disabled { cursor: default; }

.process-step > span {
  grid-row: 1 / 3;
  align-self: center;
  color: var(--line-strong);
  font-family: var(--mono);
  font-size: 11px;
}

.process-step strong {
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-step small {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-step.is-active {
  color: var(--ink);
  background: var(--surface-strong);
}

.process-step.is-active > span { color: var(--accent-dark); }

.process-step.is-done {
  color: var(--green);
  background: var(--green-pale);
}

.workbench {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workbench-head {
  min-height: 82px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line-strong);
  background:
    linear-gradient(90deg, rgba(213, 139, 50, .08), transparent 36%),
    var(--surface-strong);
}

.workbench-head h2 {
  margin: 4px 0 0;
  font-size: 24px;
  letter-spacing: -.03em;
}

.workbench-head h2,
.run-status,
.workbench-controls > p {
  transition:
    opacity .28s var(--ease-soft),
    transform .38s var(--ease-out);
}

body.is-stage-changing .workbench-head h2,
body.is-stage-changing .run-status,
body.is-stage-changing .workbench-controls > p {
  opacity: 0;
  transform: translateY(7px);
}

body.is-stage-entering .workbench-head h2,
body.is-stage-entering .run-status,
body.is-stage-entering .workbench-controls > p {
  animation: stage-copy-in .62s var(--ease-out) both;
}

@keyframes stage-copy-in {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

.run-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
}

.run-status i {
  background: var(--line-strong);
  box-shadow: 0 0 0 4px var(--blue-pale);
}

body.is-playing .run-status i {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-pale);
  animation: pulse 1.3s infinite;
}

body[data-stage="4"] .run-status i {
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-pale);
  animation: none;
}

@keyframes pulse {
  50% { transform: scale(.65); opacity: .55; }
}

.work-grid {
  min-height: 690px;
  display: grid;
  grid-template-columns: minmax(300px, .92fr) minmax(420px, 1.32fr) minmax(260px, .76fr);
}

.mail-sheet,
.analysis-board,
.result-rail {
  min-width: 0;
  position: relative;
}

.mail-sheet,
.analysis-board {
  border-right: 1px solid var(--line-strong);
}

.mail-sheet {
  padding: 24px;
  background:
    linear-gradient(rgba(20, 35, 48, .025) 1px, transparent 1px),
    var(--surface-strong);
  background-size: 100% 28px;
}

.sheet-head,
.board-head,
.drawing-card header,
.result-rail > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.sheet-head {
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}

.sheet-head strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.mail-state,
.match-state {
  padding: 5px 8px;
  color: var(--accent-dark);
  background: var(--accent-pale);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
}

.sender {
  padding: 18px 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--line);
}

.sender-logo {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
}

.sender strong,
.sender span { display: block; }

.sender span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.sender time {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.mail-subject {
  padding: 20px 0 13px;
}

.mail-subject > span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.mail-subject h3 {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.16;
  letter-spacing: -.03em;
}

.mail-body {
  color: #384b57;
  font-size: 13px;
}

.mail-body p { margin: 0 0 12px; }

.request-line {
  padding: 2px 5px;
  transition:
    color .65s var(--ease-soft),
    background .65s var(--ease-soft),
    box-shadow .65s var(--ease-soft),
    transform .65s var(--ease-out);
}

body[data-stage="1"] .request-line,
body[data-stage="2"] .request-line,
body[data-stage="3"] .request-line,
body[data-stage="4"] .request-line {
  color: var(--ink);
  background: var(--accent-pale);
  box-shadow: inset 3px 0 var(--accent);
  transform: translateX(3px);
}

.request-line[data-token="item"] { transition-delay: .08s; }
.request-line[data-token="alloy"] { transition-delay: .18s; }
.request-line[data-token="delivery"] { transition-delay: .28s; }

.attachment {
  margin-top: 20px;
  padding: 11px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.attachment-type {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink-2);
  font-family: var(--mono);
  font-size: 9px;
}

.attachment strong,
.attachment small { display: block; }
.attachment strong { font-size: 11px; }
.attachment small { color: var(--muted); font-size: 9px; }
.attachment-check { color: var(--green); font-weight: 900; }

.extract-overlay {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  position: absolute;
  right: 24px;
  bottom: 24px;
  left: 24px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .7s var(--ease-soft), transform .75s var(--ease-out);
}

.extract-overlay span {
  padding: 5px 7px;
  border: 1px solid var(--accent);
  color: var(--accent-dark);
  background: rgba(246, 232, 212, .94);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .5s var(--ease-soft), transform .65s var(--ease-out);
}

body[data-stage="1"] .extract-overlay,
body[data-stage="2"] .extract-overlay,
body[data-stage="3"] .extract-overlay,
body[data-stage="4"] .extract-overlay {
  opacity: 1;
  transform: none;
}

body:not([data-stage="0"]) .extract-overlay span {
  opacity: 1;
  transform: none;
}

.extract-overlay span:nth-child(1) { transition-delay: .12s; }
.extract-overlay span:nth-child(2) { transition-delay: .22s; }
.extract-overlay span:nth-child(3) { transition-delay: .32s; }
.extract-overlay span:nth-child(4) { transition-delay: .42s; }

.analysis-board {
  overflow: hidden;
  background:
    linear-gradient(rgba(20, 35, 48, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 35, 48, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 20px 20px;
}

.board-empty {
  min-height: 690px;
  padding: 40px;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  transition:
    opacity .48s var(--ease-soft),
    visibility .48s,
    transform .58s var(--ease-out);
}

.board-empty strong {
  margin-top: 22px;
  font-size: 19px;
}

.board-empty p {
  max-width: 340px;
  margin: 8px 0 0;
  color: var(--muted);
}

.scan-target {
  width: 112px;
  height: 112px;
  display: block;
  position: relative;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(90deg, transparent 49%, var(--line) 50%, transparent 51%),
    linear-gradient(transparent 49%, var(--line) 50%, transparent 51%);
}

.scan-target::before,
.scan-target::after {
  width: 24px;
  height: 24px;
  content: "";
  position: absolute;
  border-color: var(--accent);
  border-style: solid;
}

.scan-target::before {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
}

.scan-target::after {
  right: -1px;
  bottom: -1px;
  border-width: 0 2px 2px 0;
}

.analysis-content {
  min-height: 690px;
  padding: 24px;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition:
    opacity .65s var(--ease-soft),
    visibility .65s,
    transform .72s var(--ease-out);
}

body:not([data-stage="0"]) .board-empty {
  opacity: 0;
  visibility: hidden;
}

body:not([data-stage="0"]) .analysis-content {
  opacity: 1;
  visibility: visible;
  transform: none;
}

body.is-stage-changing .analysis-content {
  opacity: .42;
  transform: translateY(7px);
}

.board-head h3 {
  margin: 4px 0 0;
  font-size: 22px;
  letter-spacing: -.03em;
}

.confidence {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--green);
  font-family: var(--mono);
  font-size: 11px;
}

.confidence i {
  width: 50px;
  height: 4px;
  overflow: hidden;
  position: relative;
  background: var(--line);
}

.confidence i::after {
  width: var(--confidence, 0%);
  height: 100%;
  content: "";
  display: block;
  background: var(--green);
  transition: width .7s ease;
}

.field-grid {
  margin: 20px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.field-grid > div {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .76);
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity .55s var(--ease-soft),
    transform .7s var(--ease-out);
}

body:not([data-stage="0"]) .field-grid > div {
  opacity: 1;
  transform: none;
}

.field-grid > div:nth-child(1) { transition-delay: .08s; }
.field-grid > div:nth-child(2) { transition-delay: .14s; }
.field-grid > div:nth-child(3) { transition-delay: .20s; }
.field-grid > div:nth-child(4) { transition-delay: .26s; }
.field-grid > div:nth-child(5) { transition-delay: .32s; }
.field-grid > div:nth-child(6) { transition-delay: .38s; }

.field-grid dt,
.drawing-spec span,
.paper-terms span,
.dialog-fields dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.field-grid dd {
  margin: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono { font-family: var(--mono); }

.drawing-card {
  border: 1px solid var(--line-strong);
  background: rgba(251, 252, 251, .86);
  opacity: .34;
  transform: translateY(9px) scale(.992);
  transition:
    opacity .75s var(--ease-soft),
    transform .85s var(--ease-out),
    border-color .75s var(--ease-soft);
}

body[data-stage="2"] .drawing-card,
body[data-stage="3"] .drawing-card,
body[data-stage="4"] .drawing-card {
  opacity: 1;
  transform: none;
  border-color: var(--line-strong);
}

.drawing-card header {
  min-height: 40px;
  padding: 10px 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.drawing-space {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  align-items: stretch;
}

.insert-drawing {
  width: 100%;
  min-height: 220px;
  padding: 12px;
}

.insert-drawing text {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.axis {
  fill: none;
  stroke: var(--line);
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.dimension,
.leader {
  fill: none;
  stroke: var(--accent-dark);
  stroke-width: 1;
}

.insert-shape {
  fill: var(--accent-pale);
  stroke: var(--ink);
  stroke-width: 2;
}

.insert-hatch {
  fill: url(#hatch);
  stroke: var(--ink);
  stroke-width: 1;
}

#hatch line {
  stroke: rgba(20, 35, 48, .16);
  stroke-width: 1;
}

.insert-hole {
  fill: var(--surface-strong);
  stroke: var(--ink);
  stroke-width: 1.5;
}

.insert-hole-inner {
  fill: var(--paper);
  stroke: var(--accent-dark);
  stroke-width: 1;
}

.drawing-spec {
  border-left: 1px solid var(--line);
}

.drawing-spec p {
  margin: 0;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.drawing-spec p:last-child { border-bottom: 0; }
.drawing-spec span,
.drawing-spec strong { display: block; }
.drawing-spec strong { font-size: 11px; }

.match-state { color: var(--muted); background: var(--blue-pale); }

body[data-stage="2"] .match-state,
body[data-stage="3"] .match-state,
body[data-stage="4"] .match-state {
  color: var(--green);
  background: var(--green-pale);
}

.attention-list {
  margin-top: 18px;
  opacity: .38;
  transform: translateY(10px);
  pointer-events: none;
  transition:
    opacity .7s var(--ease-soft),
    transform .8s var(--ease-out);
}

body[data-stage="3"] .attention-list,
body[data-stage="4"] .attention-list {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.attention-title {
  margin: 0 0 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.attention-title span {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--danger);
  font-family: var(--mono);
}

.attention-list label {
  min-height: 48px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface-strong);
  cursor: pointer;
}

.attention-list input {
  width: 1px;
  height: 1px;
  position: absolute;
  opacity: 0;
}

.check-ui {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: transparent;
  background: var(--paper);
  transform: scale(.94);
  transition:
    color .3s var(--ease-soft),
    background .45s var(--ease-soft),
    border-color .45s var(--ease-soft),
    transform .55s var(--ease-out);
}

.attention-list input:checked + .check-ui {
  border-color: var(--green);
  color: white;
  background: var(--green);
  transform: none;
}

.attention-list strong,
.attention-list small { display: block; }
.attention-list strong { font-size: 11px; }
.attention-list small { color: var(--muted); font-size: 9px; }

.approve-button {
  width: 100%;
  min-height: 48px;
  padding: 0 15px;
  border: 1px solid var(--ink);
  color: white;
  background: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.approve-button:disabled {
  border-color: var(--line);
  color: #a5afb3;
  background: var(--paper);
  cursor: default;
}

.result-rail {
  padding: 24px;
  background: #edf0ef;
}

.result-rail > header {
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-strong);
}

.result-counter {
  font-family: var(--mono);
  font-size: 11px;
}

.result-counter b { color: var(--accent-dark); }

.result-item {
  min-height: 70px;
  padding: 13px 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  opacity: .38;
  transition: opacity .65s var(--ease-soft), transform .75s var(--ease-out);
}

.result-item.is-ready {
  opacity: 1;
  transform: translateX(5px);
}

.result-item:nth-of-type(2) { transition-delay: .12s; }
.result-item:nth-of-type(3) { transition-delay: .24s; }
.result-item:nth-of-type(4) { transition-delay: .36s; }

.result-icon {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 9px;
}

.result-item.is-ready .result-icon {
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.result-item strong,
.result-item small { display: block; }
.result-item strong { font-size: 12px; }
.result-item small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.result-item > i { color: var(--green); font-style: normal; font-weight: 900; opacity: 0; }
.result-item > i { transform: scale(.7); transition: opacity .4s .28s, transform .55s .28s var(--ease-out); }
.result-item.is-ready > i { opacity: 1; transform: none; }

.crm-preview {
  margin-top: 20px;
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  opacity: .35;
  transform: translateY(8px);
  transition: opacity .75s .24s var(--ease-soft), transform .85s .24s var(--ease-out);
}

body[data-stage="4"] .crm-preview {
  opacity: 1;
  transform: none;
}

.preview-title {
  min-height: 44px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: white;
  background: var(--ink);
}

.preview-title span {
  padding: 3px 5px;
  color: var(--ink);
  background: var(--accent);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 900;
}

.preview-title strong { font-size: 11px; }

.crm-preview dl { margin: 0; }

.crm-preview dl > div {
  padding: 9px 11px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.crm-preview dl > div:last-child { border-bottom: 0; }
.crm-preview dt { color: var(--muted); font-size: 9px; }
.crm-preview dd { margin: 0; text-align: right; font-size: 9px; font-weight: 700; }
.crm-preview dd span { padding: 3px 5px; color: var(--green); background: var(--green-pale); }

.result-actions {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  font-weight: 800;
  cursor: pointer;
  transition:
    color .3s var(--ease-soft),
    background .3s var(--ease-soft),
    border-color .3s var(--ease-soft),
    transform .35s var(--ease-out);
}

.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover,
.approve-button:not(:disabled):hover,
.nav-button:not(:disabled):hover {
  transform: translateY(-2px);
}

.primary-button {
  color: white;
  background: var(--ink);
}

.secondary-button {
  color: var(--ink);
  background: transparent;
}

.primary-button:disabled,
.secondary-button:disabled {
  border-color: var(--line);
  color: #9da8ad;
  background: transparent;
  cursor: default;
}

.workbench-controls {
  min-height: 68px;
  padding: 12px 18px 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line-strong);
  background: var(--surface-strong);
}

.workbench-controls > p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.workbench-controls > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--surface);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.nav-button:disabled { color: #a8b1b5; cursor: default; }

.nav-next {
  border-color: var(--ink);
  color: white;
  background: var(--ink);
}

.step-count {
  min-width: 58px;
  text-align: center;
  font-family: var(--mono);
  font-size: 9px;
}

.step-count b { color: var(--accent-dark); }

.outcome {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
  background: rgba(251, 252, 251, .68);
}

.outcome article {
  min-height: 150px;
  padding: 24px;
  border-right: 1px solid var(--line-strong);
}

.outcome article:last-child { border-right: 0; }

.outcome article > span {
  color: var(--accent-dark);
  font-family: var(--mono);
  font-size: 10px;
}

.outcome strong {
  max-width: 320px;
  margin-top: 15px;
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.outcome p {
  max-width: 340px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.demo-disclaimer {
  max-width: 980px;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

dialog {
  width: min(920px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 0;
  color: var(--ink);
  background: transparent;
}

dialog[open] {
  animation: dialog-in .48s var(--ease-out) both;
}

dialog::backdrop {
  background: rgba(8, 17, 24, .72);
  backdrop-filter: blur(5px);
}

dialog[open]::backdrop {
  animation: backdrop-in .38s var(--ease-soft) both;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(18px) scale(.985); }
  to { opacity: 1; transform: none; }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dialog-shell {
  padding: 30px;
  position: relative;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .32);
}

.dialog-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  position: absolute;
  top: 11px;
  right: 11px;
  z-index: 3;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--surface-strong);
  font-size: 22px;
  cursor: pointer;
}

.paper {
  min-height: 570px;
  padding: clamp(24px, 5vw, 58px);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(rgba(20, 35, 48, .025) 1px, transparent 1px),
    white;
  background-size: 100% 26px;
}

.paper-stamp {
  padding: 6px 9px;
  position: absolute;
  top: 23px;
  right: 23px;
  border: 2px solid var(--danger);
  color: var(--danger);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 900;
  transform: rotate(-4deg);
}

.paper-head {
  padding-bottom: 20px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 2px solid var(--ink);
}

.paper-head > div:last-child { padding-right: 120px; text-align: right; }
.paper-head strong,
.paper-head span,
.paper-head small { display: block; }
.paper-head strong { font-size: 18px; }
.paper-head span { font-family: var(--mono); font-size: 10px; font-weight: 900; }
.paper-head small { margin-top: 4px; color: var(--muted); font-size: 9px; }

.paper-address {
  padding: 22px 0;
}

.paper-address span,
.paper-address strong,
.paper-address small { display: block; }
.paper-address span { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.paper-address strong { margin-top: 3px; font-size: 16px; }
.paper-address small { color: var(--muted); font-size: 10px; }

.paper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.paper th,
.paper td {
  padding: 10px;
  border: 1px solid var(--line-strong);
  text-align: left;
}

.paper th {
  color: white;
  background: var(--ink);
  font-family: var(--mono);
  font-size: 8px;
  text-transform: uppercase;
}

.paper td strong,
.paper td small { display: block; }
.paper td small { color: var(--muted); font-size: 9px; }

.paper-terms {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.paper-terms p {
  margin: 0;
  padding: 12px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.paper-terms span,
.paper-terms strong { display: block; }
.paper-terms strong { font-size: 10px; }

.paper-note {
  margin-top: 20px;
  padding: 12px;
  color: var(--accent-dark);
  background: var(--accent-pale);
  font-size: 10px;
}

.crm-dialog-shell {
  width: min(620px, 100%);
  margin: 0 auto;
}

.crm-dialog-shell h2 {
  margin: 7px 0 17px;
  font-size: 34px;
  letter-spacing: -.04em;
}

.dialog-status {
  width: fit-content;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--green);
  background: var(--green-pale);
  font-size: 11px;
  font-weight: 800;
}

.dialog-fields {
  margin: 22px 0 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.dialog-fields > div {
  padding: 14px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface-strong);
}

.dialog-fields dd {
  margin: 0;
  font-size: 12px;
  font-weight: 750;
}

@media (max-width: 1180px) {
  .work-grid {
    grid-template-columns: minmax(280px, .9fr) minmax(410px, 1.1fr);
  }

  .result-rail {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 18px;
    border-top: 1px solid var(--line-strong);
  }

  .result-rail > header,
  .crm-preview,
  .result-actions { grid-column: 1 / -1; }

  .result-item { border-right: 1px solid var(--line); padding-right: 14px; }
  .result-item:nth-of-type(3) { border-right: 0; }
  .crm-preview dl { display: grid; grid-template-columns: repeat(2, 1fr); }
  .result-actions { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .topbar-meta .spec-id { display: none; }
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .hero-copy { max-width: 680px; }
  .process { min-height: 76px; }
  .process-step { padding: 13px 10px; grid-template-columns: 1fr; }
  .process-step > span { grid-row: auto; }
  .process-step small { display: none; }
  .work-grid { grid-template-columns: 1fr; }
  .mail-sheet,
  .analysis-board { border-right: 0; border-bottom: 1px solid var(--line-strong); }
  .mail-sheet { min-height: 620px; }
  .analysis-board,
  .analysis-content,
  .board-empty { min-height: 700px; }
  .extract-overlay { position: static; margin-top: 18px; }
  .outcome { grid-template-columns: 1fr; }
  .outcome article { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line-strong); }
  .outcome article:last-child { border-bottom: 0; }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 66px;
    padding: 10px 16px;
  }

  .brand-mark { width: 38px; height: 38px; }
  .brand-copy small,
  .safety { display: none; }
  .topbar-meta { gap: 12px; }
  main { width: calc(100% - 24px); padding-top: 28px; }
  h1 { font-size: clamp(40px, 13vw, 62px); }
  .hero { margin-bottom: 31px; }
  .start-button { grid-template-columns: 52px 1fr auto; min-height: 54px; }
  .process {
    grid-template-columns: repeat(5, minmax(62px, 1fr));
    overflow-x: auto;
  }
  .process-step {
    min-width: 62px;
    padding: 11px 7px;
    text-align: center;
  }
  .process-step strong { font-size: 9px; }
  .process-step > span { font-size: 8px; }
  .workbench-head { padding: 15px; align-items: flex-start; }
  .workbench-head h2 { font-size: 19px; }
  .run-status { max-width: 94px; justify-content: flex-end; text-align: right; }
  .mail-sheet,
  .analysis-content,
  .result-rail { padding: 17px; }
  .mail-sheet { min-height: auto; }
  .mail-subject h3 { font-size: 18px; }
  .sender { grid-template-columns: auto 1fr; }
  .sender time { grid-column: 2; }
  .analysis-board,
  .analysis-content,
  .board-empty { min-height: 780px; }
  .field-grid { grid-template-columns: 1fr; }
  .drawing-space { grid-template-columns: 1fr; }
  .drawing-spec {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border-top: 1px solid var(--line);
    border-left: 0;
  }
  .drawing-spec p { border-right: 1px solid var(--line); }
  .result-rail { display: block; }
  .result-item { border-right: 0; }
  .crm-preview dl { display: block; }
  .result-actions { grid-template-columns: 1fr; }
  .workbench-controls { padding: 12px; display: block; }
  .workbench-controls > p { margin-bottom: 10px; }
  .workbench-controls > div { justify-content: space-between; }
  .nav-button { flex: 1; }
  .paper-head { display: block; }
  .paper-head > div:last-child { margin-top: 16px; padding-right: 0; text-align: left; }
  .paper-stamp { top: 18px; right: 18px; }
  .paper-terms,
  .dialog-fields { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .hero-copy > p { font-size: 14px; }
  .start-time { display: none; }
  .start-button { grid-template-columns: 50px 1fr; }
  .workbench-head .technical-label { font-size: 8px; }
  .run-status span { font-size: 8px; }
  .analysis-board,
  .analysis-content,
  .board-empty { min-height: 805px; }
  .insert-drawing { min-height: 190px; padding: 4px; }
  .dialog-shell { padding: 12px; }
  .paper { padding: 58px 14px 24px; }
  .paper table { font-size: 9px; }
  .paper th,
  .paper td { padding: 7px 5px; }
  .paper th:nth-child(1),
  .paper td:nth-child(1) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
