/* Défi01 Surveillance : même feuille de style que le CRM Défi01 (parties communes), puis les composants propres au comptage.
   Parti pris : interface monochrome et calme ; l'orange Défi01 sert uniquement de repère.
   Police : Instrument Sans (SIL OFL, fonts/OFL.txt). */

@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans-latin-ext.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #18171c;
  --ink-soft: #66646d;
  --ink-faint: #a3a1aa;
  --paper: #ffffff;
  --subtle: #f6f6f7;
  --line: #e8e7eb;
  --line-strong: #d2d0d7;
  --signal: #f29c1f;
  --signal-ink: #9a5a00;
  --signal-bg: #fdf3e3;
  --ok: #0e7a6c;
  --ok-bg: #e9f4f1;
  --danger: #be2f28;
  --danger-bg: #fcedec;
  --visit: #b8235e;
  --visit-bg: #fbecf2;
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar: 248px;
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/1.55 var(--font); color: var(--ink); background: var(--paper); font-feature-settings: "ss01" 0; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 600; }
h1 { font-size: 1.75rem; letter-spacing: -.022em; }
h2 { font-size: 1rem; letter-spacing: -.005em; margin-bottom: .85rem; }
h3 { font-size: .87rem; color: var(--ink-soft); margin: 1.25rem 0 .4rem; }
h2 + h3 { margin-top: .25rem; }
h4 { font-size: .9rem; font-weight: 600; margin: 1rem 0 .4rem; }
h3 + h4 { margin-top: .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: currentColor; }
strong, b { font-weight: 600; }
code { font: .85em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code.wrap { word-break: break-all; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--signal-bg); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 0; }
.muted, .hint { color: var(--ink-soft); font-size: .87rem; }
.hint { display: block; font-weight: 400; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.req { color: var(--danger); }

/* ───── Structure ───── */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--subtle); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1.25rem .75rem 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); padding: 0 .55rem 1.5rem; }
.brand::before { content: ""; width: .7rem; height: .7rem; border-radius: 2px; background: var(--signal); flex: none; }
.brand-mark { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-sub { font-size: .87rem; color: var(--ink-soft); }
.brand-center { justify-content: center; padding: 0 0 1.75rem; }
.sidebar nav { flex: 1; display: grid; align-content: start; gap: 1.1rem; }
.nav-group { display: grid; gap: .15rem; }
.nav-heading { margin: 0; padding: 0 .6rem .2rem; font-size: .78rem; font-weight: 500; color: var(--ink-faint); }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.sidebar nav a { position: relative; display: flex; align-items: center; gap: .65rem; padding: .4rem .6rem; border-radius: var(--radius-sm); color: var(--ink-soft); text-decoration: none; font-size: .92rem; }
.sidebar nav a:hover { color: var(--ink); background: #ececef; }
.sidebar nav a[aria-current="page"] { color: var(--ink); background: var(--paper); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.sidebar nav a[aria-current="page"]::before { content: ""; position: absolute; left: -.75rem; top: .45rem; bottom: .45rem; width: 3px; border-radius: 0 2px 2px 0; background: var(--signal); }
.nav-icon { display: inline-flex; width: 1.05rem; height: 1.05rem; flex: none; }
.nav-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[data-reminder-count]:not(:empty) { margin-left: .2rem; color: var(--signal-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.sidebar-user { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .9rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sidebar-user a { display: grid; min-width: 0; color: var(--ink); text-decoration: none; padding: .3rem .55rem; border-radius: var(--radius-sm); font-size: .9rem; line-height: 1.3; }
.sidebar-user a[aria-current="page"], .sidebar-user a:hover { background: #ececef; }
.sidebar-user a strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user a span { font-size: .8rem; color: var(--ink-soft); }
.sidebar .btn-ghost { border-color: transparent; color: var(--ink-soft); font-weight: 500; }
.sidebar .btn-ghost:hover { color: var(--ink); background: #ececef; border-color: transparent; }
main { padding: 2.25rem clamp(1rem, 3.5vw, 3rem) 4rem; min-width: 0; max-width: 1480px; }
main:focus { outline: none; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1.5rem; margin-bottom: 1.75rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ───── Composants ───── */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.35rem; margin-bottom: 1.25rem; }
.card > h2:first-child { margin-top: 0; }
.card.late { box-shadow: inset 2px 0 0 var(--danger); }
.card.danger-zone { border-color: #efc9c6; }
.empty { color: var(--ink-soft); }
.card.empty { text-align: center; padding: 2.5rem 1rem; border-style: dashed; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 1.25rem; align-items: start; margin-bottom: 1.25rem; }
.grid-2 > .card { margin-bottom: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.25rem; padding: .35rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); font: inherit; font-size: .92rem; font-weight: 500; line-height: 1.2; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--ink-faint); background: var(--subtle); color: var(--ink); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #34323b; border-color: #34323b; color: #fff; }
.btn-danger { background: var(--paper); border-color: #e3aaa6; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--subtle); border-color: transparent; }
.btn-small { min-height: 1.9rem; padding: .2rem .65rem; font-size: .85rem; }
.btn[aria-current="page"], .btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.button-row, .form-actions, .row-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.form-actions { margin-top: .25rem; }
.inline-form { display: inline-block; margin-top: .75rem; }
.button-row .inline-form, .row-actions .inline-form { margin-top: 0; }

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .05rem .5rem; border-radius: 4px; background: var(--subtle); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); font-size: .8rem; font-weight: 500; line-height: 1.6; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); box-shadow: none; color: var(--ok); }
.badge-danger { background: var(--danger-bg); box-shadow: none; color: var(--danger); }
.badge-warn { background: var(--signal-bg); box-shadow: none; color: var(--signal-ink); }
.count-pill { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; border-radius: 4px; color: var(--ink-soft); font-size: .8rem; font-weight: 500; text-align: center; font-variant-numeric: tabular-nums; }
.count { color: var(--ink-soft); font-size: .87rem; margin-bottom: .6rem; }

.flash { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem; border: 1px solid; font-size: .93rem; }
.flash-success { background: var(--ok-bg); border-color: #bfe0d8; color: #0a5448; }
.flash-error { background: var(--danger-bg); border-color: #efc9c6; color: #7d1c17; }
.flash ul { margin: .4rem 0; padding-left: 1.2rem; }
.flash p:last-child { margin-bottom: 0; }

/* ───── Formulaires ───── */
label { display: block; font-weight: 500; font-size: .88rem; }
label > input, label > select, label > textarea { display: block; margin-top: .3rem; }
label > .hint { margin-top: .25rem; }
input, select, textarea { font: inherit; font-size: .93rem; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: .4rem .65rem; min-height: 2.25rem; width: 100%; }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:hover, select:hover, textarea:hover { border-color: var(--ink-faint); }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgb(242 156 31 / 28%); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
input:disabled, select:disabled, textarea:disabled { background: var(--subtle); color: var(--ink-soft); }
textarea { resize: vertical; line-height: 1.5; }
input[type="checkbox"], input[type="radio"] { width: 1.05rem; min-height: 1.05rem; height: 1.05rem; padding: 0; accent-color: var(--ink); box-shadow: none; }
input[type="file"] { padding: .3rem; }
label.check { display: flex; align-items: center; gap: .55rem; font-weight: 400; font-size: .93rem; }
.stack { display: grid; gap: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 1rem 1.1rem; align-items: start; }
.form-grid > fieldset { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 1rem 1.1rem; align-items: start; }
.form-grid .wide, .form-grid .form-actions { grid-column: 1 / -1; }
.form-grid.compact { margin-top: 1rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: .93rem; padding: 0 .4rem; }
.filters label.check, .agenda-filter label.check { min-height: 2.25rem; align-self: end; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: .8rem; align-items: end; }
.inline-fields { display: flex; gap: .5rem; margin-bottom: .75rem; }
.inline-fields select { flex: 1; min-width: 0; }
details.disclosure { margin: .5rem 0 1rem; }
details.disclosure > summary { list-style: none; cursor: pointer; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary:not(.btn) { font-weight: 500; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: .18em; }
details.disclosure > summary:not(.btn):hover { text-decoration-color: currentColor; }
details.disclosure[open] > summary { margin-bottom: .85rem; }

/* ───── Tableaux ───── */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1.25rem; }
.card .table-wrap { border-radius: var(--radius-sm); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { padding: .65rem .9rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: .82rem; font-weight: 500; color: var(--ink-soft); white-space: nowrap; }
thead th { border-bottom-color: var(--line-strong); }
td a { font-weight: 500; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafb; }
.pagination { display: flex; gap: .75rem; align-items: center; justify-content: center; margin: 1.25rem 0; font-size: .9rem; }
.note-internal { color: var(--signal-ink); font-size: .87rem; }

/* ───── Listes ───── */
dl.facts { display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: .45rem 1.25rem; margin: 0 0 .85rem; font-size: .93rem; }
dl.facts dt { color: var(--ink-soft); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
ul.links li { display: grid; }
ul.links span { color: var(--ink-soft); font-size: .87rem; }
.task-list, .contact-list { list-style: none; margin: 0 0 .85rem; padding: 0; }
.task-list li, .contact-list li { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.task-list li:first-child, .contact-list li:first-child { padding-top: .2rem; }
.task-list li:last-child, .contact-list li:last-child { border-bottom: 0; }
.task-list li > div:first-child, .contact-list li > div { display: grid; min-width: 0; }
.task-list strong, .contact-list strong { font-weight: 500; }
.task-list span, .contact-list span { color: var(--ink-soft); font-size: .87rem; overflow-wrap: anywhere; }
.task-list li.late strong { color: var(--danger); }
.task-list.closed strong { font-weight: 400; color: var(--ink-soft); text-decoration: line-through; }
.notes, .tl-notes { white-space: pre-wrap; }

/* ───── Indicateurs ───── */
/* Une seule bande, séparée par des filets : les chiffres se lisent d'un coup d'œil, sans mosaïque de cartes. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1.75rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kpi { display: grid; align-content: start; gap: .3rem; padding: 1rem 1.25rem 1.1rem; text-decoration: none; color: var(--ink); box-shadow: -1px 0 0 var(--line); }
a.kpi:hover { background: var(--subtle); }
.kpi-value { font-size: 2.1rem; font-weight: 500; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--ink-soft); font-size: .85rem; line-height: 1.35; }
.kpi-alert .kpi-value { color: var(--danger); }
.kpi-alert .kpi-label::before { content: ""; display: inline-block; width: .45rem; height: .45rem; border-radius: 50%; background: var(--danger); margin-right: .4rem; vertical-align: .08em; }

/* ───── Pages hors navigation ───── */
.bare-body { background: var(--subtle); }
.bare { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.bare-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 2.25rem 2rem 2rem; width: min(100%, 420px); }
.bare-card h1 { font-size: 1.35rem; margin: 0 0 1.25rem; text-align: center; }
.bare-card .btn-primary { width: 100%; min-height: 2.5rem; margin-top: .35rem; }
.bare-card form + .hint, .bare-card form + p { margin-top: 1rem; }
.bare-card .card { border: 0; padding: 0; }
.error-code { font-size: .87rem; font-weight: 600; color: var(--danger); }
.steps { padding-left: 1.2rem; display: grid; gap: 1rem; }
.qr { width: 200px; margin: .5rem 0; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { background: var(--subtle); box-shadow: inset 0 0 0 1px var(--line); padding: .15rem .45rem; border-radius: 4px; user-select: all; overflow-wrap: anywhere; }
.secret.big { font-size: 1.2rem; padding: .5rem .8rem; display: inline-block; letter-spacing: .04em; }

/* ───── Mobile : la navigation passe en barre basse défilante ───── */
@media (max-width: 860px) {
  .app { display: block; }
  .sidebar { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; align-items: center; padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom)); z-index: 5; overflow-x: auto; background: rgb(255 255 255 / 96%); border-right: 0; border-top: 1px solid var(--line); }
  .sidebar .brand, .nav-heading { display: none; }
  .sidebar nav { display: flex; gap: 0; }
  .nav-group { display: contents; }
  .sidebar ul { display: flex; gap: 0; }
  .sidebar nav a { flex-direction: column; gap: .2rem; font-size: .68rem; padding: .4rem .5rem; min-width: 4.2rem; text-align: center; white-space: nowrap; box-shadow: none; }
  .sidebar nav a[aria-current="page"] { background: transparent; box-shadow: none; }
  .sidebar nav a[aria-current="page"]::before { left: 30%; right: 30%; top: -.3rem; bottom: auto; width: auto; height: 2px; border-radius: 0 0 2px 2px; }
  .nav-icon { width: 1.2rem; height: 1.2rem; }
  .sidebar-user { border-top: 0; margin: 0; border-left: 1px solid var(--line); padding: 0 0 0 .4rem; }
  .sidebar-user a { font-size: .68rem; min-width: 4.2rem; text-align: center; padding: .35rem .5rem; }
  .sidebar-user a span { display: none; }
  .sidebar .btn-ghost { width: auto; white-space: nowrap; }
  main { padding: 1.5rem 1rem 6.5rem; }
  h1 { font-size: 1.45rem; }
  .page-header { margin-bottom: 1.25rem; }
  .detail { grid-template-columns: 1fr; }
  th, td { padding: .55rem .65rem; }
  .card { padding: 1rem; }
  .kpi { box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line); }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .sidebar nav a, input, select, textarea { transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s; }
}


/* ───── Surveillance : éléments communs ───── */
[hidden] { display: none !important; }
/* La connexion occupe toute la largeur : la largeur maximale de main ne vaut que pour les pages de l’application. */
main.bare { max-width: none; }
.crumbs { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: -.75rem 0 .6rem; font-size: .87rem; color: var(--ink-faint); }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.lede { color: var(--ink-soft); max-width: 62rem; margin-bottom: 1.25rem; }
.section-title { font-size: 1.15rem; margin: 2rem 0 .5rem; }
.kpi-small { font-size: 1rem; letter-spacing: 0; line-height: 1.6; }
.tone-ok { color: var(--ok); }
.tone-warn { color: var(--signal-ink); }
.tone-danger { color: var(--danger); }
.warn-text { color: var(--signal-ink); }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; color: var(--ink-soft); font-size: .85rem; margin: -.5rem 0 1.25rem; }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { display: inline-block; width: .9rem; height: .6rem; border-radius: 2px; border: 2px solid; }
.swatch-counted { border-color: var(--signal); }
.swatch-ignored { border-color: var(--ink-faint); border-style: dashed; }
.swatch-zone { border-color: var(--ok); background: rgb(14 122 108 / 18%); }
.swatch-ignore { border-color: var(--danger); background: rgb(190 47 40 / 18%); }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: end; margin-bottom: 1.25rem; }
.toolbar label { min-width: 14rem; }
.toolbar-note { margin: 0 0 .45rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ───── Salles : vue d’ensemble ───── */
.room-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1.25rem; }
.room-card { display: grid; align-content: start; gap: .75rem; height: 100%; padding: 1.1rem 1.25rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); text-decoration: none; }
.room-card:hover { border-color: var(--line-strong); background: #fcfcfd; }
.room-card.status-over { border-color: #efc9c6; box-shadow: inset 3px 0 0 var(--danger); }
.room-card.status-occupied { box-shadow: inset 3px 0 0 var(--signal); }
.room-card.status-disabled { opacity: .65; }
.room-card-head { display: flex; justify-content: space-between; align-items: start; gap: .75rem; }
.room-card-head h2 { margin: 0; font-size: 1.05rem; }
.room-count { display: flex; align-items: baseline; gap: .55rem; margin: 0; }
.room-count-value { font-size: 2.75rem; font-weight: 500; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.status-over .room-count-value { color: var(--danger); }
.room-count-label { color: var(--ink-soft); font-size: .9rem; }
.room-spaces { list-style: none; margin: 0; padding: 0; display: grid; font-size: .9rem; }
.room-spaces li { display: flex; justify-content: space-between; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.room-spaces li:last-child { border-bottom: 0; }
.room-spaces span { color: var(--ink-soft); }
.room-spaces strong { font-weight: 500; font-variant-numeric: tabular-nums; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: .35rem; }
.thumb { aspect-ratio: 16 / 9; border-radius: 4px; background: var(--subtle); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb-off { box-shadow: inset 0 0 0 2px var(--danger); }
.thumb-off img { opacity: .35; }
.room-meta { margin: 0; color: var(--ink-faint); font-size: .8rem; }

/* ───── Salle : toutes les caméras ───── */
.space { margin-bottom: 2rem; }
.space-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem .75rem; margin-bottom: .75rem; }
.space-head h2 { margin: 0; font-size: 1.1rem; }
.space-head .count-pill { font-size: .95rem; font-weight: 600; color: var(--ink); background: var(--subtle); box-shadow: inset 0 0 0 1px var(--line); padding: 0 .5rem; }
.space-head .muted { font-size: .85rem; }
.inline-label { display: inline-flex; align-items: center; gap: .5rem; font-weight: 400; color: var(--ink-soft); margin-left: auto; }
.inline-label select { margin: 0; min-height: 1.9rem; padding: .15rem .5rem; font-size: .85rem; }
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 1rem; }
.cam { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.cam.cam-down { border-color: #efc9c6; }
.cam.cam-off { opacity: .6; }
.cam.drawing { border-color: var(--signal); box-shadow: 0 0 0 3px rgb(242 156 31 / 22%); }
.cam-frame { position: relative; background: var(--ink); aspect-ratio: 16 / 9; }
.cam-frame canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.cam-placeholder { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--ink-faint); font-size: .9rem; }
.cam figcaption { display: flex; flex-wrap: wrap; gap: .3rem .75rem; align-items: center; padding: .6rem .85rem; font-size: .9rem; }
.cam figcaption strong { font-weight: 600; }
.cam figcaption select { width: auto; margin-left: auto; min-height: 1.9rem; padding: .15rem .5rem; font-size: .85rem; }
.cam-error { margin: 0; padding: 0 .85rem .6rem; color: var(--danger); font-size: .85rem; overflow-wrap: anywhere; }
.camera-test .cam-error, .tg-tools .cam-error { padding: 0; }

/* ───── Zones ───── */
.zone-canvas { touch-action: none; user-select: none; -webkit-user-select: none; }
.cam.cam-wide { grid-column: 1 / -1; }
.cam .cam-frame { max-height: 78vh; margin-inline: auto; }
.zone-hint:empty { display: none; }
.zone-tools .swatch { margin-right: .1rem; }
/* Agrandir / Réduire: on the image itself, top right */
.frame-btn { position: absolute; top: .55rem; right: .55rem; display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .65rem .3rem .5rem; border: 0; border-radius: var(--radius-sm); background: rgb(24 23 28 / 78%); color: #fff; font: inherit; font-size: .82rem; font-weight: 500; cursor: pointer; backdrop-filter: blur(4px); }
.frame-btn:hover { background: var(--ink); }
.frame-btn svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* While drawing: a highlighted bar with an obvious way to finish */
.drawbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; margin: 0 .85rem .8rem; padding: .6rem .75rem .6rem .9rem; border-radius: var(--radius-sm); background: var(--signal-bg); box-shadow: inset 3px 0 0 var(--signal); }
.drawbar-text { margin: 0; font-size: .9rem; }
.drawbar-text span { color: var(--ink-soft); }
.drawbar-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.drawbar .btn-primary:disabled { opacity: .45; cursor: not-allowed; }
/* Unsaved changes: pinned to the bottom of the screen until saved */
.savebar { position: sticky; bottom: 1rem; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; margin-top: 1.5rem; padding: .75rem .9rem .75rem 1.1rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper); box-shadow: 0 6px 24px rgb(24 23 28 / 14%), inset 3px 0 0 var(--signal); font-weight: 500; }
.savebar.savebar-ok { box-shadow: 0 6px 24px rgb(24 23 28 / 14%), inset 3px 0 0 var(--ok); color: var(--ok); }
.savebar.savebar-ok .button-row { display: none; }
@media (max-width: 860px) { .savebar { bottom: calc(4.8rem + env(safe-area-inset-bottom)); } }
.zone-tools { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 .85rem .75rem; }
.zone-tools .btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.cam > .hint { padding: 0 .85rem .7rem; margin: 0; }
.help-card > summary { font-weight: 600; }
.help-card .steps { margin: 0; }

/* ───── Administration ───── */
.space-card { box-shadow: inset 3px 0 0 var(--line-strong); }
.space-form { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: end; }
.space-form label { flex: 1 1 14rem; }
.space-card > .hint { margin: .6rem 0 1rem; }
.space-card .table-wrap { margin-bottom: .9rem; }
a.badge { text-decoration: none; }
.camera-layout { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.camera-test img { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); margin-top: .75rem; background: var(--ink); }
.url-helper { background: var(--subtle); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; }
.url-helper > summary { cursor: pointer; font-weight: 500; font-size: .93rem; }
.url-helper[open] > summary { margin-bottom: .85rem; }
.url-helper .form-grid { margin-bottom: .75rem; }
.camera-test img { max-height: 70vh; object-fit: contain; }
.url-helper .btn { margin-top: .75rem; }
.tg-tools { margin-top: 1rem; }
.card > .form-actions, .card .form-grid + .form-actions { margin-top: 1.25rem; }
.card > label.check { margin: .6rem 0; }
.tg-chats { margin-top: .75rem; }
.tg-chats li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* ───── Alertes ───── */
.alert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.alert-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem 1.25rem; padding: 1rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); }
.alert-item.alert-open { box-shadow: inset 3px 0 0 var(--signal); }
.alert-actions { grid-column: 2; grid-row: 1; align-self: start; display: flex; gap: .4rem; align-items: center; }
.alert-head { display: flex; flex-wrap: wrap; gap: .3rem .75rem; align-items: center; font-size: .87rem; }
.alert-head time { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.alert-title { margin: .45rem 0 .2rem; font-weight: 600; }
.alert-title a { color: inherit; text-decoration: none; }
.alert-title a:hover { text-decoration: underline; }
.alert-line { margin: 0; color: var(--ink-soft); font-size: .93rem; overflow-wrap: anywhere; }
.alert-photos { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .5rem; }
.alert-photos img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-sm); background: var(--subtle); }
.badge.badge-open { background: var(--signal-bg); box-shadow: none; color: var(--signal-ink); font-weight: 600; }
.badge.badge-open::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: var(--signal); }

/* Page d'une alerte : photos de l'alerte, puis la salle en direct */
.alert-summary .alert-head { margin-bottom: .55rem; }
.alert-section { margin-top: 1.75rem; }
.alert-section > h2 { font-size: 1.1rem; }
.alert-photos-large { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 1rem; }
.alert-photos-large figure { margin: 0; }
.alert-photos-large img { object-fit: contain; background: var(--ink); }
.alert-photos-large figcaption { margin-top: .35rem; font-size: .85rem; }

@media (max-width: 860px) {
  .room-count-value { font-size: 2.3rem; }
  .cam-grid { grid-template-columns: 1fr; }
  .alert-item { grid-template-columns: 1fr; }
  .alert-actions { grid-column: 1; grid-row: auto; }
}

/* ───── Caméra désactivée : identifiants incorrects ───── */
.badge.badge-critical { background: var(--danger); box-shadow: none; color: #fff; font-weight: 600; font-size: .82rem; padding: .15rem .55rem; }
a.badge.badge-critical:hover { background: #9e2520; }
.auth-alert { margin: 0; padding: .55rem .75rem; border-radius: var(--radius-sm); background: var(--danger); color: #fff; font-size: .9rem; font-weight: 600; }
.auth-alert a { color: #fff; text-decoration-color: rgb(255 255 255 / 60%); margin-left: .35rem; }
main > .auth-alert { margin-bottom: 1.25rem; padding: .8rem 1rem; font-size: 1rem; }
.cam-auth-badge { display: none; }
.cam.cam-auth { opacity: 1; border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.cam.cam-auth .cam-placeholder { display: none; }
.cam.cam-auth .cam-auth-badge { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .35rem; padding: 1rem; text-align: center; background: rgb(190 47 40 / 92%); color: #fff; }
.cam-auth-badge strong { font-size: 1.15rem; }
.cam-auth-badge span { font-size: .9rem; opacity: .9; }
.cam-auth-badge .btn { margin-top: .4rem; background: #fff; border-color: #fff; color: var(--danger); font-weight: 600; }
.auth-banner { margin-bottom: 1.25rem; padding: 1rem 1.25rem; border-radius: var(--radius); background: var(--danger-bg); border: 2px solid var(--danger); color: #7d1c17; }
.auth-banner-title { margin: 0 0 .5rem; padding: .35rem .7rem; display: inline-block; border-radius: var(--radius-sm); background: var(--danger); color: #fff; font-size: 1.05rem; font-weight: 700; }
.auth-banner ol { margin: .5rem 0; padding-left: 1.2rem; }
.auth-banner p:last-child { margin-bottom: 0; }
.check-attention { padding: .4rem .6rem; border-radius: var(--radius-sm); background: var(--danger-bg); box-shadow: inset 0 0 0 1px #efc9c6; font-weight: 600; }

/* ───── Réservations ───── */
pre.code { font: .85rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--subtle); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .75rem 1rem; overflow-x: auto; }
.day-title { font-size: 1.05rem; margin: 0 0 1rem; text-transform: capitalize; }
.booking-alerts li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .75rem; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.room-booking { margin: .35rem 0 0; font-size: .85rem; color: var(--ink-soft); }
.room-booking.booking-unpaid { color: var(--danger); font-weight: 600; }
.booking-line { display: inline-flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: baseline; margin: -.75rem 0 1.25rem; font-size: .93rem; }
