:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --border: #1f2a44;
  --text: #e6edf7;
  --muted: #7b8aa8;
  --accent: #5fd0ff;
  --ok: #3ddc84;
  --warn: #f5c518;
  --err: #ff5c7a;
}
* { box-sizing: border-box; }
body {
  font-family: ui-monospace, "JetBrains Mono", Menlo, monospace;
  background: var(--bg); color: var(--text);
  margin: 0; padding: 1.5rem;
}
header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.25rem; }
header h1 { margin: 0; font-size: 1.25rem; color: var(--accent); }
.sub { color: var(--muted); font-size: 0.85rem; }
h2 { font-size: 1rem; color: var(--accent); margin: 1.5rem 0 0.5rem; }

.muted { color: var(--muted); }
.err { color: var(--err); }

section { background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }

.worker-grid { display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.worker { background: rgba(255,255,255,0.02); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.75rem; }
.worker.offline { opacity: 0.55; border-color: var(--err); }
.worker .hdr { display: flex; justify-content: space-between;
  gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; flex-wrap: wrap; }
.worker .gpu { color: var(--muted); font-size: 0.8rem; }
.worker .state { color: var(--ok); font-size: 0.75rem; text-transform: uppercase; }
.worker.offline .state { color: var(--err); }
.bar { display: grid; grid-template-columns: 60px 1fr auto; gap: 0.5rem;
  align-items: center; margin-bottom: 0.25rem; font-size: 0.8rem; }
.bar small { color: var(--muted); }

progress { appearance: none; height: 10px; width: 100%;
  border-radius: 6px; overflow: hidden; border: 1px solid var(--border); background: #0a1020; }
progress::-webkit-progress-bar { background: #0a1020; }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

.acq-grid { display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.acq-col { background: rgba(255,255,255,0.02); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.75rem; }
.acq-title { color: var(--text); font-size: 0.95rem; margin: 0 0 0.75rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: baseline; }
.acq-title .total { color: var(--muted); font-size: 0.8rem; font-weight: normal; }

.job-list { list-style: none; margin: 0; padding: 0; }
.job-list .job-item { display: grid;
  grid-template-columns: 20px 1fr auto 20px; gap: 0.5rem;
  align-items: center; padding: 0.25rem 0; font-size: 0.85rem; }
.job-list .job-item .icon { display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 3px; }
.job-list .job-item.done .icon { background: var(--ok); color: #062410; font-weight: bold; }
.job-list .job-item.running .icon,
.job-list .job-item.extracting .icon { color: var(--accent); }
.job-list .job-item.running .icon .spin,
.job-list .job-item.extracting .icon .spin { display: inline-block;
  animation: spin 1.2s linear infinite; }
.job-list .job-item.queued .icon { color: var(--muted); }
.job-list .job-item.error .icon { background: var(--err); color: #fff; font-weight: bold; }

.job-list .label { color: var(--text); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.prog-wrap { display: flex; align-items: center; gap: 4px; height: 10px; position: relative; width: 100%; max-width: 160px; }
.prog-fill { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.5s; min-width: 2px; }
.prog-text { font-size: 0.7rem; color: var(--muted); white-space: nowrap; }
.job-list .dur { color: var(--muted); font-size: 0.78rem; }
.job-list .ext { margin-left: 0.5rem; color: var(--accent); font-size: 0.75rem; }
button.ext.viewer-btn { background: transparent; border: 1px solid var(--accent);
  color: var(--accent); font-size: 0.72rem; padding: 1px 6px; border-radius: 3px;
  cursor: pointer; font-family: inherit; }
button.ext.viewer-btn:hover { background: var(--accent); color: #000; }
button.ext.viewer-btn:disabled { opacity: 0.6; cursor: wait; }

.err-line { color: var(--err); font-size: 0.75rem;
  padding-left: 28px; padding-bottom: 0.25rem; }

.stitch-section { margin-top: 0.75rem; padding-top: 0.6rem;
  border-top: 1px dashed var(--border); }
.stitch-title { display: flex; align-items: center; gap: 0.5rem;
  color: var(--text); font-size: 0.85rem; margin-bottom: 0.25rem; }
.stitch-children { list-style: none; padding: 0 0 0 1.4rem; margin: 0; }
.stitch-children .sub { color: var(--muted); font-size: 0.8rem;
  padding: 0.15rem 0; display: flex; align-items: center; gap: 0.4rem; }

button.mini { padding: 0 0.4rem; font-size: 0.75rem; line-height: 1.4; }

@keyframes spin { to { transform: rotate(360deg); } }

.monitor-header { margin-bottom: 0.75rem; }
.dispatcher-status { display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: var(--muted); }
.dispatcher-status .dot { width: 8px; height: 8px; border-radius: 50%;
  background: var(--err); flex-shrink: 0; }
.dispatcher-status.alive .dot { background: var(--ok); }
.dispatcher-status.alive { color: var(--ok); }
.worker-meta { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
.tag { font-size: 0.75rem; padding: 0.1rem 0.35rem; border-radius: 4px;
  background: rgba(255,255,255,0.05); color: var(--text); }
.tag.warn { color: var(--warn); }

button { background: transparent; color: var(--accent); border: 1px solid var(--border);
  padding: 0.2rem 0.6rem; border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 0.75rem; }
button:hover { border-color: var(--accent); }
a { color: var(--accent); }
code { background: rgba(255,255,255,0.05); padding: 0 0.25rem; border-radius: 3px; }

/* ==== Jobs table ==== */
.acq { margin-bottom: 1.5rem; }
.acq-title { font-size: 1rem; margin: 0 0 0.5rem; }
.acq-title .total { color: var(--muted); font-size: 0.85rem; margin-left: 0.5rem; }

.jobs-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.jobs-table thead th { text-align: left; padding: 4px 8px; color: var(--muted); font-weight: 500; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border, #333); }
.jobs-table tbody td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
.jobs-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.col-status { width: 24px; text-align: center; }
.col-thumb { width: 56px; }
.col-thumb img { width: 48px; height: 27px; object-fit: cover; border-radius: 3px; display: block; }
.thumb-placeholder { display: inline-block; width: 48px; height: 27px; background: rgba(255,255,255,0.04); border-radius: 3px; }
.col-id { font-family: ui-monospace, monospace; color: var(--muted); font-size: 0.75rem; }
.col-auv { min-width: 110px; }
.col-seg { font-variant-numeric: tabular-nums; color: var(--muted); }
.col-dur, .col-frames, .col-trim, .col-elapsed { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.8rem; }
.col-progress { min-width: 140px; }
.col-actions { width: 24px; text-align: right; }

.badge { display: inline-block; width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 3px; font-size: 0.72rem; font-weight: 600; }
.badge.ok { background: var(--ok, #2d7); color: #062410; }
.badge.busy { color: var(--accent, #4af); }
.badge.err { background: var(--err, #d44); color: #fff; }
.badge.muted { color: var(--muted, #888); }

.job-row.skipped { opacity: 0.45; }
.job-row.skipped .col-seg, .job-row.skipped .col-auv { font-style: italic; }

.prog-bar { display: inline-block; width: 100px; height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.prog-fill { display: block; height: 100%; background: var(--accent, #4af); transition: width 0.5s; }
.prog-text { margin-left: 6px; color: var(--muted); font-size: 0.72rem; }

.btn-viser { display: inline-block; text-decoration: none; padding: 3px 10px; border: 1px solid var(--accent, #4af); border-radius: 3px; color: var(--accent, #4af); font-size: 0.72rem; background: transparent; cursor: pointer; font-family: inherit; }
.btn-viser:hover { background: var(--accent, #4af); color: #062036; }

.stitch-section { margin-top: 0.75rem; padding: 0.5rem 0 0; border-top: 1px dashed var(--border, #333); }
.stitch-title { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.35rem; }
.stitch-list { list-style: none; padding: 0; margin: 0; }
.stitch-item { display: flex; align-items: center; gap: 0.5rem; padding: 3px 0; font-size: 0.82rem; }
.stitch-item .err-line { flex-basis: 100%; margin-left: 26px; color: var(--err, #d44); font-size: 0.72rem; }

.badge.busy { display: inline-block; animation: spin 1.2s linear infinite; transform-origin: 50% 50%; }
.progress-wrap { display: flex; align-items: center; gap: 6px; }
.step-text { margin-top: 2px; color: var(--muted); font-size: 0.7rem; font-style: italic; font-variant-numeric: tabular-nums; }

.docs-link {
  margin-left: auto;
  font-size: 0.85rem;
  color: #8ab4f8;
  text-decoration: none;
  padding: 0.2rem 0.6rem;
  border: 1px solid #3c4043;
  border-radius: 4px;
}
.docs-link:hover { background: #2d2f31; }
.btn-glb, .btn-ply-dl { display: inline-block; text-decoration: none; padding: 3px 10px; border: 1px solid #8bc34a; border-radius: 3px; color: #8bc34a; font-size: 0.72rem; background: transparent; cursor: pointer; font-family: inherit; }
.btn-glb:hover, .btn-ply-dl:hover { background: #8bc34a; color: #000; }
.btn-qc { display: inline-block; text-decoration: none; padding: 3px 10px; border: 1px solid #29b6f6; border-radius: 3px; color: #29b6f6; font-size: 0.72rem; background: transparent; cursor: pointer; font-family: inherit; }
.btn-qc:hover { background: #29b6f6; color: #000; }

/* Section évolutions */
#evolutions { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border, #333); }
#evolutions h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted, #888); margin-bottom: 0.75rem; }
#evolutions h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted, #888); margin: 0.75rem 0 0.4rem; }

.evol-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-bottom: 1rem; }
.evol-table th { text-align: left; padding: 0.3rem 0.6rem; color: var(--muted, #888); font-weight: 600; border-bottom: 1px solid var(--border, #333); font-size: 0.72rem; }
.evol-table td { padding: 0.35rem 0.6rem; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: top; }
.evol-table td:first-child { white-space: nowrap; }
.evol-table a { color: var(--accent, #4af); text-decoration: none; }
.evol-table a:hover { text-decoration: underline; }
.evol-table code { font-size: 0.75rem; background: rgba(255,255,255,0.07); padding: 1px 4px; border-radius: 3px; }

.pipeline-box { background: rgba(255,255,255,0.03); border: 1px solid var(--border, #333); border-radius: 6px; padding: 0.6rem 1rem; }
.pipeline-box ol { margin: 0; padding-left: 1.4rem; }
.pipeline-box li { padding: 0.18rem 0; font-size: 0.78rem; color: var(--muted, #888); }
.pipeline-box code { font-size: 0.73rem; background: rgba(255,255,255,0.07); padding: 1px 5px; border-radius: 3px; color: #cef; }

.viewer-btn { background: #1a3a2a; color: #4ade80; border: 1px solid #4ade80; border-radius: 3px; padding: 2px 8px; cursor: pointer; font-size: 0.8rem; }
.viewer-btn:hover { background: #4ade80; color: #0a1a10; }
.viewer-btn:disabled { opacity: 0.5; cursor: wait; }

/* ==== Pipeline section ==== */
.pipeline-mission { margin-bottom: 1rem; }
.pm-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.pm-name { font-weight: 600; color: var(--accent); }
.pm-status { font-size: 0.75rem; padding: 0.1rem 0.4rem; border-radius: 4px; text-transform: uppercase; font-weight: 600; }
.pm-counts { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.cnt { font-size: 0.72rem; padding: 0.1rem 0.35rem; border-radius: 3px; background: rgba(255,255,255,0.05); }
.cnt.ok { color: var(--ok); } .cnt.busy { color: var(--accent); } .cnt.warn { color: var(--warn); } .cnt.err { color: var(--err); }

.pipeline-jobs-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.pipeline-jobs-table th { text-align: left; padding: 3px 8px; color: var(--muted); font-size: 0.70rem; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.pipeline-jobs-table td { padding: 4px 8px; border-bottom: 1px solid rgba(255,255,255,0.03); }
.pipeline-jobs-table tr.pj-err-row td { padding: 0 8px 4px; }

.pj-badge { font-size: 0.70rem; padding: 1px 5px; border-radius: 3px; text-transform: uppercase; font-weight: 600; }
.status-done, .pj-badge.status-done { color: var(--ok); background: rgba(61,220,132,0.1); }
.status-running, .pj-badge.status-running { color: var(--accent); background: rgba(95,208,255,0.1); }
.status-queued, .pj-badge.status-queued { color: var(--muted); }
.status-degraded, .pj-badge.status-degraded { color: var(--warn); background: rgba(245,197,24,0.1); }
.status-error, .pj-badge.status-error { color: var(--err); background: rgba(255,92,122,0.1); }
.status-ingested, .pm-status.status-ingested { color: var(--accent); background: rgba(95,208,255,0.12); }

/* AUV viser buttons (per-mission) */
.pm-auvs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.3rem 0 0.5rem; align-items: center; }
.pm-auvs-label { color: var(--muted, #888); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.btn-viser-auv { font-size: 0.72rem; padding: 2px 8px; background: transparent;
  border: 1px solid var(--accent, #4af); color: var(--accent, #4af); border-radius: 3px;
  cursor: pointer; font-family: inherit; }
.btn-viser-auv:hover { background: var(--accent, #4af); color: #062036; }
.btn-viser-auv:disabled { opacity: 0.5; cursor: wait; }
