:root {
    --bg: #0d1117;
    --panel: #151b23;
    --panel-2: #1c2430;
    --line: #273142;
    --text: #e6edf3;
    --muted: #8b98a9;
    --accent: #e5484d;
    --accent-2: #ff6b6f;
    --ok: #3fb950;
    --warn: #d29922;
    --bad: #f85149;
    --info: #58a6ff;
    --radius: 10px;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
code, .mono { font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { margin-left: auto; text-align: right; }
.nowrap { white-space: nowrap; }
.wrap { word-break: break-all; }
.grow { flex: 1; min-width: 0; }
.pad { padding: 1rem 1.25rem; }

/* Layout administrace */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--muted); padding: .5rem .75rem; border-radius: 8px; }
.sidebar nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.content { padding: 1.75rem 2rem 3rem; max-width: 1400px; width: 100%; }

.brand { display: flex; align-items: center; gap: .6rem; font-size: 1.15rem; color: var(--text); font-weight: 500; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent-2); font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #8a1c20); color: #fff; font-weight: 800; }

/* Uživatelský portál */
.portal-head { display: flex; align-items: center; gap: 2rem; padding: .9rem 1.5rem; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.portal-head nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.portal-head nav a { color: var(--muted); padding: .4rem .8rem; border-radius: 8px; }
.portal-head nav a.active, .portal-head nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.portal-user { margin-left: auto; display: flex; gap: .75rem; align-items: center; }
.portal-main { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.portal-main h1 { margin-bottom: 1rem; }

/* Statické stránky (přihlášení) */
.plain { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 3rem 1rem; gap: 1.5rem; }
.plain-brand { font-size: 1.4rem; }
.narrow { width: 100%; max-width: 440px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.card.flush { padding: 0; overflow-x: auto; }
/* Karty s rozbalovacími menu (⋮) nesmí obsah ořezávat, jinak menu u spodního okraje není vidět. */
.card.flush.no-clip { overflow: visible; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.card-head h2 { margin-bottom: .5rem; }
.card-head.pad { padding-bottom: .25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; }
.grid-2 > .card { margin-bottom: 1.25rem; }

/* Formuláře */
label { display: block; margin-bottom: .85rem; color: var(--muted); font-size: .88rem; }
input, select, textarea {
    display: block; width: 100%; margin-top: .3rem; padding: .6rem .75rem; font: inherit; color: var(--text);
    background: var(--bg); border: 1px solid var(--line); border-radius: 8px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--info); box-shadow: 0 0 0 3px rgb(88 166 255 / .15); }
select { width: auto; display: inline-block; margin: 0 .35rem 0 0; padding: .35rem .5rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.search { width: 300px; margin: 0; }
.inline-input { display: inline-block; width: 220px; margin: 0 .35rem 0 0; padding: .3rem .5rem; }
.code-input { font-family: ui-monospace, Menlo, monospace; font-size: 1.8rem; letter-spacing: .35em; text-align: center; max-width: 260px; }
.pair-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.pair-row .code-input { margin: 0; }
.pair-done { font-size: 1.1rem; }
.toggle { display: flex; align-items: center; gap: .5rem; margin: 0; color: var(--text); }
.toggle input { width: auto; margin: 0; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; overflow-x: auto; }

.btn {
    display: inline-flex; align-items: center; gap: .35rem; padding: .55rem 1rem; font: inherit; font-weight: 500; cursor: pointer;
    color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #3a475b; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn.wide { width: 100%; justify-content: center; padding: .75rem; }
.link { background: none; border: 0; padding: 0; color: var(--info); cursor: pointer; font: inherit; }
.link:hover { text-decoration: underline; }

/* Upozornění */
.alert { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert.error { background: rgb(248 81 73 / .1); border-color: rgb(248 81 73 / .4); color: #ffa198; }
.alert.ok { background: rgb(63 185 80 / .1); border-color: rgb(63 185 80 / .4); color: #7ee787; }
.alert.warn { background: rgb(210 153 34 / .1); border-color: rgb(210 153 34 / .4); color: #e3b341; }
.alert.info { background: rgb(88 166 255 / .08); border-color: rgb(88 166 255 / .35); color: #a5d6ff; }
.link-alert { display: block; }
.link-alert:hover { text-decoration: none; filter: brightness(1.15); }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 500; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { color: #7ee787; background: rgb(63 185 80 / .12); border-color: rgb(63 185 80 / .3); }
.badge.warn { color: #e3b341; background: rgb(210 153 34 / .12); border-color: rgb(210 153 34 / .3); }
.badge.bad { color: #ffa198; background: rgb(248 81 73 / .12); border-color: rgb(248 81 73 / .3); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #3a475b; margin-right: .4rem; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgb(63 185 80 / .2); }

/* Tabulky a seznamy */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.table td { padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--panel-2); }
.table .big { font-size: 1.25rem; letter-spacing: .1em; }
.table th.right, .table td.right { text-align: right; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: baseline; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.device-list { list-style: none; margin: 0; padding: 0 1.25rem .5rem; }
.device-list li { display: flex; align-items: center; gap: .75rem; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.device-list li:last-child { border-bottom: 0; }

.props { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }

/* Dlaždice přehledu */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; color: var(--text); }
.tile:hover { border-color: #3a475b; text-decoration: none; }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: 2rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile-sub { color: var(--muted); font-size: .8rem; }

/* Katalog */
.tabs { display: flex; gap: .25rem; align-items: center; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; color: var(--muted); padding: .6rem 1rem; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.posters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.1rem; }
.poster { display: flex; flex-direction: column; gap: .3rem; color: var(--text); }
.poster:hover { text-decoration: none; }
.poster img, .poster-empty { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.poster:hover img { border-color: var(--muted); }
.poster-empty { display: grid; place-items: center; font-size: 2.5rem; color: var(--muted); }
.poster-title { font-size: .9rem; font-weight: 500; line-height: 1.3; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 1.5rem 0; }
.detail-hero { display: flex; gap: 1.5rem; margin-bottom: 1.25rem; align-items: flex-start; }
.detail-poster { width: 200px; border-radius: 10px; border: 1px solid var(--line); flex: none; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: .75rem 1.25rem; background: #5c1a1a; color: #fff; z-index: 1000; }
#blazor-error-ui .reload { color: #fff; text-decoration: underline; margin-left: .5rem; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; }

@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .content { padding: 1.25rem 1rem; }
    .search { width: 100%; }
    .detail-hero { flex-direction: column; }
}

/* Upload */
.wide-select { display: block; width: 100%; margin: .25rem 0 1rem; padding: .55rem .6rem; }
.inbox-upload { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.inbox-upload input[type=file] { width: auto; flex: 1; min-width: 200px; margin: 0; padding: .35rem; }
.progress { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin: .35rem 0; min-width: 120px; flex: 1; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: .9rem; }
.segmented button { background: none; border: 0; color: var(--muted); padding: .4rem 1rem; font: inherit; cursor: pointer; }
.segmented button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.tmdb-preview { display: flex; gap: 1rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.tmdb-preview img { width: 92px; border-radius: 6px; border: 1px solid var(--line); align-self: flex-start; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: .35rem 0; }
.error-text { color: #ffa198; margin-top: .25rem; }

/* Verze aplikací */
pre.log { max-height: 60vh; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: .8rem; line-height: 1.45; }
.report-view { border-bottom: 1px solid var(--line); }
input[type=file] { padding: .45rem; }

/* Detail titulu */
.title-years { font-size: 1.1rem; font-weight: 400; }
.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; }
.link-badge { color: var(--text); }
.link-badge:hover { border-color: var(--muted); text-decoration: none; }
.dropdown { position: relative; }
.dropdown-backdrop { position: fixed; inset: 0; z-index: 10; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 11; min-width: 230px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .3rem; box-shadow: 0 10px 30px rgb(0 0 0 / .45); }
.dropdown-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: .55rem .75rem; border-radius: 6px; font: inherit; cursor: pointer; }
.dropdown-menu button:hover:not(:disabled) { background: var(--panel-2); }
.dropdown-menu button:disabled { opacity: .45; cursor: default; }

/* Detail titulu — přehled, řady, epizody, streamy */
.title-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); gap: 1.25rem; margin-bottom: 1.25rem; }
.title-top .detail-hero { margin: 0; }
.detail-hero .detail-poster { width: 150px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; align-content: start; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; display: flex; flex-direction: column; }
.stat b { font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .8rem; }
.stat.warn b { color: #e3b341; }
.stat.bad b { color: #ffa198; }
.stat .progress { margin: .4rem 0 0; }
.season-tabs { display: flex; gap: .25rem; overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--info); border-radius: var(--radius) var(--radius) 0 0; padding: .35rem; }
.season-tabs button { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; min-width: 96px; padding: .45rem .75rem; background: none; border: 0; border-radius: 6px; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.season-tabs button.active { background: var(--panel-2); }
.season-tabs button.active b { color: var(--info); }
.season-tabs .dot-warn { position: absolute; top: .55rem; right: .5rem; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.progress.thin { display: block; height: 3px; width: 100%; min-width: 0; margin: .2rem 0 0; }
.progress > span { display: block; height: 100%; background: var(--ok); }
.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; background: var(--panel); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: .6rem .75rem; margin-bottom: 1rem; }
.list-toolbar .search { margin-left: auto; width: 280px; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: .25rem .7rem; font: inherit; font-size: .85rem; cursor: pointer; }
.chip.active { background: var(--info); border-color: var(--info); color: #06121f; }
.chip .count { opacity: .75; font-size: .75rem; margin-left: .2rem; }
.season-block { margin-bottom: 1rem; }
.season-head { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.season-head .progress { max-width: 120px; margin: 0; }
.episode { border-bottom: 1px solid var(--line); }
.episode:last-child { border-bottom: 0; }
.episode.not-aired { opacity: .55; }
.episode-row { display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; cursor: pointer; }
.episode-row:hover, .episode.open .episode-row { background: var(--panel-2); }
.chevron { width: 1rem; color: var(--muted); }
.ep-code { color: var(--muted); min-width: 4.5rem; }
.still { width: 96px; height: 54px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); flex: none; }
.still.empty { display: inline-block; background: var(--panel-2); }
.ep-text { min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge.res { color: #a5d6ff; background: rgb(88 166 255 / .12); border-color: rgb(88 166 255 / .3); }
.badge.lang { font-family: ui-monospace, Menlo, monospace; }
.episode-streams { padding: .5rem 1rem .75rem 2.5rem; display: flex; flex-direction: column; gap: .5rem; }
.episode-streams.flat { padding: 0 1rem 1rem; }
.episode-foot { display: flex; align-items: center; gap: .75rem; }
.stream-row { display: grid; grid-template-columns: 110px minmax(180px, 2fr) 90px minmax(140px, 1.5fr) 60px auto; gap: .75rem; align-items: center; padding: .6rem .8rem; background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 8px; }
.stream-row.status-ok { border-left-color: var(--ok); }
.stream-row.status-bad { border-left-color: var(--bad); opacity: .7; }
.stream-langs { display: flex; flex-wrap: wrap; gap: .25rem; }
.stream-actions { display: flex; gap: .3rem; align-items: center; justify-content: flex-end; }
.select-all { user-select: all; }
.key { color: #e3b341; margin-left: .5rem; }
.icon-btn { width: 30px; height: 30px; display: inline-grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; color: var(--muted); cursor: pointer; font: inherit; }
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
.icon-btn.on-ok { background: rgb(63 185 80 / .2); color: #7ee787; border-color: rgb(63 185 80 / .5); }
.icon-btn.on-bad { background: rgb(248 81 73 / .2); color: #ffa198; border-color: rgb(248 81 73 / .5); }
.dropdown-menu hr { margin: .3rem 0; }
.dropdown-menu .danger-item { color: var(--bad); }
.modal-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .55); z-index: 50; }
.modal { position: fixed; z-index: 51; top: 6vh; left: 50%; transform: translateX(-50%); width: min(720px, 94vw); max-height: 88vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; box-shadow: 0 20px 60px rgb(0 0 0 / .6); }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.side-panel { position: fixed; z-index: 51; top: 0; right: 0; bottom: 0; width: min(700px, 96vw); overflow: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 1.25rem; box-shadow: -20px 0 60px rgb(0 0 0 / .5); }
.side-panel h3 { margin: 1rem 0 .5rem; font-size: .95rem; }
.radio-row { display: flex; gap: 1.25rem; margin-bottom: .6rem; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; max-height: 340px; overflow: auto; padding: 2px; }
.image-grid.tall { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.image-grid button { padding: 0; background: var(--panel-2); border: 2px solid transparent; border-radius: 6px; cursor: pointer; overflow: hidden; color: var(--text); font: inherit; }
.image-grid button.active { border-color: var(--info); }
.image-grid img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.image-grid.tall img { aspect-ratio: 2/3; }
.image-auto { display: flex !important; flex-direction: column; justify-content: center; align-items: center; gap: .25rem; padding: .5rem !important; text-align: center; min-height: 80px; }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto; margin: .5rem 0 1rem; }
.pick-list button { text-align: left; background: none; border: 1px solid transparent; border-radius: 6px; padding: .45rem .6rem; color: var(--text); font: inherit; cursor: pointer; }
.pick-list button:hover { background: var(--panel-2); }
.pick-list button.active { border-color: var(--info); background: var(--panel-2); }
.search.wide { width: 100%; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 1100px) {
    .title-top { grid-template-columns: 1fr; }
    .stream-row { grid-template-columns: 1fr 1fr; }
}

.server-chart { display: block; width: 100%; height: 140px; margin-top: .75rem; }
.server-chart polyline { fill: none; stroke: var(--info); stroke-width: 2; vector-effect: non-scaling-stroke; }
.server-chart .chart-grid { stroke: var(--line); stroke-width: 1; fill: none; vector-effect: non-scaling-stroke; }
.server-chart-labels { display: flex; justify-content: space-between; margin-top: .5rem; }
