/* ============================================================================
   TEMA
   ----------------------------------------------------------------------------
   Rənglər iki qatdadır. Aşağıdakı :root tünd temanın dəyərləridir; işıqlı tema
   faylın sonundakı [data-theme="light"] blokunda eyni adları yenidən təyin edir.
   Heç bir qayda birbaşa hex yazmır - hamısı bu adlara müraciət edir, ona görə
   tema dəyişmək üçün yalnız iki blok saxlanılır.

   Adlar rəngi yox, ROLU bildirir: --a-surface «panel fonu»dur, hansı boz
   olduğu temadan asılıdır. İki ad qəsdən heç vaxt çevrilmir:

     --a-on-color   rəngli düymə/nişan üzərindəki ağ mətn
     --a-on-accent  kəhrəba işarə üzərindəki tünd mətn

   Onların fonu hər iki temada eynidir (bənövşəyi düymə bənövşəyi qalır), ona
   görə üstündəki mətn də dəyişməməlidir.

   Tema html elementindəki data-theme atributu ilə seçilir; onu <head>-dəki
   kiçik skript hər səhifədə ilk işdə qoyur - əks halda səhifə bir an tünd
   yanıb sönərdi.
   ========================================================================== */
:root {
  /* Color Palette - Modern & Premium */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);

  --bg-dark: #0f0f23;
  --bg-card: rgba(25, 25, 45, 0.8);
  --bg-card-hover: rgba(35, 35, 55, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.05);

  --text-primary: #ffffff;
  --text-secondary: #b4b4c8;
  --text-muted: #7a7a8c;

  --border-color: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(102, 126, 234, 0.3);

  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  /* ---- Analitika səhifəsinin rol tokenləri ----
     Səthlər: dərindən qabağa doğru. Tünd temada qabaq plana çıxdıqca açılır,
     işıqlı temada əksinə - səhifə ən açıqdır, panel ondan bir ton fərqlənir. */
  --a-surface-deep: #111827;
  --a-surface: #1f2937;
  --a-surface-raised: #374151;
  --a-surface-slate: #0f172a;
  --a-surface-sunken: #0b1220;
  --a-surface-hover: #161f36;
  --a-bar: #14142b;

  /* Səth üzərində mətn - güclüdən sönüyə */
  --a-txt-hi: #fff;
  --a-txt-strong: #e5e7eb;
  --a-txt: #d1d5db;
  --a-txt-soft: #cbd5e1;
  --a-txt-muted: #9ca3af;
  --a-txt-faint: #6b7280;
  --a-txt-dim: #94a3b8;

  /* Rəngli fon üzərində - temadan asılı deyil */
  --a-on-color: #fff;
  --a-on-accent: #111827;

  /* Sərhədlər, örtüklər, yüklənmə skeleti */
  --a-border-soft: #263041;
  --a-border-mid: #334155;
  --a-border-hover: #4b5563;
  /* Sönük ulduz: interaktiv düymədir, ona görə ən azı 3:1 kontrast lazımdır.
     Əvvəlki dəyər 1.9:1 idi - tünd temada da güclə seçilirdi. Boz qalır ki,
     yanmış (kəhrəba) vəziyyətdən aydın fərqlənsin. */
  --a-icon-off: #6b7280;

  /* Çipə birləşən saat düyməsi və ikinci dərəcəli düymələrin sərhədi.
     Modalın öz fonu ilə qaynamamaq üçün ayrıca tokendir - --bg-card ilə
     eyni olduqda düymə ümumiyyətlə görünmürdü. */
  --a-control: #4b5563;
  --a-control-hover: #5b6675;
  --a-hover-soft: rgba(255, 255, 255, 0.04);
  --a-hover: rgba(255, 255, 255, 0.08);
  --a-divider: rgba(255, 255, 255, 0.05);
  --a-chip-bg: rgba(255, 255, 255, 0.12);
  --a-skeleton: #273041;
  --a-skeleton-hi: #323d52;
  --a-skeleton-dim: #232b3a;

  /* ---- Rəngli fon və vurğu üzərindəki mətn ----
     Tünd temada bunlar açıq çalarlardır (tünd fonda oxunsun deyə). İşıqlı
     temada həmin rolun mətni TÜND olmalıdır, yoxsa ağ fonda itir - məhz bu
     səbəbdən adları ayrıdır. Bir neçə çalar işıqlı temada eyni dəyərə yığılır;
     tünd temada isə hərəsi öz orijinal tonunu saxlayır. */
  --a-accent-txt: #c7d2fe;
  --a-accent-txt-dim: #a5b4fc;
  --a-brand-txt: #667eea;
  --a-warn-txt: #fcd34d;
  --a-warn-txt-soft: #fde68a;
  --a-warn-txt-mid: #fbbf24;
  --a-warn-txt-strong: #f59e0b;
  --a-bad-txt: #fca5a5;
  --a-bad-txt-soft: #fecaca;
  --a-bad-txt-strong: #ef4444;
  --a-good-txt: #6ee7b7;
  --a-good-txt-soft: #a7f3d0;
  --a-good-txt-strong: #10b981;
  --a-info-txt: #93c5fd;
  --a-sky-txt: #38bdf8;
  --a-sky-soft: #e0f2fe;
  --a-txt-hint: #8b93a1;

  /* Çart tor xətti - canvas-a çəkilir, ayrıca tokendir ki, işıqlı temada
     sərhədlərdən daha solğun ola bilsin. */
  --a-chart-grid: #374151;

  /* Pay zolağının etiketi: zolağın həm dolu, həm boş hissəsinin üstündən
     keçir, ona görə rəngi ilə kölgəsi cüt işləyir - biri fonu udan hala. */
  --a-bar-label: #fff;
  --a-bar-label-shadow: rgba(0, 0, 0, 0.6);

  /* Yapışqan başlıq - blur arxasında olduğu üçün şəffafdır */
  --header-bg: rgba(15, 15, 35, 0.8);
  --header-bg-solid: rgba(15, 15, 35, 0.9);

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Border Radius */
  --radius-sm: 0.5rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.4);

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
}

