/* Контент завод — dark admin theme. No frameworks, no CDN. */
:root {
  --bg: #0f1115;
  --card: #1a1e26;
  --card-2: #212734;
  --line: #2b3240;
  --text: #e7ebf2;
  --muted: #8b95a7;
  --accent: #4f8cff;
  --success: #3ddc84;
  --danger: #ff5d5d;
  --warn: #ffb648;
  --radius: 12px;
  --sidebar: 224px;
}

* { box-sizing: border-box; }

/* Author display rules (.btn, .table tr…) would otherwise beat the UA sheet. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

body.centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---- sidebar ---- */
.sidebar { position: fixed; z-index: 10; top: 0; left: 0; bottom: 0; width: var(--sidebar);
  display: flex; flex-direction: column; gap: 18px; padding: 16px 12px;
  background: var(--card); border-right: 1px solid var(--line); overflow-y: auto; }
.brand { font-weight: 700; color: var(--text); font-size: 16px; padding: 4px 10px; }
.nav { display: flex; flex-direction: column; gap: 16px; flex: 1; min-height: 0; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-title { color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; padding: 0 10px 4px; }
.nav-link { display: block; color: var(--muted); padding: 7px 10px; border-radius: 8px; font-size: 14px; }
.nav-link:hover { background: var(--card-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--card-2); color: var(--text); }
/* A page that does not exist yet: no link, no hover, just the «скоро» mark. */
.nav-soon { cursor: default; opacity: .6; }
.nav-soon:hover { background: none; color: var(--muted); }
.nav-mark { font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 20px; padding: 1px 6px; margin-left: 4px; }
.userbox { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 1px solid var(--line); padding-top: 12px; }
.username { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }

.page { margin-left: var(--sidebar); padding-top: 24px; padding-bottom: 32px; }

/* ---- surfaces ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.page-title { margin-bottom: 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .page-title { margin: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { margin: 0; }
.stat-value { font-size: 32px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 6px; }
.tone-accent { color: var(--accent); }
.tone-success { color: var(--success); }
.tone-muted { color: var(--text); }
.tone-danger { color: var(--danger); }

.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.flash-ok { background: rgba(61, 220, 132, .12); color: var(--success); border: 1px solid rgba(61, 220, 132, .3); }
.flash-err { background: rgba(255, 93, 93, .12); color: var(--danger); border: 1px solid rgba(255, 93, 93, .3); }

/* ---- controls ---- */
.btn { display: inline-block; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  border-radius: 9px; padding: 9px 15px; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #07112a; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-danger { color: var(--danger); border-color: rgba(255, 93, 93, .4); background: rgba(255, 93, 93, .1); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
input[type=text], input[type=password], input[type=file], input[type=number],
input[type=date], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 9px 11px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; color: var(--text); font: inherit;
}
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=range] { display: block; width: 100%; margin-top: 8px; accent-color: var(--accent); }

.login-card { width: 340px; max-width: 100%; margin: 0; }
.row-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin: 16px 0; }
.row-form label { flex: 1 1 200px; margin-bottom: 0; }
.row-form .btn { margin-bottom: 1px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr.job-row:hover, .table tbody tr:hover { background: var(--card-2); }
.table form { display: inline; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; white-space: nowrap;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line); }
.badge-queued { color: var(--muted); }
.badge-downloading, .badge-preparing, .badge-transcribing { color: var(--warn); border-color: rgba(255, 182, 72, .35); }
.badge-awaiting_plan { color: var(--accent); border-color: rgba(79, 140, 255, .4); }
.badge-rendering { color: var(--accent); border-color: rgba(79, 140, 255, .4); }
.badge-done { color: var(--success); border-color: rgba(61, 220, 132, .35); }
.badge-failed { color: var(--danger); border-color: rgba(255, 93, 93, .4); }
.badge-canceled { color: var(--muted); }

