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

/* height: 100% en body/html para que el % cascade funcione en Firefox */
html {
    height: 100%;
    min-height: 100%;
}

body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    background: #000;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

html[data-theme="light"] body {
    background: #f3f4f6;
    color: #171717;
}

/* ═══════════════════════════════════════════════
   LAYOUT RAÍZ  (flex row: sidebar | player)
   Uso 100vh directo para máxima compatibilidad
═══════════════════════════════════════════════ */
#app {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════
   SIDEBAR  (columna izquierda, ancho fijo)
═══════════════════════════════════════════════ */
#sidebar {
    width: clamp(245px, 22vw, 320px);
    flex-shrink: 0;
    /* NO ponemos height: 100% — align-items:stretch lo hace automáticamente */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0f0f0f;
    border-right: 1px solid #1e1e1e;
}

/* Marca */
#brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 15px 16px 12px;
    border-bottom: 1px solid #1e1e1e;
    flex-shrink: 0;
}

.brand-home {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

#brand svg {
    width: 20px;
    height: 20px;
    stroke: #e50914;
    flex-shrink: 0;
}

#brand span {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: #e50914;
}

.brand-home:hover span {
    color: #ff3b45;
}

.brand-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.brand-actions a {
    border: 1px solid #2a2a2a;
    border-radius: 7px;
    padding: 6px 8px;
    color: #ddd;
    background: #171717;
    text-decoration: none;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.theme-toggle {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #2a2a2a;
    border-radius: 7px;
    color: #f8fafc;
    background: #171717;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 900;
    cursor: pointer;
}

.theme-toggle:hover {
    color: #fff;
    border-color: #e50914;
}

.brand-actions a:hover {
    color: #fff;
    border-color: #e50914;
}

.brand-actions a:last-child {
    color: #fecaca;
    background: #2a1012;
    border-color: #5f171b;
}

/* Etiqueta de sección */
#channels-label {
    padding: 10px 16px 6px;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #3a3a3a;
    flex-shrink: 0;
}

#channel-search-wrap {
    flex-shrink: 0;
    padding: 6px 10px 8px;
    background: #0f0f0f;
    border-bottom: 1px solid #1a1a1a;
}

#channel-search {
    width: 100%;
    height: 34px;
    border: 1px solid #272727;
    border-radius: 7px;
    padding: 0 11px;
    color: #eee;
    background: #151515;
    outline: none;
    font: inherit;
    font-size: 0.78rem;
}

#channel-search:focus {
    border-color: #e50914;
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.18);
}

#channel-search::placeholder {
    color: #555;
}

/* ═══════════════════════════════════════════════
   LISTA DE CANALES
   min-height:0 es CRÍTICO en Firefox para que
   el flex item pueda shrink y activar el scroll
═══════════════════════════════════════════════ */
#channel-list {
    list-style: none;
    flex: 1;
    min-height: 0;          /* ← Firefox fix */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 8px 16px;
}

#channel-list::-webkit-scrollbar        { width: 3px; }
#channel-list::-webkit-scrollbar-track  { background: transparent; }
#channel-list::-webkit-scrollbar-thumb  { background: #2a2a2a; border-radius: 3px; }
#channel-list::-webkit-scrollbar-thumb:hover { background: #404040; }

/* ─── Canal (generado por JS) ─── */
.channel-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: 7px;
    border-left: 3px solid transparent;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.12s;
    margin-bottom: 2px;
}

