:root {
  --bg: #f4f7f7;
  --surface: #ffffff;
  --surface-soft: #f9fbfb;
  --line: #dce5e7;
  --line-strong: #c7d4d7;
  --ink: #101b22;
  --navy: #123f5d;
  --muted: #65737e;
  --muted-2: #8897a1;
  --teal: #087b79;
  --teal-dark: #066967;
  --teal-soft: #e8f5f4;
  --green: #14745e;
  --green-soft: #e9f5f1;
  --amber: #d36b18;
  --amber-soft: #fff3e9;
  --red: #b44242;
  --shadow: 0 16px 44px rgba(21, 35, 43, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(8, 123, 121, 0.45);
  outline-offset: 2px;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.app-shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 88px;
  padding: 23px 24px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: flex;
  justify-content: center;
  gap: 4px;
  width: 38px;
  color: var(--teal);
}

.brand-mark i {
  display: block;
  width: 5px;
  border-radius: 6px;
  background: currentColor;
}

.brand-mark i:nth-child(1) {
  height: 28px;
  margin-top: 7px;
}

.brand-mark i:nth-child(2) {
  height: 38px;
}

.brand-mark i:nth-child(3) {
  height: 31px;
  margin-top: 4px;
}

.brand strong,
.brand small {
  display: block;
  min-width: 0;
}

.brand strong {
  font-size: 17px;
  line-height: 20px;
  overflow-wrap: anywhere;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.queue,
.request-facts,
.data-hub {
  padding: 18px 18px 0;
}

.queue {
  padding-bottom: 18px;
}

.side-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.side-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.side-heading strong {
  color: var(--navy);
  font-size: 13px;
}

.request-card {
  display: grid;
  width: 100%;
  min-height: 82px;
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.request-card.active {
  border-color: rgba(8, 123, 121, 0.38);
  background: var(--teal-soft);
  box-shadow: inset 3px 0 0 var(--teal);
}

.request-card span,
.request-card strong,
.request-card small {
  display: block;
  min-width: 0;
}

.request-card span {
  color: var(--muted);
  font-size: 12px;
}

.request-card strong {
  margin-top: 4px;
  font-size: 15px;
  line-height: 19px;
}

.request-card small {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.request-facts dl {
  display: grid;
  gap: 13px;
  margin: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.data-hub ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.data-hub li {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.data-hub span,
.data-hub strong {
  display: block;
  min-width: 0;
}

.data-hub span {
  color: var(--muted);
  font-size: 11px;
  line-height: 14px;
}

.data-hub strong {
  margin-top: 4px;
  color: var(--navy);
  font-size: 16px;
  line-height: 20px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

dd {
  margin: 3px 0 0;
  font-size: 14px;
  line-height: 19px;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  min-height: 88px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.title-block span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

.title-block h1 {
  margin: 3px 0 0;
  font-size: 24px;
  line-height: 30px;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
}

.autosave {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill,
.chip,
.state-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2f3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.state-chip.done,
.chip.ok {
  background: var(--green-soft);
  color: var(--green);
}

.state-chip.current,
.chip.info {
  background: var(--teal-soft);
  color: var(--teal);
}

.chip.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.secondary-button,
.primary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 6px;
  font-weight: 700;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
  box-shadow: 0 8px 18px rgba(8, 123, 121, 0.17);
}

.primary-button:hover {
  background: var(--teal-dark);
}

.text-button {
  min-height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--teal);
}

.stage-rail {
  display: flex;
  gap: 0;
  padding: 14px 28px 0;
  scrollbar-width: none;
}

.stage-rail::-webkit-scrollbar {
  display: none;
}

.stage-step {
  position: relative;
  display: flex;
  flex: 1 1 0;
  gap: 9px;
  align-items: center;
  min-width: 0;
  min-height: 48px;
  padding: 8px 10px 10px;
  border: 0;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.stage-step.active {
  border-bottom-color: var(--teal);
  box-shadow: none;
}

.stage-step.done {
  border-bottom-color: rgba(8, 123, 121, 0.32);
}

.stage-index {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-weight: 800;
}

.stage-step.done .stage-index,
.stage-step.active .stage-index {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.stage-step strong,
.stage-step small {
  display: block;
  min-width: 0;
}

.stage-step strong {
  font-size: 14px;
  line-height: 18px;
}

.stage-step small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  gap: 20px;
  padding: 20px 28px 28px;
}

.workspace,
.next-panel {
  min-width: 0;
}

.workspace {
  display: grid;
  gap: 18px;
}

.next-panel {
  position: sticky;
  top: 20px;
  align-self: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 19px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.next-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 25px;
  letter-spacing: 0;
}

.panel-header p,
.next-panel p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 21px;
}

.panel-body {
  padding: 18px 20px 20px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.82fr);
  gap: 18px;
}

.intake-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 18px;
}

.upload-card {
  display: grid;
  align-self: start;
  align-content: start;
  justify-items: start;
  min-height: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.upload-card.empty {
  border-style: dashed;
  border-color: rgba(8, 123, 121, 0.42);
  background: linear-gradient(180deg, rgba(8, 123, 121, 0.06), rgba(255, 255, 255, 0.9));
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
}

.upload-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-card strong {
  font-size: 17px;
  line-height: 22px;
}

.upload-card p {
  max-width: 340px;
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 21px;
}

.empty-files {
  display: grid;
  place-items: center;
  min-height: 194px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
}

.empty-files strong,
.empty-files span {
  display: block;
}

.empty-files span {
  max-width: 360px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}

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

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

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 39px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.span-2 {
  grid-column: 1 / -1;
}

.doc-list,
.check-list,
.todo-list,
.supply-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-list li,
.check-list li,
.todo-list li,
.supply-list li {
  position: relative;
  min-width: 0;
  padding: 12px 12px 12px 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  line-height: 20px;
}

.doc-list li::before,
.check-list li::before,
.todo-list li::before,
.supply-list li::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 17px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
}

.doc-list li.warn::before,
.check-list li.warn::before,
.todo-list li.warn::before {
  background: var(--amber);
}

.doc-list strong,
.doc-list span,
.check-list strong,
.check-list span {
  display: block;
  min-width: 0;
}

.doc-list span,
.check-list span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.compact-list {
  margin-top: 14px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 0 0 12px;
}

.section-title h3 {
  margin: 0;
  font-size: 15px;
  line-height: 20px;
}

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

.metric {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric span,
.metric strong,
.metric small {
  display: block;
  min-width: 0;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  margin-top: 7px;
  font-size: 22px;
  font-weight: 600;
  line-height: 27px;
  overflow-wrap: anywhere;
}

.metric small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.drawing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.drawing-viewer {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.drawing-viewer img {
  display: block;
  width: 100%;
  height: 418px;
  object-fit: contain;
  filter: grayscale(1) contrast(1.03);
}

.zone-line {
  position: absolute;
  right: 24%;
  top: 34%;
  width: 160px;
  height: 64px;
  border-top: 4px solid var(--teal);
  border-left: 4px solid var(--teal);
  transform: skewX(-28deg);
}

.zone-dot {
  position: absolute;
  right: calc(24% + 154px);
  top: calc(34% + 56px);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 6px rgba(8, 123, 121, 0.15);
}

.zone-label {
  position: absolute;
  right: 12%;
  top: 30%;
  width: 156px;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(21, 35, 43, 0.14);
}

.zone-label strong,
.zone-label span {
  display: block;
}

.zone-label span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.zone-table,
.variant-table,
.offer-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.zone-table th,
.zone-table td,
.variant-table th,
.variant-table td,
.offer-table th,
.offer-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.zone-table th,
.variant-table th,
.offer-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.zone-table tr:last-child td,
.variant-table tr:last-child td,
.offer-table tr:last-child td {
  border-bottom: 0;
}

.row-action {
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.variant-table tr[data-variant] {
  cursor: pointer;
}

.variant-table tr.selected td {
  background: var(--teal-soft);
}

.score-bar {
  display: inline-grid;
  grid-template-columns: 38px 58px;
  gap: 8px;
  align-items: center;
}

.score-bar i {
  display: block;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal) var(--score), #d7e1e3 var(--score));
}

.kit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
}

.equipment-visual {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.equipment-visual img {
  display: block;
  width: 168px;
  max-width: 80%;
  height: auto;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.offer-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.summary-block {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-block span,
.summary-block strong,
.summary-block small {
  display: block;
  min-width: 0;
}

.summary-block span {
  color: var(--muted);
  font-size: 12px;
}

.summary-block strong {
  margin-top: 7px;
  font-size: 20px;
  line-height: 25px;
}

.summary-block small {
  margin-top: 4px;
  color: var(--muted);
}

.next-panel-inner {
  padding: 20px;
}

.next-panel .stage-kicker {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.next-action {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}

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

.decision-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.decision-list li {
  position: relative;
  padding-left: 24px;
  color: #34434c;
  font-size: 13px;
  line-height: 20px;
}

.decision-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--teal);
}

.panel-divider {
  height: 1px;
  margin: 18px 0;
  background: var(--line);
}

.selected-kit {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.selected-kit img {
  display: block;
  width: 84px;
  height: auto;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.selected-kit strong,
.selected-kit span {
  display: block;
}

.selected-kit span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 360px;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 20px 50px rgba(17, 27, 34, 0.22);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

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

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

  .brand {
    grid-template-columns: 1fr;
    justify-items: center;
    padding-inline: 14px;
  }

  .brand span:last-child,
  .queue,
  .request-facts,
  .data-hub {
    display: none;
  }

  .workbench {
    grid-template-columns: minmax(0, 1fr);
  }

  .next-panel {
    position: static;
  }

  .two-column,
  .intake-layout,
  .drawing-layout,
  .kit-layout {
    grid-template-columns: 1fr;
  }

  .metric-strip,
  .offer-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1500px) {
  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    min-height: auto;
    padding: 16px;
  }

  .top-actions,
  .top-actions button {
    width: 100%;
  }

  .stage-rail {
    display: flex;
    overflow-x: auto;
    padding: 14px 16px 0;
    scroll-snap-type: x mandatory;
  }

  .stage-step {
    flex: 0 0 220px;
    scroll-snap-align: start;
  }

  .workbench {
    padding: 16px;
  }

  .panel-header {
    flex-direction: column;
  }

  .field-grid,
  .intake-layout,
  .metric-strip,
  .offer-summary {
    grid-template-columns: 1fr;
  }

  .drawing-viewer {
    min-height: 300px;
  }

  .drawing-viewer img {
    height: 298px;
  }

  .zone-line,
  .zone-dot,
  .zone-label {
    display: none;
  }

  .zone-table,
  .variant-table,
  .offer-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
