/* =========================================================
   Nayen Music — App UI
   Reskinned with the NAYEN MUSIC aesthetic
   (dark, violet, glassmorphism, aurora background)
   ========================================================= */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Sora:wght@600;700;800&display=swap");
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css");

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

/* ---------- Design Tokens (dark / default) ---------- */
:root {
  --bg: #09090b;
  --bg-2: #0d0d11;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-solid: #121216;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --primary: #a855f7;
  --primary-hover: #7c3aed;
  --primary-dim: rgba(168, 85, 247, 0.14);
  --accent: #7c3aed;
  --accent-dim: rgba(124, 58, 237, 0.14);

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  --text: #ffffff;
  --text-muted: #a1a1aa;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --shadow: 0 20px 60px -22px rgba(0, 0, 0, 0.75);
  --shadow-glow: 0 0 50px -12px rgba(124, 58, 237, 0.55);
  --sidebar-w: 248px;
  --transition: 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --gradient: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  --grad-soft: linear-gradient(135deg, rgba(124, 58, 237, 0.20), rgba(168, 85, 247, 0.06));

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Sora", var(--font);
}

/* ---------- Light theme override ---------- */
[data-theme="light"] {
  --bg: #f6f5fb;
  --bg-2: #efeef7;
  --surface: #ffffff;
  --surface-2: #f3f1fb;
  --surface-solid: #ffffff;
  --border: #e7e3f3;
  --border-strong: #d6cdec;

  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-dim: rgba(124, 58, 237, 0.10);
  --accent: #a855f7;
  --accent-dim: rgba(168, 85, 247, 0.10);

  --text: #1a1626;
  --text-muted: #6b6880;

  --shadow: 0 12px 40px -16px rgba(76, 29, 149, 0.28);
  --shadow-glow: 0 0 40px -14px rgba(124, 58, 237, 0.35);
}

html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Aurora background layers ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(48% 38% at 12% 8%, rgba(124, 58, 237, 0.22), transparent 60%),
    radial-gradient(42% 42% at 88% 12%, rgba(168, 85, 247, 0.18), transparent 60%),
    radial-gradient(60% 50% at 50% 100%, rgba(124, 58, 237, 0.14), transparent 60%);
  filter: blur(8px);
  animation: auroraShift 20s ease-in-out infinite alternate;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 110% 70% at 50% 0%, #000 25%, transparent 80%);
}
[data-theme="light"] body::before {
  background:
    radial-gradient(48% 38% at 12% 8%, rgba(124, 58, 237, 0.12), transparent 60%),
    radial-gradient(42% 42% at 88% 12%, rgba(168, 85, 247, 0.10), transparent 60%),
    radial-gradient(60% 50% at 50% 100%, rgba(124, 58, 237, 0.08), transparent 60%);
}
[data-theme="light"] body::after {
  background-image:
    linear-gradient(rgba(26, 22, 38, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 22, 38, 0.03) 1px, transparent 1px);
}
@keyframes auroraShift {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0.9; }
  100% { transform: translate3d(0, -2%, 0) scale(1.06); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(124, 58, 237, 0.4); color: #fff; }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 90;
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 130;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  transition: left var(--transition), right var(--transition), background var(--transition), border-color var(--transition);
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(140%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
[data-theme="light"] .sidebar { background: var(--surface); }
.sidebar-logo {
  display: flex; align-items: center; gap: 11px;
  padding: 22px 20px 18px;
  font-family: var(--font-display);
  font-weight: 800; font-size: 15px; letter-spacing: -0.01em; color: #fff;
  border-bottom: 1px solid var(--border);
}

/* ── Brand mark (shared logo) ── */
.brand-mark {
  display: none;
  width: 34px; height: 34px;
  border-radius: 11px;
  background: var(--gradient);
  box-shadow: var(--shadow-glow);
  color: #fff;
  flex-shrink: 0;
}
.brand-mark svg { filter: none; }
.brand-mark i { font-size: 0.95rem; line-height: 1; }
.auth-logo .brand-mark i { font-size: 1.05rem; }
.brand-accent { color: var(--accent); margin-left: 2px; }
[data-theme="light"] .sidebar-logo .brand-accent { color: var(--accent); }

/* Keep logo text flat across all views: NAYEN white + MUSIC accent. */
.brand-text,
.sidebar-logo > span:not(.brand-mark) {
  color: #fff !important;
  background: none !important;
  -webkit-background-clip: border-box !important;
  background-clip: border-box !important;
  -webkit-text-fill-color: currentColor !important;
}

.brand-text .brand-accent,
.sidebar-logo > span:not(.brand-mark) .brand-accent {
  color: var(--accent) !important;
}
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13.5px; font-weight: 500;
  position: relative;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active {
  background: var(--grad-soft);
  color: #fff;
  border: 1px solid var(--border-strong);
}
[data-theme="light"] .nav-link.active { color: var(--primary); }
.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%;
  border-radius: 3px;
  background: var(--gradient);
  box-shadow: var(--shadow-glow);
}
.nav-section { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--text-muted); padding: 14px 12px 4px; }
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gradient); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: #fff; flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.btn-logout {
  background: none; border: none; padding: 4px; border-radius: var(--radius-sm);
  color: var(--text-muted); transition: color var(--transition);
  display: flex; align-items: center;
}
.btn-logout:hover { color: var(--danger); }

