:root {
    color-scheme: dark;
    --bg: #07101d;
    --bg-strong: #091624;
    --panel: rgba(8, 18, 34, 0.78);
    --panel-strong: rgba(12, 23, 44, 0.94);
    --panel-soft: rgba(255, 255, 255, 0.04);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.14);
    --text: #f8f3ea;
    --muted: #a8b7c9;
    --muted-strong: #d8e2ec;
    --warm: #ff6b2c;
    --gold: #ffcc5c;
    --green: #3cf2b0;
    --blue: #4ac7ff;
    --cyan: #5ff1ff;
    --danger: #ff7a7a;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    --headline-font: "Space Grotesk", "Trebuchet MS", sans-serif;
    --body-font: "Archivo", "Segoe UI Variable", sans-serif;
    /* Responsive & TV */
    --touch-target-min: 44px;
    --safe-area-inset: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text);
    font-family: var(--body-font);
    background:
        radial-gradient(circle at 0% 0%, rgba(255, 107, 44, 0.3), transparent 24%),
        radial-gradient(circle at 100% 0%, rgba(95, 241, 255, 0.18), transparent 28%),
        radial-gradient(circle at 50% 100%, rgba(255, 204, 92, 0.14), transparent 35%),
        linear-gradient(135deg, #060c16 0%, #071424 34%, #091320 68%, #061019 100%);
    position: relative;
    overflow-x: hidden;
    /* Safe area para notches, barras del sistema y TV overscan */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body::after {
    content: "";
    position: fixed;
    inset: -20%;
    pointer-events: none;
    background:
        radial-gradient(circle at 20% 25%, rgba(255, 107, 44, 0.12), transparent 20%),
        radial-gradient(circle at 75% 20%, rgba(95, 241, 255, 0.1), transparent 18%),
        radial-gradient(circle at 65% 70%, rgba(60, 242, 176, 0.1), transparent 20%);
    filter: blur(28px);
    animation: auroraShift 18s linear infinite;
    opacity: 0.9;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 120px 120px;
    mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.7), transparent 85%);
    opacity: 0.28;
}

button,
input,
video {
    font: inherit;
}

/* Touch targets mínimos para móvil/tablet (44px recomendado por WCAG) */
button,
input[type="text"],
input[type="password"],
input[type="number"],
a[role="button"] {
    min-height: var(--touch-target-min);
}

/* Focus visible para navegación con teclado y mando TV (D-pad) */
:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 3px;
}

button:focus-visible,
input:focus-visible,
.channel-card:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(255, 204, 92, 0.2);
}

/* Ocultar outline solo cuando no es navegación por teclado */
:focus:not(:focus-visible) {
    outline: none;
}

[hidden] {
    display: none !important;
}

.page-shell {
    position: relative;
    z-index: 1;
    width: min(1480px, calc(100% - 40px));
    margin: 0 auto;
    padding: 20px 0 32px;
    display: grid;
    gap: 18px;
    /* Evitar overflow en pantallas pequeñas */
    max-width: 100%;
}

.card-surface {
    border: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(11, 24, 40, 0.9), rgba(7, 18, 31, 0.96)),
        linear-gradient(135deg, rgba(255, 107, 44, 0.04), rgba(95, 241, 255, 0.04));
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-radius: 22px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.eyebrow,
.section-tag,
.status-kicker,
.step-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 7px 12px;
    border-radius: 999px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
}

.eyebrow,
.section-tag {
    background: rgba(255, 111, 60, 0.13);
    color: var(--gold);
}

.masthead h1,
.intro-card h2,
.auth-card h2,
.dashboard-bar h2,
.stage-card h3,
.lineup-card h3 {
    margin: 0;
    font-family: var(--headline-font);
    letter-spacing: -0.05em;
}

.masthead h1 {
    font-size: clamp(1.45rem, 3vw, 2rem);
    line-height: 1;
    max-width: none;
}

