:root {
    --bg-base: #0d0d12;
    --bg-1: #161620;
    --bg-2: #1f1f2c;
    --bg-3: #2a2a38;
    --bg-card: #1a1a25;
    --bg-elevated: #252533;
    --bg-glass: rgba(20, 20, 28, 0.85);
    --accent: #00a8e1;
    --accent-2: #00c4f5;
    --accent-3: #0080a8;
    --accent-glow: rgba(0, 168, 225, 0.5);
    --accent-soft: rgba(0, 168, 225, 0.15);
    --accent-faint: rgba(0, 168, 225, 0.08);
    --text: #ffffff;
    --text-2: #c8c8d8;
    --text-3: #88889a;
    --text-4: #5a5a6a;
    --danger: #ff3a5e;
    --success: #00d68f;
    --warning: #ffb800;
    --border: 1px solid rgba(255, 255, 255, 0.06);
    --border-2: 1px solid rgba(255, 255, 255, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --ease: cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    background: var(--bg-base);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

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

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 400px;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 18px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    min-width: 260px;
    animation: toastIn 0.35s var(--ease);
    will-change: transform, opacity;
    contain: layout style paint;
}

.toast.success { border-color: rgba(0, 214, 143, 0.4); box-shadow: 0 12px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,214,143,0.2); }
.toast.error { border-color: rgba(255, 58, 94, 0.4); box-shadow: 0 12px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,58,94,0.2); }
.toast.info { border-color: rgba(0, 168, 225, 0.4); box-shadow: 0 12px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,168,225,0.2); }
.toast.warning { border-color: rgba(255, 184, 0, 0.4); }

.toast-icon { font-size: 16px; font-weight: 800; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--accent-2); }
.toast.warning .toast-icon { color: var(--warning); }

.toast.removing { animation: toastOut 0.3s var(--ease) forwards; }

@keyframes toastIn {
    from { opacity: 0; transform: translate3d(120%, 0, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes toastOut {
    to { opacity: 0; transform: translate3d(120%, 0, 0); }
}

.auth-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    contain: layout style paint;
}

.auth-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #050510 0%, #0a1525 50%, #150525 100%);
    z-index: 0;
}

.auth-glow {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    will-change: transform;
    contain: layout style paint;
}

.auth-glow-1 {
    top: 15%; left: 10%;
    width: 420px; height: 420px;
    background: radial-gradient(circle, rgba(0, 168, 225, 0.4) 0%, transparent 70%);
    filter: blur(60px);
    animation: glow-float-1 14s ease-in-out infinite;
}

.auth-glow-2 {
    bottom: 10%; right: 8%;
    width: 380px; height: 380px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.35) 0%, transparent 70%);
    filter: blur(60px);
    animation: glow-float-2 17s ease-in-out infinite;
}

.auth-glow-3 {
    top: 50%; left: 50%;
    width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.3) 0%, transparent 70%);
    filter: blur(70px);
    animation: glow-float-3 20s ease-in-out infinite;
}

@keyframes glow-float-1 {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(80px, 60px, 0) scale(1.1); }
}
@keyframes glow-float-2 {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(-90px, -50px, 0) scale(1.15); }
}
@keyframes glow-float-3 {
    0%, 100% { transform: translate3d(-50%, -50%, 0) scale(1); }
    50% { transform: translate3d(-30%, -70%, 0) scale(1.2); }
}

.auth-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 0;
    pointer-events: none;
    mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black, transparent);
    -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black, transparent);
}

.auth-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 440px;
    padding: 20px;
    animation: containerIn 0.7s var(--ease);
}

@keyframes containerIn {
    from { opacity: 0; transform: translate3d(0, 30px, 0) scale(0.95); }
    to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

.auth-box {
    background: rgba(15, 15, 22, 0.7);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 44px 40px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    animation: boxIn 0.7s var(--ease);
    contain: layout style paint;
}

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

.auth-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 168, 225, 0.6), transparent);
    animation: shine 3.5s ease-in-out infinite;
}

@keyframes shine {
    0%, 100% { opacity: 0.3; transform: scaleX(0.8); }
    50% { opacity: 1; transform: scaleX(1); }
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 36px;
    justify-content: center;
    animation: logoIn 0.7s 0.15s var(--ease) backwards;
}

@keyframes logoIn {
    from { opacity: 0; transform: translate3d(0, -10px, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.auth-logo-icon {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 22px;
    box-shadow: 0 8px 24px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    animation: pulse-icon 3s ease-in-out infinite;
    will-change: transform;
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

.auth-logo-icon::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.3) 50%, transparent 60%);
    animation: shine-icon 3.5s linear infinite;
}

@keyframes shine-icon {
    0% { transform: translate3d(-100%, -100%, 0); }
    100% { transform: translate3d(100%, 100%, 0); }
}

.auth-logo-text {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-title {
    font-size: 28px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
    animation: fadeUp 0.6s 0.25s var(--ease) backwards;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--text-3);
    text-align: center;
    margin-bottom: 32px;
    animation: fadeUp 0.6s 0.35s var(--ease) backwards;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translate3d(0, 10px, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-field {
    animation: fieldIn 0.5s var(--ease) backwards;
    position: relative;
}

.auth-field:nth-child(1) { animation-delay: 0.4s; }
.auth-field:nth-child(2) { animation-delay: 0.5s; }
.auth-field:nth-child(3) { animation-delay: 0.55s; }

@keyframes fieldIn {
    from { opacity: 0; transform: translate3d(-20px, 0, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.auth-field input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 14px 16px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.25s, background 0.25s, box-shadow 0.25s, transform 0.25s;
    outline: none;
}

.auth-field input:hover { border-color: rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.4); }
.auth-field input:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 3px var(--accent-soft);
    transform: translate3d(0, -1px, 0);
}

.auth-field input::placeholder { color: var(--text-4); }

.auth-error {
    background: rgba(255, 58, 94, 0.15);
    border: 1px solid rgba(255, 58, 94, 0.3);
    color: #ff8a9c;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    text-align: center;
    animation: fadeUp 0.3s var(--ease);
}

.auth-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    color: white;
    border: none;
    padding: 15px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
    font-family: inherit;
    margin-top: 8px;
    box-shadow: 0 4px 16px var(--accent-soft);
    position: relative;
    overflow: hidden;
    animation: fadeUp 0.5s 0.6s var(--ease) backwards;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.6s;
}

.auth-btn:hover::before { left: 100%; }
.auth-btn:hover { transform: translate3d(0, -2px, 0); box-shadow: 0 8px 24px var(--accent-glow); }
.auth-btn:active { transform: translate3d(0, 0, 0); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.auth-btn .btn-spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}

.auth-btn.loading .btn-spinner { display: inline-block; }
.auth-btn.loading .btn-text { opacity: 0.7; }

.auth-switch {
    text-align: center;
    margin-top: 22px;
    font-size: 13px;
    color: var(--text-3);
    animation: fadeIn 0.5s 0.7s var(--ease) backwards;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.auth-switch a {
    color: var(--accent-2);
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s;
    text-decoration: none;
    position: relative;
}

.auth-switch a::after {
    content: '';
    position: absolute;
    bottom: -2px; left: 0;
    width: 0; height: 1px;
    background: var(--accent-2);
    transition: width 0.3s;
}

.auth-switch a:hover::after { width: 100%; }
.auth-switch a:hover { color: var(--accent); }

#admin-screen { min-height: 100vh; background: var(--bg-base); }

.admin-header {
    background: var(--bg-1);
    border-bottom: var(--border);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    animation: fadeUp 0.5s var(--ease);
}

.admin-logo { display: flex; align-items: center; gap: 12px; }

.admin-logo-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--warning), #d97706);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 800; color: white;
    box-shadow: 0 4px 16px rgba(255, 184, 0, 0.3);
    animation: adminPulse 2.5s ease-in-out infinite;
    will-change: box-shadow;
}

@keyframes adminPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(255, 184, 0, 0.3); }
    50% { box-shadow: 0 4px 24px rgba(255, 184, 0, 0.5), 0 0 30px rgba(255, 184, 0, 0.2); }
}

