/* Dashboard CSS - Айдентика Unicast (как в Billing) */

/* ─── CSS Переменные (как в Billing) ─── */
:root {
    --blue:      #3b82f6;
    --blue-d:    #1e40af;
    --sidebar:   #0f172a;
    --bg:        #f1f5f9;
    --card:      #ffffff;
    --text:      #1e293b;
    --muted:     #64748b;
    --border:    #e2e8f0;
    --green:     #3b82f6;
    --red:       #94a3b8;
    --orange:    #60a5fa;
    --purple:    #3b82f6;
    --sidebar-w: 240px;
    /* Совместимость со старыми переменными.
       :root — это светлая тема, поэтому здесь должны быть светлые значения.
       Раньше тут стояли тёмные (--text-heading: #fff, --text-primary: #e0e0e0),
       и в светлой теме текст выходил почти белым на белой карточке. */
    --bg-primary:    #f1f5f9;
    --bg-secondary:  #ffffff;
    --bg-tertiary:   #f8fafc;
    --bg-input:      #ffffff;
    --bg-hover:      #f1f5f9;
    --text-primary:  #1e293b;
    --text-secondary:#64748b;
    --text-muted:    #94a3b8;
    --text-heading:  #0f172a;
    --text-label:    #475569;
    --card-shadow:   0 2px 8px rgba(15, 23, 42, 0.08);
    --accent:        #3b82f6;
    --accent-dark:   #1e40af;
    --accent-glow:   rgba(59,130,246,0.2);
}

/* Тёмная тема — все тексты светлые (белые/серые) */
[data-theme="dark"] {
    --card: #1a1a1a;
    --border: #2a2a2a;
    --bg-primary:   #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary:  #334155;
    --bg-input:     #1e293b;
    --bg-hover:     #334155;
    --text:         #e2e8f0;
    --muted:        #94a3b8;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted:   #94a3b8;
    --text-heading: #f8fafc;
    --text-label:   #cbd5e1;
    /* Тёмной теме нужна своя тень: светлая из :root на тёмном фоне не видна. */
    --card-shadow:  0 2px 8px rgba(0, 0, 0, 0.4);
}
/* Сайдбар: светлый текст при любой теме */
[data-theme="dark"] .sidebar .nav-item,
[data-theme="dark"] .sidebar .nav-group-title,
[data-theme="dark"] .sidebar .nav-sub-item {
    color: rgba(255,255,255,.9) !important;
}
[data-theme="dark"] .sidebar .nav-item svg,
[data-theme="dark"] .sidebar .nav-group-title svg {
    color: rgba(195, 197, 202, 1) !important;
}
[data-theme="dark"] .header h1,
[data-theme="dark"] .stat-value {
    color: #e2e8f0;
}
[data-theme="dark"] .stat-label {
    color: #94a3b8;
}
[data-theme="dark"] .header {
    background: var(--bg-secondary);
}
[data-theme="dark"] .main-content,
[data-theme="dark"] .page {
    background: var(--bg-primary);
}
[data-theme="dark"] .stat-card,
[data-theme="dark"] .screen-card,
[data-theme="dark"] .media-card,
[data-theme="dark"] .playlist-card {
    background: var(--bg-secondary);
}
[data-theme="dark"] .apk-status-text {
    color: #f8fafc;
}
[data-theme="dark"] .apk-status-meta {
    color: #94a3b8;
}

/* Outline icons (stroke-based, line-art style) */
.icon-outline {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Icon style: thin outlined lines, rounded corners */
.sidebar .nav-item svg,
.sidebar .nav-group-title svg,
.brand-icon-default,
.sidebar-collapse-icon,
.sidebar-expand-icon,
.btn-with-icon svg,
.screen-info-icon svg,
.screen-status-icon svg,
.playlist-stat-icon svg,
.stat-icon svg,
.schedule-icon svg,
.schedule-header-icon svg,
.schedule-status-badge .schedule-icon svg,
.btn-theme-icon svg,
.content-icon svg,
.available-item .item-icon svg,
.media-thumbnail svg,
.tab-btn-icon svg,
.pair-tv-icon svg,
.empty-state-icon svg,
.anim-select-arrow {
    stroke-width: 1.5 !important;
}

.pair-tv-icon {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-right: 6px;
    color: inherit;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    transition: background 0.25s, color 0.25s;
}

/* Предупреждение: тариф скоро истечёт */
.plan-expiry-banner {
    flex-shrink: 0;
    width: 100%;
    background: rgba(59, 130, 246, 0.12);
    border-bottom: 1px solid rgba(180, 83, 9, 0.35);
    color: var(--text-primary);
}
[data-theme="dark"] .plan-expiry-banner {
    background: rgba(59, 130, 246, 0.1);
    border-bottom-color: rgba(251, 191, 36, 0.25);
}
.plan-expiry-banner-inner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 20px 10px 16px;
    max-width: 100%;
    box-sizing: border-box;
}
.plan-expiry-banner-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
    line-height: 1.4;
    opacity: 0.9;
}
.plan-expiry-banner-text {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-size: 13px;
    line-height: 1.45;
}
.plan-expiry-banner-link {
    flex-shrink: 0;
    font-weight: 600;
    font-size: 13px;
    color: var(--accent, #60a5fa);
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
    align-self: center;
}
.plan-expiry-banner-link:hover {
    opacity: 0.88;
}
@media (max-width: 720px) {
    .plan-expiry-banner-inner {
        flex-wrap: wrap;
    }
    .plan-expiry-banner-link {
        width: 100%;
        margin-top: 4px;
    }
}

/* Sidebar — как в Billing */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    border-right: 1px solid rgba(255,255,255,.08);
    transition: width 0.2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-wordmark {
    display: inline-flex;
    width: auto;
    min-width: 0;
    flex-shrink: 0;
}

.brand-compact {
    display: none;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.sidebar.collapsed .brand-wordmark { display: none; }
.sidebar.collapsed .brand-compact { display: block; }

.sidebar-context {
    padding: 12px 14px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-context__card {
    display: grid;
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-context__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.2;
}

.sidebar-context__controls {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.sidebar-context__select-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.sidebar-context__select {
    width: 100%;
    height: 36px;
    padding: 0 32px 0 11px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background-color: #1e293b;
    color: #f8fafc;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    color-scheme: dark;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.sidebar-context__select:hover {
    border-color: rgba(255, 255, 255, 0.22);
    background-color: #243044;
}

.sidebar-context__select:focus {
    border-color: #3b82f6;
    background-color: #243044;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.sidebar-context__select option {
    background: #1e293b;
    color: #f8fafc;
}

.sidebar-context__select:disabled {
    opacity: 0.92;
    cursor: default;
    color: #f8fafc;
}

.sidebar-context__chevron {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: rgba(255, 255, 255, 0.45);
    pointer-events: none;
}

.sidebar-context__add {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 9px;
    background: #3b82f6;
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.12s;
}

.sidebar-context__add svg {
    width: 16px;
    height: 16px;
}

.sidebar-context__add:hover:not(:disabled) {
    background: #2563eb;
}

.sidebar-context__add:active:not(:disabled) {
    transform: scale(0.96);
}

.sidebar-context__add:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sidebar.collapsed .sidebar-context {
    display: none !important;
}

.brand-text {
    flex: 1;
    min-width: 0;
}
.sidebar-collapse-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6.84px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    background: transparent;
    transition: color 0.15s, background 0.15s;
}
.sidebar-collapse-btn:hover {
    color: #fff;
    background: rgba(255,255,255,.1);
}

/* Свёрнутый сайдбар — только иконки */
.sidebar.collapsed {
    width: 72px !important;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-group-title span,
.sidebar.collapsed .nav-group-arrow,
.sidebar.collapsed .nav-group-sub,
.sidebar.collapsed .nav-spacer {
    display: none !important;
}
/* Popover при свёрнутом сайдбаре — показывается справа при наведении */
.sidebar-nav-popover::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 0;
    bottom: 0;
    width: 12px;
}
.sidebar-nav-popover {
    display: none;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 12px;
    min-width: 160px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6.84px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    padding: 6px 0;
    z-index: 300;
    white-space: nowrap;
}
.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-group-title {
    position: relative;
}
.sidebar.collapsed .nav-item:hover .sidebar-nav-popover,
.sidebar.collapsed .nav-group-title:hover .sidebar-nav-popover {
    display: block;
}
.sidebar-popover-item {
    display: block;
    padding: 10px 14px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}
.sidebar-popover-item:hover {
    background: var(--bg-hover);
}
.sidebar.collapsed .sidebar-user {
    flex-direction: column;
    padding: 12px;
    gap: 8px;
}
.sidebar.collapsed .sidebar-user-info {
    display: none !important;
}
.sidebar.collapsed .btn-logout {
    margin: 0;
}
.sidebar.collapsed .sidebar-brand {
    flex-direction: column;
    padding: 16px 12px;
    gap: 8px;
}
.sidebar.collapsed .brand-icon {
    margin: 0;
}
.sidebar.collapsed .sidebar-collapse-btn .sidebar-collapse-icon {
    display: none !important;
}
.sidebar.collapsed .sidebar-collapse-btn .sidebar-expand-icon {
    display: block !important;
}
.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-group-title {
    justify-content: center;
    padding: 10px;
}
.sidebar.collapsed .nav-group-title {
    padding: 10px;
}
.sidebar.collapsed .nav-menu {
    padding: 8px 6px;
}
.sidebar.collapsed ~ .main-content {
    margin-left: 72px;
}
.main-content {
    transition: margin-left 0.2s ease;
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 8.55px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.brand-icon-main {
    width: 40px;
    height: 40px;
    display: block;
}

#sidebar-brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    inset: 0;
}

.brand-name {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

.brand-sub {
    color: rgba(255,255,255,.4);
    font-size: 11px;
}

/* Legacy logo (для совместимости) */
.logo { display: none; }
.logo-icon, .logo-text { display: none; }

.nav-menu {
    flex: 1;
    min-height: 0;
    padding: 12px 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6.84px;
    transition: all 0.15s, transform 0.15s;
    color: rgba(255,255,255,.8);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 6px;
    cursor: pointer;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}

.nav-item:active {
    transform: scale(0.98);
}

.nav-item.active {
    color: #fff;
    background: var(--blue);
    border-left: none;
}

.nav-soon-badge {
    margin-left: auto;
    padding: 3px 7px;
    border-radius: 999px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.14);
    color: #93c5fd;
    font-size: 10px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
    white-space: nowrap;
}

.nav-item.active .nav-soon-badge {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.nav-sub-item.has-soon-badge,
.sidebar-popover-item.has-soon-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sidebar.collapsed .nav-soon-badge {
    display: none !important;
}

.nav-item svg,
.nav-group-title svg {
    width: 18.9px;
    height: 18.9px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* Clopos-style nav: groups & sub-items */
.nav-spacer {
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.nav-group {
    margin-bottom: 6px;
}

/* Стиль как у nav-item — выравнивание под Плейлисты */
.nav-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: rgba(255,255,255,.8);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border-radius: 6.84px;
}

.nav-group-title:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.nav-group-title:active {
    transform: scale(0.98);
}

.nav-group-arrow {
    margin-left: auto;
    font-size: 16px;
    transition: transform 0.2s;
}

.nav-group.expanded .nav-group-arrow {
    transform: rotate(90deg);
}

.nav-group-sub {
    display: none;
}

.nav-group.expanded .nav-group-sub {
    display: block;
}

.nav-sub-item {
    display: block;
    padding: 10px 12px 10px 40px;
    color: rgba(255,255,255,.8);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s, transform 0.15s;
    cursor: pointer;
}

.nav-sub-item:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.nav-sub-item:active {
    transform: scale(0.98);
}

.nav-sub-item.active {
    background: rgba(255,255,255,.08);
    color: #3b82f6;
    border-left: 3px solid #3b82f6;
}

.admin-only {
    display: none;
}

.employees-access {
    display: none;
}

.module-coming-soon-banner {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    margin: 0 0 18px;
    border: 1px solid rgba(245, 158, 11, 0.28);
    border-radius: 12px;
    background: var(--card);
    border: 1px solid var(--brand-border, rgba(59, 130, 246, 0.2));
    box-shadow: var(--card-shadow);
}

.module-coming-soon-banner__badge {
    flex: 0 0 auto;
    padding: 6px 10px;
    border-radius: 999px;
    background: #3b82f6;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.module-coming-soon-banner__body {
    min-width: 0;
}

.module-coming-soon-banner__body strong {
    display: block;
    color: var(--text-heading);
    font-size: 15px;
    line-height: 1.35;
    margin-bottom: 4px;
}

.module-coming-soon-banner__body p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}

.module-coming-soon-banner--payment {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Полноэкранная заглушка «Скоро» — блюр контента + замок */
.is-coming-soon-module {
    overflow: hidden;
}

.module-soon-shell {
    position: relative;
    min-height: calc(100vh - 120px);
}

.module-soon-preview {
    filter: blur(10px);
    opacity: 0.38;
    pointer-events: none;
    user-select: none;
    transform: scale(1.01);
}

.module-soon-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse 80% 60% at 50% 40%, rgba(59, 130, 246, 0.12), transparent 70%),
        rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

[data-theme="light"] .module-soon-overlay {
    background:
        radial-gradient(ellipse 80% 60% at 50% 40%, rgba(59, 130, 246, 0.1), transparent 70%),
        rgba(241, 245, 249, 0.78);
}

.module-soon-card {
    max-width: 420px;
    width: 100%;
    padding: 32px 28px 28px;
    text-align: center;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(15, 23, 42, 0.92);
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(59, 130, 246, 0.15) inset;
}

[data-theme="light"] .module-soon-card {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.98);
    box-shadow:
        0 24px 48px rgba(15, 23, 42, 0.1),
        0 0 0 1px rgba(59, 130, 246, 0.08) inset;
}

.module-soon-lock {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.16);
    border: 1px solid rgba(59, 130, 246, 0.22);
    color: var(--brand-text, #93c5fd);
}

[data-theme="light"] .module-soon-lock {
    color: var(--brand-blue, #2563eb);
    border-color: rgba(59, 130, 246, 0.2);
}

.module-soon-hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted);
}

.module-soon-lock svg {
    width: 34px;
    height: 34px;
}

.module-soon-badge {
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 14px;
    border-radius: 999px;
    background: #3b82f6;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.module-soon-title {
    margin: 0 0 10px;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-heading);
}

.module-soon-text {
    margin: 0 0 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted);
}

.apk-page {
    padding: 40px;
    max-width: 520px;
}

.apk-status {
    margin-bottom: 24px;
}

.apk-status-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}

.apk-status-icon svg {
    width: 100%;
    height: 100%;
    stroke: var(--text-muted);
}

.apk-status-text {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-heading);
    margin-bottom: 4px;
}

.apk-status-meta {
    font-size: 13px;
    color: var(--text-muted);
}

.apk-hint {
    margin: 12px 0 0;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
    max-width: 480px;
}

.apk-upload-form {
    margin-bottom: 20px;
}

.apk-upload-form input[type="file"] {
    margin-right: 12px;
    margin-bottom: 12px;
}

.apk-download .btn {
    display: inline-block;
}

/* Настройки — скачать плеер */
#page-settings-apk .player-downloads-page {
    max-width: 920px;
    margin: 0 auto;
    padding: 8px 0 32px;
}

.player-downloads-header {
    margin-bottom: 24px;
}

