:root {
  --bg: #f7f7f5; --panel: #ffffff; --text: #1d1d1b; --muted: #77776f; --line: #e4e4de;
  --accent: #2f5fd0; --accent-text: #ffffff; --ok: #1f7a3d; --warn: #9a6200; --bad: #b3261e;
  --ok-bg: #e7f4ec; --warn-bg: #fbf1dc; --bad-bg: #fbe7e5; --chip: #efefea;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514; --panel: #1e1e1c; --text: #e9e9e4; --muted: #96968d; --line: #31312e;
    --accent: #7ea2ff; --accent-text: #0f1320; --ok: #6fcf8d; --warn: #e4b35a; --bad: #ff8a80;
    --ok-bg: #1d3325; --warn-bg: #3a2f17; --bad-bg: #3d1f1c; --chip: #2a2a27;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 28px 0 10px; }
h3 { font-size: 14px; margin: 20px 0 8px; }
code { background: var(--chip); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
pre { white-space: pre-wrap; font: 12px/1.4 ui-monospace, monospace; margin: 6px 0; }

.layout { display: flex; min-height: 100vh; }
.side { width: 190px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px;
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.side .brand { font-weight: 700; padding: 4px 10px 14px; }
.side a { color: var(--text); padding: 6px 10px; border-radius: 6px; display: flex; justify-content: space-between; }
.side a:hover { background: var(--chip); text-decoration: none; }
.side a.on { background: var(--chip); font-weight: 600; }
.side .who { margin-top: auto; padding: 10px; color: var(--muted); display: flex; justify-content: space-between; }
main { flex: 1; padding: 24px 28px 60px; min-width: 0; }
.badge { background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 600; }

.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); } .bad-text { color: var(--bad); }
.dim { opacity: .55; }

.note { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.bad { background: var(--bad-bg); color: var(--bad); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 24px; align-items: start; }
.cols.wide-left { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.cols > section > h2:first-child { margin-top: 0; }
.narrow { max-width: 520px; }

table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.grid th, table.grid td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-weight: 600; color: var(--muted); font-size: 12px; background: var(--bg); }
table.grid tr:last-child td { border-bottom: 0; }
table.kv th { text-align: left; color: var(--muted); font-weight: normal; padding: 3px 14px 3px 0; vertical-align: top; }
table.kv td { padding: 3px 0; word-break: break-word; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 8px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; color: var(--text); display: flex; flex-direction: column; }
.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi b { font-size: 24px; }
.kpi span { color: var(--muted); font-size: 12px; }
.alerts { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.alerts li { padding: 8px 12px; border-radius: 8px; }
.alerts li.warn { background: var(--warn-bg); } .alerts li.warn a { color: var(--warn); }
.alerts li.bad { background: var(--bad-bg); } .alerts li.bad a { color: var(--bad); }

.st { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--chip); white-space: nowrap; }
.st-published, .st-approved, .st-success { background: var(--ok-bg); color: var(--ok); }
.st-scheduled, .st-queued, .st-approved_auto_only, .st-running, .st-waiting { background: var(--warn-bg); color: var(--warn); }
.st-failed, .st-rejected, .st-error, .st-crashed, .st-expired { background: var(--bad-bg); color: var(--bad); }
.st-awaiting_approval { background: var(--accent); color: var(--accent-text); }
.chip { display: inline-block; white-space: nowrap; background: var(--chip); color: var(--text); border-radius: 6px; padding: 0 6px; font-size: 12px; margin: 1px 0; }

label { display: block; margin: 0 0 10px; color: var(--muted); font-size: 12px; }
label.check { color: var(--text); font-size: 14px; display: flex; gap: 8px; align-items: center; }
label.check.inline { display: inline-flex; margin-right: 14px; }
.field { margin-bottom: 10px; }
.field > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
input, select, textarea { display: block; width: 100%; margin-top: 3px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg); color: var(--text); font: inherit; }
input[type=checkbox] { width: auto; margin: 0; display: inline; }
input[type=file] { padding: 5px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; padding: 8px 12px 2px; }
legend { padding: 0 4px; }
button, .button { display: inline-block; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font: inherit; cursor: pointer; }
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button.link.danger { color: var(--bad); }
button.toggle { border: 0; background: none; padding: 0 4px; font-size: 16px; }
button.toggle.on { color: var(--ok); } button.toggle.off { color: var(--muted); }
form.inline { display: inline; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.row { display: flex; gap: 8px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.row select { width: auto; flex: 1; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; margin: 0; }
.pager a, .pager b { margin-right: 6px; }
details.help { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
details.help summary { cursor: pointer; }
.danger-zone { border-color: var(--bad-bg); }

.clip { display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
.clip-media video { width: 100%; border-radius: 8px; background: #000; aspect-ratio: 9 / 16; }
.clip-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.issues { margin: 4px 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
video.tall { width: 100%; max-width: 320px; border-radius: 8px; background: #000; aspect-ratio: 9 / 16; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 16px; }
.tile video { width: 100%; border-radius: 8px; background: #000; aspect-ratio: 9 / 16; }
img.thumb { height: 32px; background: repeating-conic-gradient(var(--chip) 0 25%, transparent 0 50%) 50% / 12px 12px; border-radius: 4px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 340px; }
.login h1 { justify-content: center; }
.login button { width: 100%; margin-top: 6px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .side { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { width: 100%; padding-bottom: 4px; }
  .side .who { margin: 0 0 0 auto; }
  main { padding: 16px; }
  .cols, .cols.wide-left { grid-template-columns: 1fr; }
  .clip { grid-template-columns: 1fr; }
  .clip-media video { max-width: 260px; }
  table.grid { display: block; overflow-x: auto; }
}
::placeholder { color: var(--muted); opacity: .55; font-style: italic; }
