:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1677ff;
  --primary-weak: #e6f4ff;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #111827;
  --panel-soft: #1f2937;
  --text: #f9fafb;
  --muted: #9ca3af;
  --line: #374151;
  --primary: #4096ff;
  --primary-weak: rgba(64, 150, 255, 0.14);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.hero h1 { margin: 0 0 8px; font-size: 26px; font-weight: 750; letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--muted); line-height: 1.7; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.vendor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 16px;
}
.vendor-tab {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 650;
  line-height: 1.35;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.vendor-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-weak);
}
.vendor-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 8px 20px var(--primary-weak);
}
.vendor-tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-weak);
}
button, .button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 650;
}
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.success { background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .32); color: var(--success); }
button.warning { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .38); color: var(--warning); }
button.danger { background: #fff1f2; border-color: #fecdd3; color: var(--danger); }
[data-theme="dark"] button.success { background: rgba(16, 185, 129, .14); border-color: rgba(16, 185, 129, .38); }
[data-theme="dark"] button.warning { background: rgba(245, 158, 11, .14); border-color: rgba(245, 158, 11, .38); }
[data-theme="dark"] button.danger { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .35); }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--panel-soft); }
td { line-height: 1.55; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; min-width: 212px; }
.table-actions-first { min-width: max-content; }
.table-actions-first .action-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 232px;
  background: var(--panel);
  box-shadow: 10px 0 16px rgba(15, 23, 42, 0.06);
}
.table-actions-first th.action-col { z-index: 3; background: var(--panel-soft); }
.row-actions button { padding: 7px 10px; border-radius: 9px; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 650; background: var(--primary-weak); color: var(--primary); }
.badge.success { background: rgba(16, 185, 129, .12); color: var(--success); }
.badge.muted { color: var(--muted); background: var(--panel-soft); border: 1px solid var(--line); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; align-items: start; }
.field { grid-column: span 6; min-width: 0; }
.field.full, .grid > .full { grid-column: 1 / -1; }
.field.third { grid-column: span 4; }
.field label { display: block; margin: 0 0 6px; font-weight: 650; color: var(--muted); font-size: 12px; }
.required-mark { color: var(--danger); font-weight: 800; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, .12); }
.field-error { min-height: 16px; margin-top: 5px; color: var(--danger); font-size: 12px; line-height: 1.35; }
.field.has-error label { color: var(--danger); }
.modal-backdrop { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(15, 23, 42, .45); z-index: 40; }
.modal-backdrop.open { display: flex; }
.modal { width: min(880px, 100%); max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.modal-header, .modal-footer { padding: 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.modal-footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
.modal-body { padding: 16px; }
.notice { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-soft); color: var(--muted); line-height: 1.7; min-width: 0; }
.notice.full { grid-column: 1 / -1; }
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.price-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.price-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.price-head h3 { margin: 0 0 4px; font-size: 18px; }
.price-head p { margin: 0; color: var(--muted); }
.logo { width: 36px; height: 36px; border-radius: 10px; object-fit: contain; background: var(--panel-soft); border: 1px solid var(--line); padding: 6px; }
.price-matrix { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metric { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--panel-soft); }
.metric span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.metric strong { font-size: 16px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.toast { position: fixed; right: 20px; bottom: 20px; padding: 12px 14px; border-radius: 12px; background: var(--text); color: var(--panel); display: none; z-index: 50; }
.toast.show { display: block; }
@media (max-width: 760px) {
  .container { padding: 16px; }
  .hero { flex-direction: column; }
  .vendor-tabs { margin-top: 0; }
  .vendor-tab { flex: 1 1 auto; min-width: max-content; }
  .field, .field.third { grid-column: span 12; }
  .price-matrix { grid-template-columns: 1fr; }
}

.share-button,
.home-link {
  white-space: nowrap;
}
.share-modal {
  width: min(720px, 100%);
}
.share-modal .modal-header {
  align-items: flex-start;
}
.share-modal h2 {
  margin: 0 0 6px;
  font-size: 20px;
}
.share-modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}
.share-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.share-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}
.share-qr-card,
.share-link-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 16px;
}
.share-qr-card {
  text-align: center;
}
.share-qr {
  width: 220px;
  height: 220px;
  max-width: 100%;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px;
}
.share-link-card label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.share-link-card input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.share-actions {
  margin-top: 12px;
}
.share-note {
  margin-top: 12px !important;
}
.wechat-tip {
  color: var(--text);
  border-color: rgba(16, 185, 129, .32);
  background: rgba(16, 185, 129, .1);
}
@media (max-width: 760px) {
  .catalog-actions {
    width: 100%;
  }
  .catalog-actions input,
  .catalog-actions .share-button,
  .catalog-actions .home-link {
    width: 100% !important;
    justify-content: center;
    text-align: center;
  }
  .share-grid {
    grid-template-columns: 1fr;
  }
  .share-modal .modal-header {
    flex-direction: column;
  }
  .share-modal .modal-header button {
    align-self: flex-end;
  }
}

