:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-soft: #eef4ef;
  --ink: #17201b;
  --muted: #5c675f;
  --line: #dce3dd;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --pink: #ec4899;
  --purple: #8b5cf6;
  --teal-dark: #0f766e;
  --shadow: 0 18px 45px rgba(23, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  background: rgba(247, 248, 245, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
  font-weight: 780;
  letter-spacing: 0;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.subtitle,
.section-note,
.muted {
  color: var(--muted);
}

.subtitle {
  margin-top: 8px;
  font-size: 14px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
}

.section {
  margin-top: 24px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.section-head .eyebrow {
  margin-bottom: 0;
}

.section-head.compact {
  margin-bottom: 18px;
}

.section-note {
  max-width: 520px;
  font-size: 13px;
  line-height: 1.45;
}

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

.kpi,
.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 174px;
  padding: 18px;
}

.kpi-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpi-value {
  margin-top: 12px;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 820;
  letter-spacing: 0;
}

.kpi-sub {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.trend {
  font-weight: 760;
}

.trend.up {
  color: var(--green);
}

.trend.down {
  color: var(--red);
}

.panel {
  padding: 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 16px;
}

.bar-chart {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 88px;
  align-items: center;
  gap: 14px;
  min-height: 34px;
}

.bar-label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 720;
}

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

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
}

.bar-value {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.day-type-table {
  table-layout: fixed;
}

.day-type-table th,
.day-type-table td {
  width: 12.5%;
}

.day-type-table th:first-child,
.day-type-table td:first-child {
  width: 22%;
}

.cpc-day-table {
  table-layout: fixed;
}

.cpc-day-table .cpc-day-col-type {
  width: 18%;
}

.cpc-day-table .cpc-day-col-small {
  width: 9%;
}

.cpc-day-table .cpc-day-col-metric {
  width: 11%;
}

.cpc-day-table .cpc-day-col-wide {
  width: 16.5%;
}

.cpc-day-table th,
.cpc-day-table td {
  padding-right: 12px;
  padding-left: 12px;
  text-align: center;
}

.cpc-day-table th:first-child,
.cpc-day-table td:first-child {
  text-align: left;
}

th {
  padding: 10px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th.month-sep,
td.month-sep {
  border-left: 1px solid var(--line);
  padding-left: 16px;
}

tr:last-child td {
  border-bottom: 0;
}

.product-cell {
  min-width: 420px;
  max-width: 720px;
  white-space: normal;
  text-align: left !important;
}

.product-cell strong,
.product-cell span {
  display: block;
}

.product-cell strong {
  line-height: 1.35;
}

.product-cell span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.roas-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 800;
}

.roas-top {
  background: #dcfce7;
  color: #047857;
}

.roas-high {
  background: #dbeafe;
  color: #1d4ed8;
}

.roas-mid {
  background: #fef3c7;
  color: #b45309;
}

.roas-low {
  background: #fee2e2;
  color: #b91c1c;
}

.rank-move {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 3px 7px;
  border-radius: 999px;
  font-weight: 820;
}

.rank-move.up {
  background: #dcfce7;
  color: #047857;
}

.rank-move.down {
  background: #fee2e2;
  color: #b91c1c;
}

.rank-move.same {
  background: #eef4ef;
  color: var(--muted);
}

.rank-move.new {
  background: #dbeafe;
  color: #1d4ed8;
}

.suggestion-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 820;
}

.suggestion-badge.increase {
  background: #dcfce7;
  color: #047857;
}

.suggestion-badge.reduce {
  background: #fee2e2;
  color: #b91c1c;
}

.suggestion-badge.neutral {
  background: #eef4ef;
  color: var(--muted);
  min-width: 34px;
}

.stack-list {
  display: grid;
  gap: 12px;
}

.metric-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.metric-tab {
  min-width: 92px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 760;
  transition: background 180ms ease, color 180ms ease;
}

.metric-tab.active,
.metric-tab:hover {
  background: var(--surface);
  color: var(--ink);
}

.combo-chart {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.combo-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.combo-title {
  font-size: 16px;
  font-weight: 820;
}

.combo-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

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

.legend-box {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-box.gmv {
  background: var(--blue);
}

.legend-box.cost {
  background: var(--amber);
}

.legend-line {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--green);
}

.combo-svg {
  display: block;
  width: 100%;
  height: auto;
}

.axis-line {
  stroke: #b9c4bd;
  stroke-width: 1;
}

.axis-line.subtle,
.grid-line {
  stroke: #e2e8e3;
  stroke-width: 1;
}

.bar-gmv {
  fill: var(--blue);
}

.bar-cost {
  fill: var(--amber);
}

.roas-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.roas-point {
  fill: var(--surface);
  stroke: var(--green);
  stroke-width: 3;
}

.axis-label,
.axis-title,
.value-label,
.roas-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.value-label,
.roas-label {
  fill: var(--ink);
  font-size: 12px;
}

.stack-item {
  display: grid;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.stack-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.stack-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.stack-name {
  font-weight: 760;
}

.stack-meta {
  color: var(--muted);
}

.product-card {
  display: grid;
  gap: 18px;
}

.product-name {
  font-size: 18px;
  line-height: 1.35;
  font-weight: 780;
}

.product-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.stat-value {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 800;
}

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

.level-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.level-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.level-metrics {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.level-metrics strong {
  color: var(--ink);
}

.error {
  padding: 24px;
  border: 1px solid var(--red);
  border-radius: 8px;
  background: #fff1f2;
  color: #7f1d1d;
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split,
  .level-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    position: static;
    flex-direction: column;
    padding: 20px;
  }

  main {
    padding: 16px 16px 32px;
  }

  h1 {
    font-size: 26px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .bar-row {
    grid-template-columns: 110px 1fr 72px;
    gap: 10px;
  }

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