:root {
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #1baf7a;
  --series-3: #eda100;
  --series-4: #008300;
  --series-5: #4a3aa7;
  --series-6: #e34948;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.app-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 24px;
}

.legend {
  display: flex;
  gap: 16px;
}

.legend[hidden] {
  display: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

.legend-swatch-a {
  background: var(--series-1);
}

.legend-swatch-b {
  background: var(--series-2);
}

.chart-type-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.chart-type-button {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.chart-type-button + .chart-type-button {
  border-left: 1px solid var(--border);
}

.chart-type-button:hover {
  background: var(--gridline);
}

.chart-type-button.is-active {
  background: var(--text-primary);
  color: var(--surface-1);
}

.toggle-button {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-button:hover {
  background: var(--gridline);
}

.chart-main {
  flex: 1;
  min-height: 0;
  position: relative;
}

.chart-container {
  position: absolute;
  inset: 5vmin;
}

.chart-container svg {
  display: block;
}

.axis text {
  fill: var(--text-muted);
  font-size: 12px;
}

.axis .domain {
  stroke: var(--baseline);
}

.axis line {
  stroke: var(--baseline);
}

.grid line {
  stroke: var(--gridline);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.grid .domain {
  display: none;
}

.bar-group:focus {
  outline: none;
}

.bar-group:focus .segment {
  filter: brightness(1.08);
}

.segment {
  transition: filter 0.1s ease;
}

.bar-group.is-hovered .segment {
  filter: brightness(1.08);
}

.segment-a {
  fill: var(--series-1);
}

.segment-b {
  fill: var(--series-2);
}

.bar-hit {
  fill: transparent;
  cursor: pointer;
}

.pie-layout {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 24px;
}

.pie-svg-wrap svg {
  display: block;
}

.pie-slice {
  transition: filter 0.1s ease;
  cursor: pointer;
}

.pie-slice:focus {
  outline: none;
}

.pie-slice.is-hovered,
.pie-slice:focus {
  filter: brightness(1.08);
}

.pie-legend {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  width: 200px;
  flex: none;
}

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

.pie-legend-label {
  flex: none;
  width: 16px;
  color: var(--text-primary);
  font-weight: 600;
}

.pie-legend-value {
  flex: 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.pie-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex: none;
  display: inline-block;
}

.pie-swatch-a,
.pie-slice-a {
  background: var(--series-1);
  fill: var(--series-1);
}

.pie-swatch-b,
.pie-slice-b {
  background: var(--series-2);
  fill: var(--series-2);
}

.pie-swatch-c,
.pie-slice-c {
  background: var(--series-3);
  fill: var(--series-3);
}

.pie-swatch-d,
.pie-slice-d {
  background: var(--series-4);
  fill: var(--series-4);
}

.pie-swatch-e,
.pie-slice-e {
  background: var(--series-5);
  fill: var(--series-5);
}

.pie-swatch-f,
.pie-slice-f {
  background: var(--series-6);
  fill: var(--series-6);
}

.table-container {
  position: absolute;
  inset: 5vmin;
  overflow: auto;
  padding: 24px;
  background: var(--surface-1);
}

.data-table {
  border-collapse: collapse;
  width: 100%;
  max-width: 480px;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: right;
  padding: 6px 12px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
  font-variant-numeric: normal;
}

.data-table th {
  color: var(--text-secondary);
  font-weight: 600;
}

.data-table td {
  color: var(--text-primary);
}

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
  min-width: 140px;
}

.tooltip[hidden] {
  display: none;
}

.tooltip-header {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.tooltip-key {
  width: 10px;
  height: 2px;
  border-radius: 1px;
  display: inline-block;
  flex: none;
}

.tooltip-key-A {
  background: var(--series-1);
}

.tooltip-key-B {
  background: var(--series-2);
}

.tooltip-label {
  color: var(--text-secondary);
  flex: 1;
}

.tooltip-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.tooltip-total {
  border-top: 1px solid var(--gridline);
  margin-top: 4px;
  padding-top: 4px;
}