.admin-logo-text { font-size: 18px; font-weight: 700; }
.admin-logo-text span { color: var(--warning); font-weight: 600; }

.admin-header-right { display: flex; gap: 10px; }

.admin-btn-back, .admin-btn-logout, .admin-btn-secondary {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s var(--ease), background 0.2s;
    border: var(--border-2);
    font-family: inherit;
}

.admin-btn-back, .admin-btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-2);
}

.admin-btn-back:hover, .admin-btn-secondary:hover {
    background: var(--bg-3); color: var(--text); transform: translate3d(0, -1px, 0);
}

.admin-btn-logout {
    background: rgba(255, 58, 94, 0.15);
    color: #ff8a9c;
    border-color: rgba(255, 58, 94, 0.2);
}

.admin-btn-logout:hover { background: var(--danger); color: white; transform: translate3d(0, -1px, 0); }

.admin-container { max-width: 1400px; margin: 0 auto; padding: 32px; }

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.admin-stat {
    background: var(--bg-card);
    border: var(--border);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.3s var(--ease), border-color 0.3s, box-shadow 0.3s;
    animation: fadeUp 0.5s var(--ease) backwards;
    will-change: transform;
}

.admin-stat:nth-child(1) { animation-delay: 0.05s; }
.admin-stat:nth-child(2) { animation-delay: 0.1s; }
.admin-stat:nth-child(3) { animation-delay: 0.15s; }
.admin-stat:nth-child(4) { animation-delay: 0.2s; }
.admin-stat:nth-child(5) { animation-delay: 0.25s; }

.admin-stat:hover {
    transform: translate3d(0, -4px, 0);
    border-color: rgba(0, 168, 225, 0.3);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.admin-stat-icon {
    width: 52px; height: 52px;
    background: var(--bg-elevated);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px;
    transition: transform 0.3s;
}

.admin-stat:hover .admin-stat-icon { transform: scale(1.1) rotate(-5deg); }

.admin-stat-value { font-size: 28px; font-weight: 800; transition: color 0.3s; }
.admin-stat:hover .admin-stat-value { color: var(--accent-2); }
.admin-stat-label { font-size: 13px; color: var(--text-3); font-weight: 500; }

.admin-section {
    background: var(--bg-card);
    border: var(--border);
    border-radius: var(--radius);
    padding: 24px;
    animation: fadeUp 0.5s 0.3s var(--ease) backwards;
}

.admin-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-section-head h2 { font-size: 18px; font-weight: 700; }

.admin-btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s var(--ease), box-shadow 0.2s;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.admin-btn-primary::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.6s;
}

.admin-btn-primary:hover::before { left: 100%; }
.admin-btn-primary:hover { transform: translate3d(0, -2px, 0); box-shadow: 0 8px 24px var(--accent-glow); }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }

.admin-table tr { animation: fadeUp 0.4s var(--ease) backwards; }
.admin-table tr:nth-child(1) { animation-delay: 0.4s; }
.admin-table tr:nth-child(2) { animation-delay: 0.45s; }
.admin-table tr:nth-child(3) { animation-delay: 0.5s; }
.admin-table tr:nth-child(4) { animation-delay: 0.55s; }
.admin-table tr:nth-child(5) { animation-delay: 0.6s; }

.admin-table th, .admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: var(--border);
    font-size: 13px;
}

.admin-table th {
    color: var(--text-3);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
    background: var(--bg-1);
}

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

.admin-role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.admin-role-badge.admin {
    background: rgba(255, 184, 0, 0.15);
    color: var(--warning);
    border: 1px solid rgba(255, 184, 0, 0.2);
    animation: badgePulse 2.5s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 184, 0, 0); }
    50% { box-shadow: 0 0 0 4px rgba(255, 184, 0, 0.1); }
}

.admin-role-badge.user {
    background: rgba(0, 168, 225, 0.15);
    color: var(--accent-2);
    border: 1px solid rgba(0, 168, 225, 0.2);
}

.admin-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.admin-status-badge.active { background: rgba(0, 214, 143, 0.15); color: var(--success); }
.admin-status-badge.inactive { background: rgba(255, 58, 94, 0.15); color: var(--danger); }

.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.admin-action-btn {
    background: var(--bg-elevated);
    color: var(--text-2);
    border: var(--border-2);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s var(--ease), background 0.2s, color 0.2s;
    font-family: inherit;
}

.admin-action-btn:hover { background: var(--bg-3); color: var(--text); transform: translate3d(0, -1px, 0); }
.admin-action-btn.danger { color: #ff8a9c; }
.admin-action-btn.danger:hover { background: var(--danger); color: white; transform: translate3d(0, -1px, 0); }
.admin-action-btn.renew {
    color: var(--accent-2);
    background: var(--accent-soft);
    border-color: rgba(0, 168, 225, 0.2);
}
.admin-action-btn.renew:hover { background: var(--accent); color: white; border-color: var(--accent); }

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s var(--ease);
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: var(--bg-1);
    border: var(--border-2);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 440px;
    z-index: 1;
    animation: modalIn 0.3s var(--ease);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translate3d(0, -20px, 0); }
    to { opacity: 1; transform: scale(1) translate3d(0, 0, 0); }
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: var(--border);
}

