* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: #172033;
  background: #f5f7fb;
}

button,
input {
  font: inherit;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #5a6b85;
  font-size: 14px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.12;
}

h2 {
  font-size: 17px;
}

.header-actions,
.upload-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-zone {
  margin-bottom: 18px;
}

.drop-area {
  flex: 1 1 540px;
  min-height: 112px;
  border: 1.5px dashed #9baac2;
  background: #fff;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  padding: 22px;
  cursor: pointer;
}

.drop-area span {
  color: #5a6b85;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.drop-area input {
  display: none;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
}

button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

.primary {
  min-height: 112px;
  background: #1677ff;
  color: #fff;
  font-weight: 700;
}

.secondary {
  background: #fff;
  color: #172033;
  border: 1px solid #d6deeb;
}

.alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff4e6;
  color: #a24b00;
  margin: 12px 0;
}

.report {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.stat,
.panel {
  background: #fff;
  border: 1px solid #e1e7f0;
  border-radius: 8px;
}

.stat {
  min-height: 104px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

.stat span {
  color: #5a6b85;
  font-size: 13px;
}

.stat strong {
  font-size: 24px;
  line-height: 1.1;
}

.panel {
  padding: 18px;
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.sheet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sheet-list span,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 6px;
  background: #eef5ff;
  color: #115bb5;
  padding: 4px 8px;
  font-size: 13px;
}

.tag.danger {
  background: #fff0f0;
  color: #c81e1e;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1.25fr 1.25fr .9fr;
  gap: 12px;
}

.chart {
  width: 100%;
  height: 320px;
}

.table-wrap {
  overflow: auto;
  max-height: 520px;
  border: 1px solid #e9eef6;
  border-radius: 8px;
}

.compact-panel .table-wrap {
  max-height: 320px;
}

.compact-panel table {
  min-width: 760px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1800px;
  background: #fff;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid #edf1f7;
  font-size: 14px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #40516b;
  font-weight: 700;
  white-space: nowrap;
}

td {
  color: #26344c;
}

.live-ranking th {
  cursor: grab;
  user-select: none;
}

.live-ranking th.dragging {
  opacity: .55;
}

.live-ranking th.drag-over {
  box-shadow: inset 3px 0 0 #1677ff;
}

.drag-handle {
  color: #8a99ad;
  font-size: 12px;
  margin-right: 6px;
}

.sort-button {
  min-height: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  border: 0;
  padding: 0;
  font-weight: 700;
  cursor: pointer;
}

.live-ranking .col-productName {
  min-width: 460px;
  max-width: 620px;
  white-space: normal;
  line-height: 1.45;
}

.live-ranking .col-productId {
  min-width: 128px;
}

.group-row td {
  position: sticky;
  left: 0;
  background: #f1f6ff;
  color: #115bb5;
  font-weight: 700;
  border-top: 1px solid #d9e7ff;
  border-bottom: 1px solid #d9e7ff;
}

.empty-cell,
.empty-text {
  color: #697a93;
}

.advice ol {
  margin: 0;
  padding-left: 22px;
}

.advice li {
  margin: 10px 0;
  line-height: 1.6;
}

.talk-track {
  margin: 0;
  line-height: 1.8;
  color: #26344c;
}

.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1080px) {
  main {
    padding: 18px;
  }

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

@media (max-width: 720px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .upload-zone {
    align-items: stretch;
  }

  .primary {
    width: 100%;
    min-height: 48px;
  }

  .stats-grid,
  .charts-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .stat {
    min-height: 92px;
  }

  .chart {
    height: 280px;
  }
}
