/* ═══════════════════════════════════════════════════════════
   IPTV Master — Premium Mobile-First Responsive Design
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS Variables ─────────────────────────────────────── */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card2: #162032;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --glass: rgba(30, 41, 59, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
    --sidebar-w: 260px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ─────────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInL {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideInR {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes modalIn {
    from {
        transform: scale(0.92) translateY(20px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.35s ease-out forwards;
}

.spin {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ════════════════════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════════════════════ */
#login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: radial-gradient(ellipse at 70% 20%, rgba(99, 102, 241, 0.18) 0%, transparent 50%),
        radial-gradient(ellipse at 20% 80%, rgba(139, 92, 246, 0.12) 0%, transparent 50%),
        var(--bg-dark);
}

.login-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: clamp(1.75rem, 5vw, 2.75rem);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.login-card h1 {
    font-size: clamp(1.5rem, 4vw, 1.875rem);
    font-weight: 800;
    margin-bottom: 0.35rem;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* ─── Forms ──────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
    background: rgba(15, 23, 42, 0.8);
}

.form-group select option {
    background: #1e293b;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
    width: 100%;
    padding: 0.8rem 1.25rem;
    border-radius: var(--radius);
    border: none;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ════════════════════════════════════════════════════════════
   DASHBOARD LAYOUT
   ════════════════════════════════════════════════════════════ */
#dashboard-container {
    display: none;
    height: 100vh;
    overflow: hidden;
}

/* On desktop: side-by-side */
@media (min-width: 768px) {
    #dashboard-container {
        display: grid !important;
        grid-template-columns: var(--sidebar-w) 1fr;
        grid-template-rows: 100vh;
    }
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--glass-border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    z-index: 300;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile: sidebar is fixed off-screen */
@media (max-width: 767px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(var(--sidebar-w), 80vw);
        height: 100%;
        transform: translateX(-100%);
        z-index: 500;
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(0);
        animation: slideInL 0.3s ease;
    }
}

/* Sidebar overlay (mobile) */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    z-index: 400;
}

#sidebar-overlay.show {
    display: block;
}

.sidebar .logo {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 1.75rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 0.5rem;
    flex-shrink: 0;
}

.nav-menu {
    list-style: none;
    flex: 1;
}

.nav-item {
    margin-bottom: 0.3rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    transition: var(--transition);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    user-select: none;
}

.nav-link i {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
}

.nav-link.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

/* ─── Main Content ───────────────────────────────────────── */
.main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 2.5rem);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ─── Top Bar ────────────────────────────────────────────── */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 0.75rem;
    flex-shrink: 0;
}

.top-bar h2 {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    font-weight: 700;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Hamburger button (mobile only) */
#hamburger-btn {
    display: none;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--primary);
    border-radius: var(--radius);
    padding: 0.5rem 0.7rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
}

#hamburger-btn:hover {
    background: rgba(99, 102, 241, 0.25);
}

@media (max-width: 767px) {
    #hamburger-btn {
        display: flex;
        align-items: center;
    }

    #server-status-badge {
        display: none;
    }

    #admin-username {
        display: none;
    }

    .user-info>div:last-child {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

/* ════════════════════════════════════════════════════════════
   STATS GRID
   ════════════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
}

.stat-card {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.04;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card .label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
}

.stat-card .value {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 800;
}

/* ════════════════════════════════════════════════════════════
   TABLES (mobile scrollable)
   ════════════════════════════════════════════════════════════ */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 550px;
    /* Force scroll below this width */
}

th {
    background: rgba(15, 23, 42, 0.4);
    text-align: left;
    padding: 0.875rem 1.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    white-space: nowrap;
    font-weight: 700;
}

td {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.875rem;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* ─── Status Badges ──────────────────────────────────────── */
.status-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-active {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent);
}