/* ---- queue: progress bar under the status badge ---- */
.job-progress { display: block; max-width: 220px; margin-top: 7px; }
.job-progress-track { display: block; height: 5px; border-radius: 4px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--line); }
.job-progress-fill { display: block; height: 100%; width: 0; background: var(--accent);
  transition: width .6s ease; }
/* awaiting_plan is frozen: the wait is on a human, not on the pipeline. */
.job-progress-frozen .job-progress-fill { background: var(--warn); }
.job-progress-text { display: block; margin-top: 4px; }

.table-queue td:nth-child(3) { max-width: 260px; }
.table-queue td:nth-child(6), .table-queue td:nth-child(7) { white-space: nowrap; }
.nowrap { white-space: nowrap; }
.job-details > td { background: var(--card-2); }
.job-details:hover > td { background: var(--card-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.plan-form { max-width: 720px; margin-bottom: 16px; }
.events h3 { color: var(--muted); font-weight: 500; }
.event-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.event { display: flex; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.event span:last-child { white-space: pre-wrap; word-break: break-word; }
.event-error span:last-child { color: var(--danger); }
.event-warn span:last-child { color: var(--warn); }

/* ---- bank ---- */
.bank-counts { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.bank-count { background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; display: flex; gap: 10px; align-items: baseline; }
.bank-count.empty { border-color: rgba(255, 93, 93, .4); }
.bank-count-label { font-size: 13px; color: var(--muted); }
.bank-count-value { font-weight: 700; }

/* ---- library grid ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.clip { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.clip-poster { position: relative; aspect-ratio: 9 / 16; background: #0b0d11; display: flex; align-items: center; justify-content: center; }
/* Shown through when there is no poster (or it failed to load). */
.clip-poster::before { content: "без обложки"; color: var(--muted); font-size: 12px; }
.clip-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-duration { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .7);
  border-radius: 6px; padding: 2px 7px; font-size: 12px; }
.clip-flag { position: absolute; left: 8px; top: 8px; background: rgba(61, 220, 132, .18);
  color: var(--success); border-radius: 6px; padding: 2px 7px; font-size: 12px; }
.clip-new { position: absolute; right: 8px; top: 8px; z-index: 1; background: var(--accent);
  color: #07112a; border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; }
.clip-body { padding: 12px; }
.clip-title { font-size: 14px; }
.clip-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
/* Мини-превью заглушки: сама картинка вертикальная, места занимает немного. */
.clip-cover { display: flex; align-items: center; gap: 8px; margin-top: 8px;
  text-decoration: none; }
.clip-cover img { width: 34px; height: 60px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); background: #0b0d11; display: block; }
.clip-score { display: inline-block; margin-bottom: 8px; padding: 2px 8px; border-radius: 20px;
  font-size: 12px; color: var(--warn); background: rgba(255, 182, 72, .12);
  border: 1px solid rgba(255, 182, 72, .35); cursor: help; }

/* Poster doubles as the play button. */
.clip-playable { cursor: pointer; }
.clip-playable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.clip-play { position: absolute; z-index: 1; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0, 0, 0, .6); border: 1px solid rgba(231, 235, 242, .5); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 15px; padding-left: 3px; }
.clip-playable:hover .clip-play { background: var(--accent); color: #07112a; border-color: var(--accent); }

/* ---- video player modal ---- */
.modal-player { width: 480px; }
.player-body { padding: 0; background: #000; }
.modal-player video { display: block; width: 100%; max-height: calc(100vh - 160px);
  background: #000; }

/* ---- wizard modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5, 7, 10, .7); z-index: 20; }
.modal { position: fixed; z-index: 21; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 560px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px); overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-top: 1px solid var(--line); }
.wizard-progress { color: var(--muted); font-size: 13px; }
.options { display: grid; gap: 10px; }
.option { text-align: left; width: 100%; padding: 13px 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text); font: inherit; cursor: pointer; }
.option:hover { border-color: var(--accent); }
.option[disabled] { opacity: .45; cursor: not-allowed; }
.option[disabled]:hover { border-color: var(--line); }
.option .option-note { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.option .option-warn { color: var(--danger); }

/* ---- wizard: how many clips ---- */
.cut-modes { display: grid; gap: 10px; }
.cut-option { display: flex; gap: 10px; align-items: flex-start; margin: 0;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card-2); color: var(--text); font-size: 15px; cursor: pointer; }
.cut-option:hover { border-color: var(--accent); }
.cut-option input[type=radio] { margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.cut-option-title { display: block; }
.cut-option-note { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.cut-sub { display: grid; gap: 8px; margin-left: 18px; padding-left: 14px;
  border-left: 1px solid var(--line); }
.cut-count { margin-left: 30px; max-width: 200px; }
.cut-count label { margin-bottom: 0; }

/* ---- wizard: clip length, video params, source ---- */
.step-subtitle { margin: 20px 0 10px; color: var(--muted); font-weight: 500; }
.len-range { display: flex; gap: 12px; margin-left: 18px; padding-left: 14px;
  border-left: 1px solid var(--line); }
.len-range label { flex: 1 1 0; margin-bottom: 0; max-width: 160px; }
.source-sub { margin-left: 18px; padding-left: 14px; border-left: 1px solid var(--line); }
.source-sub label { margin-bottom: 0; }

.wizard-badge { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 16px; padding: 8px 12px; font-size: 13px; border-radius: 10px;
  color: var(--accent); background: rgba(79, 140, 255, .12);
  border: 1px solid rgba(79, 140, 255, .4); }

/* ---- upload progress ---- */
.progress { margin-top: 16px; }
.progress-bar { height: 8px; border-radius: 6px; overflow: hidden;
  background: var(--card-2); border: 1px solid var(--line); margin-bottom: 6px; }
.progress-fill { display: block; height: 100%; width: 0; background: var(--accent);
  transition: width .2s linear; }

/* ---- forms: per-field hints ---- */
.field-note { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.field-error { display: block; color: var(--danger); font-size: 12px; margin-top: 5px; }
.field-error[hidden] { display: none; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.filter-card { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 6px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; position: relative; }
.filter-card:hover { border-color: var(--accent); }
.filter-card input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.filter-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.filter-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-card img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 6px; display: block; }
.filter-card-title { font-weight: 500; }
.filter-card-note { color: var(--muted); font-size: 11px; line-height: 1.3; }
.modal-narrow { width: 420px; }

/* ---- toasts: finished jobs, top centre, stacked ---- */
.toasts { position: fixed; z-index: 30; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px; width: 440px; max-width: calc(100vw - 32px);
  pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; pointer-events: auto;
  padding: 11px 12px 11px 14px; border-radius: 10px; font-size: 14px; line-height: 1.4;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(3, 5, 9, .55); animation: toast-in .18s ease-out; }
.toast-ok { border-color: rgba(61, 220, 132, .45); }
.toast-err { border-color: rgba(255, 93, 93, .45); }
.toast-body { flex: 1; min-width: 0; color: var(--text); }
.toast-body:hover { color: var(--accent); text-decoration: none; }
.toast-close { flex: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 18px; line-height: 1; padding: 0 2px; cursor: pointer; }
.toast-close:hover { color: var(--text); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* ---- misc ---- */
.error-card { text-align: center; padding: 48px 20px; }
.error-code { font-size: 46px; font-weight: 700; color: var(--accent); }
.placeholder { border-style: dashed; }

/* Narrow screens: the sidebar unsticks and becomes a plain top panel, the nav
   groups sit in one wrapping row and their titles disappear. */
@media (max-width: 760px) {
  .sidebar { position: static; width: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 10px; padding: 10px 16px;
    border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; flex: 1 1 100%; }
  .nav-group { flex-direction: row; flex-wrap: wrap; }
  .nav-group-title { display: none; }
  .userbox { border-top: 0; padding-top: 0; margin-left: auto; }
  .page { margin-left: 0; padding-top: 20px; }
}

@media (max-width: 720px) {
  .stat-value { font-size: 26px; }
  .row-form label { flex-basis: 100%; }
}
