/* VOD Admin — Rhema Media */
:root {
  --ink: #172033;
  --ink-2: #26324a;
  --ink-text: #c9d1e0;
  --paper: #f3f5f8;
  --panel: #ffffff;
  --line: #dde2ea;
  --text: #1b2333;
  --muted: #5d6779;
  --signal: #1a6dd9;
  --signal-ink: #ffffff;
  --signal-soft: #e5effc;
  --ok: #1f7a5f;
  --ok-soft: #e2f3ed;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --bad: #b8351f;
  --bad-soft: #fbe6e2;
  --thumb: #d4d9e2;
  --radius-s: 4px;
  --radius-m: 8px;
  --font: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10151f;
    --panel: #171e2b;
    --line: #2a3446;
    --text: #e6eaf2;
    --muted: #97a1b3;
    --signal: #4b8ff0;
    --signal-soft: #1b2b45;
    --ok: #4cc29a; --ok-soft: #15302a;
    --warn: #e0a440; --warn-soft: #33270f;
    --bad: #f07a63; --bad-soft: #3a1c17;
    --thumb: #232c3c;
    --ink: #0b0f17;
    --ink-2: #1a2232;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
a { color: var(--signal); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
img { max-width: 100%; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--ink);
  color: var(--ink-text);
  padding: 20px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; }
.brand-mark {
  width: 30px; height: 22px; border-radius: 3px; background: var(--signal);
  position: relative; flex: none;
}
.brand-mark::after { /* play triangle */
  content: ""; position: absolute; left: 11px; top: 5px;
  border-left: 10px solid #fff; border-top: 6px solid transparent; border-bottom: 6px solid transparent;
}
.brand b { display: block; font-size: 1rem; font-weight: 600; }
.brand small { display: block; font-size: .78rem; color: var(--ink-text); opacity: .8; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side .group { font-size: .78rem; color: #8590a6; padding: 18px 10px 6px; }
.side a {
  color: var(--ink-text); padding: 8px 10px; border-radius: var(--radius-s);
  display: flex; justify-content: space-between; align-items: center;
}
.side a:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.side a[aria-current="page"] { background: var(--ink-2); color: #fff; box-shadow: inset 3px 0 0 var(--signal); }
.side .count { font-size: .78rem; opacity: .7; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--ink-2); font-size: .85rem; }
.side .me b { display: block; color: #fff; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .me form { margin-top: 8px; }
.side .me button { background: none; border: 0; color: var(--ink-text); padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
.role { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 10px; background: var(--ink-2); color: #fff; margin-top: 2px; }

.main { min-width: 0; }
.top {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 28px 36px 18px;
}
.top .sub { color: var(--muted); margin-top: 4px; }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 0 36px 48px; max-width: 1480px; }

/* ---------- elements */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel-pad { padding: 18px 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.stack > * + * { margin-top: 20px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  font: inherit; font-weight: 500; font-size: .92rem;
  padding: 8px 14px; border-radius: var(--radius-s); cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn-primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--signal); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

.flash { padding: 12px 16px; border-radius: var(--radius-s); margin-bottom: 20px; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--text); }
.flash.error { background: var(--bad-soft); border-color: var(--bad); color: var(--text); }

.pill { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.pill.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.pill.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.pill.info { background: var(--signal-soft); border-color: transparent; color: var(--signal); }

label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: 4px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=number], input[type=search], select {
  font: inherit; font-size: .92rem; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 10px; min-width: 0;
}
input:focus, select:focus { border-color: var(--signal); outline: none; box-shadow: 0 0 0 3px var(--signal-soft); }
.field { margin-bottom: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.filters input[type=search] { width: 240px; }
.filters .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--muted); font-size: .88rem; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a[aria-current="true"] { background: var(--signal-soft); color: var(--signal); font-weight: 500; }
.seg a:hover { text-decoration: none; color: var(--text); }

table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-weight: 500; color: var(--muted); font-size: .82rem; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; }
.table-wrap { overflow-x: auto; }

.pager { display: flex; gap: 4px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.pager a, .pager span { padding: 6px 11px; border-radius: var(--radius-s); font-size: .9rem; }
.pager a { border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.pager .pg-cur { background: var(--signal); color: #fff; }
.pager .pg-gap { color: var(--muted); }

.empty { text-align: center; padding: 56px 20px; }
.empty h2 { margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 46ch; margin: 0 auto 18px; }

/* ---------- library */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.figure { background: var(--panel); padding: 16px 18px; }
.figure b { display: block; font-size: 1.7rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.figure span { color: var(--muted); font-size: .88rem; }
.figure a { color: inherit; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 22px 18px; }
.tile { display: block; color: var(--text); min-width: 0; }
.tile:hover { text-decoration: none; }
.tile:hover .tile-title { color: var(--signal); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--thumb); border-radius: var(--radius-s); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(10, 14, 22, .82); color: #fff; font-size: .75rem; padding: 1px 6px; border-radius: 3px; }
.thumb .flag { position: absolute; left: 6px; top: 6px; }
.thumb.removed img { filter: grayscale(1); opacity: .45; }
.thumb .none { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
.tile-title { margin-top: 8px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-meta { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.mini { width: 96px; flex: none; }
.row-thumb { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-thumb .mini .thumb { border-radius: 3px; }

.detail { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.prose { white-space: pre-line; max-width: 72ch; }
details.raw summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
pre.code { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px; overflow: auto; font-size: .8rem; max-height: 480px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.order { list-style: none; margin: 0; padding: 0; }
.order li { display: grid; grid-template-columns: 40px 112px 1fr auto; gap: 14px; align-items: center; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.order li:last-child { border-bottom: 0; }
.order .pos { color: var(--muted); text-align: right; font-size: .9rem; }

/* ---------- sync phase track (the one distinctive element) */
.track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin: 4px 0 6px; }
.track .stage { position: relative; padding: 14px 12px 4px 0; }
.track .bar { height: 6px; background: var(--line); border-radius: 0; position: relative; overflow: hidden; }
.track .stage:first-child .bar { border-radius: 3px 0 0 3px; }
.track .stage:last-child .bar { border-radius: 0 3px 3px 0; }
.track .stage + .stage .bar { margin-left: -12px; }
.track .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--signal); transition: width .6s ease; }
.track .stage.done .fill { width: 100%; background: var(--ok); }
.track .name { font-weight: 500; font-size: .9rem; margin-top: 10px; }
.track .stat { color: var(--muted); font-size: .82rem; }
.track .stage.active .name { color: var(--signal); }
.track .stage.active .fill { animation: none; }
@media (prefers-reduced-motion: reduce) { .track .fill { transition: none; } }
.run-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.events { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; font-size: .9rem; }
.events li { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 7px 20px; border-bottom: 1px solid var(--line); }
.events time { color: var(--muted); font-size: .82rem; padding-top: 1px; }
.events .warning span { color: var(--warn); }
.events .error span { color: var(--bad); }
.events .success span { color: var(--ok); font-weight: 500; }

/* ---------- settings tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 22px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--signal); font-weight: 500; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.subtabs { margin-bottom: 18px; }
.check-ok { color: var(--ok); font-weight: 600; }
.check-bad { color: var(--warn); font-weight: 600; }
.log-entry summary { cursor: pointer; list-style: none; display: grid; grid-template-columns: 84px 76px 1fr; gap: 12px; padding: 8px 20px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.log-entry summary::-webkit-details-marker { display: none; }
.log-entry[open] summary { background: var(--paper); }
.log-entry .body { padding: 10px 20px 14px; border-bottom: 1px solid var(--line); }
.lvl-error, .lvl-critical { color: var(--bad); font-weight: 600; }
.lvl-warning { color: var(--warn); font-weight: 600; }
.lvl-info { color: var(--signal); }
.lvl-debug { color: var(--muted); }

/* ---------- login / standalone */
.solo { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.solo-card { background: var(--panel); border-radius: var(--radius-m); padding: 36px; width: 100%; max-width: 420px; }
.solo-card .brand { color: var(--text); padding: 0 0 26px; }
.solo-card .brand small { color: var(--muted); }
.solo-card h1 { font-size: 1.35rem; margin-bottom: 8px; }
.solo-card .btn { width: 100%; padding: 11px; margin-top: 10px; }
.ms-logo { display: inline-grid; grid-template-columns: 8px 8px; gap: 2px; }
.ms-logo i { width: 8px; height: 8px; display: block; }

@media (max-width: 900px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; }
  .brand { padding: 4px 8px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side .group { display: none; }
  .side .me { margin: 0 0 0 auto; border: 0; padding: 0 8px; }
  .top, .content { padding-left: 18px; padding-right: 18px; }
  .detail { grid-template-columns: 1fr; }
  .track { grid-template-columns: 1fr; }
  .track .stage + .stage .bar { margin-left: 0; }
  .order li { grid-template-columns: 32px 80px 1fr; }
  .order li > :last-child { grid-column: 3; }
  .filters input[type=search] { width: 100%; }
}
