:root {
    --bg: #0e1016;
    --panel: rgba(23, 27, 39, 0.94);
    --panel-strong: #171b27;
    --line: rgba(110, 126, 164, 0.34);
    --text: #edf2ff;
    --muted: #95a1c4;
    --accent: #42d6b5;
    --accent-dark: #1ca185;
    --success: rgba(28, 161, 133, 0.16);
    --success-text: #8ef5de;
    --error: rgba(255, 99, 132, 0.16);
    --error-text: #ffb8c6;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Trebuchet MS", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(66, 214, 181, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(70, 108, 255, 0.16), transparent 30%),
        linear-gradient(180deg, #090b11 0%, var(--bg) 24%, #131826 100%);
    min-height: 100vh;
}

a {
    color: inherit;
}

.table-sort-link {
    color: inherit;
    text-decoration: none;
}

.table-sort-link:hover {
    color: #ffffff;
}

button,
input,
select,
textarea {
    font: inherit;
}

.page-shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
    margin-bottom: 24px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.header-film-search-form {
    position: relative;
    width: min(100%, 360px);
}

.header-film-search-field {
    display: block;
}

.header-film-search-field input {
    width: 100%;
    min-width: 0;
}

.header-film-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 150;
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(8, 12, 22, 0.97);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
}

.header-film-search-result,
.header-film-search-empty {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 14px;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.03);
}

.header-film-search-result:hover {
    border-color: var(--accent);
    background: rgba(76, 223, 188, 0.12);
}

.header-film-search-result strong {
    color: var(--text);
}

.header-film-search-result span,
.header-film-search-empty {
    color: var(--muted);
    font-size: 14px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

h1,
h2,
legend {
    margin: 0;
    font-weight: 700;
}

h1 {
    font-size: clamp(32px, 4vw, 48px);
}

h2 {
    margin-bottom: 18px;
}

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

.tab,
.pill-link,
button {
    border: 1px solid var(--line);
    background: var(--panel-strong);
    border-radius: 999px;
    padding: 10px 16px;
    text-decoration: none;
    transition: 0.2s ease;
}

.tab.active,
button,
.pill-link:hover,
.tab:hover {
    border-color: var(--accent);
}

button {
    cursor: pointer;
    color: #041412;
    background: linear-gradient(135deg, var(--accent), #7cf0d5);
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(66, 214, 181, 0.18);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
    box-shadow: none;
}

.ghost-button {
    background: transparent;
    color: var(--muted);
    padding: 6px 10px;
    box-shadow: none;
}

.logout-form {
    margin: 0;
}

.logout-button {
    color: var(--text);
    border-color: var(--line);
}

.logout-button:hover {
    box-shadow: none;
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    border-radius: 16px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    background: rgba(15, 19, 30, 0.84);
}

.flash.success {
    background: var(--success);
    color: var(--success-text);
}

.flash.error {
    background: var(--error);
    color: var(--error-text);
}

.grid {
    display: grid;
    gap: 20px;
}

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

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

.program-layout {
    align-items: start;
}

.card {
    background: linear-gradient(180deg, rgba(25, 30, 45, 0.96), rgba(17, 21, 31, 0.96));
    border: 1px solid rgba(112, 127, 166, 0.24);
    border-radius: 24px;
    padding: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    margin-bottom: 20px;
}

.schedule-nav-card {
    position: relative;
    z-index: 40;
    overflow: visible;
}

.login-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding-top: 0;
    padding-bottom: 0;
}

.login-card {
    width: min(100%, 460px);
    margin-bottom: 0;
}

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

label,
fieldset {
    display: grid;
    gap: 8px;
}

fieldset {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
}

legend {
    padding: 0 6px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(11, 14, 22, 0.92);
    color: var(--text);
}

input::placeholder,
textarea::placeholder {
    color: #6f7ba0;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(66, 214, 181, 0.26);
    outline-offset: 1px;
    border-color: rgba(66, 214, 181, 0.52);
}

textarea {
    resize: vertical;
}

.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: auto;
}

.series-fields {
    display: none;
}

.series-fields.visible {
    display: grid;
}

.full-width {
    grid-column: 1 / -1;
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    padding: 14px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 600;
}

