.market-cap-page {
  overflow-x: hidden;
  background: #f4f4ef;
  color: var(--ink);
}

.market-cap-page .site-header { z-index: 80; }
.market-cap-page .reveal { opacity: 1; transform: none; }
[hidden] { display: none !important; }

.cap-masthead {
  padding-top: 54px;
  padding-bottom: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(520px, .95fr);
  gap: 44px;
  align-items: end;
  border-bottom: 1px solid rgba(17, 21, 17, .12);
}

.cap-title h1 {
  margin: 16px 0 14px;
  font-size: clamp(44px, 6vw, 78px);
  line-height: 1.02;
  letter-spacing: 0;
}

.cap-title p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.cap-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid rgba(17, 21, 17, .16);
  border-left: 1px solid rgba(17, 21, 17, .16);
}

.cap-overview div {
  min-height: 98px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid rgba(17, 21, 17, .16);
  border-bottom: 1px solid rgba(17, 21, 17, .16);
  background: rgba(255, 255, 255, .45);
}

.cap-overview span { color: var(--muted); font-size: 11px; font-weight: 800; }
.cap-overview b { font-size: 21px; line-height: 1.25; }
.cap-workspace { padding-top: 30px; padding-bottom: 92px; }

.cap-view-tabs {
  width: min(560px, 100%);
  margin-bottom: 24px;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid rgba(17, 21, 17, .15);
  border-radius: 7px;
  background: rgba(255, 255, 255, .5);
}

.cap-view-tabs button {
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
}