.modal-head h3 { font-size: 18px; font-weight: 700; }

.modal-close {
    background: var(--bg-elevated);
    color: var(--text-2);
    border: var(--border-2);
    width: 32px; height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s var(--ease), color 0.2s, transform 0.2s var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: var(--danger); color: white; }

.modal-form { display: flex; flex-direction: column; gap: 14px; }
.modal-field { display: flex; flex-direction: column; gap: 6px; }
.modal-field label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-left: 4px; }

.modal-field input, .modal-field select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 11px 14px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.modal-field input:focus, .modal-field select:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-field select option { background: var(--bg-1); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.modal-btn-cancel, .modal-btn-save {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    font-family: inherit;
    border: none;
}

.modal-btn-cancel { background: var(--bg-elevated); color: var(--text-2); }
.modal-btn-cancel:hover { background: var(--bg-3); }

.modal-btn-save {
    background: var(--accent);
    color: white;
    position: relative;
    overflow: hidden;
}

.modal-btn-save::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.6s;
}

.modal-btn-save:hover::before { left: 100%; }
.modal-btn-save:hover { background: var(--accent-2); }

.duration-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.duration-row input[type="number"] {
    flex: 1;
    min-width: 80px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 11px 14px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.duration-row input[type="number"]:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.duration-presets {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.preset-btn {
    background: var(--bg-2);
    color: var(--text-2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
    font-family: inherit;
}

.preset-btn:hover {
    background: var(--accent-soft);
    color: var(--accent-2);
    border-color: rgba(0, 168, 225, 0.3);
    transform: translate3d(0, -1px, 0);
}

.preset-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    color: white;
    border-color: var(--accent);
}

.preset-btn.preset-unlimited {
    color: var(--warning);
    border-color: rgba(255, 184, 0, 0.2);
}

.preset-btn.preset-unlimited:hover,
.preset-btn.preset-unlimited.active {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

/* ==========================================
   APP — SIDEBAR COMO DRAWER MÓVIL
   ========================================== */
.app { display: flex; min-height: 100vh; position: relative; }

.sidebar {
    width: 280px;
    background: var(--bg-1);
    border-right: var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    animation: slideInLeft 0.4s var(--ease);
}

@keyframes slideInLeft {
    from { transform: translate3d(-100%, 0, 0); }
    to { transform: translate3d(0, 0, 0); }
}

.sidebar-top { padding: 16px 16px 8px; border-bottom: var(--border); flex-shrink: 0; }

.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 0; }

.logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 16px;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.logo-text { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.logo-text span { color: var(--accent-2); }

.sidebar-menu { padding: 8px 8px 4px; border-bottom: var(--border); flex-shrink: 0; }

.sidebar-group-title {
    font-size: 9px;
    font-weight: 800;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 14px 4px;
    margin-top: 4px;
}
.sidebar-group-title:first-child { margin-top: 0; padding-top: 0; }

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 14px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    border: 1px solid transparent;
    background: none;
    text-align: left;
    width: 100%;
    font-family: inherit;
    margin-bottom: 2px;
    position: relative;
}

.menu-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.menu-item.active {
    color: white;
    background: linear-gradient(90deg, var(--accent-soft), transparent);
    border-color: rgba(0, 168, 225, 0.3);
}

.menu-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.menu-item .icon { font-size: 18px; width: 22px; text-align: center; }
.menu-item .count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-3);
    background: rgba(255,255,255,0.06);
    padding: 2px 8px;
    border-radius: 8px;
}
.menu-item.active .count { background: rgba(0, 168, 225, 0.25); color: var(--accent-2); }

.sidebar-categories-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.sidebar-categories-head {
    padding: 8px 12px 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
.sidebar-categories-head > span {
    font-size: 9px;
    font-weight: 800;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 4px;
}

.sidebar-search {
    width: 100%;
    background: var(--bg-2);
    border: var(--border-2);
    border-radius: 6px;
    padding: 7px 10px;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}
.sidebar-search:focus { border-color: var(--accent); background: var(--bg-3); }
.sidebar-search::placeholder { color: var(--text-3); }

.sidebar-categories {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 16px;
    min-height: 0;
}
.sidebar-categories::-webkit-scrollbar { width: 4px; }
.sidebar-categories::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
.sidebar-categories::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

.cat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    margin-bottom: 1px;
    position: relative;
    overflow: hidden;
}
.cat-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0;
    width: 0; height: 100%;
    background: var(--accent);
    transition: width 0.2s;
}
.cat-item.active::before, .cat-item:hover::before { width: 3px; }
.cat-item:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.cat-item.active { color: var(--accent-2); background: var(--accent-soft); }
.cat-item .cat-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    background: rgba(255,255,255,0.04);
    padding: 1px 7px;
    border-radius: 6px;
}

/* Botón hamburguesa (oculto en desktop) */
.menu-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    width: 40px;
    height: 40px;
    background: var(--bg-elevated);
    border: var(--border-2);
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 150;
    color: var(--text);
    font-size: 18px;
    backdrop-filter: blur(20px);
    transition: background 0.2s, transform 0.2s;
}

.menu-toggle:hover { background: var(--accent-soft); transform: scale(1.05); }

/* Backdrop del sidebar móvil */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease);
    backdrop-filter: blur(4px);
}

.sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

.main { flex: 1; min-width: 0; background: var(--bg-base); display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-1);
    border-bottom: var(--border);
    flex-shrink: 0;
    gap: 16px;
}

.topbar-left { flex: 1; min-width: 0; }
.view-title { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; margin-bottom: 2px; }
.view-meta { font-size: 12px; color: var(--text-3); }

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

.status-pill {
    background: var(--accent-soft);
    color: var(--accent-2);
    border: 1px solid rgba(0, 168, 225, 0.25);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.status-pill.error { background: rgba(255,58,94,0.15); color: var(--danger); border-color: rgba(255,58,94,0.25); }

.status-dot {
    width: 6px; height: 6px;
    background: var(--accent-2);
    border-radius: 50%;
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.9); }
}

.user-menu { position: relative; }

.user-menu-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: transform 0.2s var(--ease);
}