.player-downloads-title {
    margin: 0 0 8px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-heading);
}

.player-downloads-intro {
    margin: 0;
    max-width: 640px;
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.55;
}

.player-downloads-grid {
    display: grid;
    gap: 14px;
}

.player-downloads-card {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 18px 20px;
    border-radius: 14px;
    border: 1px solid var(--ui-border, rgba(148, 163, 184, 0.16));
    background: var(--ui-surface, rgba(17, 24, 39, 0.88));
    box-shadow: var(--ui-shadow, 0 10px 28px rgba(15, 23, 42, 0.08));
}

.player-downloads-card.is-unavailable {
    opacity: 0.72;
}

.player-downloads-card__icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
}

.player-downloads-card__icon svg {
    width: 26px;
    height: 26px;
}

.player-downloads-card__title {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-heading);
}

.player-downloads-card__subtitle {
    margin: 0 0 8px;
    font-size: 0.84rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.player-downloads-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.player-downloads-card__version {
    font-weight: 700;
    color: var(--text-primary);
}

.player-downloads-card__build {
    color: var(--text-muted);
}

.player-downloads-card__action .btn-sm {
    min-width: 112px;
}

.player-downloads-card__soon {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: rgba(148, 163, 184, 0.14);
    color: var(--text-muted);
}

.player-downloads-loading,
.player-downloads-error {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
}

.player-downloads-admin {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--ui-border, rgba(148, 163, 184, 0.16));
}

.player-downloads-admin-title {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 700;
}

@media (max-width: 720px) {
    .player-downloads-card {
        grid-template-columns: 44px 1fr;
    }

    .player-downloads-card__action {
        grid-column: 1 / -1;
    }

    .player-downloads-card__action .btn-sm {
        width: 100%;
    }
}

/* Legacy APK billing tab */
#page-settings-apk .apk-page {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

#page-settings-apk .apk-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

#page-settings-apk .apk-status-icon {
    margin-left: auto;
    margin-right: auto;
}

#page-settings-apk .apk-hint {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

#page-settings-apk .apk-upload-form {
    text-align: center;
}

#page-settings-apk .apk-upload-form form {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

#page-settings-apk .apk-upload-form input[type="file"] {
    margin-right: 0;
    margin-bottom: 0;
}

#page-settings-apk .apk-download {
    text-align: center;
}

.settings-placeholder {
    padding: 60px 40px;
    text-align: center;
}

.settings-placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.settings-placeholder h2 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-heading);
}

.settings-placeholder p {
    color: var(--text-muted);
    font-size: 14px;
}

.settings-section {
    padding: 24px;
    max-width: 520px;
}

.settings-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 20px;
}

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

.settings-form .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.settings-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

.settings-subtitle {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.form-message {
    font-size: 13px;
    color: var(--success, #34d399);
}

.logo-upload-area {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.logo-preview {
    width: 80px;
    height: 80px;
    border: 1px dashed var(--border);
    border-radius: 6.84px;
    background: var(--bg);
    flex-shrink: 0;
}

.logo-upload-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.logo-file-input {
    display: none;
}

.logo-filename {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Main content — как в Billing */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 100vh;
}

.header {
    padding: 0 28px;
    height: 60px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Buttons — анимации при нажатии */
.btn {
    padding: 10px 20px;
    border-radius: 6.84px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: #3b82f6;
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-primary:active {
    transform: translateY(0) scale(0.97);
}

.btn-flexible {
    background: #3b82f6 !important;
}
.btn-flexible:hover {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4) !important;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary:active {
    transform: translateY(0) scale(0.97);
}

.btn-danger {
    background: #3b82f6;
    color: #fff;
}

.btn-danger:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-warning {
    background: #3b82f6;
    color: #fff;
}

.btn-warning:hover {
    background: #2563eb;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-success {
    background: #3b82f6;
    color: #fff;
}

.btn-success:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* Pages */
.page {
    flex: 1;
    padding: 24px 28px;
    overflow-y: auto;
    display: none;
}

.page.active {
    display: block;
}

/* Stats — как в Billing */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10.26px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10.26px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 25.2px;
    height: 25.2px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.stat-icon.blue   { background: rgba(59,130,246,.12); color: var(--blue); }
.stat-icon.green  { background: rgba(34,197,94,.12);  color: var(--green); }
.stat-icon.purple { background: rgba(139,92,246,.12); color: var(--purple); }
.stat-icon.orange { background: rgba(249,115,22,.12); color: var(--orange); }

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.stat-label {
    font-size: 12px;
    color: var(--muted);
}

/* Screens list */
.screens-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.screen-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10.26px;
    padding: 20px;
    transition: all 0.2s, transform 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.screen-card:hover {
    border-color: var(--blue);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.screen-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 16px;
}

.screen-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-heading);
}

.screen-status {
    padding: 4px 12px;
    border-radius: 10.26px;
    font-size: 12px;
    font-weight: 500;
}

.screen-status.paired {
    background: rgba(59, 130, 246, 0.12);
    color: var(--brand-text-soft, #2563eb);
}

.screen-status.unpaired {
    background: rgba(59, 130, 246, 0.08);
    color: var(--brand-text, #1e40af);
}

/* Индикатор онлайн статуса */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 10.26px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 10px;
}

.status-indicator.online {
    background: rgba(59, 130, 246, 0.16);
    color: var(--brand-pill-active-text, #fff);
    border: 1px solid rgba(96, 165, 250, 0.35);
}

.status-indicator.warning {
    background: rgba(59, 130, 246, 0.08);
    color: var(--brand-pill-text, #2563eb);
    border: 1px solid rgba(59, 130, 246, 0.22);
}

.status-indicator.offline {
    background: rgba(148, 163, 184, 0.08);
    color: var(--brand-text-muted, #64748b);
    border: 1px solid rgba(148, 163, 184, 0.22);
}

.status-indicator svg {
    width: 12.6px;
    height: 12.6px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.screen-status.unpaired {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.screen-status-icon {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
}

.screen-status-icon svg {
    width: 18.9px;
    height: 18.9px;
}

.screen-code {
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 4px;
    color: #3b82f6;
    margin-bottom: 16px;
    font-family: 'Courier New', monospace;
}

.screen-code {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px 10px;
    background: rgba(59, 130, 246, 0.07);
    border-left: 3px solid #3b82f6;
    border-radius: 0 5.13px 5.13px 0;
    margin: -8px 0 12px 0;
}

.screen-info {
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.screen-info div {
    margin: 4px 0;
}

.screen-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.screen-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--blue);
    opacity: 0.8;
}

.screen-info-icon svg {
    width: 18.48px;
    height: 18.48px;
    flex-shrink: 0;
}

.screen-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-with-icon .btn {
    transition: transform 0.15s;
}

.btn-with-icon .btn:active {
    transform: scale(0.97);
}

.btn-with-icon svg {
    width: 16.8px;
    height: 16.8px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Media list */
.media-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.media-type-tabs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    margin: 0 0 20px;
    padding: 4px;
    border-radius: var(--ui-radius);
    background: var(--ui-surface-2, rgba(15, 23, 42, 0.08));
}

.media-type-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 112px;
    padding: 9px 14px;
    border: 0;
    border-radius: var(--ui-radius-sm);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.media-type-tab:hover {
    color: var(--text-primary);
}

.media-type-tab.active {
    background: var(--card);
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.media-type-tab__count {
    min-width: 22px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.11);
    color: var(--ui-blue, #2563eb);
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

.media-type-tab.active .media-type-tab__count {
    background: var(--ui-blue, #2563eb);
    color: #fff;
}

@media (max-width: 560px) {
    .media-type-tabs {
        display: flex;
        width: 100%;
    }

    .media-type-tab {
        flex: 1;
        min-width: 0;
        padding-inline: 8px;
    }
}

.media-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10.26px;
    overflow: hidden;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.media-card:hover {
    border-color: var(--blue);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.media-preview {
    width: 100%;
    height: 150px;
    background: #0f0f0f;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.media-preview--clickable {
    cursor: zoom-in;
}

.media-preview--clickable::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    pointer-events: none;
    transition: border-color 0.16s ease, background 0.16s ease;
}

.media-preview--clickable:hover::after,
.media-preview--clickable:focus-visible::after {
    border-color: rgba(59, 130, 246, 0.92);
    background: rgba(15, 23, 42, 0.08);
}

.media-preview--clickable:focus-visible {
    outline: none;
}

body.media-lightbox-open {
    overflow: hidden;
}

.media-lightbox {
    position: fixed;
    inset: 0;
    z-index: 13000;
    display: grid;
    place-items: center;
    padding: clamp(16px, 3vw, 40px);
    background: rgba(2, 6, 23, 0.9);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.16s ease;
}

.media-lightbox.is-open {
    opacity: 1;
}

.media-lightbox__dialog {
    position: relative;
    display: flex;
    max-width: min(96vw, 1600px);
    max-height: calc(100dvh - 32px);
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.media-lightbox__image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100dvh - 92px);
    border-radius: 12px;
    background: #0f172a;
    object-fit: contain;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.media-lightbox__close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.82);
    color: #fff;
    font: 400 30px/1 Arial, sans-serif;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.media-lightbox__close:hover,
.media-lightbox__close:focus-visible {
    background: #2563eb;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.media-lightbox__caption {
    max-width: min(92vw, 900px);
    overflow: hidden;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .media-lightbox {
        padding: 8px;
    }

    .media-lightbox__dialog {
        max-width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
    }

    .media-lightbox__image {
        max-height: calc(100dvh - 66px);
        border-radius: 9px;
    }

    .media-lightbox__close {
        top: 8px;
        right: 8px;
        width: 40px;
        height: 40px;
    }
}

.ui-corner-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 24px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .95);
    border-radius: 50%;
    background: #fff;
    color: #2563eb;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .24);
    line-height: 1;
}

.ui-corner-status svg {
    width: 14px;
    height: 14px;
    flex: none;
}

.media-processing-badge,
.media-optimized-badge {
    position: absolute;
    top: 9px;
    right: 9px;
    z-index: 3;
    pointer-events: none;
}

.media-card--error {
    opacity: 0.85;
    border-color: rgba(239, 68, 68, 0.45);
}

.media-ffmpeg-banner {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
    font-size: 13px;
    line-height: 1.45;
}

.media-card.processing .media-preview video {
    opacity: 0.92;
}

.media-preview img,
.media-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.media-icon svg {
    width: 50.4px;
    height: 50.4px;
}

.media-info {
    padding: 16px;
}

.media-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-heading);
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.media-actions {
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.media-actions .btn {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #1a1a1a;
    border-radius: 10.26px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-content.modal-large {
    max-width: 700px;
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-heading);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.15s;
}

.modal-close:hover {
    color: var(--text-primary);
    transform: scale(1.05);
}

.modal-close:active {
    transform: scale(0.95);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid #2a2a2a;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-label);
}

.form-input {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6.84px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
}

/* Кастомный dropdown анимаций (иконки в стиле сайдбара) */
.anim-select {
    position: relative;
}
.anim-select-native {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}
.anim-select-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6.84px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s;
}
.anim-select-trigger:hover {
    border-color: var(--muted);
}
.anim-select.open .anim-select-trigger {
    border-color: #3b82f6;
}
.anim-select-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}
.anim-select-text {
    flex: 1;
}
.anim-select-arrow {
    flex-shrink: 0;
    color: var(--muted);
    transition: transform 0.2s;
}
.anim-select.open .anim-select-arrow {
    transform: rotate(180deg);
}
.anim-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6.84px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}
.anim-select.open .anim-select-dropdown {
    display: block;
}
.anim-select-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
    transition: background 0.15s;
}
.anim-select-option:hover {
    background: var(--bg-hover);
}
.anim-select-option.selected {
    background: rgba(59,130,246,0.15);
    color: #3b82f6;
}
.anim-option-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}
.anim-select-option.selected .anim-option-icon {
    color: #3b82f6;
}

/* Ползунок скорости анимации */
.form-range {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #3b82f6 0%, #3b82f6 var(--val, 15%), #2a2a2a var(--val, 15%), #2a2a2a 100%);
    border-radius: 3.42px;
    outline: none;
    cursor: pointer;
    margin-top: 8px;
}
.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 42.75%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
    transition: box-shadow 0.2s;
}
.form-range::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 5px rgba(59,130,246,0.35);
}
.form-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 42.75%;
    background: #3b82f6;
    border: none;
    cursor: pointer;
}

.code-input {
    font-size: 24px;
    letter-spacing: 8px;
    text-align: center;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
}

.help-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Upload area */
.upload-area {
    border: 2px dashed #2a2a2a;
    border-radius: 10.26px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.upload-icon {
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    margin: 0 auto 16px;
    border: 1px solid rgba(59, 130, 246, 0.24);
    border-radius: 18px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--blue);
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.upload-icon svg {
    width: 34px;
    height: 34px;
}

.upload-area:hover .upload-icon {
    border-color: rgba(59, 130, 246, 0.48);
    background: rgba(59, 130, 246, 0.18);
    transform: translateY(-2px);
}

.upload-progress {
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #2a2a2a;
    border-radius: 3.42px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-bar-fill {
    height: 100%;
    background: #3b82f6;
    width: 0%;
    transition: width 0.3s;
}

.modal-content--wide {
    max-width: 720px;
    width: 96%;
}

.upload-staging-hint {
    margin-bottom: 12px;
}

.upload-staging-toolbar {
    margin-bottom: 12px;
}

.upload-staging-select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-muted);
}

.upload-staging-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(52vh, 420px);
    overflow-y: auto;
    padding-right: 4px;
}

.upload-staging-row {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto auto;
    column-gap: 12px;
    row-gap: 4px;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.upload-staging-row.is-error {
    border-color: #ef4444;
}

.upload-staging-row.is-done {
    border-color: #22c55e;
    opacity: 0.85;
}

.upload-staging-thumb-cell,
.upload-staging-type-icon {
    grid-column: 1;
    grid-row: 1;
    width: 56px;
    height: 56px;
    min-width: 56px;
    max-width: 56px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--bg-hover);
    justify-self: start;
    align-self: center;
    flex-shrink: 0;
}

.upload-staging-main,
.upload-staging-info,
.upload-staging-row > div:nth-child(2):not(.upload-staging-side) {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.upload-staging-side {
    grid-column: 3 / 5;
    grid-row: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    justify-self: end;
}

.upload-staging-row > .upload-staging-optimize {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
}

.upload-staging-row > .upload-staging-remove {
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
}

.upload-staging-thumb {
    width: 100%;
    height: 100%;
    max-width: 56px;
    max-height: 56px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--bg-hover);
    display: block;
}

.upload-staging-thumb--video {
    object-fit: cover;
    pointer-events: none;
}

.upload-staging-thumb--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
}

.upload-staging-name-input {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-heading);
    font-size: 14px;
    margin: 0;
}

.upload-staging-name-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.upload-staging-meta {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    padding: 0;
}

.upload-staging-optimize {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
    color: var(--text-muted);
}

.upload-staging-optimize input {
    width: 16px;
    height: 16px;
}

.upload-staging-remove {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px 8px;
}

#upload-status {
    font-size: 14px;
    color: var(--text-muted);
}

/* Media selector */
.media-selector {
    display: grid;
    gap: 12px;
}

.media-checkbox-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #0f0f0f;
    border: 1px solid #2a2a2a;
    border-radius: 6.84px;
    cursor: pointer;
    transition: all 0.2s;
}

.media-checkbox-item:hover {
    border-color: #3b82f6;
}

