:root {
  --bg: #0c0f14;
  --panel: #141922;
  --panel-2: #1a2130;
  --line: #263042;
  --text: #e6ebf3;
  --muted: #8b97ab;
  --accent: #7c9cff;
  --accent-2: #5ee0c4;
  --ok: #4fd18b;
  --warn: #f5b84b;
  --bad: #ff6b6b;
  --run: #7c9cff;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.small { font-size: 12.5px; }

/* ---------- En-tête ---------- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 22px; padding: 10px 22px;
  background: rgba(12, 15, 20, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .2px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 6px 11px; border-radius: 8px; color: var(--muted); }
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--panel-2); color: var(--text); }
.top .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.on .dot { background: var(--run); box-shadow: 0 0 0 0 var(--run); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(124,156,255,.6); } 70% { box-shadow: 0 0 0 8px rgba(124,156,255,0); } 100% { box-shadow: 0 0 0 0 rgba(124,156,255,0); } }

main { padding: 22px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

/* ---------- Éléments ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel + .panel { margin-top: 14px; }
.panel h2 { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer; white-space: nowrap; color: var(--text); }
.btn:hover { border-color: #3a4760; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b1020; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
input[type=text], input[type=number], input[type=password], select, textarea {
  background: #0f141c; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
label.field > :is(input, select) { color: var(--text); font-size: 14px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-align: left; color: var(--text); }
.tab b { display: block; }
.tab span { color: var(--muted); font-size: 12px; }
.tab.on { border-color: var(--accent); background: #18203a; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: #0f141c; cursor: pointer; font-size: 12.5px; color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #0b1020; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { padding: 6px 12px; border: 0; background: #0f141c; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--panel-2); color: var(--text); font-weight: 600; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-queued { color: var(--muted); }
.st-starting, .st-running, .st-checking { color: var(--run); }
.st-blocked { color: var(--warn); }
.st-done { color: var(--ok); }
.st-failed, .st-timeout { color: var(--bad); }
.st-cancelled { color: var(--muted); }

.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score small { font-weight: 400; color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.error-box { padding: 10px 12px; border-radius: 8px; background: rgba(255,107,107,.08); border: 1px solid rgba(255,107,107,.35); color: #ffc9c9; }
.note-box { padding: 10px 12px; border-radius: 8px; background: rgba(245,184,75,.07); border: 1px solid rgba(245,184,75,.3); color: #f6dcaa; font-size: 12.5px; }
.toast { position: fixed; right: 18px; bottom: 18px; padding: 10px 14px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); z-index: 50; max-width: 420px; }
.toast.bad { border-color: var(--bad); }

/* ---------- Calendrier ---------- */
.cal-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-height: calc(100vh - 230px); }
table.cal { border-collapse: separate; border-spacing: 0; }
table.cal th, table.cal td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px; vertical-align: top; }
table.cal thead th { position: sticky; top: 0; z-index: 2; background: var(--panel-2); font-weight: 600; font-size: 12.5px; text-align: center; min-width: 196px; }
table.cal thead th .month { display: block; color: var(--muted); font-weight: 400; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
table.cal th.cfg { position: sticky; left: 0; z-index: 1; background: var(--panel); min-width: 240px; max-width: 280px; text-align: left; }
table.cal thead th.cfg { z-index: 3; background: var(--panel-2); }
.cfg-model { font-weight: 700; }
.cfg-sub { color: var(--muted); font-size: 12px; }
.cell { display: block; position: relative; width: 180px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #0f141c; color: var(--text); }
.cell:hover { border-color: var(--accent); text-decoration: none; }
.cell img, .cell .ph { display: block; width: 180px; height: 101px; object-fit: cover; background: #0b0e13; }
.cell .ph { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-align: center; padding: 6px; }
.cell .meta { display: flex; justify-content: space-between; align-items: center; padding: 5px 7px; font-size: 12px; gap: 6px; }
.cell .count { position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,.7); border-radius: 6px; padding: 0 6px; font-size: 11px; }
.cell + .cell { margin-top: 6px; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--run); border-radius: 50%; animation: rot 1s linear infinite; margin-right: 6px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- Lancement ---------- */
.bench-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.bench-card { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #0f141c; cursor: pointer; }
.bench-card.on { border-color: var(--accent); background: #161f38; }
.bench-card input { margin-top: 3px; }
.cfg-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #10151e; }
.cfg-card + .cfg-card { margin-top: 10px; }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.cfg-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.launch-bar { position: sticky; bottom: 0; margin-top: 16px; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- Historique ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
table.list tr:hover td { background: #121822; }

/* ---------- Fiche d'un run ---------- */
.run-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 18px; margin-top: 14px; }
.facts div span { display: block; color: var(--muted); font-size: 12px; }
.preview { background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); margin: 0 auto; transition: width .2s; }
.preview iframe { display: block; width: 100%; height: 72vh; border: 0; background: #fff; }
.captures { display: flex; gap: 10px; flex-wrap: wrap; }
.captures a img { display: block; height: 120px; border-radius: 6px; border: 1px solid var(--line); }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.ok { color: var(--ok); } .bad { color: var(--bad); } .half { color: var(--warn); }
.crit { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.crit input[type=number] { width: 76px; }
.crit .quick { display: flex; gap: 4px; }
.agent-msg { white-space: pre-wrap; font-size: 13px; background: #0f141c; border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 420px; overflow: auto; }
pre.prompt { white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; background: #0f141c; border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 520px; overflow: auto; }
details > summary { cursor: pointer; color: var(--muted); }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cmp .preview iframe { height: 75vh; }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login .brand { font-size: 18px; justify-content: center; margin-bottom: 6px; }

@media (max-width: 900px) {
  main { padding: 14px; }
  .grid2, .cmp { grid-template-columns: 1fr; }
  .top { gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
}