.user-menu-btn:hover, .user-menu-btn.active { transform: scale(1.08); }

.user-avatar-top {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
    transition: box-shadow 0.2s;
}

.user-avatar-top.user-avatar-lg {
    width: 44px;
    height: 44px;
    font-size: 17px;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.user-menu-btn:hover .user-avatar-top,
.user-menu-btn.active .user-avatar-top {
    box-shadow: 0 4px 16px var(--accent-glow), 0 0 0 3px var(--accent-soft);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 280px;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
    padding: 14px;
    z-index: 200;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.2s var(--ease), transform 0.25s var(--ease);
    backdrop-filter: blur(20px);
}

.user-dropdown.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.user-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 14px;
    width: 12px;
    height: 12px;
    background: var(--bg-elevated);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
}

.user-dropdown-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 4px 12px;
}

.user-dropdown-info { flex: 1; min-width: 0; }

.user-dropdown-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-role {
    font-size: 11px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-top: 2px;
}

.user-dropdown-meta { padding: 0 4px 12px; }

.user-expires-dropdown {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 6px;
    text-align: center;
}

.user-expires-dropdown.ok { color: var(--success); background: rgba(0, 214, 143, 0.12); border: 1px solid rgba(0, 214, 143, 0.25); }
.user-expires-dropdown.warning { color: var(--warning); background: rgba(255, 184, 0, 0.12); border: 1px solid rgba(255, 184, 0, 0.25); }
.user-expires-dropdown.critical {
    color: var(--danger); background: rgba(255, 58, 94, 0.15);
    border: 1px solid rgba(255, 58, 94, 0.3);
    animation: criticalPulse 2s ease-in-out infinite;
}
.user-expires-dropdown.expired {
    color: var(--danger); background: rgba(255, 58, 94, 0.2);
    border: 1px solid rgba(255, 58, 94, 0.4); font-weight: 800;
}

.user-dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 6px 0;
}

.user-dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-align: left;
    font-family: inherit;
}

.user-dropdown-item .icon { font-size: 16px; width: 20px; text-align: center; }

.user-dropdown-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }

.user-dropdown-item.user-dropdown-logout { color: #ff8a9c; }
.user-dropdown-item.user-dropdown-logout:hover { background: var(--danger); color: white; }

.advanced-search-btn {
    background: var(--bg-elevated);
    color: var(--text-2);
    border: var(--border-2);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.advanced-search-btn:hover { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(0, 168, 225, 0.3); }

.advanced-search {
    background: var(--bg-1);
    border-bottom: var(--border);
    padding: 0 28px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s var(--ease), padding 0.4s var(--ease);
}

.advanced-search.open { max-height: 200px; padding: 16px 28px; }

.adv-search-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.adv-input {
    background: var(--bg-2);
    color: var(--text);
    border: var(--border-2);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    min-width: 120px;
    flex: 1;
}

.adv-input:focus { border-color: var(--accent); background: var(--bg-3); }
.adv-input::placeholder { color: var(--text-3); }
.adv-input option { background: var(--bg-1); }

.adv-btn-search {
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.adv-btn-search:hover { transform: translate3d(0, -1px, 0); box-shadow: 0 4px 12px var(--accent-glow); }

.adv-search-meta {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-3);
}

.adv-search-loading { color: var(--accent-2); font-weight: 600; }

.content { flex: 1; overflow-y: auto; padding: 24px 28px 40px; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s var(--ease), border-color 0.3s, box-shadow 0.3s;
    border: var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    animation: fadeUp 0.4s var(--ease) backwards;
    will-change: transform;
    contain: layout style paint;
}

.card:hover {
    transform: translate3d(0, -8px, 0) scale(1.03);
    border-color: rgba(0, 168, 225, 0.5);
    box-shadow: 0 20px 50px rgba(0,0,0,0.6), 0 0 25px rgba(0, 168, 225, 0.2);
    z-index: 10;
}

.poster {
    width: 100%;
    aspect-ratio: 16/10;
    background: linear-gradient(135deg, var(--bg-2), var(--bg-1));
    overflow: hidden;
    position: relative;
}

.poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s var(--ease), filter 0.4s ease;
    /* filter: blur(8px); -- REMOVIDO PARA MEJOR CALIDAD */
    animation: none;
}

.poster img.loaded { 
    filter: blur(0);
    animation: none;
}

@keyframes imageReady {
    to { filter: blur(0); }
}

/* @keyframes imageReady {
    to { filter: blur(0); }
} */

.poster img.loaded { filter: blur(0); }
.card:hover .poster img { transform: scale(1.1); }

.poster::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(13,13,18,0.85) 0%, transparent 60%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.card:hover .poster::after { opacity: 1; }

.tag {
    position: absolute;
    top: 8px; left: 8px;
    background: rgba(13, 13, 18, 0.85);
    backdrop-filter: blur(8px);
    padding: 3px 8px;
    font-size: 9px;
    font-weight: 800;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
}

.tag.live { color: var(--danger); border-color: rgba(255, 58, 94, 0.4); animation: livePulse 2s infinite; }
.tag.movie { color: var(--accent-2); border-color: rgba(0, 168, 225, 0.4); }
.tag.series { color: var(--warning); border-color: rgba(255, 184, 0, 0.4); }

@keyframes livePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 58, 94, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(255, 58, 94, 0); }
}

.play-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    width: 52px; height: 52px;
    background: rgba(255,255,255,0.95);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: transform 0.4s var(--ease), opacity 0.3s;
    z-index: 2;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.play-overlay svg { width: 22px; height: 22px; fill: black; margin-left: 3px; }

.card:hover .play-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(360deg);
}

.fav-btn {
    position: absolute;
    top: 8px; right: 8px;
    width: 32px; height: 32px;
    background: rgba(13, 13, 18, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    color: var(--text-3);
    transition: transform 0.2s var(--ease), color 0.2s, background 0.2s, border-color 0.2s, opacity 0.2s;
    padding: 0;
    opacity: 0;
}

.card:hover .fav-btn, .fav-btn.active { opacity: 1; }
.fav-btn:hover { transform: scale(1.15); background: rgba(13, 13, 18, 0.95); }
.fav-btn.active { color: #ff4d6d; border-color: rgba(255, 77, 109, 0.4); }

.fav-btn.pop { animation: favPop 0.4s var(--ease); }
@keyframes favPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

.card-info { padding: 12px 14px; background: var(--bg-card); transition: background 0.2s; }
.card:hover .card-info { background: var(--bg-elevated); }

.card-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 36px;
    transition: color 0.2s;
}

.card:hover .card-title { color: var(--accent-2); }

.card-meta {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-3);
}

