:root {
  --bg: #05070b;
  --surface: rgba(10, 16, 24, 0.9);
  --surface2: rgba(17, 24, 35, 0.96);
  --border: rgba(138, 163, 191, 0.14);
  --text: #edf3fb;
  --text-dim: #8b9bb1;
  --accent: #7cd6ff;
  --green: #59e7bd;
  --yellow: #f5c86b;
  --red: #ff7b86;
  --orange: #ff9b63;
}

body {
  font-family: "Sora", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(124, 214, 255, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(89, 231, 189, 0.08), transparent 24%),
    linear-gradient(180deg, #05070b 0%, #090d14 100%);
  color: var(--text);
}

a {
  color: var(--accent);
}

.header {
  position: sticky;
  top: 0;
  z-index: 120;
  display: block;
  padding: 14px 24px 12px;
  backdrop-filter: blur(18px);
  background: rgba(7, 11, 18, 0.82);
  border-bottom: 1px solid rgba(138, 163, 191, 0.08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.header-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.header-brand {
  display: flex;
  align-items: center;
  justify-self: start;
  min-width: 0;
  max-width: 320px;
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, max-width 0.2s ease;
}

.header-nav-rail {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.header-nav-rail::-webkit-scrollbar {
  display: none;
}

.header-side {
  justify-self: end;
  display: flex;
  justify-content: flex-end;
}

.header.is-scrolled .header-brand {
  opacity: 0;
  transform: translateY(-8px);
  max-width: 0;
}

.header-stat-card {
  min-width: 152px;
  padding: 12px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(16, 24, 36, 0.94), rgba(10, 16, 24, 0.9));
  border: 1px solid rgba(138, 163, 191, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.header-stat-label {
  color: #8fa2ba;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.header-stat-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
}

.header-stat-sub {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 11px;
}

.header h1 {
  font-size: 22px;
  letter-spacing: -0.04em;
  line-height: 1;
  white-space: nowrap;
}

.container {
  max-width: 1560px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.card {
  background:
    linear-gradient(180deg, rgba(20, 29, 42, 0.96), rgba(10, 15, 23, 0.96));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.summary-row {
  gap: 16px;
  margin-bottom: 22px;
}

#summaryCards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#summaryCards .card {
  padding: 18px 20px;
  min-height: 132px;
}

#summaryCards .label {
  color: #90a1b7;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#summaryCards .value {
  margin-top: 14px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

#summaryCards .sub {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 12px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 0;
  padding: 10px;
  width: max-content;
  min-width: 100%;
  overflow: visible;
  flex-wrap: nowrap;
  justify-content: center;
  scrollbar-width: none;
  border-radius: 24px;
  background: rgba(8, 12, 18, 0.74);
  border: 1px solid rgba(138, 163, 191, 0.12);
  backdrop-filter: blur(18px);
}

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

.tab {
  flex: 0 0 auto;
  border-radius: 18px;
  padding: 12px 18px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: -0.02em;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.tab:hover {
  transform: translateY(-1px);
  color: var(--text);
}

.tab.active {
  color: #f8fbff;
  background: linear-gradient(135deg, rgba(124, 214, 255, 0.2), rgba(89, 231, 189, 0.14));
  border-color: rgba(124, 214, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.badge {
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
}

.tab-content {
  animation: reelsFadeIn 0.24s ease;
}

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

.section-kicker {
  color: #89a0bc;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.reels-kpi-stack {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.reels-kpi-card {
  padding: 18px 18px 16px;
  min-height: 136px;
}

.reels-kpi-card .label {
  color: #90a1b7;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reels-kpi-card .value {
  margin-top: 14px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.reels-kpi-card .sub {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.45;
}

.reels-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.reels-chart-card,
.reels-accounts-card,
.reels-viral-card {
  padding: 20px 22px;
}

.reels-chart-card {
  min-height: 468px;
}

.reels-mini-chart-card {
  min-height: 420px;
}

.reels-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.reels-card-head h2 {
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.05em;
}

.reels-range-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

#reelsAccountsNiche,
#reelsAccountsSort {
  min-width: 220px;
}

.reels-chart-toggle {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(13, 20, 30, 0.9);
  border: 1px solid rgba(138, 163, 191, 0.12);
}

.reels-toggle-btn {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.reels-toggle-btn.active {
  color: #f5fbff;
  background: linear-gradient(135deg, rgba(124, 214, 255, 0.24), rgba(89, 231, 189, 0.18));
}

.reels-range-select,
.reels-custom-range input {
  background: rgba(17, 25, 36, 0.88);
  color: var(--text);
  border: 1px solid rgba(138, 163, 191, 0.18);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
}

.reels-custom-range {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reels-chart-meta,
.post-feed-meta,
.post-tracker-meta {
  margin: 0 2px 14px;
  color: var(--text-dim);
  font-size: 12px;
}

#reelsOverviewChart {
  width: 100% !important;
  height: 350px !important;
}

#reelsPostsChart {
  width: 100% !important;
  height: 300px !important;
}

.reels-viral-card {
  margin-top: 20px;
}

.reels-viral-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.viral-row {
  display: grid;
  grid-template-columns: 42px 88px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 14px;
  border-radius: 20px;
  background: rgba(11, 17, 25, 0.72);
  border: 1px solid rgba(138, 163, 191, 0.1);
}

.viral-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(124, 214, 255, 0.24), rgba(89, 231, 189, 0.18));
  color: #f5fbff;
  font-weight: 800;
}

.viral-thumb,
.viral-thumb-empty {
  width: 88px;
  height: 88px;
  border-radius: 18px;
}

.viral-thumb {
  object-fit: cover;
  display: block;
}

.viral-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 26, 37, 0.95);
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
}

.viral-main {
  min-width: 0;
}

.viral-topline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.viral-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.viral-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.viral-avatar-wrap,
.reels-account-avatar-wrap,
.post-feed-avatar-wrap,
.post-tracker-avatar-wrap {
  display: inline-flex;
  flex: 0 0 auto;
}

.character-pfp-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(124, 214, 255, 0.26), rgba(89, 231, 189, 0.18));
  color: #f5fbff;
  font-size: 72px;
  font-weight: 800;
}

.viral-avatar,
.viral-avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 14px;
}

.viral-avatar {
  display: block;
  object-fit: cover;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.26);
}

