/* MMP admin UI. Tokens first; components below keep the class names the
   templates use. No inline styles anywhere (the CSP forbids them). */
:root {
  color-scheme: light;
  --bg: #f4f5f9; --card: #fff; --card-2: #f7f8fb; --fg: #141824; --muted: #5f687c; --faint: #8d95a7;
  --line: #e2e5ec; --line-strong: #cfd4de;
  --accent: #5250d8; --accent-hover: #4341c4; --accent-soft: #eeeefd; --accent-fg: #fff;
  --ok-bg: #e2f5ea; --ok-fg: #17663a; --warn-bg: #fdf0d8; --warn-fg: #8a5300;
  --off-bg: #edeff3; --off-fg: #5f687c; --error-bg: #fdeaea; --error-fg: #b42323;
  --side-bg: #121624; --side-fg: #b9c0d2; --side-muted: #6d7690; --side-hover: rgba(255,255,255,.06); --side-active: rgba(130,128,255,.16);
  --shadow: 0 1px 2px rgba(20,24,36,.05), 0 1px 3px rgba(20,24,36,.04);
  --shadow-lg: 0 10px 30px rgba(20,24,36,.12);
  --radius: 10px; --radius-sm: 7px;
  --side-w: 236px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d1017; --card: #151924; --card-2: #1a1f2c; --fg: #e8ebf2; --muted: #9aa3b7; --faint: #6f788d;
    --line: #252b3a; --line-strong: #323a4d;
    --accent: #8583f7; --accent-hover: #9c9afa; --accent-soft: #23234a; --accent-fg: #0d1017;
    --ok-bg: #12301f; --ok-fg: #86dba6; --warn-bg: #352812; --warn-fg: #f2c46d;
    --off-bg: #222837; --off-fg: #9aa3b7; --error-bg: #3a1a1c; --error-fg: #f4a4a4;
    --side-bg: #0a0d14; --side-fg: #b9c0d2;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 30px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); min-height: 100vh;
  font: 14.5px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.i { width: 18px; height: 18px; flex: none; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 1.55rem; line-height: 1.25; letter-spacing: -.01em; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 .6rem; letter-spacing: -.005em; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
section > h2:first-child { margin-top: 0; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }
code { background: var(--card-2); border: 1px solid var(--line); border-radius: 5px; padding: 0 .3rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sub { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.hint { font-size: .78rem; color: var(--faint); }
.okmsg { color: var(--ok-fg); }
.errmsg { color: var(--error-fg); }

/* ---------- App shell ---------- */
body.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: 1fr auto; }
.sidebar { grid-row: 1 / span 2; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--side-bg); color: var(--side-fg); padding: 1rem .75rem; overflow-y: auto; z-index: 30; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .05em; padding: .25rem .5rem 1rem; }
.brand:hover { color: #fff; }
.brand small { display: block; font-weight: 500; letter-spacing: .02em; font-size: .72rem; color: var(--side-muted); }
.logo-mark { width: 30px; height: 30px; color: #8f8dff; flex: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section { margin: 1rem .6rem .35rem; font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--side-muted); }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .48rem .65rem; border-radius: 8px;
  color: var(--side-fg); text-decoration: none; font-weight: 500; }
.sidebar nav a svg { order: -1; opacity: .75; }
.sidebar nav a:hover { background: var(--side-hover); color: #fff; }
.sidebar nav a[aria-current="page"] { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #8f8dff; }
.sidebar nav a[aria-current="page"] svg { opacity: 1; color: #a9a7ff; }
.who { display: flex; align-items: center; gap: .6rem; padding: .75rem .4rem 0; margin-top: 1rem; border-top: 1px solid rgba(255,255,255,.07); }
.who form { margin: 0 0 0 auto; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #2d3150; color: #c9c8ff;
  font-weight: 700; text-transform: uppercase; font-size: .85rem; }
.who-name { display: flex; flex-direction: column; color: #e6e8f0; font-size: .88rem; line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.who-name small { color: var(--side-muted); font-size: .72rem; }
.iconbtn { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 8px;
  background: transparent; color: inherit; border: 0; cursor: pointer; }
.iconbtn:hover { background: var(--side-hover); }
.mobilebar { display: none; }
.scrim { display: none; }
main.page { padding: 1.75rem 2rem 2.5rem; width: 100%; max-width: 1240px; }
body.bare { display: flex; flex-direction: column; }
main.center { flex: 1; display: grid; place-items: center; padding: 1.25rem; }
.foot { grid-column: 2; color: var(--faint); font-size: .78rem; padding: 0 2rem 1.25rem; }

@media (max-width: 900px) {
  body.app { display: block; }
  .mobilebar { display: flex; align-items: center; gap: .5rem; position: sticky; top: 0; z-index: 20; height: 54px; padding: 0 .75rem;
    background: var(--side-bg); color: #fff; }
  .mobilebar .brand { padding: 0; }
  .mobilebar .logo-mark { width: 26px; height: 26px; }
  .mobilebar .iconbtn:hover { background: rgba(255,255,255,.08); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, 85vw); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(8,10,16,.5); z-index: 25; }
  main.page { padding: 1.25rem 1rem 2rem; }
  .foot { padding: 0 1rem 1rem; }
}

/* ---------- Page header ---------- */
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; flex-wrap: wrap; }
.head h1 { margin: 0; }
.head > .row, .head > .button, .head > a.button { flex: none; }
.crumbs { margin: 0 0 .35rem; color: var(--muted); font-size: .85rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.lede { color: var(--muted); max-width: 72ch; margin: 0 0 1.25rem; }
.head + .lede, h1 + .lede { margin-top: .15rem; }
main.page > p.muted:first-of-type { max-width: 80ch; }

/* ---------- Surfaces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }
.empty { text-align: center; padding: 2.25rem 1.25rem; }
.empty p:first-child { font-weight: 600; font-size: 1rem; }
.empty .button { margin-top: .5rem; }
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.75rem; align-items: start; }
.split.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .split, .split.even { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
.span2 { grid-column: span 2; }

/* ---------- Messages ---------- */
.flash, .error, .warnmsg { display: flex; align-items: flex-start; gap: .6rem; border-radius: var(--radius-sm); padding: .65rem .85rem; margin: 0 0 1rem; border: 1px solid transparent; }
.flash { background: var(--ok-bg); color: var(--ok-fg); border-color: color-mix(in srgb, var(--ok-fg) 18%, transparent); }
.flash a { color: inherit; font-weight: 600; }
.error { background: var(--error-bg); color: var(--error-fg); border-color: color-mix(in srgb, var(--error-fg) 18%, transparent); }
.warnmsg { background: var(--warn-bg); color: var(--warn-fg); }
.flash .dismiss { margin-left: auto; background: none; color: inherit; padding: 0 .2rem; opacity: .6; }
.flash .dismiss:hover { opacity: 1; background: none; }

/* ---------- Buttons ---------- */
button, .button { font: inherit; font-weight: 550; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: .5rem .95rem; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-fg); line-height: 1.3; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
button:hover, .button:hover { background: var(--accent-hover); color: var(--accent-fg); }
button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
.button.secondary, button.secondary { background: var(--card); color: var(--fg); border-color: var(--line-strong); }
.button.secondary:hover, button.secondary:hover { background: var(--card-2); border-color: var(--faint); color: var(--fg); }
.button.small, button.small { padding: .28rem .65rem; font-size: .82rem; }
button.danger, .button.danger { background: var(--error-fg); color: #fff; }
button.danger:hover { background: color-mix(in srgb, var(--error-fg) 85%, #000); }
button.link { background: none; color: var(--accent); padding: 0; border: 0; font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; }
button:disabled { opacity: .55; cursor: progress; }
.iconbtn svg { pointer-events: none; }

/* ---------- Forms ---------- */
label { display: grid; gap: .3rem; font-size: .85rem; font-weight: 550; color: var(--fg); }
input, select, textarea { font: inherit; font-weight: 400; color: var(--fg); background: var(--card); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: .48rem .65rem; min-height: 36px; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
input[readonly] { background: var(--card-2); }
textarea { min-height: 5rem; }
label > input:not([type=checkbox]):not([type=radio]), label > select, label > textarea { width: 100%; min-width: 0; }
label.check { display: flex; align-items: center; gap: .55rem; font-weight: 400; color: var(--fg); cursor: pointer; }
label.inline { display: flex; align-items: center; gap: .5rem; flex-direction: row; }
.form { display: grid; gap: 1rem; max-width: 760px; }
form.narrow { max-width: 560px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .65rem .9rem .85rem; margin: 0; }
legend { font-size: .85rem; font-weight: 600; color: var(--fg); padding: 0 .35rem; }
.checks { display: flex; flex-wrap: wrap; gap: .45rem 1.25rem; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.search { margin-bottom: 1rem; }
.search input[type=search] { width: 100%; max-width: 440px; }
.search.row { gap: .6rem; }
.search.row input[type=search] { flex: 1 1 240px; }
.search.row label.check { white-space: nowrap; }
input[type=search] { padding-left: 2.1rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d95a7' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: .65rem center; background-size: 16px; }

/* Danger zone: destructive actions sit apart, with what they do. */
form.danger { margin-top: 1.5rem; border: 1px solid color-mix(in srgb, var(--error-fg) 30%, var(--line)); border-radius: var(--radius);
  padding: .9rem 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: var(--card); }
form.danger::before { content: "Danger zone"; font-weight: 650; color: var(--error-fg); font-size: .9rem; }
form.danger .danger-text { flex: 1 1 100%; order: 1; margin: 0; color: var(--muted); font-size: .82rem; }
form.danger button { order: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 650; background: var(--card-2); white-space: nowrap; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
td a:not(.button) { font-weight: 550; text-decoration: none; }
td a:not(.button):hover { text-decoration: underline; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td form { margin: 0; }
tr.dim td { opacity: .55; }
.actions { white-space: nowrap; display: flex; gap: .35rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.actions-row { flex-wrap: wrap; }
.actions-row form { margin: 0; }
img.logo { width: 28px; height: 28px; object-fit: contain; vertical-align: middle; margin-right: .55rem; border-radius: 5px; background: var(--card-2); }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: center; padding: 1rem; }
.pager a { padding: .35rem .8rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); text-decoration: none; background: var(--card); color: var(--fg); }
.pager a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: .35rem; border-radius: 999px; padding: .12rem .6rem; font-size: .75rem; font-weight: 600; border: 0; line-height: 1.5; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.off { background: var(--off-bg); color: var(--off-fg); }
.pill.bad { background: var(--error-bg); color: var(--error-fg); }
button.pill { cursor: pointer; padding: .15rem .65rem; }
button.pill.ok:hover { background: color-mix(in srgb, var(--ok-bg) 80%, var(--ok-fg)); color: var(--ok-fg); }
button.pill.off:hover { background: color-mix(in srgb, var(--off-bg) 85%, var(--off-fg)); color: var(--off-fg); }

/* ---------- Login ---------- */
.login { width: 100%; max-width: 360px; display: grid; gap: 1rem; padding: 2rem; box-shadow: var(--shadow-lg); }
.login h1 { margin: 0; display: flex; align-items: center; gap: .6rem; }
.login h1 .logo-mark { width: 34px; height: 34px; color: var(--accent); }
.login p { margin: 0; }
.login button { width: 100%; padding: .6rem; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .9rem; align-items: center; }
.stat .ico { grid-row: span 2; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat .ico svg { width: 22px; height: 22px; }
.stat .num { font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .of { font-size: .95rem; color: var(--faint); font-weight: 500; }
.stat .label { color: var(--muted); font-size: .85rem; }
.live-state { display: inline-flex; align-items: center; gap: .4rem; color: var(--ok-fg); font-size: .82rem; font-weight: 600;
  background: var(--ok-bg); padding: .2rem .65rem; border-radius: 999px; }
.live-state[data-state="down"] { color: var(--warn-fg); background: var(--warn-bg); }
ul.events, ul.slots { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
ul.events { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .35rem 0; box-shadow: var(--shadow); }
ul.events li { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; padding: .4rem .9rem; border-bottom: 1px solid var(--line); }
ul.events li:last-child { border-bottom: 0; }
ul.slots li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; box-shadow: var(--shadow); }
.slot-head { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.slot-head a { font-weight: 600; text-decoration: none; }
.bar { height: 6px; background: var(--off-bg); border-radius: 3px; margin-top: .55rem; overflow: hidden; }
.bar .fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .3s; }
.bar .fill.full { background: var(--warn-fg); }

/* Setup checklist */
.setup { margin-bottom: 1.5rem; padding: 1.25rem 1.4rem; }
.setup-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .85rem; }
.setup-head h2 { margin: 0; }
.setup-progress { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .85rem; }
.setup-progress .bar { width: 140px; margin: 0; }
ol.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; counter-reset: step; }
ol.steps li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: .85rem; align-items: center; padding: .6rem .4rem; border-radius: 8px; }
ol.steps li + li { border-top: 1px solid var(--line); }
ol.steps .dot { counter-increment: step; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line-strong); color: var(--muted); font-weight: 700; font-size: .8rem; }
ol.steps .dot::before { content: counter(step); }
ol.steps li.done .dot { background: var(--ok-fg); border-color: var(--ok-fg); color: var(--card); }
ol.steps li.done .dot::before { content: none; }
ol.steps li.done .dot svg { width: 16px; height: 16px; }
ol.steps li:not(.done) .dot svg { display: none; }
ol.steps li.next { background: var(--accent-soft); }
ol.steps li.next .dot { border-color: var(--accent); color: var(--accent); }
ol.steps .step-title { font-weight: 600; }
ol.steps li.done .step-title { color: var(--muted); }
ol.steps .step-text { color: var(--muted); font-size: .84rem; }
ol.steps li.done .step-text { display: none; }

/* ---------- Channel editor ---------- */
ol.failover, ul.picker { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
ol.failover li, ul.picker li { display: flex; align-items: center; gap: .75rem; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; box-shadow: var(--shadow); }
ol.failover li { cursor: grab; }
ol.failover li:hover { border-color: var(--line-strong); }
ol.failover li.dragging { opacity: .5; border-style: dashed; }
ol.failover li.dim { opacity: .55; }
.grip { color: var(--faint); user-select: none; }
.rank { font-weight: 700; min-width: 1.5rem; text-align: center; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: .05rem .35rem; }
.what { flex: 1; display: grid; min-width: 0; }
.state { display: flex; gap: .35rem; align-items: center; white-space: nowrap; }
.moves { display: flex; gap: .25rem; }
.moves button { padding: .2rem .5rem; min-width: 30px; }
#picker { margin-top: .5rem; }
ol.compact { margin: 0; padding-left: 1.2rem; }

/* ---------- Lists & pickers ---------- */
.editor { margin-bottom: 1.5rem; }
.pane-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; flex-wrap: wrap; }
.pane-head h2 { margin: 0; flex: 1; }
ul.pick-list { list-style: none; margin: 0; padding: 0; max-height: 440px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
ul.pick-list li { border-bottom: 1px solid var(--line); padding: .45rem .85rem; }
ul.pick-list li:hover { background: var(--card-2); }
ul.pick-list li:last-child { border-bottom: 0; }
ul.pick-list .num { display: inline-block; min-width: 2.5rem; text-align: right; color: var(--faint); font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--muted); margin: .25rem 0; }
.tabs { display: flex; gap: .25rem; margin: .5rem 0 1rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .55rem .9rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-weight: 550; margin-bottom: -1px; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- User player setup ---------- */
.creds { display: grid; gap: .55rem; margin-bottom: 1rem; }
.copy { display: grid; grid-template-columns: 9rem minmax(0, 1fr) auto; gap: .5rem; align-items: center; }
.copy .label { color: var(--muted); font-size: .85rem; }
.copy input { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; background: var(--card-2); }
@media (max-width: 600px) { .copy { grid-template-columns: 1fr auto; } .copy .label { grid-column: 1 / -1; } }

/* ---------- Movies & series, bouquets ---------- */
.vod-cats { margin-bottom: 1.5rem; }
.vod-cats .pick-list li.row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.vod-add { margin-top: .75rem; }

/* ---------- Provider groups ---------- */
.groups-form .mode { border: 0; padding: 0; margin: 0 0 1rem; display: flex; gap: 1.5rem; flex-wrap: wrap; }
.groups-form .pane-head { position: sticky; top: 0; background: var(--bg); padding: .6rem 0; z-index: 3; }
.groups-form .pane-head input[type=search] { flex: 1 1 14rem; }
.group-list { columns: 2 20rem; column-gap: 0; }
.group-list li { break-inside: avoid; }
@media (max-width: 900px) { .groups-form .pane-head { top: 54px; } }

/* ---------- Match ---------- */
.match-filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin: 1rem 0; }
.match-filters label { display: flex; flex-direction: column; gap: .3rem; }
.match-filters .grow { flex: 1 1 18rem; }
.apply-opts { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.apply-opts legend { font-weight: 650; padding: 0 .3rem; }
.apply-opts label { display: flex; flex-direction: column; gap: .3rem; }
.match-bar { position: sticky; top: 0; z-index: 3; background: var(--bg); display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.match-bar .push { margin-left: auto; }
@media (max-width: 900px) { .match-bar { top: 54px; } }
.proposals { list-style: none; margin: 0; padding: 0; }
.proposal { display: grid; grid-template-columns: auto 3rem minmax(12rem, 1fr) minmax(14rem, 1.4fr); gap: .85rem; align-items: start; padding: .85rem .5rem; border-bottom: 1px solid var(--line); border-radius: 8px; }
.proposal:hover { background: var(--card); }
.proposal:has(input[name=key]:checked) { background: var(--accent-soft); }
.proposal .pick { padding-top: .45rem; }
.proposal .logo-box { width: 3rem; height: 2.2rem; display: flex; align-items: center; justify-content: center; background: var(--card-2); border-radius: 6px; }
.proposal .logo-box img { max-width: 2.8rem; max-height: 2rem; object-fit: contain; }
.proposal .name-row { display: flex; gap: .45rem; align-items: center; }
.proposal .name-edit { flex: 1; min-width: 0; font-weight: 600; padding: .25rem .5rem; min-height: 32px; }
.proposal .streams { margin: 0; padding-left: 1.2rem; font-size: .87rem; }
.proposal .streams li { margin: .12rem 0; }
.proposal .streams label.check { gap: .45rem; }
.rules { margin-top: 2rem; }
.rules summary { cursor: pointer; display: flex; gap: .75rem; align-items: baseline; }
.rules summary h2 { display: inline; margin: 0; }
form.rule { margin-top: 1rem; }
@media (max-width: 760px) {
  .proposal { grid-template-columns: auto 1fr; }
  .proposal .logo-box { display: none; }
  .proposal .streams { grid-column: 1 / -1; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
td.name-col { min-width: 13rem; }
.sub.url { overflow-wrap: normal; word-break: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22rem; }
.row.center { justify-content: center; }
@media (max-width: 900px) {
  .sidebar { box-shadow: none; }
  body.nav-open .sidebar { box-shadow: var(--shadow-lg); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat { padding: .8rem .9rem; column-gap: .65rem; }
  .stat .ico { width: 34px; height: 34px; }
  .stat .num { font-size: 1.35rem; }
}
/* Floating legend sits inside its fieldset, so long hints wrap cleanly. */
fieldset > legend { float: left; width: 100%; padding: 0; margin-bottom: .45rem; }
fieldset > legend + * { clear: both; }
/* Tables become stacked cards on phones. */
@media (max-width: 700px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: .2rem 0; text-align: left; display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline; }
  table.stack td.num { text-align: left; }
  table.stack td[data-label]::before { content: attr(data-label); color: var(--faint); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; flex: none; }
  table.stack tr { display: flex; flex-direction: column; }
  table.stack td.cell-title { display: block; order: -1; font-size: 1rem; padding-bottom: .35rem; }
  table.stack td > * { min-width: 0; }
  table.stack td.cell-actions .actions { justify-content: flex-start; padding-top: .45rem; }
  table.stack .sub.url { max-width: 100%; }
  .table-wrap:has(table.stack) { overflow-x: visible; }
}
