/* Digicop — "control room" dark theme. One theme only: tokens below. */

@font-face {
  font-family: "Inter";
  src: url("/web/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0E1013;
  --bg-2: #121519;
  --surface: #16191D;
  --surface-2: #1D2126;
  --surface-3: #252A30;
  --border: #2A2F36;
  --border-strong: #3A414A;
  --text: #E9ECEF;
  --text-2: #C2C8CF;
  --muted: #8B939C;

  --accent: #E53935;
  --accent-2: #FF5A52;
  --accent-soft: rgba(229, 57, 53, 0.14);
  --ok: #2FB566;
  --ok-soft: rgba(47, 181, 102, 0.14);
  --warn: #F08C00;
  --warn-soft: rgba(240, 140, 0, 0.14);
  --info: #339AF0;
  --info-soft: rgba(51, 154, 240, 0.14);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --fast: 150ms ease;

  /* Translucent bars and overlays, per theme. */
  --topbar-bg: rgba(14, 16, 19, 0.85);
  --nav-bg: rgba(18, 21, 25, 0.95);
  --glass: rgba(14, 16, 19, 0.75);
  --warn-text: #FFB547;
  --card-veil: linear-gradient(180deg, rgba(14, 16, 19, 0.2), rgba(14, 16, 19, 0.88) 75%);
  --card-photo-filter: blur(1.5px) saturate(0.8) brightness(0.6);

  color-scheme: dark;
}

/* Light theme, readable in full sun: chosen in the user menu
   (html[data-theme], ui/theme.go), or the phone's setting when "Auto". */
:root[data-theme="light"] {
  --bg: #F3F4F6;
  --bg-2: #ECEEF1;
  --surface: #FFFFFF;
  --surface-2: #F1F3F5;
  --surface-3: #E5E8EC;
  --border: #DADFE5;
  --border-strong: #BFC6CF;
  --text: #14171A;
  --text-2: #3A4149;
  --muted: #646C76;

  --accent: #D32F2F;
  --accent-2: #C62828;
  --accent-soft: rgba(211, 47, 47, 0.10);
  --ok: #1E8E4E;
  --ok-soft: rgba(30, 142, 78, 0.12);
  --warn: #C76A00;
  --warn-soft: rgba(240, 140, 0, 0.13);
  --info: #1C7ED6;
  --info-soft: rgba(28, 126, 214, 0.12);

  --shadow: 0 1px 2px rgba(20, 23, 26, 0.08), 0 6px 18px rgba(20, 23, 26, 0.08);
  --shadow-lg: 0 12px 36px rgba(20, 23, 26, 0.18);

  --topbar-bg: rgba(255, 255, 255, 0.9);
  --nav-bg: rgba(255, 255, 255, 0.96);
  --glass: rgba(255, 255, 255, 0.85);
  --warn-text: #8A4B00;
  --card-veil: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.94) 75%);
  --card-photo-filter: blur(1.5px) saturate(0.7) brightness(1.05);

  color-scheme: light;
}
/* The logo is white text with a red D: dark text, red D in the light theme. */
:root[data-theme="light"] .brand img { filter: invert(1) hue-rotate(180deg); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .brand img { filter: invert(1) hue-rotate(180deg); }
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F3F4F6;
    --bg-2: #ECEEF1;
    --surface: #FFFFFF;
    --surface-2: #F1F3F5;
    --surface-3: #E5E8EC;
    --border: #DADFE5;
    --border-strong: #BFC6CF;
    --text: #14171A;
    --text-2: #3A4149;
    --muted: #646C76;

    --accent: #D32F2F;
    --accent-2: #C62828;
    --accent-soft: rgba(211, 47, 47, 0.10);
    --ok: #1E8E4E;
    --ok-soft: rgba(30, 142, 78, 0.12);
    --warn: #C76A00;
    --warn-soft: rgba(240, 140, 0, 0.13);
    --info: #1C7ED6;
    --info-soft: rgba(28, 126, 214, 0.12);

    --shadow: 0 1px 2px rgba(20, 23, 26, 0.08), 0 6px 18px rgba(20, 23, 26, 0.08);
    --shadow-lg: 0 12px 36px rgba(20, 23, 26, 0.18);

    --topbar-bg: rgba(255, 255, 255, 0.9);
    --nav-bg: rgba(255, 255, 255, 0.96);
    --glass: rgba(255, 255, 255, 0.85);
    --warn-text: #8A4B00;
    --card-veil: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.94) 75%);
    --card-photo-filter: blur(1.5px) saturate(0.7) brightness(1.05);

    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: #fff; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 16px; }
h2 { font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 10px; }
h3 { font-size: 0.9rem; font-weight: 600; margin: 18px 0 8px; color: var(--text-2); }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.right { margin-left: auto; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82em; }
.empty { color: var(--muted); padding: 32px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }

.icon { width: 1.1em; height: 1.1em; flex-shrink: 0; vertical-align: -0.18em; }

