:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --border: #e7e7eb;
  --text: #111418;
  --muted: #6a7180;
  --accent: #4f46e5;
  --chip: #f3f4f6;
  --positive: #15803d;
  --negative: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 48px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 0;
  background: rgba(250, 250, 250, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(231, 231, 235, 0.9);
}

.brand-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.03em;
}

.muted,
.card-footer a:last-child,
.cell-title span,
.meta-panel span {
  color: var(--muted);
}

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 0.95rem;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
}

.lang-switch a {
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.86rem;
}

.lang-switch a.active {
  background: var(--chip);
  color: var(--text);
}

main {
  padding-top: 18px;
}

.shell-intro,
.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.9fr);
  gap: 22px;
  align-items: start;
  padding: 20px 0 8px;
}

.shell-intro h1,
.page-head h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.05em;
}

.shell-intro p,
.page-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  max-width: 64ch;
}

.stats-row,
.home-groups {
  display: grid;
  gap: 16px;
}

.stats-row {
  grid-template-columns: repeat(2, minmax(180px, 220px));
  justify-content: end;
  align-content: start;
}

.stat,
.meta-panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.stat {
  padding: 18px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.2rem;
}

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

.section-head h2 {
  margin: 8px 0 0;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  max-width: 56ch;
  line-height: 1.6;
}

.cell-title strong {
  display: block;
}

.back-link {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
}

.meta-panel {
  padding: 18px;
}

.meta-panel div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.meta-panel div:last-child {
  border-bottom: 0;
}

.table-wrap {
  margin-top: 18px;
  overflow-x: auto;
}

.mobile-list-wrap {
  display: none;
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

.home-group,
.stat,
.meta-panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.home-group {
  padding: 18px;
}

.group-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
}

.group-head h2 {
  margin: 4px 0 6px;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.group-head p,
.panel-meta span {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.group-picker {
  min-width: 132px;
}

.group-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #d8dde6;
  border-radius: 999px;
  height: 34px;
  padding: 0 34px 0 14px;
  background:
    linear-gradient(45deg, transparent 50%, #8791a1 50%) calc(100% - 16px) calc(50% - 2px) / 6px 6px no-repeat,
    linear-gradient(135deg, #8791a1 50%, transparent 50%) calc(100% - 12px) calc(50% - 2px) / 6px 6px no-repeat,
    #f8fafc;
  color: #4f5a69;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1;
  box-shadow: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.group-select:hover {
  background:
    linear-gradient(45deg, transparent 50%, #6b7280 50%) calc(100% - 16px) calc(50% - 2px) / 6px 6px no-repeat,
    linear-gradient(135deg, #6b7280 50%, transparent 50%) calc(100% - 12px) calc(50% - 2px) / 6px 6px no-repeat,
    #f1f5f9;
  border-color: #cdd5df;
  color: #334155;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.group-select:focus {
  outline: none;
  border-color: #bfc8d4;
  color: #1f2937;
  box-shadow: 0 0 0 3px rgba(203, 213, 225, 0.45);
}

.group-select option {
  color: var(--text);
}

.panel-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}

.panel-meta strong {
  display: block;
  margin-bottom: 4px;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

thead th {
  padding: 16px 18px;
  text-align: left;
  color: var(--muted);
  font-size: 0.86rem;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 16px 18px;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
}

.rank-cell {
  font-weight: 700;
}

.cell-title strong a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.change-up {
  color: var(--positive);
}

.change-down {
  color: var(--negative);
}

.table-action a {
  color: var(--accent);
}

.mobile-list {
  display: flex;
  flex-direction: column;
}

.mobile-item {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.mobile-item:last-child {
  border-bottom: 0;
}

.mobile-item-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
}

.mobile-item-main {
  display: flex;
  align-items: start;
  gap: 12px;
  min-width: 0;
}

.mobile-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.mobile-item-heading {
  min-width: 0;
}

.mobile-item-heading strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.35;
}

.mobile-item-heading strong a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mobile-item-heading span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.mobile-item-value {
  flex: 0 0 auto;
  text-align: right;
}

.mobile-item-value span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.mobile-item-value strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.mobile-item-meta {
  margin-top: 10px;
  margin-left: 50px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.mobile-item-meta strong {
  color: var(--text);
  font-weight: 600;
}

.mobile-item-summary {
  margin: 8px 0 0;
  margin-left: 50px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mobile-list-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: #fcfcfd;
}

.mobile-list-footer a {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
}

.all-rankings {
  margin-top: 34px;
}

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

.ranking-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.ranking-card strong {
  font-size: 0.98rem;
  letter-spacing: -0.02em;
}

.ranking-card span {
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.92rem;
}

@media (max-width: 900px) {
  .site-header,
  .shell-intro,
  .page-head,
  .section-head,
  .group-head,
  .panel-meta {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: start;
  }

  .site-header {
    position: static;
  }

  .stats-row {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .group-picker {
    width: 100%;
  }

  .ranking-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  table {
    min-width: 720px;
  }
}

@media (max-width: 768px) {
  .site-shell {
    width: min(100% - 20px, 720px);
    padding-bottom: 32px;
  }

  .site-header {
    position: static;
    padding: 14px 0;
    gap: 12px;
  }

  nav {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.9rem;
  }

  .shell-intro,
  .page-head {
    gap: 14px;
    padding: 14px 0 6px;
  }

  .shell-intro h1,
  .page-head h1 {
    margin-bottom: 8px;
    font-size: clamp(1.7rem, 8vw, 2.2rem);
  }

  .shell-intro p,
  .page-head p,
  .group-head p,
  .panel-meta span,
  .section-head p {
    line-height: 1.55;
    font-size: 0.95rem;
  }

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

  .stat {
    padding: 14px;
  }

  .stat strong {
    font-size: 1rem;
  }

  .home-groups {
    gap: 12px;
  }

  .home-group {
    padding: 14px;
  }

  .group-head {
    gap: 12px;
  }

  .group-head h2 {
    margin: 4px 0 6px;
    font-size: 1.2rem;
  }

  .group-picker {
    width: 100%;
  }

  .group-select {
    height: 40px;
    font-size: 0.92rem;
  }

  .panel-meta {
    margin-top: 10px;
  }

  .panel-meta .muted {
    font-size: 0.85rem;
  }

  .table-wrap {
    display: none;
  }

  .mobile-list-wrap {
    display: block;
  }

  .section-head {
    margin-top: 24px;
  }
}