.media-checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.media-thumbnail-wrap {
    width: 60px;
    height: 60px;
    border-radius: 3.42px;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}
.media-thumbnail {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.media-thumbnail svg {
    width: 33.6px;
    height: 33.6px;
}

/* Notifications */
.notifications {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notification {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6.84px;
    padding: 16px 20px;
    min-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification.success {
    border-left: 4px solid #28a745;
}

.notification.error {
    border-left: 4px solid #dc3545;
}

.notification.warning {
    border-left: 4px solid #ff9800;
}

.notification.info {
    border-left: 4px solid #3b82f6;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state-icon svg {
    width: 67.2px;
    height: 67.2px;
    color: var(--blue);
    opacity: 0.6;
}

.empty-state p {
    font-size: 18px;
    margin-bottom: 24px;
    color: var(--text-muted);
}

/* Center empty-state in list containers */
.screens-list:has(.empty-state),
.media-list:has(.empty-state),
.playlists-list:has(.empty-state),
.schedules-list:has(.empty-state) {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 280px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #2a2a2a;
    border-radius: 3.42px;
}

::-webkit-scrollbar-thumb:hover {
    background: #333;
}

/* Playlists list */
.playlists-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.playlist-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10.26px;
    padding: 20px;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.playlist-card:hover {
    border-color: var(--blue);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 16px;
}

.playlist-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
}

.playlist-mode {
    padding: 4px 12px;
    border-radius: 10.26px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.playlist-stats {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: flex;
    gap: 16px;
}

.playlist-stat-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.playlist-stat-icon {
    display: inline-flex;
    align-items: center;
    color: var(--blue);
    opacity: 0.8;
}

.playlist-stat-icon svg {
    width: 18.48px;
    height: 18.48px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.playlist-merge-stat.merge-status-ready { color: #22c55e; }
.playlist-merge-stat.merge-status-pending { color: #f59e0b; }
.playlist-merge-stat.merge-status-error { color: #ef4444; }
.playlist-merge-stat.merge-status-unsupported { color: var(--text-muted); }

.playlist-merge-banner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.35);
    font-size: 13px;
}

.playlist-merge-banner.merge-status-ready {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.08);
}

.playlist-merge-banner.merge-status-pending {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
}

.playlist-merge-banner.merge-status-error {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.08);
}

.playlist-merge-banner .merge-error-text {
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.85;
    word-break: break-word;
}

.playlist-merge-settings {
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.35);
    font-size: 13px;
}

.playlist-merge-settings.merge-status-ready {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.08);
}

.playlist-merge-settings.merge-status-pending {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
}

.playlist-merge-settings.merge-status-error {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.08);
}

.playlist-merge-settings-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.playlist-merge-settings-title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-heading);
}

.playlist-merge-settings-hint {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
}

.playlist-merge-status-badge {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(148, 163, 184, 0.15);
    white-space: nowrap;
}

.playlist-merge-settings.merge-status-ready .playlist-merge-status-badge {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.playlist-merge-settings.merge-status-pending .playlist-merge-status-badge {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.playlist-merge-settings.merge-status-error .playlist-merge-status-badge {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.playlist-merge-sources-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.playlist-merge-sources {
    margin: 0;
    padding-left: 1.2em;
    font-size: 12px;
    line-height: 1.5;
}

.playlist-merge-sources-empty {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.playlist-merge-result,
.playlist-merge-progress {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.playlist-merge-flash {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.45;
}

.playlist-merge-flash--ready {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.35);
    color: #86efac;
}

.playlist-merge-flash--error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.playlist-merge-flash-detail {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.45;
    word-break: break-word;
}

.playlist-merge-progress-panel {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.22);
}

.playlist-merge-progress-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.playlist-merge-progress-copy {
    flex: 1;
    min-width: 0;
}

.playlist-merge-progress-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #f3f4f6);
    margin-bottom: 4px;
}

.playlist-merge-progress-sub,
.playlist-merge-progress-meta {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
}

.playlist-merge-progress-meta {
    margin-top: 8px;
}

.playlist-merge-progress-track {
    margin-top: 10px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.playlist-merge-progress-bar {
    width: 40%;
    height: 100%;
    border-radius: inherit;
    background: #3b82f6;
    animation: playlist-merge-progress-indeterminate 1.4s ease-in-out infinite;
}

@keyframes playlist-merge-progress-indeterminate {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}

.playlist-merge-spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(245, 158, 11, 0.25);
    border-top-color: #f59e0b;
    border-radius: 50%;
    animation: playlist-merge-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.playlist-merge-spinner--inline {
    width: 14px;
    height: 14px;
    border-width: 2px;
    vertical-align: -2px;
    margin-right: 6px;
}

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

.btn-rebuild-merge.is-loading,
.btn-rebuild-merge:disabled {
    opacity: 0.72;
    cursor: wait;
}

.playlist-merge-settings-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

.playlist-merge-settings .merge-error-text {
    margin-top: 8px;
    font-size: 11px;
    opacity: 0.9;
    word-break: break-word;
    color: #ef4444;
}

.playlist-sync-settings {
    margin-bottom: 16px;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.25);
    background: rgba(59, 130, 246, 0.06);
}

.playlist-sync-settings-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.playlist-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Playlist media management */
.playlist-media-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.playlist-media-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-heading);
}

.playlist-media-list,
.available-media-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 12px;
    background: #0f0f0f;
    border: 1px solid #2a2a2a;
    border-radius: 6.84px;
}

.media-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6.84px;
    margin-bottom: 8px;
    cursor: move;
    transition: all 0.2s;
}

.media-item:hover {
    border-color: #3b82f6;
}

.media-item.dragging {
    opacity: 0.5;
    border-color: #3b82f6;
}

.media-info {
    flex: 1;
}

.media-info .media-name {
    font-size: 14px;
    color: var(--text-heading);
    margin-bottom: 4px;
}

.media-info .media-type {
    font-size: 12px;
    color: var(--text-muted);
}

.media-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-small {
    width: 80px;
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 3.42px;
    color: var(--text-primary);
    font-size: 12px;
}

.input-small:focus {
    outline: none;
    border-color: #3b82f6;
}

/* Schedules */
.schedules-list-container {
    max-height: 500px;
    overflow-y: auto;
}

.schedule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #0f0f0f;
    border: 1px solid #2a2a2a;
    border-radius: 6.84px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.schedule-item:hover {
    border-color: #3b82f6;
}

.schedule-info {
    flex: 1;
}

.schedule-playlist {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 8px;
}

.schedule-time,
.schedule-days {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.schedule-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 10.26px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 8px;
}

.schedule-status.active {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
}

.schedule-status.inactive {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
}

/* Schedule status badges */
.schedule-status-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 12px;
    border-radius: 10.26px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.schedule-status-badge .schedule-icon {
    color: inherit;
}

/* Выполняется (активно сейчас) */
.schedule-status-badge.status-running {
    background: #f44336;
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.schedule-item.schedule-running {
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.2);
}

/* Запланировано (еще не началось) */
.schedule-status-badge.status-scheduled {
    background: rgba(33, 150, 243, 0.2);
    color: #2196f3;
    border: 1px solid rgba(33, 150, 243, 0.3);
}

/* Выполнено (завершено) */
.schedule-status-badge.status-completed {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

/* Остановлено (вручную отключено) */
.schedule-status-badge.status-disabled {
    background: rgba(158, 158, 158, 0.2);
    color: #9e9e9e;
    border: 1px solid rgba(158, 158, 158, 0.3);
}

.schedule-item.schedule-disabled {
    opacity: 0.6;
}

/* Ожидание активации (ошибка?) */
.schedule-status-badge.status-pending {
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

/* Старые классы для обратной совместимости */
.currently-active-badge {
    background: #f44336;
    color: white;
    animation: pulse 2s infinite;
}

.schedule-item.currently-active {
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.2);
}

.schedule-item {
    position: relative;
}

.schedule-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Schedule action indicators */
.schedule-item.action-on {
    border-left: 3px solid #28a745;
}

.schedule-item.action-off {
    border-left: 3px solid #dc3545;
}

.schedule-item.action-replace {
    border-left: 3px solid #ffc107;
}

.schedule-name,
.schedule-action-label,
.schedule-media-name,
.schedule-time,
.schedule-duration,
.schedule-repeat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.schedule-name .schedule-icon,
.schedule-action-label .schedule-icon,
.schedule-media-name .schedule-icon,
.schedule-time .schedule-icon,
.schedule-duration .schedule-icon,
.schedule-repeat .schedule-icon {
    flex-shrink: 0;
    color: var(--muted);
}
.schedule-icon svg {
    width: 16.8px;
    height: 16.8px;
}
.schedule-header-icon svg {
    width: 21px;
    height: 21px;
}

.schedule-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 6px;
    color: #fff;
}

.schedule-action-label {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 8px;
}

.schedule-media-name {
    font-size: 14px;
    color: #999;
    margin-bottom: 4px;
}

.schedule-time {
    font-size: 13px;
    color: #999;
    margin-bottom: 4px;
}

.schedule-duration {
    font-size: 13px;
    color: #999;
    margin-bottom: 4px;
}

.schedule-repeat {
    font-size: 13px;
    color: #999;
    margin-bottom: 4px;
}

/* Flexible schedule slots editor */
.schedule-slot-item {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6.84px;
    padding: 12px;
    margin-bottom: 12px;
}

.schedule-slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.schedule-slot-num {
    font-weight: 600;
    color: #fff;
    font-size: 13px;
}

.schedule-slot-fields {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
}

.schedule-slot-fields .schedule-slot-media {
    min-width: 180px;
}

.schedule-slot-fields .schedule-slot-start,
.schedule-slot-fields .schedule-slot-end {
    min-width: 160px;
}

@media (max-width: 640px) {
    .schedule-slot-fields {
        grid-template-columns: 1fr;
    }
}

/* Schedule screens multi-select */
.schedule-screens-multiselect {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6.84px;
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
}
.schedule-screen-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
}
.schedule-screen-item:hover {
    color: var(--accent);
}
.schedule-screen-item input[type="checkbox"] {
    cursor: pointer;
}

.schedule-content-select-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.schedule-content-select-row select {
    flex: 1;
    min-width: 140px;
}
.schedule-content-or {
    color: var(--text-muted);
    font-size: 13px;
}

/* Screen schedules grouping */
.screen-schedules-group {
    margin-bottom: 30px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 10.26px;
    padding: 20px;
}

.screen-schedules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #2a2a2a;
}

.screen-schedules-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
}
.screen-schedules-header-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}
.screen-schedules-header-icon svg {
    width: 21px;
    height: 21px;
}

.screen-schedules-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.schedules-list {
    padding: 20px;
}

/* Playlist selector */
.playlists-selector {
    max-height: 400px;
    overflow-y: auto;
}

.playlist-checkbox-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #0f0f0f;
    border: 1px solid #2a2a2a;
    border-radius: 6.84px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.playlist-checkbox-item:hover {
    border-color: #3b82f6;
    background: #1a1a1a;
}

.playlist-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    cursor: pointer;
}

.playlist-checkbox-item label {
    flex: 1;
    cursor: pointer;
    margin: 0;
}

.playlist-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.playlist-name {
    font-weight: 500;
    color: var(--text-heading);
}

.playlist-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.form-text {
    color: var(--text-primary);
    font-size: 14px;
    padding: 8px 0;
}

/* ========================================
   UNIFIED CONTENT MANAGER
   ======================================== */

/* Tabs */
.content-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid #2a2a2a;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab-btn-icon {
    display: inline-flex;
    opacity: 0.85;
}
.tab-btn-icon svg {
    display: block;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: #4caf50;
    border-bottom-color: #4caf50;
}

.tab-btn:active {
    transform: scale(0.98);
}

.content-tab-count {
    display: inline-grid;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    place-items: center;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 14%, transparent);
    color: inherit;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.tab-btn.active .content-tab-count {
    background: color-mix(in srgb, #4caf50 16%, transparent);
}

/* Content: активное расписание и обычный контент */
.content-schedule-notice {
    margin-bottom: 16px;
}
.schedule-badge {
    display: inline-block;
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 8px 14px;
    border-radius: 6.84px;
    font-size: 14px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.content-original-section {
    margin-top: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(255, 152, 0, 0.08);
    border-radius: 6.84px;
    border: 1px solid rgba(255, 152, 0, 0.2);
}
.content-original-title {
    font-size: 14px;
    color: #ffb74d;
    margin-bottom: 8px;
}
.content-original-list {
    font-size: 13px;
    color: var(--text-muted);
}
.content-original-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
}
.content-original-item svg {
    width: 16.8px;
    height: 16.8px;
    flex-shrink: 0;
    opacity: 0.9;
}

/* Selected Content Section */
.selected-content-section {
    margin-bottom: 32px;
    background: #1a1a1a;
    padding: 20px;
    border-radius: 10.26px;
}

.selected-content-section h3 {
    color: var(--text-heading);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.sortable-content-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100px;
}

.content-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #2a2a2a;
    padding: 12px;
    border-radius: 6.84px;
    cursor: move;
    transition: all 0.2s;
}

.content-item:hover {
    background: #333;
}

.content-item.dragging {
    opacity: 0.5;
}

.content-transition-row {
    position: relative;
    padding: 2px 12px 5px 52px;
}

.content-transition-rail {
    display: grid;
    grid-template-columns: minmax(18px, 1fr) auto minmax(18px, 1fr);
    align-items: center;
    gap: 8px;
    max-width: 210px;
    margin: 0 0 7px 2px;
    color: var(--text-muted);
}

.content-transition-rail span {
    height: 1px;
    background: color-mix(in srgb, var(--accent) 34%, transparent);
}

.content-transition-rail b {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.content-transition-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 9px;
    border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--border));
    background: color-mix(in srgb, var(--accent) 5%, var(--bg-secondary));
    border-radius: 9px;
}

.content-transition-options,
.content-transition-duration {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.content-transition-option,
.content-transition-duration button {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    border-radius: 7px;
    cursor: pointer;
    transition: .16s ease;
}

.content-transition-option {
    min-width: 54px;
    padding: 6px 7px 5px;
    display: inline-grid;
    justify-items: center;
    gap: 2px;
}

.content-transition-option > span {
    font-size: 18px;
    line-height: 1;
}

.content-transition-option small {
    font-size: 10px;
    font-weight: 600;
}

.content-transition-option:hover,
.content-transition-duration button:hover {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 9%, transparent);
}

.content-transition-option.is-active {
    color: #fff;
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 24%, transparent);
}

.content-transition-duration {
    flex: 0 0 auto;
    padding-left: 10px;
    border-left: 1px solid var(--border-color);
}

.content-transition-duration button {
    padding: 6px 7px;
    font-size: 11px;
    font-weight: 700;
}

.content-transition-duration button.is-active {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.drag-handle {
    color: var(--text-muted);
    cursor: grab;
    font-size: 18px;
}

.drag-handle:active {
    cursor: grabbing;
}

.content-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--text-muted);
}
.content-icon svg {
    width: 25.2px;
    height: 25.2px;
}

.content-info {
    flex: 1;
}

.content-name {
    color: var(--text-heading);
    font-weight: 500;
    margin-bottom: 4px;
}

.content-type {
    color: var(--text-muted);
    font-size: 12px;
}

/* Available Content Section */
.available-content-section {
    background: #1a1a1a;
    padding: 20px;
    border-radius: 10.26px;
}

