@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #07090e;
  --bg-secondary: #0d111a;
  --bg-card: rgba(18, 24, 38, 0.7);
  --bg-card-hover: rgba(28, 38, 58, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.4);
  
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --cyan-accent: #06b6d4;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #64748b;
  
  --glass-bg: rgba(13, 17, 26, 0.75);
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(6, 182, 212, 0.1) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(139, 92, 246, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Layout */
.app-container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 16px 20px;
}

/* Header & Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  margin-bottom: 24px;
  position: sticky;
  top: 16px;
  z-index: 100;
  gap: 16px;
  flex-wrap: nowrap;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--primary-glow);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.brand-info h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.brand-info .tagline {
  font-size: 0.72rem;
  color: var(--cyan-accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Nav Tabs */
.nav-tabs {
  display: flex !important;
  align-items: center !important;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 6px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: nowrap !important;
  gap: 3px;
  flex-shrink: 0;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px;
  transition: var(--transition);
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  word-break: keep-all !important;
}

.nav-btn:hover {
  color: var(--text-main);
}

.nav-btn.active {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.badge-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
}

/* Mini Realtime Speed Pill (Nhỏ 50%, nằm sau menu Cấu Hình) */
.nav-speed-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 189, 248, 0.32);
  padding: 3px 8px;
  border-radius: 9999px;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.1);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 4px;
  user-select: none;
  transition: var(--transition);
}

.nav-speed-mini:hover {
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.25);
}

.nav-speed-mini .speed-pulse-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: speedPulseMini 2s infinite ease-in-out;
  flex-shrink: 0;
}

@keyframes speedPulseMini {
  0% { transform: scale(0.85); opacity: 0.7; }
  50% { transform: scale(1.25); opacity: 1; box-shadow: 0 0 8px #10b981; }
  100% { transform: scale(0.85); opacity: 0.7; }
}

.speed-mini-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1;
}

.speed-mini-item.dl {
  color: #38bdf8;
}

.speed-mini-item.up {
  color: #34d399;
}

.speed-mini-sep {
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.65rem;
  margin: 0 1px;
}

/* Stats Ribbon */
.stats-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: var(--border-color) 1px solid;
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-highlight);
  background: var(--bg-card-hover);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.indigo { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.stat-icon.cyan { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.stat-icon.emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.stat-info .stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.stat-info .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Main Content Panels */
.panel {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.panel.active {
  display: block;
}

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

/* Catalog Filter Bar */
.filter-bar {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.platform-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.platform-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.platform-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.platform-btn.active {
  background: var(--primary-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.filter-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.tab-group {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sub-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.sub-tab-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 420px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-sub);
}

.lang-select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

/* Batch Action Toolbar */
.batch-toolbar {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.batch-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.batch-checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.batch-checkbox-wrap input[type="checkbox"] {
  display: none;
}

.custom-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.batch-checkbox-wrap input[type="checkbox"]:checked + .custom-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

.batch-checkbox-wrap input[type="checkbox"]:checked + .custom-checkbox::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.batch-counter-badge {
  font-size: 0.825rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.batch-counter-badge strong {
  color: #38bdf8;
  font-weight: 700;
}

.btn-clear-selection {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-clear-selection:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-batch-sync {
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-batch-sync:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.8);
}

.btn-batch-sync:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

/* Movie Grid: ~10 columns layout */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1700px) {
  .movie-grid {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 1520px) {
  .movie-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 1320px) {
  .movie-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 1024px) {
  .movie-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }
}

@media (max-width: 768px) {
  .movie-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .movie-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
}

.movie-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: relative;
  user-select: none;
}

.movie-card.selected {
  border-color: #818cf8;
  background: rgba(99, 102, 241, 0.14);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5), 0 8px 18px rgba(0, 0, 0, 0.4);
}

.movie-card.is-synced {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.07);
}

.movie-card.is-synced::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #10b981, #059669);
  z-index: 5;
}

.synced-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.6);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 3px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.card-checkbox-label.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.movie-card.is-syncing {
  border-color: rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}

.movie-card.is-syncing::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  z-index: 5;
  animation: pulse-border 1.5s infinite alternate;
}

