/* ============================================================================
   trans-coded — design system

   Theming: every colour below is a token. The dark palette is the default (it
   also lives under [data-theme="dark"] so an explicit choice round-trips), and
   the alternate themes only re-declare the token block. Nothing outside the
   theme blocks may hardcode a colour — add a token instead, or the new theme
   will look right in three places and wrong in the fourth.

   Token groups per theme:
     surfaces  bg / bg-2 / panel / panel-{2,3} / border / border-{2,3}
     ink       text / text-2 / muted / on-accent
     status    <name> (fill), <name>-ink (readable text), <name>-soft
               (background tint), <name>-line (border tint)
     chrome    topbar-bg / glow-{1,2} / nav-active-* / shadow / ring / scrim
     shape     radius / radius-sm

   There is a fourth theme, "custom": no block here declares it, so it inherits
   the dark tokens and is otherwise whatever CSS the visitor writes in the
   in-app editor (Theme ▸ Custom…). The starter text they get lives in
   `static/custom-theme-template.css` unless the operator overrides it with
   CUSTOM_THEME_CSS / CUSTOM_THEME_CSS_FILE.
   ========================================================================== */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  /* surfaces */
  --bg:        #0b0d12;
  --bg-2:      #0e1117;
  --panel:     #141821;
  --panel-2:   #1b202b;
  --panel-3:   #232a37;
  --border:    #262d3a;
  --border-2:  #303947;
  --border-3:  #3c4658;

  /* ink */
  --text:      #eef1f6;
  --text-2:    #b7c0d0;
  --muted:     #7d8798;
  --on-accent: #06122a;

  /* brand + status (validated categorical / status palette) */
  --accent:       #3987e5;
  --accent-2:     #5b9ef0;
  --accent-ink:   #7db2f6;
  --accent-hover: #9cc6f9;
  --accent-soft:  rgba(57,135,229,.14);
  --accent-line:  rgba(57,135,229,.40);

  --success:      #199e70;
  --success-ink:  #4bd3a0;
  --success-soft: rgba(25,158,112,.14);
  --success-line: rgba(25,158,112,.40);

  --warn:         #c98500;
  --warn-ink:     #f0c063;
  --warn-soft:    rgba(201,133,0,.13);
  --warn-line:    rgba(201,133,0,.42);

  --danger:       #e05656;
  --danger-ink:   #ff9b9b;
  --danger-soft:  rgba(224,86,86,.12);
  --danger-soft-2:rgba(224,86,86,.20);
  --danger-line:  rgba(224,86,86,.42);

  --violet:       #9085e9;
  --violet-ink:   #b9b2ff;
  --violet-soft:  rgba(144,133,233,.14);
  --violet-line:  rgba(144,133,233,.40);

  /* chrome */
  --topbar-bg:       rgba(14,17,23,.72);
  --glow-1:          rgba(57,135,229,.10);
  --glow-2:          rgba(144,133,233,.08);
  --nav-active-bg:   rgba(57,135,229,.14);
  --nav-active-ink:  #cfe0fb;
  --nav-active-line: rgba(57,135,229,.35);
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --ring:      0 0 0 3px rgba(57,135,229,.28);
  --logo-glow: 0 4px 14px -4px rgba(57,135,229,.6);
  --scrim:     rgba(4,6,12,.58);

  --radius:    14px;
  --radius-sm: 9px;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg:        #f3f5f9;
  --bg-2:      #ffffff;
  --panel:     #ffffff;
  --panel-2:   #eef1f7;
  --panel-3:   #e2e7f0;
  --border:    #dde3ec;
  --border-2:  #c8d1de;
  --border-3:  #a6b2c4;

  --text:      #121722;
  --text-2:    #41506a;
  --muted:     #69758a;
  --on-accent: #ffffff;

  --accent:       #1f6fd0;
  --accent-2:     #3987e5;
  --accent-ink:   #155ab0;
  --accent-hover: #0f4a95;
  --accent-soft:  rgba(31,111,208,.11);
  --accent-line:  rgba(31,111,208,.32);

  --success:      #12805b;
  --success-ink:  #0d6b4b;
  --success-soft: rgba(18,128,91,.12);
  --success-line: rgba(18,128,91,.32);

  --warn:         #a86e00;
  --warn-ink:     #855700;
  --warn-soft:    rgba(168,110,0,.12);
  --warn-line:    rgba(168,110,0,.34);

  --danger:       #cf3d3d;
  --danger-ink:   #b02a2a;
  --danger-soft:  rgba(207,61,61,.10);
  --danger-soft-2:rgba(207,61,61,.18);
  --danger-line:  rgba(207,61,61,.34);

  --violet:       #6a5ed3;
  --violet-ink:   #544ab5;
  --violet-soft:  rgba(106,94,211,.12);
  --violet-line:  rgba(106,94,211,.32);

  --topbar-bg:       rgba(255,255,255,.80);
  --glow-1:          rgba(57,135,229,.12);
  --glow-2:          rgba(106,94,211,.09);
  --nav-active-bg:   rgba(31,111,208,.12);
  --nav-active-ink:  #12508f;
  --nav-active-line: rgba(31,111,208,.30);
  --shadow:    0 1px 2px rgba(16,24,40,.06), 0 10px 26px -14px rgba(16,24,40,.28);
  --ring:      0 0 0 3px rgba(31,111,208,.25);
  --logo-glow: 0 4px 14px -6px rgba(31,111,208,.55);
  --scrim:     rgba(24,32,48,.34);
}

