:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --page-bg: linear-gradient(135deg, #020617 0%, #111827 100%);
    --surface: #111827;
    --surface-strong: #0f172a;
    --shadow: 0 25px 50px -12px rgba(2, 6, 23, 0.55);
}

body.light-theme {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-dark: #f3f6ff;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #475569;
    --glass: rgba(79, 70, 229, 0.08);
    --glass-border: rgba(15, 23, 42, 0.08);
    --page-bg: linear-gradient(135deg, #f8fbff 0%, #eef2ff 100%);
    --surface: #f8fbff;
    --surface-strong: #ffffff;
    --shadow: 0 24px 54px -20px rgba(79, 70, 229, 0.25);
}

body.dark-theme {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --bg-dark: #050816;
    --card-bg: #111827;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass: rgba(129, 140, 248, 0.12);
    --glass-border: rgba(148, 163, 184, 0.18);
    --page-bg: linear-gradient(135deg, #040816 0%, #0f172a 100%);
    --surface: #0f172a;
    --surface-strong: #111827;
    --shadow: 0 20px 48px -22px rgba(2, 6, 23, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--page-bg);
    color: var(--text-main);
    min-height: 100vh;
    padding: 24px;
}

body.dark-theme .sidebar,
body.dark-theme .main-panel,
body.dark-theme .manage-card,
body.dark-theme .library-card,
body.dark-theme .upload-card,
body.dark-theme .table-responsive,
body.dark-theme .stat-card,
body.dark-theme .modal-card {
    background-color: var(--card-bg);
    color: var(--text-main);
}

body.dark-theme .table-responsive,
body.dark-theme .manage-card,
body.dark-theme .library-card,
body.dark-theme .upload-card,
body.dark-theme .stat-card,
body.dark-theme .modal-card {
    background-image: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: calc(100vh - 48px);
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    overflow: hidden;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

body.light-theme .app-shell {
    background: rgba(255, 255, 255, 0.65);
}

.sidebar {
    background: var(--surface-strong);
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    border-right: 1px solid var(--glass-border);
}

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

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    font-weight: 800;
}

.sidebar-brand h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.sidebar-brand h1 span {
    color: var(--primary);
}

.sidebar-brand p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 2px;
}

.main-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: rgba(15, 23, 42, 0.6);
}

body.light-theme .main-panel {
    background: rgba(255, 255, 255, 0.38);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px 18px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.72);
}

body.light-theme .topbar {
    background: rgba(255, 255, 255, 0.2);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.72rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 6px;
}

.topbar h2 {
    font-size: 1.35rem;
    font-weight: 800;
}

main {
    padding: 24px 28px 28px;
    flex: 1;
}

.sidebar-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.theme-toggle,
.ghost-btn {
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.ghost-btn {
    justify-content: center;
}

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-btn {
    text-align: left;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    padding: 12px 14px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.nav-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(129, 140, 248, 0.12));
    color: var(--text-main);
    border-color: rgba(99, 102, 241, 0.24);
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
    font-size: 0.8rem;
    font-weight: 700;
}

.status-pill-soft {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.2);
}

/* Upload Card Styling */
.upload-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}

.drop-zone {
    border: 2px dashed var(--glass-border);
    border-radius: 16px;
    padding: 40px 18px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--glass);
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.drop-zone:hover {
    border-color: var(--primary);
    background: var(--glass);
}

.drop-zone .icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

/* File Info & Button */
.file-info {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--glass);
    padding: 15px 20px;
    border-radius: 12px;
}

#upload-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

#upload-btn:hover {
    background: var(--primary-hover);
}

/* Progress Bar */
.progress-container {
    margin-top: 25px;
    display: grid;
    gap: 14px;
}

.progress-group {
    display: grid;
    gap: 8px;
}

.progress-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.progress-bar {
    background: var(--glass);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.upload-fill {
    background: var(--primary);
}

.conversion-fill {
    background: #14b8a6;
}

#status-text {
    margin-top: 4px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
}

.user-meta-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.user-phone-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.badge-green {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(34, 197, 94, 0.25);
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-red {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(248, 113, 113, 0.25);
    background: rgba(248, 113, 113, 0.12);
    color: #f87171;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Player Card */
.player-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 30px;
    border: 1px solid var(--glass-border);
    animation: slideUp 0.6s ease-out;
}

.player-card h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.video-wrapper {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

video {
    width: 100%;
    height: 100%;
}

.stream-info {
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--text-muted);
    word-break: break-all;
}

#stream-url {
    color: var(--primary);
    font-family: monospace;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.view.active {
    display: block;
}

.upload-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}