body.menu-open {
  overflow: hidden;
  touch-action: none;
  height: 100vh;
}

/* Animated Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 20%, rgba(79, 172, 254, 0.1) 0%, transparent 50%);
  animation: backgroundShift 20s ease infinite;
  z-index: -1;
}

@keyframes backgroundShift {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.8;
  }
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--spacing-sm);
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition-fast);
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--spacing-lg);
}

/* Header */
.header {
  padding: var(--spacing-lg) 0;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  cursor: pointer;
  flex-shrink: 0;
}

/* ===== Brand lockup: mark + name + what the system does ===== */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@media (max-width: 560px) {
  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand-name {
    font-size: 1.15rem;
  }
}

/* Mobile Header Adjustments */
@media (max-width: 768px) {
  .header-content {
    padding: 0 var(--spacing-sm);
  }

  .logo {
    font-size: 1.2rem;
  }
}

/* Hamburger Menu */
.hamburger-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 1001;
  transition: opacity var(--transition-fast);
  margin-left: auto;
  flex-shrink: 0;
}

.hamburger-menu.hidden {
  opacity: 0;
  pointer-events: none;
}

.hamburger-menu span {
  width: 25px;
  height: 3px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition-fast);
}

.nav-menu {
  position: fixed;
  top: 0;
  right: -100%;
  width: 280px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  padding: 60px 20px 20px;
  transition: right var(--transition-normal);
  z-index: 1000;
  box-shadow: var(--shadow-lg);
}

.nav-menu.active {
  right: 0;
}