.event-label {
    margin: 0;
    font-size: 0.92rem;
    color: var(--muted-strong);
    font-weight: 600;
}

.status-tile {
    display: grid;
    gap: 6px;
    align-content: start;
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.status-tile strong {
    font-size: 1.15rem;
    line-height: 1.15;
}

.status-tile small {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.35;
}

.status-kicker {
    padding: 0;
    color: var(--muted-strong);
    background: none;
}

.status-tile--accent {
    background: linear-gradient(135deg, rgba(74, 199, 255, 0.16), rgba(60, 242, 176, 0.12));
    border-color: rgba(95, 241, 255, 0.22);
}

.top-status {
    min-width: 260px;
    max-width: 320px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-layout,
.dashboard {
    display: grid;
    gap: 22px;
}

.auth-layout {
    grid-template-columns: minmax(320px, 560px);
    justify-content: center;
}

.intro-card,
.auth-card,
.stage-card,
.lineup-card {
    border-radius: 24px;
    padding: 22px;
}

/* Vista evento: más aire dentro del player y del listado */
#channels-view .stage-card,
#channels-view .lineup-card {
    padding: clamp(24px, 2.2vw, 34px);
}

.intro-card h2,
.auth-card h2,
.dashboard-bar h2 {
    font-size: clamp(1.8rem, 3vw, 2.45rem);
    line-height: 0.94;
}

.lead {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--muted-strong);
    max-width: 54ch;
}

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

.step-card {
    display: grid;
    gap: 14px;
    padding: 20px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.step-card h3 {
    margin: 0;
    font-family: var(--headline-font);
    font-size: 1.25rem;
    letter-spacing: -0.04em;
}

.step-card p,
.intro-note,
.support-copy,
.muted,
.channel-meta,
.empty-state span,
.overlay-copy span,
.stage-helper {
    color: var(--muted);
}

.step-card p,
.intro-note,
.support-copy,
.muted,
.empty-state span,
.overlay-copy span {
    margin: 0;
    line-height: 1.6;
}

.step-index {
    background: rgba(240, 188, 89, 0.12);
    color: var(--gold);
}

.intro-note {
    padding: 18px 20px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.auth-card {
    display: grid;
    gap: 16px;
    align-content: start;
}

.auth-switch {
    display: inline-flex;
    gap: 10px;
    padding: 8px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.auth-mode-button {
    padding: 12px 16px;
}

.auth-mode-button.is-active {
    background: linear-gradient(135deg, rgba(255, 204, 92, 0.24), rgba(255, 107, 44, 0.18));
    border-color: rgba(240, 188, 89, 0.35);
}

.access-form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 12px;
}

.field span {
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-strong);
}

.field input {
    width: 100%;
    padding: 18px 20px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
    outline: none;
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
    /* Evita zoom automático en iOS al enfocar (min 16px) */
    font-size: max(1rem, 16px);
}

.field input::placeholder {
    color: rgba(202, 211, 220, 0.45);
}

.field input:focus {
    border-color: rgba(240, 188, 89, 0.7);
    box-shadow: 0 0 0 4px rgba(240, 188, 89, 0.12);
    transform: translateY(-1px);
}

button {
    cursor: pointer;
    border: 0;
    border-radius: 18px;
    padding: 16px 22px;
    background: linear-gradient(135deg, var(--gold), #ff9460 52%, var(--warm));
    color: #11161d;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
    box-shadow: 0 14px 30px rgba(255, 111, 60, 0.22);
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 34px rgba(255, 111, 60, 0.28);
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
    transform: none;
    box-shadow: none;
}

.ghost-button {
    color: var(--text);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(95, 241, 255, 0.03));
    box-shadow: none;
    border: 1px solid var(--line);
}

.inline-error {
    margin: 0;
    color: var(--danger);
    font-weight: 700;
    line-height: 1.5;
}

.topbar-button {
    white-space: nowrap;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.32fr) minmax(300px, 0.78fr);
    gap: clamp(24px, 3.2vw, 40px);
    align-items: start;
}