.card-meta span { display: inline-flex; align-items: center; gap: 2px; }

.card-progress {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 4px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.card-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 0.3s var(--ease);
    box-shadow: 0 0 8px var(--accent-glow);
}

.empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
}

.empty .icon { font-size: 56px; margin-bottom: 16px; opacity: 0.4; }
.empty h3 { font-size: 16px; color: var(--text-2); margin-bottom: 6px; font-weight: 700; }
.empty p { font-size: 12px; color: var(--text-3); }

.load-more-wrap { grid-column: 1 / -1; text-align: center; padding: 20px; }

.load-more-btn {
    background: var(--bg-elevated);
    color: var(--text-2);
    border: var(--border-2);
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.load-more-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 168, 225, 0.2), transparent);
    transition: left 0.6s;
}

.load-more-btn:hover::before { left: 100%; }
.load-more-btn:hover { background: var(--accent-soft); color: var(--text); border-color: var(--accent); transform: translate3d(0, -2px, 0); }

.drawer {
    display: none;
    position: fixed;
    right: 0; top: 0;
    width: 440px;
    height: 100%;
    background: var(--bg-1);
    border-left: var(--border-2);
    box-shadow: -20px 0 60px rgba(0,0,0,0.8);
    z-index: 150;
    flex-direction: column;
    animation: drawerIn 0.4s var(--ease);
}

@keyframes drawerIn {
    from { transform: translate3d(100%, 0, 0); }
    to { transform: translate3d(0, 0, 0); }
}

.drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 22px 24px 18px;
    border-bottom: var(--border);
    gap: 12px;
}

.drawer-title { font-size: 17px; font-weight: 700; }
.drawer-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.btn-close {
    position: relative;
    background: var(--bg-elevated);
    color: var(--text-2);
    border: var(--border-2);
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: background 0.25s var(--ease), color 0.25s, border-color 0.25s, padding 0.25s var(--ease), box-shadow 0.25s var(--ease);
    font-family: inherit;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-close::before,
.btn-close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 12px;
    width: 10px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.3s var(--ease), opacity 0.25s, background 0.25s;
    transform-origin: center;
}

.btn-close::before { transform: translateY(-50%) rotate(45deg); }
.btn-close::after  { transform: translateY(-50%) rotate(-45deg); }

.btn-close:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    padding-left: 30px;
    box-shadow: 0 6px 20px rgba(255, 58, 94, 0.35);
}

.btn-close:hover::before, .btn-close:hover::after { background: white; }

.ep-list { overflow-y: auto; flex: 1; padding: 14px 24px 24px; }

.ep-item {
    background: var(--bg-2);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    border: var(--border);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s, padding 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.ep-item::before { content: '▶'; color: var(--text-3); font-size: 9px; transition: color 0.2s, transform 0.2s; }
.ep-item:hover { border-color: var(--accent); background: var(--accent-faint); color: var(--text); transform: translate3d(6px, 0, 0); padding-left: 20px; }
.ep-item:hover::before { color: var(--accent-2); transform: scale(1.3); }

.player-layer {
    display: none;
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 300;
    flex-direction: column;
    padding: 20px 28px;
    animation: fadeIn 0.3s ease;
}

.player-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
    gap: 12px;
}

.player-head-left { flex: 1; min-width: 0; }
.player-head h2 {
    font-size: 16px;
    font-weight: 700;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.player-head-right { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

.btn-epg, .btn-fav-player {
    background: var(--bg-elevated);
    color: var(--text-2);
    border: var(--border-2);
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: background 0.2s, color 0.2s, transform 0.2s, border-color 0.2s;
    font-family: inherit;
}

.btn-epg:hover { background: var(--accent); color: white; border-color: var(--accent); }
.btn-fav-player { font-size: 18px; padding: 5px 12px; }
.btn-fav-player.active { color: #ff4d6d; border-color: rgba(255, 77, 109, 0.4); background: rgba(255, 77, 109, 0.1); }
.btn-fav-player:hover { transform: scale(1.1); }

/* Botón de Pausa/Play */
.btn-control-player {
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    color: white;
    border: none;
    width: 38px; height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--accent-glow);
    transition: transform 0.2s var(--ease), box-shadow 0.2s;
    font-family: inherit;
}

.btn-control-player:hover { transform: scale(1.08); box-shadow: 0 6px 18px var(--accent-glow); }
.btn-control-player:active { transform: scale(0.95); }

.player-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

.player-progress-bar {
    flex: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    cursor: pointer;
    min-width: 100px;
    position: relative;
    transition: height 0.2s;
}

.player-progress-bar:hover { height: 8px; }

.player-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 3px;
    transition: width 0.3s;
    width: 0%;
    pointer-events: none;
}

.player-progress-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(0, 168, 225, 0.5);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, width 0.2s, height 0.2s;
}

.player-progress-bar:hover .player-progress-handle {
    opacity: 1;
    width: 16px;
    height: 16px;
}

.player-viewport {
    flex: 1;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    border: var(--border);
    box-shadow: 0 32px 80px rgba(0,0,0,0.8);
    position: relative;
}

video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.loader {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-2);
    text-align: center;
    z-index: 1;
}

.loader .spin {
    width: 48px; height: 48px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent-2);
    border-radius: 50%;
    margin: 0 auto 14px;
    animation: spin 0.8s linear infinite;
}

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

.error-state {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-2);
    text-align: center;
    max-width: 440px;
    padding: 20px;
    animation: fadeUp 0.4s var(--ease);
}

.error-state .icon { font-size: 64px; margin-bottom: 16px; opacity: 0.6; animation: errorPulse 2s ease-in-out infinite; }

@keyframes errorPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.9; }
}

.error-state h3 { color: var(--text); margin-bottom: 10px; font-size: 19px; font-weight: 700; }
.error-state p { font-size: 13px; color: var(--text-3); margin-bottom: 18px; line-height: 1.6; }
.error-state .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn-retry {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.btn-retry::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.6s;
}

.btn-retry:hover::before { left: 100%; }
.btn-retry:hover { background: var(--accent-2); transform: translate3d(0, -2px, 0); box-shadow: 0 4px 12px var(--accent-glow); }

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-2);
    border: var(--border-2);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    font-family: inherit;
}