.close-menu {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.close-menu:hover {
  background: var(--bg-glass);
  transform: scale(1.1);
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0;
  list-style: none;
}

.nav-links li {
  border-bottom: 1px solid var(--border-color);
}

.nav-links a {
  display: block;
  padding: var(--spacing-md);
  border-radius: 0;
  transition: var(--transition-normal);
}

.nav-links a:hover {
  background: var(--bg-glass);
}

/* Buttons */
.btn {
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  text-align: center;
  justify-content: center;
}

.btn-primary {
  background: var(--primary-gradient);
  /* --text-primary DEYİL: o, temaya görə çevrilir və işıqlı temada bənövşəyi
     fonun üstündə qara yazı qalırdı. Qradient hər iki temada eynidir, ona görə
     yazı da həmişə ağdır. */
  color: var(--a-on-color);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  /* --border-color (12% qaralıq) ağ kartın üstündə görünmürdü: fon da,
     düymə də ağ olanda geriyə yalnız yazı qalırdı. Kontur düymənin
     sərhədini çəkir, fon isə hər iki temada olduğu kimi saxlanılır. */
  border: 1px solid var(--a-control);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
}

.btn-danger {
  background: var(--error);
  color: var(--text-primary);
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  backdrop-filter: blur(10px);
  transition: var(--transition-normal);
}

.card:hover {
  border-color: var(--border-glow);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
}

/* Table */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  margin-top: var(--spacing-lg);
}

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

thead {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
}

th {
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  cursor: pointer;
  user-select: none;
  transition: var(--transition-fast);
}

th:hover {
  background: var(--bg-card-hover);
}

td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

tr {
  transition: var(--transition-fast);
}

tbody tr:hover {
  background: var(--bg-glass);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
}

.badge-az {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.badge-en {
  background: rgba(59, 130, 246, 0.2);
  color: var(--info);
}

.badge-ru {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.badge-unknown {
  background: rgba(122, 122, 140, 0.2);
  color: var(--text-muted);
}

.badge-youtube {
  background: rgba(141, 133, 113, 0.2);
  color: #ff0000;
}

.badge-tiktok {
  background: rgba(0, 242, 234, 0.2);
  color: #00f2ea;
}

/* Canlı yayım: transkript hələ yoxdur, yayım bitəndən sonra götürüləcək. */
.badge-live {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-md);
}

label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: 600;
  color: var(--text-primary);
}

input[type="text"],
input[type="password"],
input[type="url"],
textarea {
  width: 100%;
  padding: var(--spacing-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition-fast);
}

/* Açılan siyahının BƏNDLƏRİ. Bunlar `select`-in fonunu miras almır - brauzer
   onları ayrıca çəkir, ona görə rəngi burada açıq şəkildə vermək lazımdır.
   Verilmədikdə tünd temada sistem standartı qalırdı: ağ fonda ağ mətn, yəni
   yazı yalnız üzərinə gələndə görünürdü.

   `--bg-glass` BURADA YARAMIR - o, yarımşəffafdır (rgba), bənd fonu isə tam
   qeyri-şəffaf olmalıdır. `--a-surface` hər iki temada bərk rəngdir:
   tünd #1f2937, işıqlı #ffffff.

   DİQQƏT: yalnız `option` üslublanır, `select`-in ÖZÜ YOX. `select` yuxarıdakı
   qaydaya salınmışdı, oradakı `width: 100%` isə ana səhifədəki axtarış və dil
   seçimlərini səhifə boyu uzatdı. Onların öz enləri sinif qaydalarından gəlir,
   rəngləri isə index.html-dəki `select` qaydası onsuz da verir. */
select option {
  background: var(--a-surface);
  color: var(--text-primary);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-glow);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-glass);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--header-bg-solid);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* Alert */
.alert {
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-left: 4px solid var(--success);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-left: 4px solid var(--error);
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border-left: 4px solid var(--info);
}