.channel-item:hover  { background: #1c1c1c; }
.channel-item.active { background: #222; border-left-color: #e50914; }

.channel-logo {
    width: 44px;
    height: 26px;
    border-radius: 4px;
    object-fit: contain;
    background: #1a1a1a;
    padding: 3px;
    flex-shrink: 0;
}

.channel-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.channel-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.channel-item.active .channel-name { color: #fff; font-weight: 600; }

.channel-type {
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: #3a3a3a;
}

.channel-sources {
    display: flex;
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 5px;
    margin-left: auto;
}

.channel-sources button {
    max-width: 76px;
    overflow: hidden;
    border: 1px solid #303030;
    border-radius: 999px;
    padding: 4px 7px;
    color: #cfcfcf;
    background: #171717;
    font: inherit;
    font-size: 0.58rem;
    font-weight: 800;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
}

.channel-sources button:hover,
.channel-sources button.active {
    color: #fff;
    border-color: #e50914;
    background: #2a1012;
}

.channel-sources button.active {
    animation: live-source-pulse 1.65s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(229, 9, 20, 0.58), 0 0 12px rgba(229, 9, 20, 0.24);
}

@keyframes live-source-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(229, 9, 20, 0.58), 0 0 12px rgba(229, 9, 20, 0.24);
        filter: brightness(1);
    }
    50% {
        box-shadow: 0 0 0 7px rgba(229, 9, 20, 0), 0 0 18px rgba(255, 56, 66, 0.5);
        filter: brightness(1.38) saturate(1.18);
    }
}

@media (prefers-reduced-motion: reduce) {
    .channel-sources button.active {
        animation: none;
    }
}

.channel-empty {
    padding: 14px 10px;
    color: #666;
    font-size: 0.76rem;
    text-align: center;
}

/* ═══════════════════════════════════════════════
   ÁREA DEL REPRODUCTOR  (columna derecha)
   min-height:0 CRÍTICO para Firefox en flex-column
═══════════════════════════════════════════════ */
#player-area {
    flex: 1;
    min-width: 0;
    min-height: 0;          /* ← Firefox fix */
    display: flex;
    flex-direction: column;
    background: #000;
    overflow: hidden;
}

/* ─── Contenedor de video (Shaka monta su UI aquí) ─── */
#video-container {
    flex: 1;
    min-height: 0;          /* ← Firefox fix */
    position: relative;
    background: #000;
    overflow: hidden;
    aspect-ratio: auto;
}

#video-container::after {
    display: none;
    content: none;
}

#video-container:fullscreen::after,
#video-container:-webkit-full-screen::after,
#video-container:-moz-full-screen::after,
#video-container:-ms-fullscreen::after {
    display: none;
}

/* Usamos top/left/right/bottom en vez de inset para Firefox < 87 */
#video {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
}

.player-loading {
    position: absolute;
    z-index: 4;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translate(-50%, -50%);
    padding: 10px 14px;
    color: #eee;
    background: rgba(12, 12, 12, 0.76);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
    font-size: 0.78rem;
}

.player-loading.is-hidden {
    display: none;
}

.loader-ring {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #e50914;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.shaka-video-container .shaka-controls-container {
    z-index: 3;
    background: transparent !important;
}

.shaka-video-container:fullscreen .shaka-controls-container,
.shaka-video-container:-webkit-full-screen .shaka-controls-container,
.shaka-video-container:-moz-full-screen .shaka-controls-container,
.shaka-video-container:-ms-fullscreen .shaka-controls-container,
#video-container:fullscreen .shaka-controls-container,
#video-container:-webkit-full-screen .shaka-controls-container,
#video-container:-moz-full-screen .shaka-controls-container,
#video-container:-ms-fullscreen .shaka-controls-container {
    background: transparent !important;
}

.shaka-video-container .shaka-bottom-controls {
    padding: 0 18px 14px !important;
}

.shaka-video-container .shaka-controls-button-panel {
    gap: 6px;
}

.shaka-video-container .material-icons-round,
.shaka-video-container .material-icons {
    color: #f5f5f5 !important;
}

.shaka-video-container button:hover .material-icons,
.shaka-video-container button:hover .material-icons-round {
    color: #e50914 !important;
}

.shaka-video-container .shaka-seek-bar-container {
    height: 5px !important;
    border-radius: 999px;
}

.shaka-video-container .shaka-seek-bar,
.shaka-video-container .shaka-volume-bar {
    accent-color: #e50914;
}

/* ─── Barra de estado ─── */
.status {
    flex-shrink: 0;
    padding: 5px 14px;
    font-size: 0.71rem;
    line-height: 1.5;
    color: #3a3a3a;
    background: #060606;
    border-top: 1px solid #181818;
    white-space: pre-line;
    min-height: 24px;
}