#course-select {
    flex: 1 1 220px;
    min-width: 0;
}

#upload-btn {
    flex: 0 0 auto;
}

#category-select, #course-select, #sub-user, #sub-session {
    background: var(--bg-dark);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 10px;
    border-radius: 8px;
    outline: none;
}

.manage-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 24px;
    border: 1px solid var(--glass-border);
    margin-top: 24px;
    box-shadow: var(--shadow);
}

.management-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.form-box {
    background: var(--glass);
    padding: 20px;
    border-radius: 16px;
}

.form-box h3, .table-container h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--primary);
}

form input, form select {
    width: 100%;
    margin-bottom: 15px;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 8px;
}

form textarea {
    width: 100%;
    margin-bottom: 15px;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 8px;
    resize: vertical;
    min-height: 92px;
}

form button {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.data-list {
    list-style: none;
    margin-top: 20px;
}

.data-list li {
    background: var(--glass);
    padding: 12px 20px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.inline-form {
    display: flex;
    gap: 10px;
}

.inline-form input { margin-bottom: 0; }
.inline-form button { width: auto; }

.library-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(248,250,252,0.9));
    border-radius: 24px;
    padding: 24px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 18px 40px -24px rgba(15, 23, 42, 0.28);
}

body.light-theme .library-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

body.dark-theme .library-card,
body.dark-theme .media-library-card,
body:not(.light-theme) .library-card,
body:not(.light-theme) .media-library-card {
    background: var(--card-bg);
    border-color: var(--glass-border);
    box-shadow: none;
}

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

#search-input {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 10px;
    outline: none;
    width: 250px;
    transition: border-color 0.3s;
}

.video-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.video-item {
    background: var(--glass);
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.video-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    transform: translateY(-3px);
}

.video-item .name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.play-btn { color: var(--primary); font-size: 0.8rem; font-weight: 600; }

.delete-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.delete-btn:hover { background: #ef4444; color: white; }

.empty-msg { color: var(--text-muted); text-align: center; grid-column: 1 / -1; padding: 20px; }

footer {
    text-align: center;
    margin-top: 40px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

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

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

/* Media layout */
.media-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.media-library-card {
    min-width: 0;
}

.media-tabs {
    display: inline-flex;
    gap: 8px;
    margin-bottom: 18px;
}

.media-tab {
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
}

.media-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.media-tab-panel {
    display: none;
}

.media-tab-panel.active {
    display: block;
}

.section-kicker {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 4px;
}

.compact-header {
    margin-bottom: 12px;
    padding-bottom: 0;
    border-bottom: none;
}

.media-side-card {
    position: static;
    top: auto;
    width: 100%;
    overflow: visible;
}

.player-card {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
}

.player-card-head {
    margin-bottom: 16px;
}

.login-card {
    max-width: 420px;
}

/* Responsive */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }

    .media-layout {
        grid-template-columns: 1fr;
    }

    .media-side-card {
        position: static;
    }
}

@media (max-width: 600px) {
    body { padding: 12px; }
    .app-shell { min-height: calc(100vh - 24px); border-radius: 24px; }
    .topbar, main { padding-left: 18px; padding-right: 18px; }
    .upload-card, .player-card { padding: 20px; }
}

