/* Visiops — feuille de style unique */
:root {
  --bg: #f3f5f6; --surface: #ffffff; --surface-2: #eef2f3; --text: #142024; --muted: #5d6c71;
  --line: #d9e0e2; --primary: #0b6e6e; --primary-ink: #ffffff; --danger: #c0392b; --ok: #1f8a4c; --warn: #b7791f;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --dark: #0b1416; --dark-2: #132326;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1719; --surface: #152326; --surface-2: #1b2d31; --text: #e4ecee; --muted: #93a4a9; --line: #26393e; --primary: #2bb3a8; --primary-ink: #04201e; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary); }
h1 { font-size: 1.35rem; margin: 0 0 .6rem; } h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }

/* En-tête */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1.2rem; background: var(--dark); color: #e9f2f3; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.app-logo { height: 30px; }
.brand-mark { width: 26px; height: 26px; border-radius: 50%; border: 3px solid #2bb3a8; position: relative; display: inline-block; }
.brand-mark::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: #2bb3a8; }
.brand-mark.big { width: 56px; height: 56px; border-width: 5px; margin: 0 auto 1rem; display: block; }
.brand-mark.big::after { inset: 11px; }
.nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.nav a { color: #cfe3e5; text-decoration: none; } .nav a:hover { color: #fff; }
.nav-user { color: #8fb3b7; font-size: .9rem; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.2rem; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

/* Composants */
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.1rem; }
.form { display: grid; gap: .8rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.form label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%; }
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); padding: .55rem 1rem; border-radius: 8px; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(.97); } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-small { padding: .35rem .7rem; font-size: .85rem; }
.btn-big { width: 100%; padding: .95rem; font-size: 1.05rem; }
.btn.on, .tool.on { outline: 2px solid var(--primary); }
.btn.off { text-decoration: line-through; opacity: .7; }
.inline { display: inline; }
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: .9rem; border: 1px solid; }
.alert-success { background: #e7f6ed; border-color: #b6e2c6; color: #1b5e37; }
.alert-error { background: #fdecea; border-color: #f5c2bd; color: #8a2a20; }
.alert-info { background: #e8f2f8; border-color: #bcd8ea; color: #1d4f6e; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.actions { white-space: nowrap; display: flex; gap: .35rem; flex-wrap: wrap; }
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.badge-wait { background: #fff3d6; color: #7a5200; } .badge-live { background: #d9f5e4; color: #11663a; } .badge-off { background: var(--surface-2); color: var(--muted); }
.steps { padding-left: 1.2rem; margin: 0; } .steps li { margin-bottom: .4rem; }
pre.console { background: #0b1416; color: #b9f0d9; padding: .8rem; border-radius: 8px; max-height: 340px; overflow: auto; font-size: .8rem; white-space: pre-wrap; }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .4rem .8rem; border-radius: 8px; text-decoration: none; background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.tabs a.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .8rem; }

/* Authentification */
.page-auth .container { display: grid; place-items: center; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem; width: 100%; max-width: 400px; box-shadow: var(--shadow); margin: 2rem auto; }

/* ───── Poste expert ───── */
.page-session .container { max-width: none; padding: .9rem; }
.expert-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: .9rem; align-items: start; }
@media (max-width: 1000px) { .expert-layout { grid-template-columns: 1fr; } }
.session-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .6rem; }
.session-head h1 { margin: 0; } .session-head h1 small { font-weight: 400; font-size: .9rem; }
.stage { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; max-height: calc(100vh - 230px); width: 100%; }
.stage video#remote-video, .stage #frozen-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.annot-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.annot-canvas.editable { cursor: crosshair; }
.pip { position: absolute; right: 12px; bottom: 12px; width: 22%; max-width: 220px; border-radius: 8px; border: 2px solid rgba(255,255,255,.6); background: #111; z-index: 3; object-fit: cover; }
.mirror { transform: scaleX(-1); }
.frozen-badge { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: #0a84ff; color: #fff; padding: .25rem .7rem; border-radius: 99px; font-size: .8rem; font-weight: 700; z-index: 4; }
.tech-top .frozen-badge { position: static; transform: none; }
.hud { position: absolute; left: 12px; top: 12px; display: flex; align-items: center; gap: .5rem; background: rgba(0,0,0,.55); color: #fff; padding: .35rem .6rem .35rem .35rem; border-radius: 99px; z-index: 4; font-size: .8rem; }
.hud-text { display: grid; line-height: 1.15; } .hud-text strong { font-size: .95rem; }
.compass { width: 36px; height: 36px; border-radius: 50%; border: 2px solid rgba(255,255,255,.8); position: relative; display: grid; place-items: start center; }
.compass > span { font-size: 9px; font-weight: 800; margin-top: 1px; }
.needle { position: absolute; left: 50%; top: 50%; width: 4px; height: 26px; margin: -13px 0 0 -2px; transition: transform .25s linear;
  background: linear-gradient(#ff3b30 0 50%, #fff 50% 100%); border-radius: 2px; }
.call-tools { display: flex; flex-wrap: wrap; gap: .6rem; margin: .7rem 0; align-items: center; }
.tool-group { display: flex; gap: .3rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .25rem; }
.tool { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--text); font-size: 1.05rem; cursor: pointer; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.swatch.on { outline: 2px solid var(--text); outline-offset: 1px; }
.link-box { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.link-box input { flex: 1; min-width: 220px; font-size: .8rem; }
.status-pill { padding: .25rem .7rem; border-radius: 99px; font-size: .8rem; font-weight: 700; white-space: nowrap; background: var(--surface-2); }
.status-pill.ok { background: #d9f5e4; color: #11663a; } .status-pill.wait { background: #fff3d6; color: #7a5200; } .status-pill.bad { background: #fdecea; color: #8a2a20; }
.presence { font-weight: 700; } .presence.on { color: var(--ok); } .presence.off { color: var(--muted); }
.side-col .panel { padding: .8rem; margin-bottom: .9rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.panel-head h2 { margin: 0; }
.map { height: 330px; border-radius: 8px; background: var(--surface-2); }
.map-photo { background: none; border: 0; }
.map-photo img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; border: 2px solid #ffd60a; position: absolute; left: 8px; top: 8px; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.map-photo-arrow { position: absolute; inset: 0; }
.map-photo-arrow::before { content: ""; position: absolute; left: 50%; top: -6px; margin-left: -7px; border: 7px solid transparent; border-bottom: 12px solid #ffd60a; }
.map-popup img { width: 280px; max-width: 100%; border-radius: 6px; display: block; margin-bottom: .3rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .4rem; max-height: 200px; overflow-y: auto; }
.thumb { position: relative; display: block; aspect-ratio: 4/3; border-radius: 6px; overflow: hidden; background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-tag { position: absolute; right: 3px; bottom: 3px; background: rgba(0,0,0,.65); color: #fff; font-size: .7rem; padding: 0 .3rem; border-radius: 4px; }
.chat-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: .35rem; }
.chat-list li { display: grid; padding: .4rem .6rem; border-radius: 10px; max-width: 88%; }
.chat-list li.mine { align-self: flex-end; background: var(--primary); color: var(--primary-ink); }
.chat-list li.theirs { align-self: flex-start; background: var(--surface-2); }
.chat-list li.system { align-self: center; color: var(--muted); font-size: .8rem; font-style: italic; background: none; }
.chat-list .meta { font-size: .7rem; opacity: .75; } .chat-list .text { white-space: pre-wrap; word-break: break-word; }
.chat-form { display: flex; gap: .4rem; margin-top: .5rem; }
.toasts { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); display: grid; gap: .4rem; z-index: 2000; width: min(92vw, 420px); pointer-events: none; }
.toast { background: rgba(20,32,36,.94); color: #fff; padding: .6rem .9rem; border-radius: 10px; font-size: .9rem; box-shadow: var(--shadow); }
.toast-error { background: rgba(160,40,30,.95); } .toast-ok { background: rgba(20,120,70,.95); }

/* ───── Écran technicien (mobile) ───── */
.page-tech { background: var(--dark); color: #e8f1f2; min-height: 100dvh; overscroll-behavior: none; }
.tech-screen { min-height: 100dvh; display: grid; place-items: center; padding: 1.2rem; }
.tech-card { background: var(--dark-2); border-radius: 16px; padding: 1.6rem 1.3rem; max-width: 420px; width: 100%; text-align: center; }
.tech-card p { color: #c2d4d7; }
.perm-list { list-style: none; padding: 0; margin: 1rem 0; text-align: left; display: grid; gap: .6rem; }
.perm-list li { display: flex; gap: .6rem; align-items: flex-start; background: rgba(255,255,255,.05); padding: .6rem .7rem; border-radius: 10px; }
.tech-call { position: fixed; inset: 0; background: #000; overflow: hidden; }
.tech-call #local-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tech-call #frozen-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; z-index: 1; }
.tech-call .annot-canvas { z-index: 2; pointer-events: none; }
.tech-call .pip { top: calc(env(safe-area-inset-top) + 60px); bottom: auto; width: 26vw; max-width: 140px; aspect-ratio: 3/4; }
.tech-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; display: flex; gap: .5rem; align-items: center; justify-content: space-between; flex-wrap: wrap; z-index: 4; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.small-hud { position: static; }
.tech-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around; align-items: center; padding: 12px 6px calc(env(safe-area-inset-bottom) + 12px); background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.round { position: relative; width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 1.3rem; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(6px); }
.round span { position: absolute; bottom: -17px; font-size: .62rem; white-space: nowrap; }
.round.big { width: 66px; height: 66px; background: #fff; color: #000; font-size: 1.6rem; }
.round.danger { background: #d6342a; }
.round.on { background: #ffd60a; color: #000; }
.round.off { background: rgba(214,52,42,.8); }
.round:disabled { opacity: .35; }
.badge-dot { position: absolute; top: -2px; right: -2px; background: #ff3b30; color: #fff; font-size: .7rem; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; }
.tech-chat { position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--dark-2); border-radius: 16px 16px 0 0; padding: 1rem 1rem calc(env(safe-area-inset-bottom) + 1rem); max-height: 60dvh; display: flex; flex-direction: column; }
.tech-chat .chat-list { flex: 1; max-height: none; }
.tech-chat .chat-list li.theirs { background: rgba(255,255,255,.1); color: #fff; }
.tech-chat input { background: #0b1416; color: #fff; border-color: #2a3e42; }
.page-tech .btn-ghost { color: #fff; border-color: #2a3e42; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 20; }
.flash.go { animation: flash .4s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.badge-caller { background: #c0392b; color: #fff; vertical-align: middle; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.mode-switch label { display: flex; align-items: center; gap: .45rem; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; font-weight: 600; cursor: pointer; }
.mode-switch label:has(input:checked) { border-color: var(--primary); background: var(--surface-2); }
.mode-switch input { width: auto; }
.loc-panel .loc-row { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; padding: .35rem 0; border-top: 1px solid var(--line); }
.loc-panel .loc-row:first-of-type { border-top: 0; }
#loc-address { font-size: 1rem; }
.unmute { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 6; border: 0; border-radius: 99px; padding: .6rem 1.1rem; font: inherit; font-weight: 700; background: #ffd60a; color: #000; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.tech-call .unmute { bottom: auto; top: calc(env(safe-area-inset-top) + 64px); }
.diag { display: grid; grid-template-columns: auto 1fr; gap: .25rem .7rem; margin: .6rem 0; }
.diag dt { color: var(--muted); } .diag dd { margin: 0; word-break: break-word; }
.tech-call .status-pill { cursor: pointer; }
.tech-diag { position: absolute; left: 10px; right: 10px; top: calc(env(safe-area-inset-top) + 60px); z-index: 12; background: rgba(11,20,22,.95); color: #e8f1f2; border-radius: 12px; padding: .8rem; max-height: 60dvh; overflow-y: auto; }
.tech-diag .diag dt { color: #93a4a9; }
.zoom-group input[type=range] { width: 120px; padding: 0; accent-color: var(--primary); border: 0; }
.zoom-group .tool:disabled, .zoom-group input:disabled { opacity: .4; }
.zoom-badge { background: rgba(0,0,0,.6); color: #ffd60a; font-weight: 800; padding: .2rem .55rem; border-radius: 99px; font-size: .85rem; }
[hidden] { display: none !important; }
.org-name { font-weight: 700; color: #2bb3a8; margin-top: -.4rem; }
.preset { margin: .4rem 0 1rem; background: var(--surface-2); border-radius: 8px; padding: .6rem .8rem; } .preset summary { cursor: pointer; } .preset .table td { padding: .3rem .4rem; }
#gallery-empty { grid-column: 1 / -1; }