.status.ok   { color: #4ade80; }
.status.warn { color: #f87171; }

.audio-track-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 5px 12px;
    color: #777;
    background: #080808;
    border-top: 1px solid #181818;
}

.audio-track-bar.is-hidden {
    display: none;
}

.audio-track-bar label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.audio-track-bar select {
    min-width: 150px;
    max-width: 100%;
    color: #ddd;
    background: #161616;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 4px 8px;
    font: inherit;
    font-size: 0.72rem;
}

.audio-track-bar select:disabled {
    opacity: 0.55;
}

html[data-theme="light"] #sidebar,
html[data-theme="light"] #channel-search-wrap,
html[data-theme="light"] .admin-topbar,
html[data-theme="light"] .admin-tabs,
html[data-theme="light"] .admin-card {
    background: #ffffff;
    border-color: #d7dce3;
}

html[data-theme="light"] #sidebar {
    border-right-color: #d7dce3;
}

html[data-theme="light"] #brand,
html[data-theme="light"] .status,
html[data-theme="light"] .audio-track-bar {
    background: #f8fafc;
    border-color: #d7dce3;
}

html[data-theme="light"] .brand-actions a,
html[data-theme="light"] .brand-actions .theme-toggle,
html[data-theme="light"] .admin-top-actions a,
html[data-theme="light"] .admin-top-actions .theme-toggle,
html[data-theme="light"] .admin-tabs button,
html[data-theme="light"] .channel-sources button,
html[data-theme="light"] .admin-row button,
html[data-theme="light"] .channel-admin-item button,
html[data-theme="light"] .admin-card-heading button,
html[data-theme="light"] .source-editor-heading button,
html[data-theme="light"] .source-card-heading button,
html[data-theme="light"] .stream-pagination button {
    color: #334155;
    background: #ffffff;
    border-color: #cfd6df;
}

html[data-theme="light"] .brand-actions a:last-child,
html[data-theme="light"] .admin-top-actions a.danger-link {
    color: #991b1b;
    background: #fff1f2;
    border-color: #fecdd3;
}

html[data-theme="light"] #channel-search,
html[data-theme="light"] .admin-search-row input,
html[data-theme="light"] .audio-track-bar select,
html[data-theme="light"] .admin-form input,
html[data-theme="light"] .admin-form select,
html[data-theme="light"] .admin-form textarea {
    color: #172033;
    background: #ffffff;
    border-color: #cfd6df;
}

html[data-theme="light"] #channels-label,
html[data-theme="light"] .channel-type,
html[data-theme="light"] .status,
html[data-theme="light"] .audio-track-bar,
html[data-theme="light"] .admin-metrics span,
html[data-theme="light"] .channel-admin-item span,
html[data-theme="light"] .check-list span,
html[data-theme="light"] .stream-pagination,
html[data-theme="light"] .stream-live-note,
html[data-theme="light"] .login-hint,
html[data-theme="light"] .empty-note {
    color: #667085;
}

html[data-theme="light"] .channel-name,
html[data-theme="light"] .admin-card h1,
html[data-theme="light"] .admin-metrics strong,
html[data-theme="light"] .channel-admin-item strong,
html[data-theme="light"] .admin-row,
html[data-theme="light"] .check-list strong,
html[data-theme="light"] .source-editor-heading strong,
html[data-theme="light"] .source-card-heading strong,
html[data-theme="light"] .channel-editor summary {
    color: #172033;
}

html[data-theme="light"] .channel-item:hover,
html[data-theme="light"] .channel-item.active,
html[data-theme="light"] .admin-metrics div,
html[data-theme="light"] .channel-admin-item,
html[data-theme="light"] .bulk-actions,
html[data-theme="light"] .admin-row,
html[data-theme="light"] .check-list,
html[data-theme="light"] .source-editor,
html[data-theme="light"] .source-card,
html[data-theme="light"] .channel-editor,
html[data-theme="light"] .modal-panel,
html[data-theme="light"] .stream-monitor-wrap {
    background: #f8fafc;
    border-color: #d7dce3;
}

html[data-theme="light"] .stream-monitor {
    color: #172033;
    background: #ffffff;
}

html[data-theme="light"] .stream-monitor th,
html[data-theme="light"] .stream-monitor td {
    border-bottom-color: #e2e8f0;
}

html[data-theme="light"] .stream-monitor th {
    color: #475569;
    background: #eef2f7;
}