body[data-view="admin"] .masthead {
    display: none;
}

body[data-view="admin"] .page-shell {
    width: calc(100% - 40px);
    max-width: 1920px;
}

@media (min-width: 1200px) {
    body[data-view="admin"] .table-shell {
        overflow-x: visible;
    }
}

.admin-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    min-height: 500px;
    align-items: start;
    border-radius: 24px;
    overflow: hidden;
}

.admin-sidebar {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    border-radius: 0 24px 24px 0;
    min-height: 400px;
}

.sidebar-brand {
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
}

.sidebar-brand .eyebrow {
    display: block;
    margin-bottom: 4px;
}

.sidebar-brand strong {
    font-family: var(--headline-font);
    font-size: 1.2rem;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0 12px;
    flex: 1;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 6px;
    border: none;
    border-radius: 16px;
    background: transparent;
    color: var(--muted-strong);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 180ms, color 180ms;
}

.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.sidebar-nav-item.is-active {
    background: linear-gradient(135deg, rgba(255, 204, 92, 0.2), rgba(255, 107, 44, 0.12));
    color: var(--gold);
    border: 1px solid rgba(255, 204, 92, 0.25);
}

.sidebar-icon {
    font-size: 1.2rem;
}

.sidebar-footer {
    padding: 20px 24px 0;
    border-top: 1px solid var(--line);
}

.sidebar-logout {
    width: 100%;
    justify-content: center;
}

.admin-content {
    padding: 24px 28px 40px;
    min-width: 0;
}


.admin-module {
    animation: adminFadeIn 0.25s ease;
}

@keyframes adminFadeIn {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
    max-width: 100%;
}

@media (min-width: 1400px) {
    .admin-grid {
        grid-template-columns: minmax(0, 1.6fr) minmax(360px, 0.9fr);
    }
}

.stage-card {
    display: grid;
    gap: 22px;
}

.stage-top,
.lineup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding-bottom: 2px;
}

.stage-top > div:first-child,
.lineup-header > div:first-child {
    min-width: 0;
    padding-right: 12px;
    display: grid;
    gap: 10px;
    align-content: start;
}

.lineup-header .muted {
    margin: 0;
    max-width: 28ch;
    line-height: 1.45;
}

.lineup-header #catalog-summary {
    text-align: right;
}

@media (max-width: 1180px) {
    .lineup-header #catalog-summary {
        text-align: left;
    }
}

.stage-card h3,
.lineup-card h3 {
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    line-height: 0.95;
}

.player-state {
    flex-shrink: 0;
    min-width: 136px;
    padding: 11px 16px;
    margin-top: 2px;
    border-radius: 999px;
    text-align: center;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.76rem;
    background: rgba(99, 199, 255, 0.12);
    color: var(--blue);
}

.player-state[data-tone="live"] {
    background: rgba(60, 242, 176, 0.14);
    color: var(--green);
}

.player-state[data-tone="loading"] {
    background: rgba(240, 188, 89, 0.12);
    color: var(--gold);
}

.player-state[data-tone="error"] {
    background: rgba(255, 122, 122, 0.12);
    color: var(--danger);
}

.stage-helper {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.92rem;
}

.video-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 28px;
    overflow: hidden;
    background:
        radial-gradient(circle at top, rgba(255, 111, 60, 0.18), transparent 30%),
        #04080d;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.video-frame video {
    width: 100%;
    height: 100%;
    display: block;
    background: #04080d;
    object-fit: contain;
}

.player-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        linear-gradient(180deg, rgba(8, 18, 29, 0.35), rgba(5, 10, 16, 0.82)),
        linear-gradient(135deg, rgba(240, 188, 89, 0.08), rgba(255, 111, 60, 0.08));
    text-align: center;
}

