:root {
  --bg: #0b0b0d; --panel: #16161a; --panel2: #1f1f25; --line: #2b2b33;
  --text: #f2f2f4; --muted: #9a9aa5; --ok: #34c77b; --warn: #f2b33d; --err: #ff5d5d;
  --accent: linear-gradient(90deg, #f9a23c, #f03e8a, #8b3ff0);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px 48px; }

header.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
header.top .brand { font-weight: 800; letter-spacing: .3px; text-decoration: none; font-size: 17px; }
header.top .brand span { background: var(--accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
header.top nav { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
header.top nav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); }
header.top nav a.active, header.top nav a:hover { background: var(--panel2); color: var(--text); }
header.top form { margin: 0; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: #f03e8a; color: #fff; font-size: 12px; font-weight: 700; text-align: center; }

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

input[type=text], input[type=url], input[type=password], textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font: inherit; }
textarea { resize: vertical; min-height: 96px; }
input:focus, textarea:focus { outline: 2px solid #8b3ff0; border-color: transparent; }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
label.check input { width: 18px; height: 18px; accent-color: #f03e8a; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; }

button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
button:hover, .btn:hover { border-color: #555; }
button.primary { background: var(--accent); border: 0; color: #fff; }
button.ok { background: var(--ok); border: 0; color: #06210f; }
button.danger { background: transparent; border-color: var(--err); color: var(--err); }
button.danger.confirm { background: var(--err); color: #fff; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 6px 10px; color: var(--muted); font-weight: 400; }

.submit-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.submit-row button { flex: 0 0 auto; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-decoration: none; display: block; }
.stat .n { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #444; margin-right: 6px; vertical-align: middle; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 0 rgba(52,199,123,.7); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(52,199,123,0); } 100% { box-shadow: 0 0 0 0 rgba(52,199,123,0); } }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { border-color: var(--ok); color: var(--ok); background: rgba(52,199,123,.08); }
.flash.error { border-color: var(--err); color: var(--err); background: rgba(255,93,93,.08); }
.warn { color: var(--warn); }
.err { color: var(--err); }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 14px; align-items: center; padding: 12px 14px; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.item:hover { border-color: #444; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .meta { color: var(--muted); font-size: 13px; }
.item .age { font-weight: 700; white-space: nowrap; }
.item .age.old { color: var(--warn); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--panel2); color: var(--muted); white-space: nowrap; }
.pill.done { color: var(--ok); } .pill.failed { color: var(--err); }
.pill.awaiting_validation { color: #f9a23c; } .pill.deleted { opacity: .6; }
.pill.queued, .pill.downloading, .pill.analyzing, .pill.rendering { color: #9fb6ff; }

.job { display: grid; grid-template-columns: minmax(0, 380px) 1fr; gap: 24px; align-items: start; }
.preview { position: relative; width: 100%; aspect-ratio: 1080 / 1920; background: #000;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--line); cursor: pointer; }
.preview video { position: absolute; object-fit: fill; background: #000; }
.preview img.frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.preview .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center; color: var(--muted); }
.preview-tools { display: flex; gap: 8px; margin-top: 8px; }
.fit { min-height: 22px; font-size: 13px; margin-top: 6px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-weight: 600; background: var(--panel); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.msg { max-width: 460px; }
tr.error td { color: var(--err); } tr.warning td { color: var(--warn); }

.login { max-width: 360px; margin: 12vh auto 0; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .job { grid-template-columns: 1fr; }
  .preview { max-width: 360px; margin: 0 auto; }
  .actions button { flex: 1 1 auto; }
}
