:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --line: #dbe3e6;
  --text: #172126;
  --muted: #64727a;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --accent: #b45309;
  --danger: #b42318;
  --ok-bg: #e7f7ef;
  --ok-text: #166534;
  --wait-bg: #eef5ff;
  --wait-text: #1d4ed8;
  --warn-bg: #fff7ed;
  --warn-text: #b45309;
  --bad-bg: #fef2f2;
  --bad-text: #b42318;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button.secondary {
  background: #e8eef0;
  color: var(--text);
}

button.secondary:hover {
  background: #dce5e8;
}

button.danger {
  background: var(--danger);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  background: #e8eef0;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.button-link:hover {
  background: #dce5e8;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 44px;
}

.query-panel,
.summary,
.jump-panel,
.import-panel,
.edit-panel,
.list-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.query-panel {
  padding: 24px;
}

.import-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 20px;
}

.jump-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 20px;
}

.brand-row,
.form-head,
.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.header-actions button {
  min-height: 40px;
}

.login-shell {
  width: min(520px, calc(100% - 32px));
}

.login-panel {
  display: grid;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.18;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.25;
}

.plain-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.plain-link:hover {
  text-decoration: underline;
}

.search-form {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.compact-form {
  margin-top: 0;
}

.input-row,
.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.detection-hint {
  margin-top: -6px;
}

.detection-hint.ok {
  color: var(--ok-text);
}

.detection-hint.warn {
  color: var(--warn-text);
}

.notice {
  margin-top: 16px;
  border-radius: 6px;
  padding: 12px 14px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

.notice.error {
  background: var(--bad-bg);
  color: var(--bad-text);
}

.summary {
  margin-top: 18px;
  padding: 18px 20px;
}

.stats {
  display: flex;
  gap: 18px;
  color: var(--muted);
  white-space: nowrap;
}

.stats strong {
  color: var(--text);
  font-size: 22px;
}

.results,
.link-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.result-card,
.warehouse-item,
.link-card,
.empty-state {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.result-top,
.warehouse-top,
.link-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pending {
  background: var(--wait-bg);
  color: var(--wait-text);
}

.status-found {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.status-h5 {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.status-wechat {
  background: var(--wait-bg);
  color: var(--wait-text);
}

.status-no_result,
.status-needs_manual {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.status-timeout,
.status-error {
  background: var(--bad-bg);
  color: var(--bad-text);
}

.result-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
}

.result-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.copy-waybill {
  display: inline;
  min-height: 0;
  max-width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  cursor: pointer;
}

.copy-waybill:hover {
  background: transparent;
  color: var(--primary-dark);
  text-decoration: underline;
}

.copy-waybill.copied {
  color: var(--ok-text);
  text-decoration: none;
}

.waybill-empty {
  color: var(--muted);
}

.waybill-only-meta {
  grid-template-columns: 1fr;
  margin-bottom: 0;
}

.link-card {
  display: grid;
  gap: 14px;
}

.mini-link-card {
  gap: 10px;
  padding: 12px;
}

.mini-link-card h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.mini-link-card .hint {
  font-size: 12px;
  line-height: 1.35;
}

.mini-link-card .open-link {
  min-height: 38px;
  padding: 0 10px;
}

.link-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.link-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.open-link {
  width: 100%;
}

.empty-state {
  grid-column: 1 / -1;
  margin-top: 18px;
  color: var(--muted);
  text-align: center;
}

.link-grid .empty-state {
  margin-top: 0;
}

.compact-grid {
  margin-top: 0;
}

.compact-result {
  display: grid;
  gap: 12px;
}

.result-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.trace-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.trace-list li {
  border-top: 1px solid var(--line);
  padding-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.trace-list time {
  display: block;
  color: var(--text);
  font-weight: 700;
}

.admin-shell {
  width: min(1240px, calc(100% - 32px));
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 18px;
  margin-top: 18px;
}

.edit-panel,
.list-panel {
  padding: 20px;
}

.edit-panel {
  display: grid;
  gap: 14px;
  align-self: start;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-label {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-self: end;
  min-height: 44px;
  color: var(--text);
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.warehouse-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.warehouse-item {
  display: grid;
  gap: 12px;
}

.compact-warehouse {
  padding: 0;
  overflow: hidden;
}

.warehouse-summary {
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 0;
  padding: 12px 14px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.warehouse-summary:hover {
  background: #f7faf9;
}

.warehouse-summary h3 {
  margin-bottom: 4px;
}

.summary-badges {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.warehouse-collapse {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
}

.warehouse-collapse[hidden] {
  display: none;
}

.warehouse-details {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.warehouse-details span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-lines {
  grid-template-columns: 1fr;
}

.warehouse-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .results,
  .link-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

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

  .warehouse-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .shell,
  .admin-shell {
    width: min(100% - 24px, 1120px);
    padding-top: 18px;
  }

  .query-panel,
  .summary,
  .jump-panel,
  .import-panel,
  .edit-panel,
  .list-panel {
    padding: 16px;
  }

  .brand-row,
  .summary,
  .form-head {
    align-items: flex-start;
  }

  h1 {
    font-size: 24px;
  }

  .input-row,
  .form-actions,
  .form-row {
    grid-template-columns: 1fr;
  }

  .stats {
    flex-direction: column;
    gap: 6px;
  }

  .result-meta,
  .link-meta,
  .warehouse-details {
    grid-template-columns: 1fr;
  }

  .mini-link-card {
    padding: 11px;
  }

  .mini-link-card .link-card-top {
    display: grid;
    gap: 6px;
  }

  .mini-link-card .status-pill {
    width: max-content;
    min-height: 24px;
    padding: 3px 8px;
  }

  .warehouse-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-badges {
    justify-content: flex-start;
  }
}
