:root {
  --bg: #f3efe7;
  --bg-accent: radial-gradient(circle at 18% 15%, rgba(31, 163, 153, 0.24), rgba(243, 239, 231, 0) 48%), radial-gradient(circle at 85% 88%, rgba(219, 107, 65, 0.2), rgba(243, 239, 231, 0) 38%);
  --panel: #fff8f0;
  --sidebar-bg: rgba(255, 248, 240, 0.92);
  --line: #d2c7b4;
  --text: #1f1b16;
  --muted: #6a6154;
  --positive: #0b8457;
  --negative: #b93a32;
  --accent: #db6b41;
  --accent-2: #1fa399;
}

[data-theme="dark"] {
  --bg: #111724;
  --bg-accent: radial-gradient(circle at 16% 10%, rgba(43, 121, 150, 0.35), rgba(17, 23, 36, 0) 48%), radial-gradient(circle at 84% 86%, rgba(194, 110, 68, 0.22), rgba(17, 23, 36, 0) 42%);
  --panel: #192233;
  --sidebar-bg: rgba(20, 28, 42, 0.9);
  --line: #2c3a4f;
  --text: #e9eef8;
  --muted: #9aa8bf;
  --positive: #35c980;
  --negative: #ff7075;
  --accent: #c76e44;
  --accent-2: #3eb8c5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: var(--bg-accent), var(--bg);
}

h1,
h2,
h3 {
  font-family: "Archivo Narrow", sans-serif;
  letter-spacing: 0.02em;
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 1.25rem 1rem;
  background: var(--sidebar-bg);
}

.theme-row {
  margin-bottom: 0.8rem;
}

.sidebar .muted {
  margin: 0.4rem 0 1rem;
}

#nav {
  display: grid;
  gap: 0.5rem;
}

.nav-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  padding: 0.58rem 0.7rem;
  border-radius: 0.55rem;
  cursor: pointer;
}

.nav-button.active {
  background: linear-gradient(90deg, rgba(31, 163, 153, 0.24), rgba(219, 107, 65, 0.24));
  border-color: #9b8c74;
}

.meta {
  margin-top: 1rem;
  display: grid;
  gap: 0.5rem;
}

#lastUpdated {
  line-height: 1.35;
  font-size: 0.86rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.theme-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.button {
  border: 1px solid #7b3d24;
  background: var(--accent);
  color: #fff;
  font: inherit;
  padding: 0.5rem 0.7rem;
  border-radius: 0.55rem;
  cursor: pointer;
}

.content {
  padding: 1rem;
}

.page {
  display: none;
  animation: fadeIn 220ms ease;
}

