:root {
  --bg: #f4efe7;
  --paper: rgba(255, 252, 247, 0.82);
  --paper-strong: #fffaf2;
  --ink: #1e2430;
  --muted: #5e6676;
  --line: rgba(37, 41, 48, 0.1);
  --accent: #c95f2d;
  --accent-soft: rgba(201, 95, 45, 0.14);
  --teal: #1f7a72;
  --teal-soft: rgba(31, 122, 114, 0.14);
  --berry: #92474f;
  --good: #13795b;
  --bad: #b54747;
  --shadow: 0 18px 40px rgba(69, 47, 19, 0.12);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "PingFang TC", "Noto Sans TC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(201, 95, 45, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(31, 122, 114, 0.18), transparent 30%),
    linear-gradient(180deg, #f7f1e7 0%, #efe7db 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.15) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.6), transparent);
}

.page-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.hero-badge,
.panel {
  background: var(--paper);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
}

.hero-copy {
  flex: 1;
  border-radius: 36px;
  padding: 28px 30px 30px;
}

.hero-copy h1 {
  margin: 10px 0 12px;
  font-size: clamp(2.2rem, 4vw, 4.1rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.hero-description {
  margin: 0;
  max-width: 1120px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.hero-badge {
  width: 250px;
  border-radius: 32px;
  padding: 24px;
  display: grid;
  align-content: start;
  gap: 10px;
  background:
    linear-gradient(160deg, rgba(31, 122, 114, 0.12), rgba(31, 122, 114, 0.02)),
    var(--paper);
}

.hero-badge span,
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

.hero-badge strong {
  display: block;
  margin-top: 8px;
  font-size: 1.35rem;
  line-height: 1.2;
}

.hero-badge small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.hero-badge-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

.hero-badge-value {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.3;
  font-weight: 800;
  word-break: break-word;
}

.hero-badge-sub {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.update-data-button {
  justify-self: start;
  border: 1px solid rgba(201, 95, 45, 0.18);
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, opacity 180ms ease;
  white-space: nowrap;
}

.update-data-button:hover {
  transform: translateY(-1px);
  background: var(--accent);
  color: #fff7f2;
}

.update-data-button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.refresh-data-status {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

.refresh-data-status.success {
  color: var(--good);
}

.refresh-data-status.error {
  color: var(--bad);
}

.hero-badge-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

.hero-badge-value {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.3;
  font-weight: 800;
  word-break: break-word;
}

.hero-badge-sub {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.update-data-button {
  justify-self: start;
  border: 1px solid rgba(201, 95, 45, 0.18);
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, opacity 180ms ease;
  white-space: nowrap;
}

.update-data-button:hover {
  transform: translateY(-1px);
  background: var(--accent);
  color: #fff7f2;
}

.update-data-button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.refresh-data-status {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

.refresh-data-status.success {
  color: var(--good);
}

.refresh-data-status.error {
  color: var(--bad);
}

.hero-badge-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.update-data-button {
  border: 1px solid rgba(201, 95, 45, 0.18);
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, opacity 180ms ease;
  white-space: nowrap;
}

.update-data-button:hover {
  transform: translateY(-1px);
  background: var(--accent);
  color: #fff7f2;
}

.update-data-button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.refresh-data-status {
  margin: 10px 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--muted);
}

.refresh-data-status.success {
  color: var(--good);
}

.refresh-data-status.error {
  color: var(--bad);
}

.dashboard {
  display: grid;
  gap: 20px;
}

.panel {
  border-radius: var(--radius);
  padding: 24px;
}

.filters-panel {
  padding-bottom: 22px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 8px 0 0;
  font-size: 1.45rem;
  letter-spacing: -0.04em;
}

.ghost-button,
.text-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
}

.text-button {
  color: var(--accent);
  font-weight: 700;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span,
.month-filter-head span {
  font-size: 0.92rem;
  font-weight: 700;
}

.field select {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
}

.month-filter {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.month-filter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.month-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.month-chip {
  border: 1px solid rgba(146, 71, 79, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--berry);
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

.month-chip:hover {
  transform: translateY(-1px);
}

.month-chip.active {
  background: var(--berry);
  color: #fff6f6;
}

.kpi-section {
  display: grid;
  gap: 16px;
}

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

.secondary-kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.45)),
    var(--paper);
}

.kpi-label-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.kpi-label {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.kpi-delta-pill {
  min-width: 70px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
  background: rgba(30, 36, 48, 0.06);
  color: var(--muted);
}

.kpi-delta-pill.positive {
  background: rgba(19, 121, 91, 0.14);
  color: var(--good);
}

.kpi-delta-pill.negative {
  background: rgba(181, 71, 71, 0.14);
  color: var(--bad);
}

.kpi-value {
  margin-top: 16px;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.kpi-footnote {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
  word-break: break-word;
}

.viz-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  gap: 18px;
}

.viz-grid.single-column {
  grid-template-columns: 1fr;
}

.chart-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.emphasis-panel {
  padding-bottom: 18px;
}

.metric-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.view-mode-switcher {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.metric-button {
  border: 1px solid rgba(201, 95, 45, 0.18);
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.metric-button.active {
  background: var(--accent);
  color: #fff7f2;
}

.mode-button {
  border: 1px solid rgba(31, 122, 114, 0.2);
  background: rgba(255, 255, 255, 0.72);
  color: var(--teal);
  border-radius: 999px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.mode-button.active {
  background: var(--teal);
  color: #effffb;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.line-chart-wrap {
  position: relative;
  overflow-x: auto;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.2)),
    rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(30, 36, 48, 0.08);
  padding: 10px;
}

.line-chart {
  width: 100%;
  min-width: 860px;
  height: auto;
  display: block;
}

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

.grid-line {
  stroke: rgba(30, 36, 48, 0.1);
  stroke-width: 1;
}

.grid-line.axis-base {
  stroke: rgba(30, 36, 48, 0.18);
}

.series-line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.series-point {
  stroke: #fffdf8;
  stroke-width: 3;
}

.hover-target {
  fill: transparent;
  cursor: pointer;
}

.month-hover-zone {
  fill: transparent;
  cursor: crosshair;
}

.series-point.is-active {
  filter: drop-shadow(0 0 0.7rem rgba(201, 95, 45, 0.28));
}

.month-guide-line {
  stroke: rgba(30, 36, 48, 0.18);
  stroke-width: 1.5;
  stroke-dasharray: 6 6;
}

.chart-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  width: 300px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(27, 31, 39, 0.92);
  color: #fffdf7;
  box-shadow: 0 18px 34px rgba(16, 19, 24, 0.26);
  pointer-events: none;
  z-index: 2;
}

.tooltip-title {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 8px;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  font-size: 0.92rem;
}

.tooltip-row + .tooltip-row {
  margin-top: 6px;
}

.tooltip-divider {
  height: 1px;
  margin: 10px 0;
  background: rgba(255, 255, 255, 0.12);
}

.tooltip-key {
  flex: 1 1 auto;
  color: rgba(255, 255, 255, 0.72);
}

.tooltip-value {
  flex: 0 0 112px;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tooltip-value.positive {
  color: #8de1b6;
}

.tooltip-value.negative {
  color: #ffb4b4;
}

.chart-caption {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 12px;
}

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

.mix-chart {
  display: grid;
  gap: 16px;
}

.stack-bar {
  display: flex;
  overflow: hidden;
  border-radius: 999px;
  height: 18px;
  background: rgba(30, 36, 48, 0.08);
}

.stack-segment {
  height: 100%;
  min-width: 0;
}

.stack-segment.bn {
  background: linear-gradient(90deg, #c95f2d, #e38844);
}

.stack-segment.mt {
  background: linear-gradient(90deg, #1f7a72, #59a39b);
}

.stack-segment.new {
  background: linear-gradient(90deg, #92474f, #b86873);
}

.stack-segment.old {
  background: linear-gradient(90deg, #7d8ca3, #a6b2c3);
}

.stack-segment.video {
  background: linear-gradient(90deg, #6f55c8, #9683e1);
}

.stack-segment.non-video {
  background: linear-gradient(90deg, #c2a86d, #dcc690);
}

.mix-legend {
  display: grid;
  gap: 12px;
}

.mix-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.mix-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.mix-dot.bn {
  background: #c95f2d;
}

.mix-dot.mt {
  background: #1f7a72;
}

.mix-dot.new {
  background: #92474f;
}

.mix-dot.old {
  background: #7d8ca3;
}

.mix-dot.video {
  background: #6f55c8;
}

.mix-dot.non-video {
  background: #c2a86d;
}

.mix-name,
.mix-value,
.mix-share {
  font-size: 0.95rem;
}

.mix-name,
.mix-share {
  color: var(--muted);
}

.mix-value {
  font-weight: 800;
}

.table-panel {
  overflow: hidden;
}

.table-count {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.table-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.3fr) minmax(180px, 220px) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.table-search input,
.compact-field select {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 2px;
  font-weight: 700;
  color: var(--ink);
}

.check-field input {
  width: 18px;
  height: 18px;
}

.table-wrap {
  overflow: auto;
}

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

thead th {
  text-align: left;
  padding: 0 12px 14px 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 14px 12px 14px 0;
  border-bottom: 1px solid rgba(30, 36, 48, 0.08);
  font-size: 0.92rem;
  vertical-align: top;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 800;
}

.tag.new {
  background: rgba(146, 71, 79, 0.14);
  color: var(--berry);
}

.tag.old {
  background: rgba(125, 140, 163, 0.16);
  color: #566170;
}

.tag.unique {
  background: rgba(31, 122, 114, 0.14);
  color: var(--teal);
}

.tag.repeat {
  background: rgba(30, 36, 48, 0.08);
  color: var(--muted);
}

.metric-neutral {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 1080px) {
  .hero,
  .viz-grid,
  .contrib-grid,
  .kpi-grid,
  .filters-grid,
  .table-toolbar {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .hero-badge {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 1380px);
    padding-top: 20px;
  }

  .panel,
  .hero-copy,
  .hero-badge {
    border-radius: 24px;
  }

  .update-data-button {
    padding: 8px 12px;
    font-size: 0.82rem;
  }

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