:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f4f5f7;
  color: #1f2a44;
}

body {
  margin: 0;
  padding: 0;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

header h1 {
  margin-bottom: 0.25rem;
  font-size: clamp(1.75rem, 2.5vw, 2.3rem);
}

.lede {
  margin-top: 0;
  color: #4b5c7e;
}

.status {
  background: #fff2cc;
  border-left: 4px solid #ffbf00;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin: 1.5rem 0;
  font-weight: 500;
}

.status--success {
  background: #e6ffed;
  border-left-color: #34d399;
  color: #0f5132;
}

.status--error {
  background: #ffe4e6;
  border-left-color: #f87171;
  color: #842029;
}

.status--loading {
  background: #e5edff;
  border-left-color: #2f6fed;
  color: #1a2e66;
}

.cards-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(360px, 2fr);
  gap: 1.5rem;
  margin-top: 1.5rem;
  align-items: start;
}

.chart-card,
.table-card {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(31, 42, 68, 0.08);
  padding: 1.25rem 1.5rem;
}

.chart-card h2,
.table-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.chart-caption {
  margin-top: 0.5rem;
  color: #74819a;
  font-size: 0.8rem;
  text-align: center;
}

.chart-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.chart-card canvas {
  width: 100%;
  max-width: 280px;
  height: auto;
  aspect-ratio: 1;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-select {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #b6c2de;
  background: #ffffff;
  font-size: 0.95rem;
  color: inherit;
}

.refresh-button {
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  background: #2f6fed;
  color: #ffffff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease-in-out;
}

.refresh-button:hover {
  background: #2456b5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid #e2e7f1;
  text-align: left;
}

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

@media (max-width: 600px) {
  .container {
    padding: 1.5rem 1rem 2rem;
  }

  .cards-row {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 0.6rem;
  }
}
.table-card {
  min-width: 0;
  overflow-x: auto;
}

.advanced-toggle {
  background: transparent;
  border: 1px solid #b6c2de;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}

.advanced-panel {
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 8px rgba(31,42,68,0.06);
}

.advanced-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Ensure selects and the advanced toggle have good contrast in all color schemes */
.view-select,
.range-select,
.range-select-debug,
.range-select-debug option,
.range-select option,
.view-select option {
  color: #0f1724; /* dark text */
  background: #ffffff; /* white background */
  border: 1px solid #b6c2de;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}

.advanced-toggle {
  color: #0f1724; /* dark text for visibility */
  background: #ffffff;
  border: 1px solid #b6c2de;
}

/* Make sure debug refresh matches primary refresh button style */
.advanced-controls .refresh-button {
  background: #2f6fed;
  color: #ffffff;
}
