:root {
  --bg: #f4f8fd;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --panel-muted: rgba(248, 251, 255, 0.92);
  --line: rgba(148, 163, 184, 0.24);
  --glass-line: rgba(255, 255, 255, 0.72);
  --text: #122033;
  --muted: #5f6f84;
  --blue: #2563eb;
  --blue-deep: #1d4ed8;
  --blue-soft: rgba(37, 99, 235, 0.1);
  --cyan: #38bdf8;
  --green: #16a34a;
  --shadow: 0 16px 42px rgba(15, 23, 42, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 4%, rgba(56, 189, 248, 0.2), transparent 30%),
    radial-gradient(circle at 88% 20%, rgba(37, 99, 235, 0.11), transparent 28%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
  background-attachment: fixed;
}

button,
input {
  font: inherit;
}

select {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  font: inherit;
  outline: none;
}

textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none;
  resize: vertical;
}

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

button {
  border: 0;
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  padding: 14px 12px;
  z-index: 20;
  background: rgba(244, 248, 255, 0.76);
  border-right: 1px solid var(--glass-line);
  box-shadow: 12px 0 42px rgba(30, 64, 175, 0.08), inset -1px 0 rgba(148, 163, 184, 0.12);
  backdrop-filter: blur(24px) saturate(145%);
  -webkit-backdrop-filter: blur(24px) saturate(145%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue-deep), var(--blue));
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
}

.brand p,
.user-card p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.nav-group {
  display: grid;
  gap: 5px;
}

.nav-group > p {
  margin: 0;
  padding: 0 14px 5px;
  color: #667085;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.nav a {
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
}

.nav a.active,
.nav a:hover {
  color: var(--blue-deep);
  border-color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.12), inset 0 1px 0 #fff;
}

.nav a.active {
  background: linear-gradient(135deg, rgba(219, 234, 254, 0.92), rgba(255, 255, 255, 0.72));
}

.user-card {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 #fff;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.shell {
  margin-left: 232px;
  padding: 18px;
}

.topbar,
.login-panel,
.hero-panel,
.module-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(135%);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  position: sticky;
  top: 18px;
  z-index: 8;
}

.top-actions,
.login-form,
.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

input {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button {
  min-height: 38px;
  padding: 8px 16px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue-deep), var(--blue));
  font-weight: 800;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h2,
h3 {
  margin: 0;
}

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

.status-pill {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  background: #f1f5f9;
  font-weight: 800;
}

.status-pill.ok {
  color: var(--green);
  background: #ecfdf3;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 18px 22px;
}

.login-panel[hidden] {
  display: none;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  gap: 20px;
  margin-top: 16px;
  padding: 22px;
}

.revenue-number {
  margin: 8px 0;
  font-size: 48px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 16px;
  border-radius: 8px;
  background: #f8fbff;
  border: 1px solid var(--line);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

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

.module-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.module-card {
  min-width: 0;
  padding: 20px;
}

.span-2 {
  grid-column: span 2;
}

.card-title {
  justify-content: space-between;
  margin-bottom: 14px;
}

.tag {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--blue);
  background: #eff6ff;
  font-size: 12px;
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  background: #f8fafc;
}

.ranking-list {
  display: grid;
  gap: 10px;
}

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

.rank-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #f8fbff;
}

.rank-row span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: #fff;
  background: #f59e0b;
  font-weight: 900;
}

.rank-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row em {
  color: var(--blue);
  font-style: normal;
  font-weight: 800;
}

.bars {
  display: flex;
  align-items: end;
  gap: 8px;
  min-height: 160px;
  overflow-x: auto;
}

.upload-panel {
  margin-top: 16px;
}

.meituan-summary {
  margin-top: 16px;
}

.meituan-pending-card {
  margin-top: 16px;
}

.card-command,
.card-detail {
  margin-top: 16px;
}

.card-filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr)) auto;
  align-items: end;
  gap: 10px;
}

.card-filter-grid select,
.card-filter-grid input {
  width: 100%;
  min-width: 0;
}