.type-list,
.chip-wrap {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.type-list {
    margin-top: 18px;
    flex-direction: column;
}

.type-chip-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.type-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    min-height: 28px;
    border-radius: 999px;
    background: rgba(66, 214, 181, 0.12);
    border: 1px solid rgba(66, 214, 181, 0.24);
    white-space: nowrap;
    font-size: 0.95rem;
}

.text-link {
    color: #7cead0;
    text-decoration: none;
    font-weight: 600;
}

.tab.active,
.pill-link:hover,
.tab:hover,
.text-link:hover {
    color: #ffffff;
}

.muted {
    color: var(--muted);
}

.centered {
    text-align: center;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.detail-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 6px;
}

.day-nav {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    flex-wrap: wrap;
}

.week-nav {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.week-nav-strip {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.week-nav-shift {
    min-width: 46px;
    text-align: center;
    padding-inline: 0;
}

.week-day-pill {
    display: grid;
    gap: 4px;
    justify-items: center;
    align-content: center;
    min-height: 72px;
    padding: 10px 8px;
    border: 1px solid transparent;
    border-radius: 20px;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.week-day-pill:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.week-day-pill-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(237, 242, 255, 0.82);
}

.week-day-pill-number {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
}

.week-theme-blue {
    background: linear-gradient(180deg, rgba(20, 39, 77, 0.96), rgba(12, 25, 54, 0.98));
    border-color: rgba(93, 131, 216, 0.36);
}

.week-theme-green {
    background: linear-gradient(180deg, rgba(18, 56, 49, 0.96), rgba(11, 36, 31, 0.98));
    border-color: rgba(77, 170, 145, 0.34);
}

.week-theme-red {
    background: linear-gradient(180deg, rgba(82, 27, 39, 0.96), rgba(54, 16, 25, 0.98));
    border-color: rgba(219, 113, 136, 0.38);
}

.week-theme-pink {
    background: linear-gradient(180deg, rgba(96, 34, 84, 0.96), rgba(61, 20, 55, 0.98));
    border-color: rgba(224, 131, 206, 0.4);
}

.week-day-pill.is-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(66, 214, 181, 0.26), 0 16px 30px rgba(0, 0, 0, 0.24);
}

.week-day-pill.is-today .week-day-pill-label::after {
    content: " •";
    color: var(--accent);
}

.date-jump {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.program-date-picker {
    position: relative;
    min-width: min(100%, 320px);
}

.program-date-picker.is-open {
    z-index: 260;
}

.program-date-trigger {
    width: 100%;
    justify-content: space-between;
    text-align: left;
    color: var(--text);
    background: rgba(12, 16, 24, 0.88);
}

.program-date-trigger::after {
    content: "▾";
    color: var(--muted);
    margin-left: 14px;
}

.program-date-popup {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 300;
    width: min(92vw, 360px);
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(12, 16, 24, 0.98);
    box-shadow: var(--shadow);
    display: grid;
    gap: 12px;
}

.program-date-popup[hidden] {
    display: none;
}

.program-date-popup-head,
.program-date-popup-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.program-date-popup-head strong {
    text-align: center;
    flex: 1;
}

.program-date-nav-button {
    min-width: 42px;
    padding-inline: 0;
}

.program-date-weekdays,
.program-date-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.program-date-weekdays span {
    text-align: center;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.program-date-grid {
    align-items: stretch;
}

.program-date-day {
    min-height: 42px;
    padding: 0;
    border-radius: 14px;
    border: 1px solid transparent;
    color: var(--text);
    font-weight: 600;
    box-shadow: none;
}

.program-date-day:hover {
    box-shadow: none;
}

.program-date-day.theme-blue {
    background: linear-gradient(180deg, rgba(20, 39, 77, 0.96), rgba(12, 25, 54, 0.98));
    border-color: rgba(93, 131, 216, 0.36);
}

.program-date-day.theme-green {
    background: linear-gradient(180deg, rgba(18, 56, 49, 0.96), rgba(11, 36, 31, 0.98));
    border-color: rgba(77, 170, 145, 0.34);
}

.program-date-day.theme-red {
    background: linear-gradient(180deg, rgba(82, 27, 39, 0.96), rgba(54, 16, 25, 0.98));
    border-color: rgba(219, 113, 136, 0.38);
}

.program-date-day.theme-pink {
    background: linear-gradient(180deg, rgba(96, 34, 84, 0.96), rgba(61, 20, 55, 0.98));
    border-color: rgba(224, 131, 206, 0.4);
}

.program-date-day.is-outside {
    opacity: 0.55;
}

.program-date-day.is-today {
    border-color: rgba(255, 255, 255, 0.58);
}

.program-date-day.is-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(66, 214, 181, 0.26), 0 10px 20px rgba(0, 0, 0, 0.2);
}

.today-marker {
    margin-top: 16px;
    color: var(--muted);
}

.day-nav .today-marker {
    margin-top: 0;
}

@media (max-width: 860px) {
    .two-columns,
    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .topbar,
    .day-nav {
        align-items: start;
        flex-direction: column;
    }

    .week-nav {
        grid-template-columns: 1fr;
    }

    .week-nav-shift {
        width: 100%;
        min-width: 0;
    }

    .week-nav-strip {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .program-date-picker {
        min-width: 100%;
    }

    .program-date-popup {
        width: min(100vw - 32px, 360px);
    }

    .topbar-actions {
        width: 100%;
        align-items: flex-start;
        justify-content: flex-start;
    }

    .header-film-search-form {
        width: 100%;
    }

    .page-shell {
        width: min(100vw - 20px, 1000px);
        padding-top: 20px;
    }

    .episode-editor-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .table-wrap {
        overflow-x: visible;
    }

    .responsive-table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }

    .responsive-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        border: 0;
    }

    .responsive-table tbody {
        display: grid;
        gap: 12px;
    }

    .responsive-table tr {
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 18px;
        background: rgba(9, 12, 19, 0.78);
    }

    .responsive-table th,
    .responsive-table td {
        border-bottom: 0;
    }

    .responsive-table td {
        display: grid;
        grid-template-columns: minmax(92px, 108px) minmax(0, 1fr);
        gap: 10px;
        padding: 6px 0;
        font-size: 0.95rem;
    }

    .responsive-table td::before {
        content: "";
        color: var(--muted);
        text-transform: uppercase;
        font-size: 11px;
        letter-spacing: 0.08em;
        line-height: 1.4;
    }

    .responsive-table td[colspan] {
        display: block;
        padding: 0;
        text-align: left;
    }

    .responsive-table td[colspan]::before {
        content: none;
    }

    .responsive-table .actions-wrap,
    .responsive-table .chip-wrap {
        justify-content: flex-start;
    }

    .responsive-table .actions-wrap {
        gap: 8px;
    }

    .responsive-table .inline-form input[type="text"] {
        min-width: 0;
        width: 100%;
    }

    .responsive-table .subtitle-actions {
        align-items: flex-start;
    }

    .responsive-table .subtitle-actions .more-actions-menu {
        left: 0;
        right: auto;
    }

    .responsive-table .type-chip {
        padding: 6px 10px;
    }

    .responsive-table .compact-pill,
    .responsive-table .compact-inline-form button,
    .responsive-table .more-actions-trigger,
    .responsive-table .icon-button {
        width: 38px;
        min-width: 38px;
        height: 38px;
        min-height: 38px;
    }

    .responsive-table .action-icon {
        width: 16px;
        height: 16px;
    }

    .active-schedule-row {
        background: rgba(76, 201, 123, 0.14);
    }

    .active-schedule-row td {
        background: transparent;
    }

    .films-table td:nth-child(1)::before,
    .latest-films-table td:nth-child(1)::before,
    .translation-jobs-table td:nth-child(1)::before {
        content: "Назва";
    }

    .films-table td:nth-child(2)::before {
        content: "Оригінал";
    }

    .films-table td:nth-child(3)::before,
    .latest-films-table td:nth-child(2)::before {
        content: "Рік";
    }

    .films-table td:nth-child(4)::before,
    .latest-films-table td:nth-child(3)::before {
        content: "Формат";
    }

    .films-table td:nth-child(5)::before,
    .latest-films-table td:nth-child(4)::before,
    .episodes-table td:nth-child(3)::before {
        content: "Тривалість";
    }

    .films-table td:nth-child(6)::before,
    .home-schedule-table td:nth-child(4)::before,
    .program-schedule-table td:nth-child(4)::before {
        content: "Типи";
    }

    .films-table td:nth-child(7)::before,
    .subtitles-table td:nth-child(4)::before {
        content: "Дії";
    }

    .home-schedule-table td:nth-child(1)::before,
    .program-schedule-table td:nth-child(1)::before,
    .watch-history-table td:nth-child(2)::before {
        content: "Початок";
    }

    .home-schedule-table td:nth-child(2)::before,
    .program-schedule-table td:nth-child(2)::before {
        content: "Назва";
    }

    .home-schedule-table td:nth-child(3)::before,
    .program-schedule-table td:nth-child(3)::before,
    .watch-history-table td:nth-child(3)::before {
        content: "Завершення";
    }

    .episodes-table td:nth-child(1)::before {
        content: "#";
    }

    .episodes-table td:nth-child(2)::before {
        content: "Назва серії";
    }

    .episodes-table td:nth-child(4)::before {
        content: "Субтитри";
    }

    .watch-history-table td:nth-child(1)::before {
        content: "Дата";
    }

    .watch-history-table td:nth-child(4)::before {
        content: "Що дивився";
    }

    .subtitles-table td:nth-child(1)::before {
        content: "ID";
    }

    .subtitles-table td:nth-child(2)::before {
        content: "Файл";
    }

    .subtitles-table td:nth-child(3)::before {
        content: "Мова";
    }

    .translation-jobs-table td:nth-child(2)::before {
        content: "Статус";
    }

    .translation-jobs-table td:nth-child(3)::before {
        content: "Модель";
    }

    .translation-jobs-table td:nth-child(4)::before {
        content: "Прогрес";
    }

    .translation-jobs-table td:nth-child(5)::before {
        content: "Оновлено";
    }

    .usage-batches-table td:nth-child(1)::before {
        content: "Батч";
    }

    .usage-batches-table td:nth-child(2)::before {
        content: "Input";
    }

    .usage-batches-table td:nth-child(3)::before {
        content: "Output";
    }

    .usage-batches-table td:nth-child(4)::before {
        content: "Total";
    }

    .usage-batches-table td:nth-child(5)::before {
        content: "Cached";
    }

    .repair-missing-table td:nth-child(1)::before {
        content: "Індекс";
    }

    .repair-missing-table td:nth-child(2)::before {
        content: "Оригінал";
    }

    .repair-missing-table td:nth-child(3)::before {
        content: "Переклад";
    }
}

.split-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 16px;
    flex-wrap: wrap;
}

