:root {
  color-scheme: light;
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-soft: #f9fbfd;
  --text: #172033;
  --muted: #687386;
  --line: #dce5ef;
  --blue: #1769e8;
  --blue-dark: #0f4fb7;
  --blue-soft: #e7f1ff;
  --teal: #6bd8dd;
  --green: #3bb86c;
  --red: #d94747;
  --red-soft: #fff0f0;
  --shadow: 0 12px 34px rgba(31, 50, 72, 0.09);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
  overflow: hidden;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 70px minmax(0, 1fr) 82px;
  padding: 0 18px 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.brand,
.top-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #26334a;
  font-size: 16px;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
  color: #141b29;
}

.top-meta {
  justify-content: flex-end;
  color: #4b5668;
  font-size: 14px;
  font-weight: 500;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(520px, 1fr) 360px;
  gap: 16px;
  min-height: 0;
  overflow: hidden;
  padding-top: 18px;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  overflow: auto;
  padding-bottom: 2px;
}

.panel-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(24, 38, 58, 0.05);
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.section-title strong {
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid #b7d6ff;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 16px;
  white-space: nowrap;
}

.info-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.info-list div {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid #edf2f6;
}

.info-list div:last-child {
  border-bottom: 0;
}

.info-list dt {
  color: var(--muted);
  font-size: 14px;
}

.info-list dd {
  margin: 0;
  min-width: 0;
  color: #273244;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.notice-list {
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

.notice-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  border: 1px solid #e6edf5;
  border-radius: 7px;
  padding: 10px 12px;
  background: var(--surface-soft);
  color: #344154;
  font-size: 14px;
}

.notice-tag {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-left: 6px;
  border-radius: 4px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
}

.notice-time {
  color: #8793a5;
  font-size: 13px;
  white-space: nowrap;
}

.task-list {
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.task-stop {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  min-height: 72px;
  border: 1px solid #e4edf6;
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.task-stop.current {
  border-color: #9dc7ff;
  background: var(--blue-soft);
}

.task-stop.done {
  border-color: #b8e6c9;
  background: #edf9f2;
}

.task-index {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #e6edf5;
  color: #536174;
  font-size: 13px;
  font-weight: 800;
}

.task-stop.current .task-index {
  background: var(--blue);
  color: #fff;
}

.task-stop.done .task-index {
  background: var(--green);
  color: #fff;
}

.task-copy {
  min-width: 0;
}

.task-copy h3 {
  margin: 0;
  color: #1f2d42;
  font-size: 15px;
  line-height: 1.3;
}

.task-copy p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.task-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-top: 8px;
  border-radius: 5px;
  padding: 2px 8px;
  background: #e9eef5;
  color: #526075;
  font-size: 12px;
  font-weight: 700;
}

.task-stop.current .task-status {
  background: #d2e6ff;
  color: var(--blue-dark);
}

.task-stop.done .task-status {
  background: #d9f2e3;
  color: #167043;
}

.map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e7edf2;
  box-shadow: var(--shadow);
}

#factoryScene {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.map-toolbar {
  position: absolute;
  z-index: 5;
  left: 18px;
  top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  max-width: calc(100% - 36px);
  padding: 10px 14px;
  border: 1px solid rgba(220, 229, 239, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 20px rgba(30, 42, 61, 0.08);
  color: #344154;
  font-size: 13px;
}

.legend {
  display: inline-block;
  width: 18px;
  height: 10px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: middle;
}

.legend.route { background: var(--blue); }
.legend.danger { background: repeating-linear-gradient(45deg, rgba(217, 71, 71, 0.25), rgba(217, 71, 71, 0.25) 4px, rgba(217, 71, 71, 0.65) 4px, rgba(217, 71, 71, 0.65) 7px); }
.legend.dock { background: #2f7ff0; border-radius: 50%; width: 12px; height: 12px; }
.legend.warehouse { background: var(--teal); }
.legend.gate { background: var(--green); }

.map-overlays {
  position: absolute;
  z-index: 6;
  left: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
}

.icon-button {
  min-width: 46px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: #314052;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(31, 50, 72, 0.1);
}

.route-status {
  position: absolute;
  z-index: 6;
  right: 18px;
  bottom: 18px;
  min-width: 220px;
  border: 1px solid rgba(23, 105, 232, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  padding: 12px 14px;
  box-shadow: 0 8px 20px rgba(31, 50, 72, 0.1);
}

.route-status strong {
  display: block;
  color: var(--blue);
  font-size: 15px;
  margin-bottom: 6px;
}

.route-status span {
  color: var(--muted);
  font-size: 13px;
}

.route-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.route-summary strong {
  display: block;
  margin-top: 4px;
  color: #1e2a3d;
  font-size: 18px;
}

.step-list {
  list-style: none;
  display: grid;
  gap: 0;
  margin: 8px 0 0;
  padding: 0;
}

.step-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 13px 0;
  border-bottom: 1px solid #edf2f6;
}

.step-item:last-child {
  border-bottom: 0;
}

.step-dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #edf3fb;
  color: #536174;
  font-size: 13px;
  font-weight: 800;
}

.step-item.active .step-dot,
.step-item.done .step-dot {
  background: var(--blue);
  color: #fff;
}

.step-item h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.step-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.step-distance {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.risk-notice {
  margin-top: 14px;
  border: 1px solid #f2c9c9;
  border-radius: 8px;
  background: var(--red-soft);
  padding: 14px;
  color: #8b2d2d;
}

.risk-notice strong {
  display: block;
  margin-bottom: 8px;
  color: var(--red);
  font-size: 15px;
}

.muted {
  margin: 14px 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.command-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding-top: 14px;
}

.primary-action,
.secondary-action {
  min-width: 220px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 18px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.primary-action {
  border-color: var(--blue);
  background: linear-gradient(180deg, #2384ff 0%, var(--blue) 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(23, 105, 232, 0.26);
}

.secondary-action {
  background: #fff;
  color: #35455a;
  box-shadow: 0 8px 18px rgba(31, 50, 72, 0.08);
}

.primary-action:hover,
.secondary-action:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(31, 50, 72, 0.13);
}

.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-rows: auto auto auto;
    padding: 0 12px 14px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 0;
    text-align: left;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .top-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .map-stage,
  #factoryScene {
    height: auto;
    min-height: 560px;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .left-panel .panel-block:last-child,
  .left-panel .task-panel,
  .right-panel .panel-block:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .brand {
    font-size: 14px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .side-panel,
  .route-summary {
    grid-template-columns: 1fr;
  }

  .panel-block {
    padding: 14px;
  }

  .map-toolbar {
    left: 10px;
    top: 10px;
    font-size: 12px;
  }

  .map-stage {
    order: -1;
  }

  .map-stage,
  #factoryScene {
    min-height: 430px;
  }

  .command-bar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
    min-width: 0;
  }
}
