:root {
  --canvas: #eef6ff;
  --surface: #ffffff;
  --surface-soft: #f5f9ff;
  --ink: #1f2a3d;
  --body: #244263;
  --muted: #7186a3;
  --hairline: #d3e2f7;
  --primary: #1468ff;
  --danger: #e60012;
  --danger-soft: #ffecec;
  --warning: #f08a00;
  --warning-soft: #fff4df;
  --blocked: #d97800;
  --success: #11845b;
  --success-soft: #e8f8f0;
  --shadow: 0 12px 32px rgba(21, 87, 180, 0.1);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--canvas);
}

button,
select {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

.shell {
  position: fixed;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  padding: 8px 14px;
  overflow: hidden;
  transform-origin: top left;
}

.topbar {
  display: grid;
  grid-template-columns: 560px 1fr 360px;
  align-items: center;
  height: 48px;
  padding: 0 18px;
  background: linear-gradient(90deg, #ffffff 0%, #dfe8ff 48%, #ffffff 100%);
  border: 1px solid var(--hairline);
  border-radius: 6px;
}

.filters {
  display: flex;
  gap: 26px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.filters label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.filters select {
  width: 118px;
  height: 26px;
  border: 1px solid #cfd8ea;
  border-radius: 4px;
  color: #7d8ca4;
  background: #fff;
  padding: 0 8px;
}

.topbar h1 {
  color: #3478f6;
  font-size: 27px;
  line-height: 1;
  text-align: center;
}

.clock {
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  text-align: right;
}

.dashboard {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  height: calc(100% - 60px);
  margin-top: 10px;
}

.sidebar,
.content {
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: grid;
  grid-template-rows: 340px minmax(0, 1fr);
  gap: 12px;
}

.panel,
.toolbar,
.stage-row {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel {
  padding: 16px;
}

.warehouse-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #bed5ff;
  border-radius: 999px;
  color: var(--primary);
  background: #edf5ff;
  font-weight: 850;
}

.panel h2 {
  margin-top: 14px;
  font-size: 18px;
}

.donut {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  margin: 26px auto 18px;
  border-radius: 50%;
  background: conic-gradient(var(--danger) 0 45%, var(--primary) 45% 82%, #dce8ff 82% 100%);
}

.donut > div {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #fff;
}

.donut span {
  color: var(--muted);
  font-size: 13px;
}

.donut strong {
  font-size: 32px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.metric-grid article {
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: #edf5ff;
}

.metric-grid span,
.stage-mini p {
  color: var(--muted);
  font-size: 12px;
}

.metric-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.danger-text {
  color: var(--danger);
}

.info-text {
  color: var(--primary);
}

.stage-stat {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
}

.stage-stat h2 {
  margin: 0 0 2px;
}

.stage-mini {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px dashed color-mix(in srgb, var(--stage-color), white 35%);
  border-radius: 6px;
  background: color-mix(in srgb, var(--stage-color), white 94%);
}

.stage-mini b {
  color: var(--stage-color);
  font-size: 14px;
}

.stage-mini span {
  color: var(--body);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.content {
  display: grid;
  grid-template-rows: 50px minmax(0, 1fr);
  gap: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
}

.tabs {
  display: inline-flex;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-soft);
}

.tabs button {
  height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  color: var(--body);
  background: transparent;
  cursor: pointer;
  font-weight: 900;
}

.tabs button.active {
  color: #fff;
  background: var(--primary);
}

.quick-stats {
  display: flex;
  gap: 24px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.quick-stats b {
  color: var(--ink);
  font-size: 18px;
}

.board-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.order-board {
  gap: 12px;
}

.order-card {
  flex: 0 0 auto;
  display: grid;
  grid-template-rows: auto auto auto;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: none;
  overflow: hidden;
}

.order-card-head {
  display: grid;
  grid-template-columns: 54px 300px minmax(0, 1fr);
  align-items: center;
  min-height: 74px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  background: #fff;
}

.order-rank {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #d0d7e2;
  border-radius: 4px;
  color: var(--ink);
  background: #f4f4f4;
  font-size: 17px;
  font-weight: 900;
}

.order-title {
  min-width: 0;
}

.warehouse-link {
  color: var(--primary);
  font-weight: 950;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.warehouse-link:hover,
.oms-link:hover {
  color: var(--primary-strong);
}

.oms-link {
  color: var(--body);
  text-decoration: none;
}

.order-title .warehouse-link {
  display: inline-block;
  margin-left: 8px;
  font-size: 17px;
  vertical-align: middle;
}

.order-title .oms-link {
  display: block;
  margin-top: 4px;
  margin-left: 72px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.order-summary span {
  min-height: 36px;
  padding: 8px 10px;
  border-left: 3px solid #d0d7e2;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.order-summary b {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chain-detail-list {
  display: grid;
  gap: 8px;
  padding: 10px 14px 12px 70px;
  background: #fff;
}

.chain-detail {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.chain-detail-head {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 110px;
  align-items: center;
  min-height: 38px;
  padding: 6px 10px;
  border-bottom: 1px solid #e8edf5;
  background: #f8fafc;
}

.chain-detail-head strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
}

.chain-node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1px;
  background: #e8edf5;
}

.chain-node {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  grid-template-areas:
    "stage range status"
    "stage metrics person";
  align-items: center;
  gap: 4px 8px;
  min-height: 64px;
  padding: 8px 10px;
  background: #fff;
  overflow: hidden;
}

.node-stage {
  grid-area: stage;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 4px;
  color: var(--body);
  background: #edf2f7;
  font-weight: 950;
}

.node-range {
  grid-area: range;
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.node-status {
  grid-area: status;
  justify-self: end;
  min-width: 52px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 950;
}

.node-person {
  grid-area: person;
  justify-self: end;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.node-metrics {
  grid-area: metrics;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.node-metric {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #f4f4f4;
  color: var(--body);
  font-size: 12px;
  font-weight: 800;
}

.chain-node.timeout .node-stage,
.chain-node.timeout .node-status {
  color: var(--danger);
  background: var(--danger-soft);
}

.chain-node.warning .node-stage,
.chain-node.warning .node-status {
  color: var(--primary);
  background: #e9f1ff;
}

.chain-node.blocked .node-stage,
.chain-node.blocked .node-status {
  color: var(--blocked);
  background: var(--warning-soft);
}

.chain-node.normal .node-stage,
.chain-node.normal .node-status {
  color: var(--success);
  background: var(--success-soft);
}

.single-detail-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 12px 70px;
  background: #fff;
}

.single-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #d0d7e2;
  border-radius: 999px;
  color: var(--body);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 800;
}

.stage-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  min-height: 0;
}

.stage-row:not(.chain-section) {
  flex: 1 1 0;
}

.chain-section {
  flex: 1 1 auto;
}

.stage-label {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--stage-color);
  font-weight: 950;
  text-align: center;
}

.stage-label span {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 23px;
}

.stage-label strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.chain-label {
  background: #1f2a3d;
}

.stage-body {
  min-width: 0;
  overflow: hidden;
}

.stage-scroll {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: #b8c5d8 transparent;
  scrollbar-width: thin;
}

.stage-scroll::-webkit-scrollbar {
  width: 6px;
}

.stage-scroll::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: #b8c5d8;
}

table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th {
  height: 34px;
  padding: 5px 8px;
  color: var(--ink);
  background: #fbfcfe;
  border-bottom: 1px solid var(--hairline);
  font-size: 15px;
  font-weight: 950;
  text-align: center;
  white-space: nowrap;
}

td {
  height: 42px;
  padding: 5px 8px;
  color: #222;
  border-bottom: 1px solid #edf1f6;
  font-size: 15px;
  line-height: 1.18;
  text-align: center;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: 0;
}

.stage-table th:first-child,
.stage-table td:first-child {
  width: 70px;
}

.chain-table th:nth-child(1) {
  width: 80px;
}

.chain-table th:nth-child(2) {
  width: 120px;
}

.chain-table th:nth-child(3) {
  width: 210px;
}

.chain-table th:nth-child(4) {
  width: 190px;
}

.chain-table th:nth-child(5) {
  width: 160px;
}

.chain-table th:nth-child(6) {
  width: 120px;
}

.chain-table th:nth-child(7) {
  width: 140px;
}

.chain-table th:nth-child(8),
.chain-table th:nth-child(9) {
  width: 110px;
}

.chain-table th:nth-child(10) {
  width: 100px;
}

.order-cell {
  text-align: left;
}

.order-cell .warehouse-link {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  max-width: 180px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-cell .oms-link {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  max-width: 180px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-badge,
.state,
.status-pill,
.chain-tag,
.mini-node {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.source-badge {
  color: #0e4a99;
  background: #edf5ff;
  border: 1px solid #b9d4ff;
}

.state {
  color: var(--body);
  background: #f0f6ff;
}

.status-pill.timeout {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #ffd6dc;
}

.status-pill.warning {
  color: #004dff;
  background: #e9f1ff;
  border-color: #c8dcff;
}

.status-pill.blocked {
  color: var(--blocked);
  background: var(--warning-soft);
  border-color: #ffd99e;
}

.status-pill.normal {
  color: var(--success);
  background: var(--success-soft);
  border-color: #bdebd2;
}

.status-pill.pending {
  color: var(--muted);
  background: #eef2f7;
  border-color: #d7dee8;
}

.chain-name-cell {
  color: var(--body);
  font-weight: 950;
  text-align: left;
}

.chain-relation-row td {
  height: 35px;
  padding: 0 8px 6px;
  background: #fff;
}

.relation-strip {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid #d8e6f8;
  border-radius: 6px;
  background: #f6faff;
}

.relation-label {
  color: var(--body);
  font-size: 13px;
  font-weight: 950;
}

.mini-node-chain {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.mini-node.normal {
  color: var(--success);
  background: var(--success-soft);
}

.mini-node.pending {
  color: var(--muted);
  background: #eef2f7;
}

.mini-node.timeout {
  color: var(--danger);
  background: var(--danger-soft);
}

.mini-node.warning {
  color: var(--primary);
  background: #e9f1ff;
}

.mini-node.blocked {
  color: var(--blocked);
  background: var(--warning-soft);
}

.mini-arrow {
  color: #8ca6c8;
  font-weight: 950;
}

.chain-tags-cell {
  min-width: 0;
}

.chain-tag {
  margin: 2px 3px;
}

.chain-tag.root {
  color: var(--danger);
  background: var(--danger-soft);
}

.chain-tag.blocked {
  color: var(--blocked);
  background: var(--warning-soft);
}

.chain-tag.chain {
  color: var(--primary);
  background: #e9f1ff;
}

.chain-tag.single {
  color: var(--muted);
  background: #eef2f7;
}