::selection { background: var(--accent); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Shell ---------- */

.shell { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 58px;
  flex-shrink: 0;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1100;
}

.brand { display: flex; align-items: center; }
.brand img { height: 22px; display: block; }

.nav { display: flex; gap: 2px; margin-left: auto; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.92rem;
  transition: color var(--fast), background var(--fast);
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-button { border: none; background: none; font: inherit; cursor: pointer; }
.nav-link.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }

.whoami {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; border: 0; min-height: 0;
  background: var(--surface-2); color: var(--text-2); font: inherit; font-size: 0.82rem; cursor: pointer;
}
.user-menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 1301; min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.menu-head { padding: 8px 10px; font-weight: 600; }
.menu-section { padding: 6px 10px 4px; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.menu-item {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%; min-height: 40px; padding: 8px 10px;
  background: none; border: 0; border-radius: var(--radius-sm); color: var(--text-2); font: inherit; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item.selected { color: var(--text); font-weight: 600; }
.menu-check { display: inline-flex; width: 18px; color: var(--accent-2); }

.content { flex: 1; min-height: 0; overflow: auto; }
.copyright {
  flex-shrink: 0; padding: 6px 20px; text-align: center;
  color: var(--muted); font-size: 0.72rem;
  border-top: 1px solid var(--border); background: var(--bg-2);
}
.login-page .copyright { position: absolute; left: 0; right: 0; bottom: 0; border: 0; background: none; }

.page { max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Phone: bottom tab bar. */
@media (max-width: 680px) {
  /* No blur here: a backdrop-filter makes the bar the containing block of
     its fixed children, and the bottom navigation then sat inside the top
     bar, over the logo, the bell and the user menu. */
  .topbar { padding: 0 16px; backdrop-filter: none; background: var(--bg-2); }
  .whoami span { display: none; } /* icon only: the menu stays reachable */
  .menu-panel { position: fixed; left: auto; right: 8px; top: 56px; }
  .shell { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 4px env(safe-area-inset-bottom);
    margin: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    z-index: 1200;
  }
  .nav-link { flex-direction: column; gap: 2px; font-size: 0.7rem; padding: 6px 10px; }
  .nav-link .icon { width: 22px; height: 22px; }
  .nav-link.active { box-shadow: none; color: var(--accent-2); background: none; }
  .page { padding: 18px 16px 28px; }
}

/* ---------- Controls ---------- */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 550;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background var(--fast), border-color var(--fast), transform var(--fast), opacity var(--fast);
}
button:hover:not(:disabled), .button:hover { background: var(--surface-3); color: var(--text); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

button.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(229, 57, 53, 0.3);
}
button.primary:hover:not(:disabled) { background: var(--accent-2); }
button.danger { background: transparent; color: var(--accent-2); border-color: rgba(229, 57, 53, 0.5); }
button.danger:hover:not(:disabled) { background: var(--accent-soft); }
button.link, a.link {
  border: 0; background: none; padding: 0; margin-bottom: 12px;
  color: var(--muted); font-weight: 500; display: inline-flex; gap: 4px;
}
button.link:hover, a.link:hover { color: var(--text); background: none; }
button.wide { width: 100%; margin-top: 12px; }
.small-btn { padding: 5px 10px; font-size: 0.84rem; }

input, select {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  transition: border-color var(--fast), box-shadow var(--fast);
}
input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); padding: 0; }
input::placeholder { color: #5D646C; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; flex: 1; }
.field > span { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; cursor: pointer; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 12px 0; padding: 10px 14px; }
legend { color: var(--muted); font-size: 0.82rem; padding: 0 6px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
/* align-items: start — sans ça toutes les cartes d'une rangée prennent la
   hauteur de la plus haute, ce qui creusait d'énormes vides sous les cartes
   courtes (État, Santé) quand Commandes faisait 1 310 px. */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 24px; align-items: start; }
/* cards-stacked : deux colonnes franches pour les cartes courtes, pleine
   largeur pour les denses. Des cartes « larges » occupant 2 colonnes sur 3,
   entrelacées avec des étroites, produisaient une mosaïque en escalier —
   chaque rangée commençait à une abscisse différente et laissait un trou. */
@media (min-width: 1000px) {
  .cards-stacked { grid-template-columns: 1fr 1fr; }
  .cards-stacked .card-wide { grid-column: 1 / -1; }
  .card-wide:not(.cards-stacked .card-wide) { grid-column: span 2; }
}

.error, .warning {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 0.92rem;
}
.error { background: var(--accent-soft); color: var(--accent-2); border: 1px solid rgba(229, 57, 53, 0.3); }
.warning { background: var(--warn-soft); color: var(--warn-text); border: 1px solid rgba(240, 140, 0, 0.3); }

/* ---------- Badges, statuses ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
}
.status-ok, .verdict-nothing, .cmd-done { background: var(--ok-soft); color: var(--ok); }
.cmd-sent { background: var(--info-soft); color: var(--info); }
.cmd-queued { background: var(--warn-soft); color: var(--warn); }
.status-muted, .verdict-skipped, .verdict-disarmed, .verdict-pending, .cmd-expired { background: var(--surface-3); color: var(--muted); }
.verdict-human, .verdict-vehicle, .verdict-failed, .cmd-failed, .cmd-error { background: var(--accent-soft); color: var(--accent-2); }
.tag-human { background: var(--accent-soft); color: var(--accent-2); }
.tag-vehicle { background: var(--info-soft); color: #74C0FC; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.status-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.status-muted { background: var(--muted); }
.dot.status-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.sensor-dots { display: inline-flex; gap: 5px; margin-left: 6px; }

/* Home: what needs someone. */
.attention {
  margin-bottom: 18px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.attention h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 1rem; color: var(--warn); }
.attention-item {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 7.5em; gap: 12px; align-items: baseline;
  padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text-2);
  border-left: 3px solid var(--border-strong);
}
.attention-item + .attention-item { margin-top: 4px; }
.attention-item:hover { background: var(--surface-2); }
.attention-item.level-warning { border-left-color: var(--warn); }
.attention-where { color: var(--text); font-weight: 600; }
.attention-when { font-size: 0.8rem; white-space: nowrap; text-align: right; }
@media (max-width: 680px) {
  .attention-item { grid-template-columns: 1fr auto; }
  .attention-reason { grid-column: 1 / -1; grid-row: 2; }
}

.arm-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em;
  white-space: nowrap;
}
.arm-status.armed { background: var(--accent); color: #fff; box-shadow: 0 0 16px rgba(229, 57, 53, 0.45); }
.arm-status.disarmed { background: var(--ok-soft); color: var(--ok); }

/* ---------- Arming switch ---------- */

.arm-switch {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  font-weight: 600;
}
.switch-track {
  position: relative; width: 46px; height: 26px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  transition: background 200ms ease, border-color 200ms ease;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 220ms cubic-bezier(0.3, 1.4, 0.6, 1);
}
.arm-switch.on .switch-track { background: var(--accent); border-color: var(--accent); }
.arm-switch.on .switch-thumb { transform: translateX(20px); }
.arm-switch.confirm { border-color: var(--warn); background: var(--warn-soft); color: #FFB547; animation: shake 300ms; }
.arm-switch.confirm .switch-track { background: var(--warn); border-color: var(--warn); }
.arm-switch.busy .switch-thumb { animation: pulse 0.8s infinite alternate; }

/* ---------- Alerts ---------- */

.alert-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0; padding: 10px 14px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--accent), #B71C1C);
  color: #fff; font-size: 0.9rem;
  box-shadow: 0 0 24px rgba(229, 57, 53, 0.35);
}
.alert-banner .icon { animation: pulse 0.9s infinite alternate; width: 18px; height: 18px; }

@keyframes pulse { from { opacity: 1; } to { opacity: 0.25; } }
@keyframes glow { from { box-shadow: 0 0 0 1px var(--accent), 0 0 10px rgba(229, 57, 53, 0.3); } to { box-shadow: 0 0 0 1px var(--accent), 0 0 32px rgba(229, 57, 53, 0.7); } }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes ping { from { transform: scale(1); opacity: 0.7; } to { transform: scale(2.6); opacity: 0; } }