.actions-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.films-search-field {
    min-width: min(100%, 360px);
    flex: 1 1 280px;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form input[type="text"] {
    width: auto;
    min-width: 220px;
}

.subtitle-actions {
    gap: 8px;
}

.compact-pill,
.compact-inline-form button,
.more-actions-trigger {
    padding: 7px 12px;
    font-size: 0.92rem;
}

.compact-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 14px;
}

.action-icon {
    width: 18px;
    height: 18px;
    display: block;
}

.compact-inline-form {
    gap: 0;
}

.more-actions {
    position: relative;
}

.more-actions summary {
    list-style: none;
}

.more-actions summary::-webkit-details-marker {
    display: none;
}

.more-actions-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    border: 1px solid var(--line);
    background: var(--panel-strong);
    border-radius: 14px;
    cursor: pointer;
    color: var(--text);
    line-height: 1;
}

.more-actions[open] .more-actions-trigger,
.more-actions-trigger:hover {
    border-color: var(--accent);
    color: #fff;
}

.more-actions-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 20;
    min-width: 240px;
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(12, 16, 24, 0.98);
    box-shadow: var(--shadow);
}

.more-actions-menu .pill-link,
.more-actions-menu .inline-form,
.more-actions-menu .ghost-button {
    width: 100%;
}