@keyframes pulse-border {
  from { opacity: 0.6; }
  to { opacity: 1; filter: drop-shadow(0 0 4px #f59e0b); }
}

.syncing-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.6);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 3px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.card-custom-check.is-syncing-check {
  background: #d97706;
  border-color: #fbbf24;
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
}

.spin-icon {
  display: inline-block;
  animation: spin 1.2s linear infinite;
}

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

.movie-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-highlight);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* Movie Checkbox overlay on poster */
.card-checkbox-label {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 10;
  cursor: pointer;
  padding: 2px;
}

.card-checkbox-label input[type="checkbox"] {
  display: none;
}

.card-custom-check {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.card-checkbox-label:hover .card-custom-check {
  border-color: #fff;
  background: rgba(0, 0, 0, 0.85);
}

.card-checkbox-label input[type="checkbox"]:checked + .card-custom-check {
  background: var(--primary);
  border-color: #fff;
  box-shadow: 0 0 8px var(--primary-glow);
}

.card-checkbox-label input[type="checkbox"]:checked + .card-custom-check::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.movie-poster-wrap {
  width: 100%;
  aspect-ratio: 3 / 4.1;
  position: relative;
  overflow: hidden;
  background: #111;
}

.movie-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.movie-card:hover .movie-poster {
  transform: scale(1.05);
}

.episodes-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 2;
  pointer-events: none;
}

.platform-badge {
  position: absolute;
  top: 32px;
  left: 6px;
  background: var(--primary-gradient);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 2;
  pointer-events: none;
}

.poster-meta-ribbon {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 5px 3px 5px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.5) 60%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  z-index: 2;
  pointer-events: none;
}

.views-badge {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  color: #38bdf8;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heat-badge {
  background: rgba(244, 63, 94, 0.25);
  backdrop-filter: blur(4px);
  color: #fb7185;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid rgba(244, 63, 94, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movie-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.movie-title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-main);
  min-height: 2em;
}

.movie-tags {
  display: none; /* Hide tags in high-density compact 10-movie grid */
}

.movie-actions {
  margin-top: auto;
  display: flex;
  gap: 4px;
}

.btn-detail {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 4px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.btn-detail:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn-sync {
  flex: 1.3;
  background: var(--primary-gradient);
  border: none;
  color: #fff;
  padding: 4px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: var(--transition);
}

.btn-sync:hover {
  filter: brightness(1.15);
  box-shadow: 0 4px 14px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-sync:disabled {
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-sync.btn-synced {
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #34d399;
  font-weight: 700;
}

.btn-sync.btn-syncing {
  background: rgba(245, 158, 11, 0.22);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fbbf24;
  font-weight: 700;
}

/* Tasks Monitor Table */
.monitor-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--glass-shadow);
}

.monitor-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.monitor-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.task-list {
  display: flex;
  flex-direction: column;
}

.task-item {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
  transition: var(--transition);
}

.task-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.task-thumb {
  width: 48px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #222;
}

.task-info {
  flex: 1;
}

.task-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.task-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
}