.available-content-section h3 {
    color: var(--text-heading);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.screen-merge-status {
    position: sticky;
    bottom: 0;
    z-index: 4;
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border-color));
    border-radius: 11px;
    background: color-mix(in srgb, var(--primary) 8%, var(--bg-card));
    box-shadow: 0 -8px 28px color-mix(in srgb, #000 10%, transparent);
}

.screen-merge-status[hidden] {
    display: none !important;
}

.screen-merge-status--ready {
    border-color: color-mix(in srgb, #22c55e 45%, var(--border-color));
    background: color-mix(in srgb, #22c55e 8%, var(--bg-card));
}

.screen-merge-status--error {
    border-color: color-mix(in srgb, #ef4444 45%, var(--border-color));
    background: color-mix(in srgb, #ef4444 7%, var(--bg-card));
}

.screen-merge-status__head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.screen-merge-status__head > div {
    min-width: 0;
    flex: 1;
}

.screen-merge-status__head strong {
    display: block;
    color: var(--text-heading);
    font-size: 14px;
}

.screen-merge-status__head p {
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}

.screen-merge-status__icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    font-weight: 800;
}

.screen-merge-status__icon i {
    width: 15px;
    height: 15px;
    border: 2px solid color-mix(in srgb, var(--primary) 22%, transparent);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: playlist-merge-spin .8s linear infinite;
}

.screen-merge-status__badge {
    flex: 0 0 auto;
    padding: 5px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.screen-merge-status__track {
    height: 5px;
    margin-top: 11px;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.screen-merge-status__track span {
    display: block;
    height: 100%;
    min-width: 8%;
    border-radius: inherit;
    background: var(--primary);
    transition: width .35s ease;
}

@media (max-width: 820px) {
    .content-transition-row {
        padding-left: 20px;
    }

    .content-transition-controls {
        align-items: stretch;
        flex-direction: column;
    }

    .content-transition-duration {
        padding: 8px 0 0;
        border-left: 0;
        border-top: 1px solid var(--border-color);
    }
}

.tab-content-pane {
    display: none;
}

.tab-content-pane.active {
    display: block;
}

.available-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.available-item {
    background: #2a2a2a;
    padding: 16px;
    border-radius: 6.84px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    min-width: 0; /* позволяет сжиматься во flex/grid */
}

.available-item:hover {
    background: #333;
}

.available-item .item-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--text-muted);
}
.available-item .item-icon svg {
    width: 29.4px;
    height: 29.4px;
}

.available-item .item-name {
    flex: 1;
    min-width: 0;
    color: var(--text-heading);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.available-item .item-copy {
    flex: 1;
    min-width: 0;
}

.available-item .item-copy .item-name {
    display: block;
}

.available-item .item-meta {
    margin-top: 4px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.available-item--playlist {
    border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border-color));
}

.content-type--video,
.content-type--playlist {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
}

.content-type--video {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.10);
}

.content-type--playlist {
    color: #7c3aed;
    background: rgba(124, 58, 237, 0.10);
}

.available-item .btn {
    flex-shrink: 0;
}

.empty-state-text {
    text-align: center;
    color: #666;
    padding: 40px;
    font-size: 14px;
}

/* Modal XL size */
.modal-xl {
    width: 90%;
    max-width: 1200px;
}

/* Screen content modal — прокрутка тела, шапка/футер закреплены */
#modal-screen-content .modal-content {
    width: min(1200px, calc(100vw - 48px));
    max-width: min(1200px, calc(100vw - 48px));
    max-height: min(820px, calc(100vh - 48px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#modal-screen-content .modal-header,
#modal-screen-content .modal-footer {
    flex: 0 0 auto;
}

#modal-screen-content .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Sidebar user info — как в Billing */
.sidebar-user {
    padding: 14px 14px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    display: block;
    text-align: left;
}

.sidebar-user-profile {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.sidebar-user-profile:hover,
.sidebar-user-profile:focus-visible {
    background: rgba(59, 130, 246, 0.14);
    outline: none;
}

.sidebar-user-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
}

.sidebar-user-chevron {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    color: #94a3b8;
}

.sidebar-user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    display: block;
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

.btn-logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 6.84px;
    color: rgba(255,255,255,.8);
    cursor: pointer;
    font-size: 16px;
    padding: 6px 10px;
    transition: all 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.btn-logout:hover {
    border-color: #ef4444;
    color: #ef4444;
}

.account-summary-modal {
    inset: auto auto 86px 14px;
    width: min(400px, calc(100vw - 28px));
    height: auto;
    background: transparent;
    align-items: initial;
    justify-content: initial;
}
.modal.account-summary-modal {
    padding: 0;
    background: transparent;
    backdrop-filter: none;
}
.account-summary-modal.active { display: block; }
.account-summary-modal::after {
    content: none;
}
.modal.account-summary-modal .modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    max-height: calc(100vh - 110px);
    margin: 0;
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid var(--ui-border);
    background: var(--ui-surface);
    background-clip: padding-box;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .18);
    isolation: isolate;
}
.account-summary-modal .modal-header {
    flex: 0 0 auto;
    padding: 14px 16px;
    border-radius: 13px 13px 0 0;
    box-shadow: none;
}
.account-summary-modal .modal-header h2 { font-size: 16px; }
.account-summary-modal .modal-close { width: 28px; height: 28px; font-size: 25px; }
.account-summary-modal .modal-body {
    min-height: 0;
    padding: 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.account-summary-modal .modal-footer {
    flex: 0 0 auto;
    padding: 10px 14px;
    border-radius: 0 0 13px 13px;
    box-shadow: none;
}
.account-summary-modal .modal-footer .btn { min-height: 34px; padding: 7px 12px; }
.account-summary-modal .modal-header > div { min-width: 0; }
.account-summary-subtitle { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.account-summary-loading,
.account-summary-error {
    padding: 24px 14px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--muted);
    text-align: center;
}
.account-summary-error { color: #ef4444; }
.account-summary-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 2px 2px 14px;
    border: 0;
    border-bottom: 1px solid var(--ui-border, var(--border));
    border-radius: 0;
    background: transparent;
}
.account-summary-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border: 1px solid var(--ui-border, var(--border));
    border-radius: 50%;
    background: var(--ui-surface-2, var(--bg-secondary));
    color: var(--accent);
    font-size: 15px;
    font-weight: 800;
}
.account-summary-identity span { color: var(--muted); font-size: 11px; }
.account-summary-identity h3 { margin: 2px 0; color: var(--text); font-size: 15px; }
.account-summary-identity p { margin: 0; color: var(--muted); font-size: 11px; }
.account-summary-identity p strong { color: var(--text); }
.account-summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--ui-border, var(--border));
    border-radius: 10px;
}
.account-summary-grid article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 10px;
    min-height: 0;
    padding: 10px 12px;
    border: 0;
    border-radius: 0;
    background: var(--ui-surface, var(--card));
}
.account-summary-grid article + article { border-top: 1px solid var(--ui-border, var(--border)); }
.account-summary-grid article > span { color: var(--muted); font-size: 11px; }
.account-summary-grid article > strong { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--text); font-size: 14px; line-height: 1.2; text-align: right; font-variant-numeric: tabular-nums; }
.account-summary-grid article > small { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 10px; }
.account-summary-grid__primary {
    border-color: var(--ui-border, var(--border)) !important;
    background: var(--ui-surface, var(--card)) !important;
}
.account-summary-modal .modal-footer .btn { text-decoration: none; }
[data-theme="light"] .account-summary-grid article { background: var(--ui-surface, #fff); }

@media (max-width: 680px) {
    .account-summary-grid { grid-template-columns: minmax(0, 1fr); }
    .account-summary-modal {
        left: 12px;
        bottom: calc(86px + env(safe-area-inset-bottom));
        width: min(360px, calc(100vw - 24px));
    }
    .account-summary-modal .modal-content { width: 100%; }
}

.btn-logout:active {
    transform: scale(0.95);
}

.btn-logout svg {
    display: block;
}

/* Billing page tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

/* Billing tabs */
.billing-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8.55px;
    padding: 4px;
    width: fit-content;
}

.billing-tab {
    padding: 8px 20px;
    background: transparent;
    border: none;
    border-radius: 5.99px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s, transform 0.15s;
}

.billing-tab.active {
    background: var(--bg-tertiary);
    color: var(--blue);
}

.billing-tab:hover:not(.active) {
    color: var(--text-secondary);
}

.billing-tab:active {
    transform: scale(0.97);
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 17.1px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-active   { background: rgba(59,130,246,0.15); color: var(--brand-text-soft, #60a5fa); }
.badge-suspended{ background: rgba(148,163,184,0.15); color: var(--brand-text-muted, #94a3b8); }
.badge-trial    { background: rgba(59,130,246,0.15);  color: var(--brand-text-soft, #60a5fa); font-size:10px; margin-left:4px; }
.badge-expired  { background: rgba(148,163,184,0.15); color: var(--brand-text-muted, #94a3b8); }
.badge-cancelled{ background: rgba(148,163,184,0.15); color: var(--brand-text-muted, #94a3b8); }
.badge-admin    { background: rgba(59,130,246,0.15); color: var(--brand-text-soft, #60a5fa); }
.badge-user     { background: rgba(107,114,128,0.15);color: #9ca3af; }

[data-theme="light"] .badge-active   { color: #1d4ed8; }
[data-theme="light"] .badge-suspended,
[data-theme="light"] .badge-cancelled,
[data-theme="light"] .badge-expired { color: #64748b; }

/* Billing layout */
.billing-toolbar {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.billing-pane-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.billing-pane-header--split {
    justify-content: space-between;
}

.employees-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.brands-header,
.plans-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
}

.table-actions .btn {
    flex: 0 1 auto;
    white-space: nowrap;
}

.brand-info-grid {
    display: grid;
    gap: 16px;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

.brand-info-grid strong {
    color: var(--text-heading);
    font-weight: 600;
}

.brand-info-section {
    margin-top: 12px;
}

.data-table--compact td {
    padding: 6px 8px;
}

#page-users-billing .stat-icon.green,
#page-users-billing .stat-icon.purple {
    background: rgba(59, 130, 246, 0.12);
    color: var(--blue);
}

/* Sync groups */
.sync-group-card {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    color: var(--text-primary);
}

.sync-group-card__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sync-group-card__name-wrap {
    flex: 1;
    min-width: 200px;
}

.sync-group-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sync-group-screens-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 4px 16px;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.sync-screen-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    color: var(--text-primary);
}

.sync-screen-label__muted {
    opacity: 0.55;
    font-size: 12px;
}

/* Admin tables — theme-aware cells */
.admin-td-center {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}

.admin-td-error {
    padding: 20px;
    color: var(--text-muted);
}

.admin-cell-title {
    font-weight: 500;
    color: var(--text-heading);
}

.admin-cell-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.admin-cell-muted {
    color: var(--text-secondary);
    font-size: 13px;
}

.admin-cell-dim {
    color: var(--text-muted);
}

.btn-table-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    /* Sidebar и header — см. dashboard-mobile.css */
    .screens-list,
    .media-list,
    .playlists-list {
        grid-template-columns: 1fr;
    }

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

/* ═══════════════════════════════════════════════════════
   СВЕТЛАЯ ТЕМА (как в Billing)
   ═══════════════════════════════════════════════════════ */
[data-theme="light"] {
    --bg-primary:    #f1f5f9;
    --bg-secondary:  #ffffff;
    --bg-tertiary:   #f8fafc;
    --bg-input:      #ffffff;
    --bg-hover:      #f1f5f9;
    --border:        #e2e8f0;
    --border-light:  #e2e8f0;
    --text:          #1e293b;
    --muted:         #475569;
    --text-primary:  #1e293b;
    --text-secondary:#64748b;
    --text-muted:    #475569;
    --text-heading:  #0f0f1a;
    --text-label:    #374151;
    --card-shadow:   0 1px 4px rgba(0,0,0,.06);
}

[data-theme="light"] body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Sidebar */
[data-theme="light"] .sidebar {
    background: var(--sidebar);
    border-right: none;
}
[data-theme="light"] .logo {
    border-bottom: 1px solid var(--border);
}
[data-theme="light"] .logo-text {
    color: #0f0f1a;
}
/* Сайдбар всегда тёмный — принудительно светлый текст */
[data-theme="light"] .sidebar .nav-item,
[data-theme="light"] .sidebar .nav-group-title,
[data-theme="light"] .sidebar .nav-sub-item {
    color: rgba(255,255,255,.9);
}
[data-theme="light"] .sidebar .nav-item svg,
[data-theme="light"] .sidebar .nav-group-title svg {
    color: rgba(195, 197, 202, 1) !important;
}
[data-theme="light"] .sidebar .nav-item:hover,
[data-theme="light"] .sidebar .nav-group-title:hover,
[data-theme="light"] .sidebar .nav-sub-item:hover {
    color: #fff;
}
[data-theme="light"] .sidebar-user {
    border-top: 1px solid rgba(255,255,255,.15);
}
/* Sidebar always dark — use light text in both themes */
[data-theme="light"] .sidebar-user-name {
    color: #e2e8f0;
}
[data-theme="light"] .sidebar-user-role {
    color: #94a3b8;
}
[data-theme="light"] .btn-logout {
    border-color: rgba(255,255,255,.3);
    color: rgba(255,255,255,.8);
}
[data-theme="light"] .btn-logout:hover {
    border-color: rgba(96, 165, 250, 0.6);
    color: #93c5fd;
}

/* Header */
[data-theme="light"] .header {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
}
[data-theme="light"] .header h1 {
    color: #0f0f1a;
}

/* Main content */
[data-theme="light"] .main-content {
    background: var(--bg-primary);
}

/* Pages */
[data-theme="light"] .page {
    background: var(--bg-primary);
}

/* Stat cards */
[data-theme="light"] .stat-card {
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    color: #1e293b;
}
[data-theme="light"] .stat-value {
    color: #1e293b;
}
[data-theme="light"] .stat-label {
    color: #475569;
}
[data-theme="light"] .apk-status-text {
    color: #1e293b;
}
[data-theme="light"] .apk-status-meta {
    color: #475569;
}

/* Screen / Media / Playlist cards */
[data-theme="light"] .screen-card,
[data-theme="light"] .media-card,
[data-theme="light"] .playlist-card {
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
}
[data-theme="light"] .screen-card:hover,
[data-theme="light"] .media-card:hover,
[data-theme="light"] .playlist-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(59,130,246,0.15);
}
[data-theme="light"] .screen-name,
[data-theme="light"] .media-name,
[data-theme="light"] .playlist-name {
    color: #0f0f1a;
}
[data-theme="light"] .screen-info {
    color: #4a5568;
}

/* Screen status — читаемый контраст на светлой теме */
[data-theme="light"] .screen-status.unpaired {
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
}
[data-theme="light"] .screen-status.paired {
    background: rgba(59, 130, 246, 0.14);
    color: #1e40af;
}
[data-theme="light"] .screen-status-icon {
    color: inherit;
}

/* Screen code */
[data-theme="light"] .screen-code {
    background: rgba(59,130,246,0.06);
    border-left-color: var(--accent);
}
[data-theme="light"] .screen-code span {
    color: var(--accent-dark);
}

/* Buttons */
[data-theme="light"] .btn-secondary {
    background: #f0f2f5;
    color: #1a1a2e;
    border: 1px solid var(--border);
}
[data-theme="light"] .btn-secondary:hover {
    background: #e2e6ed;
}
[data-theme="light"] .btn-danger {
    background: #3b82f6;
    color: #fff;
}

/* Modals */
[data-theme="light"] .modal {
    background: rgba(0,0,0,0.45);
}
[data-theme="light"] .modal-content {
    background: #ffffff;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
[data-theme="light"] .modal-header {
    border-bottom: 1px solid var(--border);
}
[data-theme="light"] .modal-header h2 {
    color: #0f0f1a;
}
[data-theme="light"] .modal-close {
    color: #718096;
}
[data-theme="light"] .modal-close:hover {
    color: #0f0f1a;
}
[data-theme="light"] .modal-footer {
    border-top: 1px solid var(--border);
    background: #ffffff;
}

/* Forms */
[data-theme="light"] .form-group label {
    color: #2d3748;
}
[data-theme="light"] .form-input,
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="email"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="number"],
[data-theme="light"] input[type="datetime-local"],
[data-theme="light"] select,
[data-theme="light"] textarea {
    background: #ffffff;
    border: 1px solid var(--border);
    color: #1a1a2e;
}
[data-theme="light"] .form-input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
[data-theme="light"] .form-input::placeholder,
[data-theme="light"] input::placeholder {
    color: #a0aec0;
}
[data-theme="light"] .help-text {
    color: #718096;
}

/* Range slider */
[data-theme="light"] .form-range {
    background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--val, 15%), #d4d8e1 var(--val, 15%), #d4d8e1 100%);
}

/* Upload area */
[data-theme="light"] .upload-area {
    border: 2px dashed var(--border);
    background: #f8fafc;
    color: #4a5568;
}
[data-theme="light"] .upload-area:hover {
    border-color: var(--accent);
    background: #eff6ff;
}

/* Schedules */
[data-theme="light"] .schedule-item {
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
}
[data-theme="light"] .screen-schedules-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
[data-theme="light"] .screen-schedules-header h3 {
    color: #1a1a2e;
}
[data-theme="light"] .schedule-info {
    color: #2d3748;
}

/* Notifications */
[data-theme="light"] .notification {
    background: #ffffff;
    border: 1px solid var(--border);
    color: #1a1a2e;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

/* Tables (billing) */
[data-theme="light"] .data-table th {
    color: #4a5568;
    border-bottom: 1px solid var(--border);
}
[data-theme="light"] .data-table td {
    color: #1a1a2e;
    border-bottom: 1px solid #f0f2f5;
}
[data-theme="light"] .data-table tbody tr:hover {
    background: #f8fafc;
}

/* Billing tabs */
[data-theme="light"] .billing-tabs {
    background: #f0f2f5;
    border: 1px solid var(--border);
}
[data-theme="light"] .billing-tab {
    color: #4a5568;
}
[data-theme="light"] .billing-tab.active {
    background: #ffffff;
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Content tabs */
[data-theme="light"] .content-tabs {
    border-bottom: 1px solid var(--border);
}
[data-theme="light"] .tab-btn {
    color: #4a5568;
}
[data-theme="light"] .tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Sortable content items */
[data-theme="light"] .content-item,
[data-theme="light"] .available-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    color: #1a1a2e;
}
[data-theme="light"] .content-item:hover,
[data-theme="light"] .available-item:hover {
    background: #eff6ff;
    border-color: var(--accent);
}

/* Available items grid */
[data-theme="light"] .available-items-grid .available-item {
    background: #ffffff;
    border: 1px solid var(--border);
    color: #1a1a2e;
}

/* Playlist media */
[data-theme="light"] .playlist-media-list .media-item-row,
[data-theme="light"] .available-media-list .media-item-row {
    background: #f8fafc;
    border: 1px solid var(--border);
    color: #1a1a2e;
}

/* Empty state */
[data-theme="light"] .empty-state,
[data-theme="light"] .empty-state p {
    color: #475569;
}

/* Loading overlay */
[data-theme="light"] #auth-loading {
    background: var(--bg-primary);
}

/* Auth screen */
[data-theme="light"] .auth-card {
    background: #ffffff;
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
    border: 1px solid var(--border);
}
[data-theme="light"] .auth-title {
    color: #0f0f1a;
}
[data-theme="light"] .auth-subtitle {
    color: #4a5568;
}

/* QR connect modal */
[data-theme="light"] #qr-connect-modal > div {
    background: #ffffff !important;
}
[data-theme="light"] #qr-connect-modal h2 {
    color: #0f0f1a !important;
}
[data-theme="light"] #qr-connect-modal p,
[data-theme="light"] #qr-connect-modal div {
    color: #2d3748;
}

/* Theme & Lang toggle buttons */
.btn-theme,
.btn-lang {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6.84px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 7px 12px;
    transition: all 0.2s, transform 0.15s;
    line-height: 1;
    white-space: nowrap;
}
.btn-theme {
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-theme .btn-theme-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-theme .btn-theme-icon svg {
    width: 21px;
    height: 21px;
    flex-shrink: 0;
}
.btn-theme:hover,
.btn-lang:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}
.btn-theme:active,
.btn-lang:active {
    transform: scale(0.95);
}

[data-theme="light"] .btn-theme,
[data-theme="light"] .btn-lang {
    border-color: var(--border);
    color: #4a5568;
}
[data-theme="light"] .btn-theme:hover,
[data-theme="light"] .btn-lang:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(59,130,246,0.08);
}

/* QR scanner overlay in light mode */
[data-theme="light"] #qr-scanner-overlay {
    background: rgba(0,0,0,0.85) !important;
}

/* Light theme: списки и контейнеры с тёмным фоном */
[data-theme="light"] .playlist-media-list,
[data-theme="light"] .available-media-list {
    background: #f8fafc !important;
    border-color: var(--border) !important;
}

[data-theme="light"] .media-checkbox-item,
[data-theme="light"] .playlist-checkbox-item {
    background: #f8fafc !important;
    border-color: var(--border) !important;
}

[data-theme="light"] .media-checkbox-item:hover,
[data-theme="light"] .playlist-checkbox-item:hover {
    background: #eff6ff !important;
}

[data-theme="light"] .schedule-item {
    background: #ffffff !important;
    border-color: var(--border) !important;
}

[data-theme="light"] .media-item {
    background: #f8fafc !important;
    border-color: var(--border) !important;
}

[data-theme="light"] .screen-schedules-group {
    background: #ffffff !important;
    border-color: var(--border) !important;
}

[data-theme="light"] .selected-content-section,
[data-theme="light"] .available-content-section {
    background: #f8fafc !important;
}

[data-theme="light"] .content-item,
[data-theme="light"] .available-item {
    background: #ffffff !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .content-item:hover,
[data-theme="light"] .available-item:hover {
    background: #eff6ff !important;
}

[data-theme="light"] .billing-tabs {
    background: #f0f2f5 !important;
    border-color: var(--border) !important;
}

[data-theme="light"] .billing-tab.active {
    background: #ffffff !important;
}

/* ─── Payment page (Multicard) ─── */
.payment-card {
    background: var(--card);
    border-radius: 16px;
    padding: 32px;
    border: 1px solid var(--border);
    max-width: 600px;
    margin: 0 auto;
    box-shadow: var(--card-shadow);
}

.payment-multicard-hint {
    max-width: 42em;
}

.payment-quick-amounts {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.payment-amount-shortcut {
    flex: 1;
    padding: 10px;
    font-size: 13px;
}

.balance-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    padding: 28px;
    background: #3b82f6;
    border-radius: 16px;
    color: white;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.2);
}

.screen-billing-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.screen-billing-summary article {
    display: grid;
    gap: 8px;
    padding: 18px;
    border: 1px solid var(--border-color, var(--border));
    border-radius: 14px;
    background: var(--card-bg, var(--bg-secondary));
}

.screen-billing-summary span {
    color: var(--text-muted);
    font-size: 12px;
}

.screen-billing-summary strong {
    color: var(--text-heading, var(--text-primary));
    font-size: 21px;
    font-variant-numeric: tabular-nums;
}

.screen-billing-note {
    margin: 0 0 18px;
    padding: 13px 15px;
    border: 1px solid rgba(59, 130, 246, .25);
    border-radius: 10px;
    background: rgba(59, 130, 246, .08);
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 900px) {
    .screen-billing-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    .screen-billing-summary { grid-template-columns: 1fr; }
}

.balance-info h4 {
    margin: 0;
    opacity: 0.85;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.balance-value-large {
    font-size: 32px;
    font-weight: 800;
    margin-top: 6px;
}

.balance-icon {
    background: rgba(255,255,255,0.15);
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.balance-icon svg {
    width: 32px;
    height: 32px;
}

.btn-generate-invoice {
    margin-top: 8px;
    height: 54px;
    font-size: 16px !important;
    font-weight: 700 !important;
    justify-content: center;
}

.btn-generate-invoice.is-coming-soon:disabled {
    opacity: 1;
    color: rgba(255, 255, 255, 0.85);
    background: #64748b;
    border-color: rgba(148, 163, 184, 0.35);
    cursor: not-allowed;
    box-shadow: none;
}

.status-badge-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}
.status-success { color: var(--brand-text-soft, #60a5fa); }
.status-pending { color: var(--brand-pill-text, #93c5fd); }
.status-failed { color: var(--brand-text-muted, #94a3b8); }

/* Loading Button State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    margin-left: -9px;
    margin-top: -9px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: btn-spinner 0.6s linear infinite;
}

@keyframes btn-spinner {
    to { transform: rotate(360deg); }
}

/* ─── Аудио на ТВ: карточки по трекам ─── */
.audio-tv-board {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 880px;
}

.audio-tv-card {
    background: var(--bg-secondary, #1f1f1f);
    border: 1px solid var(--border, #2e2e2e);
    border-radius: 12px;
    padding: 18px 20px 20px;
}

[data-theme="light"] .audio-tv-card {
    background: #fff;
}

.audio-tv-card--unassigned {
    border-style: dashed;
    opacity: 0.95;
}

.audio-tv-card-head {
    margin-bottom: 12px;
}

.audio-tv-title-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.audio-tv-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 10px;
    flex-shrink: 0;
}

.audio-tv-icon svg {
    width: 22px;
    height: 22px;
    stroke: var(--blue, #3b82f6);
}

.audio-tv-track-name {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary, #fff);
}

.audio-tv-meta {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted, #888);
}

.audio-tv-card-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #888);
    margin-bottom: 6px;
}

.audio-tv-card-sub {
    display: block;
    font-size: 13px;
    color: var(--text-secondary, #ccc);
    line-height: 1.45;
}

.audio-tv-player-row {
    margin-bottom: 14px;
}

.audio-tv-native {
    width: 100%;
    height: 36px;
    border-radius: 8px;
}

.audio-tv-sync {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

[data-theme="light"] .audio-tv-sync {
    background: rgba(0, 0, 0, 0.04);
}

.audio-tv-sync-label {
    font-size: 13px;
    color: var(--text-secondary, #ccc);
}

.audio-tv-sync-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.audio-tv-sync-muted {
    margin: 0 0 14px;
    font-size: 13px;
}

.audio-tv-block-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #888);
    margin-bottom: 8px;
}

.audio-tv-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    min-height: 8px;
}

.audio-tv-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 6px 12px;
    background: var(--bg-tertiary, #2a2a2a);
    border: 1px solid var(--border, #3a3a3a);
    border-radius: 999px;
    font-size: 13px;
}

.audio-tv-chip--plain {
    padding: 6px 12px;
}

.audio-tv-chip-text {
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 1.25;
}

.audio-tv-chip-meta {
    font-size: 11px;
    opacity: 0.7;
}

.audio-tv-chip-x {
    border: none;
    background: transparent;
    color: var(--text-muted, #888);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
}

.audio-tv-chip-x:hover {
    color: var(--error-red, #ef4444);
    background: rgba(239, 68, 68, 0.12);
}

.audio-tv-add-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.audio-tv-add-row .audio-tv-pick {
    flex: 1;
    min-width: 200px;
}

/* Мастер: дорожка → аудио → ТВ */
.audio-tv-wizard-launch {
    margin-bottom: 24px;
}

.audio-tv-wizard {
    background: var(--bg-secondary, #1f1f1f);
    border: 1px solid var(--border, #2e2e2e);
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 28px;
}

[data-theme="light"] .audio-tv-wizard {
    background: #fff;
}

.audio-tv-wizard-top {
    margin-bottom: 18px;
}

.audio-tv-wizard-title {
    margin: 0 0 14px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.audio-tv-wsteps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0;
    counter-reset: wstep;
}

.audio-tv-wsteps .audio-tv-wstep {
    display: flex;
    align-items: center;
    flex: 1;
    position: relative;
    font-size: 13px;
    color: var(--text-muted);
}

.audio-tv-wsteps .audio-tv-wstep:not(:last-child)::after {
    content: '';
    flex: 1;
    height: 2px;
    margin: 0 8px;
    background: var(--border, #3a3a3a);
    border-radius: 1px;
}

.audio-tv-wsteps .audio-tv-wstep.done:not(:last-child)::after {
    background: rgba(59, 130, 246, 0.5);
}

.audio-tv-wstep-num {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-tertiary, #2a2a2a);
    border: 2px solid var(--border, #444);
    font-weight: 700;
}

.audio-tv-wstep.active .audio-tv-wstep-num {
    border-color: var(--blue, #3b82f6);
    background: rgba(59, 130, 246, 0.2);
    color: var(--blue, #3b82f6);
}

.audio-tv-wstep.done .audio-tv-wstep-num {
    border-color: rgba(59, 130, 246, 0.4);
    color: rgba(147, 197, 253, 0.95);
}

.audio-tv-wizard-h {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.audio-tv-wizard-p {
    margin-bottom: 10px;
    max-width: 640px;
    line-height: 1.5;
}

.audio-tv-wizard-pick-audio {
    margin: 10px 0 14px;
    font-size: 14px;
    color: var(--text-secondary);
}

.audio-tv-wizard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.audio-tv-wizard-tv-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 280px;
    overflow-y: auto;
    padding: 4px 0;
}

.audio-tv-wizard-tv {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border, #333);
}

.audio-tv-wizard-tv:hover {
    background: rgba(59, 130, 246, 0.06);
}

.audio-tv-wizard-tv input {
    margin-top: 4px;
}

.audio-tv-wizard-tv-note {
    display: inline;
    font-size: 12px;
    opacity: 0.75;
    font-weight: 400;
}

.audio-tv-existing-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--text-secondary);
}

.audio-tv-board > .audio-tv-card:first-of-type {
    margin-top: 0;
}

.audio-tv-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-heading, var(--text-primary));
    margin: 22px 0 16px;
}

.screen-card.audio-tv-as-device {
    min-width: 0;
}

/* Полоса метаданных дорожки — не использовать .screen-code (там letter-spacing для кода привязки) */
.audio-tv-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 0 14px;
    padding: 10px 12px;
    letter-spacing: normal;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 500;
    font-family: inherit;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid var(--border);
    border-left: 3px solid #3b82f6;
    border-radius: 0 8px 8px 0;
}

.audio-tv-strip--youtube {
    background: rgba(220, 38, 38, 0.06);
    border-left-color: #dc2626;
}

.audio-tv-strip-kind {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.audio-tv-strip-code {
    flex: 1 1 140px;
    min-width: 0;
    margin: 0;
    padding: 3px 8px;
    font-family: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: normal;
    word-break: break-all;
    overflow-wrap: anywhere;
    color: var(--text-heading, var(--text-primary));
    background: rgba(0, 0, 0, 0.18);
    border-radius: 6px;
}

.audio-tv-strip--youtube .audio-tv-strip-code {
    color: #f87171;
    background: rgba(220, 38, 38, 0.12);
}

.audio-tv-strip-group {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.audio-tv-strip-group-label {
    opacity: 0.85;
}

.audio-tv-strip-group-num {
    font-family: ui-monospace, monospace;
    font-weight: 600;
    letter-spacing: normal;
}

.audio-tv-yt-mode-badge {
    flex-shrink: 0;
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: normal;
    white-space: nowrap;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
}

.audio-tv-strip--youtube .audio-tv-yt-mode-badge {
    margin-left: 0;
}

@media (min-width: 400px) {
    .audio-tv-strip--youtube .audio-tv-yt-mode-badge {
        margin-left: auto;
    }
}

[data-theme="light"] .audio-tv-strip-code {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .audio-tv-strip--youtube .audio-tv-strip-code {
    color: #b91c1c;
    background: rgba(220, 38, 38, 0.08);
}

[data-theme="light"] .audio-tv-yt-mode-badge {
    background: rgba(0, 0, 0, 0.04);
}

.screen-card.audio-tv-as-device .audio-tv-native {
    width: 100%;
    height: 38px;
    border-radius: 8px;
}

.audio-tv-add-actions .audio-tv-pick {
    flex: 1;
    min-width: 180px;
}

.audio-tv-tv-strip .btn-with-icon {
    max-width: 100%;
}

/* ─── Global UI refresh v20 ─────────────────────────────────────────────── */
:root {
    --ui-radius: 8px;
    --ui-radius-sm: 6px;
    --ui-surface: #ffffff;
    --ui-surface-2: #f8fafc;
    --ui-surface-3: #eef2f7;
    --ui-border: rgba(15, 23, 42, 0.10);
    --ui-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    --ui-shadow-hover: 0 18px 38px rgba(15, 23, 42, 0.12);
    --ui-blue: #2563eb;
    --ui-cyan: #0891b2;
    --ui-green: #16a34a;
}

[data-theme="dark"] {
    --ui-surface: rgba(17, 24, 39, 0.86);
    --ui-surface-2: rgba(15, 23, 42, 0.76);
    --ui-surface-3: rgba(30, 41, 59, 0.72);
    --ui-border: rgba(148, 163, 184, 0.16);
    --ui-shadow: 0 18px 44px rgba(0, 0, 0, 0.26);
    --ui-shadow-hover: 0 24px 56px rgba(0, 0, 0, 0.34);
    --bg-primary: #0b1220;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --card: rgba(17, 24, 39, 0.88);
    --border: rgba(148, 163, 184, 0.15);
    --text: #e5edf7;
    --muted: #9aa8ba;
    --text-primary: #f3f7fb;
    --text-secondary: #c8d4e4;
    --text-muted: #9aa8ba;
    --text-heading: #f8fbff;
}

body {
    background: var(--bg-primary);
}

[data-theme="dark"] body {
    background: #0b1220;
}

.main-content {
    min-width: 0;
    background: transparent;
}

.header {
    height: 64px;
    padding: 0 26px;
    border-bottom: 1px solid var(--ui-border);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
    backdrop-filter: blur(14px);
}

[data-theme="dark"] .header {
    background: rgba(11, 18, 32, 0.88);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

.header h1,
#page-title {
    color: var(--text-heading);
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0;
}

.header-actions {
    align-items: center;
    gap: 10px;
}

/* На компактных ноутбуках широкое меню оставляет меньше места для шапки.
   Не переносим действия AI Studio на вторую строку: сжимаем только
   второстепенную подпись баланса и отступы кнопок. */
@media (min-width: 901px) and (max-width: 1180px) {
    .sidebar:not(.collapsed) ~ .main-content .header {
        gap: 10px;
        padding-inline: 16px;
    }

    .sidebar:not(.collapsed) ~ .main-content .header-left {
        min-width: 0;
    }

    .sidebar:not(.collapsed) ~ .main-content .header-actions {
        min-width: 0;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .sidebar:not(.collapsed) ~ .main-content .header-balance {
        flex: 0 1 auto;
        margin-right: 0 !important;
        padding: 6px 9px !important;
        white-space: nowrap;
    }

    .sidebar:not(.collapsed) ~ .main-content .header-balance .balance-label {
        display: none;
    }

    .sidebar:not(.collapsed) ~ .main-content .ai-header-new-card {
        min-width: 0;
        padding-inline: 12px;
        font-size: 13px;
        white-space: nowrap;
    }
}

.sidebar {
    background: #0b1220;
    border-right-color: rgba(148, 163, 184, 0.14);
    box-shadow: 10px 0 34px rgba(0, 0, 0, 0.18);
}

.sidebar-brand {
    min-height: 72px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.10);
}

.brand-icon {
    border-radius: var(--ui-radius);
    background: transparent !important;
    box-shadow: none;
}

.nav-menu {
    padding: 12px 10px;
    gap: 4px;
}

.nav-item,
.nav-group-title,
.nav-sub-item {
    border-radius: var(--ui-radius);
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav-item:hover,
.nav-group-title:hover,
.nav-sub-item:hover {
    transform: translateX(2px);
}

.nav-item.active,
.nav-sub-item.active {
    background: var(--blue);
    color: #fff !important;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.20);
}

.sidebar-user {
    margin: 10px;
    border-radius: var(--ui-radius);
    border-color: rgba(148, 163, 184, 0.14);
    background: rgba(15, 23, 42, 0.72);
}

.page {
    padding: 24px 26px;
}

.page.active {
    background: transparent;
}

.btn,
button.btn,
.btn-theme,
.btn-lang {
    min-height: 38px;
    border-radius: var(--ui-radius);
    border: 1px solid transparent;
    font-weight: 700;
    letter-spacing: 0;
    box-shadow: none;
}

.btn-small {
    min-height: 32px;
    border-radius: var(--ui-radius-sm);
    font-size: 12px;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.btn-primary:hover {
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.28);
}

.btn-secondary,
.btn-ghost {
    border-color: var(--ui-border);
    background: var(--ui-surface-3);
    color: var(--text-primary);
}

.btn-secondary:hover,
.btn-ghost:hover {
    border-color: rgba(37, 99, 235, 0.42);
    background: rgba(37, 99, 235, 0.10);
}

.btn-danger {
    background: #3b82f6;
    box-shadow: 0 10px 22px rgba(59, 130, 246, 0.18);
}

.btn-success {
    background: #3b82f6;
}

.btn-warning {
    background: #60a5fa;
}

.btn:focus-visible,
.btn-theme:focus-visible,
.btn-lang:focus-visible,
.form-input:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.62);
    outline-offset: 2px;
}

.btn:disabled,
button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
    transform: none !important;
    box-shadow: none !important;
}

.stats {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
}

.stat-card,
.screen-card,
.media-card,
.playlist-card,
.schedule-item,
.media-item,
.content-item,
.available-item,
.media-checkbox-item,
.playlist-checkbox-item,
.schedule-screen-item,
.audio-tv-card,
.ai-store-card,
.ai-store-custom-cta,
.playlist-merge-settings,
.playlist-sync-settings,
.modal-content {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow);
}

.stat-card,
.screen-card,
.media-card,
.playlist-card,
.schedule-item,
.media-item,
.content-item,
.available-item,
.media-checkbox-item,
.playlist-checkbox-item,
.schedule-screen-item,
.ai-store-card {
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.stat-card:hover,
.screen-card:hover,
.media-card:hover,
.playlist-card:hover,
.schedule-item:hover,
.media-item:hover,
.content-item:hover,
.available-item:hover,
.media-checkbox-item:hover,
.playlist-checkbox-item:hover,
.schedule-screen-item:hover,
.ai-store-card:hover {
    border-color: rgba(37, 99, 235, 0.42);
    box-shadow: var(--ui-shadow-hover);
    transform: translateY(-2px);
}

.stat-card {
    min-height: 96px;
    padding: 18px;
}

.stat-icon {
    border-radius: var(--ui-radius);
    border: 1px solid rgba(148, 163, 184, 0.13);
}

.stat-value {
    color: var(--text-heading);
    font-size: 28px;
    font-weight: 800;
}

.stat-label,
.media-meta,
.playlist-meta,
.form-text,
.schedule-time,
.schedule-days {
    color: var(--text-muted);
}

.screens-list,
.media-list,
.playlists-list,
.schedules-list {
    gap: 18px;
}

.screen-name,
.media-name,
.playlist-header h3,
.playlist-name,
.schedule-playlist,
.schedule-name {
    color: var(--text-heading);
    font-weight: 800;
}

.media-preview,
.media-thumbnail,
.audio-tv-preview {
    background: rgba(59, 130, 246, 0.08);
        #0f172a;
}

.screen-actions,
.media-actions,
.playlist-actions,
.schedule-actions,
.form-actions,
.modal-footer,
.audio-tv-page-toolbar {
    gap: 10px;
}

.status-indicator,
.screen-status,
.device-status,
.schedule-status,
.schedule-status-badge,
.playlist-mode,
.playlist-merge-status-badge,
.audio-tv-mode-badge,
.media-processing-badge,
.media-optimized-badge {
    border-radius: 999px;
    font-weight: 800;
}

.form-group label,
.settings-form .form-group label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
}

.form-input,
.settings-form input,
.settings-form select,
.settings-form textarea,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="time"],
input[type="date"],
select,
textarea {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface-2);
    color: var(--text-primary);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.form-input:focus,
.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="time"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    border-color: rgba(37, 99, 235, 0.62);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
    background: var(--ui-surface);
    outline: none;
}

/* Сайдбар всегда тёмный — select организации не наследует светлую тему */
.sidebar .sidebar-context__select,
[data-theme="light"] .sidebar .sidebar-context__select {
    background-color: #1e293b;
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.12);
}

.sidebar .sidebar-context__select:hover,
[data-theme="light"] .sidebar .sidebar-context__select:hover {
    background-color: #243044;
    border-color: rgba(255, 255, 255, 0.22);
}

.sidebar .sidebar-context__select:focus,
[data-theme="light"] .sidebar .sidebar-context__select:focus {
    background-color: #243044;
    color: #f8fafc;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.sidebar .sidebar-context__select option,
[data-theme="light"] .sidebar .sidebar-context__select option {
    background: #1e293b;
    color: #f8fafc;
}

.modal {
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--ui-surface);
    overflow: hidden;
}

.modal-header,
.modal-footer {
    border-color: var(--ui-border);
    background: var(--ui-surface-2);
}

.modal-header h2 {
    color: var(--text-heading);
    font-weight: 800;
}

/* Schedule form can be taller than the viewport. Keep its header and actions
   visible while only the form body scrolls. */
#modal-create-schedule .modal-content {
    display: flex;
    flex-direction: column;
    height: min(90dvh, 820px);
    max-height: calc(100dvh - 32px);
    overflow: hidden;
}

#modal-create-schedule .modal-header,
#modal-create-schedule .modal-footer {
    flex: 0 0 auto;
}

#modal-create-schedule .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.empty-state {
    border: none;
    border-radius: var(--ui-radius);
    background: var(--ui-surface-2);
    color: var(--text-muted);
}

.empty-state-icon {
    border-radius: var(--ui-radius);
    background: rgba(37, 99, 235, 0.10);
    color: var(--ui-blue);
}

.ai-store-hero,
.audio-tv-meta-strip,
.playlist-merge-banner,
.media-ffmpeg-banner {
    border-radius: var(--ui-radius);
}

.ai-store-tabs,
.ai-store-categories,
.content-tabs {
    border-radius: var(--ui-radius);
}

.ai-store-tab,
.tab-btn,
.billing-tab,
.ai-store-chip {
    border-radius: var(--ui-radius-sm);
    font-weight: 800;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.38);
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.56);
    background-clip: padding-box;
}

@media (max-width: 900px) {
    .header {
        min-height: 60px;
        height: auto;
        padding: 10px 16px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .page {
        padding: 16px;
    }

    .stats,
    .screens-list,
    .media-list,
    .playlists-list {
        gap: 14px;
    }

    .btn {
        min-height: 36px;
    }
}

/* ─── Home dashboard v21 ───────────────────────────────────────────────── */
.home-page {
    padding: 20px 24px 28px;
}

.home-shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: none;
    margin: 0;
}

.home-hero--compact {
    padding: 20px 22px;
}

.home-hero--compact h2 {
    font-size: 24px;
    line-height: 1.2;
}

.home-hero--compact p {
    margin-top: 8px;
    font-size: 14px;
    max-width: none;
}

.home-status-bar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.home-status-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
    min-height: 72px;
    padding: 12px 16px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, transform 0.15s;
}

[data-theme="dark"] .home-status-chip {
    background: rgba(15, 23, 42, 0.82);
}

.home-status-chip:hover {
    border-color: rgba(59, 130, 246, 0.35);
    transform: translateY(-1px);
}

.home-status-chip strong {
    color: var(--text-heading);
    font-size: 18px;
    line-height: 1.1;
    font-weight: 800;
}

.home-status-chip > span:last-child {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
}

.home-focus-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    gap: 16px;
    align-items: stretch;
}

.home-ai-card,
.home-quick-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 360px;
}

.home-ai-card .home-card__head,
.home-quick-panel h3 {
    flex: 0 0 auto;
}

.home-ai-card .home-ai-list {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.home-quick-panel {
    padding: 18px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.home-quick-list {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 10px;
}

.home-quick-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 52px;
    padding: 12px 14px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(148, 163, 184, 0.06);
    color: var(--text-heading);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
}

.home-quick-btn--primary {
    margin-top: auto;
}

.home-quick-btn:hover {
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.08);
}

.home-quick-btn--primary {
    border-color: rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.12);
    color: var(--ui-blue);
}

[data-theme="dark"] .home-quick-panel {
    background: rgba(15, 23, 42, 0.82);
}

.home-quick-panel h3 {
    margin: 0 0 14px;
    color: var(--text-heading);
    font-size: 15px;
    font-weight: 800;
}

.home-quick-btn .home-row-icon {
    width: 32px;
    height: 32px;
}

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

.home-ai-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(148, 163, 184, 0.06);
}

.home-ai-item--high {
    border-color: rgba(59, 130, 246, 0.28);
    background: rgba(59, 130, 246, 0.08);
}

.home-ai-item--ok {
    border-color: rgba(59, 130, 246, 0.22);
    background: rgba(59, 130, 246, 0.06);
}

.home-ai-item__head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.home-ai-item__action {
    align-self: flex-start;
    border: 0;
    background: transparent;
    color: var(--ui-blue);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    padding: 0;
}

.home-ai-item__action:hover {
    text-decoration: underline;
}

.home-tv-health-card {
    display: flex;
    flex-direction: column;
    min-height: 360px;
}

.home-tv-health-refresh {
    flex: 0 0 auto;
    padding: 7px 11px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    box-shadow: 0 2px 7px rgba(15, 23, 42, 0.08);
    color: var(--ui-blue);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.home-tv-health-refresh:hover,
.home-tv-health-refresh:focus-visible {
    border-color: var(--ui-blue);
    outline: none;
}

.home-tv-health {
    --health-online: #2563eb;
    --health-offline: #ef4444;
    --health-unpaired: #cbd5e1;
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    align-items: start;
    gap: 20px;
    min-width: 0;
    flex: 1;
}

[data-theme="dark"] .home-tv-health {
    --health-unpaired: #475569;
}

.home-tv-health__chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.home-tv-health__donut {
    position: relative;
    display: grid;
    place-items: center;
    width: 156px;
    height: 156px;
    border-radius: 50%;
    background: conic-gradient(
        var(--health-online) 0 var(--health-online-end),
        var(--health-offline) var(--health-online-end) var(--health-paired-end),
        var(--health-unpaired) var(--health-paired-end) 100%
    );
}

.home-tv-health__donut-center {
    position: absolute;
    inset: 17px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 50%;
    background: var(--ui-surface);
}

.home-tv-health__donut-center strong {
    color: var(--text-heading);
    font-size: 25px;
    line-height: 1;
    font-weight: 800;
}

.home-tv-health__donut-center span {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

.home-tv-health__legend {
    width: 100%;
    display: grid;
    gap: 7px;
}

.home-tv-health__legend > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-heading);
    font-size: 12px;
}

.home-tv-health__legend strong { font-weight: 800; }

.home-tv-health__key {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
}

.home-tv-health__key::before {
    content: '';
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: var(--health-unpaired);
}

.home-tv-health__key.is-online::before { background: var(--health-online); }
.home-tv-health__key.is-offline::before { background: var(--health-offline); }

.home-tv-health__devices { min-width: 0; }

.home-tv-health__devices-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 10px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--ui-border);
}

.home-tv-health__devices-head strong {
    color: var(--text-heading);
    font-size: 13px;
}

.home-tv-health__devices-head span,
.home-tv-health__device small {
    color: var(--text-muted);
    font-size: 11px;
}

.home-tv-health__device {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 10px;
    width: 100%;
    padding: 11px 2px;
    border: 0;
    border-bottom: 1px solid var(--ui-border);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.home-tv-health__device:hover,
.home-tv-health__device:focus-visible {
    background: rgba(59, 130, 246, 0.05);
    outline: none;
}

.home-tv-health__device-name {
    overflow: hidden;
    color: var(--text-heading);
    font-size: 13px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-tv-health__device-state {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.home-tv-health__device-state.is-online { color: var(--health-online); }
.home-tv-health__device-state.is-offline { color: var(--health-offline); }
.home-tv-health__device small { grid-column: 1 / -1; }

.home-tv-health__more {
    margin-top: 10px;
    padding: 3px 0;
    border: 0;
    background: transparent;
    color: var(--ui-blue);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

@media (max-width: 680px) {
    .home-tv-health { grid-template-columns: 1fr; gap: 15px; }
    .home-tv-health__chart { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 15px; }
    .home-tv-health__donut { width: 120px; height: 120px; }
    .home-tv-health__donut-center { inset: 13px; }
    .home-tv-health__donut-center strong { font-size: 20px; }
}

.home-calendar-section {
    margin-top: 2px;
}

.home-calendar-card {
    padding: 18px;
}

.home-calendar {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.home-calendar__week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.home-cal-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 78px;
    padding: 10px 6px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(148, 163, 184, 0.06);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.home-cal-day:hover {
    border-color: rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.08);
}

.home-cal-day.is-today {
    border-color: rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.12);
}

.home-cal-day.is-selected {
    border-color: var(--ui-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
}

.home-cal-day__name {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
}

.home-cal-day__num {
    font-size: 20px;
    line-height: 1;
    font-weight: 800;
    color: var(--text-heading);
}

.home-cal-day__count {
    min-width: 18px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.16);
    color: var(--ui-blue);
    font-size: 10px;
    font-weight: 800;
}

.home-cal-day__count--empty {
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
}

.home-calendar__events {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 120px;
}

.home-calendar__events[hidden] {
    display: none;
}

.home-cal-event {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(148, 163, 184, 0.06);
}

.home-cal-event__time strong {
    display: block;
    color: var(--text-heading);
    font-size: 14px;
    font-weight: 800;
}

.home-cal-event__time span {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
}

.home-cal-event__body strong {
    display: block;
    color: var(--text-heading);
    font-size: 14px;
    font-weight: 800;
}

.home-cal-event__body span {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 12px;
}

.home-cal-event__status {
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.home-cal-event__status.is-running {
    background: rgba(59, 130, 246, 0.18);
    color: var(--ui-blue);
}

.home-cal-event__status.is-scheduled {
    background: rgba(148, 163, 184, 0.14);
    color: var(--text-muted);
}

.home-hero,
.home-card,
.home-kpi-card,
.home-action-card {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] .home-hero,
[data-theme="dark"] .home-card,
[data-theme="dark"] .home-kpi-card,
[data-theme="dark"] .home-action-card {
    background: rgba(15, 23, 42, 0.82);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

.home-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px;
    background: rgba(59, 130, 246, 0.1);
        rgba(255, 255, 255, 0.94);
}

[data-theme="dark"] .home-hero {
    background: rgba(59, 130, 246, 0.14);
        rgba(15, 23, 42, 0.88);
}

.home-eyebrow {
    display: inline-flex;
    margin-bottom: 8px;
    color: var(--ui-blue);
    font-size: 12px;
    font-weight: 800;
}

.home-hero h2 {
    margin: 0;
    color: var(--text-heading);
    font-size: 28px;
    line-height: 1.15;
    font-weight: 800;
}

.home-hero p {
    max-width: 640px;
    margin: 8px 0 0;
    color: var(--text-muted);
    line-height: 1.55;
}

.home-hero__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

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

.home-kpi-card {
    position: relative;
    min-height: 154px;
    padding: 18px;
    overflow: hidden;
    cursor: pointer;
}

.home-kpi-card::after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -46px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.08;
}

.home-kpi-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
}

.home-kpi-card:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.9);
    outline-offset: 2px;
}

.home-kpi-icon,
.home-row-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: var(--ui-radius);
    background: rgba(37, 99, 235, 0.10);
    color: #2563eb;
}

.home-kpi-icon svg,
.home-row-icon svg {
    width: 20px;
    height: 20px;
}

.home-kpi-trend {
    padding: 5px 8px;
    border-radius: 999px;
    background: var(--brand-bg-soft, rgba(59, 130, 246, 0.12));
    color: var(--brand-text-soft, #2563eb);
    font-size: 11px;
    font-weight: 800;
}

.home-kpi-card strong {
    display: block;
    color: var(--text-heading);
    font-size: 30px;
    line-height: 1;
    font-weight: 800;
}

.home-kpi-card > span:not(.home-kpi-trend) {
    display: block;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
}

.home-sparkline {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 30px;
    margin-top: 16px;
}

.home-sparkline i {
    display: block;
    width: 100%;
    min-width: 8px;
    border-radius: 999px 999px 0 0;
    background: currentColor;
    opacity: 0.72;
}

.home-sparkline i:nth-child(1) { height: 36%; }
.home-sparkline i:nth-child(2) { height: 52%; }
.home-sparkline i:nth-child(3) { height: 44%; }
.home-sparkline i:nth-child(4) { height: 78%; }
.home-sparkline i:nth-child(5) { height: 62%; }
.home-sparkline i:nth-child(6) { height: 88%; }

.home-kpi-card--blue,
.home-kpi-card--green,
.home-kpi-card--cyan,
.home-kpi-card--purple,
.home-kpi-card--orange { color: var(--brand-blue, #2563eb); }

.home-main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
    gap: 16px;
    align-items: start;
}

.home-side-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.home-ai-card,
.home-activity-card {
    min-height: 0;
}

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

.home-ai-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--brand-bg-soft, rgba(59, 130, 246, 0.12));
    color: var(--brand-text-soft, #2563eb);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.home-ai-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.home-ai-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(148, 163, 184, 0.06);
}

.home-ai-item--high {
    border-color: rgba(59, 130, 246, 0.28);
    background: rgba(59, 130, 246, 0.08);
}

.home-ai-item--ok {
    border-color: rgba(59, 130, 246, 0.22);
    background: rgba(59, 130, 246, 0.06);
}

.home-ai-item__head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.home-ai-item__action {
    align-self: flex-start;
    border: 0;
    background: transparent;
    color: var(--ui-blue);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    padding: 0;
}

.home-ai-item__action:hover {
    text-decoration: underline;
}

.home-card {
    padding: 18px;
    min-width: 0;
}

.home-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.home-card h3,
.home-action-card h3 {
    margin: 0;
    color: var(--text-heading);
    font-size: 16px;
    font-weight: 800;
}

.home-card p,
.home-action-card p {
    margin: 5px 0 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}

.home-link-btn {
    border: 0;
    background: transparent;
    color: var(--ui-blue);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
}

.home-chart {
    height: 260px;
    border-radius: var(--ui-radius);
    background: rgba(59, 130, 246, 0.06);
        rgba(148, 163, 184, 0.06);
    overflow: hidden;
}

.home-health-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    height: 100%;
    min-height: 220px;
    padding: 14px;
    align-items: stretch;
}

.home-health-tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .home-health-tile {
    background: rgba(15, 23, 42, 0.42);
}

.home-health-tile__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.home-health-tile__top span {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
}

.home-health-tile__top strong {
    color: var(--text-heading);
    font-size: 28px;
    line-height: 1;
    font-weight: 900;
}

.home-health-meter {
    height: 9px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    overflow: hidden;
}

.home-health-meter i {
    display: block;
    height: 100%;
    min-width: 8px;
    border-radius: inherit;
    background: currentColor;
}

.home-health-tile p {
    min-height: 34px;
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
}

.home-health-tile.is-online,
.home-health-tile.is-neutral,
.home-health-tile.is-media,
.home-health-tile.is-waiting { color: var(--brand-blue, #2563eb); }

.home-chart svg {
    width: 100%;
    height: 100%;
}

.home-chart-grid {
    fill: none;
    stroke: rgba(148, 163, 184, 0.20);
    stroke-width: 1;
}

.home-chart-fill {
    fill: url(#homeChartFill);
}

.home-chart-line {
    fill: none;
    stroke: #2563eb;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.home-chart-point {
    fill: #fff;
    stroke: #2563eb;
    stroke-width: 4;
}

.home-analytics-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.home-analytics-summary span {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.home-analytics-summary strong {
    display: block;
    color: var(--text-heading);
    font-size: 18px;
}

.home-list,
.home-activity-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.home-list-item,
.home-activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 10px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(148, 163, 184, 0.06);
}

.home-list-text {
    min-width: 0;
    flex: 1 1 auto;
}

.home-list-text strong {
    display: block;
    overflow: hidden;
    color: var(--text-heading);
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-list-text span {
    display: block;
    overflow: hidden;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-status-pill {
    flex: 0 0 auto;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
}

.home-row-icon.is-online,
.home-status-pill.is-online {
    background: var(--brand-bg-strong, rgba(59, 130, 246, 0.22));
    color: var(--brand-pill-active-text, #fff);
}

.home-row-icon.is-offline,
.home-status-pill.is-offline {
    background: var(--brand-muted-bg, rgba(148, 163, 184, 0.1));
    color: var(--brand-text-muted, #64748b);
}

.home-row-icon.is-waiting,
.home-status-pill.is-waiting {
    background: var(--brand-bg-soft, rgba(59, 130, 246, 0.1));
    color: var(--brand-pill-text, #2563eb);
}

.home-row-icon.is-media {
    background: var(--brand-bg-soft, rgba(59, 130, 246, 0.1));
    color: var(--brand-text-soft, #2563eb);
}

.home-row-icon.is-neutral,
.home-status-pill.is-neutral {
    background: var(--brand-bg-soft, rgba(59, 130, 246, 0.08));
    color: var(--brand-text-muted, #64748b);
}

.home-list-empty {
    padding: 18px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: rgba(148, 163, 184, 0.06);
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

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

.home-action-card {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    min-height: 126px;
    padding: 18px;
    overflow: hidden;
    cursor: pointer;
}

.home-action-card:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.9);
    outline-offset: 2px;
}

.home-action-card::after {
    content: "";
    position: absolute;
    right: -30px;
    bottom: -34px;
    width: 116px;
    height: 116px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.10;
}

.home-action-card > * {
    position: relative;
    z-index: 1;
}

.home-action-card--blue,
.home-action-card--cyan,
.home-action-card--green,
.home-action-card--orange { color: var(--brand-blue, #2563eb); }

@media (max-width: 1100px) {
    .home-status-bar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .home-focus-grid {
        grid-template-columns: 1fr;
    }

    .home-ai-card,
    .home-quick-panel {
        min-height: 0;
    }
}

@media (max-width: 1320px) {
    .home-kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .home-side-stack {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .home-secondary-grid {
        grid-template-columns: 1fr;
    }

    .home-analytics-card {
        grid-column: auto;
    }

    .home-side-stack {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 900px) {
    .home-page {
        padding: 16px;
    }

    .home-calendar__week {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .home-cal-event {
        grid-template-columns: 1fr;
        gap: 8px;
        align-items: flex-start;
    }

    .home-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .home-hero__actions {
        justify-content: flex-start;
    }

    .home-kpi-grid,
    .home-main-grid,
    .home-secondary-grid,
    .home-focus-grid,
    .home-action-grid,
    .home-status-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .home-status-chip {
        min-height: 64px;
    }

    .home-hero h2 {
        font-size: 20px;
    }
}

/* Playlist media modal */
#modal-playlist-media .modal-content {
    width: min(1200px, calc(100vw - 48px));
    max-width: min(1200px, calc(100vw - 48px));
    height: min(860px, calc(100vh - 48px));
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#modal-playlist-media .modal-header,
#modal-playlist-media .modal-footer {
    flex: 0 0 auto;
}

#modal-playlist-media .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px 24px;
}

#modal-playlist-media .playlist-media-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}

#modal-playlist-media #playlist-sync-banner {
    display: none !important;
}

#modal-playlist-media .playlist-editor-loading {
    grid-column: 1 / -1;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    border: 1px solid rgba(59, 130, 246, 0.28);
    border-radius: 12px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--text-secondary);
    font-weight: 600;
}

#modal-playlist-media .playlist-editor-loading--error {
    justify-content: space-between;
    border-color: rgba(239, 68, 68, 0.28);
    background: rgba(239, 68, 68, 0.08);
}

#modal-playlist-media .playlist-merge-settings,
#modal-playlist-media .playlist-sync-settings {
    margin: 0;
    min-height: 0;
    padding: 14px 16px;
}

#modal-playlist-media #playlist-merge-banner {
    padding: 16px 18px;
    border-color: var(--ui-border, var(--border));
    background: var(--ui-surface, var(--bg-secondary));
    box-shadow: var(--ui-shadow);
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-settings-head {
    align-items: center;
    margin-bottom: 0;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-settings-title {
    margin: 0;
    font-size: 15px;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-settings-hint {
    margin-top: 5px;
    max-width: 620px;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-status-badge {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-settings-body {
    margin-top: 12px;
    max-height: none;
    overflow: visible;
    padding: 0;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-result,
#modal-playlist-media #playlist-merge-banner .merge-error-text {
    margin-top: 0;
    font-size: 12px;
    line-height: 1.45;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-flash {
    margin: 0 0 10px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-flash-detail {
    margin-top: 4px;
    color: var(--text-muted);
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-progress-panel {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-progress-row {
    display: block;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-progress-copy {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 2px 12px;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-progress-title {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-progress-sub {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-progress-track {
    height: 4px;
    margin-top: 10px;
    background: var(--ui-border, var(--border));
}

#modal-playlist-media #playlist-merge-banner .playlist-merge-spinner {
    display: none;
}

#modal-playlist-media .merge-error-text {
    display: block;
    max-height: 76px;
    overflow: auto;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.4;
}

#modal-playlist-media .playlist-merge-settings-actions {
    margin-top: 10px;
}

#modal-playlist-media .playlist-sync-toggle {
    margin: 8px 0 !important;
}

#modal-playlist-media .playlist-sync-status {
    margin-bottom: 10px !important;
    line-height: 1.45;
}

#modal-playlist-media .playlist-media-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#modal-playlist-media .playlist-media-section {
    display: flex;
    flex-direction: column;
    padding: 20px;
    border: 1px solid color-mix(in srgb, var(--primary) 12%, var(--border-color));
    border-radius: 10px;
    background: var(--bg-secondary);
}

#modal-playlist-media .playlist-media-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

#modal-playlist-media .playlist-media-section h3 {
    margin: 0 0 4px;
    font-size: 17px;
}

#modal-playlist-media .playlist-media-section .help-text {
    margin: 0;
    line-height: 1.35;
}

#modal-playlist-media .playlist-media-count {
    min-width: 0;
    height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

#modal-playlist-media .playlist-media-search {
    margin: 0 0 10px;
}

#modal-playlist-media .playlist-media-search .form-input {
    height: 38px;
    padding: 8px 12px;
}

#modal-playlist-media .playlist-media-list,
#modal-playlist-media .available-media-list {
    min-height: 110px;
    padding: 0;
    border-radius: 10px;
    border: 0;
    background: transparent;
}

#modal-playlist-media .playlist-media-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: none;
    overflow: visible;
}

#modal-playlist-media .available-media-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    max-height: 340px;
    overflow-y: auto;
    padding: 2px 4px 2px 2px;
}

#modal-playlist-media .media-item {
    display: grid;
    align-items: center;
    gap: 12px;
    min-width: 0;
    margin-bottom: 8px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: none;
    cursor: default;
}

#modal-playlist-media .media-item:last-child {
    margin-bottom: 0;
}

#modal-playlist-media .media-item:hover {
    transform: none;
    border-color: rgba(37, 99, 235, 0.52);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.24);
}

#modal-playlist-media .media-item--playlist {
    grid-template-columns: auto 64px minmax(0, 1fr) auto;
    cursor: grab;
}

#modal-playlist-media .media-item--playlist:active {
    cursor: grabbing;
}

#modal-playlist-media .media-item--available {
    grid-template-columns: 64px minmax(0, 1fr) auto;
}

#modal-playlist-media .playlist-photo-thumb {
    width: 72px;
    height: 48px;
    display: block;
    box-sizing: border-box;
    padding: 0;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.65);
}

#modal-playlist-media .playlist-media-preview {
    appearance: none;
    cursor: zoom-in;
}

#modal-playlist-media .playlist-media-preview:hover,
#modal-playlist-media .playlist-media-preview:focus-visible {
    border-color: var(--accent);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#modal-playlist-media .playlist-media-preview:disabled {
    cursor: default;
}

.playlist-media-lightbox .media-lightbox__dialog {
    max-width: min(86vw, 760px);
}

.playlist-media-lightbox .media-lightbox__image,
.playlist-media-lightbox__video {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: min(72dvh, 620px);
    border-radius: 10px;
    background: #0f172a;
    object-fit: contain;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .36);
}