.player-overlay[data-tone="loading"] {
    background:
        linear-gradient(180deg, rgba(8, 18, 29, 0.48), rgba(5, 10, 16, 0.9)),
        linear-gradient(135deg, rgba(255, 204, 92, 0.16), rgba(255, 107, 44, 0.12));
}

/* Aviso autoplay: clic en el overlay = gesto de usuario para iniciar play */
.player-overlay[data-click-resume="true"] {
    cursor: pointer;
}

.player-overlay[data-tone="error"] {
    background:
        linear-gradient(180deg, rgba(18, 10, 15, 0.5), rgba(12, 6, 10, 0.9)),
        linear-gradient(135deg, rgba(255, 122, 122, 0.14), rgba(255, 107, 44, 0.1));
}

.overlay-copy {
    display: grid;
    gap: 10px;
    max-width: 460px;
    justify-items: center;
}

.overlay-copy strong {
    font-family: var(--headline-font);
    font-size: clamp(1.7rem, 4vw, 2.45rem);
    letter-spacing: -0.05em;
}

.overlay-spinner {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    border: 4px solid rgba(255, 255, 255, 0.14);
    border-top-color: var(--gold);
    border-right-color: var(--warm);
    box-shadow: 0 0 0 10px rgba(255, 204, 92, 0.08);
    animation: spin 0.95s linear infinite;
}

.lineup-card {
    display: grid;
    gap: 22px;
}

.admin-panel {
    display: grid;
    gap: 20px;
    border-radius: 24px;
    padding: 26px;
}

#admin-view .admin-panel:first-child {
    min-width: 0;
}

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

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.table-shell {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.03);
    scroll-behavior: smooth;
}


.admin-table {
    width: 100%;
    border-collapse: collapse;
}

#channels-table {
    min-width: 100%;
    table-layout: auto;
}

#channels-table th:nth-child(1),
#channels-table td:nth-child(1) { width: 80px; min-width: 80px; }
#channels-table th:nth-child(2),
#channels-table td:nth-child(2) { width: 12%; min-width: 130px; }
#channels-table th:nth-child(3),
#channels-table td:nth-child(3) { width: 90px; min-width: 90px; }
#channels-table th:nth-child(4),
#channels-table td:nth-child(4) { width: 20%; min-width: 220px; }
#channels-table th:nth-child(5),
#channels-table td:nth-child(5) { width: 26%; min-width: 280px; }
#channels-table th:nth-child(6),
#channels-table td:nth-child(6) { width: 14%; min-width: 150px; }
#channels-table th:nth-child(7),
#channels-table td:nth-child(7) { width: 100px; min-width: 100px; }
#channels-table th:nth-child(8),
#channels-table td:nth-child(8) { width: 85px; min-width: 85px; }
#channels-table th:nth-child(9),
#channels-table td:nth-child(9) { width: 95px; min-width: 95px; }

#users-table {
    min-width: 480px;
}

#users-table th:nth-child(1),
#users-table td:nth-child(1) { width: 100px; min-width: 100px; }
#users-table th:nth-child(2),
#users-table td:nth-child(2) { width: 28%; min-width: 120px; }
#users-table th:nth-child(3),
#users-table td:nth-child(3) { width: 100px; min-width: 100px; }
#users-table th:nth-child(4),
#users-table td:nth-child(4) { width: 80px; min-width: 80px; }
#users-table th:nth-child(5),
#users-table td:nth-child(5) { width: 90px; min-width: 90px; }

.admin-table th,
.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: middle;
    text-align: left;
}

.admin-table th {
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-strong);
    white-space: nowrap;
}

