*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
    *:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    :root {
      --bg-dark: #0a0a0f;
      --bg-card: #12121a;
      --bg-sidebar: #0e0e16;
      --bg-hover: #1a1a2e;
      --bg-active: #2a1015;
      --accent: #e50914;
      --accent-hover: #ff1a25;
      --text: #e5e5e5;
      --text-dim: #9898a8;
      --border: #1e1e2e;
      --success: #00c853;
      --warning: #ff9800;
    }

    /* Glassmorphism — lightweight for Smart TVs */
    .glass {
      background: rgba(18, 18, 26, 0.75);
      border: 1px solid rgba(255, 255, 255, 0.06);
      box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    }
    .glass-accent {
      background: rgba(229, 9, 20, 0.08);
      border: 1px solid rgba(229, 9, 20, 0.15);
      box-shadow: 0 4px 20px rgba(229, 9, 20, 0.1);
    }

    @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
    @keyframes spin { to { transform: rotate(360deg); } }
    @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
    @keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
    @keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      background: var(--bg-dark);
      color: var(--text);
      height: 100vh;
      overflow: hidden;
    }

    /* ===== SCREENS ===== */
    .screen {
      position: absolute; inset: 0;
      opacity: 0; pointer-events: none;
      transition: opacity 0.3s ease;
      overflow-y: auto;
    }
    .screen.active {
      opacity: 1; pointer-events: all;
    }

    /* ===== LOGO ===== */
    .logo { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; user-select: none; }
    .logo .iptv { color: var(--accent); }
    .logo .ai { color: #ffffff; font-weight: 600; }
    .logo .pro { color: var(--text-dim); font-weight: 400; font-size: 18px; }
    .logo-large { font-size: 42px; }
    .logo-large .pro { font-size: 34px; }

    /* ===== SCROLLBAR ===== */
    ::-webkit-scrollbar { width: 6px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
    ::-webkit-scrollbar-thumb:hover { background: #2e2e3e; }

    /* ===== ACCOUNT SCREEN (SaaS auth) ===== */
    #accountScreen {
      display: flex; align-items: center; justify-content: center;
      background: radial-gradient(ellipse at 50% 0%, #1a1a2e 0%, var(--bg-dark) 70%);
      padding: 20px;
    }

    /* ===== LOGIN SCREEN ===== */
    #loginScreen {
      display: flex; align-items: center; justify-content: center;
      background: radial-gradient(ellipse at 50% 0%, #1a1a2e 0%, var(--bg-dark) 70%);
    }
    .login-container {
      width: 420px; max-width: 100%; animation: slideUp 0.5s ease;
    }
    .login-header {
      text-align: center; margin-bottom: 32px;
    }
    .login-header p {
      color: var(--text-dim); margin-top: 8px; font-size: 14px;
    }
    .login-box {
      background: rgba(18, 18, 26, 0.75);
      border: 1px solid rgba(255, 255, 255, 0.06);
      box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
      border-radius: 16px;
      padding: 28px;
    }
    .login-tabs {
      display: flex; gap: 0; margin-bottom: 24px;
      background: var(--bg-dark);
      border-radius: 10px; padding: 4px;
    }
    .login-tab {
      flex: 1; padding: 10px; text-align: center;
      background: none; border: none; color: var(--text-dim);
      font-size: 13px; font-weight: 600; cursor: pointer;
      border-radius: 8px; transition: all 0.2s;
    }
    .login-tab.active {
      background: var(--accent); color: white;
    }
    .login-form { display: none; }
    .login-form.active { display: block; }

    .form-group {
      margin-bottom: 16px;
    }
    .form-group label {
      display: block; font-size: 12px; color: var(--text-dim);
      margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
    }
    .form-group input {
      width: 100%; padding: 12px 14px;
      background: var(--bg-dark); border: 1px solid var(--border);
      border-radius: 10px; color: var(--text); font-size: 16px;
      outline: none; transition: border-color 0.2s;
    }
    .form-group input:focus { border-color: var(--accent); }
    .form-group input::placeholder { color: #505060; }

    .remember-row {
      display: flex; align-items: center; gap: 8px;
      margin-bottom: 20px; cursor: pointer;
    }
    .remember-row input[type="checkbox"] {
      accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer;
    }
    .remember-row span { font-size: 13px; color: var(--text-dim); }

    .btn-connect {
      width: 100%; padding: 14px;
      background: var(--accent); color: white; border: none;
      border-radius: 10px; font-size: 15px; font-weight: 700;
      cursor: pointer; transition: all 0.2s;
      text-transform: uppercase; letter-spacing: 1px;
    }
    .btn-connect:hover { background: var(--accent-hover); transform: translateY(-1px); }
    .btn-connect:active { transform: translateY(0); }
    .btn-connect:disabled {
      opacity: 0.5; cursor: not-allowed; transform: none;
    }

    .login-error {
      margin-top: 14px; padding: 10px 14px;
      background: rgba(229,9,20,0.1); border: 1px solid rgba(229,9,20,0.3);
      border-radius: 8px; color: #ff6b6b; font-size: 13px;
      display: none; text-align: center;
    }
    .login-error.show { display: block; animation: fadeIn 0.3s ease; }

    .login-footer {
      text-align: center; margin-top: 24px;
      font-size: 12px; color: #404050;
    }

    /* ===== DASHBOARD ===== */
    #dashboardScreen { display: flex; flex-direction: column; }

    .topbar {
      height: 60px; background: rgba(14, 14, 22, 0.85);
      border-bottom: 1px solid rgba(255, 255, 255, 0.06);
      box-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
      display: flex; align-items: center; padding: 0 24px; gap: 16px;
      flex-shrink: 0;
    }
    .topbar .logo { cursor: pointer; }
    .topbar-search {
      flex: 1; max-width: 460px; position: relative; margin-left: 20px;
    }
    .topbar-search input {
      width: 100%; padding: 9px 16px 9px 38px;
      background: var(--bg-dark); border: 1px solid var(--border);
      border-radius: 10px; color: var(--text); font-size: 13px;
      outline: none; transition: border-color 0.2s;
    }
    .topbar-search input:focus { border-color: var(--accent); }
    .topbar-search input::placeholder { color: var(--text-dim); }
    .topbar-search::before {
      content: '\1F50D'; position: absolute; left: 12px; top: 50%;
      transform: translateY(-50%); font-size: 13px;
    }
    .topbar-right {
      display: flex; align-items: center; gap: 10px; margin-left: auto;
    }
    .topbar-btn {
      width: 38px; height: 38px; border-radius: 10px;
      background: var(--bg-dark); border: 1px solid var(--border);
      color: var(--text); font-size: 16px; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: all 0.2s;
    }
    .topbar-btn:hover { border-color: var(--accent); background: var(--bg-hover); }

    .dashboard-content {
      flex: 1; overflow-y: auto; padding: 32px 40px;
    }

    .main-cards {
      display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 20px;
      margin-bottom: 28px;
    }
    .main-card {
      border-radius: 18px; padding: 32px 28px;
      cursor: pointer; transition: all 0.3s;
      position: relative; overflow: hidden;
      min-height: 170px;
      display: flex; flex-direction: column; justify-content: flex-end;
    }
    .main-card::before {
      content: ''; position: absolute; inset: 0;
      background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.3) 100%);
    }
    .main-card:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0,0.4); }
    .main-card .card-icon {
      font-size: 42px; position: relative; z-index: 1; margin-bottom: 12px;
    }
    .main-card .card-title {
      font-size: 22px; font-weight: 800; position: relative; z-index: 1;
      text-transform: uppercase; letter-spacing: 1px;
    }
    .main-card .card-sub {
      font-size: 13px; color: rgba(255,255,255,0.7);
      position: relative; z-index: 1; margin-top: 4px;
    }
    .card-live { background: linear-gradient(135deg, #1a936f, #114b5f); }
    .card-movies { background: linear-gradient(135deg, #e8553d, #f5a623); }
    .card-series { background: linear-gradient(135deg, #667eea, #764ba2); }

    .card-unavailable {
      opacity: 0.4; cursor: not-allowed; position: relative;
    }
    .card-unavailable:hover { transform: none; box-shadow: none; }
    .card-unavailable .card-badge {
      position: absolute; top: 14px; right: 14px;
      background: rgba(0,0,0,0.6); padding: 4px 10px;
      border-radius: 6px; font-size: 11px; color: var(--warning);
      z-index: 2;
    }

    .ai-section {
      background: rgba(18, 18, 26, 0.75); border: 1px solid rgba(255, 255, 255, 0.06);
      box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
      border-radius: 16px; padding: 24px; margin-bottom: 28px;
    }
    .ai-header {
      font-size: 16px; font-weight: 700; margin-bottom: 14px;
      display: flex; align-items: center; gap: 8px;
    }
    .ai-input-row {
      display: flex; gap: 10px;
    }
    .ai-input-row input {
      flex: 1; padding: 12px 16px;
      background: var(--bg-dark); border: 1px solid var(--border);
      border-radius: 10px; color: var(--text); font-size: 14px;
      outline: none; transition: border-color 0.2s;
    }
    .ai-input-row input:focus { border-color: var(--accent); }
    .ai-input-row input::placeholder { color: #505060; }
    .ai-input-row button {
      width: 44px; height: 44px; border-radius: 10px;
      background: var(--bg-dark); border: 1px solid var(--border);
      color: var(--text); font-size: 18px; cursor: pointer;
      transition: all 0.2s;
    }
    .ai-input-row button:hover { border-color: var(--accent); }

    .small-cards {
      display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
    }
    .small-card {
      background: #1a3a4a; border-radius: 14px;
      padding: 22px 20px; cursor: pointer;
      transition: all 0.2s; display: flex; align-items: center; gap: 14px;
    }
    .small-card:hover { background: #1f4555; transform: translateY(-2px); }
    .small-card .sc-icon {
      width: 44px; height: 44px; border-radius: 12px;
      background: rgba(255,255,255,0.1);
      display: flex; align-items: center; justify-content: center;
      font-size: 20px; flex-shrink: 0;
    }
    .small-card .sc-title { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
    .small-card .sc-sub { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 2px; }

    .dashboard-footer {
      height: 44px; background: var(--bg-sidebar);
      border-top: 1px solid var(--border);
      display: flex; align-items: center; justify-content: center;
      gap: 20px; font-size: 12px; color: var(--text-dim);
      flex-shrink: 0;
    }
    .dashboard-footer .status-online { color: var(--success); }

    /* ===== INNER SCREENS (Live, Movies, Series) ===== */
    .inner-screen { display: flex; flex-direction: column; }

    .inner-topbar {
      height: 56px; background: var(--bg-sidebar);
      border-bottom: 1px solid var(--border);
      display: flex; align-items: center; padding: 0 20px; gap: 16px;
      flex-shrink: 0;
    }
    .btn-back {
      width: 36px; height: 36px; border-radius: 8px;
      background: var(--bg-dark); border: 1px solid var(--border);
      color: var(--text); font-size: 18px; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: all 0.2s;
    }
    .btn-back:hover { border-color: var(--accent); background: var(--bg-hover); }
    .inner-topbar .section-title { font-size: 18px; font-weight: 700; }
    .inner-topbar .search-box {
      flex: 1; max-width: 400px; position: relative; margin-left: auto;
    }
    .inner-topbar .search-box input {
      width: 100%; padding: 8px 14px 8px 36px;
      background: var(--bg-dark); border: 1px solid var(--border);
      border-radius: 8px; color: var(--text); font-size: 13px;
      outline: none; transition: border-color 0.2s;
    }
    .inner-topbar .search-box input:focus { border-color: var(--accent); }
    .inner-topbar .search-box input::placeholder { color: var(--text-dim); }
    .inner-topbar .search-box::before {
      content: '\1F50D'; position: absolute; left: 10px; top: 50%;
      transform: translateY(-50%); font-size: 12px;
    }

    .inner-body {
      flex: 1; display: grid; overflow: hidden;
    }
    .live-layout { grid-template-columns: 240px 1fr; }
    .vod-layout { grid-template-columns: 220px 1fr; }

    /* Sidebar for categories */
    .cat-sidebar {
      background: var(--bg-sidebar); border-right: 1px solid var(--border);
      overflow-y: auto; padding: 8px 0;
    }
    .cat-sidebar-title {
      padding: 10px 16px; font-size: 11px; text-transform: uppercase;
      letter-spacing: 1px; color: var(--text-dim);
    }
    .cat-item {
      display: flex; align-items: center; justify-content: space-between;
      padding: 10px 16px; cursor: pointer; transition: background 0.15s;
      border-left: 3px solid transparent;
    }
    .cat-item:hover { background: var(--bg-hover); }
    .cat-item.active { background: var(--bg-active); border-left-color: var(--accent); }
    .cat-item .name {
      font-size: 13px; white-space: nowrap; overflow: hidden;
      text-overflow: ellipsis; flex: 1;
    }
    .cat-item .count {
      font-size: 11px; color: var(--text-dim); background: var(--bg-dark);
      padding: 2px 8px; border-radius: 10px; min-width: 28px; text-align: center;
      flex-shrink: 0; margin-left: 8px;
    }

    /* ===== LIVE TV AREA ===== */
    .live-main { display: grid; grid-template-rows: auto 1fr; overflow: hidden; }

    .player-area { background: #000; position: relative; min-height: 0; height: 400px; }
    .player-area.fullscreen { position: fixed; inset: 0; z-index: 100; height: 100vh !important; }
    .player-area video { width: 100%; height: 100%; object-fit: contain; background: #000; }

    .player-placeholder {
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      height: 100%; color: var(--text-dim); gap: 12px;
    }
    .player-placeholder .icon { font-size: 48px; }

    .player-bar {
      position: absolute; bottom: 0; left: 0; right: 0;
      background: linear-gradient(transparent, rgba(0,0,0,0.9));
      padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
      opacity: 0; transition: opacity 0.3s;
    }
    .player-area:hover .player-bar { opacity: 1; }
    .player-area.tv-controls .player-bar { opacity: 1; }

    .now-playing { display: flex; align-items: center; gap: 12px; }
    .now-playing img { width: 36px; height: 36px; object-fit: contain; border-radius: 4px; background: var(--bg-card); }
    .now-playing .ch-name { font-size: 14px; font-weight: 600; }
    .now-playing .ch-group { font-size: 11px; color: var(--text-dim); }

    .player-controls { display: flex; gap: 8px; align-items: center; }
    .player-controls button {
      background: rgba(255,255,255,0.1); border: none; color: white;
      width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 16px;
      display: flex; align-items: center; justify-content: center; transition: background 0.2s;
    }
    .player-controls button:hover { background: rgba(255,255,255,0.25); }

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

    .player-status {
      position: absolute; top: 12px; left: 12px;
      background: rgba(0,0,0,0.7); padding: 4px 10px; border-radius: 4px;
      font-size: 11px; display: flex; align-items: center; gap: 6px;
    }
    .status-dot { width: 8px; height: 8px; border-radius: 50%; }
    .status-dot.live { background: var(--accent); animation: pulse 2s infinite; }
    .status-dot.loading { background: var(--warning); animation: pulse 0.5s infinite; }
    .status-dot.error { background: #f44336; }

    .channels-area { overflow-y: auto; padding: 16px; }
    .channels-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
    .channels-header h2 { font-size: 16px; font-weight: 600; }
    .channels-header .total { color: var(--text-dim); font-size: 13px; }

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

    .channel-card {
      background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
      padding: 12px; cursor: pointer; transition: all 0.2s;
      display: flex; align-items: center; gap: 10px;
    }
    .channel-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(229,9,20,0.15); }
    .channel-card.playing { border-color: var(--success); background: rgba(0,200,83,0.05); }

    .ch-logo {
      width: 40px; height: 40px; object-fit: contain; border-radius: 6px;
      background: var(--bg-dark); padding: 4px; flex-shrink: 0;
    }
    .ch-logo.no-img { display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--text-dim); }

    .ch-info { flex: 1; min-width: 0; }
    .channel-card .ch-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .channel-card .ch-group { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    .fav-btn { background: none; border: none; cursor: pointer; font-size: 14px; padding: 4px; opacity: 0.4; transition: opacity 0.2s; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
    .fav-btn:hover, .fav-btn.active { opacity: 1; }

    .live-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; flex-shrink: 0; animation: pulse 2s infinite; }
    .channel-card.playing .live-dot { background: var(--success); }

    .load-more {
      display: block; width: 100%; padding: 12px; margin-top: 12px;
      background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
      color: var(--text); cursor: pointer; font-size: 14px; transition: background 0.2s;
    }
    .load-more:hover { background: var(--bg-hover); }

    /* ===== VOD GRID (Movies/Series) ===== */
    .vod-main { overflow-y: auto; padding: 20px; }
    .vod-grid {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
      gap: 16px;
    }
    .vod-card {
      background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 12px; overflow: hidden; cursor: pointer;
      transition: all 0.25s;
    }
    .vod-card:hover {
      border-color: var(--accent); transform: translateY(-4px);
      box-shadow: 0 8px 24px rgba(229,9,20,0.2);
    }
    .vod-poster {
      width: 100%; aspect-ratio: 2/3; object-fit: cover;
      background: var(--bg-dark); display: block;
    }
    .vod-poster-placeholder {
      width: 100%; aspect-ratio: 2/3; background: var(--bg-dark);
      display: flex; align-items: center; justify-content: center;
      font-size: 36px; color: var(--text-dim);
    }
    .vod-info { padding: 10px 12px; }
    .vod-info .vod-title {
      font-size: 13px; font-weight: 600;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .vod-info .vod-year { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

    /* Series detail */
    .series-detail {
      padding: 20px; overflow-y: auto;
    }
    .series-detail-header {
      display: flex; gap: 24px; margin-bottom: 24px;
    }
    .series-detail-poster {
      width: 180px; aspect-ratio: 2/3; object-fit: cover;
      border-radius: 12px; background: var(--bg-dark); flex-shrink: 0;
    }
    .series-detail-info { flex: 1; }
    .series-detail-info h2 { font-size: 24px; font-weight: 800; margin-bottom: 8px; }
    .series-detail-info .meta { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
    .series-detail-info .plot { font-size: 14px; color: var(--text); line-height: 1.6; max-width: 600px; }

    .season-tabs {
      display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
    }
    .season-tab {
      padding: 8px 18px; border-radius: 8px;
      background: var(--bg-card); border: 1px solid var(--border);
      color: var(--text); font-size: 13px; font-weight: 600;
      cursor: pointer; transition: all 0.2s;
    }
    .season-tab:hover { border-color: var(--accent); }
    .season-tab.active { background: var(--accent); border-color: var(--accent); }

    .episode-list { display: flex; flex-direction: column; gap: 8px; }
    .episode-item {
      background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 10px; padding: 14px 16px;
      cursor: pointer; transition: all 0.2s;
      display: flex; align-items: center; gap: 14px;
    }
    .episode-item:hover { border-color: var(--accent); background: var(--bg-hover); }
    .episode-num {
      width: 36px; height: 36px; border-radius: 8px;
      background: var(--bg-dark); display: flex; align-items: center; justify-content: center;
      font-size: 14px; font-weight: 700; color: var(--accent); flex-shrink: 0;
    }
    .episode-info { flex: 1; }
    .episode-info .ep-title { font-size: 14px; font-weight: 600; }
    .episode-info .ep-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

    /* ===== SPINNER ===== */
    .spinner { text-align: center; padding: 40px; color: var(--text-dim); }
    .spinner::after {
      content: ''; display: inline-block; width: 24px; height: 24px;
      border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }

    /* ===== SKELETON LOADING ===== */
    .skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 16px; }
    .skeleton-card { border-radius: 10px; background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
    .skeleton-channel { height: 64px; }
    .skeleton-vod { aspect-ratio: 2/3; }
    .skeleton-category { height: 40px; border-radius: 8px; margin: 4px 8px; background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }

    /* ===== EMPTY STATE ===== */
    .empty-state {
      text-align: center; padding: 60px 20px; color: var(--text-dim);
      display: flex; flex-direction: column; align-items: center; gap: 8px;
    }
    .empty-state .icon { font-size: 48px; margin-bottom: 4px; opacity: 0.6; }
    .empty-state p { font-size: 14px; max-width: 300px; }
    .empty-state .hint { font-size: 12px; color: var(--text-dim); opacity: 0.7; margin-top: 4px; }

    /* ===== VOD INFO PANEL ===== */
    .vod-info-panel { display:none; background:var(--bg-card); border:1px solid var(--border); border-radius:14px; padding:20px; margin:0 16px 16px 16px; animation:fadeIn .3s; }
    .vod-info-panel.show { display:flex; gap:20px; }
    .vod-info-panel .vip-poster, .vod-info-panel .vip-poster-placeholder { width:130px; min-width:130px; aspect-ratio:2/3; border-radius:10px; background:var(--bg-dark); }
    .vod-info-panel .vip-poster { object-fit:cover; }
    .vod-info-panel .vip-poster-placeholder { display:flex; align-items:center; justify-content:center; font-size:40px; color:var(--text-dim); }
    .vod-info-panel .vip-details { flex:1; min-width:0; }
    .vod-info-panel .vip-title { font-size:18px; font-weight:700; margin-bottom:6px; }
    .vod-info-panel .vip-meta { font-size:13px; color:var(--text-dim); margin-bottom:10px; display:flex; flex-wrap:wrap; gap:8px; }
    .vod-info-panel .vip-meta .vip-rating { color:#f5a623; }
    .vod-info-panel .vip-plot { font-size:13px; line-height:1.5; margin-bottom:8px; max-height:60px; overflow:hidden; }
    .vod-info-panel .vip-cast { font-size:12px; color:var(--text-dim); }
    .vod-info-panel .vip-close { position:absolute; top:8px; right:12px; background:none; border:none; color:var(--text-dim); font-size:18px; cursor:pointer; }

    /* ===== EPG INFO (Player Bar) ===== */
    .epg-info { font-size: 11px; color: var(--text-dim); max-width: 400px; }
    .epg-now { color: var(--success); margin-bottom: 2px; }
    .epg-next { color: var(--text-dim); }

    /* ===== EPG in Channel List ===== */
    .ch-epg { font-size: 10px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

    /* ===== EPG Modal (Dashboard) ===== */
    .epg-modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.7); z-index:200; display:flex; align-items:center; justify-content:center; animation:fadeIn 0.2s; }
    .epg-modal { background:rgba(18, 18, 26, 0.85); border:1px solid rgba(255, 255, 255, 0.06); box-shadow:0 4px 24px rgba(0, 0, 0, 0.3); border-radius:16px; width:520px; max-width:90vw; max-height:80vh; display:flex; flex-direction:column; animation:slideUp 0.3s; }
    .epg-modal-header { display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--border); }
    .epg-modal-header h3 { font-size:16px; font-weight:700; }
    .epg-modal-close { background:none; border:none; color:var(--text-dim); font-size:22px; cursor:pointer; }
    .epg-modal-body { flex:1; overflow-y:auto; padding:12px 22px; }
    .epg-modal-item { display:flex; align-items:center; gap:12px; padding:10px 0; border-bottom:1px solid var(--border); }
    .epg-modal-item:last-child { border-bottom:none; }
    .epg-modal-logo { width:32px; height:32px; object-fit:contain; border-radius:4px; background:var(--bg-dark); flex-shrink:0; }
    .epg-modal-logo.no-img { display:flex; align-items:center; justify-content:center; font-size:16px; color:var(--text-dim); }
    .epg-modal-ch-name { font-size:13px; font-weight:600; min-width:100px; }
    .epg-modal-programs { flex:1; min-width:0; }
    .epg-modal-now { font-size:12px; color:var(--success); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .epg-modal-next { font-size:11px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .epg-modal-loading { text-align:center; padding:40px; color:var(--text-dim); }

    /* ===== MOBILE CATEGORY PILLS ===== */
    .mobile-cat-pills { display: none; overflow-x: auto; gap: 8px; padding: 8px 12px; white-space: nowrap; -ms-overflow-style: none; scrollbar-width: none; background: var(--bg-sidebar); border-bottom: 1px solid var(--border); }
    .mobile-cat-pills::-webkit-scrollbar { display: none; }
    .mobile-cat-pill { padding: 10px 16px; border-radius: 16px; background: var(--bg-dark); border: 1px solid var(--border); color: var(--text-dim); font-size: 12px; cursor: pointer; flex-shrink: 0; transition: all 0.2s; }
    .mobile-cat-pill.active { background: var(--accent); border-color: var(--accent); color: white; }

    /* ===== RECOMMENDATION CAROUSELS ===== */
    .reco-section { margin-bottom: 24px; }
    .reco-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
    .reco-row-wrap { position: relative; }
    .reco-row { display: flex; gap: 12px; overflow-x: auto; scroll-behavior: smooth; padding-bottom: 8px; -ms-overflow-style: none; scrollbar-width: none; }
    .reco-row::-webkit-scrollbar { display: none; }
    .reco-card { min-width: 140px; max-width: 140px; border-radius: 10px; overflow: hidden; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; background: var(--bg-card); border: 1px solid var(--border); flex-shrink: 0; }
    .reco-card:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(229,9,20,0.25); }
    .reco-card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: var(--bg-dark); }
    .reco-card .reco-placeholder { width: 100%; aspect-ratio: 2/3; display: flex; align-items: center; justify-content: center; font-size: 32px; background: var(--bg-dark); color: var(--text-dim); }
    .reco-card .reco-title { padding: 8px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .reco-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,0.7); border: 1px solid var(--border); color: white; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 2; transition: background 0.2s; }
    .reco-arrow:hover { background: var(--accent); }
    .reco-arrow.left { left: -8px; }
    .reco-arrow.right { right: -8px; }

    /* ===== TV D-PAD FOCUS ===== */
    .tv-focused { outline: 3px solid var(--accent) !important; outline-offset: 3px; box-shadow: 0 0 16px rgba(229,9,20,0.35); }

    /* ===== AUTO-PLAY OVERLAY ===== */
    .autoplay-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; animation: fadeIn 0.3s; }
    .autoplay-overlay .countdown { font-size: 48px; font-weight: 800; color: var(--accent); margin-bottom: 12px; }
    .autoplay-overlay .next-title { font-size: 16px; color: var(--text); margin-bottom: 20px; }
    .autoplay-overlay button { padding: 10px 24px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-size: 14px; cursor: pointer; transition: background 0.2s; }
    .autoplay-overlay button:hover { background: var(--accent); }

    /* ===== MOBILE BOTTOM NAV ===== */
    .mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: 56px; background: var(--bg-sidebar); border-top: 1px solid var(--border); z-index: 100; justify-content: space-around; align-items: center; }
    .mobile-nav button { background: none; border: none; color: var(--text-dim); font-size: 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 8px; transition: color 0.2s; min-width: 48px; min-height: 44px; }
    .mobile-nav button.active { color: var(--accent); }
    .mobile-nav button .nav-icon { font-size: 20px; }

    /* ===== RESPONSIVE: TV (min-width: 1600px) ===== */
    @media (min-width: 1600px) {
      .main-card .card-title { font-size: 26px; }
      .main-card .card-icon { font-size: 52px; }
      .main-card { min-height: 200px; padding: 40px 32px; }
      .channel-card { padding: 16px; }
      .player-controls button { width: 44px; height: 44px; font-size: 20px; }
      .reco-card { min-width: 170px; max-width: 170px; }
      .topbar { height: 68px; }
      .btn-back, .topbar-btn { width: 44px; height: 44px; }
    }

    /* ===== RESPONSIVE: TABLET (768-1024) ===== */
    @media (max-width: 1024px) {
      .main-cards { grid-template-columns: 1fr 1fr; }
      .main-card:first-child { grid-column: span 2; }
      .small-cards { grid-template-columns: 1fr 1fr; }
      .live-layout { grid-template-columns: 200px 1fr; }
      .vod-layout { grid-template-columns: 180px 1fr; }
      .dashboard-content { padding: 24px 20px; }
      .vod-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
      /* Tablet login: wider card, centered vertically */
      .login-container { width: 480px; }
      .login-box { padding: 36px; }
    }

    /* ===== RESPONSIVE: MOBILE (<768px) ===== */
    @media (max-width: 768px) {
      .topbar { padding: 0 12px; height: 50px; }
      .topbar .logo { font-size: 18px; }
      .topbar-search { margin-left: 8px; }
      .topbar-right .topbar-btn[title="Enviar ao Ai"] { display: none; }
      .dashboard-content { padding: 16px 12px; padding-bottom: 72px; }
      .main-cards { grid-template-columns: 1fr; gap: 12px; }
      .main-card:first-child { grid-column: span 1; }
      .main-card { min-height: 120px; padding: 20px 16px; }
      .main-card .card-title { font-size: 18px; }
      .main-card .card-icon { font-size: 32px; }
      .small-cards { grid-template-columns: 1fr; gap: 10px; }
      .ai-section { display: none; }
      .live-layout, .vod-layout { grid-template-columns: 1fr; }
      .cat-sidebar { display: none; }
      .mobile-cat-pills { display: flex !important; }
      .channels-area { padding: 10px; }
      .channel-grid { grid-template-columns: 1fr; }
      .vod-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
      .vod-info-panel.show { flex-direction: column; }
      .vod-info-panel .vip-poster, .vod-info-panel .vip-poster-placeholder { width: 100px; min-width: 100px; }
      .series-detail-header { flex-direction: column; gap: 16px; }
      .series-detail-poster { width: 120px; }
      .inner-topbar { padding: 0 10px; }
      .inner-topbar .search-box { max-width: none; }
      .mobile-nav { display: flex; }
      .dashboard-footer { display: none; }
      .reco-card { min-width: 120px; max-width: 120px; }
      .epg-info { display: none !important; }
      .player-bar {
        opacity: 1 !important;
        position: relative;
        background: var(--bg-card);
        padding: 8px 12px;
      }
      .player-bar .ch-name { font-size: 13px; }
      .player-bar .ch-group { font-size: 11px; }
      .player-area { height: auto; min-height: 200px; display: flex; flex-direction: column; }
      .player-area video { flex: 1; min-height: 200px; }
      .volume-slider { display: none; }
    }

/* ===================================================================
   SAAS UI COMPONENTS — Trial Banner, Paywall Overlay, Enhanced Toast
   =================================================================== */

/* ── CSS vars for SaaS components ── */
:root {
  --ai-accent: #6C5CE7;
  --ai-accent-dim: rgba(108, 92, 231, 0.15);
  --warning-amber: #f59e0b;
  --warning-amber-dim: rgba(245, 158, 11, 0.12);
  --trial-urgent: var(--accent);
  --trial-urgent-dim: rgba(229, 9, 20, 0.12);
}

/* ─────────────────────────────────────────
   1. TRIAL BANNER
   ───────────────────────────────────────── */
#trialBanner {
  position: relative;
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 90;
  flex-shrink: 0;
  animation: fadeIn 0.4s ease;
  transition: background 0.3s, border-color 0.3s;
}

#trialBanner.tb-safe {
  background: rgba(16, 185, 129, 0.08);
  border-bottom: 1px solid rgba(16, 185, 129, 0.18);
  color: #a7f3d0;
}
#trialBanner.tb-warn {
  background: var(--warning-amber-dim);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  color: #fcd34d;
}
#trialBanner.tb-urgent {
  background: var(--trial-urgent-dim);
  border-bottom: 1px solid rgba(229, 9, 20, 0.28);
  color: #fca5a5;
}

.trial-banner-text {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.trial-banner-cta {
  background: none;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
  opacity: 0.85;
}
.trial-banner-cta:hover { opacity: 1; background: rgba(255,255,255,0.08); }

.trial-banner-dismiss {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: inherit;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.5;
  padding: 4px 6px;
  line-height: 1;
  transition: opacity 0.2s;
}
.trial-banner-dismiss:hover { opacity: 1; }

/* Banner adjusts screens that have a topbar — push content down */
.has-trial-banner .dashboard-content,
.has-trial-banner .live-layout,
.has-trial-banner .vod-layout,
.has-trial-banner .movies-layout,
.has-trial-banner .series-layout {
  /* already inside the screen flow — no extra offset needed because banner
     is part of the flex column layout inside the screen */
}

@media (max-width: 640px) {
  #trialBanner {
    height: 34px;
    font-size: 12px;
    gap: 6px;
  }
  .trial-banner-cta { font-size: 10px; padding: 2px 8px; }
}

/* ─────────────────────────────────────────
   2. PAYWALL OVERLAY
   ───────────────────────────────────────── */
#paywallOverlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 10, 15, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
}

.paywall-card {
  background: #141419;
  border: 1px solid rgba(229, 9, 20, 0.22);
  box-shadow: 0 8px 48px rgba(229, 9, 20, 0.15), 0 2px 16px rgba(0,0,0,0.5);
  border-radius: 18px;
  padding: 36px 32px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  position: relative;
  animation: slideUp 0.35s ease;
}

.paywall-icon {
  font-size: 36px;
  margin-bottom: 14px;
  display: block;
}

.paywall-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}

.paywall-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 22px;
  line-height: 1.5;
}

.paywall-features {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  text-align: left;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.paywall-features li {
  font-size: 13px;
  color: #c4c4d0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.paywall-features li::before {
  content: '✓';
  color: var(--accent);
  font-size: 10px;
  flex-shrink: 0;
}

.paywall-cta {
  width: 100%;
  padding: 14px 24px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.2px;
  margin-bottom: 12px;
}
.paywall-cta:hover { background: var(--accent-hover); }
.paywall-cta:active { transform: scale(0.98); }
.paywall-cta:disabled { opacity: 0.6; cursor: default; }

.paywall-restore {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
  display: block;
  margin: 0 auto 8px;
}
.paywall-restore:hover { color: var(--text); }

.paywall-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.paywall-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.paywall-note {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 12px;
  opacity: 0.7;
}

@media (max-width: 480px) {
  .paywall-card {
    padding: 28px 20px 22px;
    border-radius: 14px;
    max-height: 90vh;
    overflow-y: auto;
  }
  .paywall-features {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .paywall-title { font-size: 17px; }
}

/* ─────────────────────────────────────────
   3. ENHANCED TOAST
   ───────────────────────────────────────── */

/* Override base toast to support progress bar */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 18, 26, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 12px 20px 16px;
  color: var(--text);
  font-size: 13px;
  z-index: 500;
  animation: slideUp 0.3s;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  max-width: 90vw;
  min-width: 220px;
  text-align: center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.toast-body {
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.4;
}

.toast-icon { font-size: 15px; flex-shrink: 0; }

/* Progress bar track */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 10px 10px;
  width: 100%;
  transform-origin: left;
  animation: toastProgress var(--toast-duration, 4s) linear forwards;
}

@keyframes toastProgress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* Type variants */
.toast.error   { border-color: var(--accent); }
.toast.error   .toast-progress { background: var(--accent); }

.toast.success { border-color: var(--success); }
.toast.success .toast-progress { background: var(--success); }

.toast.warning {
  border-color: var(--warning-amber);
  color: #fcd34d;
}
.toast.warning .toast-progress { background: var(--warning-amber); }

.toast.info {
  border-color: var(--ai-accent);
  color: #c4b5fd;
}
.toast.info .toast-progress { background: var(--ai-accent); }

.toast.synced {
  border-color: var(--success);
  color: #a7f3d0;
}
.toast.synced .toast-progress { background: var(--success); }