.more-actions-menu .pill-link {
    display: flex;
}

.more-actions-menu .pill-link,
.more-actions-menu button {
    justify-content: center;
}

.more-menu-form {
    display: grid;
    gap: 8px;
}

.more-menu-form input[type="text"] {
    width: 100%;
    min-width: 0;
}

.job-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.job-card {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    text-decoration: none;
    background: rgba(11, 14, 22, 0.82);
}

.job-card:hover {
    border-color: var(--accent);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.status-queued {
    background: rgba(255, 196, 86, 0.12);
    border-color: rgba(255, 196, 86, 0.32);
}

.status-running {
    background: rgba(66, 214, 181, 0.12);
    border-color: rgba(66, 214, 181, 0.32);
}

.status-needs_repair_json,
.status-needs_repair_missing {
    background: rgba(255, 122, 69, 0.14);
    border-color: rgba(255, 122, 69, 0.34);
}

.status-completed {
    background: rgba(79, 188, 112, 0.14);
    border-color: rgba(79, 188, 112, 0.34);
}

.status-failed {
    background: rgba(255, 99, 132, 0.16);
    border-color: rgba(255, 99, 132, 0.34);
}

.code-block,
.inline-pre,
.mono-textarea {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

.code-block,
.inline-pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.code-block {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(8, 11, 18, 0.9);
}

.notice-card {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(120, 136, 214, 0.24);
    background: rgba(19, 24, 39, 0.76);
}

.warning-card {
    border-color: rgba(214, 122, 122, 0.38);
    background: rgba(64, 24, 24, 0.42);
}

.repair-index-cell {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

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

.repair-shift-button {
    min-height: 28px;
    padding: 4px 10px;
}

.repair-missing-row {
    background: rgba(214, 122, 122, 0.06);
}

.tag-chip-warning {
    border-color: rgba(214, 165, 80, 0.4);
    background: rgba(214, 165, 80, 0.12);
    color: #f7d898;
}

.small-code {
    margin-top: 14px;
}

.mono-textarea {
    width: 100%;
}

.top-gap {
    margin-top: 16px;
}

.episode-editor-list {
    display: grid;
    gap: 14px;
}

.episode-editor-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr);
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(9, 12, 19, 0.72);
}

.active-schedule-row td {
    background: rgba(76, 201, 123, 0.14);
}

.jumped-highlight-row td {
    animation: jumped-highlight-fade 2.6s ease-out forwards;
}

@keyframes jumped-highlight-fade {
    0% {
        background: rgba(76, 201, 123, 0.38);
    }
    45% {
        background: rgba(76, 201, 123, 0.24);
    }
    100% {
        background: transparent;
    }
}

.past-schedule-row td {
    background: rgba(255, 99, 132, 0.14);
}

.cancelled-schedule-row td {
    background: rgba(150, 156, 174, 0.12);
    color: rgba(214, 220, 232, 0.62);
}

.cancelled-schedule-row .text-link,
.cancelled-schedule-row .muted,
.cancelled-schedule-row strong,
.cancelled-schedule-row .type-chip {
    color: rgba(214, 220, 232, 0.62);
}

.cancelled-schedule-row .type-chip {
    background: rgba(150, 156, 174, 0.1);
    border-color: rgba(150, 156, 174, 0.28);
}

.pagination-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    align-items: center;
}