html[data-theme="light"] .stream-monitor tbody tr:nth-child(even) td {
    background: #f8fafc;
}

html[data-theme="light"] .stream-monitor-tools input,
html[data-theme="light"] .stream-monitor-tools select {
    color: #172033;
    background: #ffffff;
    border-color: #cfd6df;
}

html[data-theme="light"] .password-form {
    border-bottom-color: #d7dce3;
}

html[data-theme="light"] .channel-item.active {
    border-left-color: #e50914;
}

html[data-theme="light"] .channel-item.active .channel-name {
    color: #172033;
}

html[data-theme="light"] .channel-logo,
html[data-theme="light"] .channel-admin-logo {
    background: #eef2f7;
    border-color: #d7dce3;
}

html[data-theme="light"] .channel-sources button.active,
html[data-theme="light"] .channel-sources button:hover,
html[data-theme="light"] .admin-tabs button.active {
    color: #ffffff;
    background: #e50914;
    border-color: #e50914;
}

html[data-theme="light"] .status.ok { color: #15803d; }
html[data-theme="light"] .status.warn { color: #b91c1c; }

html[data-theme="light"] .channel-admin-item.is-inactive {
    background: #f1f5f9;
    border-left-color: #94a3b8;
}

html[data-theme="light"] .form-alert {
    color: #991b1b;
    background: #fff1f2;
    border-color: #fecdd3;
}

html[data-theme="light"] .form-alert.ok {
    color: #166534;
    background: #ecfdf3;
    border-color: #bbf7d0;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — móvil y tablets en vertical
   video arriba · canales abajo con scroll propio
═══════════════════════════════════════════════ */
@media (max-width: 900px), (max-width: 1100px) and (orientation: portrait) {
    #app {
        flex-direction: column;
        height: 100svh;     /* safe area en mobile */
        height: 100dvh;
        min-height: 0;
    }

    #player-area {
        order: 2;
        flex: 0 0 auto;
        min-height: 0;
        height: calc((100vw * 9) / 16 + 52px);
        max-height: 48dvh;
    }

    #video-container {
        flex: 0 0 calc((100vw * 9) / 16);
        min-height: 0;
    }

    .status {
        padding: 4px 10px;
        min-height: 22px;
        font-size: 0.66rem;
        line-height: 1.35;
    }

    .audio-track-bar {
        padding: 4px 10px;
        gap: 6px;
    }

    .audio-track-bar select {
        flex: 1 1 120px;
        min-width: 0;
    }

    #sidebar {
        display: contents;
    }

    #brand {
        order: 1;
        min-height: 42px;
        padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 7px;
        gap: 8px;
        background: #0f0f0f;
        border-bottom: 1px solid #1e1e1e;
    }

    #brand svg {
        width: 17px;
        height: 17px;
    }

    #brand span {
        font-size: 0.75rem;
        letter-spacing: 1.8px;
    }

    #channels-label {
        order: 3;
        padding: 4px 12px 2px;
        font-size: 0.5rem;
        letter-spacing: 1.1px;
        background: #0f0f0f;
    }

    #channel-search-wrap {
        order: 4;
        padding: 5px 8px 6px;
    }

    #channel-search {
        height: 31px;
        font-size: 0.74rem;
    }

    #channel-list {
        order: 5;
        display: block;
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 4px 8px calc(12px + env(safe-area-inset-bottom, 0px));
        background: #0f0f0f;
        border-top: 1px solid #1e1e1e;
    }

    #channel-list::-webkit-scrollbar        { width: 3px; }
    #channel-list::-webkit-scrollbar-thumb  { background: #2a2a2a; }

    .channel-item {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        padding: 8px 10px;
        width: 100%;
        min-width: 0;
        min-height: 48px;
        border-left: 3px solid transparent;
        border-bottom: none;
        border-radius: 7px;
        text-align: left;
        margin-bottom: 2px;
    }

    .channel-item.active {
        border-left-color: #e50914;
        border-bottom-color: transparent;
    }

    .channel-logo {
        width: 48px;
        height: 30px;
    }

    .channel-info {
        flex: 1;
        width: auto;
        align-items: flex-start;
    }

    .channel-sources {
        flex-wrap: wrap;
        max-width: 42%;
    }

    .channel-sources button {
        max-width: 58px;
        padding: 4px 6px;
        font-size: 0.54rem;
    }

    .channel-name {
        width: 100%;
        font-size: 0.8rem;
        line-height: 1.25;
    }

    .channel-type { display: block; }
}