.btn-secondary:hover { background: var(--bg-3); color: var(--text); transform: translate3d(0, -1px, 0); }

.epg-panel {
    position: fixed;
    top: 0; right: 0;
    width: 420px;
    height: 100%;
    background: var(--bg-1);
    border-left: var(--border-2);
    box-shadow: -20px 0 60px rgba(0,0,0,0.8);
    z-index: 350;
    transform: translate3d(100%, 0, 0);
    transition: transform 0.4s var(--ease);
    display: flex;
    flex-direction: column;
    will-change: transform;
}

.epg-panel.open { transform: translate3d(0, 0, 0); }

.epg-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: var(--border);
    background: var(--bg-1);
    flex-shrink: 0;
}

.epg-head h3 { font-size: 16px; font-weight: 700; }

.epg-head button {
    background: var(--bg-elevated);
    color: var(--text-2);
    border: var(--border-2);
    width: 32px; height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 0;
}

.epg-head button::before, .epg-head button::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transform-origin: center;
}

.epg-head button::before { transform: rotate(45deg); }
.epg-head button::after { transform: rotate(-45deg); }
.epg-head button:hover { background: var(--danger); color: white; transform: scale(1.05); }

.epg-content { flex: 1; overflow-y: auto; padding: 20px 24px; }

.epg-loading { text-align: center; padding: 40px 20px; color: var(--text-3); }
.epg-loading .spin { width: 36px; height: 36px; margin: 0 auto 12px; }

.epg-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-3);
    animation: fadeUp 0.4s var(--ease);
}

.epg-empty .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.epg-empty h4 { color: var(--text-2); font-size: 15px; margin-bottom: 8px; font-weight: 700; }
.epg-empty p { font-size: 12px; line-height: 1.5; }

.epg-empty-mini {
    background: var(--bg-2);
    padding: 14px 16px;
    border-radius: 8px;
    color: var(--text-3);
    font-size: 12px;
    text-align: center;
    border: var(--border);
}

.epg-channel {
    background: linear-gradient(135deg, var(--accent-soft), transparent);
    border: 1px solid rgba(0, 168, 225, 0.2);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 16px;
    animation: fadeUp 0.4s var(--ease);
}

.epg-channel-name { font-size: 14px; font-weight: 700; color: var(--accent-2); }

.epg-card {
    background: var(--bg-2);
    border: var(--border-2);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    animation: fadeUp 0.4s var(--ease);
    transition: transform 0.2s var(--ease), border-color 0.2s;
}

.epg-card.current { border-color: rgba(255, 58, 94, 0.3); background: linear-gradient(135deg, rgba(255,58,94,0.05), var(--bg-2)); }
.epg-card.next { border-color: rgba(0, 168, 225, 0.2); }

.epg-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.epg-badge {
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    animation: livePulse 2s infinite;
}

.epg-badge.next { background: var(--accent); }

.epg-time {
    font-size: 11px;
    color: var(--text-3);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.epg-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.epg-desc { font-size: 12px; color: var(--text-3); line-height: 1.5; margin-bottom: 8px; }

.epg-progress {
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.epg-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--danger), var(--warning));
    border-radius: 2px;
    transition: width 0.6s var(--ease);
}

.admin-btn-notif {
    position: relative;
    background: var(--bg-elevated);
    color: var(--text-2);
    border: var(--border-2);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.admin-btn-notif:hover { background: var(--accent-soft); color: var(--accent-2); transform: translate3d(0, -1px, 0); }

.notif-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    animation: badgePulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(255, 58, 94, 0.5);
}

.notif-panel {
    position: fixed;
    top: 0; right: 0;
    width: 380px;
    height: 100%;
    background: var(--bg-1);
    border-left: var(--border-2);
    box-shadow: -20px 0 60px rgba(0,0,0,0.8);
    z-index: 200;
    transform: translate3d(100%, 0, 0);
    transition: transform 0.4s var(--ease);
    display: flex;
    flex-direction: column;
}

.notif-panel.open { transform: translate3d(0, 0, 0); }

.notif-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: var(--border);
    flex-shrink: 0;
}

.notif-head h3 { font-size: 16px; font-weight: 700; }

.notif-content { flex: 1; overflow-y: auto; padding: 16px 24px; }

.notif-empty { text-align: center; padding: 40px 20px; color: var(--text-3); }

.notif-item {
    display: flex;
    gap: 12px;
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 10px;
    border: var(--border-2);
    animation: fadeUp 0.3s var(--ease);
    transition: transform 0.2s var(--ease);
}

.notif-item:hover { transform: translate3d(4px, 0, 0); }
.notif-item.warning { background: rgba(255, 184, 0, 0.08); border-color: rgba(255, 184, 0, 0.3); }
.notif-item.critical { background: rgba(255, 58, 94, 0.08); border-color: rgba(255, 58, 94, 0.3); }
.notif-item.error { background: rgba(255, 58, 94, 0.12); border-color: rgba(255, 58, 94, 0.4); }

.notif-icon { font-size: 22px; flex-shrink: 0; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.notif-msg { font-size: 12px; color: var(--text-3); line-height: 1.4; }

.admin-logs {
    max-height: 500px;
    overflow-y: auto;
    background: var(--bg-base);
    border-radius: 8px;
    padding: 8px;
}

.logs-empty { text-align: center; padding: 30px; color: var(--text-3); font-size: 13px; }

.log-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 4px;
    transition: background 0.2s;
    flex-wrap: wrap;
}

.log-item:hover { background: rgba(255, 255, 255, 0.03); }
.log-item.login_failed, .log-item.login_expired { background: rgba(255, 58, 94, 0.05); }

.log-time { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 11px; min-width: 130px; }
.log-type {
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-elevated);
    font-size: 11px;
    min-width: 100px;
    text-align: center;
}
.log-user { color: var(--text-2); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.log-ip { color: var(--text-4); font-size: 11px; font-family: monospace; }

.admin-select {
    background: var(--bg-elevated);
    color: var(--text-2);
    border: var(--border-2);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.admin-select:focus { border-color: var(--accent); }

.expire-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
}

.expire-text.expired { color: var(--danger); font-weight: 700; }

.expire-text .days-left {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.expire-text.critical .days-left {
    background: rgba(255, 58, 94, 0.2);
    color: var(--danger);
    animation: criticalPulse 2s ease-in-out infinite;
}

.expire-text.warning .days-left {
    background: rgba(255, 184, 0, 0.2);
    color: var(--warning);
}

.expire-text.normal .days-left {
    background: rgba(0, 168, 225, 0.15);
    color: var(--accent-2);
}

@keyframes criticalPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 58, 94, 0); }
    50% { box-shadow: 0 0 0 4px rgba(255, 58, 94, 0.15); }
}

