:root {
  --green: #62c82f;
  --green-strong: #43b91f;
  --green-soft: #edfbe8;
  --ink: #1f2a37;
  --muted: #7a8594;
  --line: #e8edf2;
  --panel: #ffffff;
  --bg: #f5f7fa;
  --orange: #ff9f38;
  --teal: #20b5a9;
  --purple: #8a67e8;
  --red: #f24d5d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 14px 10px;
  z-index: 20;
}

.brand {
  display: grid;
  place-items: center;
  height: 42px;
  margin-bottom: 16px;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 22px;
  border: 8px solid var(--green);
  border-top-color: #df2f52;
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(10deg);
}

.side-nav {
  display: grid;
  gap: 7px;
}

.side-item {
  width: 52px;
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  color: #47515f;
  background: transparent;
  display: grid;
  place-items: center;
  gap: 4px;
}

.side-item span:last-child {
  font-size: 12px;
}

.side-item.active {
  color: var(--green-strong);
  background: var(--green-soft);
}

.icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  background: #98a2ae;
  mask-size: contain;
  mask-position: center;
  mask-repeat: no-repeat;
}

.active .icon {
  background: var(--green-strong);
}

.grid { mask-image: linear-gradient(#000 0 0); border-radius: 4px; box-shadow: 9px 0 0 #98a2ae, 0 9px 0 #98a2ae, 9px 9px 0 #98a2ae; width: 7px; height: 7px; }
.active .grid { box-shadow: 9px 0 0 var(--green-strong), 0 9px 0 var(--green-strong), 9px 9px 0 var(--green-strong); }
.pie { border-radius: 50%; clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 0); }
.user { border-radius: 50% 50% 45% 45%; }
.video { border-radius: 4px; position: relative; }
.video::after { content: ""; position: absolute; border-left: 5px solid #fff; border-top: 4px solid transparent; border-bottom: 4px solid transparent; top: 5px; left: 7px; }
.live { border-radius: 4px; }
.bag { border-radius: 4px 4px 6px 6px; }
.lock { border-radius: 4px; }
.tool { border-radius: 3px; transform: rotate(45deg); }
.data { border-radius: 50%; }

.workspace {
  min-width: 0;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 15;
}

.menu-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-content: center;
  gap: 4px;
}

.menu-button span {
  width: 14px;
  height: 2px;
  background: #9aa4b2;
  border-radius: 2px;
}

.search {
  position: relative;
  width: min(360px, 45vw);
}

.search input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0 42px 0 18px;
  outline: 0;
  color: var(--ink);
  background: #fbfcfd;
}

.search-icon {
  position: absolute;
  right: 15px;
  top: 11px;
  width: 14px;
  height: 14px;
  border: 2px solid #a4adb8;
  border-radius: 50%;
}

.search-icon::after {
  content: "";
  width: 7px;
  height: 2px;
  background: #a4adb8;
  position: absolute;
  right: -6px;
  bottom: -3px;
  transform: rotate(45deg);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

.ghost-button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #516071;
  background: #fff;
  padding: 0 14px;
}

.rank-nav-wrap {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  padding-left: 24px;
  position: sticky;
  top: 64px;
  z-index: 14;
}

.rank-tabs {
  display: flex;
  align-items: stretch;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.rank-tabs::-webkit-scrollbar {
  display: none;
}

.rank-tabs button {
  position: relative;
  min-width: max-content;
  border: 0;
  background: transparent;
  color: #263241;
  padding: 0 22px;
}

.rank-tabs button.active {
  color: var(--green-strong);
  font-weight: 600;
}

.rank-tabs button.active::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 3px;
  background: var(--green);
  border-radius: 3px 3px 0 0;
}

.rank-tabs b,
.mega-column b {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  color: #fff;
  background: var(--green-strong);
  font-size: 10px;
  line-height: 14px;
  vertical-align: top;
}

.mega-column b {
  background: var(--red);
}

.mega-column b.new {
  background: var(--green-strong);
}

.more-button {
  margin: 10px 24px 10px auto;
  height: 36px;
  border: 1px solid #bceba3;
  border-radius: 6px;
  background: #f8fff4;
  color: var(--green-strong);
  font-weight: 600;
  padding: 0 14px;
  white-space: nowrap;
}

.trophy {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  background: var(--green-strong);
  clip-path: polygon(15% 10%, 85% 10%, 78% 58%, 58% 58%, 58% 78%, 75% 78%, 75% 90%, 25% 90%, 25% 78%, 42% 78%, 42% 58%, 22% 58%);
  vertical-align: -2px;
}

.mega-menu {
  position: absolute;
  top: 54px;
  left: 8px;
  width: min(820px, calc(100vw - 110px));
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 42px rgba(31, 42, 55, 0.13);
  border-radius: 0 0 8px 8px;
  padding: 30px 36px;
  z-index: 30;
}

