:root {
  color-scheme: light;
  --page-plane:      #f9f9f7;
  --surface-1:       #fcfcfb;
  --text-primary:    #0b0b0b;
  --text-secondary:  #52514e;
  --text-muted:      #898781;
  --gridline:        #e1e0d9;
  --baseline:        #c3c2b7;
  --border:          rgba(11,11,11,0.10);
  --series-1:        #2a78d6;
  --series-1-wash:   rgba(42,120,214,0.10);
  --good:            #006300;
}

@media (prefers-color-scheme: light) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page-plane:      #0d0d0d;
    --surface-1:       #1a1a19;
    --text-primary:    #ffffff;
    --text-secondary:  #c3c2b7;
    --text-muted:      #898781;
    --gridline:        #2c2c2a;
    --baseline:        #383835;
    --border:          rgba(255,255,255,0.10);
    --series-1:        #3987e5;
    --series-1-wash:   rgba(57,135,229,0.14);
    --good:            #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page-plane:      #0d0d0d;
  --surface-1:       #1a1a19;
  --text-primary:    #ffffff;
  --text-secondary:  #c3c2b7;
  --text-muted:      #898781;
  --gridline:        #2c2c2a;
  --baseline:        #383835;
  --border:          rgba(255,255,255,0.10);
  --series-1:        #3987e5;
  --series-1-wash:   rgba(57,135,229,0.14);
  --good:            #0ca30c;
}

* { box-sizing: border-box; }

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

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 600;
}

.subtitle {
  margin: 0 0 32px;
  color: var(--text-secondary);
  font-size: 15px;
}

/* Stat tiles */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

.stat-label {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
}

.stat-delta {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Chart cards */
.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px 8px;
  margin-bottom: 20px;
}

.chart-card-head h2 {
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 600;
}

.chart-subtitle {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.chart-body { position: relative; }

.chart-body svg { width: 100%; height: auto; display: block; overflow: visible; }

.bar {
  fill: var(--series-1);
}
.bar:hover, .bar.is-active {
  fill: var(--series-1);
  opacity: 0.85;
}

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

.bar-value-label,
.axis-label,
.axis-tick {
  fill: var(--text-secondary);
  font-size: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.axis-tick { fill: var(--text-muted); }

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

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.1s ease;
  white-space: nowrap;
  z-index: 10;
}
.tooltip.is-visible { opacity: 1; }
.tooltip-value {
  font-weight: 600;
  color: var(--text-primary);
}
.tooltip-label {
  color: var(--text-secondary);
}

/* Table */
.table-section { margin-bottom: 32px; }

.table-section summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 4px 0;
}

.table-wrap { overflow-x: auto; margin-top: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}

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

/* Facility lookup */
.facility-lookup {
  margin-bottom: 32px;
}

.lookup-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
}

.lookup-subtitle {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.lookup-controls {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.year-selector,
.search-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.year-selector {
  min-width: 160px;
}

.search-box {
  flex: 1;
  min-width: 250px;
}

.search-input-group {
  display: flex;
  gap: 8px;
}

.search-input-group input {
  flex: 1;
}

.lookup-controls label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.lookup-controls select,
.lookup-controls input {
  padding: 10px 12px;
  font-size: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.lookup-controls select:focus,
.lookup-controls input:focus {
  outline: 2px solid var(--series-1);
  outline-offset: -1px;
}

.lookup-controls input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--series-1);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

.search-btn:hover {
  opacity: 0.85;
}

.search-btn:active {
  transform: translateY(1px);
}

.search-btn:focus {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
}

/* Search results */
.search-results {
  min-height: 60px;
}

.search-hint {
  padding: 16px;
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.search-no-results {
  padding: 16px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.result-item {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  transition: background 0.15s ease;
}

.result-item:hover {
  background: var(--series-1-wash);
}

.result-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.result-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.result-id {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.result-status {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
}

.status-reported {
  background: rgba(0, 99, 0, 0.12);
  color: var(--good);
}

.status-not-reported {
  background: var(--series-1-wash);
  color: var(--text-secondary);
}

/* Footer */
.page-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}