/* --- ADMIN DASHBOARD AND TABLE STYLES --- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 30px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(99, 102, 241, 0.4);
}

.stat-icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.6rem;
}

.user-icon {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.sub-icon {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.session-icon {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

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

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 4px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--glass-border);
}

.analytics-shell {
    padding: 24px;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(15, 23, 42, 0.66));
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.analytics-card {
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 18px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.82), rgba(2, 6, 23, 0.7));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.analytics-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.analytics-card h3 {
    font-size: 1rem;
    font-weight: 700;
}

.analytics-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.16);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
}

.analytics-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.analytics-bar-row {
    display: grid;
    grid-template-columns: 70px 1fr auto;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.analytics-bar-row strong {
    color: var(--text-main);
    font-weight: 700;
    min-width: 34px;
    text-align: right;
}

.analytics-bar-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
    overflow: hidden;
    min-width: 0;
}

.analytics-bar-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    transition: width 0.3s ease;
}

.analytics-bar-fill.alt {
    background: linear-gradient(90deg, #38bdf8, #818cf8);
}

.analytics-bar-fill.accent {
    background: linear-gradient(90deg, #34d399, #10b981);
}

.analytics-trends {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.analytics-chart-card {
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 18px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.85), rgba(2, 6, 23, 0.72));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.trend-toggle-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.trend-toggle {
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    padding: 7px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
}

.trend-toggle.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.analytics-chart-area {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.12), transparent 45%), rgba(255,255,255,0.03);
    padding: 10px;
}

.trend-svg {
    width: 100%;
    height: 180px;
}

.chart-label {
    fill: var(--text-muted);
    font-size: 9px;
    font-family: 'Inter', sans-serif;
}

.analytics-chart-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.chart-empty {
    color: var(--text-muted);
    font-size: 0.95rem;
}

body.light-theme .analytics-chart-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 252, 0.92));
}

body.light-theme .analytics-chart-area {
    background: radial-gradient(circle at top left, rgba(79, 70, 229, 0.1), transparent 40%), rgba(15, 23, 42, 0.02);
}

body.light-theme .analytics-shell {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(248, 250, 252, 0.95));
}

body.light-theme .analytics-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.92));
}

.dashboard-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.search-box-wrapper {
    position: relative;
    min-width: 0;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.search-box-wrapper input {
    display: block;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 16px 12px 40px;
    border-radius: 10px;
    outline: none;
    width: 260px;
    max-width: 100%;
    min-height: 44px;
    margin: 0;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.search-box-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.course-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 16px;
    align-items: end;
    margin-bottom: 24px;
}

.course-form-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.course-form .form-group {
    margin-bottom: 0;
}

.course-form input,
.course-form select,
.course-form textarea {
    margin-bottom: 0;
}

.course-description-field {
    grid-column: 1 / 4;
}

.course-form button {
    width: auto;
    min-width: 140px;
}

.course-info-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 260px;
}

.course-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    flex: 0 0 auto;
}

.course-thumb-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex: 0 0 auto;
}

.course-title-text {
    display: block;
    font-weight: 700;
    color: var(--text-main);
}

.course-description-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 4px;
    max-width: 420px;
    line-height: 1.35;
}

.action-btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.action-btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Table Design */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.94));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

body.light-theme .table-responsive {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

body.dark-theme .table-responsive,
body:not(.light-theme) .table-responsive {
    background: var(--card-bg);
    border-color: var(--glass-border);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

.admin-table th {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(129, 140, 248, 0.06));
    color: var(--text-muted);
    font-weight: 700;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

body.dark-theme .admin-table th,
body:not(.light-theme) .admin-table th {
    background: rgba(99, 102, 241, 0.14);
    color: var(--text-muted);
}

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

.admin-table tbody tr {
    transition: background-color 0.2s ease;
}

.admin-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.06), rgba(129, 140, 248, 0.03));
}

body.dark-theme .admin-table tbody tr:hover,
body:not(.light-theme) .admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.table-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
    font-style: italic;
}

/* User Info Cell */
.user-info-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    color: white;
    font-weight: 800;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.95rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name-text {
    font-weight: 600;
    color: var(--text-main);
}

.user-email-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Badges */
.badge-purple {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

/* Row Actions */
.row-actions {
    display: flex;
    gap: 8px;
}

.btn-row-action {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(129, 140, 248, 0.08));
    border: 1px solid rgba(79, 70, 229, 0.16);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.btn-row-action:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-row-delete {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.btn-row-delete:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

/* Pagination container */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination-buttons {
    display: flex;
    gap: 6px;
}

.page-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.page-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: var(--text-muted);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

/* Modal Overlay Styling */
.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 1000;
    animation: fadeInModal 0.25s ease-out;
}

.modal-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    width: min(100%, 520px);
    max-width: 520px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    min-height: 0;
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    animation: scaleUpModal 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin: auto;
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

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

.modal-close:hover {
    color: #ef4444;
}

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.modal-card > form {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#course-lessons-modal .modal-card {
    width: min(760px, calc(100vw - 32px));
    height: min(720px, calc(100dvh - 48px));
}

#course-lessons-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

#course-lessons-modal .modal-inline-form {
    flex: 0 0 auto;
    margin-bottom: 0;
}

#course-lessons-modal .modal-table-container {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-group input, .form-group select {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group textarea {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
}

.submit-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.submit-btn:hover {
    background: var(--primary-hover);
}

.community-form {
    display: grid;
    gap: 16px;
    padding: 20px;
    border: 1px solid var(--glass-border);
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(15, 23, 42, 0.78));
    margin-bottom: 20px;
}

.community-form .form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.community-form .form-actions button {
    width: 100%;
    justify-content: center;
}

#community-view .row-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

#community-view .btn-row-action {
    width: 100%;
}

