/* vod-uploader — corporate light UI, blue accent.
 *
 * Two shells, designed separately:
 *   Desktop (>=1024px): fixed left sidebar with grouped navigation and a
 *   live status block; content column with per-page headers.
 *   Mobile (<1024px): compact topbar (brand + status dots) and a fixed
 *   bottom tab bar; content designed for one column, tables become cards.
 *
 * The CSP forbids inline <style> and style="" attributes; the only dynamic
 * visual values (progress width, timeline segment geometry) are set via
 * CSSOM from JS.
 */

:root {
  /* Brand */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;

  /* Neutrals */
  --page: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef1f5;
  --line: #e4e8ee;
  --line-strong: #cdd5df;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;

  /* Semantic */
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --ok-line: #abefc6;
  --err: #b42318;
  --err-bg: #fef3f2;
  --err-line: #fecdca;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --warn-line: #fedf89;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 28px rgba(16, 24, 40, 0.12), 0 4px 10px rgba(16, 24, 40, 0.06);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Liberation Sans", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;

  --sidebar-w: 236px;
  --tabbar-h: 62px;
  --content-max: 1080px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--page);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

.mono { font-family: var(--mono); font-variant-ligatures: none; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.mt { margin-top: 16px; }

:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================ app shell ============================== */

.shell { display: flex; min-height: 100vh; }

/* The panel spans the full page height; its contents stay pinned while the
   page scrolls. */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  align-self: stretch;
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.sidebar-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  overflow-y: auto;
}
.brand {
  display: block;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--text);
  padding: 4px 10px 16px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-accent { color: var(--blue-600); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 14px 10px 5px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
}
.nav-link:hover { background: var(--surface-3); text-decoration: none; }
.nav-link.active { background: var(--blue-50); color: var(--blue-700); font-weight: 600; }
.nav-link svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
.nav-link.active svg { color: var(--blue-600); }

.sidebar-foot { margin-top: auto; }
.status-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 4px 10px;
  margin-bottom: 12px;
}
.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  min-width: 0;
}
.status-row + .status-row { border-top: 1px solid var(--line); }
.status-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-2);
  width: 58px;
  flex: none;
}
.status-value {
  font-family: var(--sans); font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}
.sidebar-user {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.version {
  font-family: var(--sans); font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--muted);
  background: var(--surface-3);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  flex: none;
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted-2); }
.dot.ok { background: #12b76a; }
.dot.err { background: #f04438; }
.dot.busy { background: var(--blue-600); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}
@media (prefers-reduced-motion: reduce) { .dot.busy { animation: none; } }

/* ---- mobile topbar + tab bar (hidden on desktop) ---- */

.mobile-topbar { display: none; }
.tabbar { display: none; }

/* ---- content column ---- */

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 30px 32px 72px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 22px; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; max-width: 64ch; }

/* ============================ alert banner =========================== */

.alert-banner {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--err-bg);
  border-bottom: 1px solid var(--err-line);
  border-left: 4px solid var(--err);
  color: var(--err);
  padding: 12px 24px;
}
.alert-title { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14px; }
.alert-title::before {
  content: "";
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--err);
  flex: none;
  animation: pulse 1.6s infinite;
}
.alert-detail {
  margin-top: 3px;
  font-family: var(--sans); font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: #912018;
  white-space: pre-wrap;
}

/* =============================== cards =============================== */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.card .card-sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.card h3 { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 18px 0 8px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; }
.link { font-size: 13px; font-weight: 500; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.dash-grid > * { margin-bottom: 0; }

/* ================================ hero =============================== */

.hero { padding: 22px 24px; }

.hero-idle { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.hero-state { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; }
.hero-state .dot { width: 10px; height: 10px; }
.hero-sub { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }
.hero-sub strong { color: var(--text-2); }
.hero-last { margin: 10px 0 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }

.hero-run-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.hero-run-head .spacer { flex: 1; }
.hero-phase { font-size: 19px; font-weight: 650; margin-bottom: 10px; }
.run-item {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  margin-bottom: 12px;
  word-break: break-word;
}
.run-steprow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-family: var(--sans); font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.run-steprow .pct { color: var(--blue-700); font-weight: 700; }

.progress {
  height: 10px;
  background: var(--surface-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue-600), #4f83f1);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.counters { display: flex; gap: 10px; flex-wrap: wrap; }
.counter {
  display: flex;
  align-items: baseline;
  gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 12px;
  color: var(--muted);
}
.counter b { font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 14px; color: var(--text); font-weight: 600; }
.counter.ok b { color: var(--ok); }
.counter.err b { color: var(--err); }
.counter.warn b { color: var(--warn); }

/* =============================== stats =============================== */

.stat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-width: 0;
}
.stat-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value { display: block; font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 21px; font-weight: 600; line-height: 1.3; }
.stat-value.ok { color: var(--ok); }
.stat-value.err { color: var(--err); }
.stat-value.warn { color: var(--warn); }

.queue-chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ============================== buttons ============================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted-2); }
.btn:active { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-primary:active { background: var(--blue-800); }
.btn-primary:disabled:hover { background: var(--blue-600); border-color: var(--blue-600); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); color: var(--text-2); border-color: transparent; }