.mega-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 34px;
}

.mega-column h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.mega-column p {
  margin: 7px 0 22px;
  color: #667386;
  font-size: 13px;
}

.mega-column button {
  display: block;
  width: 100%;
  height: 40px;
  text-align: left;
  border: 0;
  background: transparent;
  color: #273343;
  border-radius: 6px;
}

.mega-column button:hover {
  color: var(--green-strong);
  background: var(--green-soft);
}

.filters {
  margin: 28px 28px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px 24px;
  display: grid;
  grid-template-columns: auto 240px 1fr;
  gap: 20px;
  align-items: center;
}

.period-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.period-switch button {
  height: 36px;
  min-width: 64px;
  border: 0;
  border-right: 1px solid var(--line);
  color: #566273;
  background: #fff;
}

.period-switch button:last-child {
  border-right: 0;
}

.period-switch button.active {
  color: var(--green-strong);
  background: #f8fff4;
  box-shadow: inset 0 0 0 1px var(--green);
  font-weight: 600;
}

.date-field input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #7a8594;
  padding: 0 12px;
  outline: 0;
}

.filter-help {
  justify-self: end;
  color: #98a2ae;
  font-size: 13px;
}

.tag-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  color: #7a8594;
}

.tag-label {
  color: #5d6878;
  margin-right: 2px;
}

.tag-row button {
  height: 28px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #8a94a3;
  padding: 0 8px;
}

.tag-row button.active {
  background: #a8df8c;
  color: #fff;
}

.notice {
  margin: 0 28px 16px;
  color: #8a94a3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.notice-icon {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: #fff;
  background: #b8c0cb;
  font-size: 11px;
  font-weight: 700;
}

.table-card {
  margin: 0 28px 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.table-meta {
  height: 54px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.table-meta strong {
  margin-right: 10px;
  font-size: 16px;
}

#sourceBadge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  color: #9f6a22;
  background: #fff5df;
  font-size: 12px;
}

#sourceBadge.live {
  color: #167a43;
  background: #e6f8ee;
}

#sourceBadge.error {
  color: #aa2634;
  background: #ffe9ec;
}

#updatedAt {
  color: #8994a3;
  font-size: 13px;
}

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

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

th {
  height: 48px;
  color: #5f6b7a;
  background: #f8fafc;
  text-align: left;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  height: 84px;
  border-bottom: 1px solid var(--line);
  color: #293546;
  vertical-align: middle;
}

th,
td {
  padding: 0 14px;
}

.rank-cell {
  width: 78px;
  text-align: center;
  color: #4c596a;
}

.video-info,
.creator {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 260px;
}

.video-info img {
  width: 54px;
  height: 64px;
  border-radius: 5px;
  object-fit: cover;
  background: #edf1f6;
  flex: 0 0 auto;
}

.creator {
  min-width: 170px;
}

.creator img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: #edf1f6;
  flex: 0 0 auto;
}

.video-info span,
.creator span {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.video-info strong,
.creator strong {
  max-width: 270px;
  color: #1f2a37;
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.creator strong {
  max-width: 130px;
  display: block;
  white-space: nowrap;
}

.video-info em,
.creator em {
  color: #8a94a3;
  font-size: 12px;
  font-style: normal;
}

.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid #bfeaaa;
  color: var(--green-strong);
  background: #f7fff3;
  font-weight: 600;
}

.score.high {
  border-color: #ffcf98;
  color: #f27c1b;
  background: #fff6ec;
}

.score.low {
  border-color: #cfe6ff;
  color: #2581cf;
  background: #f2f8ff;
}

.metric {
  color: #31506d;
  font-variant-numeric: tabular-nums;
}

.metric.hot {
  color: var(--green-strong);
  font-weight: 600;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  color: #8792a1;
}

.empty-state strong {
  color: #435166;
}

.skeleton span {
  display: block;
  height: 16px;
  width: 80%;
  border-radius: 8px;
  background: linear-gradient(90deg, #edf1f6, #f8fafc, #edf1f6);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

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

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

  .sidebar {
    display: none;
  }

  .topbar {
    padding: 0 14px;
  }

  .topbar-actions {
    display: none;
  }

  .search {
    width: 100%;
  }

  .rank-nav-wrap {
    top: 64px;
    padding-left: 8px;
  }

  .rank-tabs button {
    padding: 0 14px;
  }

  .more-button {
    margin-right: 10px;
  }

  .mega-menu {
    left: 8px;
    width: calc(100vw - 16px);
    padding: 22px;
  }

  .mega-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .filters {
    margin: 16px 12px;
    grid-template-columns: 1fr;
  }

  .filter-help {
    justify-self: start;
  }

  .notice,
  .table-card {
    margin-left: 12px;
    margin-right: 12px;
  }
}