.community-post-cell {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.community-post-cell strong {
    color: var(--text-main);
}

.community-post-cell span,
.community-post-cell small {
    color: var(--text-muted);
    line-height: 1.45;
}

.community-post-title-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.community-post-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.community-post-body {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    color: var(--text-main);
    line-height: 1.45;
}

.community-likes-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    font-weight: 700;
}

/* Modal Inline Form (Subscriptions) */
.modal-inline-form {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.modal-inline-form .select-wrapper {
    flex-grow: 1;
}

.modal-inline-form select {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 10px;
    outline: none;
    font-size: 0.9rem;
}

.modal-inline-form select:focus {
    border-color: var(--primary);
}

.modal-action-btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.modal-action-btn-primary:hover {
    background: var(--primary-hover);
}

/* Modal Internal Table */
.modal-table-container {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.3);
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.modal-table th {
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 1px solid var(--glass-border);
    text-align: left;
}

.modal-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-main);
}

.modal-table tbody tr:last-child td {
    border-bottom: none;
}

.modal-body h4 {
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Animations */
@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Extra Mobile Adjustments */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dashboard-actions {
        width: 100%;
    }
    
    .search-box-wrapper,
    .search-box-wrapper input {
        width: 100%;
    }
    
    .action-btn-primary {
        width: 100%;
        text-align: center;
    }

    .analytics-grid,
    .analytics-trends {
        grid-template-columns: 1fr;
    }

    .course-form {
        grid-template-columns: 1fr;
    }

    .course-description-field {
        grid-column: auto;
    }
}