.task-progress-box {
  flex: 1.5;
  max-width: 360px;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-desc {
  font-size: 0.72rem;
  color: var(--cyan-accent);
  display: flex;
  justify-content: space-between;
  font-weight: 600;
}

.status-badge {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.status-badge.SCHEDULED { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.4); }
.status-badge.QUEUED { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.status-badge.FETCHING_INFO, .status-badge.CREATING_DRIVE_FOLDER { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.status-badge.DOWNLOADING, .status-badge.DOWNLOADING_EPISODE { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.status-badge.DOWNLOADED { background: rgba(168, 85, 247, 0.2); color: #c084fc; }
.status-badge.UPLOADING_DRIVE, .status-badge.UPLOADING_EPISODE { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.status-badge.COMPLETED { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-badge.FAILED { background: rgba(244, 63, 94, 0.2); color: #fb7185; }

/* Compact Tasks Monitor Table */
.compact-task-table th, 
.compact-task-table td {
  padding: 8px 12px;
  vertical-align: middle;
}

.compact-task-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.15s ease;
}

.compact-task-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.compact-task-thumb {
  width: 34px;
  height: 46px;
  border-radius: 4px;
  object-fit: cover;
  background: #1a1a24;
  display: block;
  margin: 0 auto;
}

.phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.phase-badge.dl-done {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.phase-badge.dl-active {
  background: rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
  border: 1px solid #818cf8;
  animation: pulse-border 1.5s infinite alternate;
}

.phase-badge.sync-done {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.phase-badge.sync-active {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid #f59e0b;
  animation: pulse-border 1.5s infinite alternate;
}

.phase-badge.phase-waiting {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-mini-action {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: var(--transition);
  text-decoration: none;
}

.btn-mini-action:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-mini-action.btn-retry-dl:hover {
  background: rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  border-color: #818cf8;
}

.btn-mini-action.btn-retry-sync:hover {
  background: rgba(16, 185, 129, 0.3);
  color: #34d399;
  border-color: #10b981;
}

.btn-mini-action.btn-delete:hover {
  background: rgba(244, 63, 94, 0.3);
  color: #fb7185;
  border-color: #f43f5e;
}

/* Compact Timeline Box */
.task-time-box {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 125px;
  white-space: nowrap !important;
}

.task-time-row {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap !important;
}

.task-time-label {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: 42px;
  min-width: 42px;
  flex-shrink: 0;
  white-space: nowrap !important;
}

.task-time-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: #cbd5e1;
  white-space: nowrap !important;
  display: inline-block;
  flex-shrink: 0;
  line-height: 1.2;
}

.task-time-val.active {
  color: #38bdf8;
  font-weight: 700;
}

.task-time-val.done {
  color: #34d399;
  font-weight: 700;
}

.task-time-val.waiting {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Compact Task Table specific padding & fixed layout to eliminate horizontal scroll */
.compact-task-table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
}

#panel-tasks .data-table-wrap {
  overflow-x: hidden !important;
}

.compact-task-table th,
.compact-task-table td {
  padding: 8px 6px;
  box-sizing: border-box;
}

.compact-task-table th {
  padding: 10px 6px;
  font-size: 0.78rem;
}

.compact-task-table .btn-mini-action {
  padding: 3px 6px;
  font-size: 0.68rem;
  white-space: nowrap;
}

/* Synced Library Table */
.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 14px 20px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.code-badge {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  color: var(--cyan-accent);
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 760px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}

/* Chi Tiết Phim trong Modal */
.drama-detail-header-wrap {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.drama-detail-cover {
  width: 140px;
  min-width: 140px;
  max-width: 140px;
  height: 196px;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--bg-tertiary);
  flex-shrink: 0;
  display: block;
}

.drama-detail-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Tablet Responsive */
@media (max-width: 1024px) {
  .stats-ribbon {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
  .navbar {
    padding: 14px 20px;
  }
  .settings-grid-2col {
    grid-template-columns: 1fr;
  }
}

/* Auto-Sync Toggle Switch */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.3s;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.slider-toggle:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider-toggle {
  background: var(--primary-gradient);
  border-color: #818cf8;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

input:checked + .slider-toggle:before {
  transform: translateX(22px);
}

/* Auto-Sync Selectable Chips */
.auto-sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.auto-sync-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.auto-sync-chip input[type="checkbox"] {
  accent-color: #6366f1;
  cursor: pointer;
}

.auto-sync-chip:has(input:checked) {
  background: rgba(99, 102, 241, 0.2);
  border-color: #818cf8;
  color: #c7d2fe;
}

/* Mini action buttons for task & library table */
.btn-mini-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-mini-action:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateY(-1px);
}

.btn-mini-action.btn-delete {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.35);
  color: #fb7185;
}

.btn-mini-action.btn-delete:hover {
  background: rgba(244, 63, 94, 0.25);
  border-color: #f43f5e;
  color: #fff;
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.35);
}

.btn-mini-action.btn-retry-dl {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
}

.btn-mini-action.btn-retry-dl:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #fff;
}

.btn-mini-action.btn-retry-sync {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.35);
  color: #34d399;
}

.btn-mini-action.btn-retry-sync:hover {
  background: rgba(52, 211, 153, 0.25);
  border-color: #34d399;
  color: #fff;
}

/* Local storage badge and button in task table */
.badge-local-storage {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  border: 1px solid transparent;
}

.badge-local-storage.warning {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.badge-local-storage.info {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.35);
  color: #93c5fd;
}

.badge-local-storage.clean {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.btn-mini-action.btn-clean-local {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 4px;
}

.btn-mini-action.btn-clean-local:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

#task-search-input:focus {
  outline: none;
}

/* Task Filter & Search Bar Base */
.task-filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.65);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: var(--transition);
}

.task-search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 340px;
}

.task-search-wrap input {
  width: 100%;
  padding: 7px 32px 7px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  outline: none;
  transition: var(--transition);
}

.task-search-wrap input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
  background: rgba(255, 255, 255, 0.08) !important;
}

.task-search-wrap button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
}