/* Grid */
.grid {
  display: grid;
  gap: var(--spacing-lg);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.mt-1 {
  margin-top: var(--spacing-sm);
}

.mt-2 {
  margin-top: var(--spacing-md);
}

.mb-1 {
  margin-bottom: var(--spacing-sm);
}

.mb-2 {
  margin-bottom: var(--spacing-md);
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-1 {
  gap: var(--spacing-sm);
}

.gap-2 {
  gap: var(--spacing-md);
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: var(--spacing-sm);
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  /* Stays a row. The column direction is left over from when the navigation
     sat inline in the header; it is a fixed drawer now, so stacking only
     pushed the brand and the hamburger onto two lines. */
  .header-content {
    gap: var(--spacing-sm);
  }

  .nav-links {
    flex-direction: row;
    /* Changed to row for better mobile usage if space permits, or multiline */
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    gap: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
  }

  .nav-links li {
    border-bottom: none;
  }

  .table-container {
    font-size: 0.875rem;
  }

  th,
  td {
    padding: var(--spacing-sm);
  }

  /* Channel Items stack on mobile */
  .channel-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
  }

  .channel-info {
    width: 100%;
  }

  .channel-actions {
    width: 100%;
    justify-content: flex-start;
    /* Align buttons to start */
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    /* Allow buttons to wrap */
  }

  .btn {
    width: 100%;
    /* Full width buttons on mobile often look better or easier to tap */
    justify-content: center;
  }

  .channel-actions .btn {
    width: auto;
    /* Keep channel action buttons natural width or expand if needed */
    flex: 1;
  }
}

/* Login Card */
.login-card {
  max-width: 500px;
  margin: 4rem auto;
}

@media (max-width: 768px) {
  .login-card {
    margin: 2rem auto;
    padding: var(--spacing-md);
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(0);
  }
}

.slide-in {
  animation: slideIn 0.3s ease;
}

/* Mobile Responsive - Smaller Buttons */
@media (max-width: 768px) {
  .btn {
    padding: 8px 16px;
    font-size: 0.875rem;
  }

  .btn-secondary {
    padding: 8px 14px;
  }
}

/* Video Title Link */
.video-title-link {
  color: var(--text-primary);
  text-decoration: none;
  display: block;
  transition: all var(--transition-fast);
  position: relative;
}

.video-title-link:hover {
  color: #4facfe;
  text-decoration: underline;
}

.video-title-link:active {
  color: #00f2fe;
}

/* ===== Custom summary =====
   A small tool at the foot of the detail panel. One divider marks it off; the
   heading is plain text, because a coloured, emoji-led title made an optional
   extra look like the main event. */
.custom-summary {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

.cs-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary, #9ca3af);
}

.custom-summary-input-container {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.custom-summary-prompt-textarea {
  flex: 1;
  min-height: 64px;
  resize: vertical;
  padding: 9px 11px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.875rem;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.custom-summary-prompt-textarea:focus {
  outline: none;
  border-color: var(--accent-color);
}

.custom-summary-input-container .btn {
  padding: 9px 18px;
  font-size: 0.85rem;
}

/* Plainly inert rather than merely faded: the whole point is that it reads as
   "not yet", so the cursor has to say so too. */
.custom-summary-input-container .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--bg-card);
  color: var(--text-secondary, #9ca3af);
  border: 1px solid var(--border-color);
  box-shadow: none;
  transform: none;
}

.cs-result {
  display: none;
  margin-top: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--a-hover-soft);
  color: var(--text-primary);
  font-size: 0.875rem;
  line-height: 1.65;
}

.cs-controls {
  display: none;
  margin-top: 8px;
  text-align: right;
}

.cs-replace {
  padding: 6px 12px;
  font-size: 0.8rem;
}

@media (max-width: 768px) {
  .custom-summary-input-container {
    flex-direction: column;
    gap: 10px;
  }

  .custom-summary-prompt-textarea {
    width: 100%;
    min-height: 72px;
    /* Slightly taller than desktop: a thumb-typed prompt needs the room */
  }

  .custom-summary-input-container button {
    width: 100%;
    padding: 12px;
    justify-content: center;
  }
}

/* ===== Platform marks =====
   Shown wherever a video's source appears, on both pages. Sized in em so the
   logo follows whatever text it sits next to instead of needing a rule per
   place, and aligned optically to the baseline. */
.src-ico {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.22em;
  flex-shrink: 0;
}

.src-ico.yt {
  color: #ff0000;
}

/* TikTok's mark is monochrome: white on dark, black on light. A fixed light
   grey vanished against the light theme's white surfaces. */
.src-ico.tt {
  color: var(--a-txt-hi);
}

/* ===== Yüklənmə göstəricisi =====
   Shared by every page (see app-loader.js). An empty container measures 0 px,
   so the layout used to collapse to nothing while the first request was in
   flight - up to ~2 s on a one-year analytics range. The mark is the same one
   the header and the login page use; only its two bars move, which reads as a
   signal being measured. */
.app-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  min-height: 280px;
  padding: 40px 20px;
  text-align: center;
}

