:root {
  --red: #d91f26;
  --red-dark: #b8171d;
  --ink: #191919;
  --muted: #77736f;
  --line: #eae5df;
  --paper: #fff;
  --canvas: #f5f2ee;
  --good: #21845a;
  --warn: #a46116;
  --danger: #bd252b;
  --shadow: 0 3px 16px rgb(49 35 20 / 5%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(217 31 38 / 22%);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  transform: translateY(-150%);
  border-radius: 6px;
  background: #fff;
  color: #111;
  padding: 9px 13px;
}

.skip-link:focus {
  transform: none;
}

.topbar {
  position: relative;
  z-index: 10;
  border-bottom: 3px solid var(--red);
  background: #191919;
  color: #fff;
}

.topbar-inner {
  display: flex;
  width: min(100%, 1508px);
  min-height: 76px;
  margin: 0 auto;
  padding: 0 34px;
  align-items: stretch;
  gap: 28px;
}

.platform-brand {
  display: flex;
  min-width: 266px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px 11px 16px 16px;
  background: var(--red);
  box-shadow: inset 0 -5px 0 rgb(0 0 0 / 13%);
  font-family: Georgia, "Songti SC", serif;
  font-size: 20px;
  font-weight: 800;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: contain;
}

.brand-copy {
  display: flex;
  min-width: 0;
  margin-left: 13px;
  flex-direction: column;
  gap: 3px;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  overflow: hidden;
  color: #a7a7a7;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-nav {
  display: flex;
  min-width: 0;
  align-items: stretch;
}

.platform-nav > a,
.platform-nav > span {
  position: relative;
  display: flex;
  min-width: 76px;
  padding: 0 14px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 3px;
  color: #b8b8b8;
  text-decoration: none;
}

.platform-nav > a::after {
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--red);
  content: "";
}

.platform-nav .active {
  color: #fff;
  background: rgb(255 255 255 / 4%);
}

.platform-nav .disabled {
  color: #737373;
  cursor: default;
}

.platform-nav span span,
.platform-nav a span {
  font-size: 12px;
  font-weight: 700;
}

.platform-nav small {
  font-size: 9px;
}

.header-actions {
  display: flex;
  margin-left: auto;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.header-actions form {
  margin: 0;
}

.ghost-button,
.text-button {
  min-height: 36px;
  border-radius: 7px;
  cursor: pointer;
}

.ghost-button {
  border: 1px solid #535353;
  background: transparent;
  color: #eee;
  padding: 7px 13px;
}

.ghost-button:hover {
  border-color: #777;
  background: #272727;
}

.text-button {
  border: 0;
  background: transparent;
  color: #aaa;
  padding: 7px 4px;
}

.text-button:hover {
  color: #fff;
}

.user-name {
  display: inline-flex;
  min-width: 34px;
  height: 34px;
  max-width: 112px;
  overflow: hidden;
  padding: 0 10px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #343434;
  color: #fff;
  font-size: 11px;
  text-overflow: ellipsis;
}
.dashboard-account-link { display: inline-flex; color: inherit; text-decoration: none; }
.dashboard-account-link .user-name { padding: 0; }
.dashboard-account-link .user-name img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }

.page-shell {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 32px 34px 28px;
}

.report-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
}

.report-title {
  min-width: 260px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--red);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h1 {
  margin: 0 0 8px;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(27px, 3vw, 34px);
  letter-spacing: -0.035em;
  line-height: 1.18;
}

.report-title > p:last-child,
.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(145px, 1.25fr) minmax(132px, 1fr) minmax(132px, 1fr) auto;
  align-items: end;
  gap: 9px;
}

.filters label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
}

.filters input,
.filters select {
  width: 100%;
  height: 39px;
  min-width: 0;
  border: 1px solid #dcd5cf;
  border-radius: 7px;
  outline: none;
  background: #fff;
  color: #333;
  padding: 0 11px;
  font-size: 12px;
}

