*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #4ade80;
  --bg: #09090b;
  --border: #27272a;
  --c-dtc: #3b82f6;
  --c-fee: #ef4444;
  --c-ftd: #a855f7;
  --c-si: #f59e0b;
  --c-sv: #14b8a6;
  --max-w: 1060px;
  --radius: 2px;
  --surface: #18181b;
  --text: #fafafa;
  --text-dim: #d4d4d8;
}

html {
  -webkit-text-size-adjust: 100%;
  font-size: 14px;
}

body {
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100dvh;
}

header {
  margin: 0 auto;
  max-width: var(--max-w);
  padding: 2.5rem 2rem 0;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.byline {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-dim);
}

.byline .shimmer {
  font-size: 0.8rem;
}

.byline .shimmer:hover {
  animation-duration: 1s;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.sources {
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.7rem;
  gap: 0.15rem 1rem;
  letter-spacing: 0.01em;
  margin-top: 0.5rem;
}

.sources span {
  white-space: nowrap;
}

.sources em {
  font-style: normal;
}

.sources a {
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.sources a:hover {
  color: var(--text);
  border-bottom-color: var(--text-dim);
}

main {
  margin: 0 auto;
  max-width: var(--max-w);
  padding: 2rem 2rem 4rem;
}

.treemap-section {
  margin-bottom: 2rem;
}

.treemap-header {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.treemap-title {
  color: var(--text);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.treemap-legend {
  align-items: center;
  display: flex;
  gap: 0.1rem;
}

.treemap-legend-item {
  align-items: center;
  display: flex;
  font-size: 0.6rem;
  gap: 0.25rem;
  color: var(--text-dim);
}

.treemap-legend-swatch {
  border-radius: 1px;
  display: inline-block;
  height: 10px;
  width: 16px;
}

.treemap-legend-label {
  margin-right: 0.5rem;
  white-space: nowrap;
}

.treemap-date-nav {
  color: var(--text-dim);
  font-size: 0.65rem;
  letter-spacing: 0.02em;
}

.tm-date-active {
  color: var(--text);
  font-weight: 700;
}

.tm-date {
  color: var(--text-dim);
}

.treemap-stats {
  color: var(--text-dim);
  display: flex;
  font-size: 0.7rem;
  gap: 2rem;
  margin-top: 0.5rem;
}

.treemap-stat-val {
  color: var(--text);
  font-weight: 700;
}

.treemap-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.treemap-container svg {
  cursor: pointer;
  display: block;
  height: auto;
  width: 100%;
}

.watchlists {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr 2fr;
  margin-bottom: 2.5rem;
}

.watchlist {
  min-width: 0;
}

.watchlist-title {
  color: var(--text);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
}

.watchlist-badge {
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0;
  margin-left: 0.4rem;
  text-transform: none;
}

.watchlist-desc {
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
  line-height: 1.4;
  padding-bottom: 0.75rem;
}

.wl-row {
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  display: flex;
  font-size: 0.8rem;
  gap: 0.75rem;
  line-height: 1.3;
  padding: 0.6rem 0;
}

.wl-rank {
  color: var(--text-dim);
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 500;
  text-align: right;
  width: 1.2rem;
}

.wl-ticker {
  color: var(--accent);
  flex-shrink: 0;
  font-weight: 700;
  width: 4rem;
}

.wl-reason {
  color: var(--text-dim);
  flex: 1;
  font-size: 0.75rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wl-reason .val-fee {
  color: var(--c-fee);
  font-weight: 600;
}

.wl-reason .val-dtc {
  color: var(--c-dtc);
  font-weight: 600;
}

.wl-reason .val-si {
  color: var(--c-si);
  font-weight: 600;
}

.wl-reason .val-ftd {
  color: var(--c-ftd);
  font-weight: 600;
}

.wl-reason .val-sv {
  color: var(--c-sv);
  font-weight: 600;
}

.wl-cap {
  color: var(--text-dim);
  flex-shrink: 0;
  font-size: 0.7rem;
  text-align: right;
}

.wl-ticker,
td.ticker {
  cursor: pointer;
}

.section-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin-bottom: 2rem;
}

.filter-panel {
  margin-bottom: 2.5rem;
}

.filter-row {
  align-items: center;
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
}

.filter-row + .filter-row {
  margin-top: 0.5rem;
}

.filter-row:first-child {
  background: var(--surface);
  border: 1px solid var(--border);
}

.filter-row:nth-child(2) {
  background: #111114;
  border: 1px solid var(--border);
}

.filter-fee {
  border-left: 3px solid var(--c-fee);
  padding-left: 0.5rem;
}

.filter-fee::before {
  color: var(--c-fee);
}

.filter-fee button.active {
  background: var(--c-fee);
  border-color: var(--c-fee);
}

.filter-si {
  border-left: 3px solid var(--c-si);
  padding-left: 0.5rem;
}

.filter-si::before {
  color: var(--c-si);
}

.filter-si button.active {
  background: var(--c-si);
  border-color: var(--c-si);
}

.filter-dtc {
  border-left: 3px solid var(--c-dtc);
  padding-left: 0.5rem;
}

.filter-dtc::before {
  color: var(--c-dtc);
}

.filter-dtc button.active {
  background: var(--c-dtc);
  border-color: var(--c-dtc);
}

.filter-ftd {
  border-left: 3px solid var(--c-ftd);
  padding-left: 0.5rem;
}

.filter-ftd::before {
  color: var(--c-ftd);
}

.filter-ftd button.active {
  background: var(--c-ftd);
  border-color: var(--c-ftd);
}

.reset-btn {
  background: var(--c-fee);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.4rem 0.75rem;
}

.reset-btn:hover {
  opacity: 0.85;
}

.scenario-row {
  background: #0d0d10;
  border: 1px solid var(--border);
}

.scenario-label {
  color: var(--text);
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-right: 0.25rem;
  text-transform: uppercase;
}

.scenario-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 3px solid;
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.45rem 0.9rem;
  transition: background 0.1s, border-color 0.1s, filter 0.1s;
}

.scenario-btn:hover {
  filter: brightness(1.3);
}

.scenario-btn:active {
  border-bottom-width: 1px;
  margin-top: 2px;
}

.scenario-btn:nth-child(2) {
  border-bottom-color: var(--c-fee);
}

.scenario-btn:nth-child(3) {
  border-bottom-color: var(--c-dtc);
}

.scenario-btn:nth-child(4) {
  border-bottom-color: var(--c-si);
}

.scenario-btn:nth-child(5) {
  border-bottom-color: var(--c-ftd);
}

.filter-panel input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
  padding: 0.45rem 0.75rem;
  width: 170px;
}

.filter-panel input:focus {
  border-color: var(--text);
}

.filter-panel input::placeholder {
  color: var(--text-dim);
}

.btn-group {
  align-items: center;
  display: flex;
}

.btn-group::before {
  color: var(--text-dim);
  content: attr(data-label);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-right: 0.4rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.btn-group button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 0.4rem 0.7rem;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.btn-group button:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.btn-group button:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.btn-group button:not(:first-child) {
  border-left: none;
}

.btn-group button:hover {
  color: var(--text);
}

.btn-group button.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.btn-group button.active + button {
  border-left-color: var(--text);
}

#table-wrap {
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  table-layout: fixed;
  width: 100%;
}

col.col-ticker { width: 60px; }
col.col-name { width: auto; }
col.col-data { width: 62px; }

.col-group-row th {
  cursor: default;
  top: 0;
}

.col-group-header {
  background: var(--bg);
  border-bottom: none;
  color: var(--text-dim);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.4rem 0.5rem 0;
  text-align: center;
  text-transform: uppercase;
}

.col-group-header:empty {
  border-bottom: none;
}

th {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.5rem;
  position: sticky;
  text-align: left;
  text-transform: uppercase;
  top: 0;
  user-select: none;
  white-space: nowrap;
}

td.score-col,
th.score-col {
  border-left: 2px solid var(--border);
}

th.sort-asc::after {
  content: " \25B2";
  font-size: 0.55rem;
}

th.sort-desc::after {
  content: " \25BC";
  font-size: 0.55rem;
}

td {
  border-bottom: 1px solid #1e1e21;
  padding: 0.4rem 0.5rem;
  white-space: nowrap;
}

td.name-col {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.ticker {
  color: var(--accent);
  font-weight: 700;
}

td.heat {
  color: #fff;
  font-weight: 600;
  text-align: right;
}

.num {
  text-align: right;
}

.ticker-tip {
  background: #27272a;
  border: 1px solid #3f3f46;
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  color: var(--text);
  display: none;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.6;
  padding: 0.5rem 0.65rem;
  pointer-events: none;
  position: fixed;
  white-space: nowrap;
  z-index: 1000;
}

.ticker-tip.visible {
  display: block;
}

.pager {
  align-items: center;
  color: var(--text-dim);
  display: flex;
  font-size: 0.7rem;
  gap: 0.5rem;
  padding: 1rem 0 0;
}

.pager button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0.3rem 0.65rem;
}

.pager button:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

footer {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin: 0 auto;
  max-width: var(--max-w);
  padding: 3rem 2rem 4rem;
  text-align: center;
}

footer p + p {
  font-size: 0.7rem;
  margin-top: 0.5rem;
}

footer a {
  text-decoration: none;
}

.shimmer {
  animation: shimmer 2.5s linear infinite;
  background: linear-gradient(
    90deg,
    #4ade80 0%,
    #86efac 25%,
    #fff 50%,
    #86efac 75%,
    #4ade80 100%
  );
  background-clip: text;
  background-size: 200% 100%;
  border-bottom: 0.12em solid rgba(74, 222, 128, 0.5);
  box-shadow: 0 0.25em 0 rgba(74, 222, 128, 0.3);
  padding-bottom: 0.08em;
  text-decoration: none;
  display: inline-block;
  font-weight: 700;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

footer .shimmer {
  font-size: 1.3rem;
}

footer .shimmer:hover {
  animation-duration: 1s;
}

@media (max-width: 700px) {
  header {
    padding: 1.5rem 1rem 0;
  }

  h1 { font-size: 1.2rem; }

  .byline { display: block; margin-top: 0.25rem; }

  main {
    padding: 1.5rem 0.75rem 3rem;
  }

  .watchlists {
    gap: 1.5rem;
    grid-template-columns: 1fr;
  }

  .filter-row {
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
  }

  table { table-layout: auto; }

  col.col-data { width: auto; }
  col.col-flag { width: auto; }

  th, td { padding: 0.25rem 0.3rem; font-size: 0.7rem; }

  /* Hide: Name(2), MktCap(3), Avail(6), FTD(7), SHO(8), SIChg(11), SV%(13), 13D(14) */
  th:nth-child(2), td:nth-child(2),
  th:nth-child(3), td:nth-child(3),
  th:nth-child(6), td:nth-child(6),
  th:nth-child(7), td:nth-child(7),
  th:nth-child(8), td:nth-child(8),
  th:nth-child(11), td:nth-child(11),
  th:nth-child(13), td:nth-child(13),
  th:nth-child(14), td:nth-child(14),
  col:nth-child(2), col:nth-child(3),
  col:nth-child(6), col:nth-child(7), col:nth-child(8),
  col:nth-child(11), col:nth-child(13), col:nth-child(14) {
    display: none;
  }

  .col-group-row { display: none; }

  .treemap-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .treemap-legend {
    flex-wrap: wrap;
  }

  .treemap-stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .scenario-label { display: none; }
  .scenario-btn { font-size: 0.65rem; padding: 0.35rem 0.6rem; }

  footer { padding: 2rem 1rem 3rem; }
  footer .shimmer { font-size: 1.1rem; }
}