/* Inside a table cell there is already a row's worth of chrome around it. */
.app-loader.compact {
  min-height: 180px;
  padding: 24px 20px;
}

.al-mark {
  width: 68px;
  height: 68px;
  filter: drop-shadow(0 6px 18px rgba(102, 126, 234, 0.35));
  animation: al-breathe 2.4s ease-in-out infinite;
}

@keyframes al-breathe {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

/* fill-box + bottom origin so a bar grows off its own base, not the centre of
   the whole 64x64 canvas */
.al-bar {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: al-bar 1.1s ease-in-out infinite;
}

/* Staggered so the three bars ripple instead of pumping in unison. */
.al-bar-b {
  animation-delay: 0.37s;
}

.al-bar-c {
  animation-delay: 0.74s;
}

@keyframes al-bar {

  0%,
  100% {
    transform: scaleY(0.3);
  }

  50% {
    transform: scaleY(1);
  }
}

/* A thin indeterminate track - it says "still working" even when the mark is
   scrolled out of view on a short screen. */
.al-track {
  width: 180px;
  height: 3px;
  border-radius: 999px;
  background: var(--a-hover);
  overflow: hidden;
}

.al-track i {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #667eea, #a78bfa);
  animation: al-slide 1.3s ease-in-out infinite;
}

@keyframes al-slide {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(360%);
  }
}

/* Failure state: the same block, but it has things to say, and the loader's
   generous spacing would pull them apart. */
.app-loader.fail {
  gap: 12px;
  min-height: 220px;
}

.al-fail {
  font-size: 40px;
  line-height: 1;
}

.al-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.al-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  max-width: 340px;
  line-height: 1.5;
}

.al-retry {
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-primary);
  font-size: 12.5px;
  font-family: inherit;
  padding: 7px 15px;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}

.al-retry:hover {
  border-color: #667eea;
}

@media (prefers-reduced-motion: reduce) {

  .al-mark,
  .al-bar {
    animation: none;
  }

  /* The track is the one thing left that says "still working", so it keeps
     moving - just without the sliding travel. */
  .al-track i {
    width: 100%;
    animation: al-fade 2s ease-in-out infinite;
  }

  @keyframes al-fade {

    0%,
    100% {
      opacity: 0.25;
    }

    50% {
      opacity: 1;
    }
  }
}

/* ============================================================================
   İŞIQLI TEMA
   ----------------------------------------------------------------------------
   Yuxarıdakı :root ilə eyni adlar, əks qiymətlərlə. Qayda sadədir: tünd temada
   səth qabağa çıxdıqca AÇILIR, işıqlıda TÜNDLƏŞİR - ona görə sadəcə "rəngi
   tərsinə çevirmək" işləmir, hər rol ayrıca seçilib.

   Semantik rənglər (yaşıl/qırmızı/sarı/bənövşəyi) burada yoxdur: onlar hər iki
   temada eyni qalır. Yalnız çox açıq olanlar - ağ fonda oxunmayanlar - bir ton
   tündləşdirilib.
   ========================================================================== */