.viral-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(124, 214, 255, 0.28), rgba(89, 231, 189, 0.18));
  color: #f5fbff;
  font-weight: 800;
}

.viral-username {
  color: #f5fbff;
  font-size: 15px;
  font-weight: 700;
  min-width: 0;
}

.viral-date {
  color: var(--text-dim);
  font-size: 12px;
}

.viral-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--text-dim);
  font-size: 12px;
}

.reels-accounts-card {
  margin-top: 18px;
}

.reels-accounts-table-wrap,
.reels-detail-table-wrap {
  overflow-x: auto;
}

.reels-accounts-table,
.reels-detail-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.reels-accounts-table {
  table-layout: fixed;
}

.reels-accounts-table thead th,
.reels-detail-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(11, 17, 25, 0.96);
  color: #93a7c1;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.reels-accounts-table th,
.reels-accounts-table td,
.reels-detail-table th,
.reels-detail-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(138, 163, 191, 0.08);
}

.reels-accounts-table th:first-child,
.reels-accounts-table td:first-child {
  width: 220px;
}

.reels-accounts-table th:nth-child(2),
.reels-accounts-table td:nth-child(2) {
  width: 120px;
}

.reels-accounts-table td {
  font-size: 12px;
}

.reels-account-row {
  cursor: pointer;
  transition: background 0.16s ease;
}

.reels-account-row:hover {
  background: rgba(16, 24, 35, 0.82);
}

.reels-account-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

.reels-account-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 12px;
  display: block;
  object-fit: cover;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.26);
}

.reels-account-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(124, 214, 255, 0.28), rgba(89, 231, 189, 0.18));
  color: #f5fbff;
  font-weight: 800;
}

.reels-account-link {
  color: #f5fbff;
  font-weight: 700;
}

.reels-account-detail-row td {
  padding: 0 0 16px;
  border-bottom: 0;
}

.reels-detail-panel {
  margin: 0 12px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(8, 13, 20, 0.94);
  border: 1px solid rgba(138, 163, 191, 0.1);
}

.reels-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.reels-detail-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.reels-detail-sub {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 12px;
}

.reels-empty {
  padding: 24px;
  border-radius: 18px;
  border: 1px dashed rgba(138, 163, 191, 0.16);
  color: var(--text-dim);
  text-align: center;
}