.task-filter-selects-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-field {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-field label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.task-filter-count-wrap {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.task-filter-count-wrap span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.mobile-table-hint {
  display: none;
  font-size: 0.74rem;
  font-weight: 600;
  color: #38bdf8;
  padding: 7px 12px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px dashed rgba(6, 182, 212, 0.35);
  border-radius: 8px;
  margin-bottom: 10px;
  text-align: center;
  user-select: none;
  animation: pulse-border 2s infinite alternate;
}

/* Settings Form Components */
.auto-sync-status-grid {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.settings-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}

.settings-subgrid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.settings-subgrid-full {
  grid-column: span 2;
}

.settings-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}


/* Pagination Styling */
.pagination-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  user-select: none;
}

.pagination-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.pagination-btn.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-ellipsis {
  color: var(--text-muted);
  padding: 0 4px;
  font-size: 0.75rem;
  user-select: none;
}

/* ========================================================
   COMPACT TASK TABLE - ZERO HORIZONTAL SCROLL & PERFECT FIT
   ======================================================== */
/* ========================================================
   COMPACT TASK TABLE - ZERO HORIZONTAL SCROLL & PERFECT FIT
   ======================================================== */
#panel-tasks .data-table-wrap {
  width: 100% !important;
  box-sizing: border-box !important;
}

@media (min-width: 1025px) {
  #panel-tasks .data-table-wrap {
    overflow-x: hidden !important;
  }
}

@media (max-width: 1024px) {
  #panel-tasks .data-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
}


table.compact-task-table {
  table-layout: fixed !important;
  width: 100% !important;
  max-width: 100% !important;
  border-collapse: collapse !important;
}

table.compact-task-table th,
table.compact-task-table td {
  padding: 10px 8px !important;
  box-sizing: border-box !important;
  vertical-align: middle !important;
  overflow: hidden !important;
}

table.compact-task-table th {
  padding: 11px 8px !important;
  font-size: 0.76rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em;
}

/* Đệm lề trái và phải bảng để không bị dính sát mép ngoài */
table.compact-task-table th:first-child,
table.compact-task-table td:first-child {
  padding-left: 14px !important;
}

table.compact-task-table th:last-child,
table.compact-task-table td:last-child {
  padding-right: 16px !important;
}

/* Timeline Box: Chỉ hiển thị Tải & Sync trên 1 dòng duy nhất */
.task-time-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-time-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: nowrap !important;
}

.task-time-label {
  color: var(--text-muted);
  font-weight: 500;
  min-width: 44px;
  white-space: nowrap !important;
  user-select: none;
}

.task-time-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap !important;
  letter-spacing: -0.01em;
}

.task-time-val.done {
  color: #34d399;
}

.task-time-val.active {
  color: #60a5fa;
  animation: pulse-border 1.5s infinite alternate;
}

.task-time-val.waiting {
  color: rgba(255, 255, 255, 0.35);
}

table.compact-task-table .btn-mini-action {
  padding: 3px 7px !important;
  font-size: 0.68rem !important;
  white-space: nowrap !important;
  border-radius: 4px;
}

/* ========================================================
   AUTHENTICATION GLASSMORPHISM OVERLAY & CARD
   ======================================================== */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 7, 15, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease-out;
}

.auth-modal-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7), 0 0 40px rgba(99, 102, 241, 0.2);
  box-sizing: border-box;
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-modal-header {
  text-align: center;
}

.auth-logo-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 12px;
}

.auth-logo-icon svg {
  width: 28px;
  height: 28px;
}

