/* === TikTok Stats — futuristic dark === */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
  background: #0a0a0f;
  background-image:
    radial-gradient(ellipse at top left, rgba(254,44,85,0.15) 0%, transparent 40%),
    radial-gradient(ellipse at bottom right, rgba(37,244,238,0.10) 0%, transparent 40%),
    linear-gradient(180deg, #0a0a0f 0%, #07070b 100%);
  background-attachment: fixed;
  color: #e6e6f0;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app { max-width: 1280px; margin: 0 auto; padding: 16px; }

/* ----- TOP BAR ----- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 {
  font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.5px;
  background: linear-gradient(90deg, #fe2c55, #25f4ee);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #fe2c55;
  box-shadow: 0 0 12px #fe2c55, 0 0 24px rgba(254,44,85,0.5);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}
.header-controls { display: flex; gap: 8px; }
.icon-btn {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  color: #e6e6f0; width: 36px; height: 36px; border-radius: 10px;
  font-size: 18px; cursor: pointer; transition: all 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); }
.icon-btn:active { transform: scale(0.92); }

/* ----- CARDS ----- */
.card {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 14px;
}
.card.glow {
  box-shadow: 0 0 60px rgba(254,44,85,0.15), 0 0 120px rgba(37,244,238,0.08);
}
.card h2 {
  font-size: 15px; font-weight: 600; margin: 0;
  color: #e6e6f0;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.card .muted { color: #8a8aa0; }
.muted.small { font-size: 12px; }

/* ----- LOGIN ----- */
#login-screen { padding: 40px 0; }
#login-screen h2 { font-size: 24px; margin-bottom: 12px; }
#login-screen p { color: #a0a0b0; margin-bottom: 24px; line-height: 1.6; }

.btn-primary {
  display: block; text-align: center;
  background: linear-gradient(135deg, #fe2c55 0%, #ff4d70 100%);
  color: white; padding: 16px 24px;
  border-radius: 12px; text-decoration: none;
  font-weight: 600; font-size: 16px;
  border: none; cursor: pointer; width: 100%;
  box-shadow: 0 8px 32px rgba(254,44,85,0.35);
  transition: all 0.2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 40px rgba(254,44,85,0.5); }
.btn-primary:active { transform: scale(0.98); }

/* ----- ACCOUNT TABS ----- */
.account-tabs-wrap { margin-bottom: 12px; }
.account-tabs {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.account-tabs::-webkit-scrollbar { display: none; }
.account-tab {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: #c8c8d8; padding: 8px 14px;
  border-radius: 20px; font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
.account-tab:hover { background: rgba(255,255,255,0.08); color: #fff; }
.account-tab.active {
  background: linear-gradient(135deg, #fe2c55, #ff4d70);
  color: #fff; border-color: transparent;
  box-shadow: 0 4px 16px rgba(254,44,85,0.4);
}
.account-tab.add { background: transparent; border-style: dashed; color: #fe2c55; }
.account-tab .tab-x {
  display: inline-block; width: 16px; height: 16px; line-height: 14px;
  text-align: center; border-radius: 50%; font-size: 12px;
  background: rgba(0,0,0,0.25);
}
.account-tab.active .tab-x { background: rgba(255,255,255,0.25); color: #fff; }

/* ----- VIEW TOGGLE ----- */
.view-toggle {
  display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap;
  align-items: center;
}
.view-tab, .range-tab {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #a0a0b0; padding: 7px 14px;
  border-radius: 10px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.view-tab.active {
  background: rgba(37,244,238,0.12);
  border-color: rgba(37,244,238,0.4);
  color: #25f4ee;
}
.range-tab.active {
  background: rgba(254,44,85,0.15);
  border-color: rgba(254,44,85,0.4);
  color: #fe2c55;
}
.range-spacer { flex: 1; min-width: 12px; }

/* ----- KPI GRID ----- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 14px;
}
@media (min-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
.kpi-card {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 14px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, #fe2c55, transparent);
  opacity: 0.6;
}
.kpi-label { font-size: 11px; color: #8a8aa0; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; color: #fff; line-height: 1.1; }
.kpi-delta { font-size: 12px; color: #25f4ee; margin-top: 4px; font-weight: 500; }
.kpi-delta.neg { color: #ff4d70; }
.kpi-delta.zero { color: #6a6a80; }

/* ----- MAIN GRID (chart + top posts) ----- */
.main-grid {
  display: grid; grid-template-columns: 1fr; gap: 14px;
}
@media (min-width: 960px) {
  .main-grid { grid-template-columns: 2fr 1fr; }
}
.chart-card .chart-wrap {
  position: relative; height: 280px;
}
#chart { width: 100% !important; height: 100% !important; }

/* ----- TOP POSTS ----- */
.top-posts-card { max-height: 480px; overflow-y: auto; }
.top-post-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.top-post-row:last-child { border-bottom: none; }
.top-post-rank {
  font-size: 18px; font-weight: 700; color: #fe2c55;
  min-width: 24px; text-align: center;
}
.top-post-thumb {
  width: 44px; height: 60px; border-radius: 8px;
  background: rgba(255,255,255,0.05); flex-shrink: 0; object-fit: cover;
}
.top-post-info { flex: 1; min-width: 0; }
.top-post-title {
  font-size: 13px; color: #e6e6f0; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-post-account { font-size: 11px; color: #8a8aa0; margin-top: 2px; }
.top-post-views { text-align: right; }
.top-post-views-num { font-size: 14px; font-weight: 600; color: #fff; }
.top-post-views-delta { font-size: 11px; color: #25f4ee; margin-top: 2px; }
.top-post-views-delta.neg { color: #ff4d70; }

/* ----- LEADERBOARD ----- */
.leaderboard-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-rank {
  font-size: 20px; font-weight: 700;
  min-width: 30px; text-align: center;
}
.leaderboard-row:nth-child(1) .leaderboard-rank { color: #ffd700; }
.leaderboard-row:nth-child(2) .leaderboard-rank { color: #c0c0c0; }
.leaderboard-row:nth-child(3) .leaderboard-rank { color: #cd7f32; }
.leaderboard-name { flex: 1; font-size: 14px; color: #e6e6f0; font-weight: 500; }
.leaderboard-bar-wrap { flex: 2; height: 6px; background: rgba(255,255,255,0.05); border-radius: 3px; overflow: hidden; margin-right: 12px; }
.leaderboard-bar { height: 100%; background: linear-gradient(90deg, #fe2c55, #25f4ee); border-radius: 3px; transition: width 0.4s ease; }
.leaderboard-value { font-size: 13px; font-weight: 600; color: #fff; min-width: 60px; text-align: right; }

/* ----- VIDEO LIST ----- */
#video-list .video-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
}
#video-list .video-row:last-child { border-bottom: none; }
.video-thumb {
  width: 50px; height: 70px; border-radius: 8px;
  background: rgba(255,255,255,0.05); flex-shrink: 0; object-fit: cover;
}
.video-info { flex: 1; min-width: 0; }
.video-title {
  font-size: 13px; color: #e6e6f0; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.video-date { font-size: 11px; color: #8a8aa0; margin-top: 2px; }
.video-views { font-size: 14px; font-weight: 600; color: #fff; text-align: right; }
.video-views-delta { font-size: 11px; color: #25f4ee; text-align: right; margin-top: 2px; }
.video-views-delta.neg { color: #ff4d70; }

/* ----- ERROR / UTIL ----- */
.error {
  background: rgba(255,77,112,0.15); color: #ff4d70;
  border: 1px solid rgba(255,77,112,0.4);
  padding: 12px 16px; border-radius: 12px;
  margin: 16px 0; font-size: 14px;
}
.hidden { display: none !important; }
.small { font-size: 12px; }