.reels-empty.inline {
  padding: 16px;
  background: rgba(11, 17, 25, 0.8);
}

.post-feed-grid {
  display: grid;
  gap: 18px;
}

.post-feed-day-group {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.post-feed-day-label {
  position: sticky;
  top: 116px;
  padding: 14px 0 0;
  color: #f5fbff;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.post-feed-day-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.post-feed-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px;
  min-height: 0;
}

.post-feed-avatar,
.post-feed-avatar-fallback {
  width: 64px;
  height: 64px;
  border-radius: 18px;
}

.post-feed-avatar {
  display: block;
  object-fit: cover;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

.post-feed-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(124, 214, 255, 0.3), rgba(89, 231, 189, 0.18));
  color: #f5fbff;
  font-weight: 800;
}

.post-feed-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  width: 100%;
}

.post-feed-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.post-feed-name {
  color: #f5fbff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.post-feed-submeta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.post-feed-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(17, 25, 36, 0.82);
  border: 1px solid rgba(138, 163, 191, 0.12);
  color: var(--text-dim);
  font-size: 11px;
}

.post-feed-time {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
}

.post-feed-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.post-feed-metric {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(13, 20, 30, 0.94);
  border: 1px solid rgba(138, 163, 191, 0.12);
  min-width: 0;
}

.post-feed-metric .label {
  display: block;
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.post-feed-metric .value {
  display: block;
  margin-top: 6px;
  color: #dbe7f2;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-feed-caption,
.post-feed-caption.empty {
  display: none;
}

.post-feed-meta:empty {
  display: none;
}

.post-feed-grid {
  gap: 24px;
}

.post-feed-day-group {
  grid-template-columns: 1fr;
  gap: 14px;
}

.post-feed-day-label {
  position: static;
  padding: 0;
  color: #f5fbff;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.post-feed-day-cards {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.post-feed-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px;
}

.post-feed-top {
  display: flex;
  align-items: center;
  gap: 16px;
}

.post-feed-body {
  gap: 6px;
}

.post-feed-name {
  font-size: 17px;
}

.post-feed-time {
  margin-top: 0;
  font-size: 13px;
}

.post-feed-detail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding-top: 12px;
  border-top: 1px solid rgba(138, 163, 191, 0.12);
}

.post-feed-detail-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.post-feed-detail-item .value {
  color: #f5fbff;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.post-feed-detail-item .label {
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.01em;
  text-transform: none;
}

.post-feed-detail-item.niche .label {
  color: #8fa7bf;
}

@media (max-width: 1280px) {
  .header-shell {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand side"
      "nav nav";
  }

  .header-brand {
    grid-area: brand;
    max-width: none;
  }

  .header-nav-rail {
    grid-area: nav;
  }

  .header-side {
    grid-area: side;
  }

  .tabs {
    justify-content: flex-start;
  }

  .reels-kpi-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .reels-overview-grid {
    grid-template-columns: 1fr;
  }

  .post-feed-day-group {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .post-feed-day-label {
    position: static;
    padding-top: 0;
  }
}

@media (max-width: 980px) {
  #summaryCards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reels-kpi-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .viral-row {
    grid-template-columns: 42px 72px minmax(0, 1fr);
  }

  .viral-thumb,
  .viral-thumb-empty {
    width: 72px;
    height: 72px;
  }

  .post-feed-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .header {
    padding: 16px 14px 12px;
  }

  .header-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "side"
      "nav";
    gap: 12px;
  }

  .header-brand {
    display: none;
  }

  .header-side {
    justify-self: stretch;
  }

  .header-stat-card {
    width: 100%;
    min-width: 0;
  }

  .container {
    padding: 20px 14px 44px;
  }

  .tabs {
    padding: 8px;
  }

  .tab {
    padding: 11px 14px;
  }

  #summaryCards,
  .reels-kpi-stack {
    grid-template-columns: 1fr;
  }

  .reels-card-head,
  .post-feed-header {
    flex-direction: column;
  }

  .post-feed-time {
    min-width: 0;
    text-align: left;
  }

  .reels-account-cell {
    min-width: 160px;
  }

  .post-feed-grid {
    grid-template-columns: 1fr;
  }
}
