:root {
  --bg: #101114;
  --side: #202124;
  --panel: #f7f8fb;
  --card: #ffffff;
  --line: #e3e8f1;
  --line-dark: #34363b;
  --text: #111827;
  --muted: #667085;
  --light: #f8fafc;
  --white: #ffffff;
  --accent: #6d45ff;
  --accent-2: #22c7d5;
  --green: #24b47e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--white);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.app-shell {
  display: flex;
  min-height: 100vh;
}
.app-side {
  position: sticky;
  top: 0;
  height: 100vh;
  flex: 0 0 248px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--side);
  color: var(--white);
  border-right: 1px solid var(--line-dark);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff, #9aa3b2);
  color: #111;
  font-weight: 700;
}
.brand small,
.shell-note span {
  display: block;
  margin-top: 4px;
  color: #a9afbb;
}
.main-nav {
  display: grid;
  gap: 6px;
}
.main-nav button {
  padding: 0 12px;
  text-align: left;
  background: transparent;
  color: #b7bdc8;
}
.main-nav button.active,
.main-nav button:hover {
  color: #fff;
  background: #34246a;
}
.shell-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line-dark);
  border-radius: 14px;
  background: #141518;
  line-height: 1.6;
}
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7f9fc 0%, #edf2f8 100%);
  color: var(--text);
}
body.next-locked .app-shell {
  display: none;
}
body.next-locked .app-main {
  display: none;
}
.next-auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #101114;
}
.next-auth-gate[hidden] {
  display: none;
}
.next-auth-gate > div {
  width: min(460px, 100%);
  padding: 26px;
  border: 1px solid #33333a;
  border-radius: 8px;
  background: #18181b;
  box-shadow: 0 22px 56px rgba(0, 0, 0, .32);
}
.next-auth-gate h1 {
  margin: 7px 0 10px;
  font-size: 28px;
}
.next-auth-gate p {
  color: #a9afbb;
  line-height: 1.7;
}
.next-userbar a {
  color: #f4f1ff;
  text-decoration: none;
}
.next-login-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.next-login-form label {
  display: grid;
  gap: 7px;
  color: #d7dbe5;
  font-weight: 600;
}
.next-login-form input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #343741;
  border-radius: 8px;
  background: #23242a;
  color: #fff;
  outline: none;
}
.next-login-form input:focus {
  border-color: rgba(109, 69, 255, .8);
  box-shadow: 0 0 0 3px rgba(109, 69, 255, .18);
}
.next-login-form button {
  min-height: 44px;
  padding: 0 14px;
  border-color: transparent;
  background: #6d45ff;
  color: #fff;
  font-weight: 600;
}
.next-login-form button:disabled {
  cursor: wait;
  opacity: .62;
}
.next-login-form small {
  min-height: 20px;
  color: #a9afbb;
}
.next-login-form small.error {
  color: #ff9da8;
}
.next-login-form small.ok {
  color: #7ee2bd;
}
.next-login-form small.loading {
  color: #9ed7ff;
}
.next-login-fallback {
  display: inline-block;
  margin-top: 12px;
  color: #a9afbb;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.next-eyebrow {
  margin: 0;
  color: #7bc8c3;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.next-userbar {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 20;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid #33333a;
  border-radius: 10px;
  background: rgba(21, 21, 23, .94);
  color: #f4f1ff;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .26);
}
.next-userbar[hidden] {
  display: none;
}
.next-userbar span {
  color: #d9ceff;
  font-weight: 600;
}
.next-userbar a {
  color: #9c9ca6;
  font-size: 13px;
}
.next-userbar button {
  min-height: 30px;
  padding: 0 10px;
  border-color: #3b3d45;
  background: #25262c;
  color: #f4f1ff;
  font-size: 13px;
  font-weight: 600;
}
.next-userbar button:hover {
  border-color: rgba(143, 124, 246, .55);
  color: #d9ceff;
}
.module-view {
  display: none;
  min-height: 100vh;
  padding: 24px 22px 34px;
}
.module-view.active {
  display: block;
}
.next-back-button {
  position: fixed;
  left: 22px;
  top: 22px;
  z-index: 20;
  min-height: 42px;
  border: 1px solid #33333a;
  border-radius: 10px;
  background: rgba(21, 21, 23, .94);
  color: #f4f1ff;
  padding: 0 14px;
  font-weight: 600;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .26);
}
.next-back-button:hover {
  border-color: rgba(143, 124, 246, .55);
  color: #d9ceff;
}
.home-dashboard {
  max-width: 1460px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}