@media (max-width: 900px) {
    body {
        padding: 12px;
    }

    .app-shell {
        min-height: calc(100vh - 24px);
        min-height: calc(100dvh - 24px);
        grid-template-columns: minmax(0, 1fr);
        border-radius: 22px;
    }

    .sidebar {
        padding: 16px;
        gap: 14px;
    }

    .main-nav {
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        padding-bottom: 4px;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .nav-btn {
        flex: 0 0 auto;
        min-height: 44px;
        white-space: nowrap;
    }

    .sidebar-footer {
        flex-direction: row;
        align-items: center;
        margin-top: 0;
    }

    .sidebar-footer .status-pill {
        flex: 1 1 auto;
    }

    .topbar {
        padding: 18px 20px 16px;
    }

    main {
        padding: 20px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 0;
    }

    .app-shell {
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .sidebar {
        padding: 12px 14px 10px;
        gap: 10px;
    }

    .brand-mark {
        width: 40px;
        height: 40px;
    }

    .sidebar-brand p {
        font-size: 0.78rem;
    }

    .sidebar-controls,
    .theme-toggle,
    .ghost-btn {
        width: 100%;
        min-height: 44px;
    }

    .nav-btn {
        padding: 10px 12px;
    }

    .sidebar-footer .status-pill {
        min-width: 0;
        padding: 8px;
        font-size: 0.72rem;
        text-align: center;
    }

    .sidebar-footer .ghost-btn {
        width: auto;
        flex: 0 0 auto;
        padding: 10px 14px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 16px 16px 14px;
    }

    .topbar h2 {
        font-size: 1.15rem;
        line-height: 1.3;
    }

    .topbar-actions {
        width: 100%;
    }

    main {
        padding: 16px 14px 24px;
    }

    .manage-card,
    .library-card,
    .upload-card,
    .player-card {
        padding: 16px;
        border-radius: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-top: 16px;
        margin-bottom: 16px;
    }

    .stat-card {
        min-width: 0;
        gap: 10px;
        padding: 12px;
        border-radius: 12px;
    }

    .stat-icon-wrapper {
        width: 38px;
        height: 38px;
        flex: 0 0 38px;
        border-radius: 10px;
        font-size: 1.15rem;
    }

    .stat-label {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .stat-value {
        font-size: 1.15rem;
    }

    .dashboard-header {
        gap: 14px;
        margin-bottom: 16px;
    }

    .dashboard-header h2 {
        font-size: 1.1rem;
    }

    .dashboard-actions {
        align-items: stretch;
        gap: 10px;
    }

    .dashboard-actions > * {
        min-width: 0;
    }

    .action-btn-primary,
    .submit-btn,
    .modal-action-btn-primary {
        min-height: 46px;
    }

    .trend-toggle-group {
        max-width: 100%;
        overflow-x: auto;
    }

    .trend-toggle {
        flex: 0 0 auto;
        min-height: 40px;
    }

    .media-tabs {
        display: flex;
        width: 100%;
    }

    .media-tab {
        flex: 1 1 0;
        min-height: 44px;
    }

    .table-responsive {
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .admin-table {
        min-width: 600px;
    }

    .pagination-container {
        align-items: flex-start;
        gap: 10px;
    }

    .pagination-buttons {
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .page-btn {
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .modal-overlay {
        align-items: center;
        padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
    }

    .modal-card {
        width: min(100%, 560px);
        max-width: none;
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        margin: auto;
        border-radius: 16px;
        animation: scaleUpModal 0.22s ease-out;
    }

    .modal-card > form,
    .modal-card > .modal-body {
        min-height: 0;
        flex: 1 1 auto;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .modal-card > form {
        padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
    }

    .modal-header {
        gap: 12px;
        padding: 14px 16px;
    }

    .modal-header h3 {
        min-width: 0;
        font-size: 1.05rem;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .modal-close {
        display: grid;
        place-items: center;
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        border-radius: 10px;
        font-size: 1.6rem;
        touch-action: manipulation;
    }

    .modal-body {
        padding: 18px;
    }

    #course-lessons-modal .modal-card {
        width: min(100%, 720px);
        height: min(680px, calc(100dvh - 32px));
        max-height: calc(100dvh - 32px);
    }

    #course-lessons-modal .modal-body {
        overflow: hidden;
    }

    .modal-body .form-group {
        margin-bottom: 16px;
    }

    .modal-inline-form {
        flex-direction: column;
        gap: 10px;
    }

    .modal-inline-form select,
    .modal-action-btn-primary {
        width: 100%;
        min-height: 46px;
    }

    .modal-table-container {
        max-height: min(35dvh, 250px);
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    #course-lessons-modal .modal-table-container {
        max-height: none;
    }

    .modal-table {
        min-width: 420px;
    }

    .modal-table th,
    .modal-table td {
        padding: 10px;
    }

    .login-card {
        align-self: center;
    }
}

@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 14px;
    }

    .sidebar-brand h1 {
        font-size: 1rem;
    }

    .modal-body,
    .modal-card > form {
        padding-left: 14px;
        padding-right: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal-card {
        animation: none;
    }
}

.subscription-admin-card {
    display: grid;
    gap: 18px;
}

.subscription-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    border-bottom: 1px solid var(--glass-border);
}

.subscription-tab {
    min-height: 42px;
    flex: 0 0 auto;
    padding: 0 14px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
}

.subscription-tab.active {
    border-bottom-color: var(--primary);
    color: var(--text-main);
}

.subscription-panel[hidden] {
    display: none;
}

.subscription-panel {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.subscription-grant-form {
    display: grid;
    grid-template-columns: minmax(150px, 1.2fr) minmax(150px, 1.2fr) minmax(110px, .65fr) auto;
    align-items: end;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
}

.subscription-grant-form .form-group {
    margin: 0;
}

.subscription-grant-form .action-btn-primary {
    min-height: 44px;
    white-space: nowrap;
}

.subscription-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.subscription-toolbar > select {
    width: auto;
    min-width: 150px;
    margin: 0;
}

.subscription-toolbar .search-box-wrapper {
    flex: 1;
    max-width: 420px;
}

.subscription-toolbar .search-box-wrapper input {
    width: 100%;
    padding-left: 40px;
}

.subscription-toolbar .search-icon {
    pointer-events: none;
    z-index: 1;
}

.subscription-table {
    min-width: 900px;
}

.subscription-cell-main {
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.subscription-cell-main strong {
    color: var(--text-main);
    font-size: .86rem;
}

.subscription-cell-main span,
.subscription-cell-meta {
    color: var(--text-muted);
    font-size: .76rem;
}

.subscription-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.subscription-days-input {
    width: 76px;
    min-height: 34px;
    margin: 0;
    padding: 6px 8px;
}

.subscription-actions .btn-row-action {
    padding: 7px 9px;
}

.subscription-actions .btn-row-delete {
    color: #ef4444;
}

.subscription-admin-message {
    min-height: 18px;
    margin: 0;
    color: var(--text-muted);
    font-size: .85rem;
}

.refund-provider-note {
    margin: 0;
    padding: 12px 14px;
    border-left: 3px solid #d38a30;
    background: rgba(211, 138, 48, .1);
    color: var(--text-muted);
    font-size: .85rem;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .subscription-grant-form {
        grid-template-columns: 1fr 1fr;
    }

    .subscription-grant-form .action-btn-primary {
        grid-column: 1 / -1;
    }

    .subscription-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .subscription-toolbar > select,
    .subscription-toolbar .search-box-wrapper {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 420px) {
    .subscription-grant-form {
        grid-template-columns: 1fr;
    }

    .subscription-grant-form .action-btn-primary {
        grid-column: auto;
    }
}