.page.active {
  display: grid;
  gap: 0.9rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-head p,
.muted {
  color: var(--muted);
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.page-head-main {
  min-width: 0;
}

.private-auth-inline {
  display: grid;
  grid-template-columns: 140px auto;
  gap: 0.45rem;
  align-items: center;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 0.8rem;
  padding: 0.8rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.rotate-note {
  display: none;
  color: var(--muted);
  font-size: 0.86rem;
}

.top10-mobile-list {
  display: none;
}

.top10-mobile-item {
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  margin-bottom: 0.45rem;
  background: rgba(255, 255, 255, 0.14);
}

.top10-mobile-item summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  gap: 0.2rem;
  padding: 0.5rem 0.6rem;
}

.top10-mobile-body {
  border-top: 1px solid var(--line);
  padding: 0.45rem 0.6rem;
  display: grid;
  gap: 0.25rem;
  font-size: 0.86rem;
}

.top10-mobile-total {
  font-size: 0.86rem;
  color: var(--muted);
  padding: 0.2rem 0.1rem 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.44);
}

.kpi .value {
  font-size: 1.25rem;
  font-weight: 700;
}

[data-theme="dark"] .kpi {
  background: linear-gradient(180deg, rgba(37, 51, 74, 0.78), rgba(25, 36, 54, 0.78));
  border-color: #31435d;
  box-shadow: inset 0 1px 0 rgba(140, 176, 214, 0.08);
}

[data-theme="dark"] .kpi .muted {
  color: #9fb1cc;
}

[data-theme="dark"] .kpi .value {
  color: #eef4ff;
}

[data-theme="dark"] .kpi .value.pos {
  color: var(--positive);
}

[data-theme="dark"] .kpi .value.neg {
  color: var(--negative);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.period-tabs {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.period-tab {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.35);
  color: var(--text);
  padding: 0.22rem 0.55rem;
  border-radius: 0.45rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.period-tab.active {
  background: rgba(31, 163, 153, 0.22);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 700;
}

[data-theme="dark"] .period-tab {
  background: rgba(27, 38, 58, 0.68);
}

[data-theme="dark"] .period-tab.active {
  background: rgba(58, 186, 180, 0.22);
}

label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.92rem;
}

select,
input,
textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.4rem;
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 76px;
}

.button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.asset-selectors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.mcap-of-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.mcap-of-card {
  margin-top: 0.35rem;
  padding: 0.35rem 0.45rem 0.2rem;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.mcap-of-title {
  font-size: 1.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #dce6ff;
  margin-bottom: 0.7rem;
}

.mcap-of-price-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}

.mcap-of-price-row img {
  width: 26px;
  height: 26px;
  border-radius: 999px;
}

.mcap-of-price {
  font-size: 2rem;
  font-weight: 700;
}

.mcap-of-multi {
  font-size: 2rem;
  font-weight: 700;
}

.mcap-of-ratio {
  font-size: 1.7rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.mcap-of-bars {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.mcap-of-bar-line {
  width: min(420px, 100%);
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.mcap-of-bar-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2ac983, #4de3b5);
}

.mcap-of-bars .mcap-of-bar-line:nth-child(2) span {
  background: linear-gradient(90deg, #d68181, #d39e9e);
}

.mcap-of-values {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.mcap-of-values div {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1.6rem;
}

.mcap-of-values img {
  width: 20px;
  height: 20px;
  border-radius: 999px;
}

.mover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
}

.mover-box {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.45rem;
  background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .mover-box {
  background: rgba(25, 34, 51, 0.35);
}

.mover-box h4 {
  margin: 0 0 0.3rem;
}

.mover-list {
  margin: 0;
  padding-left: 1rem;
}

.mover-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin: 0.15rem 0;
}

.mover-clean-table td,
.mover-clean-table th {
  white-space: nowrap;
}

.mover-clean-table td:nth-child(1),
.mover-clean-table th:nth-child(1) {
  width: 72px;
}

.mover-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

.mover-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.mover-excl {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.08rem 0.4rem;
  white-space: nowrap;
}

.mover-period-card {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.55rem;
  background: rgba(255, 255, 255, 0.2);
}

.mover-period-card h4 {
  margin: 0 0 0.4rem;
}

.mover-side-title {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.2rem 0;
}

.mover-stack {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mover-stack li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.08rem 0;
  font-size: 0.86rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.45rem;
  font-size: 0.92rem;
  text-align: left;
}

#sectorTable table,
#sectorSubsectorTable table,
#sectorTokensTable table {
  font-variant-numeric: tabular-nums;
}

#sectorTable th:nth-child(n+2),
#sectorTable td:nth-child(n+2),
#sectorSubsectorTable th:nth-child(n+2),
#sectorSubsectorTable td:nth-child(n+2) {
  text-align: right;
  white-space: nowrap;
}

#sectorTable .sector-stats-table,
#sectorSubsectorTable .sector-stats-table {
  table-layout: fixed;
}

#sectorTable .sector-stats-table th:nth-child(1),
#sectorSubsectorTable .sector-stats-table th:nth-child(1) {
  width: 38%;
}

#sectorTable .sector-stats-table th:nth-child(2),
#sectorSubsectorTable .sector-stats-table th:nth-child(2) {
  width: 12%;
}

#sectorTable .sector-stats-table th:nth-child(3),
#sectorSubsectorTable .sector-stats-table th:nth-child(3) {
  width: 16%;
}

#sectorTable .summary-row td {
  border-top: 2px solid var(--line);
  background: rgba(31, 163, 153, 0.08);
}

#dashboardTopTokens .summary-row td {
  border-top: 2px solid var(--line);
  background: rgba(31, 163, 153, 0.08);
}