#modal-playlist-media .playlist-media-preview__fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 22px;
    background: linear-gradient(135deg, #334155, #0f172a);
}

#modal-playlist-media .playlist-media-preview__asset {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    visibility: hidden;
}

#modal-playlist-media .playlist-media-preview.has-frame .playlist-media-preview__asset {
    visibility: visible;
}

#modal-playlist-media .playlist-media-preview.is-fallback .playlist-media-preview__asset {
    visibility: hidden;
}

#modal-playlist-media .playlist-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

#modal-playlist-media .playlist-item-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 34px;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
}

#modal-playlist-media .playlist-item-action:disabled {
    opacity: .4;
    cursor: default;
}

#modal-playlist-media .playlist-item-action--duplicate {
    gap: 5px;
}

#modal-playlist-media .playlist-item-action__label {
    display: none;
}

#modal-playlist-media .playlist-photo-legacy-note {
    margin-bottom: 8px;
    padding: 9px 11px;
    border-radius: 9px;
    border: 1px solid rgba(245, 158, 11, 0.32);
    background: rgba(245, 158, 11, 0.10);
    color: #fbbf24;
    font-size: 12px;
    line-height: 1.45;
}

#modal-playlist-media .media-order {
    width: 26px;
    height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

#modal-playlist-media .media-info {
    min-width: 0;
}