.btn.danger { color: var(--err); border-color: var(--err-line); }
.btn.danger:hover { background: var(--err-bg); border-color: var(--err); }

.btn.is-placeholder { visibility: hidden; }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 12.5px; }
.btn-lg { min-height: 44px; padding: 10px 22px; font-size: 14px; }
.btn-wide { width: 100%; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ======================== inputs and forms =========================== */

.input {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  max-width: 100%;
  box-shadow: var(--shadow-xs);
}
.input:hover { border-color: var(--muted-2); }
.input:focus { border-color: var(--blue-600); outline: 3px solid var(--blue-100); outline-offset: 0; }
.input::placeholder { color: var(--muted-2); }
.input.mono { font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 13.5px; }
select.input { cursor: pointer; }

.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .input { width: 100%; }

.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-row .input { flex: 1 1 180px; min-width: 0; }

.form-error {
  background: var(--err-bg);
  border: 1px solid var(--err-line);
  color: var(--err);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  margin-bottom: 12px;
  font-size: 13px;
}
.field-error { color: var(--err); font-size: 12.5px; margin: 5px 0 0; }

/* ---- filters: search + chip toggles ---- */

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters .input[type="search"] { flex: 1 1 220px; min-width: 0; }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-toggle {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.chip-toggle:hover { border-color: var(--muted-2); color: var(--text-2); }
.chip-toggle.active {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-700);
}

/* ---- settings groups ---- */

.setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 8px 24px;
  align-items: center;
  padding: 15px 0;
  border-top: 1px solid var(--line);
}
.setting:first-of-type { border-top: none; padding-top: 6px; }
.setting-label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; font-weight: 600; }
.setting-desc { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.setting-default { margin: 2px 0 0; font-size: 11.5px; color: var(--muted-2); font-family: var(--sans); font-variant-numeric: tabular-nums; }
.setting-control .input { width: 100%; }
.setting .field-error { grid-column: 1 / -1; margin-top: 0; }

.save-bar {
  position: sticky;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  margin-top: 4px;
}
.save-bar .muted { font-size: 12.5px; }

/* ================================ tabs =============================== */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 14px 11px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--blue-700); border-bottom-color: var(--blue-600); }

/* =============================== tables ============================== */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.num, table.data td.ts { font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data td.oversize { color: var(--err); font-weight: 700; }

.cell-title { font-weight: 550; }
.cell-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.cell-meta a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--line-strong); }
.cell-meta a:hover { color: var(--blue-700); }

table.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
table.kv th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 16px 6px 0; white-space: nowrap; width: 1%; }
table.kv td { padding: 6px 0; font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }

.env-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 4px 32px; }

/* =============================== chips =============================== */

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.chip.err { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.chip.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.chip.info { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-700); }
.chip.dim { background: var(--surface-3); border-color: var(--line); color: var(--muted-2); }

/* ============================== run log ============================== */

pre.log {
  background: #0c111d;
  color: #cecfd2;
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.error-list { margin: 12px 0 0; padding-left: 18px; color: var(--err); font-size: 13px; }
.error-list li { margin-bottom: 3px; }

.blocker { border-color: var(--warn-line); background: var(--warn-bg); }
.blocker h2 { color: var(--warn); }
.blocker p { margin: 4px 0 0; font-size: 13.5px; color: #7a2e0e; }

/* ======================= credentials panel =========================== */

.cred-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 13px 15px;
  margin-bottom: 10px;
}
.cred-body { min-width: 0; flex: 1; }
.cred-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; text-transform: capitalize; }
.cred-detail { font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }

/* ========================= long VOD entries ========================== */

.lv-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lv-title { font-size: 15px; font-weight: 600; word-break: break-word; flex: 1 1 300px; }
.lv-meta { font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); margin: 4px 0 14px; word-break: break-word; }

/* Proportional timeline of the VOD with its split parts. Geometry (left /
   width percentages) is set from JS via CSSOM. */
