/* ---- brand tokens (verified against mozhem.ua, 2026-08-07) ---------------- */
:root {
  --bg: #ffffff;
  --surface: #fafafa;
  --text: #1c1c1c;
  --muted: #999999;
  --border: #dbdbdb;
  --accent: #4755f6;
  --accent-soft: #eceefe;
  --warn: #ffd700;
  --danger: #d94141;
  --ok: #2e9e5b;

  --radius-pill: 44px;
  --radius-card: 13px;
  --radius-sm: 8px;

  --shadow-card: 0 1px 2px rgba(28, 28, 28, .04), 0 8px 24px rgba(28, 28, 28, .05);
  --header-h: 68px;

  --font: 'e-Ukraine', system-ui, 'Segoe UI', Roboto, sans-serif;
}

/* e-Ukraine — Ukraine's free state typeface (Ministry of Digital Transformation),
   licensed CC BY 4.0. Self-hosted here (converted from the official OTF release to
   WOFF2) so the page never depends on a third-party CDN's uptime — the CSP forbids
   external font origins anyway. */
@font-face {
  font-family: 'e-Ukraine';
  src: url('../fonts/e-Ukraine-Regular.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'e-Ukraine';
  src: url('../fonts/e-Ukraine-Medium.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'e-Ukraine';
  src: url('../fonts/e-Ukraine-Bold.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- header -------------------------------------------------------------- */
.app-header {
  height: var(--header-h); display: flex; align-items: center; gap: 28px;
  padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 6px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { height: 22px; width: auto; display: block; color: var(--text); }
.brand-suffix { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: .04em; }
.app-nav { display: flex; gap: 4px; margin-left: 12px; }
.app-nav a {
  padding: 8px 16px; border-radius: var(--radius-pill); color: var(--text);
  font-size: 14px; font-weight: 500;
}
.app-nav a:hover { background: var(--surface); text-decoration: none; }
.app-nav a.active { background: var(--accent-soft); color: var(--accent); }
.app-user { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.app-username { font-size: 14px; color: var(--muted); }
.app-main { padding: 24px; }

/* ---- controls ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: var(--radius-pill); border: 1px solid transparent;
  font: inherit; font-weight: 500; font-size: 14px; cursor: pointer;
  background: var(--surface); color: var(--text); transition: background .15s, opacity .15s;
}
.btn:hover { background: #f0f0f0; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3945d8; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: transparent; border-color: var(--border); color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--muted);
}
.input, .select, textarea.input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
  font: inherit; font-size: 14px;
}
.input:focus, .select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.input { min-height: 110px; resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }

.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 18px; box-shadow: var(--shadow-card);
}

.badge {
  display: inline-block; padding: 2px 9px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500; background: var(--surface); color: var(--muted);
}
.badge-cost { background: var(--accent-soft); color: var(--accent); }
.badge-cost.est { background: #fdf6d6; color: #8a6d00; }
.badge-queued { background: var(--surface); }
.badge-processing { background: #fdf6d6; color: #8a6d00; }
.badge-completed { background: #e6f5ec; color: var(--ok); }
.badge-failed, .badge-cancelled { background: #fbeaea; color: var(--danger); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
  padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border);
}
.table th { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; }

.flashes { margin-bottom: 16px; }
.flash {
  padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 8px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--border);
}
.flash-error { background: #fbeaea; border-color: #f0cccc; color: var(--danger); }
.flash-success { background: #e6f5ec; border-color: #c6e6d3; color: var(--ok); }

/* ---- login --------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--surface);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--bg); padding: 36px 32px;
  border: 1px solid var(--border); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.login-logo { height: 26px; display: block; margin: 0 auto 22px; color: var(--text); }
.login-title { margin: 0 0 22px; font-size: 20px; font-weight: 500; text-align: center; }

/* ---- Seedance screen ----------------------------------------------------- */
.ws-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.ws-tab {
  padding: 10px 20px; border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
  font-weight: 500; cursor: pointer;
}
.ws-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.ws-body { display: flex; gap: 20px; align-items: flex-start; }
.ws-form {
  flex: 0 0 clamp(340px, 26vw, 400px); position: sticky; top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px); overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 18px; box-shadow: var(--shadow-card);
}
.ws-results {
  flex: 1; min-width: 0; min-height: 560px; padding: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.ws-results-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
  font-size: 13px; font-weight: 500; color: var(--muted);
}
.ws-slots { margin-left: auto; }

.job-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px; align-content: start;
}
.job-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-card); overflow: hidden;
}
/* Yellow means work in progress, accent means done — a six-tile grid then reads at a
   glance without anyone having to read the labels. */
.job-card.is-processing { border-color: var(--warn); box-shadow: 0 0 0 3px #fdf6d6; }
.job-card.is-completed { border-color: var(--accent); }
.job-card.is-failed, .job-card.is-cancelled { border-color: #f0cccc; }
.job-card video, .job-card img { width: 100%; display: block; background: #000; }
.job-card-body { padding: 10px 12px; display: flex; align-items: center; gap: 8px;
                 flex-wrap: wrap; font-size: 12px; color: var(--muted); }
/* cancel()'s billing warning (static/js/jobs.js) - on a product with no spending cap this
   is the one sentence that most needs to be seen, so it gets its own line and the danger
   colour rather than blending into the muted badge row. */
.job-grid-note { flex-basis: 100%; color: var(--danger); font-weight: 500; }

/* The empty state is a designed surface, not an absence. #ws-grid must contain NO
   whitespace in the template: :empty does not match an element holding a text node. */
.ws-empty { display: none; }
.job-grid:empty + .ws-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; min-height: 480px; padding: 32px; text-align: center;
  border: 1px dashed var(--border); border-radius: var(--radius-card);
  background: var(--bg);
}
.ws-empty-icon { font-size: 30px; opacity: .35; }
.ws-empty-title { font-size: 15px; font-weight: 500; color: var(--text); }
.ws-empty-hint { font-size: 13px; color: var(--muted); max-width: 320px; }

.ws-drop {
  border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 22px 14px;
  text-align: center; font-size: 13px; color: var(--muted); cursor: pointer;
  background: var(--surface);
}
.ws-drop.dragover, .ws-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.ws-drop-preview { max-height: 150px; border-radius: var(--radius-sm); }

.ws-cost { display: block; font-size: 12px; font-weight: 400; opacity: .9; }
.ws-row { display: flex; gap: 10px; }
.ws-row > * { flex: 1; }

@media (max-width: 900px) {
  .ws-body { flex-direction: column; }
  .ws-form { position: static; flex: 1 1 auto; width: 100%; max-height: none; }
  .app-header { gap: 14px; padding: 0 14px; }
  .app-nav { overflow-x: auto; }
}

/* ---- Історія ------------------------------------------------------------- */
.page-title { margin: 0 0 18px; font-size: 22px; font-weight: 500; }
.summary-card { margin-bottom: 16px; }
.summary-total { font-size: 15px; margin-bottom: 10px; }
.summary-list { list-style: none; margin: 0; padding: 0; display: grid;
                grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.summary-list li { display: flex; justify-content: space-between; gap: 12px;
                   font-size: 13px; color: var(--muted); padding: 6px 10px;
                   background: var(--surface); border-radius: var(--radius-sm); }
.history-filter { margin-bottom: 16px; max-width: 260px; }
.history-feed { display: grid; gap: 14px; }
.history-item { display: flex; gap: 18px; align-items: flex-start; }
.history-media { flex: 0 0 260px; }
.history-media video { width: 100%; border-radius: var(--radius-sm); background: #000;
                       display: block; }
.history-media-empty { height: 146px; display: flex; align-items: center;
                       justify-content: center; border: 1px dashed var(--border);
                       border-radius: var(--radius-sm); color: var(--muted);
                       font-size: 13px; background: var(--surface); }
.history-body { flex: 1; min-width: 0; }
.history-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
                margin-bottom: 10px; }
.history-date { font-size: 12px; color: var(--muted); margin-left: auto; }
.history-prompt { margin: 0 0 10px; font-size: 14px; overflow-wrap: anywhere; }
.history-error { margin: 0 0 10px; font-size: 13px; color: var(--danger); }
.history-actions { display: flex; gap: 8px; align-items: center; }
.history-actions form { margin: 0; }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 20px; }

@media (max-width: 720px) {
  .history-item { flex-direction: column; }
  .history-media { flex: 1 1 auto; width: 100%; }
}

/* ---- admin screens ------------------------------------------------------- */
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.input-sm { width: 150px; padding: 8px 11px; font-size: 13px; }
.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.settings-card { max-width: 620px; }
.settings-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
                margin-top: 8px; }
.checkline { display: flex; gap: 6px; align-items: center; font-size: 13px;
             color: var(--muted); }
.check-result { font-size: 13px; color: var(--muted); }
.check-result.ok { color: var(--ok); }
.check-result.bad { color: var(--danger); }
.field-hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.disk-figure { margin: 4px 0 0; font-size: 18px; font-weight: 500; }