.filter-button,
.primary-button {
  border: 1px solid var(--red);
  border-radius: 7px;
  background: var(--red);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.filter-button {
  height: 39px;
  padding: 0 16px;
  font-size: 12px;
}

.filter-button:hover,
.primary-button:hover {
  border-color: var(--red-dark);
  background: var(--red-dark);
}

.filter-button:disabled,
.filters input:disabled,
.filters select:disabled {
  cursor: wait;
  opacity: 0.65;
}

.status-banner {
  display: flex;
  min-height: 40px;
  margin-top: 18px;
  padding: 9px 12px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #ead9b5;
  border-radius: 7px;
  background: #fff8e7;
  color: #795514;
  font-size: 12px;
}

.status-banner[hidden] {
  display: none;
}

.status-banner.error {
  border-color: #efc2c4;
  background: #fff0f0;
  color: #9d1d23;
}

.status-banner button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 800;
  text-decoration: underline;
}

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

.metric-card {
  position: relative;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.metric-card.primary {
  border-top: 3px solid var(--red);
  padding-top: 18px;
}

.metric-icon {
  position: absolute;
  top: 17px;
  right: 16px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: #f5f1ed;
  color: #8b8279;
  font-size: 11px;
  font-weight: 800;
}

.primary .metric-icon {
  background: #fff0f0;
  color: var(--red);
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
}

.metric-value {
  display: block;
  overflow: hidden;
  margin: 11px 34px 9px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(21px, 2.2vw, 30px);
  letter-spacing: -0.035em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-change {
  font-size: 11px;
  font-weight: 800;
}

.metric-change small {
  margin-left: 4px;
  color: #aaa;
  font-size: inherit;
  font-weight: 400;
}

.metric-change.good {
  color: var(--good);
}

.metric-change.bad {
  color: var(--warn);
}

.metric-change.muted {
  color: #aaa;
  font-weight: 400;
}

.content-grid {
  display: grid;
  margin-top: 14px;
  grid-template-columns: minmax(0, 2fr) minmax(292px, 0.86fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.trend-panel,
.insight-panel {
  min-height: 324px;
  padding: 20px 21px 14px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin: 0 0 5px;
  font-size: 15px;
}

.legend {
  display: flex;
  padding-top: 3px;
  align-items: center;
  gap: 13px;
  color: #777;
  font-size: 10px;
  white-space: nowrap;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.sales-key {
  background: var(--red);
}

.spend-key {
  background: #d7c9bd;
}

.roi-key {
  border-radius: 50% !important;
  background: #202020;
}

.chart-stage {
  position: relative;
  min-height: 250px;
  margin-top: 10px;
}

.trend-chart {
  width: 100%;
  height: 250px;
}

.panel-state {
  display: grid;
  min-height: 110px;
  place-items: center;
  color: #99928b;
  font-size: 12px;
  text-align: center;
}

.chart-stage > .panel-state {
  position: absolute;
  inset: 0;
  background: #fff;
}

.chart-stage > .panel-state[hidden] {
  display: none;
}

.count-badge {
  border-radius: 14px;
  background: #f2efeb;
  color: #777;
  padding: 5px 9px;
  font-size: 10px;
}

.diagnostics-list {
  margin-top: 10px;
}

.insight {
  display: grid;
  padding: 14px 0;
  border-top: 1px solid #f0ede9;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
}

.insight-icon {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 8px;
  background: #f0f1f4;
  color: #545e6b;
  font-size: 12px;
  font-weight: 800;
}

.insight.good .insight-icon,
.insight.success .insight-icon {
  background: #e9f7ef;
  color: var(--good);
}

.insight.warning .insight-icon,
.insight.warn .insight-icon,
.insight.error .insight-icon,
.insight.danger .insight-icon {
  background: #fff0ea;
  color: var(--red);
}

.insight strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
}

.insight p {
  margin: 0;
  color: #89837d;
  font-size: 10px;
  line-height: 1.55;
}

.product-panel {
  margin-top: 14px;
  overflow: hidden;
}

.product-head {
  padding: 19px 21px 14px;
  align-items: center;
}

.table-actions {
  display: flex;
  padding: 3px;
  border-radius: 7px;
  background: #f4f1ee;
}

.table-actions button {
  min-height: 31px;
  padding: 6px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #777;
  cursor: pointer;
  font-size: 10px;
}

.table-actions button.active {
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 13%);
  color: #222;
}

.table-actions button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.table-actions b {
  color: var(--red);
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th {
  padding: 10px 15px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #faf8f6;
  color: #8b857f;
  font-size: 9px;
  font-weight: 700;
  text-align: left;
}

td {
  padding: 12px 15px;
  border-bottom: 1px solid #f2efec;
  color: #4f4a46;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tbody tr:not(.state-row):hover {
  background: #fffaf8;
}

td:first-child {
  min-width: 300px;
}

.product-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.product-thumb {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: #ebe4dd;
  color: #665b52;
  font-weight: 800;
}

.product-copy {
  min-width: 0;
}

.product-copy strong {
  display: block;
  max-width: 260px;
  overflow: hidden;
  margin-bottom: 3px;
  color: #25211f;
  font-size: 11px;
  text-overflow: ellipsis;
}

.product-copy span {
  color: #aaa;
  font-size: 9px;
}

.status-pill {
  display: inline-flex;
  border-radius: 12px;
  padding: 4px 9px;
  font-size: 9px;
}

.status-pill.excellent {
  background: #e7f6ee;
  color: #177950;
}

.status-pill.normal,
.status-pill.info {
  background: #eef1f4;
  color: #52606d;
}

.status-pill.watch,
.status-pill.warning {
  background: #fff4df;
  color: #9b6416;
}

.status-pill.issue,
.status-pill.error {
  background: #ffeded;
  color: #b51f26;
}

.state-row td {
  height: 104px;
  color: #99928b;
  text-align: center;
}

.report-footer {
  display: flex;
  padding: 16px 3px 0;
  justify-content: space-between;
  gap: 18px;
  color: #918b85;
  font-size: 9px;
  line-height: 1.65;
}

.is-loading .skeleton-text {
  position: relative;
  color: transparent;
}

.is-loading .skeleton-text::after {
  position: absolute;
  inset: 3px 0;
  width: min(128px, 85%);
  border-radius: 5px;
  background: linear-gradient(90deg, #f2efeb 25%, #faf8f6 50%, #f2efeb 75%);
  background-size: 200% 100%;
  content: "";
  animation: loading-sheen 1.2s infinite;
}

@keyframes loading-sheen {
  to {
    background-position: -200% 0;
  }
}

/* Login */
.login-page {
  background:
    radial-gradient(circle at 15% 15%, rgb(217 31 38 / 8%), transparent 35%),
    linear-gradient(135deg, #f4f0eb, #faf9f7);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 30px 18px;
  place-items: center;
}

.login-card {
  width: min(100%, 410px);
  padding: 38px 36px 30px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 70px rgb(65 45 30 / 12%);
}

.login-brand {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 12px 12px 17px 17px;
  background: var(--red);
  box-shadow: inset 0 -5px 0 rgb(0 0 0 / 12%);
  color: #fff;
  font-family: Georgia, "Songti SC", serif;
  font-size: 21px;
  font-weight: 800;
}

.login-brand img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: contain;
}

.login-heading h1 {
  font-size: 27px;
}

.login-heading > p:last-child {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 12px;
}

.form-alert {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid #efc2c4;
  border-radius: 7px;
  background: #fff0f0;
  color: #9d1d23;
  font-size: 12px;
}

.login-form {
  display: grid;
  gap: 8px;
}

.login-form label {
  margin-top: 6px;
  color: #5e5955;
  font-size: 11px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 44px;
  border: 1px solid #dcd5cf;
  border-radius: 7px;
  background: #fff;
  padding: 0 12px;
  color: #222;
  outline: none;
}

.login-form input:focus {
  border-color: #ba8b8d;
}

.login-password-input {
  -webkit-text-security: disc;
}

.login-submit {
  height: 44px;
  margin-top: 14px;
}

.login-footnote {
  margin: 22px 0 0;
  color: #aaa39d;
  font-size: 10px;
  text-align: center;
}

@media (max-width: 1180px) {
  .topbar-inner {
    gap: 16px;
  }

  .platform-brand {
    min-width: 224px;
  }

  .brand-copy strong {
    font-size: 14px;
  }

  .platform-nav > a,
  .platform-nav > span {
    min-width: 64px;
    padding-inline: 9px;
  }

  .report-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 20px;
  }

  .filters {
    width: min(100%, 650px);
  }

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

@media (max-width: 900px) {
  .topbar-inner {
    min-height: 0;
    padding: 13px 22px 0;
    flex-wrap: wrap;
  }

  .platform-brand {
    min-width: 0;
  }

  .header-actions {
    order: 2;
  }

  .platform-nav {
    width: 100%;
    height: 49px;
    order: 3;
  }

  .platform-nav > a,
  .platform-nav > span {
    flex: 1 1 25%;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .insight-panel {
    min-height: 0;
  }

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

  .diagnostics-list .panel-state {
    grid-column: 1 / -1;
  }

  .insight {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 11px 15px 0;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }

  .brand-copy {
    margin-left: 9px;
  }

  .brand-copy strong {
    max-width: 164px;
    font-size: 13px;
  }

  .brand-copy small,
  .user-name {
    display: none;
  }

  .header-actions {
    gap: 7px;
  }

  .ghost-button {
    padding-inline: 9px;
    font-size: 10px;
  }

  .text-button {
    font-size: 10px;
  }

  .platform-nav {
    margin: 0 -15px;
    width: calc(100% + 30px);
  }

  .platform-nav > a,
  .platform-nav > span {
    min-width: 0;
    padding-inline: 3px;
  }

  .platform-nav span span,
  .platform-nav a span {
    font-size: 11px;
  }

  .page-shell {
    padding: 23px 14px 24px;
  }

  .report-heading {
    gap: 17px;
  }

  .report-title > p:last-child {
    line-height: 1.6;
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .filters label:first-child {
    grid-column: 1 / -1;
  }

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

  .status-banner {
    align-items: flex-start;
  }

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

  .metric-card {
    padding: 16px;
  }

  .metric-card.primary {
    padding-top: 14px;
  }

  .metric-card:last-child {
    grid-column: 1 / -1;
  }

  .metric-value {
    margin-right: 26px;
    font-size: clamp(19px, 7vw, 27px);
  }

  .metric-icon {
    top: 14px;
    right: 13px;
  }

  .trend-panel,
  .insight-panel {
    min-height: 0;
    padding: 17px 12px 12px;
  }

  .panel-head {
    gap: 8px;
  }

  .legend {
    padding-top: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .chart-stage,
  .trend-chart {
    min-height: 228px;
    height: 228px;
  }

  .diagnostics-list {
    display: block;
  }

  .insight {
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
  }

  .product-head {
    padding: 17px 14px 13px;
    align-items: stretch;
    flex-direction: column;
  }

  .table-actions {
    align-self: flex-start;
  }

  .report-footer {
    flex-direction: column;
    gap: 3px;
  }

  .login-card {
    padding: 32px 24px 26px;
  }
}

@media (max-width: 380px) {
  .brand-copy strong {
    max-width: 135px;
  }

  .ghost-button {
    font-size: 0;
  }

  .ghost-button::after {
    content: "打印";
    font-size: 10px;
  }

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

  .metric-card:last-child {
    grid-column: auto;
  }
}

@media print {
  @page {
    margin: 12mm;
    size: landscape;
  }

  body,
  html {
    min-width: 0;
    background: #fff;
  }

  .topbar {
    border-bottom: 2px solid #333;
    background: #fff;
    color: #111;
  }

  .topbar-inner {
    min-height: 58px;
    padding: 0;
  }

  .brand-mark {
    print-color-adjust: exact;
  }

  .brand-copy small {
    color: #555;
  }

  .platform-nav,
  .header-actions,
  .filters,
  .status-banner,
  .table-actions {
    display: none !important;
  }

  .page-shell {
    width: 100%;
    padding: 18px 0 0;
  }

  .report-heading {
    display: block;
  }

  .metrics-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .content-grid {
    grid-template-columns: 2fr 0.86fr;
  }

  .panel,
  .metric-card {
    break-inside: avoid;
    box-shadow: none;
  }

  .product-panel {
    break-before: page;
  }

  .table-scroll {
    overflow: visible;
  }

  table {
    min-width: 0;
  }
}

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