/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: #f0f2f5;
  color: #1e293b;
  height: 100vh;
  overflow: hidden;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: 230px;
  min-width: 230px;
  background: linear-gradient(180deg, #0f172a 0%, #1a1f36 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  z-index: 200;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.logo-icon { font-size: 22px; line-height: 1; }
.logo-text {
  font-weight: 700;
  font-size: 1rem;
  color: #f1f5f9;
  letter-spacing: -0.01em;
}
.logo-version {
  font-size: 0.65rem;
  color: #475569;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-list {
  list-style: none;
  padding: 8px 0;
  flex: 1;
  overflow-y: auto;
}
.nav-list::-webkit-scrollbar { width: 0; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
}
.nav-link:hover {
  color: #e2e8f0;
  background: rgba(255,255,255,0.06);
}
.nav-link.active {
  color: #60a5fa;
  background: rgba(96,165,250,0.1);
  border-left-color: #3b82f6;
}
.nav-link svg { flex-shrink: 0; opacity: 0.8; }
.nav-link.active svg { opacity: 1; }

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 10px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin-top: auto;
}
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 500;
  min-width: 0;
}
.sidebar-user-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 5px 6px;
  cursor: pointer;
  color: #64748b;
  line-height: 0;
  flex-shrink: 0;
  transition: all 0.15s;
}
.btn-logout:hover {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.4);
  color: #f87171;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px 14px;
  border-top: 1px solid rgba(255,255,255,0.05);
  font-size: 0.78rem;
  color: #475569;
}
.sidebar-footer-text { font-size: 0.78rem; }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
  transition: all 0.3s;
}
.status-online {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.25);
  animation: pulse-green 2s infinite;
}
.status-offline { background: #ef4444; }

@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  70%  { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ─── Mobile sidebar backdrop ─────────────────────────────────────────────── */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  backdrop-filter: blur(1px);
}

/* ─── Topbar (mobile only) ────────────────────────────────────────────────── */
#topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 54px;
  background: #0f172a;
  color: #f1f5f9;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-logo {
  font-weight: 700;
  font-size: 0.95rem;
  flex: 1;
}
.btn-hamburger {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: #94a3b8;
  padding: 6px 8px;
  cursor: pointer;
  line-height: 0;
}
.btn-hamburger:hover { background: rgba(255,255,255,0.08); color: #f1f5f9; }

/* ─── Main Content ────────────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
#page-container {
  padding: 28px 32px;
  max-width: 1440px;
  width: 100%;
  flex: 1;
}

/* ─── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 3px;
}

/* ─── Stat Cards ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: #f1f5f9;
  color: #64748b;
  flex-shrink: 0;
}
.stat-label {
  font-size: 0.76rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1;
}
.stat-card.accent-blue  .stat-icon { background: #eff6ff; color: #3b82f6; }
.stat-card.accent-blue  .stat-value { color: #2563eb; }
.stat-card.accent-green .stat-icon { background: #f0fdf4; color: #22c55e; }
.stat-card.accent-green .stat-value { color: #16a34a; }
.stat-card.accent-red   .stat-icon { background: #fef2f2; color: #ef4444; }
.stat-card.accent-red   .stat-value { color: #dc2626; }
.stat-card.accent-orange .stat-icon { background: #fff7ed; color: #f97316; }
.stat-card.accent-orange .stat-value { color: #ea580c; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e8ecf0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
  gap: 8px;
  background: #fafbfc;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
}
.card-subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
}
.card-hint {
  font-size: 0.78rem;
  color: #94a3b8;
}
.card-body { padding: 0; }

/* ─── Table ───────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead th {
  background: #f8fafc;
  padding: 10px 20px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
td {
  padding: 12px 20px;
  color: #374151;
  vertical-align: middle;
}
.td-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: nowrap;
}
.td-empty {
  text-align: center;
  color: #94a3b8;
  padding: 20px;
  font-size: 0.875rem;
}
.row-live { background: #f0fdf4 !important; }

/* ─── Cell helpers ────────────────────────────────────────────────────────── */
.cell-stack { display: flex; flex-direction: column; gap: 2px; }
.stream-url {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: #2563eb;
  word-break: break-all;
  text-decoration: none;
}
.stream-url:hover { text-decoration: underline; }
.clients-active { color: #16a34a; font-weight: 700; }
.error-text { color: #dc2626; font-size: 0.82rem; }
.expired-date { color: #dc2626; font-family: 'Courier New', monospace; font-size: 0.82rem; }
.url-text { font-size: 0.8rem; color: #2563eb; word-break: break-all; }
.pw-badge {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: 'Courier New', monospace;
}

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.live-badge   { font-size: 0.68rem; letter-spacing: 0.02em; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.btn-primary   { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover:not(:disabled)   { background: #1d4ed8; border-color: #1d4ed8; }
.btn-secondary { background: #f8fafc; color: #374151; border-color: #e2e8f0; }
.btn-secondary:hover:not(:disabled) { background: #f1f5f9; border-color: #d1d5db; }
.btn-success   { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover:not(:disabled)   { background: #15803d; border-color: #15803d; }
.btn-danger    { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover:not(:disabled)    { background: #b91c1c; border-color: #b91c1c; }
.btn-warning   { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover:not(:disabled)   { background: #b45309; border-color: #b45309; }

.btn-sm { padding: 4px 10px; font-size: 0.78rem; border-radius: 5px; gap: 4px; }
.btn-icon-label { min-width: 28px; }

.gap-8 { gap: 8px; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}
.req { color: #dc2626; }
.form-hint { font-size: 0.75rem; color: #64748b; margin-top: 5px; line-height: 1.4; }

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 7px;
  font-size: 0.875rem;
  color: #1e293b;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
}
.form-control:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-control:hover:not(:focus) { border-color: #9ca3af; }
select.form-control { cursor: pointer; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
}
.form-check {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 0.875rem;
  color: #374151;
  font-weight: 500;
}
.form-check input[type="checkbox"] {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: #2563eb;
  border-radius: 4px;
}

.input-with-btn {
  display: flex;
  gap: 8px;
}
.input-with-btn .form-control { flex: 1; }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05);
}
.modal-lg { max-width: 640px; }
.modal-xl { max-width: 860px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #f1f5f9;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; color: #0f172a; }
.modal-close {
  background: #f1f5f9; border: none;
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 1.1rem; cursor: pointer;
  color: #64748b; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { background: #e2e8f0; color: #1e293b; }
.modal-body { padding: 20px 24px 24px; }

.confirm-body { text-align: center; }
.confirm-message {
  font-size: 0.95rem;
  color: #374151;
  margin-bottom: 24px;
  line-height: 1.5;
}
.confirm-body .form-actions { justify-content: center; border-top: none; padding-top: 0; }

/* ─── Toast ───────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  max-width: 400px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
  transform: translateX(110%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
  opacity: 0;
  pointer-events: all;
}
.toast-visible { transform: translateX(0); opacity: 1; }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-msg { line-height: 1.4; }

.toast-success { background: #f0fdf4; color: #15803d; border-left: 4px solid #22c55e; }
.toast-error   { background: #fef2f2; color: #dc2626; border-left: 4px solid #ef4444; }
.toast-info    { background: #eff6ff; color: #1d4ed8; border-left: 4px solid #3b82f6; }
.toast-warning { background: #fffbeb; color: #92400e; border-left: 4px solid #f59e0b; }

/* ─── Loading ─────────────────────────────────────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px 20px; color: #94a3b8; font-size: 0.9rem; gap: 12px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty ───────────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 60px 24px;
  color: #94a3b8;
}
.empty-icon { font-size: 3rem; margin-bottom: 14px; }
.empty h3 { font-size: 1rem; font-weight: 600; color: #64748b; margin-bottom: 6px; }
.empty p { font-size: 0.875rem; line-height: 1.5; }

/* ─── Filter Row ──────────────────────────────────────────────────────────── */
.filter-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid #f1f5f9;
  background: #fafbfc;
}
.filter-row .form-control { max-width: 240px; }
.filter-row select.form-control { max-width: 180px; }

/* ─── Config page ─────────────────────────────────────────────────────────── */
.modal-body { padding: 20px 24px 24px; }
.modal-body .form-actions {
  margin-top: 6px;
  padding-top: 14px;
}

/* ─── Scan results ────────────────────────────────────────────────────────── */
.scan-result-header {
  margin: 12px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.875rem;
  margin-top: 12px;
}

/* ─── Password strength ───────────────────────────────────────────────────── */
.pw-strength { margin-top: 5px; font-size: 0.78rem; font-weight: 500; }
.pw-strength.very-weak { color: #dc2626; }
.pw-strength.weak      { color: #f97316; }
.pw-strength.ok        { color: #ca8a04; }
.pw-strength.strong    { color: #16a34a; }

/* ─── EPG ─────────────────────────────────────────────────────────────────── */
.epg-info {
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.7;
}
.epg-info ol {
  margin: 10px 0 10px 20px;
}
.info-box {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 0.85rem;
  color: #0369a1;
}
.epg-channel-block { margin-bottom: 24px; }
.epg-channel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  padding: 8px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.progress-bar {
  background: #e2e8f0;
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 3px;
}
.progress-fill {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  height: 100%;
  transition: width 1s;
  border-radius: 4px;
}
.progress-label { font-size: 0.72rem; color: #64748b; }

/* ─── Misc ────────────────────────────────────────────────────────────────── */
.text-muted { color: #94a3b8; font-size: 0.8rem; }
.text-mono  { font-family: 'Courier New', monospace; font-size: 0.82rem; }
.truncate   {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  display: block;
}
.flex-center { display: flex; align-items: center; gap: 8px; }
.ml-auto { margin-left: auto; }

/* ─── Login Page ──────────────────────────────────────────────────────────── */
.login-page {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1a1f36 45%, #1e293b 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  min-height: 100vh;
}

.login-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.06);
  padding: 44px 40px 40px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-logo-icon { font-size: 30px; }
.login-logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.03em;
}

.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.login-subtitle {
  font-size: 0.85rem;
  color: #64748b;
  text-align: center;
  margin-bottom: 28px;
}

.login-form { display: flex; flex-direction: column; gap: 0; }
.login-form .form-group { margin-bottom: 16px; }

.login-input {
  width: 100%;
  height: 46px;
  font-size: 0.95rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  padding: 0 14px;
  color: #0f172a;
  background: #f8fafc;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  outline: none;
}
.login-input:hover { border-color: #cbd5e1; }
.login-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  background: #fff;
}

.login-pw-wrapper { position: relative; }
.login-pw-wrapper .login-input { padding-right: 46px; }
.login-pw-toggle {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; color: #94a3b8;
  padding: 5px; line-height: 0;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
}
.login-pw-toggle:hover { color: #475569; background: #f1f5f9; }

.login-btn {
  height: 46px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 9px;
  margin-top: 6px;
  width: 100%;
}

.login-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.login-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.login-footer {
  color: rgba(255,255,255,0.25);
  font-size: 0.78rem;
  margin-top: 28px;
  text-align: center;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body { overflow: auto; height: auto; }

  #app { height: auto; min-height: 100vh; flex-direction: column; }

  #topbar { display: flex; }

  #sidebar {
    position: fixed;
    left: -230px;
    top: 0;
    height: 100vh;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
  }
  #sidebar.sidebar-open { left: 0; }

  #sidebar-backdrop { display: block; }

  #main-content {
    height: auto;
    overflow: visible;
    flex: 1;
  }

  #page-container { padding: 16px; }

  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-row .form-control { max-width: none; flex: 1; min-width: 120px; }
  .modal { max-width: 100%; }
  .td-actions { flex-wrap: wrap; }
  #toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: auto; max-width: none; }
  .page-title { font-size: 1.3rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px 28px; margin: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ─── Channel Creation Wizard ─────────────────────────────────────────────── */
.wizard-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.wizard-step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.45;
  transition: opacity 0.2s;
}
.wizard-step-item.active { opacity: 1; }
.wizard-step-item.done   { opacity: 0.75; }
.wizard-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}
.wizard-step-item.active .wizard-step-num {
  background: var(--accent);
  color: #fff;
}
.wizard-step-item.done .wizard-step-num {
  background: #22c55e;
  color: #fff;
  font-size: 0.72rem;
}
.wizard-step-name { font-size: 0.85rem; font-weight: 500; }
.wizard-step-arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0 2px;
}

/* Directory picker row */
.dir-picker-row {
  display: flex;
  gap: 8px;
}
.dir-picker-row .form-control {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 0.83rem;
  cursor: default;
}

/* Inline directory browser */
.dir-browser {
  display: none;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.dir-browser.dir-browser-open { display: block; }

.dir-browser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: #1e293b;
  border-bottom: 1px solid var(--border);
}
.dir-browser-path-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.dir-browser-current {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}
.dir-browser-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.dir-browser-list {
  max-height: 220px;
  overflow-y: auto;
}
.dir-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
}
.dir-item:hover { background: rgba(59,130,246,0.08); }
.dir-item-name { font-weight: 500; font-size: 0.87rem; }
.dir-item-path {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dir-item-arrow { margin-left: auto; flex-shrink: 0; }

.browser-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  color: var(--text-muted);
  font-size: 0.87rem;
  font-style: italic;
}
.browser-error {
  padding: 14px 16px;
  color: #f87171;
  font-size: 0.85rem;
  background: rgba(239,68,68,0.08);
}

/* Wizard scanning state */
.wizard-scanning {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 40px 20px;
  justify-content: center;
  color: var(--text-muted);
}
.wizard-scanning strong { display: block; color: var(--text); margin-bottom: 4px; }
.wizard-scanning .text-muted { font-size: 0.85rem; margin: 2px 0; }

/* Step 2 scan summary */
.wizard-scan-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #1e293b;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.scan-summary-info { min-width: 0; }
.scan-path {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scan-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.scan-select-all {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Files table */
.wizard-files-table {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.wizard-files-table table {
  width: 100%;
  border-collapse: collapse;
}
.wizard-files-table thead th {
  position: sticky;
  top: 0;
  background: #1e293b;
  z-index: 1;
  padding: 9px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.wizard-files-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.1s;
}
.wizard-files-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.wizard-files-table tbody tr.file-row-inactive { opacity: 0.38; }
.wizard-files-table tbody td { padding: 8px 10px; vertical-align: middle; }

/* Poster thumbnails */
.file-poster {
  width: 40px;
  height: 58px;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}
.file-poster-ph {
  width: 40px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e293b;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* File info cell */
.file-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-tmdb-title {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-orig-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}
.file-filename {
  font-family: 'Courier New', monospace;
  font-size: 0.72rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-overview {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 3px;
}

/* Genre badges in table */
.genre-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.genre-tags .badge { font-size: 0.68rem; padding: 1px 5px; }

/* Active count in step 2 footer */
.wizard-active-count {
  align-self: center;
  font-size: 0.83rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.wizard-step2-actions {
  position: sticky;
  bottom: 0;
  margin: 0 -24px -24px;
  padding: 14px 24px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ─── Utilities ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
code {
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  color: #334155;
}
