:root {
  --brand-red: #d7000f;
  --brand-red-dark: #b6000c;
  --brand-blue: #0563c1;
  --page: #f2f4f7;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #e4e7ec;
  --healthy: #12b76a;
  --warning: #f79009;
  --error: #d92d20;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  background: var(--page);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  z-index: 2;
  top: 0;
  color: #ffffff;
  background: var(--brand-red);
  border-bottom: 3px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 6px 18px rgba(146, 0, 10, 0.18);
}

.topbar-inner {
  width: min(1360px, calc(100% - 40px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.rules-link {
  color: #ffffff;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  white-space: nowrap;
}
.rules-link:hover { background: rgba(255, 255, 255, 0.12); }
.login-banner {
  display: block;
  width: min(1360px, calc(100% - 40px));
  margin: 16px auto 0;
  padding: 12px 18px;
  color: #ffffff;
  background: var(--error);
  border-radius: 10px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(217, 45, 32, 0.25);
}
.login-banner[hidden] { display: none; }
.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  color: var(--brand-red);
  background: #ffffff;
  border-radius: 6px;
  font-size: 21px;
  font-weight: 900;
}

h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: 20px; line-height: 1.2; font-weight: 700; letter-spacing: 0; }

.topbar-status { display: flex; align-items: center; gap: 24px; font-size: 12px; }
.topbar-status > div { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.topbar-status dt { opacity: 0.82; }
.topbar-status dd { margin: 0; font: 600 12px/1.3 "Cascadia Mono", Consolas, monospace; }
.run-state, .refresh-state { padding: 7px 11px; background: rgba(255, 255, 255, 0.12); border-radius: 16px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--warning); }
.status-dot.healthy { background: #69e3ad; box-shadow: 0 0 0 4px rgba(105, 227, 173, 0.14); }
.status-dot.error, .status-dot.auth_required { background: #ffffff; }

main { width: min(1360px, calc(100% - 40px)); margin: 0 auto; padding: 22px 0 48px; }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.summary-item {
  min-width: 0;
  min-height: 92px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-blue);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.06);
}

.new-summary { border-left-color: var(--brand-red); }
.collection-summary { border-left-color: var(--healthy); }
body[data-state="error"] .collection-summary,
body[data-state="auth_required"] .collection-summary { border-left-color: var(--error); }

.summary-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  color: var(--brand-blue);
  background: #eaf3fc;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 800;
}