[data-theme="light"] {
  --bg-dark: #f4f5fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-glass: rgba(15, 23, 42, 0.04);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --border-color: rgba(15, 23, 42, 0.12);
  --border-glow: rgba(102, 126, 234, 0.35);

  /* Səthlər: səhifə ən açıq, panel ondan bir pillə tünd */
  --a-surface-deep: #eef1f6;
  --a-surface: #ffffff;
  --a-surface-raised: #e2e8f0;
  --a-surface-slate: #f8fafc;
  --a-surface-sunken: #eef1f6;
  --a-surface-hover: #f1f5f9;
  --a-bar: #ffffff;

  /* Mətn pilləkəni tərsinə: ən güclü = ən tünd */
  --a-txt-hi: #0f172a;
  --a-txt-strong: #1e293b;
  --a-txt: #334155;
  --a-txt-soft: #475569;
  --a-txt-muted: #64748b;
  --a-txt-faint: #94a3b8;
  --a-txt-dim: #64748b;

  /* Rəngli fon üzərində - qəsdən dəyişmir */
  --a-on-color: #fff;
  --a-on-accent: #111827;

  --a-border-soft: #e2e8f0;
  --a-border-mid: #cbd5e1;
  --a-border-hover: #94a3b8;
  --a-icon-off: #7b8a9e;
  --a-control: #94a3b8;
  --a-control-hover: #7b8a9e;
  --a-hover-soft: rgba(15, 23, 42, 0.04);
  --a-hover: rgba(15, 23, 42, 0.07);
  --a-divider: rgba(15, 23, 42, 0.08);
  --a-chip-bg: rgba(15, 23, 42, 0.08);
  --a-skeleton: #e2e8f0;
  --a-skeleton-hi: #f1f5f9;
  --a-skeleton-dim: #eef1f6;

  /* Vurğu mətnləri: ağ fonda oxunması üçün tündləşdirilib. WCAG AA (4.5:1)
     həddini keçirlər - tünd temadakı açıq çalarlar burada 1.5:1-ə düşərdi. */
  --a-accent-txt: #4338ca;
  --a-accent-txt-dim: #4f46e5;
  --a-brand-txt: #4f46e5;
  --a-warn-txt: #b45309;
  --a-warn-txt-soft: #b45309;
  --a-warn-txt-mid: #b45309;
  --a-warn-txt-strong: #b45309;
  --a-bad-txt: #b91c1c;
  --a-bad-txt-soft: #b91c1c;
  --a-bad-txt-strong: #b91c1c;
  --a-good-txt: #047857;
  --a-good-txt-soft: #047857;
  --a-good-txt-strong: #047857;
  --a-info-txt: #1d4ed8;
  --a-sky-txt: #0369a1;
  --a-sky-soft: #0c4a6e;
  --a-txt-hint: #475569;
  --a-chart-grid: #e5e9f0;
  --a-bar-label: #0f172a;
  --a-bar-label-shadow: rgba(255, 255, 255, 0.9);
  --header-bg: rgba(255, 255, 255, 0.82);
  --header-bg-solid: rgba(255, 255, 255, 0.94);

  /* Kölgələr ağ fonda daha yumşaq olmalıdır - tünd temadakı sıxlıq burada
     çirkli ləkə kimi görünür. */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.10);
  --shadow-glow: 0 0 18px rgba(102, 126, 234, 0.25);
}

/* ===== Tema açarı =====
   Hər səhifədə eyni görünsün deyə burada, analytics.html-in içində deyil.
   Hamburger düyməsi ilə yanaşı durur, ona görə ölçüsü ona yaxındır. */
.theme-toggle {
  margin-left: auto;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-glass);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--a-hover);
  border-color: var(--a-border-hover);
}

/* İkisi yanaşı olanda boşluğu açar verir - hamburgerin öz margin-left:auto-su
   varsa, ikisi arasında ara qalmazdı. */
.theme-toggle + .hamburger-menu {
  margin-left: 10px;
}