.cinema-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 290;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s var(--ease);
}

body.cinema-mode.player-open .cinema-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

body.cinema-mode.player-open .sidebar,
body.cinema-mode.player-open .topbar {
    opacity: 0.15;
    transition: opacity 0.6s var(--ease);
    pointer-events: none;
}

body.cinema-mode.player-open .sidebar:hover,
body.cinema-mode.player-open .topbar:hover {
    opacity: 1;
    pointer-events: auto;
}

body.cinema-mode.player-open .app { background: #000; }

.skel {
    background: linear-gradient(90deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-1) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
    height: 160px;
    border: var(--border);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.info-btn {
    position: absolute;
    bottom: 8px;
    left: 8px;
    width: 30px;
    height: 30px;
    background: rgba(13, 13, 18, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 700;
    transition: transform 0.2s var(--ease), background 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.card:hover .info-btn { opacity: 1; pointer-events: auto; }
.info-btn:hover { transform: scale(1.15); background: var(--accent); color: white; border-color: var(--accent); }

.continue-preview {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(13,13,18,0.95) 60%, transparent);
    padding: 16px 14px 12px;
    z-index: 2;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s var(--ease), transform 0.3s var(--ease);
    pointer-events: none;
}

.card:hover .continue-preview { opacity: 1; transform: translateY(0); }

.continue-preview-text {
    font-size: 11px;
    color: var(--text-2);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.continue-preview-text .play-icon { color: var(--accent-2); font-size: 13px; }
.continue-preview-time { color: var(--accent-2); font-weight: 800; font-variant-numeric: tabular-nums; }

.remove-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 32px;
    height: 32px;
    background: rgba(13, 13, 18, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 58, 94, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    color: #ff8a9c;
    font-size: 14px;
    font-weight: 700;
    transition: transform 0.2s var(--ease), background 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.card:hover .remove-btn { opacity: 1; pointer-events: auto; }
.remove-btn:hover { transform: scale(1.15); background: var(--danger); color: white; border-color: var(--danger); }

.detalil-modal .modal-content { max-width: 540px; padding: 0; overflow: hidden; }
.detail-content { position: relative; }

.detail-banner {
    width: 100%;
    height: 240px;
    background: linear-gradient(135deg, var(--bg-2), var(--bg-1));
    background-size: cover;
    background-position: center;
    position: relative;
}

.detail-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--bg-1) 5%, transparent 70%);
}

.detail-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
}

.detail-body { padding: 20px 24px 24px; }

.detail-title { font-size: 22px; font-weight: 800; margin-bottom: 10px; letter-spacing: -0.3px; }

.detail-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-3);
}

.detail-meta span { display: inline-flex; align-items: center; gap: 4px; }

.detail-category {
    display: inline-block;
    background: var(--bg-2);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-2);
    margin-bottom: 14px;
}

.detail-desc {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-2);
    margin-bottom: 20px;
}

.detail-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.detail-play {
    flex: 1;
    padding: 12px 20px;
    font-size: 13px;
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.detail-play::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.6s;
}

.detail-play:hover::before { left: 100%; }

.detail-fav {
    width: 44px;
    height: 44px;
    border-radius: 8px;
}

.detail-fav.active { color: #ff4d6d; border-color: rgba(255, 77, 109, 0.4); background: rgba(255, 77, 109, 0.1); }

.detail-episodes {
    max-height: 240px;
    overflow-y: auto;
    border-top: var(--border);
    padding-top: 14px;
}

.detail-episodes h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-2);
}

.detail-ep-item {
    background: var(--bg-2);
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-2);
    transition: background 0.2s, color 0.2s, transform 0.2s, padding 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-ep-item::before { content: '▶'; color: var(--text-3); font-size: 9px; }

.detail-ep-item:hover { background: var(--accent-faint); color: var(--text); transform: translate3d(4px, 0, 0); padding-left: 18px; }
.detail-ep-item:hover::before { color: var(--accent-2); }

.live-log {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 360px;
    max-height: 300px;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    z-index: 150;
    display: flex;
    flex-direction: column;
    animation: fadeUp 0.3s var(--ease);
}

.live-log-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: var(--border);
    font-size: 12px;
    font-weight: 700;
}

.live-log-head button {
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.live-log-head button:hover { color: var(--text); background: rgba(255,255,255,0.05); }

.live-log-content { flex: 1; overflow-y: auto; padding: 8px 14px; font-size: 11px; }

.live-log-item {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    gap: 8px;
    align-items: center;
}

.live-log-time { color: var(--text-4); font-variant-numeric: tabular-nums; min-width: 70px; }
.live-log-msg { color: var(--text-2); flex: 1; }
.live-log-item.log-critical { color: var(--danger); }
.live-log-item.log-info .live-log-msg { color: var(--accent-2); }

/* ==========================================
   RESPONSIVE — MOBILE
   ========================================== */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 200;
        transition: left 0.3s var(--ease);
        box-shadow: 20px 0 60px rgba(0,0,0,0.8);
    }

    .sidebar.open { left: 0; }

    .menu-toggle { display: flex; }

    .menu-item { justify-content: flex-start; padding: 11px 14px; }
    .menu-item .icon { font-size: 18px; }

    .sidebar-categories-wrap { flex: 1; min-height: 0; }
    .sidebar-categories { padding-bottom: 16px; }

    .topbar { padding-left: 70px; }
    .topbar-right { gap: 8px; }

    .view-title { font-size: 17px; }
    .view-meta { font-size: 11px; }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    .card-info { padding: 10px 12px; }
    .card-title { font-size: 12px; min-height: 32px; }
    .card-meta { font-size: 10px; }

    .advanced-search-btn { display: none; }

    .advanced-search.open { max-height: 400px; }

    .adv-search-row { flex-direction: column; gap: 6px; }
    .adv-input, .adv-btn-search { width: 100%; }

    .user-menu-btn { margin-right: 4px; }
    .user-dropdown { width: 240px; right: 0; }

    .modal-content.detail-content {
        max-width: 100%;
        margin: 12px;
        max-height: calc(100vh - 24px);
    }

    .detail-banner { height: 200px; }
    .detail-title { font-size: 18px; }
    .detail-meta { font-size: 11px; }
    .detail-ep-item { font-size: 11px; padding: 8px 12px; }

    .drawer { width: 100%; }
    .epg-panel { width: 100%; }
    .notif-panel { width: 100%; }

    .status-pill { padding: 5px 10px; font-size: 10px; }
    .toast { font-size: 12px; min-width: 200px; }

    .live-log {
        width: calc(100vw - 20px);
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    /* Ajustes del reproductor en móvil */
    .player-layer { padding: 10px 12px; }
    .player-head { margin-bottom: 8px; }
    .player-head h2 { font-size: 14px; }
    .player-sub { font-size: 10px; }
    
    .player-progress { gap: 8px; font-size: 10px; }
    .player-progress-bar { height: 6px; } /* Más gruesa para tactil */
    .player-progress-handle { opacity: 1; width: 14px; height: 14px; } /* Siempre visible en móvil */
    
    .btn-control-player { width: 34px; height: 34px; font-size: 12px; }
    .btn-epg, .btn-fav-player, .btn-volume-player, .btn-fs-player { padding: 6px 10px; font-size: 11px; }
    .btn-close { padding: 6px 10px; font-size: 11px; }
}