@media (min-width: 901px) and (max-width: 1180px) and (orientation: landscape) {
    #sidebar {
        width: 285px;
    }

    #brand {
        padding: 13px 14px 10px;
    }

    .channel-logo {
        width: 46px;
        height: 28px;
    }

    .channel-name {
        font-size: 0.82rem;
    }

    .shaka-video-container .shaka-bottom-controls {
        padding: 0 16px 12px !important;
    }
}

@media (max-width: 900px) and (max-height: 620px) {
    #player-area {
        height: calc((100vw * 9) / 16 + 46px);
        max-height: 50vh;
    }

    #brand {
        padding: 6px 10px 4px;
    }

    #channels-label {
        display: none;
    }

    #channel-list {
        padding-top: 5px;
    }

    #channel-search-wrap {
        padding-top: 4px;
        padding-bottom: 4px;
    }

    .channel-item {
        min-height: 44px;
        padding: 6px 8px;
    }

    .channel-logo {
        width: 42px;
        height: 26px;
    }

    .channel-name {
        font-size: 0.74rem;
    }

    .channel-sources button {
        max-width: 54px;
    }
}

@media (min-width: 700px) and (max-width: 1100px) and (orientation: portrait) {
    #player-area {
        height: min(calc((100vw * 9) / 16 + 56px), 50dvh);
        max-height: 50dvh;
    }

    #brand {
        min-height: 50px;
        padding-left: 18px;
        padding-right: 18px;
    }

    #brand svg {
        width: 20px;
        height: 20px;
    }

    #brand span {
        font-size: 0.86rem;
        letter-spacing: 2.2px;
    }

    #channels-label {
        padding-left: 18px;
        padding-right: 18px;
        font-size: 0.58rem;
    }

    #channel-search-wrap {
        padding-left: 14px;
        padding-right: 14px;
    }

    #channel-search {
        height: 38px;
        font-size: 0.84rem;
    }

    #channel-list {
        padding-left: 12px;
        padding-right: 12px;
    }

    .channel-item {
        min-height: 58px;
        padding: 10px 12px;
    }

    .channel-logo {
        width: 58px;
        height: 36px;
    }

    .channel-name {
        font-size: 0.9rem;
    }

    .channel-type {
        font-size: 0.62rem;
    }
}

@media (max-width: 380px) {
    #brand span {
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .brand-actions {
        gap: 6px;
    }

    .brand-actions a {
        font-size: 0.58rem;
    }

    .player-loading {
        width: max-content;
        max-width: calc(100vw - 32px);
        padding: 9px 11px;
        font-size: 0.72rem;
    }

    .channel-logo {
        width: 40px;
        height: 25px;
    }

    .channel-name {
        font-size: 0.72rem;
    }
}

.auth-page,
.admin-page {
    min-height: 100%;
    overflow: auto;
    background: #050505;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(420px, 100%);
    padding: 28px;
    background: #0f0f0f;
    border: 1px solid #242424;
    border-radius: 10px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
    color: #e50914;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 2.2px;
    text-transform: uppercase;
}

.login-brand svg {
    width: 22px;
    height: 22px;
}

.login-panel h1,
.admin-card h1 {
    margin-bottom: 16px;
    font-size: 1rem;
    color: #f4f4f4;
}

.login-form,
.admin-form {
    display: grid;
    gap: 12px;
}