.admin-table td input[type="text"],
.admin-table td input[type="number"] {
    width: 100%;
    min-width: 64px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
    outline: none;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.admin-table td input[type="text"]:focus,
.admin-table td input[type="number"]:focus {
    border-color: rgba(240, 188, 89, 0.5);
    box-shadow: 0 0 0 2px rgba(255, 204, 92, 0.1);
}

.toggle-cell {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    color: var(--muted-strong);
    font-size: 0.9rem;
}

.compact-button {
    padding: 12px 16px;
    border-radius: 14px;
    letter-spacing: 0.04em;
    font-size: 0.82rem;
}

.admin-panel .table-toolbar {
    margin-bottom: 4px;
}

.table-legend {
    margin: 0 0 12px;
    font-size: 0.85rem;
}

.admin-panel .status-note {
    margin-bottom: 12px;
}

.inline-success {
    margin: 0;
    color: var(--green);
    font-weight: 700;
    line-height: 1.5;
}

.status-note {
    margin: 0;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted-strong);
    line-height: 1.5;
}

.status-note[data-tone="loading"] {
    border-color: rgba(255, 204, 92, 0.28);
    background: rgba(255, 204, 92, 0.08);
    color: var(--gold);
}

.status-note[data-tone="success"] {
    border-color: rgba(60, 242, 176, 0.28);
    background: rgba(60, 242, 176, 0.08);
    color: var(--green);
}

.status-note[data-tone="error"] {
    border-color: rgba(255, 122, 122, 0.28);
    background: rgba(255, 122, 122, 0.08);
    color: var(--danger);
}

.status-note .status-note-detail {
    display: block;
    margin-top: 10px;
    font-weight: 500;
    line-height: 1.55;
    color: var(--muted-strong);
    opacity: 0.95;
}

.status-note[data-tone="loading"] .status-note-detail {
    color: var(--muted-strong);
}

.status-note[data-tone="success"] .status-note-detail {
    color: var(--muted-strong);
}

.admin-source-help {
    margin: 0 0 14px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.admin-source-help summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--muted-strong);
    list-style-position: outside;
    padding: 4px 0;
}

.admin-source-help summary:hover {
    color: var(--gold);
}

.admin-source-help-body {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--muted);
}

.admin-source-help-body p {
    margin: 0 0 12px;
}

.admin-source-help-body p:last-child {
    margin-bottom: 0;
}

.admin-source-help-body ul {
    margin: 8px 0 12px;
    padding-left: 1.35rem;
}

.admin-source-help-body li {
    margin-bottom: 8px;
}

.admin-source-help-body code {
    font-size: 0.86em;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.source-indicator {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}
.source-indicator--ready {
    background: rgba(60, 242, 176, 0.14);
    color: var(--green);
}
.source-indicator--loading {
    background: rgba(255, 204, 92, 0.14);
    color: var(--gold);
}
.source-indicator--pending {
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
}
.source-indicator--direct {
    background: rgba(74, 199, 255, 0.12);
    color: var(--blue);
}
.source-indicator--empty {
    color: var(--muted);
    background: none;
}

.source-indicator--fail {
    background: rgba(255, 122, 122, 0.14);
    color: var(--danger);
}

.source-status-cell {
    white-space: nowrap;
}

.source-status-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    max-width: 200px;
}

.source-row-refresh {
    font-size: 0.78rem;
    padding: 6px 10px;
    min-height: 36px;
}

.admin-table td:has(.token-auto-badge) {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.token-auto-badge {
    display: inline-flex;
    align-self: flex-start;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    background: rgba(60, 242, 176, 0.2);
    color: var(--green);
}

.channels-grid {
    display: grid;
    gap: 18px;
    /* Scroll suave en listas largas */
    overflow-anchor: auto;
}

.channel-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.035);
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.channel-card:hover {
    transform: translateY(-1px);
    border-color: rgba(240, 188, 89, 0.18);
    background: rgba(255, 255, 255, 0.05);
}

.channel-card.is-active {
    border-color: rgba(95, 241, 255, 0.3);
    background: linear-gradient(135deg, rgba(74, 199, 255, 0.12), rgba(60, 242, 176, 0.09));
}

