/* Feeds — habillage regie : sombre, dense, lisible de loin. */

:root {
  --bg: #0b0e13;
  --bg2: #121722;
  --bg3: #19202e;
  --line: #263044;
  --fg: #e6ebf5;
  --muted: #8794ad;
  --accent: #4da3ff;
  --ok: #3ddc84;
  --warn: #ffb648;
  --err: #ff5c6c;
  --idle: #5a6781;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.45 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.num { text-align: right; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.error { color: var(--err); margin: 4px 0; white-space: pre-wrap; }

/* ------------------------------------------------------------- controles */

button {
  font: inherit;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--fg);
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; border-color: var(--line); }
button.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 3px 9px; font-size: 12px; }
button.danger:hover { border-color: var(--err); color: var(--err); }
button.on { background: var(--accent); border-color: var(--accent); color: #04121f; }

input, select, textarea {
  font: inherit;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
select.compact { width: auto; min-width: 180px; padding: 4px 8px; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
label > input, label > select { margin-top: 3px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--fg); }
label.inline > span { font-size: 12px; }
.help { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0 0 12px; }
legend { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------- pastilles */

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge.running, .badge.live { color: var(--ok); border-color: #1e5c3c; background: #10241a; }
.badge.waiting, .badge.starting { color: var(--warn); border-color: #5d451c; background: #241c10; }
.badge.error, .badge.failed { color: var(--err); border-color: #5e2029; background: #240f13; }
.badge.stopped, .badge.idle { color: var(--idle); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); display: inline-block; }
.dot.running, .dot.live { background: var(--ok); box-shadow: 0 0 6px #3ddc8477; }
.dot.waiting, .dot.starting { background: var(--warn); }
.dot.error, .dot.failed { background: var(--err); }

.chip {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--muted);
}
.chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }

/* ------------------------------------------------------------- ossature */

#app { display: flex; flex-direction: column; height: 100%; }

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  height: 46px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .02em; }
.server-info { display: flex; gap: 14px; font-size: 11px; margin-left: auto; }

.tabs { display: flex; gap: 2px; }
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  padding: 12px 14px;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }

main { flex: 1; min-height: 0; }
.panel { display: none; height: 100%; flex-direction: column; }
.panel.active { display: flex; }

.split { display: flex; height: 100%; min-height: 0; }
.list { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.detail {
  width: 400px;
  flex: none;
  border-left: 1px solid var(--line);
  background: var(--bg2);
  overflow-y: auto;
  padding: 14px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
  flex: none;
}

/* ------------------------------------------------------------- tableau */

.grid { width: 100%; border-collapse: collapse; }
.grid thead th {
  position: sticky;
  top: 0;
  background: var(--bg2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}
.grid th.num { text-align: right; }
.grid th.w-state { width: 26px; }
.grid tbody tr { border-bottom: 1px solid #1b2231; cursor: pointer; }
.grid tbody tr:hover { background: var(--bg2); }
.grid tbody tr.sel { background: #16233a; box-shadow: inset 2px 0 0 var(--accent); }
.grid td { padding: 7px 10px; vertical-align: middle; }
.grid td.name { font-weight: 500; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ------------------------------------------------------------- detail */

.detail h3 { margin: 0 0 2px; font-size: 15px; }
.detail .sub { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.detail .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 16px 0 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.section-title button { text-transform: none; letter-spacing: 0; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 3px 10px; font-size: 12px; }
.kv .k { color: var(--muted); }

.url { display: flex; align-items: center; gap: 6px; margin: 5px 0; }
.url code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card2 {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg3);
  padding: 9px 10px;
  margin-bottom: 8px;
}
.card2 .head { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.card2 .head strong { font-size: 12px; }

.preview { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); display: block; }

/* ------------------------------------------------------------- multiview */

.stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: #06080c;
}
.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  max-height: 100%;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stage video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: #06080cdd;
  text-align: center;
  padding: 20px;
}
.stage-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg2);
  flex: none;
  font-size: 12px;
}

.tiles { position: absolute; inset: 0; pointer-events: none; }

.tile {
  position: absolute;
  border: 1px solid #ffffff14;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.tile.nosignal { border-color: #ff5c6c66; background: #ff5c6c0d; }
.tile .tile-top { display: flex; align-items: flex-start; gap: 4px; padding: 4px; pointer-events: auto; }
.tile .tile-bottom { display: flex; align-items: flex-end; gap: 4px; padding: 4px; pointer-events: auto; }

.tile .tname {
  font-size: 11px;
  background: #000000a8;
  border: 1px solid #ffffff1a;
  border-radius: 4px;
  padding: 1px 6px;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile .tbtn {
  font-size: 11px;
  padding: 1px 6px;
  background: #000000a8;
  border: 1px solid #ffffff2a;
  color: var(--fg);
  pointer-events: auto;
}
.tile .tbtn:hover { border-color: var(--accent); }
.tile .tbtn.live { background: var(--accent); border-color: var(--accent); color: #04121f; }
.tile .tbtn.warn { color: var(--err); border-color: #ff5c6c66; }
.tile select.tsel {
  width: auto;
  font-size: 11px;
  padding: 1px 4px;
  background: #000000a8;
  border-color: #ffffff2a;
  pointer-events: auto;
}
.tile canvas.vu { display: block; background: #000000a8; border: 1px solid #ffffff1a; border-radius: 3px; }

/* ------------------------------------------------------------- journal */

.logbody {
  flex: 1;
  margin: 0;
  padding: 10px 14px;
  overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: #c7d2e4;
}

/* ------------------------------------------------------------- fenetres */

.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); }
.login .card {
  width: 320px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
}
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0 0 16px; font-size: 12px; }
.login button { width: 100%; margin-top: 6px; }

.modal { position: fixed; inset: 0; background: #000000b0; display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-card {
  width: min(760px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.modal-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 15px; flex: 1; }
#modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.modal-foot .error { flex: 1; margin: 0; font-size: 12px; }

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 9px 16px;
  z-index: 60;
}
.toast.err { border-color: var(--err); color: var(--err); }

/* ------------------------------------------------------------- grille de cases */

.layout {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}
.layout .cell {
  border: 1px dashed var(--line);
  border-radius: 4px;
  min-height: 46px;
  padding: 4px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: pointer;
}
.layout .cell.filled { border-style: solid; border-color: var(--accent); color: var(--fg); background: #16233a; }

@media (max-width: 1100px) {
  .split { flex-direction: column; }
  .detail { width: auto; border-left: none; border-top: 1px solid var(--line); max-height: 45%; }
  .server-info { display: none; }
}
