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

:root {
  --bg:      #0d1117;
  --surface: #161b22;
  --surface2: #1c2128;
  --border:  #30363d;
  --text:    #e6edf3;
  --muted:   #8b949e;
  --blue:    #58a6ff;
  --green:   #3fb950;
  --yellow:  #d29922;
  --red:     #f85149;
  --purple:  #bc8cff;
  --orange:  #e3b341;
  --yt-red:  #ff3c3c;
  --yt-red-dim: rgba(255, 60, 60, 0.15);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Header ───────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.header-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.yt-icon {
  width: 28px;
  height: 28px;
  color: var(--yt-red);
  flex-shrink: 0;
}

.brand-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.brand-sub  { color: var(--muted); font-size: .75rem; margin-top: 1px; }

.header-center { flex: 1; display: flex; justify-content: center; }

.period-switcher {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.period-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 6px 16px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 500;
  transition: all .15s;
}
.period-btn:hover { color: var(--text); }
.period-btn.active { background: var(--yt-red); color: #fff; font-weight: 700; }

.header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.sync-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  color: var(--muted);
}
.sync-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  padding: 5px 12px;
  cursor: pointer;
  font-size: .8rem;
  text-decoration: none;
  transition: all .2s;
}
.btn-ghost:hover { border-color: var(--text); color: var(--text); }

/* ── Main layout ──────────────────────────────────────────────────── */
main {
  max-width: 1260px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ── KPI Row ──────────────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

@media (max-width: 900px) { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: border-color .2s, transform .2s;
}
.kpi-card:hover { border-color: #444c56; transform: translateY(-1px); }

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.views-icon    { background: var(--yt-red-dim); color: var(--yt-red); }
.watch-icon    { background: rgba(88,166,255,.12); color: var(--blue); }
.subs-icon     { background: rgba(63,185,80,.12); color: var(--green); }
.duration-icon { background: rgba(188,140,255,.12); color: var(--purple); }
.pct-icon      { background: rgba(210,153,34,.12); color: var(--yellow); }

.kpi-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.kpi-value { font-size: 1.55rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.kpi-sub   { font-size: .72rem; color: var(--muted); margin-top: 4px; }

/* ── Chart grid ───────────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 14px;
}

@media (max-width: 1000px) { .charts-row { grid-template-columns: 1fr; } }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.chart-full  { width: 100%; }
.chart-wide  { }
.chart-narrow { }

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.chart-title { font-size: .92rem; font-weight: 600; color: var(--text); }
.chart-sub   { font-size: .75rem; color: var(--muted); margin-top: 2px; }

.chart-plot    { height: 280px; }
.chart-plot-sm { height: 200px; }

/* ── Toggle buttons ───────────────────────────────────────────────── */
.chart-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.toggle-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 4px 12px;
  cursor: pointer;
  font-size: .75rem;
  transition: all .15s;
}
.toggle-btn:hover { color: var(--text); }
.toggle-btn.active { background: var(--surface2); color: var(--text); font-weight: 600; }

/* ── Videos table ─────────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.videos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.videos-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.videos-table th.sortable { cursor: pointer; user-select: none; }
.videos-table th.sortable:hover { color: var(--text); }
.videos-table th.sort-asc .sort-arrow::after  { content: " ▲"; }
.videos-table th.sort-desc .sort-arrow::after { content: " ▼"; }
.sort-arrow { color: var(--border); font-size: .65rem; }

.videos-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #1c2128;
  vertical-align: middle;
}
.videos-table tr:last-child td { border-bottom: none; }
.videos-table tr:hover td { background: #1c2128; }

.video-title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 340px;
}
.video-thumb {
  width: 52px;
  height: 29px;
  background: #21262d;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.video-title-text {
  font-size: .85rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.metric-num   { font-family: monospace; font-size: .88rem; color: var(--text); font-weight: 600; }
.metric-green { color: var(--green); }
.metric-blue  { color: var(--blue); }
.metric-yt    { color: var(--yt-red); }

.bar-cell { display: flex; align-items: center; gap: 8px; }
.bar-bg {
  flex: 1;
  height: 5px;
  background: #21262d;
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}
.bar-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.bar-fill.blue   { background: var(--blue); }
.bar-fill.green  { background: var(--green); }
.bar-fill.yt-red { background: var(--yt-red); }

.published-badge {
  font-size: .72rem;
  color: var(--muted);
  font-family: monospace;
}

.loading-row { text-align: center; color: var(--muted); padding: 32px; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px;
  font-size: .9rem;
}

/* ── Pagination ───────────────────────────────────────────────────── */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.pagination-info {
  font-size: .78rem;
  color: var(--muted);
}

.pagination-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.page-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  padding: 4px 10px;
  cursor: pointer;
  font-size: .8rem;
  line-height: 1.4;
  min-width: 32px;
  text-align: center;
  transition: all .15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--text); color: var(--text); }
.page-btn.active { background: var(--yt-red); border-color: var(--yt-red); color: #fff; font-weight: 700; }
.page-btn:disabled { opacity: .35; cursor: default; }
