:root {
  color-scheme: light;
  --ink: #152433;
  --muted: #5d6b78;
  --line: #d7e0e7;
  --panel: #ffffff;
  --panel-soft: #f4f7f9;
  --brand: #17324d;
  --brand-2: #2f5f87;
  --accent: #d9e9f5;
  --good: #17633a;
  --good-bg: #e4f4e9;
  --warn: #8a5600;
  --warn-bg: #fff2d6;
  --neutral-bg: #edf1f4;
  --danger: #982f2f;
  --shadow: 0 14px 35px rgba(18, 43, 63, 0.08);
  --radius: 12px;
  --max: 1440px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: #edf2f5;
}

body {
  margin: 0;
  color: var(--ink);
  background: #edf2f5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input, select { font: inherit; }

a {
  color: #175b91;
  text-underline-offset: 0.16em;
}

a:hover { color: #0d416a; }

.shell {
  width: min(calc(100% - 32px), var(--max));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -70px;
  z-index: 100;
  padding: 10px 14px;
  color: white;
  background: #000;
}

.skip-link:focus { top: 12px; }

.site-header {
  color: white;
  background:
    linear-gradient(120deg, rgba(255,255,255,0.04), transparent 45%),
    var(--brand);
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  gap: 36px;
  align-items: end;
  padding-block: 38px 34px;
}

.eyebrow {
  margin: 0 0 6px;
  color: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.74;
}

h1 {
  margin: 0;
  max-width: 850px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 13px 0 0;
  max-width: 850px;
  color: #dbe7ef;
  font-size: clamp(1rem, 1.7vw, 1.24rem);
}

.header-meta {
  display: flex;
  min-width: 210px;
  flex-direction: column;
  gap: 7px;
  align-items: flex-end;
  color: #dbe7ef;
  font-size: 0.9rem;
}

.header-meta a { color: white; }

.view-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav-inner {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.view-nav button {
  min-height: 52px;
  padding: 0 17px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
}

.view-nav button:hover,
.view-nav button[aria-current="page"] {
  color: var(--brand);
  border-bottom-color: var(--brand-2);
}

main { padding-block: 24px 54px; }

.notice,
.status-panel {
  padding: 15px 18px;
  border: 1px solid #bdd2e0;
  border-radius: var(--radius);
  background: #f4f9fc;
}

.notice { margin-bottom: 22px; }

.status-panel {
  margin-top: 18px;
  text-align: center;
}

.status-panel.error {
  color: var(--danger);
  border-color: #e2bcbc;
  background: #fff2f2;
  text-align: left;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: end;
  margin: 28px 0 18px;
}

.page-head h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.7rem);
  letter-spacing: -0.035em;
}

.page-head p {
  max-width: 820px;
  margin: 8px 0 0;
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi strong {
  display: block;
  margin-bottom: 4px;
  font-size: clamp(1.75rem, 3vw, 2.65rem);
  line-height: 1;
  letter-spacing: -0.035em;
}

.kpi span {
  color: var(--muted);
  font-size: 0.9rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: baseline;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  margin: 0;
  font-size: 1.08rem;
}

.panel-head p,
.panel-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.panel-body { padding: 18px 20px 20px; }

.bar-list {
  display: grid;
  gap: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(150px, 1.4fr) auto;
  gap: 12px;
  align-items: center;
}

.bar-label {
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf1;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-2), #79a9c9);
}

.bar-value {
  min-width: 106px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.party-list,
.quality-list {
  display: grid;
  gap: 10px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 9px;
  border-bottom: 1px dashed var(--line);
}

.stat-line:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.filters {
  display: grid;
  grid-template-columns: minmax(230px, 2fr) repeat(4, minmax(140px, 1fr)) auto;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #bdcad3;
  border-radius: 8px;
  color: var(--ink);
  background: white;
}

.field input:focus,
.field select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(47, 95, 135, 0.24);
  outline-offset: 2px;
}

.reset-button,
.secondary-button {
  align-self: end;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid #b7c5cf;
  border-radius: 8px;
  color: var(--brand);
  background: white;
  font-weight: 750;
  cursor: pointer;
}

.reset-button:hover,
.secondary-button:hover {
  background: var(--panel-soft);
}

.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin: 9px 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

.table-wrap {
  overflow: auto;
  max-height: min(68vh, 850px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #eef6fb;
  background: var(--brand);
  font-size: 0.76rem;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

tbody tr:hover { background: #f5f9fb; }

td.number {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.link-button {
  padding: 0;
  border: 0;
  color: #175b91;
  background: transparent;
  font: inherit;
  font-weight: 720;
  text-align: left;
  cursor: pointer;
}

.link-button:hover { text-decoration: underline; }

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #394957;
  background: var(--neutral-bg);
  font-size: 0.76rem;
  font-weight: 750;
  white-space: nowrap;
}

.chip.good {
  color: var(--good);
  background: var(--good-bg);
}

.chip.warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.source-links a { font-size: 0.82rem; }

.empty-state {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.method-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.method-card h3 { margin-top: 0; }

.method-card p,
.method-card li { color: var(--muted); }

.method-card code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--panel-soft);
}

.download-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.download-card {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
  text-decoration: none;
}

.download-card strong,
.download-card span { display: block; }
.download-card span { margin-top: 5px; color: var(--muted); font-size: 0.82rem; }

.site-footer {
  padding-block: 28px 42px;
  color: #dce6ed;
  background: #11283a;
}

.footer-grid {
  display: flex;
  justify-content: space-between;
  gap: 40px;
}

.footer-grid p { margin: 4px 0 0; color: #aebfca; }

.download-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 16px;
  margin-top: 7px;
}

.site-footer a { color: white; }

dialog {
  width: min(880px, calc(100% - 24px));
  max-height: calc(100vh - 36px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: white;
  box-shadow: 0 25px 80px rgba(0,0,0,0.28);
}

dialog::backdrop {
  background: rgba(8, 25, 39, 0.58);
  backdrop-filter: blur(3px);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.96);
}

.dialog-head h2 { margin: 0; }

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: white;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

#dialog-content { padding: 20px 22px 26px; }

.detail-section + .detail-section { margin-top: 24px; }

.detail-section h3 {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-field {
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.detail-field span,
.detail-field strong { display: block; }

.detail-field span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
  text-transform: uppercase;
}

.role-card,
.funding-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.role-card + .role-card,
.funding-card + .funding-card { margin-top: 9px; }

.role-card h4,
.funding-card h4 { margin: 0 0 5px; }

.role-card p,
.funding-card p { margin: 4px 0; color: var(--muted); }

.noscript {
  margin: 20px;
  padding: 15px;
  color: var(--danger);
  border: 1px solid #e2bcbc;
  background: #fff2f2;
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters .field:first-child { grid-column: span 2; }
}

@media (max-width: 800px) {
  .header-inner,
  .footer-grid,
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-meta { align-items: flex-start; }

  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid,
  .method-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .field:first-child { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: 1fr; gap: 5px; }
  .bar-value { text-align: left; }
  .download-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .shell { width: min(calc(100% - 20px), var(--max)); }
  .header-inner { padding-block: 28px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .filters .field:first-child { grid-column: auto; }
  th, td { padding: 9px 10px; }
}