@media (max-width: 480px) {
    .topbar { padding: 12px 16px 12px 64px; }
    .view-title { font-size: 15px; }
    .view-meta { font-size: 10px; }

    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .card-info { padding: 8px 10px; }
    .card-title { font-size: 11px; min-height: 30px; }
    .card-meta { font-size: 9px; }

    .fav-btn, .info-btn, .remove-btn { width: 28px; height: 28px; }
    .fav-btn svg { width: 14px; height: 14px; }
    .info-btn { font-size: 11px; }
    .tag { font-size: 8px; padding: 2px 6px; }
}

/* ==========================================
   TOGGLE PASSWORD VISIBILITY (BOTÓN DE OJO)
   ========================================== */
.auth-field-password {
    position: relative;
}
.auth-field-password input {
    padding-right: 44px !important;
}
.toggle-password {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.2s ease, background 0.2s ease;
    height: 70%;
    z-index: 5;
}
.toggle-password:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.05);
}
.toggle-password:focus {
    outline: none;
    color: var(--primary, #00d4ff);
}
.toggle-password.active {
    color: var(--primary, #00d4ff);
}
.toggle-password svg {
    display: block;
}

/* ==========================================
   CONTROLES PERSONALIZADOS DEL VIDEO
   (Reemplazan los controles nativos que
    mostraban la barra de progreso en vivo)
   ========================================== */

.player-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#video-core {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Contenedor de controles personalizados */
.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
    padding: 16px 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.player-viewport:hover .video-controls,
.player-viewport.show-controls .video-controls {
    opacity: 1;
    pointer-events: auto;
}

.video-controls-row {
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
}

.video-controls-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.video-controls-btn:hover {
    background: rgba(255,255,255,0.15);
}

.video-controls-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.video-volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.video-volume-slider {
    width: 80px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.video-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}

.video-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.video-time-display {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.95);
    font-variant-numeric: tabular-nums;
    min-width: 100px;
}

.video-live-badge {
    background: #ef4444;
    color: #fff;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.video-live-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    animation: livePulse 1.5s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.video-spacer {
    flex: 1;
}

/* ===== Barra de progreso: SOLO visible para VOD ===== */
.video-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    transition: height 0.15s;
}

.video-progress-bar:hover {
    height: 6px;
}

.video-progress-filled {
    height: 100%;
    background: linear-gradient(to right, #6366f1, #8b5cf6);
    border-radius: 2px;
    position: relative;
    width: 0%;
}

.video-progress-handle {
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.video-progress-bar:hover .video-progress-handle {
    opacity: 1;
}

/* ===== Mantener aspect ratio en live ===== */
.player-viewport .video-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.player-viewport-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}
#video-core {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
}
.custom-controls {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.player-viewport-wrap:hover .custom-controls,
.player-viewport-wrap.show-controls .custom-controls,
.player-viewport-wrap.paused .custom-controls {
    opacity: 1;
}
.cc-play-pause {
    pointer-events: auto;
    background: rgba(0,0,0,0.6);
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 80px;
}
.cc-play-pause:hover { background: rgba(99,102,241,0.9); transform: scale(1.1); }
.cc-play-pause:active { transform: scale(0.95); }
.cc-bottom-bar {
    pointer-events: auto;
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}
.cc-time {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.95);
    font-variant-numeric: tabular-nums;
    min-width: 90px;
}
.cc-spacer { flex: 1; }
.cc-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}
.cc-btn:hover { background: rgba(255,255,255,0.15); }
.cc-btn:active { background: rgba(255,255,255,0.25); }
.cc-volume-slider {
    width: 90px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}
.cc-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}
.cc-volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}
@media (max-width: 768px) {
    .cc-bottom-bar { padding: 16px 14px 12px; }
    .cc-volume-slider { width: 60px; }
    .cc-play-pause { width: 70px; height: 70px; }
}
/* Botones de volumen y fullscreen en el header del reproductor */
.btn-volume-player, .btn-fs-player {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-volume-player:hover, .btn-fs-player:hover {
    background: rgba(255,255,255,0.18);
    transform: scale(1.05);
}
.btn-volume-player:active, .btn-fs-player:active {
    transform: scale(0.95);
}
/* ✅ Auto-hide del header del reproductor */
.player-layer .player-head {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.player-layer:not(.show-header) .player-head {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.player-layer.show-header .player-head {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
/* Ocultar barra de controles nativos del navegador en pantalla completa */
video::-webkit-media-controls {
    display: none !important;
}
video::-webkit-media-controls-enclosure {
    display: none !important;
}
video::-webkit-media-controls-panel {
    display: none !important;
}
video::-webkit-media-controls-playback-button {
    display: none !important;
}
video::-webkit-media-controls-timeline {
    display: none !important;
}
video::-internal-media-controls-download-button {
    display: none !important;
}

/* Auto-hide del header del reproductor */
.player-layer .player-head {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.player-layer:not(.show-header) .player-head {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}
.player-layer.show-header .player-head {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Botones de volumen y fullscreen */
.btn-volume-player, .btn-fs-player {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-volume-player:hover, .btn-fs-player:hover {
    background: rgba(255,255,255,0.18);
    transform: scale(1.05);
}

/* Video en pantalla completa ocupa todo */
video:-webkit-full-screen {
    width: 100% !important;
    height: 100% !important;
}
video:fullscreen {
    width: 100% !important;
    height: 100% !important;
}