:root {
  color-scheme: light;
  --navy: #0a2438;
  --navy-2: #123b54;
  --ink: #132331;
  --muted: #667786;
  --teal: #0bb8ae;
  --teal-dark: #078d87;
  --teal-soft: #dff7f5;
  --blue-soft: #eaf1f8;
  --amber: #f2a83b;
  --surface: #ffffff;
  --canvas: #f3f7fa;
  --line: #dbe5ec;
  --shadow: 0 16px 38px rgba(18, 50, 70, 0.09);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(11, 184, 174, 0.04), transparent 34%),
    var(--canvas);
}

button,
select,
input {
  font: inherit;
}

button,
a,
select,
input {
  outline: none;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  box-shadow: 0 0 0 3px rgba(11, 184, 174, 0.25);
}

.topbar {
  min-height: 88px;
  padding: 18px clamp(20px, 4vw, 58px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  color: #fff;
  background:
    radial-gradient(circle at 82% -30%, rgba(11, 184, 174, 0.36), transparent 35%),
    var(--navy);
  border-bottom: 3px solid var(--teal);
}

.brand,
.header-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px 4px 11px 4px;
  color: var(--navy);
  background: var(--teal);
  font-size: 22px;
  font-weight: 850;
}

.eyebrow,
.section-kicker,
.kpi-card p {
  margin: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.eyebrow {
  margin-bottom: 2px;
  color: #a9c0cf;
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 31px);
  letter-spacing: -0.02em;
}

.header-actions {
  gap: 20px;
}

.freshness {
  display: grid;
  gap: 2px;
  padding-right: 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  text-align: right;
}

.freshness span {
  color: #a9c0cf;
  font-size: 12px;
}

.freshness strong {
  font-size: 15px;
}

.download-button {
  padding: 11px 16px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: 160ms ease;
}

.download-button:hover {
  background: rgba(255, 255, 255, 0.17);
  transform: translateY(-1px);
}

.dashboard-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 26px auto 36px;
}

.filters {
  display: grid;
  grid-template-columns: 125px 190px 150px minmax(170px, 1fr) minmax(220px, 1.35fr) auto;
  align-items: end;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(18, 50, 70, 0.05);
}

.filters label,
.field-group {
  display: grid;
  gap: 7px;
}

.filters label > span,
.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  color: var(--ink);
  background: #fbfdfe;
  border: 1px solid #cfdce5;
  border-radius: 9px;
}

select:hover,
input:hover,
select:focus,
input:focus {
  border-color: var(--teal-dark);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  background: var(--blue-soft);
  border-radius: 9px;
}

.segmented button {
  min-height: 36px;
  color: #526675;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
}

.segmented button.active {
  color: #fff;
  background: var(--navy-2);
  box-shadow: 0 4px 12px rgba(18, 59, 84, 0.18);
}

.reset-button {
  min-height: 42px;
  padding: 0 16px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  border: 1px solid #bfeae7;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 750;
}

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

.kpi-card {
  min-height: 132px;
  padding: 20px 22px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 9px 24px rgba(18, 50, 70, 0.05);
}

.kpi-card p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.kpi-card strong {
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.kpi-card span {
  color: var(--muted);
  font-size: 13px;
}

.kpi-primary {
  color: #fff;
  background:
    linear-gradient(122deg, rgba(11, 184, 174, 0.28), transparent 60%),
    var(--navy-2);
  border-color: var(--navy-2);
}

.kpi-primary p,
.kpi-primary span {
  color: #c6dbe5;
}

.trend-card {
  position: relative;
  margin-top: 18px;
  min-height: 400px;
  padding: 22px 24px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.trend-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--teal);
}

.card-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.section-kicker {
  margin-bottom: 5px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 850;
}

h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.015em;
}

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.legend span {
  width: 24px;
  height: 3px;
  background: var(--teal);
  border-radius: 4px;
}

.chart-wrap {
  position: relative;
  height: 305px;
  margin-top: 14px;
}

#trendChart {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-tooltip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  min-width: 122px;
  padding: 9px 11px;
  color: #fff;
  background: var(--navy);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(10, 36, 56, 0.22);
  font-size: 13px;
  line-height: 1.5;
}

.empty-state {
  padding: 80px 0;
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  padding: 36px 0;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 0.82fr 1.18fr 1.1fr;
  gap: 18px;
  margin-top: 18px;
}

.panel,
.detail-card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 9px 24px rgba(18, 50, 70, 0.05);
}

.panel {
  min-height: 340px;
}

.panel-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.condition-content {
  min-height: 250px;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  gap: 18px;
  padding-top: 18px;
}

.donut {
  --refurb-angle: 0deg;
  position: relative;
  width: 164px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--teal) 0 var(--refurb-angle), var(--navy-2) var(--refurb-angle) 360deg);
  box-shadow: inset 0 0 0 1px rgba(10, 36, 56, 0.08);
}

.donut::after {
  content: "";
  position: absolute;
  width: 104px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
}

.donut > div {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 2px;
  text-align: center;
}

.donut strong {
  font-size: 25px;
}

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

.condition-legend {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.condition-legend > div {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  background: #f7fafc;
  border-radius: 10px;
}

.condition-legend p {
  margin: 0;
  display: grid;
  gap: 2px;
}

.condition-legend strong {
  font-size: 17px;
}

.condition-legend small {
  color: var(--muted);
  font-size: 12px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.legend-dot.new {
  background: var(--navy-2);
}

.legend-dot.refurb {
  background: var(--teal);
}

.bar-list {
  margin-top: 18px;
  display: grid;
  gap: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(92px, 1.2fr) minmax(100px, 2fr) 58px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  background: var(--blue-soft);
  border-radius: 999px;
}

.bar-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #4fd2c9);
  border-radius: inherit;
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.ranking-list {
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  list-style: none;
}

.ranking-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 28px;
  border-bottom: 1px solid #edf2f5;
  font-size: 13px;
}

.ranking-list li:last-child {
  border-bottom: 0;
}

.rank-number {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ranking-list li:nth-child(-n + 3) .rank-number {
  color: var(--teal-dark);
}

.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.rank-value {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.detail-card {
  margin-top: 18px;
}

.detail-heading {
  margin-bottom: 16px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
}

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

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid #e6edf2;
  text-align: left;
  font-size: 13px;
}

th {
  color: #fff;
  background: var(--navy-2);
  font-weight: 750;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: var(--teal-soft);
}

td {
  color: #2d3c48;
}

td.number,
th.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pagination {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.pagination button {
  min-height: 36px;
  padding: 0 13px;
  color: var(--navy-2);
  background: #f6f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

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

.pagination span {
  min-width: 82px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.data-note {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
}

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

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

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

  .sku-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .freshness {
    text-align: left;
  }

  .dashboard-shell {
    width: min(100% - 24px, 1480px);
    margin-top: 14px;
  }

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

  .search-field {
    grid-column: auto;
  }

  .trend-card {
    min-height: 360px;
    padding: 18px 16px;
  }

  .chart-wrap {
    height: 260px;
  }

  .data-note {
    flex-direction: column;
  }

  .sku-panel {
    grid-column: auto;
  }

  .condition-legend {
    grid-template-columns: 1fr;
  }
}