.card-admin-actions,
.card-admin-actions form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.card-admin-actions {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.card-admin-actions form {
  padding-right: 8px;
  border-right: 1px solid var(--line);
}

.card-capabilities {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  min-height: 42px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.card-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.card-metrics .metric {
  min-width: 0;
  background: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.card-metrics .metric strong {
  overflow-wrap: anywhere;
  font-size: 21px;
}

.card-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card-table {
  min-width: 620px;
}

.card-table.wide {
  min-width: 920px;
}

.douyin-panel {
  margin-top: 16px;
}

.douyin-heading {
  align-items: flex-end;
}

.douyin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.config-grid.douyin-config-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.douyin-config-message {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 70px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.douyin-config-message span {
  overflow-wrap: anywhere;
}

.douyin-connection-strip {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1fr minmax(240px, 1.4fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.douyin-connection-strip > div {
  min-width: 0;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.douyin-connection-strip > div:last-child {
  border-right: 0;
}

.douyin-connection-strip span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.douyin-connection-strip strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.douyin-capability-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.douyin-capability-note strong {
  color: #b45309;
}

.douyin-filter-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.douyin-filter-label select {
  min-width: 112px;
}

.douyin-store-table {
  min-width: 920px;
}

.douyin-store-inactive td {
  color: #667085;
  background: #f8fafc;
}

.status.inactive {
  color: #475467;
  background: #eaecf0;
}

.douyin-log-table {
  min-width: 980px;
}

.douyin-log-error {
  max-width: 360px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.douyin-store-table td {
  vertical-align: middle;
}

.douyin-store-table button {
  min-height: 32px;
  padding: 6px 12px;
}

.douyin-address {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.douyin-feedback {
  min-height: 20px;
  margin-top: 12px;
  font-size: 13px;
}

.mapping-store-select {
  min-width: 220px;
}

.upload-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.upload-form input {
  width: 100%;
  min-width: 0;
}

.compact-form {
  align-content: start;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.upload-result {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.upload-actions button {
  min-width: 140px;
}

.upload-queue {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.upload-queue-message {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
}

.upload-queue-item {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.upload-queue-item p {
  margin: 10px 0 0;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.upload-queue-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.upload-queue-heading strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.upload-queue-heading .status {
  flex: 0 0 auto;
}

.upload-queue-meta {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 0;
}

.upload-queue-meta div {
  min-width: 0;
  padding: 10px;
  border-left: 2px solid var(--line);
}

.upload-queue-meta dt {
  color: var(--muted);
  font-size: 12px;
}

.upload-queue-meta dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.good-text {
  color: var(--green);
}

.warn-text {
  color: #b45309;
}

.error-text {
  color: #b91c1c;
}

.small-strong {
  overflow-wrap: anywhere;
  font-size: 14px !important;
}

.json-preview {
  min-height: 170px;
  margin: 14px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #0f172a;
  background: #f8fafc;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.status {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.status.success {
  color: var(--green);
  background: #ecfdf3;
}

.status.partial_failed,
.status.failed {
  color: #b45309;
  background: #fffbeb;
}

.status.superseded {
  color: #64748b;
  background: #f1f5f9;
}

.status.unsupported {
  color: #b45309;
  background: #fffbeb;
}

.batch-note {
  max-width: 260px;
  color: var(--muted);
  white-space: normal;
  line-height: 1.5;
}

.bar-item {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 42px;
  color: var(--muted);
  font-size: 11px;
}

.bar {
  width: 22px;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, var(--cyan), var(--blue));
}

@media (max-width: 1100px) {
  .card-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .card-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .module-grid,
  .metric-grid,
  .hero-panel,
  .meituan-summary .config-grid,
  .douyin-connection-strip {
    grid-template-columns: 1fr;
  }

  .douyin-connection-strip > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .douyin-connection-strip > div:last-child {
    border-bottom: 0;
  }

  .upload-queue-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 760px) {
  .sidebar {
    position: sticky;
    z-index: 10;
    inset: auto;
    top: 0;
    display: block;
    width: 100%;
    padding: 8px 12px;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  }

  .brand,
  .user-card {
    display: none;
  }

  .nav {
    display: flex;
    gap: 6px;
    margin-top: 0;
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .nav-group {
    display: contents;
  }

  .nav-group > p {
    display: none;
  }

  .nav a {
    flex: 0 0 auto;
    padding: 9px 12px;
    font-size: 13px;
  }

  .shell {
    margin-left: 0;
    padding: 12px;
  }

  .topbar,
  .login-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .login-form,
  .form-row {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .upload-actions button {
    flex: 1 1 140px;
  }

  .upload-queue-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .douyin-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .douyin-actions button {
    flex: 1 1 140px;
  }

  .card-filter-grid,
  .card-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .card-filter-grid button {
    grid-column: 1 / -1;
  }

  .card-admin-actions,
  .card-admin-actions form {
    align-items: stretch;
    flex-direction: column;
  }

  .card-admin-actions form {
    width: 100%;
    padding: 0 0 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .card-admin-actions input,
  .card-admin-actions button {
    width: 100%;
  }

  .upload-queue-meta {
    grid-template-columns: 1fr;
  }
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--blue-deep);
}

.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.42);
  outline-offset: 3px;
}

.user-copy {
  min-width: 0;
  flex: 1;
}

.user-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiet-button {
  min-height: 30px;
  padding: 5px 8px;
  color: var(--blue-deep);
  background: var(--blue-soft);
}

.topbar-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.text-action {
  color: var(--blue-deep);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.table-wrap,
table,
pre,
textarea {
  background: var(--panel-solid);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sidebar,
  .topbar,
  .login-panel,
  .hero-panel,
  .module-card {
    background: var(--panel-solid);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .sidebar,
  .topbar,
  .login-panel,
  .hero-panel,
  .module-card {
    background: var(--panel-solid);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