.status-inactive {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.status-banned {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.status-expired {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.status-disabled {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-muted);
}

/* ─── Stream indicators ──────────────────────────────────── */
.indicator {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.indicator-online {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
    animation: pulse 2s infinite;
}

.indicator-offline {
    background: var(--danger);
}

/* ════════════════════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════════════════════ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (max-width: 600px) {
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 92vh;
        animation: slideInR 0.3s ease;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 10;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.close-modal {
    cursor: pointer;
    font-size: 1.4rem;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: var(--transition);
    line-height: 1;
}

.close-modal:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

#modal-body {
    padding: 1.5rem;
}

/* ════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ════════════════════════════════════════════════════════════ */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 580px) {
    .flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .flex-between>* {
        width: 100%;
    }

    .flex-between>div[style*="display:flex"],
    .flex-between>div[style*="display: flex"] {
        width: 100%;
        flex-wrap: wrap;
    }
}

.mb-4 {
    margin-bottom: 1rem;
}

.gap-2 {
    gap: 0.5rem;
}

/* ─── Search Bar ─────────────────────────────────────────── */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    flex: 1;
    min-width: 0;
    max-width: 380px;
}

.search-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}

.search-container i {
    padding-left: 0.9rem;
    color: var(--text-muted);
    font-size: 13px;
    flex-shrink: 0;
}

.search-container input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    padding: 0.65rem 0.9rem;
    font-size: 0.875rem;
    width: 100%;
}

@media (max-width: 580px) {
    .search-container {
        max-width: 100%;
    }
}

/* ─── Charts ─────────────────────────────────────────────── */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

@media (max-width: 640px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    position: relative;
    height: 280px;
}

.chart-card h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── Stream status ──────────────────────────────────────── */
.stream-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ─── Video Preview ──────────────────────────────────────── */
#video-preview {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 10px;
    background: #000;
}

/* ════════════════════════════════════════════════════════════
   CONTENT TYPE TABS
   ════════════════════════════════════════════════════════════ */
.type-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.75rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.type-tabs::-webkit-scrollbar {
    display: none;
}

.type-tab {
    padding: 0.4rem 1rem;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    color: var(--text-muted);
    transition: var(--transition);
    background: transparent;
    white-space: nowrap;
    flex-shrink: 0;
}

.type-tab:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #fff;
}

.type-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

/* ─── Type Badges ────────────────────────────────────────── */
.type-badge-live {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
}

.type-badge-movie {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
}

.type-badge-series {
    background: rgba(236, 72, 153, 0.15);
    color: #ec4899;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
}

/* ════════════════════════════════════════════════════════════
   PLAYLIST CARDS
   ════════════════════════════════════════════════════════════ */
.playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

@media (max-width: 640px) {
    .playlist-grid {
        grid-template-columns: 1fr;
    }
}

.playlist-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.35rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.playlist-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
}

.playlist-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    border-color: rgba(99, 102, 241, 0.4);
}

.playlist-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.playlist-stat-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.playlist-stat {
    text-align: center;
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 0.5rem 0.25rem;
}

.playlist-stat .n {
    font-size: 1.1rem;
    font-weight: 800;
}

.playlist-stat .l {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ════════════════════════════════════════════════════════════
   CHANNEL CARD GRID
   ════════════════════════════════════════════════════════════ */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.9rem;
}

@media (max-width: 480px) {
    .channel-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.7rem;
    }
}

.channel-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.channel-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.channel-card img {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    object-fit: contain;
    background: #000;
    margin-bottom: 0.5rem;
}

.channel-card .name {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-card .actions {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 0.65rem;
}

.channel-card-online {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ════════════════════════════════════════════════════════════
   BACKUP CARDS
   ════════════════════════════════════════════════════════════ */
.backup-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: var(--transition);
    flex-wrap: wrap;
}

.backup-card:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* ════════════════════════════════════════════════════════════
   PROGRESS BAR
   ════════════════════════════════════════════════════════════ */
.progress-wrap {
    background: rgba(255, 255, 255, 0.07);
    border-radius: 99px;
    height: 7px;
    overflow: hidden;
    margin: 0.65rem 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    border-radius: 99px;
    transition: width 0.4s ease;
}

/* ════════════════════════════════════════════════════════════
   SEARCH DROPDOWN
   ════════════════════════════════════════════════════════════ */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--glass-border);
    transition: background 0.15s;
    font-size: 13px;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(99, 102, 241, 0.14);
}

