
        :root {
            color-scheme: light dark;
        }
        .availability-toggle {
            display: inline-flex;
            align-items: center;
            gap: 0.25rem;
            font-size: 0.9rem;
        }
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            margin: 0;
            padding: 0;
            background: #f4f7f9;
            color: #333;
        }
        body::after {
            content: '';
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            aspect-ratio: 542.93 / 273.56;
            background: url('/static/backgrounds/tentacles.svg') no-repeat bottom center / 100% 100%;
            pointer-events: none;
            z-index: -1;
            opacity: 0.2;
        }
        .wrapper {
            max-width: 1200px;
            margin: 0 auto;
            padding: 2rem 1rem 3rem;
        }
        h1, h2 {
            color: #2c3e50;
            margin-top: 0;
        }
        .card > h2,
        .card > h1 {
            margin-top: 0;
        }
        .card {
            background: white;
            border-radius: 10px;
            padding: 1.5rem;
            margin-bottom: 1.5rem;
            box-shadow: 0 4px 15px rgba(0,0,0,0.08);
        }
        .alert {
            padding: 0.75rem 1rem;
            border-radius: 6px;
            margin-bottom: 1rem;
            background: #e9f7ef;
            color: #1e8449;
        }
        #toast-container {
            position: fixed;
            right: 1.5rem;
            top: 1.5rem;
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            z-index: 9999;
            pointer-events: none;
        }
        .toast {
            min-width: 220px;
            max-width: 320px;
            padding: 0.75rem 1rem;
            border-radius: 12px;
            background: rgba(255, 255, 255, 0.98);
            color: #1f2933;
            box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
            font-size: 0.95rem;
            letter-spacing: 0.01em;
            border: 1px solid rgba(15, 23, 42, 0.08);
        }
        .toast--success {
            border-color: rgba(16, 185, 129, 0.35);
            color: #0f766e;
            background: rgba(240, 253, 250, 0.98);
        }
        .toast--error {
            border-color: rgba(239, 68, 68, 0.35);
            color: #b91c1c;
            background: rgba(254, 242, 242, 0.98);
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 1rem;
        }
        th, td {
            border: 1px solid #e0e0e0;
            padding: 0.5rem 0.75rem;
            text-align: left;
            font-size: 0.9rem;
            vertical-align: top !important;
        }
        th {
            background: #f0f4f8;
        }
        table.inner-table th, table.inner-table td {
            border-color: #ddd;
        }
        .form-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1rem;
        }
        .form-field-end {
            display: flex;
            justify-content: flex-end;
            align-items: flex-end;
        }
        .independent-search-form {
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }
        .search-bar {
            display: grid;
            grid-template-columns: minmax(240px, 1fr) minmax(180px, 260px);
            gap: 1rem;
            align-items: end;
        }
        .search-input-wrap {
            position: relative;
        }
        .search-history {
            display: flex;
            flex-direction: column;
            position: relative;
        }
        .history-toggle-btn {
            display: inline-flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.35rem;
            padding: 0.45rem 0.6rem;
            border-radius: 8px;
            border: 1px solid #dfe6e9;
            background: #ffffff;
            color: #1f2f3f;
            font-weight: 600;
            cursor: pointer;
            text-align: left;
        }
        .history-toggle-btn:hover {
            background: #f3f5f9;
        }
        .history-dropdown {
            position: absolute;
            top: calc(100% + 0.4rem);
            left: 0;
            right: 0;
            border: 1px solid #dfe6e9;
            border-radius: 8px;
            background: #ffffff;
            padding: 0.4rem;
            max-height: 220px;
            overflow-y: auto;
            box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
            z-index: 25;
        }
        .history-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.6rem;
            padding: 0.4rem;
            border-radius: 6px;
        }
        .history-item:hover {
            background: #f3f5f9;
        }
        .history-info {
            min-width: 0;
        }
        .history-title {
            font-weight: 600;
            color: #1f2f3f;
        }
        .history-meta {
            font-size: 0.8rem;
            color: #6c757d;
        }
        .history-actions {
            display: flex;
            gap: 0.35rem;
            flex-shrink: 0;
            margin-left: auto;
        }
        .history-actions .icon-btn {
            margin-top: 0;
            padding: 0.2rem;
            border-radius: 6px;
        }
        .history-actions .icon-btn img {
            width: 16px;
            height: 16px;
        }
        .history-empty {
            padding: 0.2rem;
        }
        .is-disabled {
            opacity: 0.6;
        }
        .is-disabled input,
        .is-disabled select,
        .is-disabled button {
            cursor: not-allowed;
        }
        .tmdb-suggestions {
            position: absolute;
            top: calc(100% + 0.4rem);
            left: 0;
            right: 0;
            background: #ffffff;
            border: 1px solid #dfe6e9;
            border-radius: 10px;
            box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
            max-height: 280px;
            overflow-y: auto;
            overflow-x: hidden;
            z-index: 20;
            list-style: none;
            padding: 0;
            margin: 0;
        }
        .tmdb-suggestions.is-hidden {
            display: none;
        }
        .tmdb-suggestion-item {
            width: 100%;
            padding: 0.6rem 0.75rem;
            border: none;
            background: transparent;
            text-align: left;
            cursor: pointer;
            border-bottom: 1px solid #f0f0f0;
            box-sizing: border-box;
        }
        .tmdb-suggestion-item:last-child {
            border-bottom: none;
        }
        .tmdb-suggestion-item:hover {
            background: #f3f5f9;
        }
        .tmdb-suggestion-item .suggestion-title {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-weight: 600;
            color: #1f2f3f;
            margin-bottom: 2px;
        }
        .tmdb-suggestion-item .suggestion-title-text {
            flex: 1;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .tmdb-suggestion-item .suggestion-meta {
            font-size: 0.85rem;
            color: #6c757d;
        }
        .emby-availability {
            display: inline-flex;
            gap: 0.25rem;
            margin-left: auto;
            padding-left: 0.5rem;
        }
        .emby-icon {
            display: inline-block;
            font-size: 1rem;
            line-height: 1;
        }
        .tmdb-suggestion {
            width: 100%;
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.6rem 0.75rem;
            border: none;
            background: transparent;
            text-align: left;
            cursor: pointer;
        }
        .tmdb-suggestion:hover {
            background: #f3f5f9;
        }
        .tmdb-suggestion-poster {
            width: 36px;
            height: 54px;
            border-radius: 6px;
            background: #e5e7eb;
            background-size: cover;
            background-position: center;
            flex-shrink: 0;
            position: relative;
        }
        .tmdb-suggestion-poster.is-empty::after {
            content: "?";
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            color: #7f8c8d;
        }
        .tmdb-suggestion-title {
            font-weight: 600;
            color: #1f2f3f;
        }
        .tmdb-suggestion-meta {
            font-size: 0.85rem;
            color: #6c757d;
        }
        .selected-title-card {
            display: flex;
            align-items: flex-start;
            gap: 0.75rem;
            padding: 0.6rem 0.75rem;
            border-radius: 10px;
            border: 1px solid #dfe6e9;
            background: #f8fafc;
            margin-top: 0.5rem;
        }
        .selected-poster {
            width: 54px;
            height: 78px;
            border-radius: 8px;
            background: #e5e7eb;
            background-size: cover;
            background-position: center;
            flex-shrink: 0;
            position: relative;
        }
        .selected-poster[data-empty="true"]::after {
            content: "?";
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            color: #7f8c8d;
        }
        .selected-meta {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 0.15rem;
        }
        .selected-title {
            font-weight: 700;
            color: #1f2f3f;
        }
        .selected-year {
            font-size: 0.9rem;
            color: #4a5867;
        }
        .selected-original {
            font-size: 0.85rem;
            color: #6c757d;
        }
        .selected-emby-availability {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 0.45rem;
            margin-top: 0.35rem;
        }
        .selected-emby-availability .tagline {
            margin: 0;
            font-size: 0.78rem;
            color: #5b6773;
        }
        .emby-server-icons {
            display: flex;
            flex-wrap: wrap;
            gap: 0.35rem;
        }
        .emby-server-btn {
            border: 1px solid #d5dde5;
            background: #ffffff;
            border-radius: 999px;
            padding: 0.15rem 0.45rem;
            font-size: 0.9rem;
            line-height: 1;
            cursor: pointer;
        }
        .emby-server-btn.is-active {
            background: #1f2f3f;
            border-color: #1f2f3f;
            color: #ffffff;
        }
        .selected-emby-browser {
            margin-top: 0.5rem;
            padding: 0.55rem;
            border-radius: 8px;
            border: 1px solid #e1e8ef;
            background: #ffffff;
        }
        .emby-browser-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.5rem;
            margin-bottom: 0.4rem;
        }
        .emby-browser-title {
            font-weight: 600;
            color: #1f2f3f;
        }
        .emby-browser-close {
            border: none;
            background: #e3e7ed;
            color: #2c3e50;
            border-radius: 999px;
            width: 26px;
            height: 26px;
            cursor: pointer;
            font-weight: 700;
            line-height: 1;
        }
        .emby-browser-sections {
            display: grid;
            grid-template-columns: minmax(120px, 1fr) minmax(180px, 2fr);
            gap: 0.6rem;
            align-items: start;
        }
        .emby-browser-sections.is-tv {
            grid-template-columns: minmax(140px, 210px) minmax(260px, 1fr);
        }
        .emby-browser-section {
            min-width: 0;
        }
        .emby-browser-section.emby-details {
            grid-column: 1 / -1;
        }
        .emby-browser-section.is-span {
            grid-column: 1 / -1;
        }
        .emby-section-title {
            font-weight: 600;
            font-size: 0.85rem;
            color: #4a5867;
            margin-bottom: 0.25rem;
        }
        .emby-season-scroll {
            max-height: clamp(180px, 40vh, 320px);
            overflow-y: auto;
            padding-right: 0.15rem;
            min-height: 0;
        }
        .emby-season-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 0.35rem;
        }
        .emby-season-btn {
            border: 1px solid #d5dde5;
            background: #f8fafc;
            border-radius: 8px;
            padding: 0.22rem 0.4rem;
            font-size: 0.76rem;
            font-weight: 600;
            text-align: center;
            color: #1f2f3f;
            cursor: pointer;
        }
        .emby-season-btn.is-active {
            background: #1f2f3f;
            border-color: #1f2f3f;
            color: #ffffff;
        }
        .emby-season-btn:focus-visible {
            outline: 2px solid #1f2f3f;
            outline-offset: 2px;
        }
        .emby-episode-grid {
            --emby-episode-tile-width: 92px;
            --emby-episode-card-height: 36px;
            --emby-episode-strip-height: 12px;
            display: grid;
            grid-template-columns: repeat(auto-fill, var(--emby-episode-tile-width));
            gap: 0.45rem;
            align-content: start;
        }
        .emby-episode-tile {
            display: flex;
            flex-direction: column;
            gap: 0;
            width: var(--emby-episode-tile-width);
        }
        .emby-episode-card {
            width: 100%;
            height: var(--emby-episode-card-height);
            border-radius: 10px 10px 0 0;
            border: 1px solid #cbd5e1;
            border-bottom: 0;
            background: #e5e7eb;
            font-weight: 600;
            font-size: 0.85rem;
            color: #1f2f3f;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            box-sizing: border-box;
        }
        .emby-episode-card.is-active {
            background: #cbd5e1;
            border-color: #1f2f3f;
            color: #0f172a;
        }
        .emby-episode-card:focus-visible {
            outline: 2px solid #1f2f3f;
            outline-offset: 2px;
        }
        .emby-episode-strip {
            width: 100%;
            height: var(--emby-episode-strip-height);
            display: flex;
            gap: 2px;
            flex-wrap: nowrap;
            overflow: hidden;
            padding: 0;
            margin-top: 0;
            border: 1px solid #cbd5e1;
            border-top: 0;
            border-radius: 0 0 10px 10px;
            background: #f8fafc;
            box-sizing: border-box;
        }
        .emby-episode-segment {
            flex: 1 1 0;
            min-width: 0;
            border: none;
            border-radius: 0;
            height: 100%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            appearance: none;
        }
        .emby-episode-segment.is-active {
            box-shadow: inset 0 0 0 2px #1f2f3f;
        }
        .emby-episode-segment:focus-visible {
            outline: none;
            box-shadow: inset 0 0 0 2px #1f2f3f;
        }
        .emby-episode-segment:first-child {
            border-bottom-left-radius: 8px;
        }
        .emby-episode-segment:last-child {
            border-bottom-right-radius: 8px;
        }
        .emby-episode-segment:only-child {
            border-bottom-left-radius: 8px;
            border-bottom-right-radius: 8px;
        }
        .emby-episode-segment.is-empty {
            background: #e2e8f0;
            width: 100%;
            flex: 1 1 0;
            cursor: default;
        }
        .emby-episode-more {
            background: #e2e8f0;
            color: #1f2f3f;
            font-size: 0.7rem;
            line-height: 1;
            font-weight: 700;
        }
        .emby-version-list {
            display: flex;
            flex-wrap: wrap;
            gap: 0.35rem;
        }
        .emby-resolution-chip {
            border: 1px solid #d5dde5;
            background: #ffffff;
            border-radius: 999px;
            padding: 0.1rem 0.4rem;
            font-size: 0.7rem;
            cursor: pointer;
            color: #1f2f3f;
        }
        .emby-resolution-chip.is-active {
            background: #1f2f3f;
            border-color: #1f2f3f;
            color: #ffffff;
        }
        .emby-resolution-chips {
            display: flex;
            flex-wrap: wrap;
            gap: 0.3rem;
            margin-bottom: 0.35rem;
        }
        .emby-resolution-btn {
            border: 1px solid #d5dde5;
            background: #ffffff;
            border-radius: 999px;
            padding: 0.15rem 0.5rem;
            font-size: 0.72rem;
            cursor: pointer;
            color: #1f2f3f;
        }
        .emby-resolution-btn.is-active {
            background: #1f2f3f;
            border-color: #1f2f3f;
            color: #ffffff;
        }
        .emby-details {
            border-top: 1px dashed #dfe6e9;
            padding-top: 0.4rem;
            display: flex;
            flex-direction: column;
            gap: 0.4rem;
        }
        .emby-streams-grid {
            display: flex;
            flex-wrap: nowrap;
            gap: 0.6rem;
            margin-top: 0.4rem;
            overflow-x: auto;
            padding-bottom: 0.25rem;
        }
        .emby-stream-table {
            border: 1px solid #e1e8ef;
            border-radius: 8px;
            padding: 0.4rem;
            background: #ffffff;
            flex: 0 0 auto;
        }
        .emby-stream-title {
            font-weight: 600;
            font-size: 0.85rem;
            color: #1f2f3f;
            margin-bottom: 0.3rem;
        }
        .emby-stream-grid {
            border-collapse: collapse;
            width: max-content;
        }
        .emby-stream-grid th,
        .emby-stream-grid td {
            border: 1px solid #e6edf4;
            padding: 0.25rem 0.4rem;
            font-size: 0.75rem;
            text-align: left;
            vertical-align: top;
            background: #ffffff;
        }
        .emby-stream-grid thead th {
            background: #f3f6fa;
            font-weight: 600;
            color: #1f2f3f;
        }
        .emby-stream-label {
            font-weight: 600;
            color: #4a5867;
            min-width: 90px;
            position: sticky;
            left: 0;
            background: #ffffff;
            z-index: 1;
        }
        .emby-stream-track {
            min-width: 120px;
            white-space: nowrap;
        }
        .emby-stream-value {
            min-width: 120px;
            white-space: nowrap;
        }
        .emby-details-title {
            font-weight: 600;
            color: #1f2f3f;
        }
        .emby-source-card {
            border: 1px solid #e1e8ef;
            border-radius: 8px;
            padding: 0.4rem 0.55rem;
            background: #f9fbfd;
        }
        .emby-source-title {
            font-weight: 600;
            font-size: 0.85rem;
            margin-bottom: 0.25rem;
            color: #1f2f3f;
        }
        .emby-detail-row {
            display: flex;
            justify-content: space-between;
            gap: 0.5rem;
            font-size: 0.78rem;
            margin-bottom: 0.2rem;
        }
        .emby-detail-label {
            color: #6c757d;
        }
        .emby-detail-value {
            color: #1f2f3f;
            text-align: right;
            word-break: break-word;
        }
        .emby-detail-tracks {
            margin: 0.25rem 0 0;
            padding-left: 1.1rem;
            font-size: 0.75rem;
            color: #4a5867;
        }
        .emby-detail-content {
            display: flex;
            flex-direction: column;
            gap: 0.45rem;
        }
        .emby-detail-popover {
            position: absolute;
            z-index: 1200;
            width: min(420px, 92vw);
            background: #ffffff;
            border: 1px solid #e1e8ef;
            border-radius: 12px;
            box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
        }
        .emby-detail-popover.is-hidden {
            display: none;
        }
        .emby-detail-popover-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.55rem 0.7rem;
            border-bottom: 1px solid #eef2f7;
            background: #f8fafc;
        }
        .emby-detail-popover-title {
            font-weight: 600;
            font-size: 0.85rem;
            color: #1f2f3f;
        }
        .emby-detail-popover-close {
            border: none;
            background: #e3e7ed;
            color: #2c3e50;
            border-radius: 999px;
            width: 26px;
            height: 26px;
            cursor: pointer;
            font-weight: 700;
            line-height: 1;
        }
        .emby-detail-popover-body {
            max-height: 60vh;
            overflow: auto;
            padding: 0.7rem;
        }
        .emby-detail-modal {
            position: fixed;
            inset: 0;
            z-index: 1200;
            display: flex;
            align-items: flex-end;
            justify-content: center;
            background: rgba(15, 23, 42, 0.45);
        }
        .emby-detail-modal.is-hidden {
            display: none;
        }
        .emby-detail-sheet {
            width: min(680px, 100%);
            background: #ffffff;
            border-radius: 16px 16px 0 0;
            max-height: 85vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        .emby-detail-sheet-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.7rem 0.9rem;
            border-bottom: 1px solid #eef2f7;
            background: #f8fafc;
        }
        .emby-detail-sheet-title {
            font-weight: 600;
            font-size: 0.9rem;
            color: #1f2f3f;
        }
        .emby-detail-sheet-close {
            border: none;
            background: #e3e7ed;
            color: #2c3e50;
            border-radius: 999px;
            width: 28px;
            height: 28px;
            cursor: pointer;
            font-weight: 700;
            line-height: 1;
        }
        .emby-detail-sheet-body {
            padding: 0.8rem 0.9rem 1rem;
            overflow: auto;
        }
        .emby-version-menu {
            display: flex;
            flex-direction: column;
            gap: 0.35rem;
        }
        .emby-version-menu-item {
            border: 1px solid #d5dde5;
            background: #f8fafc;
            border-radius: 8px;
            padding: 0.4rem 0.55rem;
            font-size: 0.78rem;
            text-align: left;
            color: #1f2f3f;
            cursor: pointer;
        }
        .emby-version-menu-item:hover {
            background: #eef2f7;
        }
        .emby-version-menu-item:focus-visible {
            outline: 2px solid #1f2f3f;
            outline-offset: 2px;
        }
        @media (max-width: 720px) {
            .emby-browser-sections {
                grid-template-columns: 1fr;
            }
            .emby-browser-section.emby-details {
                grid-column: 1 / -1;
            }
            .emby-episode-grid {
                --emby-episode-tile-width: 84px;
                --emby-episode-card-height: 36px;
                --emby-episode-strip-height: 12px;
            }
        }
        .clear-selection-btn {
            border: none;
            background: #e3e7ed;
            color: #2c3e50;
            border-radius: 999px;
            width: 32px;
            height: 32px;
            cursor: pointer;
            font-weight: 700;
        }
        .clear-selection-btn:hover {
            background: #d3dae4;
        }
        .season-picker {
            margin-top: 0.6rem;
            padding: 0.6rem 0.75rem;
            border-radius: 10px;
            border: 1px solid #e1e6f0;
            background: #ffffff;
        }
        .season-picker .tagline {
            margin-bottom: 0.4rem;
        }
        .checkbox-row {
            display: flex;
            flex-wrap: wrap;
            gap: 0.75rem;
            align-items: center;
        }
        .checkbox-row label {
            font-weight: 400;
        }
        .indexer-group {
            border: 1px solid transparent;
            border-radius: 8px;
            padding: 0.35rem 0.45rem;
        }
        .indexer-group[data-invalid="true"] {
            border-color: #f5b7b1;
            background: #fef5f5;
        }
        .indexer-group[data-invalid="true"] .tagline {
            color: #c0392b;
        }
        .search-actions {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }
        .search-actions .btn {
            margin-top: 0;
        }
        .advanced-options {
            border: 1px solid #e1e6f0;
            border-radius: 12px;
            padding: 1rem;
            background: #fbfcff;
        }
        .advanced-options h3 {
            margin-top: 0;
            margin-bottom: 0.75rem;
            color: #1f2f3f;
        }
        .advanced-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 0.9rem;
        }
        .results-placeholder {
            min-height: 140px;
            padding: 0.5rem;
            border-radius: 10px;
            border: 1px dashed #d0d7de;
            background: #f9fbfd;
        }
        .results-placeholder.has-results {
            border: none;
            background: transparent;
            padding: 0;
        }
        .manual-results {
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
        }
        .manual-loading {
            align-items: center;
            justify-content: center;
            min-height: 140px;
        }
        .manual-spinner {
            width: 34px;
            height: 34px;
            border-radius: 50%;
            border: 3px solid #dfe6e9;
            border-top-color: #0d62c2;
            animation: spin 0.8s linear infinite;
        }
        @keyframes spin {
            from { transform: rotate(0deg); }
            to { transform: rotate(360deg); }
        }
        .manual-results-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 0.5rem;
        }
        .manual-results-actions {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        .manual-bulk-btn {
            margin-top: 0;
        }
        .manual-warning {
            color: #9a3412;
        }
        .manual-results-table-wrap {
            overflow-x: auto;
        }
        .manual-results-table {
            width: 100%;
            border-collapse: collapse;
            min-width: 720px;
        }
        .manual-results-table th,
        .manual-results-table td {
            border: 1px solid #e0e0e0;
            padding: 0.55rem 0.75rem;
            text-align: left;
            font-size: 0.9rem;
            vertical-align: top;
        }
        .manual-results-table .select-col {
            width: 30px;
            text-align: center;
        }
        .manual-results-table th {
            background: #f0f4f8;
        }
        .manual-title-cell {
            min-width: 220px;
        }
        .manual-title-text {
            font-weight: 600;
            color: #1f2f3f;
        }
        .manual-title-badges {
            display: flex;
            flex-wrap: wrap;
            gap: 0.35rem;
            margin-top: 0.25rem;
        }
        .manual-seeders,
        .manual-leechers-col {
            white-space: nowrap;
        }
        .manual-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 0.4rem;
        }
        .manual-actions .btn {
            margin-top: 0;
        }
        .badge.action {
            border: none;
            cursor: pointer;
            font: inherit;
        }
        .badge.action:hover {
            filter: brightness(0.96);
        }
        .is-hidden {
            display: none !important;
        }
        .modal-backdrop {
            position: fixed;
            inset: 0;
            background: rgba(15, 23, 42, 0.6);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 1.5rem;
            z-index: 10000;
        }
        .modal {
            width: 100%;
            max-width: 560px;
            background: #ffffff;
            border-radius: 14px;
            box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
            overflow: hidden;
        }
        .modal-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 1rem 1.25rem;
            border-bottom: 1px solid #e2e8f0;
        }
        .modal-header h3 {
            margin: 0;
            font-size: 1.1rem;
            color: #1f2f3f;
        }
        .modal-close {
            border: none;
            background: #e3e7ed;
            color: #2c3e50;
            border-radius: 8px;
            width: 32px;
            height: 32px;
            cursor: pointer;
            font-size: 1.1rem;
            line-height: 1;
        }
        .modal-body {
            padding: 1rem 1.25rem 1.25rem;
            display: grid;
            gap: 0.6rem;
            max-height: 70vh;
            overflow-y: auto;
        }
        #generic-modal {
            box-sizing: border-box;
            padding: 1.5rem;
        }
        .generic-modal-content {
            box-sizing: border-box;
            background: var(--bg-card, #ffffff);
            color: #1f2f3f;
            border: 1px solid #d9e2ec;
        }
        .generic-modal-header {
            display: block;
            padding: 0 2.5rem 1rem 0;
            border-bottom: 1px solid #e2e8f0;
        }
        .generic-modal-header h3 {
            color: #1f2f3f;
            font-size: 1.15rem;
            line-height: 1.3;
        }
        .generic-modal-body {
            display: block;
            padding: 1.2rem 0 0;
            max-height: 55vh;
            overflow-y: auto;
        }
        .generic-modal-actions {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 1rem;
            padding: 0;
            border: none;
        }
        .generic-modal-close {
            width: 2rem;
            height: 2rem;
            border-radius: 8px;
            border: none;
            background: #e8eef5;
            color: #1f2f3f;
            line-height: 1;
        }
        .modal-row {
            display: grid;
            grid-template-columns: 140px 1fr;
            gap: 0.75rem;
            align-items: baseline;
            word-break: break-word;
        }
        .modal-label {
            font-weight: 600;
            color: #2c3e50;
        }
        .modal-list {
            margin: 0;
            padding-left: 1rem;
        }
        @media (max-width: 720px) {
            .search-bar {
                grid-template-columns: 1fr;
            }
        }
        .rule-note {
            margin-bottom: 0.4rem;
        }
        .rule-sections {
            display: grid;
            gap: 1rem;
            margin-top: 0.75rem;
        }
        .rule-block {
            border: 1px solid #e4e8f0;
            border-radius: 10px;
            padding: 1rem;
            background: #fbfcfe;
        }
        .rule-block h4 {
            margin: 0 0 0.6rem;
            color: #1f2f3f;
        }
        .rule-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 0.9rem;
        }
        .rule-grid.three-cols {
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        }
        .rule-grid.three-cols .wide-field {
            grid-column: span 2;
        }
        .rule-grid .wide-field {
            grid-column: 1 / -1;
        }
        .sort-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
            gap: 1rem;
            margin-top: 1rem;
        }
        .sort-column {
            border: 1px solid #e3e8f3;
            border-radius: 12px;
            padding: 1rem;
            background: #fff;
            box-shadow: 0 8px 20px rgba(41, 61, 102, 0.08);
        }
        .sort-column h4 {
            margin: 0 0 0.75rem;
            color: #1d3557;
        }
        .sort-pair {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 0.75rem;
        }
        .sort-field label {
            font-weight: 600;
        }
        .sort-note {
            margin-top: 0.35rem;
        }
        label {
            display: block;
            margin-bottom: 0.35rem;
            font-weight: 600;
        }
        input[type="text"], input[type="number"], input[type="password"], input[type="url"] {
            width: 100%;
            padding: 0.6rem;
            border-radius: 6px;
            border: 1px solid #ccd1d9;
            box-sizing: border-box;
        }
        textarea {
            width: 100%;
            padding: 0.6rem;
            border-radius: 6px;
            border: 1px solid #ccd1d9;
            box-sizing: border-box;
            resize: vertical;
            min-height: 120px;
            font-family: inherit;
        }
        select {
            width: 100%;
            padding: 0.6rem;
            border-radius: 6px;
            border: 1px solid #ccd1d9;
            box-sizing: border-box;
            background: #fff;
            color: #333;
        }
        @media (prefers-color-scheme: dark) {
            body[data-tab-page="config"] input[type="text"],
            body[data-tab-page="config"] input[type="number"],
            body[data-tab-page="config"] input[type="password"],
            body[data-tab-page="config"] input[type="url"],
            body[data-tab-page="config"] textarea,
            body[data-tab-page="config"] select {
                background: #111827;
                color: #e5e7eb;
                border-color: #334155;
            }
            body[data-tab-page="config"] input::placeholder,
            body[data-tab-page="config"] textarea::placeholder {
                color: #94a3b8;
            }
        }
        .checkbox-group {
            display: flex;
            flex-direction: column;
            gap: 0.35rem;
            margin-top: 0.5rem;
        }
        .checkbox-group label {
            font-weight: 400;
        }
        .btn {
            margin-top: 1rem;
            padding: 0.8rem 1.2rem;
            background: #007bff;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 1rem;
        }
        .btn.is-loading {
            opacity: 0.7;
            cursor: wait;
        }
        .btn:hover {
            background: #0062cc;
        }
        .btn.secondary {
            background: #6c757d;
        }
        .btn.secondary:hover {
            background: #565e64;
        }
        .btn.light {
            background: #dfe4ea;
            color: #1f2f3f;
        }
        .btn.light:hover {
            background: #cfd8da;
        }
        .btn.ghost {
            background: #f4f6fb;
            color: #1f2f3f;
            border: 1px solid #cfd8e3;
        }
        .btn.ghost:hover {
            background: #e6ebf5;
        }
        .btn.small {
            padding: 0.4rem 0.7rem;
            font-size: 0.85rem;
        }
        .help-popover {
            position: relative;
            display: inline-block;
            margin-bottom: 1rem;
        }
        .help-trigger {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            border: 1px solid #d1d9e6;
            background: #f8fafc;
            color: #1f2f3f;
            font-weight: 700;
            cursor: pointer;
        }
        .help-content {
            display: none;
            position: absolute;
            z-index: 10;
            top: 36px;
            left: 0;
            width: 300px;
            background: #ffffff;
            border: 1px solid #dbe3ef;
            border-radius: 10px;
            padding: 0.75rem 0.9rem;
            box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
            color: #1f2f3f;
        }
        .help-content code {
            font-family: inherit;
            font-weight: 600;
        }
        .help-content code.breakable {
            overflow-wrap: anywhere;
            word-break: break-word;
        }
        .help-popover:hover .help-content,
        .help-popover:focus-within .help-content {
            display: block;
        }
        .primary-nav {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
            flex-wrap: wrap;
        }
        .primary-nav .nav-link {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.4rem 0.9rem;
            border-radius: 999px;
            background: #edf2f7;
            color: #2c3e50;
            text-decoration: none;
            font-weight: 600;
            border: 1px solid transparent;
        }
        .primary-nav .nav-link:hover {
            background: #d6e4f0;
        }
        .primary-nav .nav-link.active {
            background: #1f618d;
            color: #fff;
            border-color: #154360;
        }
        .notification-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 20px;
            height: 20px;
            padding: 0 6px;
            background: #dc2626;
            color: white;
            border-radius: 10px;
            font-size: 0.7rem;
            font-weight: 700;
            line-height: 1;
        }
        .notification-badge.warning {
            background: #f59e0b;
        }
        .notification-badge + .notification-badge {
            margin-left: 4px;
        }
        .primary-nav .nav-link.active .notification-badge {
            background: #fff;
            color: #dc2626;
        }
        .primary-nav .nav-link.active .notification-badge.warning {
            color: #f59e0b;
        }
        .status-pill {
            display: inline-flex;
            align-items: center;
            padding: 0.1rem 0.5rem;
            border-radius: 999px;
            font-size: 0.8rem;
        }
        .status-ok {
            background: #e9f7ef;
            color: #1e8449;
        }
        .status-fail {
            background: #fdecea;
            color: #c0392b;
        }
        .status-skip {
            background: #f4f6f7;
            color: #5f6a6a;
        }
        .connection-status {
            margin-top: 0.75rem;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 0.5rem;
        }
        .connection-card {
            border: 1px solid #e1e6f0;
            border-radius: 10px;
            padding: 0.6rem 0.8rem;
            background: #fbfcff;
        }
        .connection-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
        }
        .connection-card .tagline {
            margin-top: 0.25rem;
        }
        .config-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 1rem;
            margin-top: 0.5rem;
        }
        .config-box {
            border: 1px solid #e1e6f0;
            border-radius: 12px;
            padding: 1rem;
            background: #fbfcff;
        }
        .config-box fieldset {
            border: none;
            padding: 0;
            margin: 0;
            min-inline-size: 0;
        }
        .config-box h4 {
            margin-top: 0;
        }
        .event-bridge-server-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 1.25rem;
            margin: 1.25rem 0;
        }
        .event-bridge-server-card {
            margin: 0;
        }
        .event-bridge-server-summary {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 1rem;
            list-style: none;
        }
        .event-bridge-server-summary::-webkit-details-marker {
            display: none;
        }
        .event-bridge-server-heading {
            min-width: 0;
        }
        .event-bridge-server-status {
            display: inline-flex;
            align-items: center;
            gap: 0.7rem;
            flex-shrink: 0;
        }
        .event-bridge-server-chevron {
            color: #64748b;
            font-size: 0.9rem;
            transition: transform 0.18s ease;
        }
        .event-bridge-server-card[open] .event-bridge-server-chevron {
            transform: rotate(180deg);
        }
        .event-bridge-server-body {
            display: grid;
            gap: 1rem;
            margin-top: 1rem;
            padding-top: 1rem;
            border-top: 1px solid #e1e8f2;
        }
        .event-bridge-options {
            display: flex;
            flex-wrap: wrap;
            gap: 0.75rem 1rem;
        }
        .event-bridge-options label {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            margin: 0;
        }
        .event-bridge-number-grid,
        .event-bridge-events-grid {
            display: grid;
            gap: 0.75rem;
        }
        .event-bridge-number-grid {
            grid-template-columns: repeat(4, minmax(0, 1fr));
        }
        .event-bridge-events-grid {
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        }
        .event-bridge-events-grid textarea {
            min-height: 8.5rem;
        }
        @media (min-width: 1180px) {
            .event-bridge-server-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
                align-items: start;
            }
        }
        @media (max-width: 760px) {
            .event-bridge-number-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
        }
        @media (max-width: 520px) {
            .event-bridge-number-grid {
                grid-template-columns: 1fr;
            }
        }
        .checklist-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 0.75rem;
            margin-top: 0.75rem;
        }
        .checklist {
            display: grid;
            gap: 0.4rem;
            padding: 0.45rem 0.6rem;
            border: 1px solid #e1e6f0;
            border-radius: 8px;
            background: #fff;
            max-height: 180px;
            overflow: auto;
        }
        .check-item {
            display: flex;
            align-items: center;
            gap: 0.45rem;
            font-size: 0.9rem;
            color: #1f2f3f;
        }
        .telegram-section fieldset {
            border: none;
            padding: 0;
            margin: 0;
            min-inline-size: 0;
        }
        .telegram-section .checklist {
            border: none;
            background: transparent;
            padding: 0;
            max-height: 220px;
        }
        .telegram-section .check-item {
            flex-direction: row;
            align-items: center;
            gap: 0.5rem;
        }
        .telegram-section .check-item input {
            margin: 0;
        }
        .telegram-alerts {
            margin-top: 0.35rem;
        }
        .telegram-alert {
            font-size: 0.78rem;
            line-height: 1.2;
            margin-top: 0.15rem;
        }
        .telegram-alert.ok {
            color: #1c7c3c;
        }
        .telegram-alert.warn {
            color: #9a6b00;
        }
        .telegram-alert.fail {
            color: #b42318;
        }
        .telegram-section {
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
        }
        .telegram-section-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 1rem;
        }
        .telegram-presets {
            margin-top: 1.25rem;
        }
        .telegram-preset-list {
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            border: 1px solid #e1e6f0;
            border-radius: 12px;
            overflow: hidden;
            background: #fff;
        }
        .telegram-preset-card {
            border: none;
            border-bottom: 1px solid #e5e7eb;
            border-radius: 0;
            padding: 1rem;
            background: transparent;
        }
        .telegram-preset-card:last-child {
            border-bottom: none;
        }
        .telegram-preset-grid {
            display: grid;
            grid-template-columns: minmax(140px, 1.2fr) minmax(120px, 1fr) minmax(160px, 1.3fr) minmax(160px, 1.3fr) auto;
            gap: 1rem;
            align-items: start;
        }
        .telegram-preset-name {
            font-weight: 700;
            font-size: 0.95rem;
            color: #111827;
        }
        .telegram-meta-label {
            font-size: 0.7rem;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            color: #6b7280;
            margin-top: 0.35rem;
        }
        .telegram-meta-value {
            font-size: 0.88rem;
            color: #1f2f3f;
        }
        .telegram-meta-empty {
            font-size: 0.85rem;
            color: #9ca3af;
        }
        .telegram-meta-stack {
            display: flex;
            flex-direction: column;
            gap: 0.2rem;
        }
        .telegram-meta-line {
            display: flex;
            align-items: center;
            gap: 0.35rem;
            font-size: 0.85rem;
            color: #1f2f3f;
        }
        .telegram-status {
            font-weight: 700;
            font-size: 0.85rem;
        }
        .telegram-status.ok {
            color: #16a34a;
        }
        .telegram-status.fail {
            color: #dc2626;
        }
        .telegram-preset-actions {
            display: flex;
            gap: 0.4rem;
            justify-content: flex-end;
            align-self: flex-start;
            margin-top: 0.15rem;
        }
        .telegram-empty {
            margin-top: 1rem;
        }
        .telegram-resource-form {
            margin-bottom: 1rem;
        }
        .telegram-form-end {
            align-self: end;
        }
        .telegram-resource-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 0.75rem;
            padding: 0.7rem 0;
            border-bottom: 1px solid #e5e7eb;
        }
        .telegram-resource-info {
            flex: 1;
            min-width: 0;
        }
        .telegram-resource-title {
            font-size: 0.9rem;
            font-weight: 600;
            color: #111827;
            display: flex;
            align-items: center;
            gap: 0.4rem;
        }
        .telegram-resource-sub {
            color: #6b7280;
            font-size: 0.78rem;
            margin-top: 2px;
        }
        .telegram-verify {
            font-size: 0.85rem;
            font-weight: 700;
        }
        .telegram-verify.ok {
            color: #16a34a;
        }
        .telegram-verify.pending {
            color: #9ca3af;
        }
        .telegram-resource-actions {
            display: flex;
            gap: 0.4rem;
            align-items: center;
            flex-wrap: wrap;
            align-self: center;
        }
        .telegram-icon-btn {
            padding: 4px 8px;
            font-size: 14px;
            line-height: 1;
            min-width: 32px;
        }
        .telegram-icon-btn.danger {
            color: #dc2626;
        }
        .telegram-inline-form {
            margin: 0;
            display: inline;
        }
        .telegram-alias-form {
            margin: 0;
            display: none;
            gap: 0.4rem;
            align-items: center;
        }
        .telegram-alias-input {
            width: 120px;
            padding: 4px 8px;
            font-size: 0.8rem;
            border: 1px solid #e5e7eb;
            border-radius: 6px;
        }
        @media (max-width: 980px) {
            .telegram-preset-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
            .telegram-preset-actions {
                justify-content: flex-start;
            }
        }
        @media (max-width: 640px) {
            .telegram-preset-grid {
                grid-template-columns: 1fr;
            }
            .telegram-resource-row {
                flex-direction: column;
                align-items: flex-start;
            }
        }
        .tagline {
            font-size: 0.9rem;
            color: #6c757d;
        }
        .result-title {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 0.5rem;
        }
        .title-text {
            word-break: break-word;
            overflow-wrap: anywhere;
        }
        .title-text mark {
            background: #ffeaa7;
            color: #333;
            padding: 0 0.1rem;
            border-radius: 3px;
        }
        .result-actions {
            display: flex;
            gap: 0.25rem;
        }
        .icon-btn, .icon-link {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0.3rem;
            border-radius: 4px;
            border: 1px solid #ccc;
            background: #fff;
            text-decoration: none;
            cursor: pointer;
        }
        .icon-btn:hover, .icon-link:hover {
            background: #e8ecef;
            border-color: #999;
        }
        .action-icon-small {
            width: 16px;
            height: 16px;
            display: block;
        }
        .action-icon {
            width: 20px;
            height: 20px;
            display: block;
        }
        .batch-icon-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0.3rem;
            border-radius: 4px;
            border: 1px solid #ccc;
            background: #fff;
            cursor: pointer;
        }
        .batch-icon-btn:hover:not(:disabled) {
            background: #e8ecef;
            border-color: #999;
        }
        .batch-icon-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }
        .action-icon-batch {
            width: 16px;
            height: 16px;
            display: block;
        }
        .batch-actions-icons {
            display: flex;
            gap: 0.25rem;
        }
        .progress-container {
            background: #e0e0e0;
            border-radius: 8px;
            overflow: hidden;
            height: 18px;
            margin-top: 0.5rem;
        }
        .progress-bar {
            background: #28a745;
            height: 100%;
            width: 0;
            transition: width 0.3s ease;
        }
        @media (max-width: 600px) {
            table {
                display: block;
                overflow-x: auto;
            }
        }
        .results-table-wrap {
            width: 100%;
            overflow-x: auto;
            border-radius: 12px;
        }
        .results-table, .inner-table {
            table-layout: fixed;
            width: 100%;
        }
        .results-table {
            min-width: 860px;
        }
        .results-table th,
        .results-table td,
        .inner-table th,
        .inner-table td {
            overflow-wrap: break-word;
            word-break: break-word;
        }
        details summary {
            cursor: pointer;
            font-weight: 600;
        }
        details.accordion-block {
            margin-top: 0.5rem;
            margin-bottom: 0.75rem;
        }
        .duplicates-panel {
            margin-top: 0.5rem;
        }
        .duplicates-panel summary {
            cursor: pointer;
            font-weight: 500;
            color: #2c3e50;
        }
        .duplicates-panel table {
            margin-top: 0.4rem;
        }
        .options-sections {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            gap: 1rem;
            margin-top: 1rem;
        }
        .options-column h4 {
            margin: 0 0 0.5rem;
            color: #2c3e50;
        }
        .inline-field {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            flex-wrap: wrap;
        }
        .options-column label {
            font-weight: 400;
        }
        .nested-option {
            margin-left: 1.2rem;
        }
        .variant-note {
            margin-top: 0.75rem;
            font-size: 0.9rem;
            color: #5d6d7e;
        }
        .requests-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 0.75rem;
        }
        .requests-table th, .requests-table td {
            border: 1px solid #dfe6e9;
            padding: 0.45rem;
            font-size: 0.85rem;
            vertical-align: top;
        }
        .requests-table th {
            background: #f5f8fb;
        }
        .requests-table input {
            width: 100%;
            box-sizing: border-box;
        }
        .badge {
            display: inline-flex;
            align-items: center;
            padding: 0.1rem 0.4rem;
            border-radius: 999px;
            font-size: 0.75rem;
            margin-right: 0.25rem;
        }
        .badge.info {
            background: #eaf2fd;
            color: #1f618d;
        }
        .badge.warn {
            background: #fef5e7;
            color: #af601a;
        }
        .badge.skip {
            background: #f9ebea;
            color: #922b21;
        }
        .badge.success {
            background: #e8f6f3;
            color: #117a65;
        }
        .badge.resolution {
            background: #eaf2fd;
            color: #1f618d;
        }
        .season-status-line {
            margin-top: 0.35rem;
            display: flex;
            flex-wrap: wrap;
            gap: 0.35rem;
        }
        .season-tab {
            border: none;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }
        .season-tab.active {
            box-shadow: 0 6px 18px rgba(38, 55, 89, 0.15);
            transform: translateY(-1px);
        }
        .season-panels {
            margin-top: 0.4rem;
        }
        .season-detail-panel {
            display: none;
            padding: 0.3rem 0;
            text-align: left;
        }
        .season-detail-panel.active {
            display: block;
        }
        .episode-chips {
            display: flex;
            flex-wrap: wrap;
            gap: 0.2rem;
            margin-top: 0.25rem;
        }
        .episode-chip {
            font-size: 0.75rem;
            padding: 0.15rem 0.45rem;
            border-radius: 999px;
            background: #ecf0f1;
            color: #2c3e50;
        }
        .episode-chip.status-available {
            background: #e9f7ef;
            color: #1e8449;
        }
        .episode-chip.status-pending {
            background: #fdecea;
            color: #c0392b;
        }
        .episode-chip.status-pending.justwatch-checked {
            background: #fef3c7;
            color: #92400e;
        }
        .episode-chip.justwatch-checked,
        .justwatch-pill.justwatch-checked {
            position: relative;
        }
        .justwatch-checked.is-open::after {
            content: attr(data-jw-label);
            position: absolute;
            left: 0;
            top: calc(100% + 6px);
            z-index: 10;
            padding: 0.35rem 0.55rem;
            border-radius: 8px;
            background: #111827;
            color: #f9fafb;
            font-size: 0.7rem;
            line-height: 1.2;
            max-width: 240px;
            white-space: normal;
            box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2);
        }
        .justwatch-checked.is-open::before {
            content: "";
            position: absolute;
            left: 0.6rem;
            top: calc(100% + 2px);
            width: 8px;
            height: 8px;
            background: #111827;
            transform: rotate(45deg);
            border-radius: 2px;
            z-index: 9;
        }
        .justwatch-pill {
            display: inline-flex;
            align-items: center;
            padding: 0.2rem 0.55rem;
            border-radius: 999px;
            border: 1px solid #f59e0b;
            background: #fef3c7;
            color: #92400e;
            font-size: 0.75rem;
            font-weight: 600;
            cursor: pointer;
        }
        .justwatch-pill:focus {
            outline: 2px solid rgba(245, 158, 11, 0.5);
            outline-offset: 2px;
        }
        .episode-chip.status-unreleased {
            background: #f4f6f7;
            color: #5d6d7e;
        }
        .episode-chip[title] {
            cursor: help;
        }
        .episode-chip .justwatch-badge {
            display: inline-flex;
            align-items: center;
            margin-left: 0.25rem;
            padding: 0.05rem 0.3rem;
            border-radius: 999px;
            background: #dbeafe;
            color: #1e40af;
            font-size: 0.6rem;
            font-weight: 600;
        }
        .list-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 0.4rem;
            margin: 0.5rem 0 0.4rem;
            align-items: center;
        }
        .btn.small {
            padding: 0.45rem 0.75rem;
            font-size: 0.85rem;
        }
        .btn.ghost {
            background: transparent;
            color: #2c3e50;
            border: 1px solid #ccd1d9;
        }
        .btn.ghost:hover {
            background: #e9ecef;
        }
        .title-year {
            font-weight: 400;
            margin-left: 0.3rem;
            color: #34495e;
        }
        .request-list {
            display: flex;
            flex-direction: column;
            gap: 0.45rem;
            margin-top: 0.55rem;
        }
        .request-list.collapsed {
            display: none;
        }
        .group-header {
            margin-top: 1rem;
        }
        .group-toggle {
            border: none;
            background: none;
            font-size: 1.05rem;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            gap: 0.45rem;
            cursor: pointer;
            color: #1f2f3f;
        }
        .group-toggle .group-count {
            font-size: 0.85rem;
            color: #6c7a89;
        }
        .group-toggle .toggle-icon {
            font-size: 0.9rem;
            transition: transform 0.2s ease;
        }
        .group-toggle[aria-expanded="false"] .toggle-icon {
            transform: rotate(-90deg);
        }
        .request-row {
            display: flex;
            gap: 0.45rem;
            align-items: flex-start;
            width: 100%;
            max-width: 100%;
        }
        .request-card {
            border: 1px solid #dfe6e9;
            border-radius: 8px;
            padding: 0.65rem 0.75rem;
            background: #fff;
            flex: 1 1 100%;
            width: 100%;
            min-width: 0;
        }
        .request-header {
            display: flex;
            flex-wrap: wrap;
            align-items: flex-start;
            gap: 0.85rem;
            justify-content: space-between;
        }
        .request-checkbox {
            padding-top: 0.35rem;
        }
        .request-checkbox input {
            margin: 0;
        }
        .request-main {
            width: 100%;
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(360px, 1fr);
            gap: 0.85rem;
            align-items: start;
        }
        .request-info-block {
            display: flex;
            flex-direction: column;
            gap: 0.22rem;
            min-width: 0;
        }
        .request-media-line {
            display: flex;
            gap: 0.72rem;
            align-items: flex-start;
            min-width: 0;
        }
        .request-poster {
            width: 76px;
            height: 114px;
            flex: 0 0 76px;
            border-radius: 6px;
            overflow: hidden;
            background: #eef2f7;
            color: #6b7a90;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            box-shadow: inset 0 0 0 1px rgba(44, 62, 80, 0.08);
        }
        .request-poster img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }
        .request-poster.is-empty i {
            font-size: 1.45rem;
        }
        .request-title-block {
            display: flex;
            flex-direction: column;
            gap: 0.16rem;
            min-width: 0;
            flex: 1 1 auto;
        }
        .request-title-row {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 0.15rem 0.3rem;
            line-height: 1.15;
        }
        .request-title-row strong {
            font-size: 1.08rem;
        }
        .request-badges {
            display: flex;
            flex-wrap: wrap;
            gap: 0.18rem;
            align-items: center;
        }
        .request-card .badge {
            margin-right: 0;
            padding: 0.08rem 0.32rem;
            font-size: 0.68rem;
        }
        .request-links-row {
            display: flex;
            flex-wrap: wrap;
            gap: 0.24rem;
            align-items: center;
        }
        .request-external-links {
            display: inline-flex;
            flex-wrap: wrap;
            gap: 0.18rem;
            align-items: center;
            margin-left: 0.1rem;
        }
        .request-external-links:empty {
            display: none;
        }
        .request-external-links a {
            display: inline-flex;
            align-items: center;
            height: 1.22rem;
            padding: 0 0.34rem;
            border-radius: 999px;
            background: #eef4ff;
            color: #1d4ed8;
            text-decoration: none;
            font-size: 0.64rem;
            font-weight: 700;
        }
        .request-external-links a:hover,
        .request-external-links a:focus {
            background: #dbeafe;
            color: #1e40af;
        }
        .request-right-block {
            display: flex;
            flex-direction: column;
            gap: 0.55rem;
            min-width: 0;
        }
        .request-rules-details {
            border-left: 1px solid #edf1f5;
            padding-left: 0.85rem;
            min-width: 0;
        }
        .request-rules-details summary {
            cursor: pointer;
            color: #415166;
            font-size: 0.85rem;
            font-weight: 700;
            list-style: none;
            width: max-content;
            padding: 0 0 0.25rem;
            border: 0;
            border-radius: 0;
            background: transparent;
        }
        .request-rules-details summary::-webkit-details-marker {
            display: none;
        }
        .request-rules-details[open] summary {
            margin-bottom: 0.35rem;
        }
        .request-fields {
            width: 100%;
            display: grid;
            grid-template-columns: 1fr;
            gap: 0.45rem;
            min-width: 0;
        }
        .request-fields label {
            font-weight: 600;
            color: #2c3e50;
            font-size: 0.85rem;
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
        }
        .request-fields input {
            margin-top: 0;
        }
        .request-options-panel {
            display: flex;
            flex-direction: column;
            gap: 0.45rem;
        }
        .request-option-inline {
            display: flex;
            flex-wrap: nowrap;
            align-items: center;
            gap: 0.5rem;
            overflow-x: auto;
        }
        .request-option-inline span,
        .request-option-inline label {
            margin: 0;
            display: inline-flex;
            align-items: center;
            gap: 0.25rem;
            font-weight: 500;
            white-space: nowrap;
        }
        .option-small-text {
            font-size: 0.75rem;
            color: #42505f;
        }
        .option-label {
            font-weight: 600;
            color: #2c3e50;
        }
        .req-alt-select {
            width: 4.5rem;
            height: 1.85rem;
            font-size: 0.8rem;
            padding: 0 0.35rem;
        }
        .req-year-variance {
            width: 3.2rem;
            height: 1.85rem;
            font-size: 0.8rem;
            padding: 0 0.35rem;
        }
        .request-option-inline input[type="checkbox"] {
            transform: scale(0.9);
        }
        @media (max-width: 1100px) {
            .request-main {
                display: flex;
                flex-direction: column;
                gap: 0.32rem;
            }
            .request-rules-details {
                width: 100%;
                border-left: 0;
                border-top: 1px solid #edf1f5;
                padding-left: 0;
                padding-top: 0.32rem;
            }
            .request-rules-details summary {
                list-style-position: inside;
                width: max-content;
                padding: 0.12rem 0.42rem;
                border: 1px solid #d7dee8;
                border-radius: 999px;
                background: #f6f8fb;
                font-size: 0.72rem;
            }
            .request-fields {
                grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            }
        }
        @media (max-width: 800px) {
            .request-media-line {
                gap: 0.4rem;
            }
            .request-poster {
                width: 58px;
                height: 86px;
                flex-basis: 58px;
            }
            .request-option-inline {
                flex-wrap: wrap;
            }
        }
        .request-meta {
            display: flex;
            flex-wrap: wrap;
            gap: 0.12rem 0.55rem;
            margin-top: 0.04rem;
            min-width: 0;
        }
        .request-meta .meta-item {
            display: inline-flex;
            gap: 0.18rem;
            align-items: baseline;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .meta-label,
        .meta-value {
            font-size: 0.7rem;
        }
        .meta-label {
            color: #7f8c8d;
            text-transform: uppercase;
            letter-spacing: 0.02em;
            display: inline;
        }
        .meta-value {
            font-weight: 400;
            color: #4a5867;
        }
        .results-table {
            border-collapse: separate;
            border-spacing: 0;
            border: none;
            overflow: hidden;
            border-radius: 12px;
            box-shadow: 0 15px 35px rgba(0,0,0,0.08);
        }
        .results-table th, .results-table td {
            border: none;
        }
        .results-table .actions-col {
            text-align: center;
            vertical-align: top !important;
        }
        .results-table td.actions-col {
            text-align: center;
            vertical-align: top !important;
            padding-top: 0.5rem;
        }
        .results-table td.actions-col .btn {
            margin-top: 0;
        }
        .result-row-actions {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.45rem;
            white-space: nowrap;
        }
        .result-row-actions .quick-scan-btn {
            flex: 0 0 auto;
        }
        .result-cleanup-btn {
            width: 2.05rem;
            height: 2.05rem;
            flex: 0 0 auto;
            padding: 0;
            border-radius: 8px;
            color: #b91c1c;
            border-color: #f0c5c5;
            background: #fff7f7;
        }
        .result-cleanup-btn:hover {
            color: #7f1d1d;
            border-color: #e9a8a8;
            background: #fee2e2;
        }
        .result-summary {
            display: grid;
            gap: 0.2rem;
            min-width: 0;
            text-align: left;
        }
        .scan-toolbar {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 0.6rem;
            margin: 0.6rem 0 1rem;
        }
        .scan-toolbar .tagline {
            margin: 0;
        }
        .resolution-header {
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            margin-bottom: 0.75rem;
        }
        .resolution-header-row {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            gap: 0.75rem;
            align-items: center;
        }
        .resolution-header h4 {
            margin: 0;
            flex: 1;
        }
        .block-filter {
            padding: 0.35rem 0.5rem;
            border-radius: 6px;
            border: 1px solid #cfd8e3;
            font-size: 0.85rem;
            max-width: 33%;
            min-width: 150px;
            flex-shrink: 0;
        }
        .batch-actions {
            display: inline-flex;
            gap: 0.35rem;
            align-items: center;
        }
        .batch-btn {
            border: 1px solid #cfd8e3;
            background: #f1f4f9;
            color: #1f2f3f;
            padding: 0.35rem 0.6rem;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.85rem;
        }
        .batch-btn:disabled {
            opacity: 0.4;
            cursor: default;
        }
        .auto-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 1rem;
            margin-top: 1rem;
        }
        .auto-section {
            border: 1px solid #e1e6f0;
            border-radius: 10px;
            padding: 1rem;
            background: #fbfcff;
            display: flex;
            flex-direction: column;
            gap: 0.6rem;
        }
        .auto-section.auto-disabled {
            opacity: 0.5;
        }
        .auto-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.5rem;
        }
        .auto-header h3 {
            margin: 0;
            font-size: 1.05rem;
        }
        .auto-inline {
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
            font-size: 0.9rem;
        }
        .auto-mode {
            display: grid;
            grid-template-columns: auto auto 1fr;
            gap: 0.4rem;
            align-items: center;
        }
        .auto-mode input[type="number"] {
            width: 80px;
        }
        .auto-mode input[type="text"] {
            width: 100%;
        }
        .auto-mode label {
            margin: 0;
            font-weight: 500;
        }
        .auto-note {
            font-size: 0.8rem;
            color: #7f8c8d;
            margin: 0;
        }
        .inline-actions {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 0.6rem;
        }
        .stacked-actions {
            display: grid;
            gap: 0.4rem;
        }
        .inline-input {
            min-width: 160px;
            padding: 0.35rem 0.55rem;
            border-radius: 8px;
            border: 1px solid #d0d7e2;
            background: #fff;
            color: #1f2f3f;
        }
        .tagline.small {
            font-size: 0.78rem;
            color: #8a95a3;
        }
        .trakt-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
        }
        .trakt-subtitle {
            margin-bottom: 0.4rem;
        }
        .trakt-hint {
            margin-bottom: 0.75rem;
        }
        .trakt-actions {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }
        .trakt-device {
            display: inline-flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.9rem;
            color: #2c3e50;
        }
        .trakt-link {
            color: #1f618d;
            text-decoration: underline;
            font-weight: 600;
        }
        .trakt-code {
            display: inline-flex;
            align-items: center;
            padding: 0.15rem 0.5rem;
            border-radius: 999px;
            background: #edf2f7;
            color: #2c3e50;
            font-weight: 700;
            letter-spacing: 0.08em;
        }
        input.read-only {
            background: #f4f6f7;
            color: #5f6a6a;
        }
        .bucket-select-all {
            display: inline-flex;
            align-items: center;
            gap: 0.25rem;
            font-size: 0.8rem;
        }
        .result-select {
            width: 1rem;
            height: 1rem;
        }
        .filter-hidden {
            display: none !important;
        }
        .manual-filter-hidden {
            display: none !important;
        }
        .result-select-cell {
            width: 30px;
        }
        .inner-table .col-select {
            width: 25px;
        }
        .inner-table .col-episode {
            width: 60px;
        }
        .inner-table .col-size {
            width: 65px;
        }
        .inner-table .col-seed {
            width: 50px;
        }
        .inner-table .col-source {
            width: 90px;
        }
        .inner-table .col-episode,
        .inner-table .col-size,
        .inner-table .col-seed {
            text-align: center;
            white-space: nowrap;
        }
        .inner-table .col-source {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .results-table .col-select {
            width: 25px;
        }
        .results-table .col-id {
            width: 50px;
        }
        .results-table .col-actions {
            width: 190px;
        }
        .results-table .col-results {
            width: 190px;
        }
        .results-table .col-id,
        .results-table .col-actions {
            text-align: center;
            white-space: nowrap;
        }
        .results-table .col-results {
            text-align: left;
            white-space: normal;
        }
        .context-menu {
            position: absolute;
            z-index: 999;
            background: #ffffff;
            border: 1px solid #cbd5f5;
            border-radius: 6px;
            box-shadow: 0 10px 25px rgba(15,23,42,0.18);
            padding: 0.25rem 0;
            display: none;
            min-width: 210px;
            color: #0f172a;
        }
        .context-menu.visible {
            display: block;
        }
        .context-menu button {
            width: 100%;
            padding: 0.45rem 0.9rem;
            border: none;
            background: transparent;
            text-align: left;
            cursor: pointer;
            font-size: 0.9rem;
            color: #0f172a;
        }
        .context-menu button:hover {
            background: #eef2f9;
        }
        .inner-table {
            border-radius: 8px;
            overflow: hidden;
        }
        .inner-table th, .inner-table td {
            border: none;
            vertical-align: middle;
        }
        .tab-shell {
            margin-top: 1.5rem;
        }
        .tabs {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            border-bottom: 1px solid #dfe6e9;
            margin-bottom: 1rem;
        }
        .tab-btn {
            border: none;
            background: #e3e7ed;
            color: #2c3e50;
            padding: 0.6rem 1rem;
            border-radius: 6px 6px 0 0;
            cursor: pointer;
            font-size: 0.95rem;
            font-weight: 600;
        }
        .tab-btn.active {
            background: #ffffff;
            color: #0d62c2;
            box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        }
        .tab-panel {
            display: none;
            animation: fadeIn 0.25s ease;
            padding-top: 0.2rem;
        }
        .tab-panel.active {
            display: block;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(8px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .results-table tr.stale {
            background: #f4f5f7;
        }
        .results-table tr.stale details summary {
            color: #5d6d7e;
        }
        .result-updated {
            font-size: 0.8rem;
            color: #7f8c8d;
            margin-top: 0.2rem;
        }
        .results-row {
            cursor: pointer;
            background: #ffffff;
        }
        .results-row:hover {
            background: #f8f9fa;
        }
        .results-row .select-col {
            cursor: default;
        }
        .details-row {
            display: none;
        }
        .details-row.expanded {
            display: table-row;
        }
        .details-content {
            padding: 1rem;
            background: #e8ecef;
            border-top: 2px solid #cbd5e0;
        }
        .results-count {
            font-size: 0.9rem;
            color: #2c3e50;
            font-weight: 600;
            margin-top: 0.3rem;
        }
        .resolution-block {
            background: #f9fbfd;
            padding: 0.25rem 0.75rem 0.75rem 0.75rem;
            border-radius: 10px;
            border: 1px solid #e3ebf3;
            margin-bottom: 0.9rem;
        }
        .inner-table {
            background: #ffffff;
        }
        .inner-table tbody tr {
            background: #ffffff;
        }
        .inner-table tbody tr:hover {
            background: #f8f9fa;
        }
        .result-select-cell input[type="checkbox"],
        .bucket-select-all-checkbox,
        .duplicates-select-all-checkbox,
        .result-scan-checkbox,
        .scan-select-all-group {
            transform: scale(1.0);
            width: 16px;
            height: 16px;
        }
        th.sortable {
            user-select: none;
        }
        th.sortable:hover {
            background: #e8ecef;
        }
        .sort-indicator {
            color: #3498db;
            font-size: 0.8em;
        }

        /* Search History Styles */
        .search-history-list {
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
        }

        .search-history-item {
            background: #f8f9fa;
            border: 1px solid #e1e4e8;
            border-radius: 6px;
            padding: 1rem;
            transition: all 0.2s ease;
        }

        .search-history-item:hover {
            background: #fff;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }

        .search-history-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 1rem;
        }

        .search-history-info {
            flex: 1;
            min-width: 0;
        }

        .search-history-query {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-bottom: 0.25rem;
            flex-wrap: wrap;
        }

        .search-history-query strong {
            font-size: 1rem;
            color: #2c3e50;
        }

        .search-history-meta {
            font-size: 0.875rem;
            color: #7f8c8d;
        }

        .search-history-actions {
            display: flex;
            gap: 0.5rem;
            flex-shrink: 0;
        }

        .badge {
            display: inline-block;
            padding: 0.2em 0.6em;
            font-size: 0.75rem;
            font-weight: 600;
            line-height: 1;
            color: #fff;
            text-align: center;
            white-space: nowrap;
            vertical-align: baseline;
            border-radius: 0.25rem;
            background-color: #6c757d;
        }

        .badge.success {
            background-color: #28a745;
        }

        .badge.warning {
            background-color: #ffc107;
            color: #212529;
        }

        .badge.error {
            background-color: #dc3545;
        }
.btn.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}
.btn.danger {
    background-color: #dc3545;
    color: white;
}
.btn.danger:hover:not(:disabled) {
    background-color: #c82333;
}
.btn.danger:disabled {
    background-color: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

/* Category Management Section */
.category-management-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.categories-three-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}
.categories-column {
    border: 1px solid #dfe3eb;
    border-radius: 4px;
    background-color: #fff;
}
.categories-column h4 {
    margin: 0;
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dfe3eb;
    font-size: 0.95rem;
    font-weight: 600;
    color: #495057;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.category-column-count {
    font-weight: 400;
    color: #6c757d;
    font-size: 0.85rem;
}
.categories-column-list {
    max-height: 500px;
    overflow-y: auto;
}
.category-item {
    display: grid;
    grid-template-columns: 40px 1fr 100px;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e9ecef;
    align-items: center;
    transition: background-color 0.15s;
}
.category-item:hover {
    background-color: #f8f9fa;
}
.category-item:last-child {
    border-bottom: none;
}
.category-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
}
.category-name {
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.category-count {
    color: #6c757d;
    font-size: 0.9rem;
    text-align: right;
}
.categories-empty {
    padding: 2rem;
    text-align: center;
    color: #6c757d;
}
