:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --text: #1a1f36;
  --muted: #6b7280;
  --border: #e5e7eb;
  --purple: #8b7ec8;
  --purple-light: #f0edf8;
  --orange: #c9956c;
  --orange-light: #faf3ed;
  --blue: #6b9bd1;
  --green: #6aab8e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.site-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.main-content {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.section-block {
  margin-bottom: 2rem;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--purple-light);
  color: var(--purple);
  margin-left: 0.5rem;
}

.badge.orange {
  background: var(--orange-light);
  color: var(--orange);
}

.badge.green {
  background: #e8f3ed;
  color: var(--green);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.data-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

.data-card.purple { border-top: 4px solid var(--purple); }
.data-card.orange { border-top: 4px solid var(--orange); }
.data-card.neutral { border-top: 4px solid var(--blue); }

.data-card-header {
  padding: 1rem 1.25rem 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.data-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 0.75rem 1.25rem 1.25rem;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-label {
  font-size: 0.8125rem;
  color: var(--muted);
}

.metric-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.metric-value.small {
  font-size: 1.125rem;
}

.note-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: #92400e;
  margin-bottom: 1.5rem;
}

.progress-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.progress-section h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}

.progress-row {
  margin-bottom: 1rem;
}

.progress-row:last-child {
  margin-bottom: 0;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
}

.progress-label {
  font-weight: 500;
}

.progress-stats {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-bar-track {
  height: 10px;
  background: #f3f4f6;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 0;
}

.progress-bar-fill.action { background: var(--orange); }
.progress-bar-fill.video { background: var(--purple); }
.progress-bar-fill.combined { background: linear-gradient(90deg, var(--purple), var(--orange)); }

.progress-pct {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
  text-align: right;
}

.formula {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.chart-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.chart-wrap {
  position: relative;
  height: 220px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 0.625rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

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

th {
  background: #f9fafb;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

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

.stage-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.stage-header .stage-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  background: var(--purple-light);
  color: var(--purple);
  font-size: 0.8125rem;
  font-weight: 700;
}

.stage-header.orange .stage-num {
  background: var(--orange-light);
  color: var(--orange);
}

.stage-header.total .stage-num {
  background: #eef4fa;
  color: var(--blue);
}

.progress-table td.cell-progress {
  min-width: 200px;
}

.pct-main {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.25rem;
}

.pct-main.action { color: var(--orange); }
.pct-main.video { color: var(--purple); }

.pct-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.mini-bar {
  height: 6px;
  background: #f3f4f6;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.375rem;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.mini-bar-fill.action { background: var(--orange); }
.mini-bar-fill.video { background: var(--purple); }

.trend-panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: visible;
}

.trend-layout {
  display: flex;
  min-height: 320px;
}

.trend-sidebar {
  display: flex;
  flex-direction: column;
  width: 120px;
  flex-shrink: 0;
  padding: 0.625rem;
  gap: 0.5rem;
  background: #f8f9fb;
  border-right: 1px solid var(--border);
}

.trend-tab {
  padding: 0.875rem 0.75rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
  line-height: 1.35;
}

.trend-tab:hover {
  color: var(--text);
  border-color: #d1d5db;
}

.trend-tab.active {
  color: var(--text);
  font-weight: 600;
  border-color: var(--purple);
  box-shadow: 0 0 0 1px var(--purple-light);
}

.trend-content {
  flex: 1;
  min-width: 0;
  padding: 1rem 1.75rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.trend-chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.625rem;
  flex: 1;
  min-width: 0;
}

.trend-mini-chart {
  background: #f9fafb;
  border-radius: 10px;
  padding: 0.625rem 0.5rem 0.375rem;
  border: 1px solid var(--border);
  min-width: 0;
  overflow: hidden;
}

.trend-mini-chart h4 {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.trend-mini-chart-wrap {
  position: relative;
  height: 185px;
}

.subnav-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.subnav-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: #f8f9fb;
}

.subnav-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subnav-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
}

.subnav-tab.active {
  color: var(--text);
  font-weight: 600;
  background: var(--surface);
  border-bottom-color: var(--purple);
}

.subnav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 700;
}

.subnav-icon.orange {
  background: var(--orange-light);
  color: var(--orange);
}

.subnav-icon.total {
  background: #eef4fa;
  color: var(--blue);
}

.subnav-body {
  padding: 1.25rem;
  min-height: 280px;
}

.subnav-content {
  display: none;
}

.subnav-content.active {
  display: block;
}

.sub-details {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.sub-details:first-child {
  margin-top: 0;
}

.sub-details summary {
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  background: #f9fafb;
  list-style: none;
  user-select: none;
}

.sub-details summary::-webkit-details-marker {
  display: none;
}

.sub-details summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
}

.sub-details[open] summary::before {
  transform: rotate(90deg);
}

.sub-details .table-wrap,
.sub-details .compact-details {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

.sub-details .compact-details {
  padding: 0.75rem 0.875rem;
  border-top: 1px solid var(--border);
}

.compact-details {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.375rem 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
}

.compact-details dt {
  color: var(--muted);
  margin: 0;
}

.compact-details dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 1rem;
  border-radius: 8px;
  margin: 1.5rem;
}

@media (max-width: 640px) {
  .data-card-body {
    grid-template-columns: 1fr;
  }

  .trend-layout {
    flex-direction: column;
  }

  .trend-sidebar {
    width: 100%;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .trend-tab {
    flex: 1;
  }

}
