* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #151618;
  background-color: #f5f6f8;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
}

.page-header {
  padding: 2rem clamp(1.5rem, 5vw, 3rem) 1.25rem;
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.page-header__main {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: baseline;
  justify-content: space-between;
}

.page-header__main h1 {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  margin: 0;
}

.page-header__meta {
  display: flex;
  gap: .5rem;
  font-size: 0.95rem;
  color: #475569;
  align-items: center;
}

.page-header__subtext {
  margin-top: .75rem;
  font-size: 0.95rem;
  color: #334155;
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(148, 163, 184, 0.7);
  border-top-color: #0f172a;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.layout {
  flex: 1;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: clamp(1rem, 3vw, 1.5rem);
  align-items: stretch;
}

.card {
  background: #ffffff;
  border-radius: 14px;
  padding: 1.15rem;
  box-shadow: 0 12px 24px -20px rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.card--span2 {
  grid-column: span 2 / span 2;
}

@media (max-width: 720px) {
  .card--span2 {
    grid-column: span 1 / span 1;
  }
}

.card__header {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  align-items: baseline;
}

.card__header h2,
.card__header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #0f172a;
}

.card__header h3 {
  font-size: 1.1rem;
}

.card__sub {
  color: #64748b;
  font-size: 0.95rem;
}

.card__value {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 600;
  color: #0f172a;
}

.card__meta {
  font-size: 0.95rem;
  color: #475569;
}

.trend {
  font-size: 0.92rem;
  color: #475569;
  font-weight: 500;
}

.trend.up {
  color: #059669;
}

.trend.down {
  color: #dc2626;
}

.processed-box,
.tokens-list {
  background: #f8fafc;
  border-radius: 10px;
  padding: 1rem;
  font-family: "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  color: #0f172a;
  margin: 0;
  white-space: pre-wrap;
}

.tokens-list {
  max-height: 240px;
  overflow: auto;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
}

canvas {
  width: 100%;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.hist-tip {
  font-size: 0.95rem;
  color: #334155;
  min-height: 1.2rem;
}

.hist-tip strong {
  font-weight: 600;
}

#next_ready_24h_asof,
#next_ready_1h_asof,
#next_refresh_eta,
#updated {
  font-variant-numeric: tabular-nums;
}

.card__meta span {
  font-variant-numeric: tabular-nums;
}

.sparkline-header {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.sparkline-header__legend {
  display: flex;
  gap: 1rem;
  font-size: 0.95rem;
  color: #475569;
}

.sparkline-header__legend span::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: .4rem;
  vertical-align: middle;
}

.sparkline-header__legend span[data-series="24h"]::before {
  background: #1d4ed8;
}

.sparkline-header__legend span[data-series="1h"]::before {
  background: #059669;
}

.chart-footer {
  font-size: 0.9rem;
  color: #475569;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
}

.chart-axes-labels {
  display: flex;
  justify-content: space-between;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 500;
}

.chart-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 500;
}

.chart-y-axis span {
  display: inline-block;
  transform: translateY(-6px);
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-thumb {
  background-color: rgba(100, 116, 139, 0.35);
  border-radius: 999px;
}

::-webkit-scrollbar-track {
  background-color: rgba(241, 245, 249, 0.7);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.5rem 0;
  padding: 0.5rem 0;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  min-height: 28px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(248, 250, 252, 0.5);
  transition: opacity 0.3s ease, background 0.3s ease;
  opacity: calc(0.3 + (var(--fade-index) * 0.175));
}

.history-item:first-child {
  opacity: 1;
  background: rgba(241, 245, 249, 0.8);
  font-weight: 500;
}

.history-left {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex: 1;
}

.history-value {
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.history-time {
  color: #64748b;
  font-size: 0.8rem;
}

.history-delta {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history-delta.delta-up {
  color: #059669;
  background: rgba(5, 150, 105, 0.1);
}

.history-delta.delta-down {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
}