.home-hero,
.home-panel,
.home-health-grid article,
.kpi-card,
.store-summary-card,
.issue-card,
.workflow-card,
.home-module-grid button {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}
.home-hero {
  padding: 24px 24px 22px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
}
.home-kicker {
  margin: 0 0 8px;
  color: #3f76ef;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.home-hero h1 {
  margin: 0;
  color: var(--text);
  font-size: 30px;
  line-height: 1.1;
}
.home-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.home-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.home-hero-actions button,
.home-panel-head button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  font-weight: 700;
}
.home-primary-action,
.home-panel-head button {
  border-color: transparent;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
}
.home-secondary-action {
  border-color: var(--line);
  background: #f8fbff;
  color: var(--text);
}
.home-health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.home-health-grid article,
.kpi-card {
  padding: 18px 18px 16px;
}
.home-health-grid span,
.kpi-card span,
.store-summary-head span,
.issue-card span,
.workflow-card span,
.home-module-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.home-health-grid strong,
.kpi-card strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 26px;
  line-height: 1.1;
}
.home-health-grid small,
.kpi-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}
.home-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}
.kpi-card span {
  color: #4f6fad;
}
.kpi-card strong {
  font-size: 25px;
}
.kpi-card-error {
  border-color: #f39ba7;
}
.home-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(340px, .9fr);
  gap: 14px;
  align-items: start;
}
.home-lower-grid {
  grid-template-columns: minmax(320px, .8fr) minmax(0, 1.2fr);
}
.home-panel {
  padding: 18px;
}
.home-panel-wide {
  min-width: 0;
}
.home-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.home-panel-head span {
  color: #3f76ef;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.home-panel-head h2 {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 19px;
}
.home-visual-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: 14px;
}
.home-scatter {
  position: relative;
  min-height: 360px;
  padding: 18px;
  overflow: hidden;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,251,255,.98)),
    radial-gradient(circle at 0 0, rgba(59,130,246,.08), transparent 42%);
  border: 1px solid var(--line);
}
.scatter-grid-lines {
  position: absolute;
  inset: 18px;
  border-radius: 12px;
  background:
    linear-gradient(to right, transparent 24.5%, rgba(148,163,184,.35) 24.5%, rgba(148,163,184,.35) 25.5%, transparent 25.5%, transparent 49.5%, rgba(148,163,184,.35) 49.5%, rgba(148,163,184,.35) 50.5%, transparent 50.5%, transparent 74.5%, rgba(148,163,184,.35) 74.5%, rgba(148,163,184,.35) 75.5%, transparent 75.5%),
    linear-gradient(to top, transparent 24.5%, rgba(148,163,184,.35) 24.5%, rgba(148,163,184,.35) 25.5%, transparent 25.5%, transparent 49.5%, rgba(148,163,184,.35) 49.5%, rgba(148,163,184,.35) 50.5%, transparent 50.5%, transparent 74.5%, rgba(148,163,184,.35) 74.5%, rgba(148,163,184,.35) 75.5%, transparent 75.5%);
  opacity: .42;
  pointer-events: none;
}
.scatter-axis {
  position: absolute;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  pointer-events: none;
  z-index: 1;
}
.scatter-x { right: 18px; bottom: 12px; }
.scatter-y { left: 18px; top: 14px; }
.scatter-point {
  position: absolute;
  z-index: 2;
  display: grid;
  grid-template-columns: var(--point-size, 28px) minmax(110px, 1fr);
  align-items: center;
  gap: 8px;
  width: clamp(160px, 36%, 230px);
  transform: translate(calc(var(--point-size, 28px) / -2), -50%);
  color: var(--text);
  pointer-events: auto;
}
.scatter-point.label-left {
  grid-template-columns: minmax(110px, 1fr) var(--point-size, 28px);
  transform: translate(calc(-100% + var(--point-size, 28px) / 2), -50%);
  text-align: right;
}
.scatter-point i {
  grid-row: 1 / span 2;
  width: var(--point-size, 28px);
  height: var(--point-size, 28px);
  border-radius: 999px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .18);
}
.scatter-point.label-left i {
  grid-column: 2;
}
.scatter-point.label-left strong,
.scatter-point.label-left span {
  grid-column: 1;
}
.scatter-point strong {
  display: block;
  font-size: 11px;
  line-height: 1.1;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scatter-point span {
  display: block;
  font-size: 10px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scatter-point.platform-tmall i { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.scatter-point.platform-douyin i { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.scatter-point.platform-pdd i { background: linear-gradient(135deg, #9333ea, #c084fc); }
.home-store-list {
  display: grid;
  gap: 12px;
}
.store-summary-card {
  padding: 16px;
}
.store-summary-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.store-summary-head h3 {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 17px;
}
.store-summary-head strong {
  color: var(--text);
  font-size: 18px;
}
.store-summary-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin-top: 14px;
}
.store-summary-metrics span {
  color: var(--muted);
  font-size: 12px;
}
.store-summary-metrics b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 12px;
}
.home-issue-list,
.home-workflow {
  display: grid;
  gap: 12px;
}
.issue-card,
.workflow-card {
  padding: 16px;
}
.issue-card strong,
.workflow-card strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 16px;
}
.issue-card p,
.workflow-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
}
.issue-empty {
  padding: 20px 16px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: #fbfcfe;
}
.home-module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.home-module-grid button {
  min-height: 94px;
  padding: 16px 14px;
  text-align: left;
  color: var(--text);
}
.home-module-grid button strong {
  display: block;
  color: var(--text);
  font-size: 16px;
}
.home-module-grid button span {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}
.home-module-grid button:hover {
  border-color: rgba(37, 99, 235, .28);
  background: #f8fbff;
}
.module-shell {
  max-width: 1240px;
  margin: 0 auto;
}
.module-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
}
.module-head span {
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
}
.module-head h1 {
  margin: 6px 0 0;
  font-size: 26px;
}
.module-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
}
.placeholder-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.placeholder-card {
  min-height: 140px;
  padding: 16px;
  border: 1px dashed #bfd0e8;
  border-radius: 12px;
  background: #f7fbff;
}
.placeholder-card strong,
.placeholder-card span {
  display: block;
}
.placeholder-card span {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}
body.next-module-loading::after {
  content: "正在加载模块...";
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  padding: 10px 12px;
  border: 1px solid #c8d6e7;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: #1e2c3b;
  box-shadow: 0 10px 30px rgba(25, 43, 68, 0.12);
  font-size: 13px;
}

