:root {
  --bg: #111214; --panel: #1b1c20; --panel2: #23252a; --line: #33363d;
  --text: #ececec; --dim: #9a9ca3; --red: #d4213d; --green: #2fa866; --amber: #e0a526;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, 'Segoe UI', sans-serif; }
a { color: #ff8a9b; }

/* ---------- Kop en navigatie ---------- */
header.top {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 22px; padding: 10px 20px;
  background: #0b0b0d; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--text); line-height: 1.2; }
.brand b { font-size: 16px; }
.brand span { font-size: 11.5px; color: var(--red); letter-spacing: .04em; }
.mainnav { display: flex; gap: 4px; }
.mainnav a { color: var(--dim); text-decoration: none; padding: 7px 12px; border-radius: 7px; }
.mainnav a:hover { color: var(--text); background: var(--panel2); }
.mainnav a.on { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--red); }
.conn { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--dim); }
form.inline { display: inline; margin: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #555; margin-right: 6px; vertical-align: 1px; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.err { background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot.live { background: var(--red); box-shadow: 0 0 8px var(--red); animation: pulse 1.2s ease-in-out infinite; }
.dot.done { background: var(--amber); }
@keyframes pulse { 50% { opacity: .35; } }

.channels { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 20px 0; max-width: 1600px; margin: 0 auto; }
.ch-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.ch { display: flex; align-items: center; gap: 4px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px;
      background: var(--panel); color: var(--text); text-decoration: none; }
.ch:hover { border-color: #4a4e57; }
.ch.active { border-color: var(--red); background: #2a1a1e; }
.ch small { color: var(--dim); font-size: 12px; margin-left: 6px; }

/* ---------- Opbouw ---------- */
main { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; padding: 18px 20px 40px; max-width: 1600px; margin: 0 auto; }
main.single { display: block; max-width: 1100px; }
main.single > section + section { margin-top: 18px; }
@media (max-width: 1000px) { main { grid-template-columns: 1fr; } }
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
section { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
section h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); font-weight: 600; }
h1 { font-size: 22px; margin: 0 0 6px; }

/* ---------- Knoppen en velden ---------- */
button, .btn {
  font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 14px; cursor: pointer; transition: background .15s, border-color .15s;
  text-decoration: none; display: inline-block; white-space: nowrap;
}
button:hover, .btn:hover { background: #2d3037; border-color: #4a4e57; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.small, .btn.small { padding: 5px 10px; font-size: 13px; }
.btn-start, button.primary, .btn.primary { background: var(--red); border-color: var(--red); font-weight: 700; }
.btn-start { font-size: 16px; padding: 14px 26px; }
.btn-start:hover, button.primary:hover, .btn.primary:hover { background: #e83552; border-color: #e83552; }
button.danger { border-color: #6b2330; color: #ff8a9b; }
button.danger:hover { background: #3a1820; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row > .grow { flex: 1; width: auto; min-width: 160px; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=tel], input[type=url], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px;
}
textarea { resize: vertical; min-height: 140px; font-family: inherit; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--red); }
input[type=range] { width: 100%; accent-color: var(--red); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 560px) { .grid4, .grid3 { grid-template-columns: 1fr 1fr; } .grid2 { grid-template-columns: 1fr; } }
.val { float: right; color: var(--text); }
.help { font-size: 12.5px; color: var(--dim); margin: -4px 0 10px; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; color: var(--text); word-break: break-all; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; }
.check input { accent-color: var(--red); width: 16px; height: 16px; }
.count { font-size: 12px; color: var(--dim); float: right; }
.kbd { font-size: 12px; color: var(--dim); margin-top: 10px; }
.urls { margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; }
.urls li { margin: 4px 0; }
.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--line); color: var(--dim); }
.badge.red { color: #ff8a9b; border-color: #6b2330; }
.badge.green { color: #6fe0a0; border-color: #245c3d; }
.badge.amber { color: #f3c763; border-color: #6b5420; }

/* ---------- Meldingen ---------- */
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #2b2e35; border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; }
.flashes { max-width: 1100px; margin: 14px auto 0; padding: 0 20px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--line); background: var(--panel); }
.flash.ok { border-color: #245c3d; background: #13261c; }
.flash.error { border-color: #6b2330; background: #2a1419; }
.flash.info { border-color: #6b5420; background: #2a2414; }

/* ---------- Inlog- en wizardkaarten ---------- */
main.auth { display: block; max-width: 460px; margin: 6vh auto; padding: 0 16px; }
main.auth.wide { max-width: 640px; }
.card h1 { font-size: 20px; }
.card .help { margin: 0 0 16px; }
.card form + form { margin-top: 10px; }
.card .actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.steps { display: flex; gap: 6px; margin: 0 0 18px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--panel2); }
.steps i.done { background: var(--red); }
.choice { display: grid; gap: 10px; }
.choice label { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; background: var(--panel2); }
.choice label:has(input:checked) { border-color: var(--red); background: #2a1a1e; }
.choice label.disabled { opacity: .5; cursor: not-allowed; }
.choice input { accent-color: var(--red); margin-top: 3px; }
.choice small { display: block; color: var(--dim); }
.qr { background: #fff; padding: 12px; border-radius: 8px; width: max-content; margin: 8px auto 12px; }
.qr svg, .qr img { display: block; width: 200px; height: 200px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; font: 600 16px ui-monospace, Consolas, monospace; background: var(--panel2); padding: 14px 18px; border-radius: 8px; margin: 10px 0 14px; }
input.code { font: 600 22px ui-monospace, Consolas, monospace; letter-spacing: .3em; text-align: center; }

/* ---------- Tabellen (beheer) ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
td .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--dim); background: var(--panel); }
.tabs a.on { color: var(--text); border-color: var(--red); }

/* ---------- Dashboard ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.chcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.chcard h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.chcard .meta { color: var(--dim); font-size: 12.5px; }

/* ---------- Regiepanelen ---------- */
.preview-wrap { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 14px; }
.preview-wrap.checker { background: repeating-conic-gradient(#2a2a2e 0 25%, #1e1e22 0 50%) 50% / 24px 24px; }
.preview-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; }
.preview-off { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--dim); }
.preview-off[hidden] { display: none; }
.status { display: flex; justify-content: space-between; gap: 10px; margin: 14px 0 6px; font-size: 13px; color: var(--dim); }
.status b { color: var(--text); font-weight: 600; }
.bar { height: 6px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: var(--red); transition: width .5s linear; }

.color { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--dim); }
.color input { width: 100%; height: 40px; padding: 2px; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.preset { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 13px; }
.preset .x { margin-left: 2px; padding: 0 4px; border-radius: 4px; color: var(--dim); }
.preset .x:hover { color: #fff; background: var(--red); }
.preset.armed { border-color: var(--red); }
.sw { display: flex; }
.sw i { width: 14px; height: 14px; display: block; border: 1px solid rgba(255,255,255,.25); }
.sw i:first-child { border-radius: 3px 0 0 3px; } .sw i:last-child { border-radius: 0 3px 3px 0; }
.orn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.orn-btn { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 10px 6px; font-size: 12px; white-space: normal; }
.orn-btn .ic { font-size: 22px; height: 22px; color: var(--red); display: flex; align-items: center; }
.orn-btn.sel, .opt.sel { border-color: var(--red); background: #2a1a1e; }
#orn-color-wrap.off { opacity: .4; pointer-events: none; }
.logo-box { display: flex; gap: 14px; align-items: center; }
.logo-thumb { width: 120px; height: 80px; background: #000; border: 1px dashed var(--line); border-radius: 7px; display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 12px; overflow: hidden; flex: none; }
.logo-thumb img { max-width: 100%; max-height: 100%; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Lowerthird-lijst ---------- */
.onair { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 9px; background: var(--panel2); border: 1px solid var(--line); }
.onair.live { border-color: var(--red); background: #2a1a1e; }
.onair .what { flex: 1; min-width: 0; }
.onair .what b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.onair .what small { color: var(--dim); }
.lt-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.lt-item { display: grid; grid-template-columns: 34px 54px minmax(0, 1fr) 118px auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel2); }
.lt-item.live { border-color: var(--red); background: #2a1a1e; }
.lt-item.live .num { background: var(--red); color: #fff; }
.lt-item .num { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--panel); color: var(--dim); font-weight: 700; font-size: 13px; }
.lt-item .go { padding: 8px 0; font-weight: 700; }
.lt-item .txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lt-item .txt input { padding: 5px 8px; }
.lt-item .txt input.t { font-weight: 600; }
.lt-item .media-name { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12.5px; min-width: 0; }
.lt-item .media-name img, .lt-item .media-name video { width: 64px; height: 36px; object-fit: contain; background: #000; border-radius: 4px; flex: none; }
.lt-item select { padding: 5px 6px; font-size: 12.5px; }
.lt-item .tools { display: flex; gap: 4px; }
.lt-item .tools button { padding: 5px 8px; }
@media (max-width: 700px) { .lt-item { grid-template-columns: 30px 50px 1fr; } .lt-item select, .lt-item .tools { grid-column: 2 / -1; } }
button.copy { min-width: 190px; }
button.copied { border-color: var(--green); color: #6fe0a0; }
table.triggers td { vertical-align: middle; }

/* ---------- Inklapbare modules ---------- */
h2.sec-toggle { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px; margin: -4px -6px 8px; padding: 4px 6px; border-radius: 6px; }
h2.sec-toggle:hover { background: var(--panel2); color: var(--text); }
h2.sec-toggle:focus-visible { outline: 2px solid var(--red); }
h2.sec-toggle::before { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
                        transform: rotate(45deg); transition: transform .2s; margin: 0 4px 3px 2px; flex: none; }
h2.sec-toggle .count { margin-left: auto; }
section.collapsed { padding-bottom: 12px; }
section.collapsed > h2.sec-toggle { margin-bottom: -4px; }
section.collapsed > h2.sec-toggle::before { transform: rotate(-45deg); margin-bottom: 0; }
section.collapsed > :not(h2.sec-toggle) { display: none !important; }
section:not(.collapsed) > :not(h2.sec-toggle) { animation: sec-open .2s ease; }
@keyframes sec-open { from { opacity: 0; transform: translateY(-4px); } }
.collapse-all { margin-left: auto; display: flex; gap: 6px; }

/* ---------- Waarschuwingen (TV-scherm weggevallen) ---------- */
#alerts { position: fixed; top: calc(64px + env(safe-area-inset-top, 0px)); right: 16px; z-index: 20; display: flex; flex-direction: column; gap: 8px; max-width: min(440px, calc(100vw - 32px)); }
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 8px 24px rgba(0,0,0,.45); animation: sec-open .2s ease; }
.alert span { flex: 1; }
.alert.red { border-color: var(--red); background: #3a1820; }
.alert.amber { border-color: #6b5420; background: #2a2414; }
.alert.ok { border-color: #245c3d; background: #13261c; }
.chcard.lost { border-color: var(--red); }