/* ── Main content ── */
.main { margin-left: var(--sidebar-w); flex: 1; padding: 32px 36px; min-width: 0; position: relative; z-index: 1; }
.page-header { margin-bottom: 28px; }
.page-title { font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 5px; }

/* ── Cards ── */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(14px);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin-bottom: 18px;
}
.card-header > div { min-width: 0; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex-shrink: 0; }
.card-title { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  backdrop-filter: blur(14px);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--grad-soft);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.stat-card:hover::before { opacity: 1; }
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  min-height: 22px;
  position: relative;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  margin-top: 0;
  padding-top: 2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  position: relative;
}
.stat-value-sm {
  margin-top: 0;
  padding-top: 2px;
  min-height: 34px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  position: relative;
}
.stat-value.green { color: var(--success); }
.stat-value.indigo {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.stat-meta { font-size: 12px; color: var(--text-muted); margin-top: 6px; position: relative; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-pill);
  font-size: 13.5px; font-weight: 600; border: 1px solid transparent;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 10px 28px -10px rgba(124, 58, 237, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 16px 38px -10px rgba(124, 58, 237, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); backdrop-filter: blur(12px); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--primary); transform: translateY(-2px); }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.32); }
.btn-danger:hover { background: rgba(239,68,68,.25); color: #fecaca; }
.btn-success { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.32); }
.btn-success:hover { background: rgba(34,197,94,.25); color: #bbf7d0; }
.btn-sm { padding: 6px 13px; font-size: 12px; }
.btn-xs { padding: 5px 11px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
[data-theme="light"] .btn-danger { color: var(--danger); }
[data-theme="light"] .btn-success { color: var(--success); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 7px; text-transform: uppercase; letter-spacing: .06em; }
.form-control {
  width: 100%; padding: 10px 13px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-dim); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control option { background: var(--surface-solid); color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { font-size: 12px; color: #fca5a5; margin-top: 4px; }
[data-theme="light"] .form-error { color: var(--danger); }
.form-warning {
  margin-top: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .12);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}
.notice-box {
  margin: 8px 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  line-height: 1.45;
}
.notice-box.notice-error {
  border-color: rgba(239, 68, 68, .35);
  background: rgba(239, 68, 68, .12);
  color: #fca5a5;
}
.notice-box.notice-warning {
  border-color: rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .12);
  color: var(--text);
}
[data-theme="light"] .notice-box.notice-error { color: #b91c1c; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }
.td-actions { display: flex; gap: 8px; align-items: center; }
.td-actions .btn {
  min-width: 122px;
  justify-content: center;
  white-space: nowrap;
}

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 600;
  border: 1px solid transparent;
}
.badge-green { background: rgba(34,197,94,.15); color: #86efac; border-color: rgba(34,197,94,.28); }
.badge-red { background: rgba(239,68,68,.15); color: #fca5a5; border-color: rgba(239,68,68,.28); }
.badge-yellow { background: rgba(245,158,11,.15); color: #fcd34d; border-color: rgba(245,158,11,.28); }
.badge-indigo { background: var(--primary-dim); color: var(--primary); border-color: var(--border-strong); }
.badge-gray { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
[data-theme="light"] .badge-green { color: #15803d; }
[data-theme="light"] .badge-red { color: #b91c1c; }
[data-theme="light"] .badge-yellow { color: #b45309; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5, 4, 10, .7);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity var(--transition);
  backdrop-filter: none;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 28px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
  transform: translateY(16px); transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 22px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ── Refresh timestamp ── */
.refresh-bar {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted); margin-bottom: 20px;
}
.refresh-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); animation: pulseDot 2s infinite; }
@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ── Date filter ── */
.filter-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.filter-btn {
  padding: 7px 15px; border-radius: var(--radius-pill); font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  backdrop-filter: blur(10px);
  transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--primary); color: var(--text); }
.filter-btn.active { background: var(--grad-soft); border-color: var(--border-strong); color: #fff; }
[data-theme="light"] .filter-btn.active { color: var(--primary); }
.filter-sep { color: var(--border-strong); }

/* ── Top video card ── */
.top-video {
  display: flex; gap: 14px; align-items: flex-start;
}
.top-video-thumb {
  width: 100px; height: 56px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--surface-2); flex-shrink: 0;
}
.top-video-info { flex: 1; min-width: 0; }
.top-video-title { font-size: 13.5px; font-weight: 600; color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.top-video-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Video list ── */
.video-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.video-item:last-child { border-bottom: none; }
.video-thumb { width: 72px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.video-info { flex: 1; min-width: 0; }
.video-title { font-size: 13px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.video-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ── Chart container ── */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { max-width: 100%; }
.drill-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  margin-top: 12px; display: none;
}
.drill-card.visible { display: block; }
.drill-row { display: flex; gap: 24px; flex-wrap: wrap; }
.drill-item label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; display: block; }
.drill-item span { font-size: 16px; font-weight: 700; color: var(--text); }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 13px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; background: var(--surface-solid);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 8px;
  backdrop-filter: none;
  animation: slideIn .25s var(--ease);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Login / auth page ── */
.auth-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 28px;
  background: var(--bg);
}
.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(50% 40% at 15% 12%, rgba(124, 58, 237, 0.28), transparent 60%),
    radial-gradient(45% 45% at 85% 18%, rgba(168, 85, 247, 0.22), transparent 60%),
    radial-gradient(60% 55% at 50% 100%, rgba(76, 29, 149, 0.22), transparent 62%);
  filter: blur(8px);
  animation: auroraShift 18s ease-in-out infinite alternate;
  pointer-events: none;
}
.auth-page::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 100% 80% at 50% 0%, #000 30%, transparent 80%);
  pointer-events: none;
}
[data-theme="light"] .auth-page::before {
  background:
    radial-gradient(50% 40% at 15% 12%, rgba(124, 58, 237, 0.16), transparent 60%),
    radial-gradient(45% 45% at 85% 18%, rgba(168, 85, 247, 0.12), transparent 60%),
    radial-gradient(60% 55% at 50% 100%, rgba(124, 58, 237, 0.10), transparent 62%);
}
[data-theme="light"] .auth-page::after {
  background-image:
    linear-gradient(rgba(26, 22, 38, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 22, 38, 0.04) 1px, transparent 1px);
}
.auth-card {
  position: relative;
  z-index: 1;
  isolation: isolate;
  width: 100%;
  max-width: 452px;
  padding: 40px 36px 30px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: linear-gradient(158deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow), var(--shadow-glow);
  backdrop-filter: blur(20px) saturate(140%);
}
[data-theme="light"] .auth-card {
  background: linear-gradient(158deg, rgba(255, 255, 255, 0.92), rgba(243, 241, 251, 0.88));
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 16px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.auth-logo .brand-mark { width: 40px; height: 40px; border-radius: 13px; }
.auth-logo .brand-text {
  color: #fff;
  -webkit-text-fill-color: #fff;
  background: none;
}
[data-theme="light"] .auth-logo .brand-text {
  color: #fff;
  -webkit-text-fill-color: #fff;
  background: none;
}
.auth-kicker {
  margin-bottom: 10px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
}
.auth-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 10px;
  color: var(--text);
}
.auth-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 26px;
  text-align: center;
}
.auth-footer {
  margin-top: 18px;
  margin-bottom: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.auth-footer a { color: var(--primary); }
.auth-footer a:hover { color: var(--primary-hover); }
.auth-theme .form-label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-theme .form-control {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.auth-theme .form-control::placeholder { color: var(--text-muted); }
.auth-theme .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-dim);
}
.auth-theme .btn-primary {
  background: var(--gradient);
  border: 1px solid transparent;
  min-height: 46px;
  font-size: 13.5px;
  letter-spacing: 0.02em;
}
.auth-theme .btn-primary:hover { background: linear-gradient(135deg, #6d28d9 0%, #9333ea 100%); }
.auth-theme .form-error { color: #fca5a5; }
[data-theme="light"] .auth-theme .form-error { color: #b91c1c; }
.auth-theme #toggle-password { color: var(--text-muted) !important; }

/* ── Video search results (admin) ── */
.search-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; max-width: 100%; overflow: hidden; }
.search-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
  backdrop-filter: blur(10px);
  transition: border-color var(--transition), transform var(--transition); position: relative;
}
.search-item:hover { border-color: var(--primary); transform: translateY(-3px); }
.search-item.selected { border-color: var(--primary); background: var(--primary-dim); }
.search-item.locked {
  border-color: var(--border);
  background: var(--surface-2);
  cursor: not-allowed;
}
.search-item.locked:hover { border-color: var(--border-strong); transform: none; }
.search-item.locked img { filter: grayscale(0.85) brightness(0.45); }
.search-item.locked .search-item-title,
.search-item.locked .search-item-views { color: var(--text-muted); }
.search-item img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.search-item-info { padding: 11px; }
.search-item-title { font-size: 12.5px; font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-item-views { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.search-item-open {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 26px; height: 26px; background: rgba(0,0,0,0.65); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; opacity: 0; transition: opacity var(--transition); text-decoration: none;
}
.search-item:hover .search-item-open { opacity: 1; }
.load-more-row {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}
.search-item-lock {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  border-radius: 14px;
  padding: 8px 12px;
  min-width: 98px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #f8fafc;
  background: rgba(9, 9, 11, 0.86);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-family: var(--font);
}
.search-item-lock-icon {
  font-size: 17px;
  line-height: 1;
}
.search-item-lock-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.selection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.selection-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.selection-item-meta img {
  width: 56px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
.selection-item-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.selection-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

#selection-items {
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

#selection-bar .btn-xs {
  min-width: 62px;
}

/* ── RPM history ── */
.rpm-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.rpm-row:last-child { border-bottom: none; }

/* ── Separator ── */
.section-gap { margin-top: 24px; }

/* ── Empty state ── */
.empty { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.8; }
.empty-text { font-size: 15px; font-weight: 600; color: var(--text); }
.empty-sub { font-size: 13px; margin-top: 4px; }

/* ── Users page mobile cards ── */
.users-mobile-list {
  display: grid;
  gap: 12px;
}
.users-mobile-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  backdrop-filter: blur(10px);
  padding: 14px;
}
.users-mobile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 4px 0;
}
.users-mobile-row .label {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: 10.5px;
}
.users-mobile-row .value {
  text-align: right;
  color: var(--text);
  font-weight: 500;
}
.users-mobile-row-channels {
  align-items: flex-start;
}
.users-mobile-row-channels .value {
  text-align: right;
  width: min(100%, 280px);
}
.linked-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
}
.linked-channel-pill {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  line-height: 1.1;
  max-width: 240px;
}
.linked-channel-pill.inactive {
  opacity: 0.65;
}
.linked-channel-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.linked-channel-id {
  font-size: 10px;
  color: var(--text-muted);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
}
.linked-channel-rpm {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
}

.users-mobile-actions {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

/* ── Creator stats header filters ── */
.creator-stats-head-info {
  min-width: 0;
}
.creator-stats-filters {
  justify-content: flex-end;
}
.creator-stats-date-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.creator-video-cell {
  min-width: 300px;
}
.creator-video-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.creator-video-table {
  min-width: 860px;
}

/* ── Payments ── */
.payment-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.payment-method-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
}
.payment-method-btn:hover { border-color: var(--primary); }
.payment-method-btn.active {
  border-color: var(--primary);
  background: var(--primary-dim);
  color: var(--primary);
}
.payment-method-btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--surface);
}
.soon-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Theme / Language controls (injected into sidebar) ── */
.sidebar-controls {
  display: flex;
  gap: 6px;
  padding: 10px 16px 14px;
}
.sidebar-controls-top {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  margin: 0;
}
.ctrl-btn {
  flex: 1;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}
.ctrl-btn:hover { border-color: var(--primary); color: var(--text); }
.ctrl-btn.active { background: var(--grad-soft); border-color: var(--border-strong); color: #fff; }
[data-theme="light"] .ctrl-btn.active { color: var(--primary); }
.ctrl-sep {
  width: 1px;
  background: var(--border);
  align-self: stretch;
  flex-shrink: 0;
  margin: 2px 0;
}

/* ── Auth page controls (login / reset) ── */
.auth-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 10px;
}
.auth-ctrl-btn {
  min-height: 34px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.auth-ctrl-btn:hover { border-color: var(--primary); color: var(--text); }
.auth-ctrl-btn.active { background: var(--grad-soft); border-color: var(--border-strong); color: #fff; }
[data-theme="light"] .auth-ctrl-btn.active { color: var(--primary); }

/* ── Cross-browser fallbacks ── */
@supports not (height: 100dvh) {
  .auth-page { min-height: 100vh; }
  @media (max-width: 768px) {
    .sidebar { height: 100vh; max-height: 100vh; }
  }
}
@supports not (aspect-ratio: 1 / 1) {
  .search-item img { height: 112px; }
}
@supports not ((-webkit-line-clamp: 2) and (-webkit-box-orient: vertical)) {
  .top-video-title,
  .search-item-title,
  .creator-video-title {
    display: block;
    line-height: 1.35;
    overflow: hidden;
  }
  .top-video-title,
  .search-item-title { max-height: calc(1.35em * 2); }
  .creator-video-title { max-height: calc(1.35em * 4); }
}
html.no-dvh .auth-page { min-height: 100vh; }
html.no-dvh .sidebar { height: 100vh; max-height: 100vh; }
html.no-aspect-ratio .search-item img { height: 112px; }
html.no-line-clamp .top-video-title,
html.no-line-clamp .search-item-title,
html.no-line-clamp .creator-video-title {
  display: block;
  line-height: 1.35;
  overflow: hidden;
}
html.no-line-clamp .top-video-title,
html.no-line-clamp .search-item-title { max-height: calc(1.35em * 2); }
html.no-line-clamp .creator-video-title { max-height: calc(1.35em * 4); }

/* ── Responsive ── */
/* Tablet (769px–1024px): tighten padding so content doesn't feel cramped next to sidebar */
@media (max-width: 1024px) and (min-width: 769px) {
  .main { padding: 28px 20px; }
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: inline-flex; }
  .sidebar {
    height: 100dvh;
    max-height: 100dvh;
    bottom: auto;
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  }
  .sidebar-nav {
    order: 3;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px;
  }
  .sidebar-footer {
    order: 2;
    border-top: none;
    border-bottom: 1px solid var(--border);
    padding-top: 10px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  body.sidebar-open { overflow: hidden; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  body.sidebar-open .mobile-menu-btn {
    left: auto;
    right: 12px;
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
  }

  .main { margin-left: 0; padding: 64px 16px 20px; width: 100%; }
  .main > * { max-width: 100%; }

  .form-row { grid-template-columns: 1fr; }
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }
  .stat-card {
    padding: 16px;
    min-height: 92px;
  }
  .stat-label { min-height: 18px; }
  .stat-value { font-size: 24px; }
  .filter-bar { gap: 8px; }
  /* Date inputs sit side-by-side; other .form-control and .btn go full-width */
  .filter-bar .btn { width: 100% !important; }
  .filter-bar .form-control { width: 100% !important; }
  .filter-bar input.form-control[type="date"] { flex: 1 1 calc(50% - 4px); min-width: 130px; width: auto !important; }
  .filter-sep { display: none; }

  .card { padding: 18px; }
  /* card-header flex-wrap already applied globally; override gap only */
  .page-title { font-size: 21px; }
  .td-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .td-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .modal { padding: 22px; width: calc(100% - 24px); }

  .table-wrap { width: 100%; }
  .chart-wrap canvas { max-width: 100% !important; }
  #an-charts-grid canvas { max-width: 100% !important; display: block; }

  .admin-analytics-filters {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .admin-analytics-filters .form-control,
  .admin-analytics-filters .btn,
  .admin-analytics-filters select {
    width: 100% !important;
    min-width: 0;
  }

  .admin-table-toolbar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
  }
  .admin-table-toolbar .form-control,
  .admin-table-toolbar select {
    width: 100% !important;
    min-width: 0;
  }

  #an-charts-grid { grid-template-columns: 1fr !important; }
  #affiliate-admin-grid { grid-template-columns: 1fr !important; }

  .users-page-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }
  .users-page-header .btn {
    width: 100%;
    justify-content: center;
  }

  .creator-stats-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .creator-stats-filters {
    width: 100%;
    justify-content: flex-start;
  }
  .creator-stats-filters .filter-btn {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }
  .creator-stats-date-row {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }
  .creator-stats-date-row .form-control {
    width: 100% !important;
    min-width: 0;
  }
  .creator-stats-filters #apply-custom {
    width: auto !important;
  }

  .creator-channel-col {
    display: table-cell;
    min-width: 150px;
  }
  .creator-video-table {
    min-width: 920px;
  }
  .creator-video-cell {
    min-width: 340px;
  }
  .creator-video-channel-mobile {
    display: none !important;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .auth-card {
    max-width: 100%;
    border-radius: 22px;
    padding: 30px 20px 24px;
  }
  .auth-title { font-size: 27px; }
  .auth-subtitle { font-size: 13px; margin-bottom: 22px; }
  .auth-controls {
    margin: 0 0 8px;
    gap: 8px;
    position: relative;
    z-index: 2;
  }
  .auth-ctrl-btn {
    min-width: 64px;
    min-height: 40px;
    padding: 8px 14px;
    font-size: 12px;
  }
}

/* ── Custom scrollbar ── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }
::-webkit-scrollbar-corner { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #cbb9ec; }

input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.75); }
[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator { filter: none; }

/* ─── Brand logo: NAYEN blanco + MUSIC violeta, sin degradado ─── */
.brand-text,
.auth-logo .brand-text,
.sidebar-logo .brand-text,
.sidebar-logo > span:not(.brand-mark) {
  color: #fff !important;
  background: none !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  -webkit-text-fill-color: #fff !important;
}
.brand-text .brand-accent,
.auth-logo .brand-text .brand-accent,
.sidebar-logo .brand-text .brand-accent,
.sidebar-logo > span:not(.brand-mark) .brand-accent {
  color: #a855f7 !important;
  -webkit-text-fill-color: #a855f7 !important;
}

/* In light mode, sidebar logo text must be dark for contrast. */
[data-theme="light"] .sidebar-logo .brand-text,
[data-theme="light"] .sidebar-logo > span:not(.brand-mark) {
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
}