.lv-timeline { margin-bottom: 14px; }
.lv-track {
  position: relative;
  height: 34px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.lv-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-50);
  border-right: 2px solid var(--surface);
  color: var(--blue-800);
  font-family: var(--sans); font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
}
.lv-seg.s-uploaded { background: var(--ok-bg); color: var(--ok); }
.lv-seg.s-failed { background: var(--err-bg); color: var(--err); }
.lv-seg.s-oversize {
  background: repeating-linear-gradient(45deg, var(--err-bg), var(--err-bg) 6px, #fde4e2 6px, #fde4e2 12px);
  color: var(--err);
}
.lv-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--sans); font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--muted-2);
  margin-top: 4px;
}

.splits-editor {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
}
.split-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-pill);
  padding: 3px 4px 3px 11px;
  font-family: var(--sans); font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--blue-800);
}
.split-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--blue-700);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}
.split-chip button:hover { background: var(--err-bg); color: var(--err); }
.split-input { flex: 0 1 130px; }
.lv-lock { font-size: 12.5px; color: var(--warn); font-weight: 500; }

/* =============================== toast =============================== */

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 200;
  max-width: 420px;
  background: #101828;
  color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--blue-600);
  padding: 11px 15px;
  font-size: 13.5px;
}
.toast.err { border-left-color: #f04438; }

/* ==================== standalone (login / error) ===================== */

body.standalone { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.standalone-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}
.standalone-brand { font-weight: 800; font-size: 15px; letter-spacing: 0.1em; margin: 0 0 6px; }
.standalone-card h1 { font-size: 20px; margin-bottom: 20px; }
.error-code { font-family: var(--sans); font-variant-numeric: tabular-nums; font-size: 44px; font-weight: 700; color: var(--blue-600); line-height: 1; margin: 6px 0; }

/* ========================= spaces (v3 shell) ========================= */

.space-label {
  margin: -6px 10px 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--blue-50);
  color: var(--blue-800);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-link.nav-sub { padding-left: 18px; }
.space-switcher { width: 100%; min-height: 34px; padding: 5px 10px; font-size: 13px; margin: 2px 0 4px; }
.topbar-space {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hero with fixed geometry: polls change text and the bar, never the size. */
.hero { min-height: 172px; }
.hero-grid { display: flex; align-items: center; gap: 24px; }
.hero-main { flex: 1; min-width: 0; }
.hero-line {
  margin: 8px 0 10px;
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero .progress { margin-bottom: 10px; }
.hero:not(.is-running) .progress { opacity: 0.45; }
.hero .hero-sub { margin: 0; }
.hero-actions .btn { min-width: 150px; }

.dash-grid { margin-bottom: 16px; }
.dash-side > .card:last-child { margin-bottom: 0; }

/* YouTube identity row */
.yt-connection { display: flex; align-items: center; gap: 12px; min-height: 44px; min-width: 0; }
.yt-thumb { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; background: var(--surface-3); }
.yt-thumb-empty {
  display: inline-block;
  border: 1px dashed var(--line-strong);
  background:
    linear-gradient(135deg, transparent 45%, var(--line-strong) 45%, var(--line-strong) 55%, transparent 55%),
    var(--surface-2);
}
.yt-text { flex: 1; min-width: 0; }
.yt-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.yt-panel { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.yt-panel .yt-connection { flex: 1 1 320px; }

/* Tables whose rows never change height */
table.data.fixed-rows td { white-space: nowrap; }
table.data.fixed-rows td.title { max-width: 0; width: 100%; }
table.data.fixed-rows .cell-title,
table.data.fixed-rows .cell-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.data td.clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data.overview td.clip.err-text { max-width: 280px; }
.err-text { color: var(--err); }
table.data.spaces td.yt-cell { max-width: 220px; }
table.data.spaces td.yt-cell .cell-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data.accounts td.clip { max-width: 200px; }
.count-line { margin: 12px 0 4px; font-size: 12.5px; }

/* Overview */
.overview-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.overview-top > .card { margin-bottom: 16px; }
.queue-card { min-height: 172px; }
.queue-list { list-style: none; margin: 8px 0 0; padding: 0; }
.queue-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 34px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
}
.queue-list li:first-child { border-top: none; }
.queue-list .clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
pre.log.fixed-log { height: 220px; max-height: none; }

.stat-row.stat-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.space-breakdown { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.space-breakdown > li { margin-bottom: 4px; }

/* Modal dialogs */
dialog.modal {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  color: var(--text);
  background: var(--surface);
}
dialog.modal::backdrop { background: rgba(16, 24, 40, 0.45); }
.modal-body { padding: 22px 22px 18px; }
.modal-body h2 { font-size: 17px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field.is-disabled label { color: var(--muted-2); }

/* ===================================================================== */
/* Mobile / tablet shell: <1024px                                        */
/* ===================================================================== */

@media (max-width: 1023px) {
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  .shell { display: block; }
  .sidebar { display: none; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
    height: 54px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .mobile-topbar .brand { padding: 0; flex: 1; }
  .dot-cluster { display: flex; gap: 7px; align-items: center; }
  .dot-cluster .dot { width: 9px; height: 9px; }

  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 55;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -1px 3px rgba(16, 24, 40, 0.06);
  }
  .tab-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
    min-width: 0;
    padding: 4px 2px;
  }
  .tab-link:hover { text-decoration: none; }
  .tab-link span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-link svg { width: 21px; height: 21px; }
  .tab-link.active { color: var(--blue-600); }

  .content { padding: 18px 16px 30px; }
  .page-head { margin-bottom: 16px; }
  .page-head h1 { font-size: 19px; }
  .alert-banner { padding: 11px 16px; }

  .dash-grid { grid-template-columns: 1fr; }
  .hero { padding: 18px; }
  .hero-idle { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { width: 100%; }

  .save-bar { bottom: calc(var(--tabbar-h) + 10px); flex-wrap: wrap; }
  .toast { left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + 14px); max-width: none; }
}

/* ===================================================================== */
/* Content adaptations: <=760px                                          */
/* ===================================================================== */

@media (max-width: 760px) {
  .card { padding: 16px; }

  .form-row { flex-direction: column; align-items: stretch; }
  .form-row .input, .form-row .btn { width: 100%; flex: none; }
  .filters .input[type="search"] { flex-basis: 100%; }
  .filters select.input { flex: 1 1 100%; }
  .save-bar .btn { flex: 1; }

  /* Cells flagged empty by the renderer carry no information on a card. */
  table.data td.empty { display: none; }

  .setting { grid-template-columns: 1fr; gap: 8px; padding: 14px 0; }
  .setting-control .input { width: 100%; }

  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .counters { gap: 8px; }

  .env-grid { grid-template-columns: 1fr; }
  table.kv th { width: auto; }

  pre.log { font-size: 11.5px; max-height: 220px; }

  /* ---- generic table -> labelled rows (runs, users, parts) ---- */
  .table-wrap { overflow-x: visible; }
  table.data, table.data tbody { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  table.data tbody tr:last-child { margin-bottom: 0; }
  table.data tbody tr:hover td { background: transparent; }
  table.data td {
    display: flex;
    align-items: baseline;
    gap: 8px;
    border: none;
    padding: 3px 0;
  }
  table.data td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted-2);
  }
  table.data td:not([data-label])::before { content: none; }
  table.data td.actions { flex-basis: 100%; justify-content: flex-start; margin-top: 6px; }
  table.data td.actions::before { content: none; }
  table.data td.actions .btn { flex: 1; }

  /* ---- uploads table -> designed cards (title-first, not a form) ---- */
  table.data.uploads td.title {
    order: -2;
    flex: 1 1 65%;
    display: block;
    padding: 0 0 4px;
  }
  table.data.uploads td.title::before { content: none; }
  table.data.uploads td.title .cell-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 14px;
  }
  table.data.uploads td.status-cell { order: -1; margin-left: auto; padding: 0; }
  table.data.uploads td.status-cell::before { content: none; }
}

/* ---- v3 shell adaptations ---- */

@media (max-width: 1023px) {
  .tabbar.tabs-4 { grid-template-columns: repeat(4, 1fr); }
  .mobile-topbar .brand { flex: none; }
  .mobile-topbar .space-switcher { flex: 1; min-width: 0; width: auto; margin: 0; }
  .overview-top { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .hero-grid { flex-direction: column; align-items: stretch; gap: 14px; }
  .hero-actions .btn { width: 100%; }
}

@media (max-width: 760px) {
  .hero { min-height: 0; }
  .mobile-topbar { gap: 10px; }
  .mobile-topbar .brand { font-size: 12px; letter-spacing: 0.06em; }
  table.data.fixed-rows td { white-space: normal; min-width: 0; }
  table.data.fixed-rows td.title { max-width: 100%; width: auto; flex: 1 1 100%; min-width: 0; overflow: hidden; }
  table.data.fixed-rows td.title .cell-title,
  table.data.fixed-rows td.title .cell-meta { display: block; max-width: 100%; }
  table.data.uploads.fixed-rows td.title { flex-basis: 60%; }
  table.data.fixed-rows td.num, table.data.fixed-rows td.ts { white-space: nowrap; }
  table.data td.clip { max-width: 100%; min-width: 0; }
  table.data.overview td.title { order: -2; }
  .field-pair { grid-template-columns: 1fr; gap: 0; }
  .stat-row.stat-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  pre.log.fixed-log { height: 180px; }
  .yt-panel .actions { width: 100%; }
  .yt-panel .actions .btn { flex: 1; }
}

@media (min-width: 761px) {
  table.data td.actions { display: table-cell; }
  table.data td.actions .btn + .btn { margin-left: 6px; }
}