.login-form label,
.admin-form label {
    display: grid;
    gap: 6px;
    color: #999;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.login-form input,
.admin-form input,
.admin-form textarea,
.admin-form select {
    width: 100%;
    color: #eee;
    background: #151515;
    border: 1px solid #2a2a2a;
    border-radius: 7px;
    padding: 9px 10px;
    font: inherit;
}

.admin-form input[type="text"],
.admin-form input:not([type]) {
    -webkit-text-security: none;
    caret-color: currentColor;
}

.admin-form textarea {
    min-height: 74px;
    resize: vertical;
}

.login-form button,
.admin-form button,
.admin-row button,
.delete-form button {
    border: 0;
    border-radius: 7px;
    padding: 9px 12px;
    color: #fff;
    background: #e50914;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

button.danger {
    background: #5f171b;
}

button.success,
.admin-form button {
    background: #15803d;
}

button.success:hover,
.admin-form button:hover {
    background: #16a34a;
}

button.warning {
    border-color: #92400e;
    background: #92400e;
}

button.warning:hover {
    background: #b45309;
}

.admin-row button,
.channel-admin-item button,
.stream-pagination button {
    border: 1px solid #2a2a2a;
    background: #1d1d1d;
}

.admin-row button:hover,
.channel-admin-item button:hover,
.stream-pagination button:hover {
    border-color: #e50914;
}

button.danger,
.admin-row button.danger,
.delete-form button.danger,
.bulk-actions button.danger {
    border-color: #5f171b;
    background: #5f171b;
}

button.danger:hover,
.admin-row button.danger:hover,
.delete-form button.danger:hover,
.bulk-actions button.danger:hover {
    background: #7f1d1d;
}

.login-hint,
.empty-note {
    margin-top: 14px;
    color: #666;
    font-size: 0.75rem;
}

.form-alert {
    margin-bottom: 14px;
    padding: 10px 12px;
    color: #fecaca;
    background: #280d0f;
    border: 1px solid #5f171b;
    border-radius: 7px;
    font-size: 0.78rem;
}

.form-alert.ok {
    color: #bbf7d0;
    background: #082412;
    border-color: #14532d;
}

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    background: #0f0f0f;
    border-bottom: 1px solid #242424;
}

.admin-brand-link {
    color: #e50914;
    text-decoration: none;
    font-weight: 900;
    letter-spacing: 1.4px;
    text-transform: uppercase;
}

.admin-brand-link:hover {
    color: #ff3842;
}

.admin-top-actions {
    display: flex;
    gap: 8px;
}

.admin-top-actions a,
.admin-top-actions .theme-toggle {
    border: 1px solid #2a2a2a;
    border-radius: 7px;
    padding: 8px 11px;
    color: #ddd;
    background: #171717;
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 800;
}

.admin-top-actions .theme-toggle {
    width: 36px;
    padding: 0;
}

.admin-top-actions a:hover,
.admin-top-actions .theme-toggle:hover {
    color: #fff;
    border-color: #e50914;
}

.admin-top-actions a.danger-link {
    color: #fecaca;
    background: #2a1012;
    border-color: #5f171b;
}

.admin-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 18px clamp(14px, 2vw, 28px) 28px;
    display: grid;
    gap: 16px;
}

.admin-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px;
    background: #0f0f0f;
    border: 1px solid #242424;
    border-radius: 8px;
    scrollbar-width: thin;
}

.admin-tabs button {
    flex: 0 0 auto;
    min-width: 112px;
    border: 0;
    border-radius: 7px;
    padding: 10px 14px;
    color: #aaa;
    background: #171717;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
}

.admin-tabs button.active {
    color: #fff;
    background: #e50914;
}

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

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

.admin-card {
    padding: 16px;
    background: #0f0f0f;
    border: 1px solid #242424;
    border-radius: 8px;
}

.admin-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.admin-metrics div {
    padding: 13px 14px;
    background: #151515;
    border: 1px solid #242424;
    border-radius: 7px;
}

.admin-metrics strong,
.admin-metrics span {
    display: block;
}

.admin-metrics strong {
    color: #fff;
    font-size: 1.25rem;
    line-height: 1.1;
}

.admin-metrics span {
    margin-top: 4px;
    color: #888;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.admin-form.compact {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    align-items: end;
}

.admin-search-row {
    margin: 0 0 12px;
}

.admin-search-row input {
    width: 100%;
    color: #e5e5e5;
    background: #151515;
    border: 1px solid #2a2a2a;
    border-radius: 7px;
    padding: 9px 11px;
    font: inherit;
    font-size: 0.82rem;
}

.admin-search-row input:focus {
    outline: none;
    border-color: #e50914;
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.16);
}