.active-page {
    border-color: var(--accent);
    color: #fff;
}

.pagination-ellipsis {
    color: var(--muted);
    padding: 0 4px;
    font-weight: 700;
}

.collapsed-type {
    display: none;
}

.schedule-episode-list {
    margin-top: 6px;
}

.history-watch-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.compact-chip-wrap {
    gap: 8px;
}

.watch-history-table th,
.watch-history-table td {
    vertical-align: middle;
    white-space: nowrap;
}

.watch-history-table .type-chip {
    padding: 4px 10px;
}

.hidden-row {
    display: none;
}

.program-schedule-table td,
.home-schedule-table td {
    vertical-align: middle;
}

.program-schedule-table td:nth-child(4),
.home-schedule-table td:nth-child(4) {
    min-width: 180px;
}

.select-search-group {
    display: grid;
    gap: 8px;
}

.select-search-group input,
.select-search-group select {
    width: 100%;
}

.episode-option-seen {
    color: #8ef5de;
    font-weight: 600;
}

.schedule-option-recent {
    color: #8ef5de;
    font-weight: 600;
}

.schedule-option-mid {
    color: #ffb347;
    font-weight: 600;
}

.schedule-option-old {
    color: #ff8fd1;
    font-weight: 600;
}

.schedule-entry-row {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.context-action-menu {
    position: absolute;
    z-index: 120;
    display: none;
    gap: 8px;
    transform: translate(8px, 8px);
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(12, 16, 24, 0.98);
    box-shadow: var(--shadow);
}

.context-action-menu.visible {
    display: grid;
}

.context-action-menu .pill-link,
.context-action-menu button {
    width: 100%;
    justify-content: center;
}

.context-shift-button {
    color: var(--text);
    border-color: var(--line);
}

.tv-channel-select {
    min-width: 18rem;
}

.tv-channel-select select {
    min-width: 18rem;
}

.tv-program-sticky-card {
    position: sticky;
    top: 12px;
    z-index: 30;
    backdrop-filter: blur(12px);
}

.tv-program-mobile-bar {
    display: none;
}

.tv-program-mobile-summary {
    display: grid;
    gap: 2px;
}

.tv-program-toggle-button {
    white-space: nowrap;
}

.epg-progress-card {
    margin-top: 18px;
    display: grid;
    gap: 12px;
}

.epg-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.epg-progress-bar {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
}

.epg-progress-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #3fd7c3 0%, #7ce3a5 100%);
    transition: width 0.35s ease;
}