.cap-view-tabs button.active { color: #fff; background: #142219; }
.cap-view-tabs button:focus-visible { outline: 2px solid #087a55; outline-offset: 2px; }

.cap-toolbar {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(210px, 280px) 110px;
  gap: 12px;
  align-items: end;
}

.cap-search, .cap-select { display: grid; gap: 8px; }
.cap-search span, .cap-select span { color: var(--muted); font-size: 11px; font-weight: 850; }

.cap-search input, .cap-select select, .cap-refresh {
  width: 100%;
  height: 48px;
  padding: 0 15px;
  border: 1px solid rgba(17, 21, 17, .16);
  border-radius: 6px;
  background: rgba(255, 255, 255, .72);
  color: var(--ink);
  font: inherit;
}

.cap-search input:focus, .cap-select select:focus {
  outline: 2px solid rgba(7, 92, 67, .22);
  border-color: #075c43;
}

.cap-refresh {
  padding: 0 12px;
  cursor: pointer;
  color: #fff;
  border-color: #142219;
  background: #142219;
  font-size: 13px;
  font-weight: 850;
}

.cap-refresh:disabled { opacity: .55; cursor: wait; }

.cap-filter-row {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.cap-filter-row.categories-only { justify-content: flex-end; }
.cap-region-tabs, .cap-sort-tabs { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.cap-region-tabs::-webkit-scrollbar, .cap-sort-tabs::-webkit-scrollbar { display: none; }

.cap-region-tabs button, .cap-sort-tabs button {
  min-height: 38px;
  padding: 0 13px;
  flex: 0 0 auto;
  border: 1px solid rgba(17, 21, 17, .13);
  border-radius: 5px;
  background: rgba(255, 255, 255, .55);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.cap-region-tabs button.active, .cap-sort-tabs button.active { color: #fff; border-color: #142219; background: #142219; }

.cap-leaders {
  margin: 28px 0 34px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid rgba(17, 21, 17, .16);
  border-bottom: 1px solid rgba(17, 21, 17, .16);
}

.cap-leaders article {
  min-height: 130px;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  column-gap: 14px;
  border-right: 1px solid rgba(17, 21, 17, .13);
  background: rgba(255, 255, 255, .42);
}

.cap-leaders article:first-child { background: #dceab0; }
.cap-leaders article:last-child { border-right: 0; }
.cap-leaders article > span:first-child { grid-column: 1 / -1; color: var(--muted); font-size: 10px; font-weight: 850; }

.cap-leader-logo, .cap-leader-index {
  width: 42px;
  height: 42px;
  align-self: center;
  display: grid;
  place-items: center;
  border: 1px solid rgba(17, 21, 17, .1);
  border-radius: 6px;
  background: rgba(255, 255, 255, .72);
  color: #075c43;
  font-size: 11px;
  font-weight: 900;
}

.cap-leader-logo img { width: 36px; height: 36px; object-fit: contain; }
.cap-leaders article > div { align-self: center; min-width: 0; }
.cap-leaders b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.cap-leaders small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.cap-leaders strong { grid-column: 1 / -1; margin-top: 9px; font-size: 19px; }

.cap-table-headline { margin-bottom: 16px; display: flex; justify-content: space-between; gap: 20px; align-items: end; }
.cap-table-headline span { color: #087a55; font-size: 10px; font-weight: 900; }
.cap-table-headline h2 { margin: 5px 0 0; font-size: 28px; letter-spacing: 0; }
.cap-table-headline p { margin: 0; color: var(--muted); font-size: 12px; }

.cap-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(17, 21, 17, .14);
  border-radius: 7px;
  background: rgba(255, 255, 255, .66);
}

.cap-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cap-table th, .cap-table td { padding: 14px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid rgba(17, 21, 17, .08); }
.cap-table th { color: var(--muted); background: #ecece5; font-size: 10px; font-weight: 900; }
.cap-table td { font-size: 13px; }
.cap-table tbody tr:last-child td { border-bottom: 0; }
.cap-table tbody tr:hover { background: rgba(220, 234, 176, .24); }
.cap-table th:nth-child(1) { width: 60px; }
.cap-table th:nth-child(2) { width: 270px; }
.cap-table th:nth-child(3) { width: 150px; }
.cap-table th:nth-child(4) { width: 110px; }
.cap-table th:nth-child(5) { width: 105px; }
.cap-table th:nth-child(6) { width: 150px; }
.cap-table th:nth-child(7) { width: 105px; }
.cap-table th:nth-child(8) { width: 105px; }

.cap-rank {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(17, 21, 17, .07);
  font-size: 11px;
  font-weight: 900;
}

.cap-company { display: flex; gap: 11px; align-items: center; min-width: 0; }
.cap-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(17, 21, 17, .1);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.cap-logo img { width: 28px; height: 28px; object-fit: contain; }
.cap-company > span:last-child { min-width: 0; }
.cap-company b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.cap-company small { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.cap-market-value { font-size: 13px; }
.cap-category-name b { display: block; font-size: 14px; }
.cap-category-name small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.cap-change { font-weight: 850; }
.cap-change.up { color: #087a55; }
.cap-change.down { color: #bd3328; }
.cap-change.flat, .cap-muted { color: var(--muted); }
.cap-sparkline { width: 128px; height: 38px; display: block; overflow: visible; }

.cap-category-tag {
  display: inline-flex;
  min-height: 25px;
  padding: 0 8px;
  align-items: center;
  border-radius: 4px;
  background: rgba(7, 92, 67, .08);
  color: #075c43;
  font-size: 10px;
  font-weight: 850;
}

.cap-load-row { padding-top: 18px; display: flex; justify-content: center; }
.cap-load-row button {
  min-width: 180px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(17, 21, 17, .18);
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
}

.cap-load-row button:hover { background: #142219; color: #fff; }
.cap-empty { grid-column: 1 / -1; color: var(--muted); }
.cap-empty-row td { padding: 42px 16px; text-align: center; color: var(--muted); }

@media (max-width: 1050px) {
  .cap-masthead { grid-template-columns: 1fr; gap: 28px; }
  .cap-overview { max-width: 760px; }
  .cap-leaders article { padding: 16px; }
}

@media (max-width: 720px) {
  .cap-masthead { padding-top: 24px; padding-bottom: 24px; }
  .cap-title h1 { margin-top: 12px; font-size: 42px; }
  .cap-title p { font-size: 14px; line-height: 1.7; }
  .cap-overview { grid-template-columns: repeat(2, 1fr); }
  .cap-overview div { min-height: 84px; padding: 14px; }
  .cap-overview b { font-size: 17px; }
  .cap-workspace { padding-top: 22px; padding-bottom: 64px; }
  .cap-view-tabs { width: 100%; margin-bottom: 20px; }
  .cap-view-tabs button { padding: 0 8px; font-size: 12px; }
  .cap-toolbar { grid-template-columns: 1fr 1fr; }
  .cap-search { grid-column: 1 / -1; }
  .cap-refresh { align-self: end; }
  .cap-filter-row { align-items: stretch; flex-direction: column; }
  .cap-sort-tabs { width: 100%; }
  .cap-sort-tabs button { flex: 1 0 auto; }
  .cap-leaders { grid-template-columns: 1fr; }
  .cap-leaders article { min-height: 112px; border-right: 0; border-bottom: 1px solid rgba(17, 21, 17, .12); }
  .cap-leaders article:last-child { border-bottom: 0; }
  .cap-table-headline { align-items: start; flex-direction: column; gap: 8px; }
  .cap-table-wrap { overflow: visible; border: 0; background: transparent; }
  .cap-table, .cap-table tbody { display: block; }
  .cap-table thead { display: none; }
  .cap-table tbody { display: grid; gap: 10px; }
  .cap-table tr {
    padding: 13px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 10px;
    border: 1px solid rgba(17, 21, 17, .13);
    border-radius: 7px;
    background: rgba(255, 255, 255, .65);
  }
  .cap-table td { padding: 0; display: block; border: 0; }
  .cap-table td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .cap-table td:nth-child(2) { grid-column: 2 / -1; grid-row: 1; }
  .cap-table td:nth-child(3) { grid-column: 1 / 3; grid-row: 2; }
  .cap-table td:nth-child(4) { grid-column: 3; grid-row: 2; text-align: right; }
  .cap-table td:nth-child(5) { grid-column: 3; grid-row: 3; text-align: right; }
  .cap-table td:nth-child(6) { grid-column: 1 / 3; grid-row: 3; }
  .cap-table td:nth-child(7) { grid-column: 1 / 3; grid-row: 4; }
  .cap-table td:nth-child(8) { grid-column: 3; grid-row: 4; text-align: right; }
  .cap-table .cap-category-row td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .cap-table .cap-category-row td:nth-child(2) { grid-column: 2 / -1; grid-row: 1; }
  .cap-table .cap-category-row td:nth-child(3) { grid-column: 1 / 3; grid-row: 2; }
  .cap-table .cap-category-row td:nth-child(4) { grid-column: 3; grid-row: 2; text-align: right; }
  .cap-table td:nth-child(n+3)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
  }
  .cap-sparkline { width: 120px; height: 34px; }
  .cap-empty-row { display: block !important; }
  .cap-empty-row td { padding: 28px 12px; }
}

@media (max-width: 420px) {
  .cap-toolbar { grid-template-columns: minmax(0, 1fr) 100px; }
  .cap-select select { padding-left: 10px; }
  .cap-region-tabs { margin-right: -16px; padding-right: 16px; }
  .cap-table tr { grid-template-columns: 38px minmax(0, 1fr) auto; }
  .cap-company small { max-width: 220px; }
}