/* ---------- Dashboard ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  animation: rise 300ms ease both;
}
.stat-icon {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface-3); color: var(--text-2);
}
.stat-icon .icon { width: 20px; height: 20px; }
.stat-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: 0.78rem; color: var(--muted); }
.stat.is-alerting { border-color: var(--accent); animation: glow 1s infinite alternate; }
.stat.is-alerting .stat-icon { background: var(--accent); color: #fff; }

.site-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.site-card {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--fast), border-color var(--fast), box-shadow var(--fast);
  animation: rise 350ms ease both;
}
.site-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.site-card.is-armed { border-color: rgba(229, 57, 53, 0.55); }
.site-card.is-alerting { animation: rise 350ms ease both, glow 1s 350ms infinite alternate; }
.site-card-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: var(--card-photo-filter);
  transform: scale(1.05);
}
.site-card-bg::after { content: ""; position: absolute; inset: 0; background: var(--card-veil); }
.site-card-body { position: relative; padding: 18px; display: flex; flex-direction: column; gap: 10px; min-height: 210px; }
.site-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.site-card h2 { margin: 0 0 2px; font-size: 1.12rem; }
.site-address { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.85rem; }
.site-facts { display: flex; flex-direction: column; gap: 4px; font-size: 0.86rem; color: var(--text-2); }
.site-facts span { display: flex; align-items: center; gap: 7px; }
.site-facts .icon { color: var(--muted); }
.site-facts .fact-alert, .site-facts .fact-alert .icon { color: var(--accent-2); font-weight: 600; }
.site-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.open-link { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 0.86rem; font-weight: 500; }
.site-card:hover .open-link { color: var(--text); }

/* Skeletons while loading. */
.skeleton { cursor: default; pointer-events: none; }
.sk-line, .sk-switch {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}
.sk-title { height: 18px; width: 60%; }
.sk-short { width: 40%; }
.sk-switch { width: 140px; height: 36px; border-radius: 999px; margin-top: auto; }

/* ---------- Login ---------- */

/* The login page stays dark in every theme: its glowing grid is drawn for it. */
.login-page {
  --bg: #0E1013; --bg-2: #121519; --surface: #16191D; --surface-2: #1D2126; --surface-3: #252A30;
  --border: #2A2F36; --border-strong: #3A414A; --text: #E9ECEF; --text-2: #C2C8CF; --muted: #8B939C;
  --accent: #E53935; --accent-2: #FF5A52; --accent-soft: rgba(229, 57, 53, 0.14);
  --warn-text: #FFB547;
  color-scheme: dark;
  color: var(--text);
}
.login-page {
  position: relative; overflow: hidden;
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(229, 57, 53, 0.10), transparent 55%), var(--bg);
}

/* Triangle grid on the lower part of the screen. The layer is a red glow
   centred on the pointer (--mx/--my, set by ui/login.go) plus a faint base
   colour; the mask keeps only the triangles' edges, fading out upwards.
   Mask tile: two rows of equilateral triangles, base 48px (h = 41.569). */