.channel-card.is-loading {
    border-color: rgba(255, 204, 92, 0.28);
    background:
        linear-gradient(135deg, rgba(255, 204, 92, 0.1), rgba(255, 107, 44, 0.08)),
        rgba(255, 255, 255, 0.035);
    box-shadow: inset 0 0 0 1px rgba(255, 204, 92, 0.08);
}

.channel-card.is-error {
    border-color: rgba(255, 122, 122, 0.24);
    background:
        linear-gradient(135deg, rgba(255, 122, 122, 0.08), rgba(255, 107, 44, 0.06)),
        rgba(255, 255, 255, 0.035);
}

.channel-card--skeleton {
    min-height: 116px;
    overflow: hidden;
    position: relative;
}

.channel-card--skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    transform: translateX(-100%);
    animation: shimmer 1.35s infinite;
}

.channel-skeleton-line,
.channel-skeleton-pill {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.channel-skeleton-line {
    height: 14px;
}

.channel-skeleton-line--lg {
    width: 58%;
    height: 18px;
}

.channel-skeleton-line--sm {
    width: 32%;
}

.channel-skeleton-pill {
    width: 104px;
    height: 36px;
}

.channel-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    align-items: center;
}

.channel-rank,
.channel-logo {
    width: 58px;
    height: 58px;
    border-radius: 18px;
}

.channel-rank {
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.06);
    color: var(--gold);
    font-weight: 900;
    letter-spacing: 0.08em;
}

.channel-logo {
    object-fit: contain;
    padding: 8px;
    background: rgba(255, 255, 255, 0.06);
    display: block;
    overflow: hidden;
}

.channel-logo--fallback {
    display: grid;
    place-items: center;
    font-weight: 900;
    color: var(--gold);
    font-size: 1.05rem;
    text-transform: uppercase;
}

.channel-content {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.channel-content h4 {
    margin: 0;
    font-family: var(--headline-font);
    font-size: 1.2rem;
    letter-spacing: -0.04em;
}

.channel-meta {
    font-size: 0.92rem;
}

.channel-action {
    width: 100%;
}

.channel-action.is-active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.channel-action.is-loading {
    background: linear-gradient(135deg, rgba(255, 204, 92, 0.24), rgba(255, 107, 44, 0.16));
    border-color: rgba(255, 204, 92, 0.3);
    color: var(--gold);
}

.empty-state {
    display: grid;
    gap: 10px;
    padding: 26px;
    border-radius: 24px;
    border: 1px dashed rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.025);
}

.empty-state strong {
    font-family: var(--headline-font);
    font-size: 1.3rem;
    letter-spacing: -0.04em;
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

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

@keyframes auroraShift {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
    }
    50% {
        transform: translate3d(3%, -2%, 0) scale(1.05);
    }
    100% {
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    body::after {
        animation: none;
    }
}

@media (max-width: 1180px) {
    .dashboard-grid,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        gap: 26px;
    }

    .admin-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .admin-sidebar {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 16px 20px;
        border-radius: 24px;
        margin-bottom: 16px;
        min-height: auto;
    }

    .admin-sidebar .sidebar-brand {
        width: 100%;
        margin-bottom: 12px;
        padding-bottom: 12px;
    }

    .admin-sidebar .sidebar-nav {
        display: flex;
        gap: 8px;
        flex: 1;
        padding: 0;
        margin: 0;
    }

    .admin-sidebar .sidebar-nav li {
        flex: 1;
    }

    .admin-sidebar .sidebar-nav-item {
        margin-bottom: 0;
        justify-content: center;
    }

    .admin-sidebar .sidebar-footer {
        width: 100%;
        padding-top: 12px;
        margin-top: 12px;
    }
}