/* Mənbə sütunu: platformanın adı, ardınca öz nişanı. Nişan burada sözdən bir
   qədər iridir, amma ölçüsü yenə em-lə verilir - şrift böyüyəndə ikisi bir
   yerdə böyüyür və sətir hizası pozulmur.

   gap yoxdur: nişanla söz bir bütöv işarə kimi oxunmalıdır - "logo + ad"
   platformanın öz yazılışıdır, aralarındakı 6px onları iki ayrı şey kimi
   göstərirdi. Nişanın SVG-sinin öz içində onsuz da bir qədər hava var. */
.src-badge {
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
}

.src-badge .src-ico {
  width: 1.45em;
  height: 1.45em;
  vertical-align: middle;
}

/* ===== Yenilə ikonu ===== */
.rf-ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.rf-ico.spin {
  animation: rf-spin 0.9s linear infinite;
}

@keyframes rf-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Hərəkəti azaldılmış rejimdə fırlanma dayanır - ikon yenə görünür. */
@media (prefers-reduced-motion: reduce) {
  .rf-ico.spin {
    animation: none;
  }
}

/* ===== Endirmə xətası bloku =====
   Videonun səsi endirilə bilməyəndə detal pəncərəsinin başında görünür.
   Rəngi xəbərdarlıq tonundadır, amma qırmızı deyil - bu, keçici vəziyyətdir,
   sistem onsuz da yenidən cəhd edir. */
.dl-error {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-left: 3px solid var(--warning);
  border-radius: 0 8px 8px 0;
  background: rgba(245, 158, 11, 0.10);
}

.dl-error-head {
  font-size: 14px;
  font-weight: 600;
  color: var(--a-warn-txt-strong);
  margin-bottom: 6px;
}

.dl-error-note {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--a-txt);
  margin-bottom: 10px;
}

.dl-retry {
  font-size: 0.75rem;
  padding: 4px 12px;
}

.dl-error-status {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--a-txt-muted);
}

.dl-error-status:empty {
  margin-top: 0;
}

/* ===== Mətn sütununun vəziyyət süzgəci =====
   Mənbə süzgəci öz stilini sətir içində daşıyır; burada seçim sayı çox
   olduğuna görə eyni şeyi 10 dəfə təkrarlamaq əvəzinə sinif verilir. */
.status-filter-opt {
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  color: var(--text-primary);
}

.status-filter-opt:hover {
  background: var(--bg-card-hover);
}

/* Seçili olan. Menyu bağlı olanda hansı süzgəcin işlədiyini başlıqdakı
   nişan göstərir, menyu açılanda isə burada görünür. */
.status-filter-opt.active {
  background: var(--bg-card-hover);
  font-weight: 600;
}

.status-filter-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--border-color);
}

/* Süzgəc aktiv olanda başlıqdakı ▼ nişanı seçilir - əks halda cədvəldə niyə
   az sətir göründüyü bilinmirdi. */
#status-filter-mark.on {
  color: var(--accent-color, #f5576c);
  font-weight: 700;
}

/* ===== Cədvəl başlığı süzgəcləri (Mənbə, Kateqoriya) =====
   "📝 Text" süzgəci ilə eyni görünüş; seçim sətirləri üçün
   .status-filter-opt / .status-filter-sep sinifləri təkrar istifadə olunur. */
.col-filter-head {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}

.col-filter-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 0;
  z-index: 1000;
  font-weight: normal;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Kanal adının yanındakı platforma nişanı sətirlə eyni hündürlükdə olsun */
.col-filter-menu .status-filter-opt {
  display: flex;
  align-items: center;
  gap: 7px;
}

.col-filter-mark {
  font-size: 0.7rem;
}

/* Aktiv süzgəc - "📝 Text" başlığındakı #status-filter-mark.on ilə eyni */
.col-filter-mark.on {
  color: var(--accent-color, #f5576c);
  font-weight: 700;
}

/* Süzgəclərə uyğun nəticə olmayanda cədvəl gizlədilmir (başlıqdakı menyular
   da onunla birlikdə yox olurdu), əvəzinə bu sətir göstərilir. */
.empty-filter-row td {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-muted);
}