.search-result-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════
   VIEW TOGGLE
   ════════════════════════════════════════════════════════════ */
.view-toggle {
    display: flex;
    gap: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 3px;
}

.view-toggle button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 9px;
    border-radius: 6px;
    font-size: 12px;
    transition: var(--transition);
}

.view-toggle button.active {
    background: var(--primary);
    color: #fff;
}

/* ════════════════════════════════════════════════════════════
   PREVIEW PANEL
   ════════════════════════════════════════════════════════════ */
.preview-panel {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-top: 1.25rem;
    animation: fadeIn 0.3s ease;
}

.preview-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    flex-wrap: wrap;
    gap: 0.75rem;
}

@media (max-width: 580px) {
    .preview-panel-header>div:last-child {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* ════════════════════════════════════════════════════════════
   TOGGLE SWITCH
   ════════════════════════════════════════════════════════════ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #334155;
    border-radius: 34px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(18px);
}

/* ════════════════════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════════════════════ */
#toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-left: 4px solid var(--primary);
    color: #fff;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    z-index: 9999;
    transform: translateY(120px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: min(340px, calc(100vw - 2rem));
    width: max-content;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    word-break: break-word;
}

@media (max-width: 480px) {
    #toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        max-width: 100%;
        width: auto;
    }
}

#toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ════════════════════════════════════════════════════════════
   LIGHT MODE
   ════════════════════════════════════════════════════════════ */
body.light-mode {
    --bg-dark: #f1f5f9;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --glass: rgba(255, 255, 255, 0.88);
    --glass-border: rgba(0, 0, 0, 0.09);
}

body.light-mode .sidebar {
    background: #1e293b;
}

body.light-mode .top-bar {
    background: var(--bg-dark);
}

body.light-mode table th {
    background: #f1f5f9;
    color: #475569;
}

body.light-mode td {
    border-color: #e2e8f0;
}

body.light-mode code {
    background: rgba(0, 0, 0, 0.07) !important;
    color: #1e293b !important;
}

body.light-mode .form-group input,
body.light-mode .form-group select,
body.light-mode .form-group textarea {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}

body.light-mode #toast {
    background: #fff;
    color: #1e293b;
}

/* ════════════════════════════════════════════════════════════
   ACTIVITY FEED
   ════════════════════════════════════════════════════════════ */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--glass-border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE HELPERS
   ════════════════════════════════════════════════════════════ */

/* Mobile: hide certain table columns */
@media (max-width: 640px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Responsive form grids in modals */
@media (max-width: 540px) {

    #modal-body form[style*="grid-template-columns: 1fr 1fr"],
    #modal-body form[style*="grid-template-columns:1fr 1fr"],
    #epg-form {
        grid-template-columns: 1fr !important;
    }

    #modal-body form>div[style*="grid-column: span 2"],
    #modal-body form>div[style*="grid-column:span 2"] {
        grid-column: span 1 !important;
    }

    #modal-body>div[style*="grid-template-columns: 1fr 1fr"],
    #modal-body>div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* Responsive top-bar flex on very small screens */
@media (max-width: 360px) {
    .top-bar h2 {
        font-size: 1rem;
    }

    .stat-card .value {
        font-size: 1.1rem;
    }
}

/* Prevent overflow in table cells */
table td,
table th {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Smooth transitions for all page sections */
#view-content>* {
    animation: fadeIn 0.35s ease-out;
}

/* ════════════════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════════════════ */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.modal.active .modal-content {
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}