:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #64707d;
  --subtle: #8b96a3;
  --line: #dce2e8;
  --line-strong: #c4ceda;
  --accent: #cf3028;
  --accent-soft: #fff0ee;
  --blue: #245f94;
  --blue-soft: #eaf2fa;
  --green: #16735c;
  --green-soft: #e9f6f2;
  --gold: #a06a15;
  --shadow: 0 16px 34px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1660px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 8px 0 12px;
}

.league-header {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(420px, 42vw);
  align-items: end;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.05;
  font-weight: 950;
}

.dek {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 1px;
  overflow: hidden;
  min-width: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.kpi-strip div {
  min-height: 43px;
  display: grid;
  align-content: center;
  gap: 1px;
  background: var(--panel);
  padding: 5px 9px;
}

.kpi-strip strong {
  overflow: hidden;
  font-size: 18px;
  line-height: 1;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-strip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.controlbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 0 5px;
}

.filters,
.source-links {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
}

.filters select,
.filters input,
.filters button,
.source-links a {
  height: 29px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 9px;
  font-size: 11.5px;
}

.filters select {
  min-width: 104px;
  color: var(--muted);
  font-weight: 780;
}

.filters input {
  width: 220px;
  min-width: 160px;
  font-weight: 750;
}

.filters button {
  cursor: pointer;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-weight: 850;
}

.filters button.loading {
  background: var(--gold);
  border-color: var(--gold);
}

.source-links {
  justify-content: end;
}

.source-links a {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
  font-weight: 850;
}

.status-line {
  min-height: 18px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board {
  display: grid;
  grid-template-columns: minmax(830px, 1fr) 374px;
  gap: 10px;
  align-items: start;
}

.leaderboard-panel,
.detail-rail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.leaderboard-panel {
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.03);
}

.table-wrap {
  overflow-x: auto;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 42px minmax(220px, 1.6fr) 120px 74px 86px 112px minmax(120px, 0.8fr);
  align-items: center;
  column-gap: 8px;
  min-width: 850px;
}

.table-head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 27px;
  border-bottom: 1px solid var(--line);
  background: #f1f4f7;
  color: var(--muted);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.table-body {
  display: grid;
}

.table-entry {
  display: grid;
}

.table-row {
  width: 100%;
  height: 28px;
  border: 0;
  border-bottom: 1px solid #edf0f4;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  cursor: pointer;
  text-align: left;
}

.table-entry:nth-child(even) .table-row {
  background: #fbfcfd;
}

.table-row:hover,
.table-row.active {
  background: var(--accent-soft);
}

.table-row.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.inline-detail {
  display: none;
}

.rank {
  width: 28px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f8fa;
  font-size: 12px;
  font-weight: 950;
}

.rank.medal-1 {
  border-color: #dbb04b;
  background: #fff3ce;
  color: #6e4607;
}

.rank.medal-2 {
  border-color: #abb7c4;
  background: #eef2f5;
}

.rank.medal-3 {
  border-color: #cf9870;
  background: #f7e2d2;
  color: #7b3f1e;
}

.ministry-cell {
  display: grid;
  min-width: 0;
}

.ministry-cell strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ministry-cell strong {
  font-size: 12.5px;
  line-height: 1.1;
  font-weight: 900;
}

.num,
.money,
.delta {
  justify-self: end;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 780;
}

.money.strong {
  color: var(--ink);
  font-weight: 950;
}

.money.muted {
  color: var(--muted);
}

.delta.up {
  color: var(--accent);
  font-weight: 950;
}

.delta.down {
  color: var(--blue);
  font-weight: 950;
}

.share-cell i {
  display: block;
  overflow: hidden;
  height: 5px;
  border-radius: 999px;
  background: #e5eaf0;
}

.share-cell b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.detail-rail {
  position: sticky;
  top: 10px;
  max-height: calc(100vh - 20px);
  overflow: auto;
  padding: 13px;
  box-shadow: var(--shadow);
}

.detail-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.seed {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.detail-top h2 {
  margin: 4px 0 3px;
  font-size: 20px;
  line-height: 1.08;
}

.detail-top p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-top a {
  height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
}

.score-card {
  min-height: 72px;
  display: grid;
  gap: 3px;
  margin: 12px 0 10px;
  border: 1px solid rgba(207, 48, 40, 0.28);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 10px 12px;
}

.score-card span,
.score-card small {
  color: #9a201a;
  font-size: 12px;
  font-weight: 900;
}

.score-card strong {
  font-size: 32px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
  gap: 1px;
}

.mini-stats div {
  min-height: 50px;
  display: grid;
  align-content: center;
  gap: 3px;
  background: #fbfcfd;
  padding: 7px 8px;
}

.mini-stats span {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
}

.mini-stats strong {
  overflow: hidden;
  font-size: 16px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.detail-section h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.breakdown-list,
.detail-rows {
  display: grid;
  gap: 6px;
}

.breakdown-item {
  display: grid;
  gap: 5px;
}

.breakdown-item div,
.detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.breakdown-item strong,
.detail-row span {
  overflow: hidden;
  font-size: 12px;
  font-weight: 880;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breakdown-item span,
.detail-row small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.breakdown-item i {
  overflow: hidden;
  height: 5px;
  border-radius: 999px;
  background: #e5eaf0;
}

.breakdown-item b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.detail-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 7px 8px;
}

.detail-row strong {
  justify-self: end;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.detail-row small {
  grid-column: 1 / -1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.program-panel {
  display: grid;
  gap: 8px;
}

.program-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.program-meta a {
  height: 25px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 900;
}

.program-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.program-stats div {
  display: grid;
  gap: 3px;
  min-height: 48px;
  align-content: center;
  background: #fbfcfd;
  padding: 7px;
}

.program-stats span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.program-stats strong {
  overflow: hidden;
  font-size: 13px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.program-list {
  display: grid;
  gap: 4px;
}

.program-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto 48px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 6px 7px;
}

.program-rank {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: #f1f4f7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
}

.program-row div {
  min-width: 0;
}

.program-row strong,
.program-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.program-row strong {
  font-size: 12px;
  line-height: 1.1;
  font-weight: 900;
}

.program-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 740;
}

.program-row b,
.program-row em {
  justify-self: end;
  font-size: 11.5px;
  font-style: normal;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.program-row em.up {
  color: var(--accent);
}

.program-row em.down {
  color: var(--blue);
}

.program-note,
.program-empty {
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  padding: 8px;
  font-size: 11px;
  line-height: 1.4;
  font-weight: 730;
}

.caveat,
.loading-box,
.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfd;
}

.caveat {
  margin: 12px 0 0;
  padding: 10px;
  font-size: 11.5px;
  line-height: 1.45;
  font-weight: 730;
}

.site-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px 16px;
  margin-top: 9px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 10px 2px 0;
  font-size: 11.5px;
  line-height: 1.4;
}

.site-footer div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.site-footer strong {
  color: var(--ink);
  font-weight: 950;
}

.site-footer span,
.site-footer p,
.site-footer small {
  margin: 0;
  font-weight: 720;
}

.site-footer nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-footer a {
  color: var(--muted);
  font-weight: 820;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ink);
}

.site-footer small {
  grid-column: 1 / -1;
  color: var(--subtle);
}

.doc-shell {
  width: min(860px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.doc-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 820;
}

.doc-nav a {
  color: var(--muted);
  text-decoration: none;
}

.doc-nav a:hover {
  color: var(--ink);
}

.doc-nav span {
  color: var(--ink);
}

.doc-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.doc-header h1 {
  font-size: 34px;
}

.doc-header p:last-child {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  font-weight: 720;
}

.doc-page {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.doc-section,
.note-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.doc-section h2,
.note-card h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 950;
}

.doc-section p,
.note-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  font-weight: 690;
}

.doc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.doc-links a {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.fact-grid div {
  display: grid;
  gap: 5px;
  min-height: 76px;
  align-content: center;
  background: #fbfcfd;
  padding: 12px;
}

.fact-grid strong {
  font-size: 22px;
  line-height: 1;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.fact-grid span {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 820;
}

.fact-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.fact-list a {
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 820;
  text-decoration: none;
}

.doc-table {
  display: grid;
  gap: 1px;
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.doc-table [role="row"] {
  display: grid;
  grid-template-columns: 44px minmax(150px, 1fr) 82px 70px 74px;
  gap: 8px;
  align-items: center;
  background: #fff;
  padding: 8px 10px;
}

.doc-table [role="row"]:first-child {
  background: #f1f4f7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
}

.doc-table span {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-table span:nth-child(n + 3) {
  justify-self: end;
  font-variant-numeric: tabular-nums;
}

.note-list {
  display: grid;
  gap: 10px;
}

.note-card span {
  display: inline-flex;
  margin-bottom: 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 900;
}

.note-card small,
.doc-credit {
  color: var(--subtle);
  font-size: 11.5px;
  font-weight: 760;
}

.note-card small {
  display: block;
  margin-top: 12px;
}

.doc-credit {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.loading-box,
.empty {
  margin: 12px;
  padding: 18px;
}

@media (max-width: 900px) {
  .shell {
    width: min(100vw - 16px, 1660px);
  }

  .board {
    grid-template-columns: 1fr;
  }

  .league-header,
  .controlbar {
    grid-template-columns: 1fr;
  }

  .kpi-strip {
    min-width: 0;
  }

  .filters,
  .source-links {
    justify-content: stretch;
    width: 100%;
  }

  .source-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters select,
  .filters input,
  .filters button,
  .source-links a {
    flex: 1 1 0;
    min-width: 0;
  }

  .table-head,
  .table-row {
    grid-template-columns: 34px minmax(126px, 1fr) 86px 50px 68px minmax(70px, 0.65fr);
    min-width: 0;
    column-gap: 6px;
  }

  .table-head > :nth-child(6),
  .table-row > :nth-child(6) {
    display: none;
  }

  .table-head,
  .table-row {
    padding: 0 8px;
  }

  .detail-rail {
    display: none;
  }

  .inline-detail {
    display: block;
    min-width: 0;
    border-bottom: 1px solid var(--line);
    background: #fff7f6;
    padding: 10px 10px 12px;
  }

  .inline-detail .detail-top h2 {
    font-size: 17px;
  }

  .inline-detail .score-card {
    min-height: 62px;
    margin: 9px 0 8px;
  }

  .inline-detail .score-card strong {
    font-size: 25px;
  }

  .inline-detail .mini-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .inline-detail .detail-section {
    margin-top: 10px;
    padding-top: 10px;
  }

  .inline-detail .breakdown-list,
  .inline-detail .detail-rows,
  .inline-detail .program-list {
    gap: 5px;
  }
}

@media (max-width: 700px) {
  .shell {
    width: min(100vw - 10px, 1660px);
    padding-top: 6px;
  }

  h1 {
    font-size: 23px;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-line {
    white-space: normal;
  }

  .table-head,
  .table-row {
    grid-template-columns: 30px minmax(88px, 1fr) 72px 44px 58px;
    column-gap: 4px;
  }

  .table-head {
    grid-template-rows: 22px 12px;
    min-height: 38px;
    align-items: center;
  }

  .table-row {
    grid-template-rows: 24px 8px;
    height: auto;
    min-height: 38px;
    row-gap: 1px;
  }

  .table-head > :nth-child(7) {
    grid-column: 2 / -1;
    grid-row: 2;
    justify-self: end;
    color: var(--subtle);
    font-size: 10px;
  }

  .table-row > :nth-child(7) {
    grid-column: 2 / -1;
    grid-row: 2;
    justify-self: stretch;
    width: 100%;
  }

  .table-row > :nth-child(7) i {
    height: 4px;
  }

  .ministry-cell strong,
  .num,
  .money,
  .delta {
    font-size: 11.5px;
  }

  .inline-detail {
    padding: 9px 8px 11px;
  }

  .inline-detail .mini-stats {
    grid-template-columns: 1fr;
  }

  .program-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .program-row {
    grid-template-columns: 22px minmax(0, 1fr) 58px 44px;
    gap: 5px;
  }

  .program-row small {
    display: none;
  }

  .site-footer {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .site-footer div,
  .site-footer nav {
    flex-wrap: wrap;
  }

  .doc-shell {
    width: min(100vw - 20px, 860px);
    padding-top: 14px;
  }

  .doc-header h1 {
    font-size: 28px;
  }

  .doc-section,
  .note-card {
    padding: 13px;
  }

  .fact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .doc-table [role="row"] {
    grid-template-columns: 34px minmax(92px, 1fr) 64px 52px 58px;
    gap: 5px;
    padding: 7px 8px;
  }

  .doc-table span {
    font-size: 11.5px;
  }
}