.password-form {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #242424;
}

.admin-card-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.admin-card-heading h1 {
    margin-bottom: 0;
}

.admin-card-heading button,
.channel-admin-item button {
    border: 1px solid #2a2a2a;
    border-radius: 7px;
    padding: 8px 11px;
    color: #fff;
    background: #1d1d1d;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.channel-admin-item button.success {
    border-color: #1f9d55;
    background: #137a43;
}

.channel-admin-item button.success:hover {
    border-color: #2fbe69;
    background: #199653;
}

.channel-admin-item button.warning {
    border-color: #b7791f;
    background: #6f4a12;
}

.channel-admin-item button.warning:hover {
    border-color: #d69e2e;
    background: #8a5d17;
}

.admin-card-heading button.success {
    border-color: #1f9d55;
    background: #137a43;
}

.admin-card-heading button.success:hover {
    border-color: #2fbe69;
    background: #199653;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.inline-check {
    display: flex !important;
    align-items: center;
    grid-auto-flow: column;
    gap: 8px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

.inline-check input {
    width: auto;
}

.check-list {
    display: grid;
    gap: 8px;
    max-height: 260px;
    overflow: auto;
    padding: 10px;
    background: #151515;
    border: 1px solid #242424;
    border-radius: 7px;
}

.check-list strong {
    color: #eee;
    font-size: 0.8rem;
}

.check-list span {
    color: #777;
    font-size: 0.72rem;
}

.channel-form textarea[name="drm"],
.channel-form textarea[name="sources"] {
    min-height: 52px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.source-editor {
    display: grid;
    gap: 10px;
    padding: 10px;
    background: #121212;
    border: 1px solid #242424;
    border-radius: 8px;
}

.source-editor-heading,
.source-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.source-card-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.source-editor-heading strong,
.source-card-heading strong {
    color: #eee;
    font-size: 0.82rem;
}

.source-editor-heading button,
.source-card-heading button {
    border: 0;
    border-radius: 7px;
    padding: 7px 10px;
    color: #fff;
    background: #1d1d1d;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 800;
    cursor: pointer;
}

.source-list {
    display: grid;
    gap: 10px;
}

.source-card {
    display: grid;
    gap: 10px;
    padding: 11px;
    background: #171717;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
}

.source-card textarea {
    min-height: 48px;
}

.admin-table,
.channel-admin-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.admin-table {
    grid-template-columns: 1fr;
}

.channel-admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #151515;
    border: 1px solid #242424;
    border-left: 3px solid #1f9d55;
    border-radius: 7px;
}

.channel-admin-item.is-inactive {
    opacity: 0.62;
    border-left-color: #525252;
    background: #121212;
}

.channel-admin-item.is-filtered-out {
    display: none;
}

.channel-admin-logo {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    object-fit: contain;
    border-radius: 7px;
    background: #0b0b0b;
    border: 1px solid #252525;
}

.channel-admin-info {
    flex: 1 1 auto;
}

.channel-admin-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-width: auto;
}

.channel-admin-actions form {
    margin: 0;
}

.bulk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #151515;
    border: 1px solid #242424;
    border-radius: 7px;
}

.bulk-actions button {
    border: 0;
    border-radius: 7px;
    padding: 8px 11px;
    color: #fff;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.bulk-check {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.bulk-check input {
    width: 16px;
    height: 16px;
}

.channel-admin-item div {
    min-width: 0;
}

.channel-admin-item strong,
.channel-admin-item span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-admin-item strong {
    color: #eee;
    font-size: 0.86rem;
}

.channel-admin-item span {
    margin-top: 3px;
    color: #777;
    font-size: 0.72rem;
    text-transform: uppercase;
}

.admin-row {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(90px, 0.7fr) minmax(0, 1fr) minmax(110px, 0.8fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    background: #151515;
    border: 1px solid #242424;
    border-radius: 7px;
    color: #bbb;
    font-size: 0.8rem;
}

.admin-row span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-row form {
    margin: 0;
}

.admin-row button {
    white-space: nowrap;
}

.user-row {
    grid-template-columns: minmax(120px, 1fr) 76px minmax(180px, 1.8fr) 120px minmax(190px, auto);
}

.session-row {
    grid-template-columns: minmax(130px, 0.8fr) minmax(220px, 1fr) minmax(240px, 1.5fr) 80px auto;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
}

.row-actions form {
    display: contents;
}

.row-actions button {
    padding: 7px 9px;
    font-size: 0.72rem;
}

.stream-monitor-tools,
.stream-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
}

