:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d8dee6;
  --accent: #0f766e;
  --accent-soft: #d9f2ef;
  --gold: #b7791f;
  --gold-soft: #fff4d6;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --shadow: 0 12px 28px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
  line-height: 1.3;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

select,
button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 650;
}

select {
  padding: 0 34px 0 12px;
}

button {
  padding: 0 16px;
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.text-button {
  height: 32px;
  padding: 0 10px;
  background: transparent;
  border-color: var(--line);
  color: var(--accent);
}

.status {
  min-height: 44px;
  margin-bottom: 14px;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 14px;
  color: var(--muted);
  box-shadow: var(--shadow);
}

.notice.error {
  border-color: #f5b5ae;
  background: var(--danger-soft);
  color: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

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

.metric {
  min-height: 104px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric span,
.panel-header span {
  color: var(--muted);
  font-size: 0.85rem;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.55rem;
  line-height: 1.1;
}

.panel {
  margin-top: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.chart {
  min-height: 300px;
  padding: 12px 16px 16px;
}

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.chart-controls select {
  min-width: 240px;
  max-width: min(360px, 100%);
  height: 36px;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

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

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

.legend-swatch.openai {
  background: var(--accent);
}

.legend-swatch.anthropic {
  background: var(--gold);
}

.spend-svg {
  display: block;
  width: 100%;
  height: 280px;
}

.grid-line {
  stroke: #edf0f3;
  stroke-width: 1;
}

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

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

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

.svg-bar.openai {
  fill: var(--accent);
}

.svg-bar.anthropic {
  fill: var(--gold);
}

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

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

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

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

h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  line-height: 1.3;
  letter-spacing: 0;
}

.detail-row td {
  background: #f9fafb;
  padding: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 16px;
}

.nested-table {
  min-width: 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.nested-table th,
.nested-table td {
  padding: 10px 12px;
}

.provider {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: capitalize;
}

.provider.openai {
  background: var(--accent-soft);
  color: var(--accent);
}

.provider.anthropic {
  background: var(--gold-soft);
  color: var(--gold);
}

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

.empty {
  padding: 24px 16px;
  color: var(--muted);
}

@media (max-width: 780px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .controls {
    justify-content: stretch;
  }

  select,
  button {
    flex: 1 1 150px;
  }

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

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-controls {
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
  }

  .chart-controls select {
    width: 100%;
  }

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

  h1 {
    font-size: 1.7rem;
  }
}

@media (max-width: 460px) {
  .metrics {
    grid-template-columns: 1fr;
  }
}
