/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:          #f5f5f0;
  --surface:     #ffffff;
  --surface-2:   #f0ede8;
  --border:      #ddd;
  --text:        #222;
  --text-muted:  #666;
  --accent:      #e8a020;
  --accent-dark: #c07010;
  --green:       #27ae60;
  --yellow:      #e6a817;
  --red:         #c0392b;
  --gray:        #95a5a6;
  --radius:      8px;
  --shadow:      0 1px 4px rgba(0,0,0,0.08);
  --font:        system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #161612;
    --surface:    #1f1f1b;
    --surface-2:  #2a2a25;
    --border:     #38382f;
    --text:       #e8e8e0;
    --text-muted: #888;
    --shadow:     0 1px 4px rgba(0,0,0,0.4);
  }
}

/* ── Reset / Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

/* ── Accessibility ─────────────────────────────────────────────────────────── */
.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;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.yard-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

select {
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ── Main layout ───────────────────────────────────────────────────────────── */
main {
  width: 100%;
  padding: 1.5rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Status cards stay readable at any width */
#status-section {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  align-self: center;
}

/* ── Status cards ──────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.status-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--gray);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.status-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.status-card.status-green  { border-left-color: var(--green); }
.status-card.status-yellow { border-left-color: var(--yellow); }
.status-card.status-red    { border-left-color: var(--red); }
.status-card.status-gray   { border-left-color: var(--gray); opacity: 0.7; }

.metrics {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
}

.metric .label { color: var(--text-muted); font-size: 0.8rem; }
.metric .value { font-weight: 600; font-variant-numeric: tabular-nums; }

.card-footer {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Chart sections ────────────────────────────────────────────────────────── */
.chart-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.chart-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.chart-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 1;
  min-height: 160px;
}

/* ── Range buttons ─────────────────────────────────────────────────────────── */
.range-group {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
}

.range-btn {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.25rem 0.6rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.range-btn:hover { background: var(--border); color: var(--text); }

.range-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Accessibility data tables ─────────────────────────────────────────────── */
details { font-size: 0.85rem; }
summary { cursor: pointer; color: var(--text-muted); padding: 0.25rem 0; user-select: none; }
summary:hover { color: var(--text); }

.data-table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.data-table-wrap table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.data-table-wrap th,
.data-table-wrap td {
  text-align: left;
  padding: 0.3rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

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

/* ── Footer ────────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .chart-header { flex-direction: column; align-items: flex-start; }
  .chart-wrap   { aspect-ratio: 2 / 1; }
}