.new-summary .summary-icon { color: var(--brand-red); background: #fff0f1; }
.collection-summary .summary-icon { color: #087443; background: #eafaf2; }
.summary-item strong { display: block; font: 750 27px/1.1 "Cascadia Mono", Consolas, monospace; }
.summary-item span:not(.summary-icon) { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; }
.collection-summary strong { font-family: "Microsoft YaHei", "Segoe UI", sans-serif; font-size: 19px; }

.error-summary {
  margin-top: 14px;
  padding: 12px 14px;
  color: #912018;
  background: #fff1f0;
  border: 1px solid #fecdca;
  border-radius: 6px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.orders-panel {
  margin-top: 16px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.05);
}

.panel-heading { min-height: 70px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-eyebrow { color: var(--brand-red); font-size: 11px; font-weight: 700; }
h2 { margin-top: 3px; font-size: 18px; line-height: 1.25; letter-spacing: 0; }
.display-count { padding: 6px 9px; color: var(--muted); background: var(--page); border-radius: 4px; font-size: 12px; white-space: nowrap; }

.table-heading, .work-order {
  display: grid;
  grid-template-columns: 64px 240px minmax(0, 1fr);
  align-items: start;
}

.table-heading { padding: 11px 16px; color: #475467; background: #f7f8fa; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700; }
.work-order { position: relative; padding: 17px 16px; border-bottom: 1px solid var(--line); }
.work-order:last-child { border-bottom: 0; }
.work-order.is-new { background: #fff8f8; }
.work-order.deadline-yellow { background: #fff8d6; }
.work-order.deadline-red { background: #ffe1e1; }
.work-order.is-new::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--brand-red); }
.sequence { color: var(--muted); font: 600 13px/1.7 "Cascadia Mono", Consolas, monospace; }
.waybill { min-width: 0; color: var(--brand-blue); font: 650 16px/1.7 "Microsoft YaHei", "PingFang SC", sans-serif; overflow-wrap: anywhere; }
.waybill-cell { min-width: 0; text-align: center; }
.complaint-label {
  display: block;
  margin-top: 4px;
  color: #d94a18;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.new-badge { display: inline-block; margin-left: 8px; padding: 1px 5px; color: #ffffff; background: var(--brand-red); border-radius: 3px; font: 700 10px/1.5 "Microsoft YaHei", sans-serif; vertical-align: 1px; }
.work-info { min-width: 0; padding-right: 8px; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; white-space: pre-wrap; }
.loading-state, .empty-state { padding: 54px 16px; color: var(--muted); text-align: center; }

.table-heading, .interception-heading {
  text-align: center;
}
.work-order, .interception-order {
  justify-items: center;
  text-align: center;
}

.interception-panel { margin-top: 16px; }
.interception-panel { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; font-weight: 700; }
.interception-panel .panel-eyebrow, .interception-panel h2, .interception-panel .display-count, .interception-panel .interception-heading, .interception-panel .waybill, .interception-panel .work-info, .interception-panel .pickup-code { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; font-weight: 700; }
.interception-heading, .interception-order {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 180px;
  gap: 20px;
}
.interception-heading {
  padding: 11px 16px;
  color: #475467;
  background: #f7f8fa;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}
.interception-order { padding: 17px 16px; align-items: start; border-bottom: 1px solid var(--line); background: #ffffff; }
.interception-order:last-child { border-bottom: 0; }
.interception-order .waybill {
  font: 700 20px/2.5 "Microsoft YaHei", "PingFang SC", sans-serif;
}
.interception-order .work-info {
  font: 700 20px/2.5 "Microsoft YaHei", "PingFang SC", sans-serif;
}
.pickup-code { font: 700 20px/2.5 "Microsoft YaHei", "PingFang SC", sans-serif; overflow-wrap: anywhere; }
.pickup-code.missing { color: var(--warning); font-family: "Microsoft YaHei", sans-serif; font-size: 13px; }
.template-heading { border-bottom: 1px solid var(--line); }
.copy-button {
  min-height: 32px;
  padding: 6px 11px;
  color: var(--brand-red);
  background: #ffffff;
  border: 1px solid #f5a3aa;
  border-radius: 4px;
  font: 650 12px/1.4 "Microsoft YaHei", sans-serif;
  cursor: pointer;
}
.copy-button:hover { background: #fff3f4; }
.copy-button:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
.copy-button:disabled { cursor: default; opacity: 0.45; }
.copy-all { color: #ffffff; background: var(--brand-red); border-color: var(--brand-red); }
.copy-all:hover { background: var(--brand-red-dark); }
.message-templates { padding: 0 16px 16px; }
.message-template { padding: 14px 0; border-bottom: 1px solid var(--line); }
.message-template:last-child { border-bottom: 0; }
.message-template header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.message-template header strong { color: var(--brand-red); font-size: 14px; }
.message-template pre {
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: var(--ink);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 13px/1.75 "Microsoft YaHei", "Segoe UI", sans-serif;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.copy-feedback { min-height: 20px; padding: 0 16px 12px; color: var(--muted); font-size: 12px; }

@media (max-width: 720px) {
  .topbar-inner { width: calc(100% - 28px); min-height: 0; padding: 12px 0; align-items: stretch; flex-direction: column; gap: 11px; }
  .brand-mark { width: 32px; height: 32px; flex-basis: 32px; font-size: 18px; }
  h1 { font-size: 18px; }
  .topbar-status { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .topbar-status > div { min-width: 0; }
  .topbar-status > div:nth-child(2) { display: block; }
  .topbar-status > div:nth-child(2) dt { display: block; margin-bottom: 2px; }
  .topbar-status > div:nth-child(2) dd { white-space: normal; overflow-wrap: anywhere; }
  .run-state, .refresh-state { padding: 6px 8px; }
  main { width: calc(100% - 24px); padding: 14px 0 28px; }
  .summary-grid { gap: 7px; }
  .summary-item { min-height: 82px; padding: 12px 8px; display: block; border-left-width: 3px; }
  .summary-icon { width: 28px; height: 28px; margin-bottom: 8px; font-size: 12px; }
  .summary-item strong { font-size: 20px; }
  .summary-item span:not(.summary-icon) { margin-top: 4px; font-size: 11px; line-height: 1.35; }
  .collection-summary strong { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
  .panel-heading { min-height: 62px; padding: 12px; }
  h2 { font-size: 17px; }
  .table-heading { display: none; }
  .work-order { grid-template-columns: 34px minmax(0, 1fr); padding: 15px 12px; }
  .sequence { grid-row: 1 / span 2; }
  .waybill-cell { grid-column: 2; margin-bottom: 5px; }
  .work-info { grid-column: 2; padding-right: 0; font-size: 13px; line-height: 1.65; }
  .interception-heading { display: none; }
  .interception-order { display: block; padding: 15px 12px; }
  .interception-order .waybill, .interception-order .work-info { display: block; margin-bottom: 7px; }
  .message-templates { padding: 0 12px 12px; }
  .message-template header { align-items: stretch; flex-direction: column; gap: 8px; }
  .copy-button { width: 100%; }
  .template-heading .copy-button { width: auto; max-width: 150px; }
  .message-template pre { padding: 11px; font-size: 12px; }
  .work-order { justify-items: center; text-align: center; }
  .work-order .sequence { justify-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
