:root {
  --bg: #f4f6f8;
  --card: #fff;
  --ink: #1d2733;
  --muted: #6b7785;
  --accent: #c8102e;
  --line: #e4e8ec;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--ink); }
header { display: flex; justify-content: space-between; align-items: center; padding: 20px 32px; background: var(--card); border-bottom: 3px solid var(--accent); }
h1 { margin: 0; font-size: 22px; }
h2 { margin: 0 0 12px; font-size: 16px; }
.sub, .muted { color: var(--muted); margin: 0; font-weight: 400; }
main { max-width: 1200px; margin: 0 auto; padding: 24px 32px 48px; display: grid; gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
[hidden] { display: none !important; }

.view { display: grid; gap: 20px; }
.loading { display: flex; gap: 16px; align-items: center; padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.loading b, .loading span { display: block; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

td a { color: inherit; font-weight: 600; text-decoration: none; }
td a:hover { color: var(--accent); text-decoration: underline; }
td a.tag { font-weight: 400; }
td a.tag:hover { text-decoration: none; }

.back { color: var(--accent); text-decoration: none; font-weight: 600; justify-self: start; }
.back:hover { text-decoration: underline; }
.detail h2 { font-size: 24px; margin: 4px 0 8px; }
.detail .tags { margin-bottom: 14px; }
.detail .desc { white-space: pre-line; margin: 0 0 16px; max-width: 75ch; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--line); display: block; }
.gallery figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts a { color: var(--accent); }
.detail-map { height: 280px; border-radius: 8px; margin-bottom: 16px; }
.actions { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; }
.actions a { color: var(--accent); }
details.raw { margin-top: 12px; }
details.raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.raw pre { max-height: 420px; overflow: auto; background: var(--bg); padding: 12px; border-radius: 8px; font-size: 12px; }

.badge { padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.badge.live { background: #e3f5e8; color: #17703a; }
.badge.sample { background: #fff1d6; color: #8a5a00; }
.error, .notice { margin: 0; padding: 12px 16px; border-radius: 8px; }
.error { background: #fde8ea; color: #9b1c2c; }
.notice { background: #fff1d6; color: #6b4700; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.kpi b { display: block; font-size: 28px; }
.kpi span { color: var(--muted); font-size: 13px; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 130px 1fr 28px; gap: 8px; align-items: center; font-size: 13px; color: inherit; text-decoration: none; padding: 2px 4px; margin: 0 -4px; border-radius: 6px; }
a.bar:hover { background: var(--bg); }
a.bar.active { background: #fde8ea; }
.bar .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { background: var(--line); border-radius: 4px; height: 12px; }
.bar .fill { background: var(--accent); height: 100%; border-radius: 4px; }
.bar .val { text-align: right; color: var(--muted); }

#map { height: 380px; border-radius: 8px; }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar h2 { margin: 0; margin-right: auto; }
input, select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fafbfc; }
.tag { display: inline-block; background: var(--bg); border-radius: 4px; padding: 0 6px; margin: 0 4px 2px 0; font-size: 12px; }
a.tag { color: inherit; text-decoration: none; }
a.tag:hover { background: #fde8ea; color: var(--accent); }
a.tag.active { background: var(--accent); color: #fff; }
a.tag.more { color: var(--muted); }
.facts a.link { text-decoration: underline; }
.types { color: var(--muted); font-size: 13px; }
a.type-link { color: inherit; text-decoration: none; margin-right: 10px; }
a.type-link:hover { color: var(--accent); text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.chip { background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 12px; font-size: 13px; text-decoration: none; }
.chip:hover { opacity: 0.85; }
.chip-clear { font-size: 13px; color: var(--muted); }