/* Trans pride: aubergine surfaces (deliberately warmer than the blue-grey dark
   theme, so the two never read as the same skin), #5BCEFA as the accent and
   #F5A9B8 in the violet slot, so the brand mark and every accent→violet
   gradient reads as the flag.

   This theme also declares a --flag-* group: the flag as reusable gradients,
   consumed by the flourish rules below. Those are the only extra tokens any
   theme adds; everything else resolves to the shared token names. */
:root[data-theme="trans"] {
  color-scheme: dark;

  --bg:        #100c1c;
  --bg-2:      #151024;
  --panel:     #1a1430;
  --panel-2:   #241c40;
  --panel-3:   #2f2552;
  --border:    #332a56;
  --border-2:  #453a72;
  --border-3:  #5b4d92;

  --text:      #f6f0fa;
  --text-2:    #cdc2e0;
  --muted:     #9689b3;
  --on-accent: #06202e;

  --accent:       #5bcefa;
  --accent-2:     #8adfff;
  --accent-ink:   #8fdcfb;
  --accent-hover: #b6ecff;
  --accent-soft:  rgba(91,206,250,.15);
  --accent-line:  rgba(91,206,250,.42);

  --success:      #26a97b;
  --success-ink:  #58d9aa;
  --success-soft: rgba(38,169,123,.15);
  --success-line: rgba(38,169,123,.42);

  --warn:         #d79a12;
  --warn-ink:     #f6cb70;
  --warn-soft:    rgba(215,154,18,.14);
  --warn-line:    rgba(215,154,18,.44);

  /* Kept redder than --violet so "failed" never reads as flag pink. */
  --danger:       #e0475c;
  --danger-ink:   #ff8f9c;
  --danger-soft:  rgba(224,71,92,.14);
  --danger-soft-2:rgba(224,71,92,.24);
  --danger-line:  rgba(224,71,92,.44);

  --violet:       #f5a9b8;
  --violet-ink:   #ffc4d0;
  --violet-soft:  rgba(245,169,184,.15);
  --violet-line:  rgba(245,169,184,.42);

  --topbar-bg:       rgba(16,12,28,.74);
  --glow-1:          rgba(91,206,250,.16);
  --glow-2:          rgba(245,169,184,.13);
  --nav-active-bg:   linear-gradient(90deg, rgba(91,206,250,.20), rgba(245,169,184,.18));
  --nav-active-ink:  #e4f3ff;
  --nav-active-line: rgba(245,169,184,.34);
  --shadow:    0 1px 2px rgba(8,4,18,.55), 0 10px 26px -12px rgba(22,6,44,.75);
  --ring:      0 0 0 3px rgba(91,206,250,.32);
  --logo-glow: 0 4px 16px -4px rgba(245,169,184,.6);
  --scrim:     rgba(10,4,22,.6);

  /* Flag gradients. -bands is the literal flag (hard stops), -edge fades out at
     both ends so it can sit on a rounded edge, -diag is the brand mark, -ribbon
     tiles at a fixed width so it stays legible at any element width. */
  --flag-bands: linear-gradient(90deg,
    #5bcefa 0 20%, #f5a9b8 20% 40%, #ffffff 40% 60%, #f5a9b8 60% 80%, #5bcefa 80% 100%);
  --flag-edge: linear-gradient(90deg,
    rgba(91,206,250,0), #5bcefa 12%, #f5a9b8 33%, #ffffff 50%, #f5a9b8 67%, #5bcefa 88%, rgba(91,206,250,0));
  --flag-diag: linear-gradient(150deg, #5bcefa 0 32%, #ffffff 46% 54%, #f5a9b8 68% 100%);
  --flag-ribbon: linear-gradient(90deg,
    #5bcefa 0 18%, #f5a9b8 30% 42%, #ffffff 47% 53%, #f5a9b8 58% 70%, #5bcefa 82% 100%);
  --flag-glow: 0 2px 16px -3px rgba(245,169,184,.42);
  --select-bg: rgba(245,169,184,.30);
}

/* ---- Trans theme flourishes -----------------------------------------------
   The flag as structure rather than as a recolour: a lit edge under the top
   bar, a fading flag hairline on every card, a pink wash in the stat tiles,
   and flag ribbons in the progress bars. Colour only ever comes from the
   tokens above. */

/* The flag itself, as the topbar's bottom edge. */
:root[data-theme="trans"] .topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 3px;
  background: var(--flag-bands);
  box-shadow: var(--flag-glow);
}

/* Hairline along the top of every card (the login form included) — the
   transparent ends of --flag-edge keep it off the rounded corners. */
:root[data-theme="trans"] .card {
  background:
    var(--flag-edge) top center / 100% 2px no-repeat,
    linear-gradient(180deg, var(--panel), var(--bg-2));
}

/* Stat tiles get the pink corner instead, so cards and tiles stay distinct. */
:root[data-theme="trans"] .stat {
  background:
    radial-gradient(130px 100px at 100% 0, var(--violet-soft), transparent 70%),
    linear-gradient(180deg, var(--panel), var(--bg-2));
}

/* Fixed-width ribbon: a 5% progress bar shows blue, not a squashed flag. */
:root[data-theme="trans"] .progressbar .fill {
  background: var(--flag-ribbon) 0 0 / 150px 100% repeat-x;
}
:root[data-theme="trans"] .progressbar .fill.indeterminate {
  background: linear-gradient(90deg, transparent, var(--accent), var(--violet), transparent);
}

/* Brand mark: flag on the diagonal, dark glyph so the white band stays legible. */
:root[data-theme="trans"] .brand .logo {
  background: var(--flag-diag);
  color: var(--on-accent);
}

:root[data-theme="trans"] button.primary,
:root[data-theme="trans"] .primary {
  background: linear-gradient(105deg, var(--accent-2) 0%, var(--accent) 48%, var(--violet) 125%);
  box-shadow: 0 6px 18px -8px var(--violet-line);
}

:root[data-theme="trans"] ::selection { background: var(--select-bg); color: var(--text); }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  line-height: 1.55;
  background:
    radial-gradient(1200px 600px at 78% -8%, var(--glow-1), transparent 60%),
    radial-gradient(900px 500px at 8% 0%, var(--glow-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { color: var(--accent-hover); }

code {
  background: var(--panel-2); padding: .1em .4em; border-radius: 6px;
  font-size: .88em; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  border: 1px solid var(--border);
}

h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 .35rem; }
h2 { font-size: 1.02rem; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h3 { font-size: .9rem; font-weight: 600; margin: 0; }

.muted { color: var(--muted); }
.center { text-align: center; }

/* ----------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem clamp(1rem, 4vw, 2rem);
  background: var(--topbar-bg);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 750; font-size: 1.08rem; letter-spacing: -.02em; color: var(--text);
}
.brand .logo {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff; font-size: .8rem; box-shadow: var(--logo-glow);
}
.topbar nav { display: flex; align-items: center; gap: .3rem; }
.topbar nav a {
  padding: .45rem .8rem; border-radius: 999px; color: var(--text-2);
  font-size: .9rem; font-weight: 550; transition: background .15s, color .15s;
}
.topbar nav a:hover { background: var(--panel-2); color: var(--text); }
.topbar nav a.active {
  background: var(--nav-active-bg); color: var(--nav-active-ink);
  box-shadow: inset 0 0 0 1px var(--nav-active-line);
}

/* ----------------------------------------------------------------------------
   Theme menu
   -------------------------------------------------------------------------- */
.theme-menu { position: relative; }
.theme-menu > .theme-toggle {
  padding: .45rem .8rem; border-radius: 999px; color: var(--text-2);
  background: none; border: 1px solid transparent;
  font-size: .9rem; font-weight: 550;
}
.theme-menu > .theme-toggle:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
.theme-menu.open > .theme-toggle { background: var(--panel-2); color: var(--text); }

.theme-list {
  position: absolute; right: 0; top: calc(100% + .5rem); z-index: 40;
  display: none; flex-direction: column; gap: .1rem; min-width: 170px;
  padding: .35rem; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--border-2); box-shadow: var(--shadow);
}
.theme-menu.open .theme-list { display: flex; }
.theme-list button {
  width: 100%; justify-content: flex-start; gap: .6rem;
  background: none; border: 0; border-radius: 7px;
  padding: .42rem .55rem; font-size: .86rem; font-weight: 550; color: var(--text-2);
}
.theme-list button:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
.theme-list button[aria-checked="true"] { color: var(--text); }
.theme-list button[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--accent-ink); }

.theme-swatch {
  width: 15px; height: 15px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--border-3);
}
.theme-swatch.dark  { background: linear-gradient(135deg, #3987e5 50%, #141821 50%); }
.theme-swatch.light { background: linear-gradient(135deg, #3987e5 50%, #ffffff 50%); }
.theme-swatch.trans {
  background: linear-gradient(180deg,
    #5bcefa 0 20%, #f5a9b8 20% 40%, #ffffff 40% 60%, #f5a9b8 60% 80%, #5bcefa 80% 100%);
}
.theme-swatch.custom {
  background: conic-gradient(#3987e5, #9085e9, #e05656, #c98500, #199e70, #3987e5);
}

/* ----------------------------------------------------------------------------
   Custom theme editor
   -------------------------------------------------------------------------- */
.css-editor {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  background: var(--scrim);
  backdrop-filter: blur(3px);
}
.css-editor[hidden] { display: none; }
.css-editor-panel {
  display: flex; flex-direction: column; gap: .9rem;
  width: min(820px, 100%); max-height: min(78vh, 720px);
  padding: 1.15rem 1.25rem;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border-2); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.css-editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.css-editor-head p { margin: .15rem 0 0; font-size: .82rem; }
.css-editor textarea {
  flex: 1; min-height: 320px; resize: vertical; width: 100%;
  padding: .8rem .9rem; tab-size: 2;
  background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  color: var(--text); font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .82rem; line-height: 1.55; white-space: pre;
}
.css-editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.css-editor-actions { display: flex; gap: .55rem; }

/* ----------------------------------------------------------------------------
   Bulk-queue settings dialog
   -------------------------------------------------------------------------- */
.queue-dialog {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  background: var(--scrim);
  backdrop-filter: blur(3px);
}
.queue-dialog[hidden] { display: none; }
.queue-panel {
  display: flex; flex-direction: column;
  width: min(620px, 100%); max-height: min(84vh, 860px);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border-2); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.queue-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.15rem 1.25rem .9rem;
  border-bottom: 1px solid var(--border);
}
.queue-head p { margin: .15rem 0 0; font-size: .82rem; }
.queue-body {
  display: flex; flex-direction: column; gap: .3rem;
  overflow-y: auto; padding: .35rem 1.25rem 1rem;
}
.queue-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .9rem 1.25rem 1.05rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
}
.queue-actions { display: flex; gap: .55rem; }

.queue-field { border: 0; margin: 0; padding: .95rem 0 .3rem; border-bottom: 1px solid var(--border); }
.queue-body .queue-field:last-of-type { border-bottom: 0; }
.queue-field > legend {
  display: flex; align-items: center; gap: .4rem;
  padding: 0; margin-bottom: .5rem;
  font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}
/* Options a choice elsewhere has made irrelevant stay readable but recede. */
.queue-field.is-disabled, .lang-picker.is-disabled { opacity: .45; }

.queue-field .opt {
  display: flex; align-items: flex-start; gap: .55rem;
  padding: .3rem 0; cursor: pointer; font-size: .87rem;
}
.queue-field .opt input { margin-top: .28rem; accent-color: var(--accent); }
.queue-field .opt span { display: flex; flex-direction: column; gap: .1rem; }
.queue-field .opt strong { font-weight: 600; }
.hint { margin: .2rem 0 0; font-size: .78rem; font-style: normal; color: var(--muted); line-height: 1.45; }

.quality-row { display: flex; align-items: center; gap: .85rem; }
.quality-row input[type="range"] { flex: 1; padding: 0; background: none; border: 0; accent-color: var(--accent); }
.quality-readout {
  min-width: 2.6rem; text-align: center;
  padding: .25rem .5rem; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--border-2);
  font-variant-numeric: tabular-nums; font-weight: 650; font-size: .9rem;
}

.lang-picker { padding: .35rem 0 .2rem 1.5rem; }
.lang-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .55rem; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 999px;
  font-size: .8rem; color: var(--text-2);
}
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.chip input { margin: 0; accent-color: var(--accent); }
.lang-extra { width: 100%; font-size: .82rem; }

/* Inline help. The bubble is CSS-only so it appears instantly and can hold a
   full explanation rather than the one line a native title tooltip allows. */
.info {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; flex-shrink: 0;
  border-radius: 50%; cursor: help;
  background: var(--panel-3); border: 1px solid var(--border-3);
  color: var(--text-2); font-size: .62rem; font-weight: 700; letter-spacing: 0;
  text-transform: none;
}
.info:hover, .info:focus-visible { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.info::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 0;
  z-index: 5; width: max-content; max-width: min(380px, 70vw);
  padding: .6rem .7rem;
  background: var(--panel-3); border: 1px solid var(--border-3); border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: var(--text-2); font-size: .78rem; font-weight: 400; line-height: 1.5;
  letter-spacing: normal; text-transform: none; text-align: left;
  opacity: 0; visibility: hidden; transition: opacity .12s ease;
}
.info:hover::after, .info:focus-visible::after { opacity: 1; visibility: visible; }

main { max-width: min(1480px, 100%); margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.25rem) clamp(1rem, 4vw, 2rem) 5rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head p { margin: 0; }

/* ----------------------------------------------------------------------------
   Cards & sections
   -------------------------------------------------------------------------- */
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin: 1.15rem 0;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.eyebrow {
  font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.15rem; align-items: start; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* ----------------------------------------------------------------------------
   Stat tiles
   -------------------------------------------------------------------------- */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .85rem;
  margin-bottom: 1.15rem;
}
.stat {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .15rem;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--tile, var(--border-2));
}
.stat:hover { transform: translateY(-2px); border-color: var(--border-2); box-shadow: var(--shadow); }
.stat .num { font-size: 2rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.stat.accent  { --tile: var(--accent); }
.stat.success { --tile: var(--success); }
.stat.warn    { --tile: var(--warn); }
.stat.violet  { --tile: var(--violet); }
.stat.highlight { --tile: var(--warn); border-color: var(--warn-line); }
.stat.highlight .num { color: var(--warn-ink); }

/* ----------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
button, .btn {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); padding: .5rem .95rem;
  font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s, filter .15s;
}
button:hover, .btn:hover { border-color: var(--border-3); background: var(--panel-3); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--ring); }

button.primary, .primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: var(--on-accent); border: 0; box-shadow: 0 6px 18px -8px var(--accent-line);
}
button.primary:hover, .primary:hover { filter: brightness(1.07); }
button.small { padding: .32rem .6rem; font-size: .8rem; border-radius: 7px; }
button.danger {
  background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-line);
}
button.danger:hover { background: var(--danger-soft-2); border-color: var(--danger); }
button.link, .link {
  background: none; border: 0; color: var(--text-2); padding: .3rem; font-weight: 550;
}
button.link:hover { color: var(--text); background: none; }
form.inline, .inline { display: inline; }

/* ----------------------------------------------------------------------------
   Banners
   -------------------------------------------------------------------------- */
.banner {
  display: flex; align-items: center; gap: .6rem;
  padding: .8rem 1rem; border-radius: var(--radius-sm); margin: 0 0 1.15rem;
  font-size: .9rem;
}
.banner.warn { background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn-ink); }
.banner::before { content: "⚠"; font-size: 1rem; }

/* ----------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); }
table.grid th, table.grid td {
  text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--border);
  font-size: .88rem; vertical-align: middle; white-space: nowrap;
}
table.grid thead th {
  position: sticky; top: 0; background: var(--panel-2); z-index: 1;
  color: var(--muted); font-weight: 650; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .06em;
}
table.grid tbody tr { transition: background .12s; }
table.grid tbody tr:hover { background: var(--panel-2); }
table.grid tbody tr:last-child td { border-bottom: 0; }
/* Truncating columns yield as the viewport narrows so the fixed-width columns
   (and the row-actions button) keep their space instead of being pushed out. */
td.title { max-width: clamp(160px, 26vw, 420px); overflow: hidden; text-overflow: ellipsis; }
td.detail { max-width: clamp(110px, 16vw, 280px); overflow: hidden; text-overflow: ellipsis; }
/* Per-job overrides from the queue dialog, under whatever the cell already says. */
.job-opts { display: block; font-size: .74rem; color: var(--muted); }
td.num { font-variant-numeric: tabular-nums; }

/* Row action column: never wraps, takes only what it needs, and stays pinned to
   the right edge so buttons like Cancel are reachable without scrolling the
   table sideways. */
table.grid th.row-actions, table.grid td.row-actions {
  width: 1%; white-space: nowrap; text-align: right;
  position: sticky; right: 0; border-left: 1px solid var(--border);
}
table.grid td.row-actions { background: var(--panel); }
table.grid tbody tr:hover td.row-actions { background: var(--panel-2); }
table.grid thead th.row-actions { z-index: 2; }

/* Hover-for-detail affordance: anything carrying an explanatory title tooltip. */
.tag[title] { cursor: help; }
.has-tip { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.tag.has-tip { text-decoration: none; }

/* ----------------------------------------------------------------------------
   Tags / badges
   -------------------------------------------------------------------------- */
.tag {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .16rem .55rem; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border-2);
  font-size: .74rem; font-weight: 650; letter-spacing: .01em; color: var(--text-2);
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.tag.plain::before { display: none; }
.tag.av1       { background: var(--success-soft); border-color: var(--success-line); color: var(--success-ink); }
.tag.subs      { background: var(--accent-soft);  border-color: var(--accent-line);  color: var(--accent-ink); }
.tag.running   { background: var(--warn-soft);    border-color: var(--warn-line);    color: var(--warn-ink); }
.tag.running::before { animation: pulse 1.1s infinite; }
.tag.queued    { color: var(--muted); }
.tag.completed { background: var(--success-soft); border-color: var(--success-line); color: var(--success-ink); }
.tag.failed    { background: var(--danger-soft);  border-color: var(--danger-line);  color: var(--danger-ink); }
.tag.skipped   { background: var(--warn-soft);    border-color: var(--warn-line);    color: var(--warn-ink); }
.tag.vmaf      { background: var(--violet-soft);  border-color: var(--violet-line);  color: var(--violet-ink); }

.reduction { color: var(--success-ink); font-weight: 650; white-space: nowrap; }
.tag.canceled  { color: var(--muted); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ----------------------------------------------------------------------------
   Progress bars
   -------------------------------------------------------------------------- */
.progressbar { background: var(--panel-3); border-radius: 999px; height: 8px; overflow: hidden; width: 100%; }
.progressbar.small { height: 6px; width: 90px; display: inline-block; vertical-align: middle; }
.progressbar .fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .5s ease;
}
.progressbar .fill.indeterminate {
  width: 35%; background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: slide 1.2s infinite ease-in-out;
}
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* ----------------------------------------------------------------------------
   Filters / inputs
   -------------------------------------------------------------------------- */
.filters { display: flex; gap: .55rem; margin: 0 0 1.15rem; flex-wrap: wrap; }
.filters input[type="search"] { min-width: 220px; flex: 1; }
input, select {
  background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text);
  border-radius: var(--radius-sm); padding: .5rem .7rem; font: inherit; font-size: .88rem;
}
input::placeholder { color: var(--muted); }
select { cursor: pointer; }

.error { color: var(--danger-ink); }

/* ----------------------------------------------------------------------------
   System meters
   -------------------------------------------------------------------------- */
.meters { display: flex; flex-direction: column; gap: 1rem; }
.meter-head { display: flex; justify-content: space-between; gap: 1rem; font-size: .84rem; margin-bottom: .4rem; }
.meter-head .k { color: var(--text-2); font-weight: 600; }
.meter-head .v { color: var(--muted); font-variant-numeric: tabular-nums; }
.meter .progressbar { height: 10px; }

/* ----------------------------------------------------------------------------
   Donut charts
   -------------------------------------------------------------------------- */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }
.chart { margin: 0; display: flex; align-items: center; gap: 1.25rem; }
.chart figcaption { font-size: .8rem; font-weight: 600; color: var(--text-2); margin-bottom: .75rem; }

.donut-wrap { position: relative; width: 148px; height: 148px; flex-shrink: 0; }
.donut { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-track { fill: none; stroke: var(--panel-3); stroke-width: 4.2; }
.donut-seg {
  fill: none; stroke-width: 4.2; stroke-linecap: round;
  transform-origin: center;
  transition: stroke-width .18s ease, opacity .18s ease;
  animation: donut-in .7s cubic-bezier(.4,0,.2,1) both;
  animation-delay: calc(var(--i) * .08s);
}
@keyframes donut-in { from { opacity: 0; } to { opacity: 1; } }
.donut-seg:hover, .donut-seg.is-active { stroke-width: 6.2; cursor: pointer; }
.chart.dimmed .donut-seg:not(.is-active) { opacity: .28; }

.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; pointer-events: none;
}
.donut-center .big { font-size: 1.7rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.donut-center .sub { font-size: .72rem; color: var(--muted); margin-top: .15rem; max-width: 96px; }

.legend { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.legend li {
  display: flex; align-items: center; gap: .55rem; padding: .3rem .45rem; border-radius: 7px;
  font-size: .84rem; cursor: default; transition: background .12s;
}
.legend li:hover, .legend li.is-active { background: var(--panel-2); }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend .legend-label { text-transform: capitalize; }
.legend .legend-val { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; padding-left: .5rem; }

/* ----------------------------------------------------------------------------
   Jobs toolbar + pagination
   -------------------------------------------------------------------------- */
.jobs-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.concurrency { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.concurrency label { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-2); }
.concurrency input { width: 4.5rem; }
.pill-count { font-size: .8rem; color: var(--muted); padding: .25rem .6rem; background: var(--panel-2); border-radius: 999px; border: 1px solid var(--border); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.1rem; font-size: .88rem; }
.pagination a, .pagination span { padding: .35rem .7rem; border-radius: 7px; }
.pagination a { cursor: pointer; background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text-2); }
.pagination a:hover { background: var(--panel-3); color: var(--text); }

.actions-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

/* ----------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */
body.centered { display: grid; place-items: center; min-height: 100vh; }
.login { width: 340px; display: flex; flex-direction: column; gap: 1rem; margin: 0; }
.login .brand { justify-content: center; font-size: 1.3rem; margin-bottom: .25rem; }
.login label { display: flex; flex-direction: column; gap: .35rem; font-size: .8rem; color: var(--text-2); font-weight: 550; }
.login input { width: 100%; padding: .6rem .75rem; }
.login button { justify-content: center; padding: .65rem; margin-top: .25rem; }