#modal-playlist-media .media-info .media-name,
#modal-playlist-media .media-info .media-type {
    display: block;
}

#modal-playlist-media .media-info .media-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

#modal-playlist-media .media-info .media-type {
    margin-top: 3px;
    color: var(--text-muted);
}

#modal-playlist-media .media-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

#modal-playlist-media .playlist-sequence-item {
    border-radius: 10px;
    transition: opacity .16s ease, transform .16s ease;
}

#modal-playlist-media .playlist-sequence-item.dragging {
    opacity: .45;
}

#modal-playlist-media .playlist-content-item {
    cursor: grab;
    border: 1px solid color-mix(in srgb, var(--primary) 10%, var(--border-color));
}

#modal-playlist-media .playlist-content-item:active {
    cursor: grabbing;
}

#modal-playlist-media .playlist-content-item .content-info {
    min-width: 0;
}

#modal-playlist-media .playlist-transition-row {
    padding: 7px 0 10px;
}

#modal-playlist-media .playlist-transition-row .content-transition-rail {
    max-width: 240px;
    margin: 0 auto 6px;
}

#modal-playlist-media .playlist-transition-row .content-transition-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 6px 10px;
    border-color: var(--ui-border, var(--border));
    background: var(--ui-surface, var(--card));
    box-shadow: none;
}