.stream-monitor-tools input,
.stream-monitor-tools select {
    color: #eee;
    background: #151515;
    border: 1px solid #2a2a2a;
    border-radius: 7px;
    padding: 9px 10px;
    font: inherit;
    font-size: 0.78rem;
}

.stream-monitor-tools input {
    flex: 1;
    min-width: 180px;
}

.stream-monitor-tools select {
    flex: 0 0 120px;
}

.stream-pagination {
    margin-top: 10px;
    color: #777;
    font-size: 0.76rem;
}

.stream-live-note {
    margin-top: 8px;
    color: #666;
    font-size: 0.72rem;
}

.stream-pagination button {
    border: 0;
    border-radius: 7px;
    padding: 8px 10px;
    color: #fff;
    background: #1d1d1d;
    font: inherit;
    font-size: 0.74rem;
    font-weight: 800;
    cursor: pointer;
}

.stream-pagination button:disabled {
    color: #555;
    cursor: not-allowed;
    opacity: 0.65;
}

.stream-monitor-wrap {
    margin-top: 10px;
    overflow-x: auto;
    border: 1px solid #242424;
    border-radius: 8px;
}

.stream-monitor {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
    background: #111;
    color: #bbb;
    font-size: 0.74rem;
}

.stream-monitor th,
.stream-monitor td {
    max-width: 220px;
    padding: 9px 10px;
    border-bottom: 1px solid #242424;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stream-monitor th {
    color: #888;
    background: #171717;
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.stream-monitor tbody tr:last-child td {
    border-bottom: 0;
}

@media (min-width: 1024px) {
    .channel-admin-list {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    }

    .admin-row {
        grid-template-columns: minmax(0, 1.1fr) minmax(90px, 0.7fr) minmax(0, 1fr) minmax(110px, 0.8fr) auto;
    }

    .user-row {
        grid-template-columns: minmax(120px, 1fr) 76px minmax(180px, 1.8fr) 120px minmax(190px, auto);
    }

    .session-row {
        grid-template-columns: minmax(130px, 0.8fr) minmax(220px, 1fr) minmax(240px, 1.5fr) 80px auto;
    }
}

@media (max-width: 980px) {
    .user-row,
    .session-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .admin-row span {
        white-space: normal;
    }

    .row-actions {
        justify-content: flex-start;
    }

    .bulk-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .bulk-actions button {
        width: 100%;
    }

    .stream-monitor-tools,
    .stream-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .stream-monitor-tools input,
    .stream-monitor-tools select,
    .stream-pagination button {
        width: 100%;
    }
}

.channel-editor {
    background: #151515;
    border: 1px solid #242424;
    border-radius: 7px;
    padding: 10px;
}

.channel-editor summary {
    cursor: pointer;
    color: #eee;
    font-weight: 700;
}

.channel-form {
    margin-top: 12px;
}

.delete-form {
    margin-top: 10px;
}

.modal {
    position: fixed;
    z-index: 20;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.72);
}

.modal.is-open {
    display: flex;
}

.modal-panel {
    position: relative;
    width: min(760px, 100%);
    max-height: min(760px, 92vh);
    overflow: auto;
    padding: 18px;
    background: #0f0f0f;
    border: 1px solid #2a2a2a;
    border-radius: 9px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.modal-panel h2 {
    margin-bottom: 14px;
    font-size: 1rem;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    color: #ccc;
    background: #1d1d1d;
    font-size: 1.2rem;
    cursor: pointer;
}

@media (max-width: 760px) {
    .admin-form.compact,
    .password-form,
    .form-grid,
    .admin-row {
        grid-template-columns: 1fr;
    }

    .admin-shell {
        padding: 14px 10px 20px;
    }

    .admin-tabs button {
        min-width: 96px;
        padding-inline: 12px;
    }

    .admin-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}
