:root {
  --primary: #2457ff;
  --primary-dark: #1b3fd6;
  --primary-soft: #eef3ff;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --danger: #b42318;
  --ok: #027a48;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1200px;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: linear-gradient(135deg, #ffffff 0%, #eef3ff 100%);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.status {
  max-width: 420px;
  padding: 10px 16px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
}

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

.status.error {
  background: #fef3f2;
  color: var(--danger);
}

.container {
  padding: 18px 24px 28px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  grid-template-columns: 150px 150px 300px minmax(560px, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 4px;
  height: 58px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

label span {
  font-weight: 600;
  line-height: 1;
}

.product-field {
  min-width: 300px;
}

select,
input,
button {
  height: 28px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 14px;
  outline: none;
}

button {
  padding: 0 12px;
}

select,
input {
  min-width: 0;
}

.product-field select {
  width: 100%;
}

select:focus,
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 87, 255, 0.12);
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

button {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  transition: 0.16s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(36, 87, 255, 0.22);
}

button.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.stat-card {
  height: 58px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: none;
}

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

.stat-card strong {
  display: block;
  color: var(--text);
  font-size: 18px;
  line-height: 1.1;
}

.stat-card.accent {
  background: linear-gradient(135deg, #2457ff 0%, #6a7cff 100%);
  color: #fff;
}

.stat-card.accent span,
.stat-card.accent strong {
  color: #fff;
}

.card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.card-title p {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.card-title h2 {
  margin: 0;
  font-size: 18px;
}

.chart-hint {
  color: var(--muted);
  font-size: 13px;
}

.chart-card {
  margin-bottom: 14px;
}

.summary-chart {
  display: flex;
  align-items: end;
  gap: 16px;
  min-height: 260px;
  padding: 14px 18px 12px;
  overflow-x: auto;
  overflow-y: hidden;
}

.chart-bar {
  display: grid;
  grid-template-rows: 24px 160px 40px;
  justify-items: center;
  gap: 8px;
  width: 118px;
  min-width: 118px;
  height: 240px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
}

.chart-bar:hover,
.chart-bar.active {
  transform: none;
}

.bar-value {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  display: flex;
  align-items: end;
  justify-content: center;
  width: 44px;
  height: 160px;
  border-radius: 999px;
  background: #eef2ff;
  overflow: hidden;
}

.bar-fill {
  display: block;
  width: 100%;
  min-height: 10px;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(180deg, #6a7cff 0%, #2457ff 100%);
  transition: height 0.2s ease;
}

.chart-bar.active .bar-track {
  outline: 3px solid rgba(36, 87, 255, 0.16);
}

.chart-bar.active .bar-fill {
  background: linear-gradient(180deg, #ffb84d 0%, #ff7a00 100%);
}

.bar-label {
  display: -webkit-box;
  width: 100%;
  height: 34px;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty-state {
  width: 100%;
  margin: 18px 0;
  padding: 34px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.detail-card {
  min-width: 0;
}

.detail-title-row {
  justify-content: center;
  min-height: 72px;
  position: relative;
  text-align: center;
}

.detail-title-row > div:first-child {
  text-align: center;
}

.detail-total-pill {
  position: absolute;
  right: 18px;
  padding: 9px 13px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
}

.detail-table-wrap {
  height: calc(100vh - 560px);
  min-height: 360px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: #475467;
  font-weight: 700;
  text-align: center;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 9px 11px;
  text-align: center;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  border-left: 1px solid var(--line);
}

tbody tr:nth-child(even) {
  background: #fafbff;
}

tbody tr:hover {
  background: #eef3ff;
}

.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.strong {
  color: var(--primary);
  font-weight: 800;
}

tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: #fff7ed;
  color: var(--text);
  font-weight: 800;
}

@media (max-width: 1200px) {
  body {
    min-width: 0;
  }

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

  .toolbar {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .actions {
    flex-wrap: wrap;
  }

  .detail-table-wrap {
    height: auto;
    max-height: none;
  }
}