#sectorTokensTable th:nth-child(1),
#sectorTokensTable td:nth-child(1),
#sectorTokensTable th:nth-child(n+4),
#sectorTokensTable td:nth-child(n+4) {
  text-align: right;
  white-space: nowrap;
}

#sectorTokensTable th:nth-child(2),
#sectorTokensTable td:nth-child(2),
#sectorTokensTable th:nth-child(3),
#sectorTokensTable td:nth-child(3) {
  text-align: left;
}

#tokenTable th:nth-child(4),
#tokenTable td:nth-child(4),
#tokenTable th:nth-child(5),
#tokenTable td:nth-child(5) {
  white-space: nowrap;
}

th {
  background: rgba(31, 163, 153, 0.08);
}

[data-theme="dark"] th {
  background: rgba(62, 184, 197, 0.12);
}

.table-link {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

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

.table-sort {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.token-logo {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: block;
}

.token-logo-fallback {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #c8bba7;
  display: block;
}

.heatmap-legend {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.heatmap-legend span {
  width: 16px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.heatmap-root {
  min-height: 0;
  position: relative;
  display: block;
  background: #0f1118;
  border: 1px solid #222839;
  border-radius: 8px;
  overflow: hidden;
}

.heatmap-sector {
  position: absolute;
  border: 1px solid #181b24;
  border-radius: 0;
  overflow: hidden;
  display: block;
  background: #121212;
}

.heatmap-sector.single-sector {
  position: relative;
  inset: auto;
  width: 100%;
  min-height: 0;
}

.heatmap-sector-head {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  background: #000;
  padding: 2px 6px;
}

.heatmap-tiles {
  position: relative;
  height: calc(100% - 22px);
}

.heatmap-tiles-grid {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  grid-auto-rows: clamp(14px, 1.6vw, 24px);
  grid-auto-flow: dense;
  gap: 1px;
  padding: 1px;
}

.heatmap-tile {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.38);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
  padding: 2px;
  overflow: hidden;
}

.heatmap-tiles-grid .heatmap-tile {
  position: relative;
  left: auto;
  top: auto;
  width: auto;
  height: auto;
  grid-column: span var(--span, 1);
  grid-row: span var(--span, 1);
  min-width: 0;
  min-height: 0;
}

.heatmap-main {
  font-size: clamp(8px, 1.15vw, 28px);
  line-height: 1;
}

.heatmap-sub {
  font-size: clamp(7px, 0.85vw, 18px);
  opacity: 0.92;
  line-height: 1.1;
}

.heatmap-ticker {
  font-size: clamp(6px, 0.55vw, 10px);
  line-height: 1;
  letter-spacing: 0.02em;
  opacity: 0.95;
  text-align: center;
  white-space: nowrap;
}

.heatmap-hover-card {
  position: absolute;
  z-index: 20;
  min-width: 240px;
  max-width: 280px;
  background: rgba(5, 8, 14, 0.92);
  border: 1px solid rgba(120, 145, 182, 0.28);
  border-radius: 8px;
  padding: 10px 12px;
  color: #e8edf9;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.heatmap-hover-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 6px;
}

.heatmap-hover-card table {
  width: 100%;
  border-collapse: collapse;
}

.heatmap-hover-card th,
.heatmap-hover-card td {
  border: 0;
  border-bottom: 1px solid rgba(122, 142, 170, 0.2);
  padding: 4px 0;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}

.heat-neg-3 { background: #ef373e; }
.heat-neg-2 { background: #c44348; }
.heat-neg-1 { background: #7c4d57; }
.heat-neutral { background: #5f6368; }
.heat-pos-1 { background: #3d8f55; }
.heat-pos-2 { background: #2fa153; }
.heat-pos-3 { background: #26b04f; }

.quarterly-grid td {
  text-align: center;
  font-weight: 700;
}

.quarterly-grid th:first-child,
.quarterly-grid td:first-child {
  text-align: left;
}

.quarterly-grid table,
table.quarterly-grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

table.quarterly-grid thead th {
  background: rgba(157, 171, 188, 0.22);
  padding: 8px 10px;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--line);
}

table.quarterly-grid tbody td {
  padding: 7px 10px;
}

table.quarterly-grid tbody td:first-child {
  background: transparent;
  color: var(--text);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.quarterly-grid td.quarter-cell {
  color: #f4f7ff;
  border-left: 1px solid rgba(255, 255, 255, 0.72);
  border-right: 1px solid rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid rgba(255, 255, 255, 0.72);
  min-width: 120px;
}

.quarterly-grid td.quarter-pos {
  background: #56c78a;
}

.quarterly-grid td.quarter-neg {
  background: #ef7276;
}

.quarterly-grid td.quarter-flat {
  background: #6d7689;
}

.quarterly-grid td.quarter-na {
  background: #3d4658;
  color: #c9d1e1;
}

.recap-story-card {
  border: 1px solid #3a414e;
  border-radius: 10px;
  padding: 14px;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0) 38%),
    linear-gradient(180deg, #1b222f 0%, #151b27 100%);
  color: #e9edf5;
}

#compareStoryCard {
  padding: 10px;
  border-radius: 8px;
}

#compareStoryCard .recap-story-head h2 {
  font-size: 1.45rem;
}

#compareStoryCard .recap-story-head p {
  margin: 4px 0 8px;
  font-size: 0.9rem;
}

#compareStoryCard .recap-story-foot {
  margin-top: 6px;
  font-size: 0.82rem;
}

#compareStoryCard[data-bg="dark"] {
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0) 42%),
    linear-gradient(180deg, #1b222f 0%, #141a26 100%);
}

#compareStoryCard[data-bg="ocean"] {
  border-color: #355768;
  background:
    radial-gradient(circle at 85% 12%, rgba(138, 214, 232, 0.2), rgba(0, 0, 0, 0) 40%),
    linear-gradient(180deg, #132734 0%, #0f1f2a 100%);
}

#compareStoryCard[data-bg="sand"] {
  border-color: #6a563d;
  color: #fff4e8;
  background:
    radial-gradient(circle at 25% 10%, rgba(255, 221, 170, 0.18), rgba(0, 0, 0, 0) 44%),
    linear-gradient(180deg, #2e2316 0%, #231a11 100%);
}

#compareStoryCard[data-bg="sand"] .recap-story-head p,
#compareStoryCard[data-bg="sand"] .recap-story-foot {
  color: #e8d7c0;
}

.recap-story-head h2 {
  margin: 0;
  font-size: 1.85rem;
}

.recap-story-head p {
  margin: 6px 0 12px;
  color: #a9b2c3;
}

.recap-story-foot {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  color: #a9b2c3;
  font-size: 0.9rem;
}

.pos {
  color: var(--positive);
  font-weight: 600;
}

.neg {
  color: var(--negative);
  font-weight: 600;
}

.warn {
  background: rgba(185, 58, 50, 0.08);
}

#topMovers,
#dashboardTopTokens,
#sectorTable,
#sectorSubsectorTable,
#sectorTokensTable,
#subsectorTable,
#tokenTable,
#quarterlyRecapTable,
#digestPreview,
#privateLabelsPanel {
  overflow-x: auto;
}

#topMovers table,
#dashboardTopTokens table,
#sectorTable table,
#sectorSubsectorTable table,
#sectorTokensTable table,
#subsectorTable table,
#tokenTable table,
#quarterlyRecapTable table,
#digestPreview table,
#privateLabelsPanel table {
  min-width: 760px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #nav {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

@media (max-width: 768px) {
  .content {
    padding: 0.75rem;
  }

  .panel {
    padding: 0.65rem;
  }

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

  .asset-selectors {
    grid-template-columns: 1fr;
  }

  .page-head {
    flex-direction: column;
  }

  .private-auth-inline {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .top10-desktop-table {
    display: none;
  }

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

  .mover-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .heatmap-root {
    min-height: 320px;
    overflow-x: auto;
  }

  .heatmap-sector {
    min-width: 220px;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  .landscape-only {
    display: none !important;
  }

  .rotate-note {
    display: block;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  .sidebar {
    padding: 0.9rem 0.75rem;
  }

  .nav-button {
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
  }

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

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

  .button {
    width: 100%;
  }

  .recap-story-head h2 {
    font-size: 1.35rem;
  }
}