/* ===== Module render error boundary ===== */
.next-error-boundary {
  display: grid;
  place-items: center;
  min-height: 60vh;
  padding: 32px;
}
.next-error-card {
  width: min(520px, 100%);
  padding: 32px 28px;
  border: 1px solid #e85d6b;
  border-radius: 16px;
  background: var(--white);
  text-align: center;
  box-shadow: 0 18px 48px rgba(232, 93, 107, .15);
}
.next-error-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff0f1;
  color: #e85d6b;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}
.next-error-card h2 {
  margin: 0 0 10px;
  font-size: 20px;
  color: var(--text);
  font-weight: 700;
}
.next-error-module {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}
.next-error-module strong {
  color: var(--text);
  font-weight: 600;
}
.next-error-detail {
  margin: 0 0 20px;
  padding: 12px;
  border-radius: 8px;
  background: #f6f8fa;
  color: #c0392b;
  font-size: 13px;
  font-family: Consolas, monospace;
  word-break: break-all;
  line-height: 1.6;
}
.next-error-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.next-error-actions button {
  min-height: 40px;
  padding: 0 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.next-error-back {
  border: 1px solid var(--line);
  background: var(--light);
  color: var(--text);
}
.next-error-back:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.next-error-reload {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
}
.next-error-reload:hover {
  opacity: .9;
}

@media (max-width: 980px) {
  .next-back-button {
    left: 12px;
    top: 12px;
  }
  .next-userbar {
    left: 12px;
    right: 12px;
    top: 62px;
    justify-content: space-between;
  }
  .app-shell {
    display: block;
  }
  .app-side {
    position: static;
    width: auto;
    height: auto;
  }
  .main-nav,
  .placeholder-grid,
  .home-health-grid,
  .home-kpi-grid,
  .home-main-grid,
  .home-lower-grid,
  .home-visual-row,
  .home-module-grid {
    grid-template-columns: 1fr;
  }
  .home-hero {
    flex-direction: column;
    align-items: flex-start;
  }
  .home-hero-actions {
    justify-content: flex-start;
  }
  .scatter-point {
    max-width: 44%;
  }
}
