@layer legacy {
.vehicle-flow {
  --vehicle-flow-topbar-height: 70px;
  --vehicle-flow-sidebar-height: 0px;
  display: contents;
}

.vehicle-flow-bar {
  position: sticky;
  top: calc(var(--vehicle-flow-topbar-height) + var(--vehicle-flow-sidebar-height));
  z-index: 12;
  margin: 0;
  padding: 12px 16px;
  color: var(--ink, #182b31);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line, #d6e1df);
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(19, 47, 54, 0.04);
  overflow: hidden;
}

.vehicle-flow,
.vehicle-flow * {
  box-sizing: border-box;
}

.vehicle-flow button,
.vehicle-flow a {
  font: inherit;
}

.vehicle-flow-head,
.vehicle-flow-details-head,
.vehicle-flow-detail-title,
.vehicle-flow-item-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.vehicle-flow-head {
  min-height: 26px;
}

.vehicle-flow-title {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 10px;
  overflow: hidden;
}

.vehicle-flow-title strong,
.vehicle-flow-kicker,
.vehicle-flow-announcement {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-flow-kicker {
  color: var(--brand, #c84d34);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.vehicle-flow-title strong {
  color: #415b63;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.vehicle-flow-title .vehicle-flow-kicker {
  color: #536b72;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.vehicle-flow-announcement {
  color: var(--muted, #657779);
  font-size: 11px;
}

.vehicle-flow-overflow {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
}

.vehicle-flow-overflow-note {
  color: var(--muted, #657779);
  font-size: 11px;
}

.vehicle-flow-scroll {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  padding: 0;
  color: var(--ink, #182b31);
  background: var(--paper, #fff);
  border: 1px solid var(--line-strong, #b8cdca);
  border-radius: 7px;
  cursor: pointer;
  line-height: 1;
}

.vehicle-flow-scroll:hover:not(:disabled) {
  color: var(--brand, #c84d34);
  border-color: var(--brand, #c84d34);
}

.vehicle-flow-scroll:disabled {
  color: #a3b1b1;
  cursor: default;
  opacity: 0.55;
}

.vehicle-flow-strip-wrap {
  position: relative;
  min-width: 0;
  margin-top: 7px;
}

.vehicle-flow-strip {
  display: flex;
  min-width: 0;
  margin: 0;
  padding: 0 2px 3px;
  gap: 28px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scroll-behavior: smooth;
  list-style: none;
}

.vehicle-flow-strip:focus-visible {
  outline: 2px solid var(--brand, #c84d34);
  outline-offset: 2px;
}

.vehicle-flow-stage {
  position: relative;
  display: flex;
  min-width: 132px;
  height: 70px;
  flex: 1 0 132px;
  padding: 0;
  border: 0;
  background: transparent;
  scroll-margin-top: calc(var(--vehicle-flow-topbar-height) + 18px);
}

.vehicle-flow-stage-button,
.vehicle-flow-item {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
}

.vehicle-flow-stage-button {
  position: relative;
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
  padding: 12px;
  color: #254b40;
  border-radius: 10px;
  line-height: 1.25;
}

.vehicle-flow-stage-button > .vehicle-flow-stage-label,
.vehicle-flow-stage-button > .vehicle-flow-status,
.vehicle-flow-stage-button > .vehicle-flow-progress,
.vehicle-flow-stage-button > .vehicle-flow-summary {
  line-height: 1.25;
}

.vehicle-flow-item:hover,
.vehicle-flow-item:focus-visible {
  border-color: var(--brand, #c84d34);
  outline: none;
}

.vehicle-flow-stage-label,
.vehicle-flow-item-label,
.vehicle-flow-owner,
.vehicle-flow-summary,
.vehicle-flow-status,
.vehicle-flow-progress {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-flow-stage-label {
  font-size: 14px;
  font-weight: 650;
}

.vehicle-flow-stage-button > .vehicle-flow-status {
  color: #536d65;
  font-size: 12px;
  font-weight: 400;
}

.vehicle-flow-status {
  color: var(--muted, #657779);
  font-size: 10px;
  line-height: 1.35;
}

.vehicle-flow-progress {
  color: var(--ink, #182b31);
  font-size: 10px;
  font-weight: 700;
}

.vehicle-flow-summary,
.vehicle-flow-owner {
  color: var(--muted, #657779);
  font-size: 10px;
  line-height: 1.3;
}

.vehicle-flow-stage-items {
  display: grid;
  max-height: 49px;
  gap: 3px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

.vehicle-flow-item {
  display: block;
  min-height: 25px;
  overflow: hidden;
  padding: 3px 5px;
  color: var(--ink, #182b31);
  background: transparent;
  border-radius: 6px;
  line-height: 1.2;
}

.vehicle-flow-item-label {
  font-size: 11px;
  font-weight: 700;
}

.vehicle-flow-item .vehicle-flow-status,
.vehicle-flow-item .vehicle-flow-owner {
  display: inline;
  font-size: 10px;
  line-height: 1.2;
}

.vehicle-flow-item .vehicle-flow-owner::before {
  content: " · ";
}

.vehicle-flow-stage-empty {
  padding: 4px 5px;
  color: var(--muted, #657779);
  font-size: 10px;
}

.vehicle-flow-stage.state-completed > .vehicle-flow-stage-button {
  border-color: #a0c4b6;
  background: #f3f8f5;
}

.vehicle-flow-stage.state-active > .vehicle-flow-stage-button {
  border-color: #43866c;
  border-style: dashed;
  background: #eaf5ee;
}

.vehicle-flow-stage.state-blocked > .vehicle-flow-stage-button,
.vehicle-flow-stage.state-stale > .vehicle-flow-stage-button,
.vehicle-flow-stage.state-cancelled > .vehicle-flow-stage-button,
.vehicle-flow-stage.state-not_applicable > .vehicle-flow-stage-button {
  color: #596b70;
  border-color: #e0e6e4;
  background: #f2f5f4;
}

.vehicle-flow-stage.state-cancelled > .vehicle-flow-stage-button,
.vehicle-flow-stage.state-cancelled .vehicle-flow-status {
  color: #786262;
}

.vehicle-flow-stage.state-stale > .vehicle-flow-stage-button,
.vehicle-flow-stage.state-stale .vehicle-flow-status {
  color: #876b30;
}

.vehicle-flow-stage-button.is-current::before {
  position: absolute;
  bottom: 12px;
  right: 12px;
  color: #287253;
  content: "当前";
  font-size: 10px;
  font-weight: 650;
  line-height: 15px;
}

.vehicle-flow-stage-button.is-current > .vehicle-flow-status {
  max-width: calc(100% - 30px);
}

.vehicle-flow-stage-button.is-selected:not(:disabled) {
  background: #e3f0e8;
}

.vehicle-flow-stage-button:hover:not(:disabled) {
  background: #e3f0e8;
}

.vehicle-flow-stage-button:focus-visible {
  outline: 2px solid #287253;
  outline-offset: -4px;
}

.vehicle-flow-stage-button:active:not(:disabled) {
  transform: translateY(1px);
}
.vehicle-flow-item.is-current {
  position: relative;
  padding-right: 30px;
}

.vehicle-flow-item.is-selected {
  box-shadow: inset 0 0 0 2px rgba(200, 77, 52, 0.38);
}

.vehicle-flow-item.is-selected {
  background: #fff8f5;
}

.vehicle-flow-siblings {
  display: flex;
  max-width: 100%;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  overflow-x: auto;
  color: var(--muted, #657779);
  font-size: 11px;
  scrollbar-width: thin;
}

.vehicle-flow-siblings > span:first-child {
  flex: 0 0 auto;
}

.vehicle-flow-sibling {
  flex: 0 0 auto;
  padding: 2px 7px;
  color: var(--muted, #657779);
  background: #f3f7f6;
  border: 1px solid var(--line, #d6e1df);
  border-radius: 999px;
  text-decoration: none;
}

.vehicle-flow-sibling:hover,
.vehicle-flow-sibling:focus-visible,
.vehicle-flow-sibling.is-current {
  color: var(--brand, #c84d34);
  border-color: var(--brand, #c84d34);
  outline: none;
}

.vehicle-flow-sibling.is-unavailable {
  color: #8a9897;
}

.vehicle-flow-details {
  margin-top: 9px;
  padding: 12px;
  background: #fbfcfc;
  border-top: 1px solid var(--line, #d6e1df);
}

.vehicle-flow-details-head {
  align-items: flex-start;
  padding-bottom: 8px;
}

.vehicle-flow-selection-note {
  margin: 2px 0 0;
  color: var(--muted, #657779);
  font-size: 12px;
}

.vehicle-flow-return {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 10px;
  white-space: nowrap;
}

.vehicle-flow-detail-panel {
  padding-top: 8px;
}

.vehicle-flow-detail-title {
  align-items: flex-start;
}

.vehicle-flow-detail-title h3,
.vehicle-flow-item-detail-head h4 {
  margin: 2px 0 0;
}

.vehicle-flow-detail-title h3 {
  font-size: 17px;
}

.vehicle-flow-detail-summary,
.vehicle-flow-detail-progress,
.vehicle-flow-notes,
.vehicle-flow-waiting {
  margin: 7px 0;
  color: var(--muted, #657779);
  font-size: 12px;
  white-space: pre-wrap;
}

.vehicle-flow-waiting {
  color: #7b612b;
}

.vehicle-flow-stage-facts,
.vehicle-flow-dependencies ul {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.vehicle-flow-stage-facts li,
.vehicle-flow-dependencies li {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 7px;
  color: var(--muted, #657779);
  background: #f4f7f6;
  border-radius: 6px;
  font-size: 11px;
}

.vehicle-flow-stage-facts li > span:first-child,
.vehicle-flow-stage-facts li > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-flow-stage-facts li > span:last-child {
  text-align: right;
}

.vehicle-flow-item-detail {
  margin-top: 10px;
  padding: 10px;
  background: var(--paper, #fff);
  border: 1px solid var(--line, #d6e1df);
  border-radius: 9px;
}

.vehicle-flow-item-detail.state-completed {
  border-left: 3px solid #4b9c7d;
}

.vehicle-flow-item-detail > summary {
  list-style: none;
}

.vehicle-flow-item-detail > summary::-webkit-details-marker {
  display: none;
}

.vehicle-flow-item-detail > summary > div {
  flex: 1;
}

.vehicle-flow-item-detail > summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  color: var(--muted, #657779);
}

.vehicle-flow-item-detail[open] > summary::before {
  transform: rotate(45deg);
}

.vehicle-flow-item-detail.state-active {
  border-left: 3px dashed #4b9c7d;
}

.vehicle-flow-item-detail.state-blocked,
.vehicle-flow-item-detail.state-stale,
.vehicle-flow-item-detail.state-cancelled,
.vehicle-flow-item-detail.state-not_applicable {
  border-left: 3px solid #b8c4c2;
}

.vehicle-flow-responsibility,
.vehicle-flow-record dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 7px;
  margin: 9px 0;
}

.vehicle-flow-responsibility > div,
.vehicle-flow-record dl > div {
  min-width: 0;
}

.vehicle-flow-responsibility dt,
.vehicle-flow-record dt {
  color: var(--muted, #657779);
  font-size: 10px;
}

.vehicle-flow-responsibility dd,
.vehicle-flow-record dd {
  margin: 1px 0 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.vehicle-flow-dependencies,
.vehicle-flow-records {
  margin-top: 10px;
}

.vehicle-flow-dependencies h5,
.vehicle-flow-records h5 {
  margin: 0;
  font-size: 12px;
}

.vehicle-flow-dependencies li {
  align-items: center;
}

.vehicle-flow-dependency {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  color: var(--brand, #c84d34);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-flow-dependency:focus-visible {
  outline: 2px solid var(--brand, #c84d34);
  outline-offset: 2px;
}

.vehicle-flow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.vehicle-flow-actions .button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.vehicle-flow-disabled-action {
  cursor: not-allowed;
  opacity: 0.62;
}

.vehicle-flow-record {
  margin-top: 7px;
  padding: 8px;
  background: #f8faf9;
  border: 1px solid var(--line, #d6e1df);
  border-radius: 7px;
}

.vehicle-flow-record > strong {
  font-size: 12px;
}

.vehicle-flow-record dl {
  margin-bottom: 0;
}

.vehicle-flow-records-empty {
  margin: 10px 0 0;
  color: var(--muted, #657779);
  font-size: 12px;
}

.vehicle-flow [hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .vehicle-flow {
    --vehicle-flow-topbar-height: 0px;
    --vehicle-flow-sidebar-height: 0px;
  }

  .vehicle-flow-bar {
    top: 0;
    padding: 8px 10px;
    border-radius: 10px;
  }

  .vehicle-flow-head {
    min-height: 22px;
  }

  .vehicle-flow-strip-wrap {
    margin-top: 4px;
  }

  .vehicle-flow-title {
    gap: 5px;
  }

  .vehicle-flow-title strong {
    max-width: 42vw;
  }

  .vehicle-flow-overflow-note {
    display: none;
  }

  .vehicle-flow-stage {
    min-width: 132px;
    height: 58px;
    flex: 0 0 132px;
  }

  .vehicle-flow-stage-button {
    padding: 9px 10px;
    gap: 4px;
  }

  .vehicle-flow-stage-label {
    font-size: 13px;
  }

  .vehicle-flow-stage-button > .vehicle-flow-status {
    font-size: 11px;
  }

  .vehicle-flow-stage-button.is-current::before {
    bottom: 9px;
    right: 10px;
    line-height: 14px;
  }

  .vehicle-flow-details {
    padding: 10px;
  }

  .vehicle-flow-details-head {
    align-items: flex-start;
  }

  .vehicle-flow-responsibility,
  .vehicle-flow-record dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  /* Keep the existing task form reachable on narrow screens with the flow bar. */
  .content:has([data-vehicle-flow]) {
    padding-top: 14px;
  }

  .content:has([data-vehicle-flow]) .vehicle-detail-head {
    gap: 4px;
    margin-bottom: 6px;
    padding: 4px 0;
  }

  .content:has([data-vehicle-flow]) .vehicle-detail-head .back-link {
    margin-bottom: 4px;
    font-size: 13px;
    line-height: 1.2;
  }

  .content:has([data-vehicle-flow]) .vehicle-detail-head h1 {
    margin-bottom: 2px;
    font-size: 20px;
    line-height: 1.2;
  }

  .content:has([data-vehicle-flow]) .vehicle-detail-head p {
    margin: 2px 0;
    font-size: 12px;
    line-height: 1.25;
  }

  .content:has([data-vehicle-flow]) .vehicle-detail-head .actions {
    gap: 4px;
  }

  .content:has([data-vehicle-flow]) .vehicle-detail-head .actions .button {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 13px;
    line-height: 1.2;
  }

  .content:has([data-vehicle-flow]) .vehicle-detail-head .status-badge {
    padding: 2px 6px;
    font-size: 11px;
    line-height: 1.2;
  }

  .content:has([data-vehicle-flow]) #vehicle-task > .vehicle-upstream-facts.contract-task-facts {
    margin: 0 0 4px;
    padding: 0;
  }

  .content:has([data-vehicle-flow]) #vehicle-task > .vehicle-upstream-facts.contract-task-facts .actions {
    gap: 4px;
    line-height: 1.2;
  }

  .content:has([data-vehicle-flow]) #vehicle-task > #vehicle-sales {
    margin-bottom: 4px;
    padding: 0;
  }

  .content:has([data-vehicle-flow]) #vehicle-sales .vehicle-sales-flow {
    gap: 6px;
    margin-top: 0;
  }

  .content:has([data-vehicle-flow]) #vehicle-contract {
    margin-top: 0;
    padding: 6px 8px;
  }

  .content:has([data-vehicle-flow]) #vehicle-contract > summary {
    padding-bottom: 4px;
  }

  .content:has([data-vehicle-flow]) #vehicle-contract .contract-review-card {
    gap: 6px;
    margin-top: 6px;
    padding: 8px;
  }

  .content:has([data-vehicle-flow]) #vehicle-contract .contract-review-card .record-row {
    gap: 6px;
    padding: 4px 0;
  }

  .content:has([data-vehicle-flow]) #vehicle-contract .contract-review-card .compact-form {
    gap: 6px;
    margin-top: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vehicle-flow-strip {
    scroll-behavior: auto;
  }
}

/* Announce selection to assistive technology without repeating it in the compact bar. */
.vehicle-flow-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* Direction stays visible while unavailable stages remain native disabled controls. */
.vehicle-flow-stage:not(:last-child)::after {
  content: "";
  position: absolute;
  left: calc(100% + 5px);
  top: calc(50% - 7px);
  width: 18px;
  height: 14px;
  background: #9bafaa;
  clip-path: polygon(0 33%, 55% 33%, 55% 0, 100% 50%, 55% 100%, 55% 67%, 0 67%);
  pointer-events: none;
}
.vehicle-flow-stage:has(> button:disabled) { cursor: not-allowed; }
.vehicle-flow-stage-button:disabled {
  pointer-events: none;
  opacity: 1;
}

}