@keyframes scaleUp {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========================================================
   COMPREHENSIVE MOBILE OPTIMIZATIONS (< 768px and < 480px)
   ======================================================== */

@media (max-width: 768px) {
  /* Layout & Container */
  .app-container {
    padding: 8px 10px 24px !important;
  }

  /* Header & Navbar on Mobile */
  .navbar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 14px !important;
    gap: 8px 10px !important;
    top: 6px !important;
    margin-bottom: 12px !important;
    border-radius: 14px !important;
  }

  .brand {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: auto !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    order: 1 !important;
  }

  .brand-icon {
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
    flex-shrink: 0 !important;
  }

  .brand-icon svg {
    width: 20px !important;
    height: 20px !important;
  }

  .brand-info {
    min-width: 0 !important;
  }

  .brand-info h1 {
    font-size: 1.12rem !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
  }

  .brand-info .tagline {
    display: none !important; /* Hide tagline to maintain compact mobile app bar */
  }

  /* Mini Speed Pill on Mobile (Đặt ở vị trí tô đỏ cạnh Brand hàng 1) */
  .nav-speed-mini {
    display: inline-flex !important;
    align-items: center !important;
    margin-left: auto !important;
    margin-right: 0 !important;
    order: 2 !important;
    flex-shrink: 0 !important;
    padding: 3px 8px !important;
    font-size: 0.68rem !important;
    border-radius: 9999px !important;
    background: rgba(15, 23, 42, 0.85) !important;
    border: 1px solid rgba(56, 189, 248, 0.35) !important;
    height: 24px !important;
    box-sizing: border-box !important;
  }

  /* Smooth scrollable horizontal nav tabs (Hàng thứ 2, chiếm 100% width) */
  .nav-tabs {
    display: flex !important;
    width: 100% !important;
    order: 3 !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding: 4px 6px !important;
    gap: 6px !important;
    border-radius: 10px !important;
    justify-content: flex-start !important;
    background: rgba(0, 0, 0, 0.45) !important;
  }

  .nav-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .nav-btn {
    padding: 7px 12px !important;
    font-size: 0.78rem !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    border-radius: 8px !important;
    gap: 5px !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  .nav-btn svg {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0 !important;
  }

  /* Compact Stats Ribbon: 2x2 grid instead of 4 giant rows */
  .stats-ribbon {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
  }

  .stat-card {
    padding: 10px 12px !important;
    gap: 10px !important;
    border-radius: 10px !important;
  }

  .stat-icon {
    width: 36px !important;
    height: 36px !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
  }

  .stat-icon svg {
    width: 18px !important;
    height: 18px !important;
  }

  .stat-info .stat-value {
    font-size: 1.15rem !important;
    line-height: 1.2 !important;
  }

  .stat-info .stat-label {
    font-size: 0.68rem !important;
    line-height: 1.25 !important;
  }

  /* Catalog Filter & Controls */
  .filter-bar {
    padding: 12px 14px !important;
    gap: 12px !important;
    border-radius: 12px !important;
    margin-bottom: 14px !important;
  }

  .platform-selector {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    padding-bottom: 3px !important;
    align-items: center !important;
  }

  .platform-selector::-webkit-scrollbar {
    display: none !important;
  }

  .platform-selector > span {
    font-size: 0.75rem !important;
    flex-shrink: 0 !important;
  }

  .platform-btn {
    padding: 6px 12px !important;
    font-size: 0.78rem !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }

  .filter-controls {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .tab-group {
    width: 100% !important;
    display: flex !important;
  }

  .sub-tab-btn {
    flex: 1 !important;
    text-align: center !important;
    padding: 7px 8px !important;
    font-size: 0.78rem !important;
  }

  .search-box {
    max-width: 100% !important;
    width: 100% !important;
    padding: 8px 14px !important;
  }

  .lang-select {
    width: 100% !important;
  }

  /* Batch Toolbar */
  .batch-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 10px 12px !important;
  }

  .batch-left {
    justify-content: space-between !important;
    width: 100% !important;
    flex-wrap: wrap !important;
  }

  .batch-right {
    width: 100% !important;
  }

  .btn-batch-sync {
    width: 100% !important;
    justify-content: center !important;
    padding: 10px !important;
    font-size: 0.85rem !important;
  }

  /* Movie Cards in Grid */
  .movie-card .movie-body {
    padding: 6px 8px !important;
  }

  .movie-card .movie-title {
    font-size: 0.74rem !important;
    line-height: 1.25 !important;
    min-height: 2.5em !important;
  }

  .movie-card .movie-actions {
    gap: 4px !important;
  }

  .movie-card .btn-detail,
  .movie-card .btn-sync {
    padding: 6px 4px !important;
    font-size: 0.68rem !important;
    min-height: 32px !important;
  }

  /* Tasks Monitor Header & Filters */
  .monitor-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 14px !important;
  }

  .monitor-header h3 {
    font-size: 1.05rem !important;
  }

  .monitor-header > div:last-child {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 8px !important;
  }

  #server-storage-widget {
    width: 100% !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
  }

  .task-filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 10px 12px !important;
  }

  .task-search-wrap {
    min-width: 100% !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .task-filter-selects-row {
    display: flex !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .task-filter-selects-row .filter-field {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .task-filter-selects-row .lang-select {
    width: 100% !important;
    font-size: 0.74rem !important;
    padding: 6px 8px !important;
  }

  .task-filter-count-wrap {
    margin-left: 0 !important;
    justify-content: flex-end !important;
  }

  /* Table Mobile Scroll Hint & Safe Width */
  .mobile-table-hint {
    display: block !important;
  }

  #panel-tasks .data-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    box-sizing: border-box !important;
    scrollbar-width: thin !important;
  }

  #panel-tasks .data-table-wrap::-webkit-scrollbar {
    height: 5px !important;
  }

  #panel-tasks .data-table-wrap::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.45) !important;
    border-radius: 4px !important;
  }

  table.compact-task-table {
    min-width: 820px !important;
    width: 820px !important;
  }

  /* Task pagination */
  #tasks-pagination-bar {
    flex-direction: column !important;
    gap: 10px !important;
    text-align: center !important;
    padding: 10px !important;
  }

  #tasks-pagination-controls {
    justify-content: center !important;
    flex-wrap: wrap !important;
  }

  /* Library Panel */
  #panel-library .monitor-header > div:last-child {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    width: 100% !important;
  }

  #panel-library .data-table {
    min-width: 720px !important;
  }

  /* Settings Panel */
  .auto-sync-status-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    padding: 12px 14px !important;
  }

  .settings-grid-2col {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .settings-subgrid-2col {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .settings-subgrid-full {
    grid-column: span 1 !important;
  }

  .settings-footer-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .settings-footer-row > div:last-child {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .settings-footer-row button {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 10px !important;
  }

  /* Detail Modal on Mobile */
  .modal-overlay {
    padding: 10px !important;
  }

  .modal-box {
    max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 14px !important;
  }

  .modal-header {
    padding: 14px 16px !important;
  }

  .modal-header h3 {
    font-size: 1.05rem !important;
  }

  .modal-body {
    padding: 14px !important;
  }

  .drama-detail-header-wrap {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 14px !important;
  }

  .drama-detail-cover {
    width: 120px !important;
    height: 165px !important;
  }

  .drama-detail-info h2 {
    font-size: 1.15rem !important;
  }

  .drama-detail-info div {
    justify-content: center !important;
  }

  .modal-footer {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px 14px !important;
  }

  .modal-footer button,
  .modal-footer a {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 10px !important;
  }

  /* Auth Modal on Mobile */
  .auth-overlay {
    padding: 12px !important;
  }

  .auth-modal-card {
    padding: 24px 18px !important;
    border-radius: 14px !important;
  }
}

@media (max-width: 480px) {
  .movie-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  .nav-btn {
    padding: 6px 10px !important;
    font-size: 0.74rem !important;
  }

  .stat-card {
    padding: 8px 10px !important;
    gap: 8px !important;
  }

  .stat-icon {
    width: 32px !important;
    height: 32px !important;
  }

  .stat-info .stat-value {
    font-size: 1.05rem !important;
  }
}

/* ========================================================
   QUEUE RANK BADGES & HOT SYNC BUTTONS
   ======================================================== */
.queue-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.queue-badge.running {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.25), rgba(14, 165, 233, 0.35));
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.5);
  animation: pulseQueue 1.8s infinite ease-in-out;
}

.queue-badge.hot {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(249, 115, 22, 0.35));
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.6);
  box-shadow: 0 0 8px rgba(249, 115, 22, 0.3);
}

.queue-badge.waiting {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.queue-badge.scheduled {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
}

.queue-badge.done {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.queue-badge.failed {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.queue-badge.default {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

@keyframes pulseQueue {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 0 10px 2px rgba(56, 189, 248, 0.5);
  }
}

.btn-mini-action.btn-prioritize {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(249, 115, 22, 0.3));
  border: 1px solid rgba(249, 115, 22, 0.5);
  color: #fb923c;
  font-weight: 700;
}

.btn-mini-action.btn-prioritize:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.4), rgba(249, 115, 22, 0.5));
  color: #fff;
  border-color: #f97316;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
}

.btn-sync.btn-hot-sync {
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: #fff;
  border: none;
  font-weight: 700;
  margin-left: 4px;
}

.btn-sync.btn-hot-sync:hover {
  background: linear-gradient(135deg, #dc2626, #ea580c);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
}