@media (max-width: 860px) {
    .page-shell {
        width: min(100% - 24px, 1480px);
        padding-top: 18px;
    }

    .masthead,
    .auth-card,
    .stage-card,
    .lineup-card,
    .admin-panel {
        padding: 22px;
        border-radius: 24px;
    }

    .masthead,
    .stage-top,
    .lineup-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .top-actions,
    .top-status {
        min-width: 0;
        width: 100%;
        max-width: none;
    }

    .top-actions {
        align-items: stretch;
        width: 100%;
    }

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

    .steps-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .page-shell {
        width: min(100% - 16px, 1480px);
    }

    .masthead h1,
    .intro-card h2,
    .auth-card h2,
    .dashboard-bar h2 {
        line-height: 1;
    }

    .player-state {
        min-width: 0;
        width: 100%;
    }

    .channel-main {
        grid-template-columns: 1fr;
    }

    .channel-rank,
    .channel-logo {
        width: 52px;
        height: 52px;
    }
}

/* Orientación horizontal en móvil: aprovechar espacio vertical */
@media (max-height: 500px) and (orientation: landscape) {
    .page-shell {
        padding: 12px 0 20px;
    }

    .masthead {
        padding: 12px 16px;
    }

    .auth-card,
    .stage-card,
    .lineup-card {
        padding: 16px;
    }
}

/* Pantallas muy pequeñas (smartphones pequeños) */
@media (max-width: 380px) {
    .page-shell {
        width: 100%;
        padding: 12px 8px 24px;
    }

    .intro-card,
    .auth-card,
    .stage-card,
    .lineup-card,
    .admin-panel {
        padding: 16px;
        border-radius: 18px;
    }

    .auth-switch {
        flex-wrap: wrap;
    }

    .channel-rank,
    .channel-logo {
        width: 44px;
        height: 44px;
        border-radius: 14px;
    }

    .field input {
        padding: 14px 16px;
    }

    button {
        padding: 14px 18px;
    }
}

/* TV / Pantallas grandes (10-foot UI: visión desde ~3m) */
@media (min-width: 1400px) and (min-aspect-ratio: 16/9) {
    .dashboard-grid {
        gap: clamp(32px, 3.5vw, 48px);
    }
    :root {
        --touch-target-min: 56px;
    }

    .page-shell {
        width: min(1600px, calc(100% - 80px));
        padding: 32px 0 48px;
        gap: 24px;
    }

    .masthead h1,
    .intro-card h2,
    .auth-card h2,
    .dashboard-bar h2,
    .stage-card h3,
    .lineup-card h3 {
        font-size: clamp(1.8rem, 2.5vw, 2.6rem);
    }

    .lead,
    .muted,
    .channel-meta,
    .support-copy {
        font-size: 1.1rem;
        line-height: 1.75;
    }

    .channel-content h4 {
        font-size: 1.35rem;
    }

    .channel-card {
        padding: 22px;
    }

    button,
    .field input {
        min-height: 52px;
        padding: 18px 26px;
        font-size: 1rem;
    }

    .video-frame {
        border-radius: 32px;
    }

    /* Focus más visible a distancia */
    :focus-visible {
        outline-width: 4px;
        outline-offset: 4px;
    }
}

/* TV full HD / 4K: tipografía y espaciado ampliados */
@media (min-width: 1920px) {
    .page-shell {
        width: min(1720px, calc(100% - 120px));
        padding: 40px 0 60px;
        gap: 28px;
    }

    .masthead h1 {
        font-size: clamp(2rem, 2.2vw, 2.5rem);
    }

    .stage-card h3,
    .lineup-card h3 {
        font-size: clamp(2rem, 2.2vw, 2.5rem);
    }

    .channel-content h4 {
        font-size: 1.45rem;
    }

    .channels-grid {
        gap: 18px;
    }

    .channel-card {
        padding: 24px;
    }

    .player-state {
        font-size: 0.9rem;
        padding: 14px 20px;
    }

    .admin-table th,
    .admin-table td {
        padding: 16px;
        font-size: 1rem;
    }
}
