:root {
  --bg: #f4f6f9; --panel: #fff; --ink: #1b2330; --muted: #6b7686; --line: #e2e6ec;
  --accent: #1f6feb; --accent-ink: #fff; --ok: #1a7f37; --warn: #b26b00; --err: #cf222e;
  --nav: #111827; --nav-ink: #cbd5e1; --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 17px; margin: 28px 0 10px; } h3 { margin: 0 0 8px; font-size: 15px; } h4 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; } .center { align-items: center; text-align: center; }
.grow { flex: 1; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: inherit; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
button, .btn { font: inherit; padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: #c4ccd6; background: #f8fafc; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line)); }
button.danger:hover { background: #fff0f0; }
button.sm { padding: 4px 9px; font-size: 13px; }
button.icon { padding: 5px 8px; }
button.link { border: none; background: none; color: var(--muted); text-decoration: underline; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label, .form-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }
label.check { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 400; }
.row { display: flex; gap: 6px; align-items: center; } .row.wrap { flex-wrap: wrap; } .row input { flex: 1; }
.inline { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.narrow { max-width: 380px; }
.err { color: var(--err); font-size: 13px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; background: #eef2f7; color: #475467; font-size: 11px; margin: 2px 4px 0 0; }
.badge:not(:empty) { background: var(--err); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; margin-left: auto; }
code { background: #eef2f7; padding: 2px 5px; border-radius: 4px; }

/* Écrans d'authentification */
body.auth { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, #0f172a, #1e3a8a); }
.auth-card { background: var(--panel); width: min(420px, 92vw); border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card.wide { width: min(560px, 94vw); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; margin-bottom: 18px; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 16px; }
.qr { display: grid; place-items: center; } .qr svg { max-width: 230px; height: auto; border-radius: 6px; }
.secret { display: block; margin-top: 6px; word-break: break-all; font-size: 13px; }
input.code { font-size: 26px; letter-spacing: .3em; text-align: center; font-family: ui-monospace, monospace; }
input.code-sm { width: 150px; letter-spacing: .1em; font-family: ui-monospace, monospace; }
.bigcode { font-size: 38px; letter-spacing: .15em; font-family: ui-monospace, monospace; text-align: center; font-weight: 700; padding: 10px; background: #eef4ff; border-radius: 10px; }
.consent { background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 13px; }
.consent ul { margin: 6px 0; padding-left: 18px; }
.spinner { width: 34px; height: 34px; border: 3px solid #dbe3ee; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Mise en page principale */
body.main #app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
#nav { background: var(--nav); color: var(--nav-ink); display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; position: sticky; top: 0; height: 100vh; }
#nav .brand { color: #fff; padding: 4px 8px 14px; margin: 0; font-size: 14px; }
#nav a { display: flex; align-items: center; gap: 10px; color: var(--nav-ink); text-decoration: none; padding: 8px 10px; border-radius: 6px; }
#nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
#nav a.active { background: rgba(31,111,235,.25); color: #fff; }
#nav .ic { width: 20px; text-align: center; }
.conn { font-size: 12px; color: #f87171; padding: 8px 10px; } .conn.on { color: #4ade80; }
#main { padding: 24px 30px; max-width: 1400px; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search { width: 100%; max-width: 480px; margin-bottom: 14px; }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.grid th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); background: #f9fafb; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:last-child td { border-bottom: none; }
table.grid td .muted { font-size: 12px; }
table.grid td button { margin-left: 4px; }
table.compact td { padding: 5px 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; margin-top: 4px; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; } .dot.busy { background: #f59e0b; box-shadow: 0 0 0 3px #fef3c7; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .actions { display: flex; gap: 6px; margin-top: 12px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.cols .card p { color: #3b4655; }
.locked { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px; background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line); }
.locked .big { font-size: 48px; }
.copyrow { display: flex; gap: 6px; align-items: stretch; } .copyrow input, .copyrow textarea { flex: 1; font-family: ui-monospace, monospace; font-size: 12px; }
table.kv { width: 100%; border-collapse: collapse; font-size: 12px; } table.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 3px 8px 3px 0; width: 35%; vertical-align: top; } table.kv td { padding: 3px 0; word-break: break-word; white-space: pre-wrap; }

/* Modales et notifications */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border-radius: 12px; width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 18px 20px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .actions { display: flex; gap: 8px; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 380px; }
.toast { background: #1f2937; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); border-left: 4px solid var(--accent); transition: opacity .4s, transform .4s; }
.toast.ok { border-color: #22c55e; } .toast.warn { border-color: #f59e0b; } .toast.err { border-color: #ef4444; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* Session */
#session { position: fixed; inset: 0; background: #0b1220; z-index: 40; display: flex; flex-direction: column; }
#toolbarWrap { background: #111827; color: #e5e7eb; border-bottom: 1px solid #1f2937; }
#toolbar { display: flex; gap: 6px; align-items: center; padding: 6px 10px; flex-wrap: wrap; }
#toolbar .title { margin-right: 6px; }
#toolbar button, #toolbar select { background: #1f2937; color: #e5e7eb; border-color: #374151; padding: 5px 9px; font-size: 13px; }
#toolbar button:hover { background: #273449; }
#toolbar button.on { background: #14532d; border-color: #166534; }
#toolbar button.danger { color: #fca5a5; }
#toolbar .tag { background: #1e3a8a; color: #bfdbfe; }
#status { display: none; background: #78350f; color: #fde68a; padding: 4px 12px; font-size: 13px; } #status.show { display: block; }
#sessBody { flex: 1; display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
body.side-hidden #sessBody { grid-template-columns: 1fr 0; } body.side-hidden #side { display: none; }
#stage { position: relative; display: grid; place-items: center; overflow: hidden; background: #0b1220; }
#screen { max-width: 100%; max-height: 100%; object-fit: contain; outline: none; cursor: default; image-rendering: auto; background: #000; }
canvas#screen:focus { box-shadow: 0 0 0 2px #2563eb; }
#stageMsg { position: absolute; color: #94a3b8; font-size: 15px; }
#dropHint { display: none; position: absolute; inset: 12px; border: 3px dashed #60a5fa; border-radius: 12px; background: rgba(37,99,235,.15); color: #dbeafe; font-size: 20px; place-items: center; pointer-events: none; }
#stage.dragging #dropHint { display: grid; }
#side { background: var(--panel); display: flex; flex-direction: column; min-height: 0; border-left: 1px solid #1f2937; }
#side .tabs { display: flex; border-bottom: 1px solid var(--line); }
#side .tabs button { flex: 1; border: none; border-radius: 0; padding: 10px 4px; background: #f9fafb; border-bottom: 2px solid transparent; justify-content: center; }
#side .tabs button.active { background: #fff; border-bottom-color: var(--accent); font-weight: 600; }
#side .pane { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; min-height: 0; }
.chatlog { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.msg { background: #f1f5f9; padding: 7px 10px; border-radius: 10px; max-width: 90%; align-self: flex-start; }
.msg.tech { background: #dbeafe; align-self: flex-end; } .msg.system { background: none; color: var(--muted); font-size: 12px; align-self: center; }
.msg div { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
#chatForm, .chat form { display: flex; gap: 6px; margin-top: 8px; } #chatForm input, .chat form input { flex: 1; }
.visio video { width: 100%; background: #0f172a; border-radius: 8px; display: none; margin-bottom: 8px; } .visio video.on { display: block; }
.dropzone { border: 2px dashed #b6c2d2; border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: #fafbfd; }
.dropzone.dragging, #fmList.dragging { border-color: var(--accent); background: #eef4ff; }
.xfer { display: flex; flex-direction: column; gap: 3px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.xfer .xname { word-break: break-all; } .xfer small { color: var(--muted); } .xfer.err small { color: var(--err); }
.progress { height: 5px; background: #e5e7eb; border-radius: 3px; overflow: hidden; } .progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; } .xfer.ok .bar { background: #22c55e; }
.fm-path { display: flex; gap: 4px; margin-bottom: 6px; } .fm-path input { flex: 1; font-family: ui-monospace, monospace; font-size: 12px; }
.fm-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
#fmList { border: 2px solid transparent; border-radius: 8px; max-height: 45vh; overflow: auto; }
.fm-table tr { cursor: default; user-select: none; } .fm-table tr:hover td { background: #f8fafc; } .fm-table tr.sel td { background: #dbeafe; }
.notes { white-space: pre-wrap; background: #fffbea; padding: 8px; border-radius: 6px; font-size: 13px; }
details.inv { margin-top: 14px; } details.inv summary { cursor: pointer; font-weight: 600; }

/* Page aidé */
body.guest-active { background: var(--bg); display: block; }
.guest header { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.live { color: var(--ok); font-size: 13px; }
.guest-body { display: grid; grid-template-columns: 1fr 380px; gap: 16px; padding: 16px; max-width: 1200px; margin: 0 auto; }
.guest-body section { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.guest-body .chat { height: calc(100vh - 100px); position: sticky; top: 70px; }
.videos { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; } .videos video { width: 100%; background: #0f172a; border-radius: 8px; display: none; } .videos video.on { display: block; }

@media (max-width: 900px) {
  body.main #app { grid-template-columns: 1fr; } #nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } #nav .grow { display: none; }
  #sessBody { grid-template-columns: 1fr; grid-template-rows: 1fr 45vh; } .guest-body { grid-template-columns: 1fr; } .guest-body .chat { height: 60vh; position: static; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Accès par ID */
.devid { font-family: ui-monospace, monospace; color: #334155; }
.tag.pw-rotating { background: #e0f2fe; } .tag.pw-fixed { background: #fef3c7; } .tag.pw-none { background: #fee2e2; }
fieldset.access { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 10px; }
fieldset.access legend { font-weight: 600; padding: 0 6px; }
.idline { display: flex; align-items: center; gap: 12px; }
.bigid { font-family: ui-monospace, monospace; font-size: 22px; font-weight: 700; letter-spacing: .06em; color: var(--accent); }
.check { font-weight: 400; display: inline-flex; align-items: center; gap: 6px; }

/* Groupes de postes */
.dev-layout { display: grid; grid-template-columns: 240px 1fr; gap: 18px; align-items: start; }
#groupPane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; position: sticky; top: 12px; max-height: calc(100vh - 40px); overflow: auto; }
.gitem { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.gitem:hover { background: #f1f5f9; } .gitem.active { background: #e8f0fe; font-weight: 600; } .gitem.drop { border-color: var(--accent); background: #eef4ff; }
.gitem .gname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gitem .gcount { font-size: 12px; color: var(--muted); background: #f1f5f9; border-radius: 10px; padding: 0 7px; }
.gitem .gedit { padding: 0 5px; border: none; background: none; opacity: 0; } .gitem:hover .gedit { opacity: 1; }
.gicon { width: 14px; text-align: center; font-size: 12px; }
.gdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.ghead { display: flex; justify-content: space-between; align-items: center; margin: 12px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.ghead button { padding: 0 7px; font-size: 15px; }
.gempty { padding: 4px 8px; }
.gchip { display: inline-block; font-size: 11px; border: 1px solid; border-radius: 10px; padding: 0 7px; margin: 3px 4px 0 0; background: #fff; }
.tag.unatt { background: #ede9fe; color: #5b21b6; margin-left: 6px; }
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: #eef4ff; border: 1px solid #c7d7fe; border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
table.grid tr.sel td { background: #f0f6ff; }
table.grid tr[draggable] { cursor: grab; }
.swatches { display: flex; gap: 8px; margin-top: 4px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.swatch input { appearance: none; width: 10px; height: 10px; border-radius: 50%; margin: 0; } .swatch input:checked { background: #fff; }
.unatt-box { background: #f5f3ff; border: 1px solid #ddd6fe; border-radius: 8px; padding: 10px; align-items: flex-start !important; }
.groups-box { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.groups-box legend { font-weight: 600; padding: 0 6px; }
.gpick { gap: 6px; }
@media (max-width: 900px) { .dev-layout { grid-template-columns: 1fr; } #groupPane { position: static; } }