.login-grid {
  --mx: 50vw; --my: 85vh;
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle 240px at var(--mx) var(--my), rgba(229, 57, 53, 0.45), rgba(229, 57, 53, 0.12) 55%, transparent 100%),
    rgba(255, 255, 255, 0.07);
  --tri: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='83.138' viewBox='0 0 48 83.138'%3E%3Cg stroke='white' stroke-width='1.5'%3E%3Cpath d='M0 0H48M0 41.569H48M0 83.138H48M-24 83.138L24 0M24 83.138L72 0M-24 0L24 83.138M24 0L72 83.138'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-image: var(--tri), linear-gradient(to top, #000 0%, #000 40%, transparent 90%);
  -webkit-mask-size: 48px 83.138px, 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  -webkit-mask-composite: source-in;
  mask-image: var(--tri), linear-gradient(to top, #000 0%, #000 40%, transparent 90%);
  mask-size: 48px 83.138px, 100% 100%;
  mask-repeat: repeat, no-repeat;
  mask-composite: intersect;
  animation: fade-in 1.2s ease both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.login-side { position: relative; width: 100%; display: flex; justify-content: center; padding: 32px 20px; }
.login {
  width: 100%; max-width: 380px; display: flex; flex-direction: column;
  padding: 32px 28px; border-radius: var(--radius);
  background: rgba(22, 25, 29, 0.82); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  animation: rise 400ms ease both;
}
.login-brand { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.login-logo { height: 40px; }
/* Fond de l'icône (#181818) fondu dans le cadre semi-transparent. */
.login-g100 { display: block; height: 72px; margin: -16px 0; mix-blend-mode: lighten; }
.login-sub { color: var(--muted); margin: 0 0 24px; }

/* ---------- Map page ---------- */

.map-layout { display: flex; height: 100%; }
.map-layout .map { flex: 1; }
.map { height: 100%; min-height: 300px; z-index: 0; background: #DDE1E4; }

.panel {
  width: 360px; flex-shrink: 0; overflow: auto; padding: 18px;
  background: var(--bg-2); border-left: 1px solid var(--border);
}
@media (max-width: 760px) {
  .map-layout { flex-direction: column; }
  .map-layout .map { flex: none; height: 55vh; }
  .panel { width: auto; border-left: 0; border-top: 1px solid var(--border); }
}

.device-list { list-style: none; padding: 0; margin: 0; }
.device-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--fast);
}
.device-list li:hover { background: var(--surface-2); }

.site-group { border-bottom: 1px solid var(--border); }
.site-group-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 12px 6px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left;
}
.site-group-head:hover:not(:disabled) { background: var(--surface-2); }
.site-group-head .arm-status { font-size: 0.62rem; padding: 2px 8px; box-shadow: none; }
.site-group-head .arm-status .icon { display: none; }
.site-group-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { width: 14px; color: var(--muted); }
.site-group .device-list { padding: 0 0 8px 18px; }
.site-group-empty { padding: 0 0 10px 24px; margin: 0; }

.preview { width: 100%; border-radius: var(--radius-sm); display: block; margin: 12px 0; border: 1px solid var(--border); }
.acquire { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.quota { font-size: 0.82rem; color: var(--muted); text-align: center; }

dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0; font-size: 0.92rem; }
dt { color: var(--muted); }
dd { margin: 0; }

/* Leaflet, dark. */
.leaflet-container { font-family: inherit; background: #DDE1E4; }
.leaflet-bar a, .leaflet-control-layers {
  background: var(--surface) !important; color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-bar { border: 1px solid var(--border) !important; box-shadow: var(--shadow) !important; }
.leaflet-control-layers { border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important; box-shadow: var(--shadow) !important; }
.leaflet-control-layers-expanded { padding: 8px 12px; }
.leaflet-control-layers label { color: var(--text); }
.leaflet-control-attribution { background: var(--glass) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--text-2) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.leaflet-popup-content-wrapper { border: 1px solid var(--border); border-radius: var(--radius); }
.leaflet-popup-content { margin: 14px 16px; font-size: 14px; line-height: 1.45; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-tooltip.dev-tooltip {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: var(--shadow); font-size: 12px; font-weight: 500;
}
.leaflet-tooltip.dev-tooltip::before { border-top-color: var(--border); }

/* "Nuit" base map: the OSM map inverted, hues kept (roads, water…). */
.tiles-night { filter: invert(1) hue-rotate(180deg) brightness(1.05) contrast(0.85) saturate(0.6); }

/* Device markers: ring = arming, dot = health, halo = alert. The marker
   keeps Leaflet's position:absolute (it already anchors the dot and halo):
   a position:relative here put the markers back in the flow, each one
   pushed 12 px lower than the one before it, at every zoom level. */
.dev-dot {
  position: absolute; inset: 4px; border-radius: 50%;
  background: #fff; border: 4px solid var(--ring, #8B939C);
  box-shadow: 0 0 0 2px rgba(14, 16, 19, 0.7), 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: transform var(--fast);
}
.dev-marker.armed { --ring: #E53935; }
.dev-marker.disarmed { --ring: #2FB566; }
.dev-marker.nosite { --ring: #8B939C; }
.dev-marker.silent .dev-dot { background: #6B737C; }
.dev-marker.selected .dev-dot { transform: scale(1.35); }
.dev-halo { position: absolute; inset: 4px; border-radius: 50%; }
.dev-marker.alerting .dev-halo { background: var(--accent); animation: ping 1.2s infinite ease-out; }
.dev-marker:hover .dev-dot { transform: scale(1.2); }

/* Sirène sur la carte : le glyphe remplace le point blanc, l'anneau
   d'armement et le halo d'alerte restent. L'anneau est aminci pour libérer
   la place du glyphe dans une pastille de 24 px. */
.dev-marker.sounder .dev-dot { border-width: 2.5px; }
.dev-glyph {
  position: absolute; inset: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); pointer-events: none;
}
.dev-glyph .icon { width: 11px; height: 11px; stroke-width: 2.6; vertical-align: 0; }
.dev-marker.silent .dev-glyph { color: #6B737C; }
.dev-marker.selected .dev-glyph,
.dev-marker:hover .dev-glyph { transform: scale(1.2); transition: transform var(--fast); }

.site-label { background: none; border: 0; }
.site-label span {
  display: inline-flex; align-items: center; gap: 6px;
  transform: translate(-50%, calc(-100% - 18px));
  white-space: nowrap;
  padding: 4px 11px; border-radius: 999px;
  font: 600 12px/1.4 "Inter", system-ui, sans-serif;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.site-label.armed span { background: rgba(229, 57, 53, 0.92); }
.site-label.disarmed span { background: rgba(31, 122, 69, 0.92); }
.site-label.alerting span { animation: label-glow 0.8s infinite alternate; }
@keyframes label-glow { from { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.8); } to { box-shadow: 0 0 0 6px rgba(229, 57, 53, 0); } }

/* Zone menu (map popup). */
.zone-menu { display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.zone-menu-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.zone-menu-head strong { font-size: 15px; }
.zone-menu-head .arm-status { font-size: 10px; box-shadow: none; }
.zone-menu-line { color: var(--muted); font-size: 13px; }
.zone-menu-alert { color: var(--accent-2); font-weight: 600; font-size: 13px; }
.popup-btn { margin-top: 10px; width: 100%; padding: 10px; font-weight: 650; }
.popup-btn.arm { background: var(--accent); border-color: var(--accent); color: #fff; }
.popup-btn.disarm { background: var(--surface-2); }
.popup-btn.confirm { background: var(--warn); border-color: var(--warn); color: #1a1000; }
.zone-menu-link { display: block; text-align: center; margin-top: 8px; font-size: 13px; }

/* ---------- Gallery ---------- */

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar h1 { margin: 0; flex: 1; }
.toolbar select { width: auto; }
.toolbar .check { margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 14px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; } }

.thumb {
  margin: 0; overflow: hidden; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform var(--fast), border-color var(--fast);
  animation: rise 300ms ease both;
}
.thumb:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--surface-2); }
.thumb-img { position: relative; }
.thumb-count {
  position: absolute; right: 8px; bottom: 8px;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.65); color: #fff; font-size: 0.75rem; font-weight: 600;
}
.timeline .day { margin-bottom: 8px; }
.day-label {
  margin: 18px 0 10px; font-size: 0.85rem; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.timeline .day:first-child .day-label { margin-top: 4px; }
.thumb figcaption { padding: 10px 12px; font-size: 0.84rem; display: flex; flex-direction: column; gap: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.lightbox {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 16px;
  background: rgba(5, 6, 8, 0.92); backdrop-filter: blur(8px);
  animation: rise 200ms ease both;
}
.lb-actions { display: flex; gap: 10px; align-items: center; }
.lb-info { color: var(--muted); font-size: 0.85rem; }
/* Clip vidéo apparié à la capture (mode P+V) : sous l'image, borné en hauteur
   pour ne jamais pousser les boutons hors de l'écran sur un téléphone. */
.lb-extra { display: flex; justify-content: center; width: 100%; }
/* Une capture avec clip empile image + lecteur + actions : sans ça la barre
   d'actions sortait de l'écran et le bouton vidéo restait introuvable.
   L'image cède la hauteur dont le lecteur a besoin. Le sélecteur part de la
   racine : .lb-extra n'est pas frère de .lb-frame, mais de .lb-stage. */
.lightbox:has(.lb-clip) .lb-frame img { max-height: 44vh; }
.lightbox:has(.lb-clip) .lb-clip video { max-height: 22vh; }
.lb-clip { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lb-clip video {
  max-width: min(100%, 640px); max-height: 32vh;
  border-radius: 8px; border: 1px solid var(--border); background: #000;
}
.contents { display: contents; }

/* Rappel de configuration : libellé à gauche, valeur à droite, lisible en
   colonne unique sur téléphone. */
/* grid-template-columns est OBLIGATOIRE ici : une règle globale `dl` impose
   `auto 1fr`, qui sans ça rangeait les lignes DEUX PAR DEUX et débordait de
   133 px. Les minmax(0, …) laissent les colonnes rétrécir, sinon un libellé
   long repousse la valeur hors de la carte. */
.config-list { display: grid; grid-template-columns: 1fr; gap: 0; margin: 4px 0 10px; }
.config-row {
  display: grid; grid-template-columns: minmax(0, 45%) minmax(0, 1fr);
  gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border);
}
.config-row dt, .config-row dd { min-width: 0; overflow-wrap: anywhere; }
/* La valeur et son bouton d'édition sur une ligne, le panneau de réglage en
   dessous quand il s'ouvre. */
.config-row { align-items: center; padding: 10px 0; }
.config-row dd { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.config-value { font-weight: 600; color: var(--text); }
/* Le lien « Changer » faisait 18 px de haut : sous la barre des ~44 px
   recommandés au doigt, et trop discret pour se lire comme un contrôle. */
.config-edit {
  margin-left: auto; flex-shrink: 0;
  display: inline-flex; align-items: center; min-height: 34px;
  padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--muted); font-size: 0.82rem; text-decoration: none;
}
.config-edit:hover:not(:disabled) {
  border-color: var(--border-strong); color: var(--text); background: var(--surface-3);
}
.config-row .cmd-control { flex-basis: 100%; margin-top: 8px; }
@media (max-width: 520px) {
  /* Au doigt : libellé, puis valeur et bouton sur une ligne pleine largeur. */
  .config-row dd { width: 100%; }
  .config-edit { min-height: 40px; padding: 6px 14px; }
}
.config-row:last-child { border-bottom: 0; }
.config-row dt { color: var(--muted); font-size: 0.86rem; display: flex; align-items: center; gap: 8px; }
.config-row dt .icon { flex: none; width: 16px; height: 16px; color: var(--text-2); }
.config-row dd { margin: 0; font-size: 0.92rem; }
@media (max-width: 520px) {
  .config-row { grid-template-columns: 1fr; gap: 2px; }
}

/* Galerie vidéo : les clips ne passent pas par la galerie d'images (pas de
   vignette, et la détection travaille sur du JPEG). */
.video-grid {
  display: grid; gap: 12px; margin: 10px 0 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.video-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
}
.video-card video { width: 100%; border-radius: 6px; background: #000; }
.video-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Badge « vidéo » sur une vignette : une détection en P+V reste UN événement
   dans la chronologie, au lieu d'une photo ici et un clip dans une autre liste. */
.thumb-clip {
  position: absolute; left: 8px; bottom: 8px;
  padding: 2px 7px; border-radius: 999px;
  background: rgba(5, 6, 8, 0.78); color: #fff;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
}

/* Diagnostic replié : un groupe de commandes qu'on ne déroule qu'au besoin. */
.cmd-cat-folded > .cmd-cat-head { cursor: pointer; list-style: none; }
.cmd-cat-folded > .cmd-cat-head::-webkit-details-marker { display: none; }
.cmd-cat-folded > .cmd-cat-head::after { content: "▾"; margin-left: 2px; }
.cmd-cat-folded[open] > .cmd-cat-head::after { content: "▴"; }
/* Zone irréversible : séparée du reste, pour qu'un formatage ne soit jamais
   à portée de clic distrait d'une action quotidienne. */
.cmd-cat-danger {
  margin-top: 18px; padding-top: 14px;
  border-top: 1px dashed rgba(229, 57, 53, 0.35);
}
.cmd-cat-danger .cmd-cat-head { color: var(--accent-2); }

/* Repère sous un titre de carte : dit où est parti ce qu'on ne trouve plus. */
.card-hint { margin: -4px 0 14px; }

@media (max-width: 520px) {
  /* Au doigt, 3 colonnes de 115 px hachaient les libellés en quatre lignes.
     Deux colonnes plus larges se lisent d'un coup d'œil. */
  .cmd-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .cmd-btn { min-height: 76px; }
  /* La galerie vidéo tient en une colonne : un lecteur de 130 px est inutile. */
  .video-grid { grid-template-columns: 1fr; }
}

/* Device page: quick actions, health pills, folded details. */
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.quick-actions button { min-height: 40px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 0.86rem;
}
.pill-label { color: var(--muted); }
.pill-value { color: var(--text); font-weight: 600; }
.pill-ok { border-color: var(--ok-soft); }
.pill-warn { border-color: var(--warn); background: var(--warn-soft); }
.pill-bad { border-color: var(--accent); background: var(--accent-soft); }
details.more { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
details.more > summary {
  cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 4px 0;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸"; transition: transform var(--fast); }
details.more[open] > summary::before { transform: rotate(90deg); }
details.more > summary:hover { color: var(--text); }
.nowrap { white-space: nowrap; }

/* Notification bell (top bar): unread badge, drop-down panel. */
.bell { position: relative; }
.bell-button { position: relative; }
.bell-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 0.68rem; font-weight: 700; line-height: 17px; text-align: center;
}
.bell-backdrop { position: fixed; inset: 0; z-index: 1300; }
.bell-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 1301;
  width: 380px; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.bell-push { padding: 10px 14px; border-top: 1px solid var(--border); }
.bell-push p { margin: 6px 0 0; }
.bell-head { padding: 12px 14px; font-weight: 600; border-bottom: 1px solid var(--border); }
.bell-empty { padding: 14px; margin: 0; }
.bell-item {
  display: flex; gap: 10px; padding: 10px 14px; color: var(--text-2);
  border-bottom: 1px solid var(--border); border-left: 3px solid transparent;
}
.bell-item:hover { background: var(--surface-2); }
.bell-item.unread { background: var(--bg-2); color: var(--text); }
.bell-item.unread .bell-title { font-weight: 700; }
.bell-item.level-critical { border-left-color: var(--accent); }
.bell-item.level-warning { border-left-color: var(--warn); }
.bell-icon { flex: none; padding-top: 2px; color: var(--muted); }
.level-critical .bell-icon { color: var(--accent-2); }
.level-warning .bell-icon { color: var(--warn); }
.bell-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bell-title { color: var(--text); }
.bell-detail { font-size: 0.85rem; color: var(--muted); }
.bell-time { font-size: 0.75rem; color: var(--muted); }
@media (max-width: 680px) {
  .bell { margin-left: auto; }
  .bell-panel { position: fixed; left: 8px; right: 8px; top: 56px; width: auto; max-height: 65vh; }
}

/* Reception: five rising bars, the lit ones coloured by level. */
.signal { display: inline-flex; align-items: center; gap: 8px; margin-right: 8px; }
.signal-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.signal-bars .bar { width: 4px; border-radius: 1px; background: var(--border-strong); }
.signal-good .bar.on { background: var(--ok); }
.signal-fair .bar.on { background: var(--warn); }
.signal-weak .bar.on { background: var(--accent); }
.signal-label { color: var(--text); }
.lb-frame { position: relative; display: inline-block; max-width: 100%; }
.lb-frame img { display: block; max-width: 100%; max-height: 76vh; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.lb-top { position: absolute; top: 12px; left: 16px; right: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lb-top .lb-info { color: var(--text-2); }
.lb-close, .lb-nav {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.14); color: #fff;
}
.lb-nav span { font-size: 28px; line-height: 1; margin-top: -3px; }
.lb-nav:disabled { opacity: 0.25; }
.lb-stage { display: flex; align-items: center; gap: 12px; max-width: 100%; }
@media (max-width: 680px) {
  .lb-nav { display: none; } /* swipe on phones */
  .lb-top .lb-info { font-size: 0.78rem; }
}
.det-box { position: absolute; border: 2px solid; border-radius: 4px; pointer-events: none; }
.det-box span {
  position: absolute; left: -2px; bottom: 100%;
  padding: 1px 7px; font: 600 11px/1.5 "Inter", system-ui, sans-serif; color: #fff; white-space: nowrap;
  border-radius: 4px 4px 0 0;
}
.det-human { border-color: var(--accent-2); box-shadow: 0 0 12px rgba(229, 57, 53, 0.4); }
.det-human span { background: var(--accent-2); }
.det-vehicle { border-color: var(--info); }
.det-vehicle span { background: var(--info); }
/* Détection écartée par la zone masquée : visible de l'administrateur seul,
   pour qu'il voie ce que son tracé exclut. */
.det-masked { border: 2px dashed var(--text-2); box-shadow: none; }
.det-masked span { background: var(--text-2); }

/* ---------- Zone masquée (page appareil) ---------- */

.mask-editor { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.mask-frame { position: relative; display: inline-block; flex: 1 1 320px; min-width: 260px; max-width: 520px; }
/* Ni bordure ni padding, et aucun object-fit : addMaskPoint divise offsetX par
   clientWidth, donc la boîte de l'image doit être exactement la zone cliquable. */
.mask-frame .mask-img {
  display: block; width: 100%; height: auto; margin: 0; border: 0; padding: 0;
  border-radius: var(--radius-sm); cursor: crosshair;
}
/* pointer-events: none est indispensable — sans ça la cible du clic serait le
   SVG et offsetX ne serait plus relatif à l'image. */
.mask-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.mask-area { fill: rgba(229, 57, 53, 0.28); stroke: var(--accent-2); stroke-width: 2; stroke-dasharray: 6 4; }
.mask-edge { stroke: var(--accent-2); stroke-width: 2; stroke-dasharray: 6 4; }
.mask-handle {
  position: absolute; transform: translate(-50%, -50%); pointer-events: none;
  min-width: 18px; height: 18px; padding: 0 2px; border-radius: 999px;
  background: var(--accent-2); color: #fff; border: 2px solid #fff;
  font: 600 10px/14px "Inter", system-ui, sans-serif; text-align: center;
}
.mask-actions { flex: 1 1 260px; display: flex; flex-direction: column; gap: 12px; }
.mask-pick { display: flex; align-items: center; gap: 8px; }

/* ---------- Site page ---------- */

.arm-panel {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin: 8px 0 18px; box-shadow: var(--shadow);
}
.arm-panel h1 { margin: 0; }
.arm-panel-state { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
@media (max-width: 680px) { .arm-panel-state { align-items: flex-start; width: 100%; } }

.site-layout { display: grid; grid-template-columns: 1fr 360px; gap: 16px; margin-bottom: 18px; }
.site-map { height: 400px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
@media (max-width: 860px) { .site-layout { grid-template-columns: 1fr; } .site-map { height: 300px; } }

.sensor-list { list-style: none; padding: 0; margin: 0; }
.sensor-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--fast);
}
.sensor-list li:hover { background: var(--surface-2); }
.sensor-list li.selected { background: var(--accent-soft); }
.sensor-pic { flex: none; width: 28px; height: 40px; object-fit: contain; }

/* Sirène αS3 : elle occupe la colonne où une caméra montre sa photo produit.
   Le rouge dit son RÔLE, pas son état — une sirène au repos est rouge aussi ;
   l'armement et la santé restent portés par la pastille à gauche.
   var(--accent) suit le thème clair comme le sombre. */
.sensor-pic-sounder { display: flex; align-items: center; justify-content: center; color: var(--accent); }
.sensor-pic-sounder .icon { width: 26px; height: 26px; stroke-width: 1.9; vertical-align: 0; }
.device-title { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.device-title h1 { margin: 0; }
.device-pic { display: block; height: 56px; width: auto; }
.device-pic-sounder { display: flex; align-items: center; justify-content: center; width: 44px; color: var(--accent); }
.device-pic-sounder .icon { width: 40px; height: 40px; stroke-width: 1.8; vertical-align: 0; }
.sensor-name { flex: 1; min-width: 0; }
.sensor-name a { color: var(--text); font-weight: 550; }
.arm-ack.ok { color: var(--ok); }
.arm-ack.warn { color: var(--warn-text); }
.arm-ack.bad { color: var(--accent); }

.schedule { margin-bottom: 22px; }
.slot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); }
.slot select { width: auto; min-width: 120px; }
.slot input[type="time"] { width: auto; }

/* ---------- Device page ---------- */

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.inline-form select, .inline-form input { flex: 1; min-width: 140px; }

table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
/* overflow-wrap : l'activité affiche des chemins de fichiers sans espace
   (/sdcard/mmcblk0p1/LOG/SNAP//…/tcpdump_115904.pcap) qui débordaient la carte
   de 281 px. Rien à couper dedans, il faut donc autoriser la césure. */
.history td { font-size: 0.86rem; overflow-wrap: anywhere; }

/* ---------- Admin ---------- */

.tabs { display: flex; gap: 4px; margin-bottom: 18px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tab { border: 0; background: none; border-radius: 0; color: var(--muted); padding: 10px 14px; box-shadow: none; }
.tab:hover:not(:disabled) { background: none; color: var(--text); }
.tab.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

.list { margin-top: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.clickable { cursor: pointer; transition: background var(--fast); }
.clickable:hover { background: var(--surface-2); }

.editor { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 16px; }
.editor-map { min-height: 460px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.editor-map .map { height: 100%; }
@media (max-width: 860px) { .editor { grid-template-columns: 1fr; } .editor-map { height: 50vh; } }
.form.narrow { max-width: 560px; }
.editor-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Contacts of a site (alerts) */
.contacts h3 { margin: 12px 0 4px; }
.contact { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.contact-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.contact-actions { display: flex; gap: 6px; flex-shrink: 0; }
.contact-form { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 4px; }
.field-label { display: block; font-size: 0.85rem; color: var(--muted); margin: 10px 0 4px; }

.upload-info { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; font-size: 0.85rem; }
.upload-info code { word-break: break-all; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }

.strategy { margin-top: 8px; }
.level { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; background: var(--bg-2); }
.level > .small-btn { align-self: flex-start; }
.level .field { margin-bottom: 0; }
.level-head { display: flex; align-items: center; gap: 8px; }
.level-num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 0.8rem;
}
.command-row { display: flex; gap: 6px; align-items: center; }
.command-row select { flex: 1; }
.command-row input { width: 140px; }

/* Sonorisation du site : deux lignes, un son par alarme. */
.sounder { margin-bottom: 14px; }
.sound-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.sound-row label { flex: 0 0 190px; font-size: 14px; }
.sound-row select { flex: 1; min-width: 0; }
.sound-row input { width: 140px; }

@media (max-width: 560px) {
  .sound-row { flex-wrap: wrap; }
  .sound-row label { flex: 1 0 100%; }
  .sound-row input { width: 100px; }
}

.settings h2 { margin-top: 22px; }
.settings h2:first-child { margin-top: 0; }
.settings .row { align-items: flex-end; }
.test-btn { margin-bottom: 12px; }

/* ---------- Toasts ---------- */

.toaster {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  z-index: 3000; width: min(92vw, 460px); pointer-events: none;
}
@media (max-width: 680px) { .toaster { bottom: calc(76px + env(safe-area-inset-bottom)); } }
.toast {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); font-size: 0.9rem;
  pointer-events: auto; cursor: pointer;
  animation: rise 220ms ease both;
}
.toast .icon { width: 18px; height: 18px; }
.toast-ok .icon { color: var(--ok); }
.toast-warning { border-color: rgba(240, 140, 0, 0.5); }
.toast-warning .icon { color: var(--warn); }
.toast-error { border-color: rgba(229, 57, 53, 0.6); }
.toast-error .icon { color: var(--accent-2); }

/* Device protocol badges (admin). */
.proto-a3 { background: var(--accent-soft); color: var(--accent-2); }
.proto-t4 { background: var(--info-soft); color: #74C0FC; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* Admin → Aide (internal/api/help.html). Each section sets its colour in
   --c; tints are mixed from it, so both themes follow. */
.help { max-width: 920px; color: var(--text-2); line-height: 1.55; }
.help b { color: var(--text); }
.help-hero {
  padding: 22px 24px; margin-bottom: 18px; border-radius: var(--radius); border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent-soft), var(--info-soft)), var(--surface);
}
.help-hero h2 { margin: 0 0 6px; font-size: 1.45rem; color: var(--text); }
.help-hero p { margin: 0; }
.help-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.help .chip {
  font-size: 0.78rem; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
}
.help kbd {
  font: 600 0.75rem ui-monospace, monospace; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface-2); color: var(--text);
}

.help details {
  --c: var(--info);
  margin: 12px 0; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); border-left: 4px solid var(--c); box-shadow: var(--shadow);
  overflow: hidden;
}
.help summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; transition: background var(--fast);
}
.help summary::-webkit-details-marker { display: none; }
.help summary::after { content: "›"; margin-left: auto; font-size: 1.4rem; color: var(--muted); transition: transform var(--fast); }
.help details[open] summary::after { transform: rotate(90deg); }
.help summary:hover { background: color-mix(in srgb, var(--c) 7%, transparent); }
.help details[open] summary { background: color-mix(in srgb, var(--c) 10%, transparent); border-bottom: 1px solid var(--border); }
.help .num {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; color: #fff; background: var(--c);
}
.help .ico { font-size: 1.25rem; }
.help .ttl { display: flex; flex-direction: column; font-weight: 650; color: var(--text); font-size: 1.02rem; }
.help .ttl small { font-weight: 400; font-size: 0.82rem; color: var(--muted); }
.help details > :not(summary) { margin-left: 18px; margin-right: 18px; }
.help details > :last-child { margin-bottom: 18px; }

.help code {
  font: 0.86em ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 6px; border-radius: 5px;
  background: color-mix(in srgb, var(--c, var(--info)) 12%, var(--surface-2)); color: var(--text);
  overflow-wrap: anywhere;
}
.help pre {
  font: 0.85rem ui-monospace, SFMono-Regular, Menlo, monospace; padding: 10px 12px; margin: 8px 0;
  border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* Numbered steps: coloured counters on a guide line. */
.help ol.steps { list-style: none; counter-reset: step; padding: 0; margin-top: 14px; }
.help ol.steps > li {
  counter-increment: step; position: relative; padding: 2px 0 14px 44px;
  border-left: 2px solid color-mix(in srgb, var(--c) 30%, transparent); margin-left: 14px;
}
.help ol.steps > li:last-child { border-left-color: transparent; }
.help ol.steps > li::before {
  content: counter(step); position: absolute; left: -15px; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
  color: var(--c); background: var(--surface); border: 2px solid var(--c);
}
.help ul.clean { padding-left: 0; list-style: none; }
.help ul.clean li { padding-left: 18px; position: relative; margin: 8px 0; }
.help ul.clean li::before { content: ""; position: absolute; left: 2px; top: 0.6em; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

/* Callouts. */
.help .callout { margin: 12px 0; padding: 10px 14px 10px 40px; border-radius: var(--radius-sm); position: relative; border: 1px solid; }
.help .callout::before { position: absolute; left: 13px; top: 9px; }
.help .callout.tip { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.help .callout.tip::before { content: "💡"; }
.help .callout.note { background: var(--surface-2); border-color: var(--border); }
.help .callout.note::before { content: "ℹ️"; }
.help .callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.help .callout.warn::before { content: "⚠️"; }
.help .callout.danger { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.help .callout.danger::before { content: "⛔"; }

/* Tables. */
.help table { border-collapse: collapse; width: 100%; margin: 10px 0 14px; font-size: 0.92rem; }
.help table.kv th { text-align: left; width: 34%; color: var(--text); font-weight: 600; background: color-mix(in srgb, var(--c) 8%, transparent); }
.help table.kv th, .help table.kv td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.help table.grid th { text-align: left; padding: 8px 10px; color: #fff; background: var(--c); }
.help table.grid th:first-child { border-top-left-radius: var(--radius-sm); }
.help table.grid th:last-child { border-top-right-radius: var(--radius-sm); }
.help table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.help table.grid tr:nth-child(even) td { background: var(--surface-2); }

/* Mini cards (channels). */
.help .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 14px; }
.help .card-mini { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.help .card-mini h4 { margin: 0 0 6px; color: var(--text); }
.help .card-mini p { margin: 4px 0; font-size: 0.9rem; }

/* Alarm flow. */
.help .flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 6px; margin-top: 14px; }
.help .flow-step {
  flex: 1 1 150px; padding: 10px 12px; border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 2px;
  background: color-mix(in srgb, var(--c) 12%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
}
.help .flow-step b { color: var(--c); }
.help .flow-step span { font-size: 0.82rem; color: var(--muted); }
.help .flow-arrow { align-self: center; color: var(--muted); font-size: 1.2rem; }
@media (max-width: 640px) {
  .help .flow-arrow { display: none; }
  .help details > :not(summary) { margin-left: 12px; margin-right: 12px; }
  .help table.kv th { width: 40%; }
}
@media print {
  .help details { box-shadow: none; break-inside: avoid; }
}

/* Command grid (device page command console) */
.cmd-cat { margin: 0 0 14px; }
.cmd-cat:last-of-type { margin-bottom: 0; }
.cmd-cat-head { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; color: var(--muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.cmd-cat-head .icon { width: 15px; height: 15px; }
/* 150 px mini : à 104 px, « Récupérer les photos en attente » se hachait sur
   trois lignes, et dans une carte pleine largeur quatre tuiles étroites
   laissaient la rangée vide à droite. */
.cmd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cmd-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-height: 68px; padding: 10px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 0.82rem; line-height: 1.2; text-align: center; cursor: pointer; transition: background var(--fast), border-color var(--fast), color var(--fast), transform var(--fast); }
.cmd-btn .icon { width: 22px; height: 22px; }
.cmd-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.cmd-btn:active:not(:disabled) { transform: translateY(1px); }
.cmd-btn:disabled { opacity: 0.45; cursor: default; }
.cmd-btn.armed { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.cmd-btn.danger { color: var(--accent-2); }
.cmd-btn.danger:hover:not(:disabled) { background: var(--accent-soft); border-color: rgba(229, 57, 53, 0.5); }
.cmd-control { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.cmd-control.cmd-danger { border-color: rgba(229, 57, 53, 0.5); background: var(--accent-soft); }
.cmd-control.cmd-danger .icon { color: var(--accent-2); width: 18px; height: 18px; }
.cmd-control-label { font-weight: 600; }
.cmd-control input[type="number"], .cmd-control input[type="text"] { width: 130px; }
.cmd-control .pills { margin: 0; }
.chip { padding: 6px 14px; border-radius: 999px; background: var(--surface-2); }
.chip:hover:not(:disabled) { background: var(--surface-3); }
.cmd-value { min-width: 1.8em; text-align: center; font-weight: 700; font-size: 1.1rem; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.cmd-control input[type="range"] { flex: 1 1 140px; max-width: 240px; accent-color: var(--accent); }

/* Caméras refusées (IMEI hors inventaire), à adopter ou ignorer. */
.unknown-devices { margin-bottom: 18px; padding: 12px 14px; border: 1px solid var(--warn); border-radius: 8px; background: var(--warn-soft); }
.unknown-devices h3 { margin-top: 0; color: var(--warn); }
.unknown-devices td button + button { margin-left: 6px; }

/* Mode test d'un site : bandeau tant qu'il dure, sinon les boutons de durée. */
.test-banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  margin: 12px 0; padding: 12px 14px; border: 1px solid var(--warn); border-radius: 8px; background: var(--warn-soft); }
.test-banner strong { color: var(--warn); }
.test-control { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0 4px; }

/* ---------- Battery history (G100) ---------- */
.battery-chart { margin: 14px 0 6px; }
.battery-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.battery-chart-head h3 { margin: 0; }
.battery-chart-days { display: flex; gap: 6px; }
.battery-chart-days .active { border-color: var(--info); color: var(--info); }
.bchart { display: block; width: 100%; height: auto; margin-top: 8px; }
.bchart-grid { stroke: var(--border); stroke-width: 1; }
.bchart-day { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 4; }
.bchart-label { fill: var(--muted); font-size: 11px; }
.bchart-cam, .bchart-panel { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.bchart-cam { stroke: var(--info); }
.bchart-panel { stroke: var(--warn); }

/* Enjambement d'un silence : même couleur, mais discontinu, plus fin et
   effacé. L'œil suit la courbe ; il voit aussi qu'on n'a rien mesuré là. */
.bchart-bridge { stroke-width: 1.2; stroke-dasharray: 3 4; opacity: 0.38; }
.battery-legend { display: flex; gap: 16px; color: var(--muted); margin-top: 4px; }
.battery-legend span::before { content: ""; display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.legend-cam::before { background: var(--info); }
.legend-panel::before { background: var(--warn); }

/* ---- Je me repère : position de l'utilisateur sur la carte du site ---- */

/* Le point bleu et son halo. La couleur diffère volontairement de celles des
   détecteurs (rouge armé / vert désarmé) : on ne doit jamais confondre « moi »
   avec un appareil. */
.me-marker { display: block; }
.me-dot {
  display: block; width: 14px; height: 14px; margin: 2px;
  border-radius: 50%; background: var(--info);
  box-shadow: 0 0 0 2px #fff, 0 1px 4px rgba(0, 0, 0, 0.4);
}

.locate { margin-top: 10px; }
.locate-err { color: var(--accent-2); margin-top: 8px; }
.locate-result { margin-top: 10px; }

.locate-list { list-style: none; margin: 8px 0 0; padding: 0; }
.locate-item {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  padding: 7px 10px; margin-bottom: 5px;
  border-radius: 7px; border-left: 3px solid var(--muted);
  background: var(--surface-2, rgba(127, 127, 127, 0.08));
}
.locate-name { font-weight: 600; }
.locate-dist { color: var(--muted); font-size: 13px; }
.locate-cov { margin-left: auto; }

/* Dans le champ, à la limite, hors champ. Le jaune n'est pas un avertissement
   ici : il dit « la mesure ne permet pas de trancher ». */
.cov-inside { border-left-color: var(--accent-2); }
.cov-inside .locate-cov { color: var(--accent-2); font-weight: 600; }
.cov-uncertain { border-left-color: var(--warn); }
.cov-uncertain .locate-cov { color: var(--warn); }
.cov-outside .locate-cov { color: var(--muted); }

@media (max-width: 560px) {
  .locate-cov { margin-left: 0; width: 100%; }
}

/* Un « utilisateur » n'a pas accès aux vidéos : il apprend qu'elle existe et
   peut la réclamer à un administrateur. */
.clip-notice {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: center; margin-top: 10px; color: var(--muted);
}

/* Transmission d'une vidéo à un utilisateur, sous le lecteur. */
.clip-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.clip-picker {
  margin-top: 10px; padding: 10px; border-radius: 8px;
  background: rgba(127, 127, 127, 0.1); max-width: 460px;
}
.clip-pick-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.clip-pick-row select { flex: 1; min-width: 0; }
.clip-warn { color: var(--warn); margin: 6px 0; line-height: 1.4; }
.clip-done { color: var(--ok); margin-top: 8px; line-height: 1.4; }

/* Version dans le pied de page : discrète, mais lisible quand elle alerte. */
.version { opacity: 0.75; }
.version-stale { opacity: 1; color: var(--warn); }
.version-stale a { color: inherit; text-decoration: underline; }

/* Cartes repliables, ouvertes par défaut. Le chevron suffit à dire qu'on peut
   replier ; le titre garde exactement l'allure des autres cartes. */
.card-fold > .card-fold-head {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card-fold > .card-fold-head::-webkit-details-marker { display: none; }
.card-fold > .card-fold-head h2 { margin: 0; }
.card-fold > .card-fold-head::after { content: "▴"; color: var(--muted); font-size: 13px; }
.card-fold:not([open]) > .card-fold-head::after { content: "▾"; }
/* Replié, la carte ne doit pas garder l'espace de son contenu. */
.card-fold:not([open]) { padding-bottom: 14px; }

/* Réglages groupés : un intertitre discret par famille. Quinze lignes plates
   ne disaient pas lesquelles allaient ensemble. */
.config-group + .config-group { margin-top: 18px; }
.config-group-head {
  margin: 0 0 6px; padding-bottom: 4px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--border);
}

/* Commande groupée : appliquer un réglage à tous les capteurs d'un site. */
.bulk { margin-top: 14px; }
.bulk-open {
  padding: 12px; border-radius: 8px;
  background: rgba(127, 127, 127, 0.1);
}
.bulk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.bulk-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bulk-pick select { flex: 1; min-width: 140px; }
.bulk-pick input { width: 120px; }
.bulk-plan { margin-top: 12px; line-height: 1.5; }
.bulk-confirm { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.bulk-warn { color: var(--warn); margin-top: 6px; }
.bulk-sent { color: var(--ok); margin-top: 8px; line-height: 1.4; }

/* Pastille choisie dans le panneau groupé : on sélectionne, on n'envoie pas. */
.bulk-choices { margin: 4px 0; }
.chip-on { border-color: var(--accent-2); color: var(--accent-2); font-weight: 600; }