#modal-playlist-media .playlist-transition-row .content-transition-options {
    justify-content: center;
    flex-wrap: nowrap;
    gap: 3px;
    margin: 0;
}

#modal-playlist-media .playlist-transition-row .content-transition-option,
#modal-playlist-media .playlist-transition-bulk__options .content-transition-option {
    min-width: 52px;
    padding: 5px 6px;
    border-color: transparent;
    box-shadow: none;
}

#modal-playlist-media .content-transition-option.is-active,
[data-theme="light"] #modal-playlist-media .content-transition-option.is-active {
    color: var(--text-heading) !important;
    border-color: var(--ui-border, var(--border)) !important;
    background: var(--ui-surface-2, var(--bg-secondary)) !important;
    box-shadow: none !important;
}

#modal-playlist-media .content-transition-option.is-active span,
#modal-playlist-media .content-transition-option.is-active small {
    color: inherit !important;
}

#modal-playlist-media .playlist-transition-bulk {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid var(--ui-border, var(--border));
    border-radius: 10px;
    background: var(--ui-surface, var(--card));
    box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
}

#modal-playlist-media .playlist-transition-bulk[hidden] {
    display: none;
}

#modal-playlist-media .playlist-transition-bulk__copy strong {
    display: block;
    color: var(--text-heading);
    font-size: 13px;
    font-weight: 600;
}

