:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --border: #e2e5eb;
  --text: #16181d;
  --muted: #5d6573;
  --accent: #1d4ed8;
  --accent-soft: #e5ecff;
  --ee: #0f766e;
  --ee-soft: #dcf3ef;
  --other: #9a3412;
  --other-soft: #fde9dc;
  --bar: #3b6cf0;
  --g0: #2f62e9;
  --g1: #0d9488;
  --g2: #c2570c;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --border: #2a2f3a;
    --text: #e7e9ee;
    --muted: #9aa3b2;
    --accent: #7ea2ff;
    --accent-soft: #1d2a4d;
    --ee: #5eead4;
    --ee-soft: #12302c;
    --other: #fdba74;
    --other-soft: #3a2414;
    --bar: #7ea2ff;
    --g0: #7ea2ff;
    --g1: #2dd4bf;
    --g2: #fb923c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.brand svg rect { fill: var(--accent); }
.brand svg path { fill: var(--surface); }
nav { display: flex; gap: 4px; }
nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
nav a.active, nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.lede { color: var(--muted); max-width: 780px; margin: 20px 0 16px; }

.controls {
  display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.controls label { min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.controls select, .controls input {
  font: inherit; font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-height: 34px;
}
.controls .search { flex: 1 1 200px; }
.controls .search input { width: 100%; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; margin: 16px 0 32px; align-items: start; }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .areas { order: -1; }
}

.ranking, .areas { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.table-meta { padding: 10px 14px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 1px solid var(--border); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr.inst-row { border-top: 1px solid var(--border); cursor: pointer; }
tbody tr.inst-row:first-child { border-top: 0; }
tbody tr.inst-row:hover { background: var(--surface-2); }
tbody tr.inst-row.open { background: var(--accent-soft); }
.inst-name { font-weight: 600; display: flex; align-items: baseline; gap: 6px; }
.caret { display: inline-block; width: 10px; color: var(--muted); transition: transform .15s; }
tr.open .caret { transform: rotate(90deg); }
.country { font-size: 12px; color: var(--muted); font-weight: 400; }
.minibars { display: flex; gap: 1px; margin-top: 5px; height: 6px; max-width: 100%; }
.minibars span { display: block; border-radius: 2px; min-width: 2px; }
.minibars .g0, .legend .g0 { background: var(--g0); }
.minibars .g1, .legend .g1 { background: var(--g1); }
.minibars .g2, .legend .g2 { background: var(--g2); }
.group-head h3 .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }

tr.detail > td { padding: 0 12px 14px; background: var(--accent-soft); }
.detail-inner { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.area-breakdown { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.chip b { font-variant-numeric: tabular-nums; }
.fac-table th, .fac-table td { padding: 6px 12px; font-size: 13.5px; }
.fac-table tr + tr td { border-top: 1px solid var(--border); }
.fac-links { display: inline-flex; gap: 6px; margin-left: 6px; font-size: 12px; }
.fac-areas { color: var(--muted); font-size: 12.5px; }
.badge { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; margin-left: 6px; }
.badge.ee { background: var(--ee-soft); color: var(--ee); }
.badge.other { background: var(--other-soft); color: var(--other); }
.badge.unknown { background: var(--surface-2); color: var(--muted); }
.more { display: block; margin: 12px auto 16px; font: inherit; padding: 8px 18px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.more:hover { border-color: var(--accent); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.areas { padding: 12px 14px 6px; position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
@media (max-width: 860px) { .areas { position: static; max-height: none; } }
.areas-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; list-style: none; cursor: default; }
.areas-head::-webkit-details-marker { display: none; }
.area-count { font-weight: 500; color: var(--muted); font-size: 13px; }
@media (max-width: 860px) {
  .areas-head { cursor: pointer; }
  .areas-head h2::before { content: "▸ "; color: var(--muted); }
  details[open] > .areas-head h2::before { content: "▾ "; }
  .areas { padding-bottom: 12px; }
}
.areas h2 { font-size: 15px; margin: 0; }
.toggles button, .group-head button {
  font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer;
}
.toggles button:hover, .group-head button:hover { border-color: var(--accent); }
.group { margin: 12px 0; }
.group-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.group-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0; }
.area { display: flex; gap: 8px; align-items: flex-start; padding: 4px 2px; border-radius: 6px; cursor: pointer; }
.area:hover { background: var(--surface-2); }
.area input { margin-top: 4px; accent-color: var(--accent); }
.area .venues { display: block; font-size: 12px; color: var(--muted); }

.about { max-width: 820px; padding-bottom: 40px; }
.about h1 { margin-top: 28px; }
.about h2 { font-size: 18px; margin-top: 28px; }
.about table { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.about td, .about th { border-bottom: 1px solid var(--border); font-size: 14px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

.site-footer { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; color: var(--muted); font-size: 13px; padding-top: 12px; padding-bottom: 28px; border-top: 1px solid var(--border); }

@media (max-width: 560px) {
  th, td { padding: 7px 8px; }
  .controls select, .controls input { width: 100%; }
  .header-inner nav a { padding: 6px 8px; }
  .inst-name { display: block; }
  .inst-name .caret { margin-right: 4px; }
  .fac-table .hide-sm { display: none; }
  .controls label { flex: 1 1 40%; }
}
.adj-tag { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 0 4px; margin-left: 4px; }
.toggles { display: flex; gap: 4px; }