.featured-home-link {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 0 !important;
  color: #fff !important;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 48%, #7c3aed 100%) !important;
  box-shadow: 0 14px 28px rgba(239, 68, 68, .28), 0 4px 10px rgba(124, 58, 237, .18);
  transform: translateY(0);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  font-weight: 900;
  letter-spacing: .02em;
  padding-inline: 18px;
}
.featured-home-link::before {
  content: "";
  position: absolute;
  inset: -40% -20%;
  z-index: -1;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,.42) 42%, transparent 70%);
  transform: translateX(-120%) rotate(8deg);
  transition: transform .55s ease;
}
.featured-home-link::after {
  content: "  →";
  font-weight: 900;
  transition: transform .18s ease;
}
.featured-home-link:hover,
.featured-home-link:focus-visible {
  filter: saturate(1.12) brightness(1.04);
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(239, 68, 68, .34), 0 8px 16px rgba(124, 58, 237, .22);
}
.featured-home-link:hover::before,
.featured-home-link:focus-visible::before {
  transform: translateX(120%) rotate(8deg);
}
.featured-home-link:hover::after,
.featured-home-link:focus-visible::after {
  transform: translateX(3px);
}
@media (max-width: 760px) {
  .catalog-actions .featured-home-link {
    order: -1;
    min-height: 48px;
    font-size: 16px;
    box-shadow: 0 16px 30px rgba(239, 68, 68, .32), 0 6px 14px rgba(124, 58, 237, .2);
  }
}


.route-priority-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}
.route-priority-form {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 14px;
}
.route-model-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  overflow: hidden;
}
.route-model-card h3 {
  margin: 0;
  padding: 16px 16px 4px;
  font-size: 18px;
}
.route-model-card p {
  margin: 0;
  padding: 0 16px 12px;
  color: var(--muted);
}
.muted {
  color: var(--muted);
}

.badge.danger { background: rgba(239, 68, 68, .12); color: var(--danger); border: 1px solid rgba(239, 68, 68, .28); }
.model-profit-panel { padding: 16px; min-width: 1440px; }
.model-profit-table th, .model-profit-table td { white-space: nowrap; }
.model-profit-table thead tr:first-child th { text-align: center; border-left: 1px solid var(--line); }
.model-profit-table thead tr:nth-child(2) th { text-align: center; }
.negative-profit-row td { background: rgba(239, 68, 68, .08); }
.negative-profit-row td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.negative-profit-cell { color: var(--danger); font-weight: 800; }
.profit-rate { font-weight: 700; }
[data-theme="dark"] .negative-profit-row td { background: rgba(239, 68, 68, .14); }
.badge.warning { background: rgba(245, 158, 11, .14); color: #92400e; border: 1px solid rgba(245, 158, 11, .38); }
.route-account-missing td { background: rgba(245, 158, 11, .10); }
.route-account-missing td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
.route-account-missing:hover td { background: rgba(245, 158, 11, .16); }
[data-theme="dark"] .route-account-missing td { background: rgba(245, 158, 11, .18); }
[data-theme="dark"] .route-account-missing:hover td { background: rgba(245, 158, 11, .24); }