#modal-playlist-media .playlist-transition-bulk__options {
    grid-column: 2;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 3px;
}

#modal-playlist-media .playlist-transition-bulk__options .content-transition-option {
    min-width: 50px;
}

#modal-playlist-media .playlist-transition-bulk .content-transition-option.is-active {
    color: var(--text-heading) !important;
    border-color: var(--ui-border, var(--border)) !important;
    background: var(--ui-surface-2, var(--bg-secondary)) !important;
    box-shadow: none !important;
}

#modal-playlist-media .playlist-transition-fixed-duration {
    grid-column: 3;
    justify-self: end;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

#modal-playlist-media .playlist-available-item {
    min-height: 76px;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--primary) 10%, var(--border-color));
}

#modal-playlist-media .playlist-available-item .media-info {
    flex: 1;
    min-width: 0;
}

#modal-playlist-media .playlist-available-item .media-name,
#modal-playlist-media .playlist-available-item .media-type {
    display: block;
}

#modal-playlist-media .playlist-available-item .media-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#modal-playlist-media .playlist-transition-control {
    display: grid;
    grid-template-columns: auto minmax(118px, 1fr) 82px;
    align-items: center;
    gap: 6px;
    min-width: 330px;
    padding: 5px 7px;
    border: 1px solid rgba(37, 99, 235, 0.22);
    border-radius: 10px;
    background: rgba(37, 99, 235, 0.08);
}

#modal-playlist-media .playlist-transition-control > span {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

#modal-playlist-media .playlist-transition-control select {
    height: 30px;
    min-width: 0;
    padding: 0 24px 0 8px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-primary);
    font-size: 12px;
}

#modal-playlist-media .playlist-transition-control select:disabled {
    opacity: 0.45;
}

#modal-playlist-media .duration-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 8px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.72);
    color: var(--text-muted);
    font-size: 12px;
}

#modal-playlist-media .duration-control .input-small {
    width: 58px;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: center;
}

#modal-playlist-media .btn-add-media {
    min-width: 116px;
    justify-content: center;
}

#modal-playlist-media .playlist-media-empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: 28px 12px;
    text-align: center;
    color: var(--text-muted);
}

#modal-playlist-media .is-hidden-by-search {
    display: none !important;
}

[data-theme="light"] #modal-playlist-media .playlist-media-list,
[data-theme="light"] #modal-playlist-media .available-media-list {
    background: transparent !important;
    border-color: transparent !important;
}

[data-theme="light"] #modal-playlist-media .media-item {
    background: #ffffff !important;
    border-color: var(--border) !important;
}

[data-theme="light"] #modal-playlist-media .duration-control {
    background: #f8fafc;
    border-color: var(--border);
}

[data-theme="light"] #modal-playlist-media .playlist-photo-legacy-note {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}

[data-theme="light"] #modal-playlist-media .playlist-media-section {
    background: #f8fafc;
    border-color: var(--border);
}

[data-theme="light"] #modal-playlist-media .playlist-content-item,
[data-theme="light"] #modal-playlist-media .playlist-available-item {
    background: #ffffff;
    border-color: var(--border);
}

#modal-playlist-media .modal-footer {
    align-items: center;
    padding: 16px 24px;
}

#modal-playlist-media .playlist-media-save-hint {
    flex: 1 1 auto;
    min-width: 0;
    margin-right: auto;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.35;
}

#modal-playlist-media .playlist-media-save-hint.is-dirty {
    color: #f59e0b;
    font-weight: 600;
}

@media (max-width: 980px) {
    #modal-screen-content .modal-content {
        width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
    }

    #modal-screen-content .available-items-grid {
        grid-template-columns: 1fr;
    }

    #modal-playlist-media .modal-content {
        width: calc(100vw - 24px);
        height: calc(100vh - 24px);
        max-height: calc(100vh - 24px);
    }

    #modal-playlist-media .modal-body {
        overflow: auto;
        padding: 16px;
    }

    #modal-playlist-media .playlist-media-list {
        max-height: none;
    }

    #modal-playlist-media .available-media-list {
        max-height: 360px;
    }
}

@media (max-width: 620px) {
    #modal-playlist-media .media-item--playlist,
    #modal-playlist-media .media-item--available {
        grid-template-columns: 1fr;
    }

    #modal-playlist-media .media-order {
        display: none;
    }

    #modal-playlist-media .playlist-photo-thumb {
        width: 64px;
        height: 44px;
    }

    #modal-playlist-media .media-controls,
    #modal-playlist-media .btn-add-media {
        width: 100%;
    }

    #modal-playlist-media .media-controls {
        align-items: stretch;
        flex-direction: column;
    }

    #modal-playlist-media .playlist-transition-control {
        grid-template-columns: 1fr;
        min-width: 0;
        width: 100%;
    }

    #modal-playlist-media .btn-add-media {
        min-width: 0;
    }

    #modal-playlist-media .playlist-media-section {
        padding: 14px;
    }

    #modal-playlist-media .available-media-list {
        grid-template-columns: 1fr;
    }

    #modal-playlist-media .playlist-content-item {
        flex-wrap: wrap;
    }

    #modal-playlist-media .playlist-transition-bulk {
        grid-template-columns: 1fr;
    }

    #modal-playlist-media .playlist-transition-bulk__options {
        flex-wrap: wrap;
    }

    #modal-playlist-media .playlist-transition-fixed-duration {
        width: max-content;
    }

    #modal-playlist-media .playlist-transition-row {
        padding-left: 12px;
        padding-right: 12px;
    }

    #modal-playlist-media .modal-footer {
        flex-wrap: wrap;
    }

    #modal-playlist-media .playlist-media-save-hint {
        flex-basis: 100%;
    }
}

/* Compact playlist actions — mirrors the device-card toolbar. */
.playlist-card {
    display: flex;
    flex-direction: column;
}

.playlist-card .playlist-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    margin-top: auto;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.05);
}

.playlist-action-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 32px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.playlist-action-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.playlist-action-btn:hover {
    color: var(--text);
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.22);
    transform: translateY(-1px);
}

.playlist-action-btn--danger:hover {
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(59, 130, 246, 0.35);
}

/* Playlist content summary. */
.playlist-card .playlist-header {
    margin-bottom: 12px;
}

.playlist-card .playlist-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 14px;
    color: var(--text-muted);
    font-size: 12px;
}

.playlist-stat-card {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    min-height: 56px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.035);
}

.playlist-stat-card .playlist-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.09);
    color: var(--blue);
    opacity: 1;
}

.playlist-stat-card .playlist-stat-icon svg {
    width: 15px;
    height: 15px;
}

.playlist-stat-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.playlist-stat-copy small,
.playlist-card-status small {
    color: var(--text-muted);
    font-size: 9px;
    line-height: 1.2;
}

.playlist-stat-copy strong,
.playlist-card-status strong {
    overflow: hidden;
    color: var(--text-heading);
    font-size: 12px;
    font-style: normal;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playlist-stat-copy strong em {
    color: var(--text-muted);
    font-size: 9px;
    font-style: normal;
    font-weight: 600;
}

.playlist-card-status {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.055);
}

.playlist-card-status__copy,
.playlist-card-status__size {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.playlist-card-status__copy {
    flex: 1;
}

.playlist-card-status__size {
    flex: 0 0 auto;
    margin-left: auto;
    text-align: right;
}

.playlist-card-status__size strong {
    font-variant-numeric: tabular-nums;
}

.playlist-card-status__dot {
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    border-radius: 50%;
    background: #94a3b8;
    box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.14);
}

.playlist-card-status.is-ready {
    border-color: rgba(34, 197, 94, 0.2);
    background: rgba(34, 197, 94, 0.055);
}

.playlist-card-status.is-ready .playlist-card-status__dot {
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.13);
}

.playlist-card-status.is-pending {
    border-color: rgba(245, 158, 11, 0.22);
    background: rgba(245, 158, 11, 0.06);
}

.playlist-card-status.is-pending .playlist-card-status__dot {
    background: #f59e0b;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.13);
}

.playlist-card-status.is-error {
    border-color: rgba(239, 68, 68, 0.22);
    background: rgba(239, 68, 68, 0.055);
}

.playlist-card-status.is-error .playlist-card-status__dot {
    background: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.playlist-card-status.is-empty strong,
.playlist-card-status.is-muted strong {
    color: var(--text-muted);
}
