:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5b6675;
  --border: #d8dde4;
  --ok: #1f8a4c;
  --late: #c27c0e;
  --stale: #c0392b;
  --accent: #2f5fb3;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b2129;
    --text: #e6eaf0;
    --muted: #9aa5b4;
    --border: #2d3540;
    --ok: #3cbf74;
    --late: #e3a53a;
    --stale: #ef6b5e;
    --accent: #7aa2f0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header, main, footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

header { padding-top: 24px; }
h1 { margin: 0 0 4px; font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin: 24px 0 12px; }
header p, footer, .stamp, .info { color: var(--muted); }
footer { padding-bottom: 24px; font-size: 0.85rem; }

.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 6px solid var(--muted);
  border-radius: 8px;
  padding: 12px 14px;
}

.card.ok { border-left-color: var(--ok); }
.card.late { border-left-color: var(--late); }
.card.stale { border-left-color: var(--stale); }
.card h3 { margin: 0 0 6px; font-size: 1rem; }
.card p { margin: 2px 0; }
.card .age { font-weight: 600; }
.card.late .age { color: var(--late); }
.card.stale .age { color: var(--stale); }
.detail { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.detail.alert { color: var(--accent); font-weight: 600; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.controls label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
}

.controls select {
  margin-top: 2px;
  min-width: 150px;
  padding: 6px 8px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.map {
  height: min(70vh, 640px);
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.raster { image-rendering: pixelated; }

.legend {
  background: rgba(255, 255, 255, 0.92);
  color: #1c2430;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  line-height: 1.5;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.legend .note { color: #5b6675; margin-bottom: 4px; }
.legend .row { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 14px; height: 14px; border: 1px solid rgba(0, 0, 0, 0.2); }

@media (max-width: 600px) {
  .controls select { min-width: 0; width: 100%; }
  .controls label { flex: 1 1 45%; }
}