.epg-progress-sources {
    display: grid;
    gap: 8px;
}

.epg-source-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
}

.epg-source-status strong {
    font-size: 0.95rem;
}

.epg-source-status span {
    color: var(--muted);
    font-size: 0.92rem;
    text-align: right;
}

.epg-source-status.running {
    border-color: rgba(63, 215, 195, 0.5);
}

.epg-source-status.completed {
    border-color: rgba(124, 227, 165, 0.55);
}

.epg-source-status.failed {
    border-color: rgba(255, 120, 120, 0.55);
}

.epg-job-log {
    display: grid;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(5, 9, 18, 0.55);
    font-size: 0.92rem;
}

.epg-job-log-line {
    color: var(--muted);
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
}

.settings-add-source-form {
    margin-top: 20px;
}

.settings-source-stack {
    display: grid;
    gap: 18px;
    margin-top: 20px;
}

.settings-source-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.02);
}

.settings-source-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.settings-inline-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-source-body.is-collapsed {
    display: none;
}

.channel-selection-table .checkbox-row {
    justify-content: flex-start;
}

.channel-selection-table code {
    font-size: 0.88rem;
    word-break: break-all;
}

.compact-checkbox span {
    font-size: 0.92rem;
}

.danger-button {
    color: #ff9e9e;
    border-color: rgba(255, 120, 120, 0.4);
}

.danger-button:hover {
    border-color: rgba(255, 120, 120, 0.7);
    background: rgba(255, 120, 120, 0.08);
}

.easy-hero,
.easy-summary-grid,
.easy-main,
.easy-side,
.easy-action-stack,
.easy-link-stack,
.simple-list {
    display: grid;
    gap: 14px;
}

.easy-hero {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.easy-hero-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.easy-layout {
    display: grid;
    grid-template-columns: minmax(0, 2.15fr) minmax(280px, 0.85fr);
    gap: 20px;
    align-items: start;
}

.easy-search-form {
    max-width: 640px;
}

.easy-two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.easy-inline-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.easy-inline-form input,
.easy-inline-form select {
    min-width: 0;
    flex: 1 1 150px;
}

.easy-link-stack a {
    width: fit-content;
}

.easy-copy-button {
    cursor: pointer;
}

.easy-copy-textarea {
    min-height: 320px;
    white-space: pre;
}

.simple-list {
    margin: 0;
    padding-left: 18px;
}

.simple-list li {
    color: var(--muted);
    line-height: 1.45;
}

.easy-subtitles-table td,
.easy-results-table td {
    vertical-align: top;
}

.danger-form button {
    border-color: rgba(255, 120, 120, 0.4);
    color: #ffb3b3;
}

.danger-form button:hover {
    background: rgba(255, 120, 120, 0.08);
}

@media (max-width: 760px) {
    .easy-hero,
    .easy-layout,
    .easy-two-column {
        grid-template-columns: 1fr;
    }

    .easy-hero-links {
        justify-content: flex-start;
    }

    .tv-channel-select,
    .tv-channel-select select {
        min-width: 0;
        width: 100%;
    }

    .tv-program-sticky-card {
        top: 8px;
    }

    .tv-program-mobile-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 4px;
    }

    .tv-program-sticky-card.is-collapsed {
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .tv-program-sticky-card.is-collapsed .tv-program-sticky-body {
        display: none;
    }

    .epg-source-status {
        grid-template-columns: 1fr;
        display: grid;
    }

    .epg-source-status span {
        text-align: left;
    }

    .settings-source-head {
        display: grid;
    }

    .settings-inline-actions {
        width: 100%;
    }
}
