:root {
  --navy: #16204e;
  --navy-2: #1c2a68;
  --ink: #10182f;
  --muted: #5b6588;
  --line: rgba(22, 32, 78, 0.1);
  --red: #f24c52;
  --green: #2fbf7a;
  --amber: #f0a429;
  --bg: #eef1f8;
  --surface: #ffffff;
  --surface-soft: #f5f7fb;
  --shadow: 0 8px 28px rgba(16, 24, 47, 0.08);
  --shadow-sm: 0 2px 10px rgba(16, 24, 47, 0.05);
  --radius: 16px;
  --radius-sm: 12px;
  --rail: 232px;
  --ease: cubic-bezier(0.22, 0.9, 0.2, 1);
  --topbar-h: 72px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: "Barlow", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 520px at 0% -10%, rgba(255, 255, 255, 0.9) 0%, transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(22, 32, 78, 0.06) 0%, transparent 50%),
    linear-gradient(165deg, #f3f5fa 0%, #e6ebf5 100%);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }

.app-shell {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  height: 100vh;
  max-height: 100dvh;
}

.sidebar {
  height: 100%;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: linear-gradient(180deg, #16204e 0%, #0d1433 100%);
  color: #fff;
  overflow: hidden;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 6px; }
.brand img { border-radius: 11px; background: #fff; width: 38px; height: 38px; }
.brand-name { font-weight: 900; font-size: 1.15rem; }
.brand-name span { color: var(--red); }
.brand-tag { font-size: 0.65rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.55; font-weight: 700; margin-top: 2px; }
.brand-show { margin-top: 10px; font-size: .92rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-demo { margin-top: 1px; font-size: .72rem; font-weight: 600; opacity: 0.72; }

.nav { display: flex; flex-direction: column; gap: 5px; flex: 1; min-height: 0; }
.nav-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: 13px;
  color: rgba(255,255,255,0.72); font-weight: 700;
  text-decoration: none;
  transition: 0.25s var(--ease);
}
.nav-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,0.14); color: #fff; }
.nav-btn .badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--red); font-style: normal;
  font-size: 11px; font-weight: 800; display: grid; place-items: center;
}

.sidebar-card {
  padding: 0;
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
}
.sidebar-devices-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s var(--ease);
}
.sidebar-devices-btn:hover {
  background: rgba(255,255,255,0.1);
}
.sidebar-devices-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.sidebar-devices-ico.ico { width: 36px; height: 36px; }
.sidebar-devices-ico svg { width: 18px; height: 18px; }
.sidebar-devices-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-devices-text strong {
  display: block;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
}
.sidebar-devices-text small {
  display: block;
  opacity: 0.65;
  font-size: 0.72rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-row { display: flex; gap: 10px; align-items: center; }
.status-row strong { display: block; font-size: 0.85rem; }
.status-row small { opacity: 0.65; font-size: 0.72rem; }
.pulse {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--amber); flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(240,164,41,0.2);
}
.pulse.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(47,191,122,0.22); }
.pulse.err { background: var(--red); box-shadow: 0 0 0 4px rgba(242,76,82,0.22); }

.workspace {
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 14px 20px 16px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  overflow: hidden;
}

.top {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  min-height: 52px;
}
.top-title { min-width: 0; }
.eyebrow {
  margin: 0 0 2px; font-size: 0.65rem; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.top h1 {
  margin: 0; font-size: clamp(1.25rem, 1.6vw, 1.55rem);
  font-weight: 900; letter-spacing: -0.03em; line-height: 1.1;
  color: var(--navy);
}
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  height: 38px; min-width: 160px; max-width: 240px; padding: 0 12px;
  border-radius: 11px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.search-box input { border: 0; outline: 0; background: transparent; width: 100%; font-weight: 600; font-size: .88rem; }
.icon-btn, .glass {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); transition: .2s var(--ease);
}
.icon-btn:hover, .glass:hover { transform: translateY(-1px); }
.cta {
  height: 38px; padding: 0 14px; border-radius: 11px;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--navy);
  color: #fff; font-weight: 800; box-shadow: 0 8px 20px rgba(22,32,78,.18);
}
.cta.block { width: 100%; justify-content: center; margin-top: 10px; }
.ghost {
  height: 38px; padding: 0 12px; border-radius: 11px; font-weight: 700;
  background: #e8ecf5; color: var(--navy);
}
.ghost.block { width: 100%; margin-top: 8px; }
.ghost.sm { height: 32px; padding: 0 10px; font-size: .76rem; }
.cta.sm { height: 36px; padding: 0 16px; font-size: .8rem; }

.chip-group, .view-modes {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.view-modes .chip-btn {
  min-width: 36px;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  font-weight: 800;
  font-size: .78rem;
}
.view-modes .chip-btn.active {
  background: var(--navy);
  color: #fff;
}

.hd-toggle { position: relative; font-weight: 800; }
#btnHdTop {
  width: auto;
  min-width: 48px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
}
#btnHdTop .hd-label {
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .04em;
}
.hd-toggle.active,
#btnHdTop.active,
#btnHd.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 6px 16px rgba(242, 76, 82, 0.3);
}
#btnHd.active { background: var(--red); color: #fff; }
.hd-toggle.active.navy-fill,
#btnHdTop.active.navy-fill {
  background: var(--navy);
  border-color: var(--navy);
  box-shadow: 0 6px 16px rgba(22, 32, 78, 0.28);
}

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

/* Live */
.live-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 14px;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  flex: 1;
  overflow: hidden;
}
.stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  container-type: size;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 10px;
}
.player {
  --ar: 1.7777778;
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: #070b18;
  box-shadow: 0 16px 40px rgba(16,24,47,.18);
  aspect-ratio: var(--ar, 1.7777778);
  width: min(100%, calc(100cqh * var(--ar, 1.7777778)));
  height: min(100%, calc(100cqw / var(--ar, 1.7777778)));
  max-width: 100%;
  max-height: 100%;
  flex-shrink: 1;
}
.player video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #070b18;
}
.player .live-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #070b18;
  z-index: 1;
}
.player.es-mode video {
  opacity: 0;
  pointer-events: none;
}
.player.es-mode .live-canvas {
  z-index: 1;
}
.player.compact {
  position: relative;
  width: 100%;
  height: auto;
  max-height: min(46vh, 440px);
  aspect-ratio: 16 / 9;
  border-radius: 12px;
}
.player.compact video {
  position: absolute;
  inset: 0;
  object-fit: cover;
}
.player.compact .loader {
  border-radius: 12px;
}

.player-ui {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(7,11,24,.48), transparent 28%, transparent 58%, rgba(7,11,24,.72));
  pointer-events: none;
}
.player-top, .player-bottom, .player-btns { display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.player-bottom { justify-content: space-between; }
.player-bottom h2 { margin: 0; color: #fff; font-size: clamp(1rem, 1.5vw, 1.25rem); font-weight: 800; }
.player-bottom p { margin: 3px 0 0; color: rgba(255,255,255,.72); font-weight: 600; font-size: .8rem; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px; border-radius: 999px; color: #fff;
  background: rgba(255,255,255,.14); backdrop-filter: blur(8px);
  font-size: .68rem; font-weight: 800; letter-spacing: .04em;
}
.chip.soft { background: rgba(255,255,255,.1); font-weight: 700; }
.chip.live i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--red);
  box-shadow: 0 0 0 3px rgba(242,76,82,.3);
}
.glass {
  width: 40px; height: 40px; border-radius: 11px;
  background: rgba(255,255,255,.14); border: 0; color: #fff;
  backdrop-filter: blur(8px); box-shadow: none;
}

/* PTZ joystick + prépositions (live) */
.ptz-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: auto;
  z-index: 4;
  opacity: 0.6;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}
.ptz-panel[hidden] { display: none !important; }
.ptz-joy {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  position: relative;
  background: radial-gradient(circle at 32% 30%, #fff, #e7ebf5 72%);
  border: 1px solid rgba(255,255,255,.8);
  box-shadow: 0 10px 28px rgba(7, 11, 24, .28), inset 0 2px 8px rgba(22, 32, 78, .08);
  touch-action: none;
  cursor: grab;
}
.ptz-joy:active { cursor: grabbing; }
.ptz-knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 32% 30%, #3d4d92, var(--navy));
  box-shadow: 0 8px 18px rgba(22, 32, 78, .45);
  pointer-events: none;
}
.ptz-joy .arr {
  position: absolute;
  width: 7px;
  height: 7px;
  border-top: 2px solid #9aa3be;
  border-right: 2px solid #9aa3be;
  pointer-events: none;
}
.ptz-joy .arr.u { top: 12px; left: 50%; transform: translateX(-50%) rotate(-45deg); }
.ptz-joy .arr.r { right: 12px; top: 50%; transform: translateY(-50%) rotate(45deg); }
.ptz-joy .arr.d { bottom: 12px; left: 50%; transform: translateX(-50%) rotate(135deg); }
.ptz-joy .arr.l { left: 12px; top: 50%; transform: translateY(-50%) rotate(-135deg); }
.ptz-zoom {
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,.94);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(7, 11, 24, .22);
}
.ptz-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--navy);
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}
.ptz-btn + .ptz-btn { border-top: 1px solid #e6eaf3; }
.ptz-btn:hover { background: #f3f5fb; }
.ptz-btn:active,
.ptz-btn.is-held { background: var(--navy); color: #fff; }
.ptz-panel.is-zoom-only .ptz-joy { display: none; }
.ptz-presets-bar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  width: min(100%, calc((100cqh - 78px) * var(--ar, 1.7777778)));
}
.ptz-presets-bar[hidden] { display: none !important; }
.ptz-presets-title {
  margin: 0;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .02em;
  color: var(--navy);
}
.ptz-presets {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 0 2px;
  scrollbar-width: none;
}
.ptz-presets::-webkit-scrollbar { display: none; }
.ptz-preset {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-weight: 800;
  font-size: .75rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.ptz-preset.is-on,
.ptz-preset:active { background: var(--navy); color: #fff; border-color: var(--navy); }
.stage { flex-direction: column; gap: 10px; }
.stage:has(#ptzPresetsBar:not([hidden])) .player {
  width: min(100%, calc((100cqh - 78px) * var(--ar, 1.7777778)));
  height: min(calc(100cqh - 78px), calc(100cqw / var(--ar, 1.7777778)));
}
.player.has-ptz .player-btns {
  position: absolute;
  top: 0;
  right: 0;
}

.loader {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 12px;
  background: rgba(7,11,24,.72); color: #fff; text-align: center; z-index: 2;
}
.loader p { margin: 0; font-weight: 700; color: rgba(255,255,255,.8); }
.spinner {
  width: 38px; height: 38px; margin: 0 auto;
  border-radius: 50%; border: 3px solid rgba(255,255,255,.15);
  border-top-color: #fff; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Transition entre menus */
.view-loader {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background:
    radial-gradient(520px 280px at 50% 42%, rgba(22, 32, 78, 0.18), transparent 70%),
    rgba(238, 241, 248, 0.55);
  backdrop-filter: blur(8px) saturate(1.05);
  transition: opacity .28s var(--ease), visibility .28s var(--ease);
}
.view-loader.is-on {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}
.view-loader[hidden] { display: none !important; }
.view-loader.is-on[hidden] { display: grid !important; }
.view-loader-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 22px 28px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(22, 32, 78, 0.08);
  box-shadow: 0 18px 48px rgba(16, 24, 47, 0.14);
  transform: translateY(8px) scale(.96);
  transition: transform .28s var(--ease);
}
.view-loader.is-on .view-loader-card { transform: none; }
.view-loader-card p {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: .72rem;
  color: var(--navy);
}
.view-loader-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background:
    conic-gradient(from 90deg, var(--red), var(--navy), rgba(22, 32, 78, 0.15), var(--red));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  animation: spin .85s linear infinite;
}

.cam-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; flex-shrink: 0;
}
.panel-head h3 { margin: 0; font-size: .92rem; font-weight: 800; color: var(--navy); }
.panel-head-sub {
  margin: 3px 0 0; font-size: .72rem; font-weight: 600; color: var(--muted);
}
.panel-head span#camCount,
.panel-head > span {
  min-width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center;
  background: #e8ecf7; color: var(--navy); font-weight: 800; font-size: .75rem;
  flex-shrink: 0;
}
.panel-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; margin-bottom: 10px; flex-shrink: 0;
}
.panel-toolbar h3 {
  margin: 0; font-size: .88rem; font-weight: 800; color: var(--navy);
}

.cam-list {
  display: flex; flex-direction: column; gap: 8px;
  overflow: auto; min-height: 0; flex: 1;
  padding-right: 2px;
}
.cam-item {
  display: grid; grid-template-columns: 76px 1fr auto; gap: 10px; align-items: center;
  padding: 8px; border-radius: var(--radius-sm); text-align: left;
  border: 1px solid transparent; transition: .2s var(--ease); background: var(--surface-soft);
  flex-shrink: 0;
}
.cam-item:hover { background: #eef1f8; }
.cam-item.active {
  border-color: rgba(22,32,78,.18);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.cam-item .thumb {
  width: 76px; height: 46px; border-radius: 8px; overflow: hidden;
  background: #11182f; position: relative; flex-shrink: 0;
}
.cam-item .thumb img, .cam-item .thumb video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.cam-item .thumb .ph {
  width: 100%; height: 100%; display: grid; place-items: center; color: rgba(255,255,255,.35);
}
.cam-item strong { display: block; font-size: .82rem; font-weight: 800; line-height: 1.25; color: var(--navy); }
.cam-item small { color: var(--muted); font-weight: 600; font-size: .7rem; }
.cam-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px;
  font-size: .65rem; font-weight: 800; letter-spacing: .02em;
  background: #e8ecf5; color: var(--muted); white-space: nowrap;
}
.cam-status.live {
  background: rgba(242, 76, 82, 0.12);
  color: var(--red);
}
.cam-status.on {
  background: rgba(47, 191, 122, 0.12);
  color: #1a9a5c;
}
.cam-status::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b0b7cc; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(47,191,122,.2); }
.dot.live { background: var(--red); box-shadow: 0 0 0 3px rgba(242,76,82,.2); }

.view-modes {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(22, 32, 78, 0.08);
  border: 1px solid var(--line);
}
.view-mode-btn {
  min-width: 34px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: .85rem;
  font-family: inherit;
  cursor: pointer;
}
.view-mode-btn.active {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 6px 16px rgba(22, 32, 78, 0.22);
}
.grid-cell .cell-timing {
  position: absolute; right: 8px; top: 8px; z-index: 2;
  font-size: .68rem; font-weight: 700; color: rgba(255,255,255,.75);
  text-shadow: 0 1px 6px rgba(0,0,0,.5);
  pointer-events: none;
}
.grid-cell.is-slow { outline: 2px solid rgba(240,164,41,.7); }
.grid-cell.is-fail { outline: 2px solid rgba(242,76,82,.75); }
#panel-live {
  display: none;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
#panel-live.active {
  display: flex;
}
#panel-live > .grid-layout {
  flex: 1;
  min-height: 0;
}
#panel-live > .live-layout.hidden,
#panel-live > .grid-layout.hidden {
  display: none !important;
}
.grid-layout {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.grid-layout.cols-2 .grid-cells { grid-template-columns: repeat(2, 1fr); }
.grid-layout.cols-3 .grid-cells { grid-template-columns: repeat(3, 1fr); }
.grid-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.grid-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: .85rem;
}
.grid-cells {
  display: grid;
  gap: 8px;
  height: 100%;
  min-height: 0;
  flex: 1;
}
.grid-cell {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #070b18;
  box-shadow: var(--shadow-sm);
  border: 0;
  padding: 0;
  cursor: pointer;
  min-height: 0;
  width: 100%;
  height: 100%;
}
.grid-cell video,
.grid-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.grid-cell .label {
  position: absolute; left: 10px; bottom: 10px; color: #fff; font-weight: 800; font-size: .85rem;
  text-shadow: 0 2px 10px rgba(0,0,0,.5); pointer-events: none;
}
.grid-cell .ph {
  width: 100%; height: 100%; display: grid; place-items: center; color: rgba(255,255,255,.3);
}
.grid-cell .cell-loader {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(7,11,24,.45); pointer-events: none;
}
.grid-cell .cell-loader .spinner { width: 28px; height: 28px; border-width: 2px; }
.muted.tight { margin: 0; font-size: .76rem; }

/* Shared */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.scroll-y { overflow: auto; min-height: 0; flex: 1; }
.two-col {
  display: grid; grid-template-columns: 1.25fr .75fr; gap: 14px;
  min-height: 0; height: 100%;
}
.two-col > * { min-height: 0; overflow: auto; }
.card.fill { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.card.side { display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--muted); font-weight: 600; line-height: 1.45; margin: 0 0 12px; }
.date-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip-btn {
  padding: 7px 12px; border-radius: 999px; background: #eef1f8;
  border: 1px solid var(--line); font-weight: 700; font-size: .76rem; color: var(--muted);
  transition: .15s var(--ease);
}
.chip-btn:hover { color: var(--navy); }
.chip-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.date-input {
  width: 100%;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0 11px;
  background: var(--surface-soft);
  font-weight: 600;
  margin-bottom: 10px;
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  min-height: 160px;
}
.empty-state .ico {
  width: 36px; height: 36px;
  color: var(--navy);
  opacity: 0.35;
}
.empty-state p {
  margin: 0;
  font-weight: 700;
  font-size: .9rem;
  max-width: 240px;
  line-height: 1.4;
}
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }

/* ─── Relecture master layout ─── */
.pb-layout {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  flex: 1;
  overflow: hidden;
}
.pb-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  height: 100%;
  padding: 14px;
  overflow: hidden;
}
.pb-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.pb-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(22, 32, 78, 0.12);
  background: #eef1f8;
  color: var(--navy);
  font-weight: 800;
  font-size: .82rem;
  cursor: pointer;
  transition: .15s var(--ease);
  max-width: min(280px, 42vw);
}
.pb-chip:hover,
.pb-chip.open {
  background: #fff;
  border-color: rgba(22, 32, 78, 0.22);
  box-shadow: var(--shadow-sm);
}
.pb-chip.soft {
  cursor: default;
  background: rgba(22, 32, 78, 0.08);
  font-variant-numeric: tabular-nums;
}
.pb-chip-ico {
  opacity: .7;
  font-size: .78rem;
}
.pb-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pb-spacer { flex: 1; min-width: 8px; }
.pb-shell .replay-player {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-height: none;
  position: relative;
  background: #0b1024;
  border-radius: 14px;
  overflow: hidden;
}
.pb-shell .replay-player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0b1024;
}
.pb-overlay-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.85);
  font-size: .84rem;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  max-width: 80%;
  z-index: 2;
}
.pb-shell .replay-player:has(video[src]) .pb-overlay-hint,
.pb-shell .replay-player.is-playing .pb-overlay-hint { display: none; }
.pb-transport {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.pb-shell .timeline-block { margin-top: 0; }
.pb-shell .replay-hint { margin: 0; flex-shrink: 0; }
.pb-popover {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: start center;
  padding: 64px 16px 16px;
  background: rgba(10, 14, 28, 0.28);
  backdrop-filter: blur(2px);
}
.pb-popover[hidden] { display: none !important; }
.pb-popover-card {
  width: min(420px, 100%);
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pb-popover-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.pb-popover-card .cam-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.pb-cal-card { width: min(360px, 100%); }
.seg-list { flex: 1; min-height: 0; overflow: auto; }
.seg-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid transparent;
  text-align: left;
  font-weight: 700;
  transition: .15s var(--ease);
  width: 100%;
}
.seg-item:hover { background: #eef1f8; }
.seg-item.active {
  border-color: rgba(22, 32, 78, 0.2);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.seg-item .seg-time { font-size: .84rem; color: var(--navy); }
.seg-item small { color: var(--muted); font-weight: 600; font-size: .72rem; }
.seg-item.alarm .seg-time { color: var(--red); }
.seg-item .seg-badge {
  font-size: .62rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 999px;
  background: rgba(22, 32, 78, 0.08); color: var(--navy);
}
.seg-item.alarm .seg-badge {
  background: rgba(242, 76, 82, 0.12); color: var(--red);
}

.slot-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid transparent;
  text-align: left;
  font-weight: 700;
}
.slot-btn:hover { background: #eef1f8; }
.slot-btn.active { border-color: rgba(22,32,78,.22); background: #fff; box-shadow: var(--shadow-sm); }
.slot-btn small { color: var(--muted); font-weight: 600; }

.timeline-block { margin-top: 14px; flex-shrink: 0; }
.pb-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: .78rem;
  font-weight: 800;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.pb-progress-meta span:last-child { color: var(--muted); font-weight: 700; }
.timeline {
  position: relative; height: 28px; border-radius: 8px;
  background: #e4e8f2; cursor: pointer; overflow: hidden;
}
.timeline.pb-progress {
  height: 10px;
  border-radius: 999px;
  background: #dde3f0;
}
.timeline.pb-progress .fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, #16204e, #24356e);
  pointer-events: none;
  z-index: 1;
  border-radius: 999px;
}
.timeline.pb-progress .head {
  position: absolute; top: 50%; left: 0%; width: 16px; height: 16px;
  margin: -8px 0 0 -8px; border-radius: 50%; background: #fff;
  border: 3px solid var(--navy);
  z-index: 3;
  box-shadow: 0 2px 8px rgba(16, 24, 47, 0.28);
}
.tl-labels {
  display: flex; justify-content: space-between; margin-top: 8px;
  color: var(--muted); font-size: .7rem; font-weight: 700;
}
.replay-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 12px 2px 0; gap: 12px; flex-wrap: wrap;
}
.replay-meta h2 { margin: 0; font-size: 1.05rem; font-weight: 900; color: var(--navy); }
.replay-meta .muted { margin: 4px 0 0; font-size: .82rem; }

/* ─── Alarmes ─── */
.alarms-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 320px;
  gap: 14px;
  min-height: 0;
  height: 100%;
  flex: 1;
  overflow: hidden;
}
.alarms-layout--single {
  grid-template-columns: 1fr;
  max-width: 920px;
}
.alarms-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.alarms-list { min-height: 0; }

.alarm-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.alarm-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.alarm-stat strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--navy);
  line-height: 1.1;
}
.alarm-stat span {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .02em;
}
.alarm-stat.critical strong { color: var(--red); }

.alarm {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 14px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); text-align: left;
  transition: .15s var(--ease);
  width: 100%;
  cursor: pointer;
}
.alarm:hover { border-color: rgba(22, 32, 78, 0.16); }
.alarm.active { outline: 2px solid rgba(22,32,78,.16); outline-offset: 0; }
.alarm.unread {
  box-shadow: inset 3px 0 0 var(--red), var(--shadow-sm);
}
.alarm-ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(242,76,82,.1); color: var(--red);
}
.alarm-body { min-width: 0; }
.alarm strong { display: block; font-size: .9rem; color: var(--navy); }
.alarm span { color: var(--muted); font-size: .8rem; font-weight: 600; }
.alarm time {
  color: var(--navy);
  font-size: .84rem;
  font-weight: 800;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.alarm-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.alarm-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-box {
  border-radius: 12px; overflow: hidden; background: #0b1024; aspect-ratio: 16/10; margin-bottom: 12px;
}
.preview-box img, .preview-box video { width: 100%; height: 100%; object-fit: cover; }

/* ─── IA (rewrite) ─── */
.ai-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.ai-hero {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-shrink: 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #16204e 0%, #24306e 55%, #1a2558 100%);
  color: #fff;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.ai-hero-glow {
  position: absolute;
  right: -40px; top: -50px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242,76,82,.45), transparent 70%);
  pointer-events: none;
}
.ai-hero .ico { color: #fff; opacity: .9; position: relative; z-index: 1; }
.ai-hero h2 { margin: 0 0 4px; font-size: 1.2rem; font-weight: 900; color: #fff; position: relative; z-index: 1; }
.ai-hero p { margin: 0; color: rgba(255,255,255,.75); font-weight: 600; position: relative; z-index: 1; }
.ai-tabs {
  display: flex; gap: 6px; flex-shrink: 0;
  padding: 4px; border-radius: 12px;
  background: rgba(22,32,78,.06); border: 1px solid var(--line);
}
.ai-tab {
  flex: 1; height: 38px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  font-weight: 800; font-size: .82rem; cursor: pointer;
}
.ai-tab.active {
  background: #fff; color: var(--navy);
  box-shadow: var(--shadow-sm);
}
.ai-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.ai-form { display: flex; gap: 10px; flex-shrink: 0; }
.ai-form input {
  flex: 1; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  padding: 0 14px; background: var(--surface); font-weight: 600; outline: 0;
}
.ai-loading {
  display: grid; place-items: center; gap: 10px; padding: 48px 20px;
  color: var(--muted); font-weight: 700; flex: 1;
}
.ai-pager {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  flex-shrink: 0; padding: 4px 0;
  font-weight: 700; font-size: .82rem; color: var(--muted);
}
.ai-pager .ghost { min-width: 72px; height: 34px; }
.ai-pager .ghost:disabled { opacity: .4; cursor: default; }
.stat-pills { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.stat-pill {
  padding: 8px 12px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); font-size: .76rem; font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.stat-pill strong { display: block; font-size: 1.05rem; color: var(--navy); }
.tag {
  display: inline-flex; padding: 4px 8px; border-radius: 999px;
  background: rgba(22,32,78,.08); color: var(--navy); font-size: .65rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em;
}

/* Cards IA — layout horizontal, texte simple (pas de -webkit-line-clamp) */
.iap-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  overflow: auto;
  min-height: 0;
  flex: 1;
  align-content: start;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 1100px) {
  .iap-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
}
@media (min-width: 1600px) {
  .iap-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.iap-card {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-height: 148px;
}
.iap-media {
  position: relative;
  background: #0b1024;
  min-height: 148px;
  height: 100%;
}
.iap-media-btn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: #0b1024;
}
.iap-media-btn img,
.iap-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.iap-media-ph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.35);
  background: #0b1024;
}
.iap-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(22, 32, 78, 0.88);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.iap-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 8px;
  min-width: 0;
  background: #fff;
}
.iap-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: nowrap;
}
.iap-chip {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(22, 32, 78, 0.08);
  color: #16204e;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.iap-title {
  margin: 0;
  color: #16204e;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 0 1 auto;
}
.iap-time {
  margin: 0 0 0 auto;
  color: #5b6588;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  flex: 0 0 auto;
}
.iap-expand {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.iap-text {
  margin: 0;
  color: #3d4663;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.iap-text.is-clamped {
  max-height: calc(1.4em * 3);
  overflow: hidden;
}
.iap-more {
  align-self: flex-start;
  height: 28px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: #16204e;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(22, 32, 78, 0.16);
}
.iap-more:hover { background: #1c2a68; }

/* Popup détail VizIA — quasi plein écran */
.vizia-detail-modal {
  z-index: 90;
  background: rgba(8, 12, 28, 0.78);
  padding: 16px !important;
  align-items: stretch;
}
.vizia-detail-modal:not([hidden]) {
  display: grid !important;
  place-items: stretch;
}
.modal-card.vizia-detail-card,
.vizia-detail-card {
  width: min(1680px, 100%) !important;
  height: calc(100vh - 32px) !important;
  max-width: none !important;
  max-height: calc(100vh - 32px) !important;
  margin: 0 auto;
  padding: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  animation: popIn .28s var(--ease);
  box-shadow: 0 30px 90px rgba(8, 12, 28, 0.45);
}
.vizia-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  margin: 0;
  flex-shrink: 0;
}
.vizia-detail-head-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}
.vizia-detail-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--navy);
}
.vizia-detail-time {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}
.vizia-detail-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  min-height: 0;
  flex: 1;
  height: 100%;
}
.vizia-detail-stage {
  position: relative;
  background: #070b18;
  min-height: 0;
  height: 100%;
}
.vizia-detail-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #070b18;
}
.vizia-detail-stage .loader { border-radius: 0; }
.vizia-detail-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  height: 100%;
  padding: 18px 20px;
  border-left: 1px solid var(--line);
  background: #f7f8fc;
}
.vizia-detail-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.vizia-detail-text {
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  color: #2f3854;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
@media (max-width: 960px) {
  .vizia-detail-modal { padding: 8px !important; }
  .vizia-detail-card {
    width: 100%;
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
  }
  .vizia-detail-split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.4fr) minmax(180px, 0.8fr);
  }
  .vizia-detail-side {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px 14px;
  }
}
.iap-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}
.iap-actions .cta,
.iap-actions .ghost {
  height: 34px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 800;
}
.iap-actions .cta {
  color: #fff;
  background: #16204e;
  padding: 0 14px;
}
.iap-actions .ghost {
  background: #e8ecf5;
  color: #16204e;
  padding: 0 12px;
}
@media (max-width: 720px) {
  .iap-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .iap-media {
    min-height: 0;
    aspect-ratio: 16 / 9;
    height: auto;
  }
}

/* Chat VizIA */
.ai-chat {
  display: flex; flex-direction: column; gap: 10px;
  flex: 1; min-height: 0; overflow: hidden;
}
.ai-chat-thread {
  flex: 1; min-height: 0; overflow: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px 2px 8px;
  -webkit-overflow-scrolling: touch;
  overflow-anchor: none;
}
.ai-chat-welcome {
  margin: auto 0; text-align: center; padding: 24px 12px;
}
.ai-chat.is-empty .ai-chat-thread { justify-content: center; }
.ai-chat-welcome .ai-chat-composer {
  margin: 14px auto 0;
  padding-top: 0;
  border-top: 0;
  width: min(100%, 520px);
}
.ai-chat-welcome-title { margin: 0 0 6px; font-size: 1.1rem; font-weight: 900; color: var(--navy); }
.ai-chat-welcome-sub { margin: 0 0 16px; color: var(--muted); font-weight: 600; font-size: .86rem; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ai-chip {
  border: 1px solid var(--line); background: #fff; color: var(--navy);
  border-radius: 999px; padding: 8px 12px; font-weight: 700; font-size: .78rem;
  cursor: pointer; box-shadow: var(--shadow-sm);
}
.ai-chip:hover { border-color: rgba(22,32,78,.28); }
.ai-chat-row { display: flex; flex-direction: column; gap: 8px; max-width: 100%; }
.ai-chat-row--user { align-items: flex-end; }
.ai-chat-row--bot { align-items: flex-start; }
.ai-bubble {
  max-width: min(100%, 640px); padding: 12px 14px; border-radius: 14px;
  font-weight: 600; font-size: .88rem; line-height: 1.4;
}
.ai-bubble--user {
  background: var(--navy); color: #fff; border-bottom-right-radius: 6px;
}
.ai-bubble--bot {
  background: #fff; border: 1px solid var(--line); color: var(--navy);
  border-bottom-left-radius: 6px; box-shadow: var(--shadow-sm);
}
.ai-bubble--typing { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.ai-bubble--error { color: #b42318; }
.ai-bubble-text { margin: 0; white-space: pre-wrap; }
.ai-chat-hits { width: 100%; }
.ai-search-count { margin: 0 0 8px; font-size: .78rem; font-weight: 800; color: var(--muted); }
.ai-chat-hits .iap-grid { flex: none; overflow: visible; }
.ai-hit-pager { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
.ai-hit-next {
  height: 40px; padding: 0 18px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); color: var(--navy);
  font-weight: 800; font-size: .82rem; box-shadow: var(--shadow-sm);
}
.ai-hit-next:hover { border-color: rgba(22,32,78,.28); }
.ai-seek {
  display: flex; align-items: center; gap: 16px;
  width: min(100%, 460px); padding: 16px 18px; border-radius: 18px;
  background:
    radial-gradient(120px 80px at 16% 50%, rgba(242,76,82,.22), transparent 70%),
    linear-gradient(135deg, #16204e 0%, #24306e 62%, #1a2558 100%);
  color: #fff;
  box-shadow: 0 14px 34px rgba(22,32,78,.22);
}
.ai-seek-orb { position: relative; width: 54px; height: 54px; flex: none; }
.ai-seek-ring, .ai-seek-sweep, .ai-seek-core { position: absolute; border-radius: 50%; }
.ai-seek-ring {
  inset: 0; border: 1.5px solid rgba(255,255,255,.35);
  animation: aiSeekPulse 2.2s ease-out infinite;
}
.ai-seek-ring-b { inset: 8px; border-color: rgba(242,76,82,.85); animation-delay: .55s; }
.ai-seek-sweep {
  inset: 5px;
  background: conic-gradient(from 0deg, transparent 0 70%, rgba(255,255,255,.95) 86%, transparent 100%);
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 61%);
  mask: radial-gradient(circle, transparent 58%, #000 61%);
  animation: aiSeekSpin 1.35s linear infinite;
}
.ai-seek-core {
  inset: 20px; background: #fff;
  box-shadow: 0 0 14px rgba(255,255,255,.75);
}
.ai-seek-kicker {
  margin: 0; font-size: .62rem; letter-spacing: .16em; text-transform: uppercase;
  font-weight: 800; opacity: .62;
}
.ai-seek-title { margin: 2px 0 0; font-weight: 800; font-size: .98rem; }
.ai-seek-lines { position: relative; height: 1.15em; margin: 4px 0 0; }
.ai-seek-lines span {
  position: absolute; left: 0; top: 0;
  font-size: .78rem; font-weight: 600; color: rgba(255,255,255,.78);
  opacity: 0; animation: aiSeekLine 6.6s infinite;
}
.ai-seek-lines span:nth-child(2) { animation-delay: 2.2s; }
.ai-seek-lines span:nth-child(3) { animation-delay: 4.4s; }
@keyframes aiSeekSpin { to { transform: rotate(360deg); } }
@keyframes aiSeekPulse {
  0% { transform: scale(.86); opacity: .85; }
  100% { transform: scale(1.16); opacity: 0; }
}
@keyframes aiSeekLine {
  0%, 6% { opacity: 0; transform: translateY(5px); }
  14%, 28% { opacity: 1; transform: none; }
  36%, 100% { opacity: 0; transform: translateY(-5px); }
}
@media (prefers-reduced-motion: reduce) {
  .ai-seek-ring, .ai-seek-sweep, .ai-seek-lines span { animation: none; }
  .ai-seek-lines span { position: static; opacity: 1; }
  .ai-seek-lines span:nth-child(n + 2) { display: none; }
}
.ai-chat-composer {
  display: flex; gap: 10px; flex-shrink: 0;
  padding-top: 4px; border-top: 1px solid var(--line);
}
.ai-chat-composer input {
  flex: 1; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  padding: 0 14px; background: var(--surface); font-weight: 600; outline: 0;
}
.ai-chat-composer .cta { min-width: 48px; padding: 0 14px; }
.spinner.sm {
  width: 16px; height: 16px; border-width: 2px;
}

.settings-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  overflow: auto; height: 100%; align-content: start;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; font-weight: 700; font-size: .78rem; color: var(--muted); }
.field input, .field select {
  height: 40px; border-radius: 10px; border: 1px solid var(--line);
  padding: 0 11px; background: var(--surface-soft); color: var(--ink); font-weight: 600;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.code {
  margin: 0; padding: 12px; border-radius: 12px; background: #0f1733; color: #c9d4ff;
  font-size: .72rem; overflow: auto; max-height: 220px;
}
.device-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 11px; border-radius: 12px; background: var(--surface-soft); font-weight: 700;
}
.device-row small { display: block; color: var(--muted); margin-top: 2px; font-weight: 600; }
.device-row .actions { display: flex; gap: 6px; }

/* Gestion appareils (comme l’app) */
.devices-mgr { display: flex; flex-direction: column; gap: 14px; }
.devices-mgr-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.devices-mgr-count { margin: 0; font-size: 1.05rem; font-weight: 900; color: var(--navy); }
.devices-mgr-sub { margin: 4px 0 0; color: var(--muted); font-size: .8rem; font-weight: 600; }
.devices-list { display: flex; flex-direction: column; gap: 10px; }
.dev-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 14px; border-radius: 14px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.dev-card.is-selected { border-color: rgba(22,32,78,.35); box-shadow: 0 0 0 2px rgba(22,32,78,.08); }
.dev-card-main {
  display: flex; align-items: center; gap: 12px; cursor: pointer; min-width: 0;
}
.dev-card-ico {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  background: rgba(22,32,78,.08); color: var(--navy);
}
.dev-card-ico .ico, .dev-card-ico svg { width: 22px; height: 22px; }
.dev-card-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dev-card-name {
  font-size: .95rem; font-weight: 800; color: var(--navy);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dev-card-sn { font-size: .78rem; font-weight: 700; color: var(--muted); }
.dev-card-meta { font-size: .72rem; font-weight: 600; color: #7a849f; }
.dev-card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.dev-card-actions .ghost.sm { height: 32px; padding: 0 10px; font-size: .74rem; }
.danger-text { color: var(--red) !important; }
.devices-empty {
  text-align: center; padding: 36px 16px;
  border-radius: 16px; background: var(--surface-soft); border: 1px dashed var(--line);
}
.devices-empty-title { margin: 10px 0 4px; font-weight: 900; color: var(--navy); }
.devices-empty-hint { margin: 0 0 14px; color: var(--muted); font-weight: 600; font-size: .84rem; }
.device-form-hint {
  margin: -4px 0 12px; color: var(--muted); font-size: .78rem; font-weight: 600;
}
.device-form-error {
  margin: 0 0 10px; padding: 10px 12px; border-radius: 10px;
  background: rgba(242,76,82,.1); color: #b42318; font-weight: 700; font-size: .8rem;
}
.device-form-card { width: min(480px, 100%); }
.field input.is-locked { background: #eef1f8; color: var(--muted); }
.switch-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 700;
}
.switch-row:last-of-type { border-bottom: 0; }
.switch-row small { display: block; color: var(--muted); font-weight: 600; margin-top: 2px; }
.toggle {
  width: 44px; height: 26px; border-radius: 999px; background: #cfd5e8;
  position: relative; flex-shrink: 0; transition: .2s var(--ease);
}
.toggle.on { background: var(--navy); }
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: .2s var(--ease); box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.toggle.on::after { left: 21px; }

/* Settings hub */
.settings-shell {
  height: 100%; min-height: 0; display: flex; flex-direction: column;
}
.settings-hub, .settings-detail {
  height: 100%; min-height: 0; display: flex; flex-direction: column;
  max-width: 720px;
}
.settings-hub.scroll-y, .settings-detail-body {
  overflow: auto; min-height: 0; flex: 1;
  padding-bottom: 24px;
}
.settings-hero {
  display: flex; gap: 14px; align-items: center; margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(22,32,78,.06), rgba(242,76,82,.05));
  border: 1px solid var(--line);
}
.settings-hero .hero-ico {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--navy);
  color: #fff; display: grid; place-items: center; flex-shrink: 0;
}
.settings-hero h2 { margin: 0 0 4px; font-size: 1.15rem; font-weight: 900; color: var(--navy); }
.settings-hero p { margin: 0; color: var(--muted); font-weight: 600; font-size: .82rem; }
.settings-nvr-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.settings-group-title {
  margin: 18px 2px 8px; font-size: .68rem; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.settings-nav-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  text-align: left; padding: 14px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); transition: .2s var(--ease);
}
.settings-nav-item:hover { transform: translateY(-1px); border-color: rgba(22,32,78,.2); }
.settings-nav-ico {
  width: 40px; height: 40px; border-radius: 11px;
  background: rgba(22, 32, 78, 0.08); color: var(--navy);
  display: grid; place-items: center; flex-shrink: 0;
}
.settings-nav-ico .ico, .settings-nav-ico svg { width: 18px; height: 18px; }
.settings-nav-item strong { display: block; font-size: .92rem; font-weight: 800; color: var(--navy); }
.settings-nav-item small { display: block; color: var(--muted); font-weight: 600; margin-top: 2px; font-size: .74rem; }
.settings-nav-item .chev { margin-left: auto; color: var(--muted); font-size: 1.4rem; font-weight: 300; }
.settings-detail-bar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-shrink: 0;
}
.settings-detail-bar h2 { margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--navy); }
.settings-kv {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px;
  padding: 12px 14px; border-radius: 12px; background: var(--surface-soft);
  border: 1px solid var(--line); margin-bottom: 8px; align-items: center;
}
.settings-kv span { color: var(--muted); font-weight: 700; font-size: .78rem; }
.settings-kv strong { font-weight: 800; font-size: .88rem; text-align: right; }
.settings-subhead {
  margin: 16px 2px 8px; font-size: .85rem; font-weight: 800; color: var(--navy);
}
.range-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.range-row label {
  display: flex; justify-content: space-between; font-weight: 700;
  font-size: .78rem; color: var(--muted);
}
.range-row input[type="range"] { width: 100%; accent-color: var(--navy); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.danger-btn {
  height: 42px; padding: 0 14px; border-radius: 12px; font-weight: 800;
  background: rgba(242,76,82,.1); color: var(--red); width: 100%;
  margin-top: 8px;
}
.ghost.block { width: 100%; justify-content: center; margin-top: 8px; display: inline-flex; align-items: center; }

.modal {
  position: fixed; inset: 0; background: rgba(10,14,30,.48);
  backdrop-filter: blur(5px); display: grid; place-items: center; z-index: 40; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(460px, 100%); background: #fff; border-radius: 20px;
  padding: 18px; box-shadow: 0 30px 80px rgba(16,24,47,.3);
}
.modal-card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-card h2 { margin: 0; font-size: 1.1rem; font-weight: 900; }
.modal-card footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Alarm video popup */
.alarm-video-modal {
  z-index: 80;
  background: rgba(8, 12, 28, 0.72);
}
.alarm-video-modal:not([hidden]) {
  display: grid !important;
}
.alarm-video-card {
  width: min(920px, 100%);
  padding: 0;
  overflow: hidden;
  background: #fff;
  animation: popIn .28s var(--ease);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.alarm-video-card > header {
  padding: 14px 16px 10px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.alarm-video-card .eyebrow { margin: 0 0 2px; }
.alarm-video-stage {
  position: relative;
  background: #070b18;
  aspect-ratio: 16 / 9;
  max-height: min(62vh, 560px);
}
.alarm-video-stage video {
  width: 100%; height: 100%; object-fit: contain; display: block; background: #070b18;
}
.alarm-video-stage .loader { border-radius: 0; }
.alarm-video-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px 14px; flex-wrap: wrap;
  margin: 0; border-top: 1px solid var(--line);
}
.alarm-video-footer .muted { margin: 0; font-size: .82rem; }
.alarm-video-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Thumbs polish */
.cam-item .thumb {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.cam-item .thumb img {
  transition: opacity .35s var(--ease), transform .45s var(--ease);
}
.cam-item.active .thumb img { transform: scale(1.03); }
.cam-item .thumb.updating img { opacity: .55; }
.thumb-fade-in { animation: thumbIn .4s var(--ease); }
@keyframes thumbIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Replay polish */
.replay-layout {
  grid-template-columns: 248px minmax(0, 1fr) 300px;
  gap: 14px;
}
.replay-cams, .replay-side, .replay-main {
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.replay-meta {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  margin: 12px 0 10px;
}
.replay-meta h2 { margin: 0; font-size: 1.05rem; font-weight: 900; color: var(--navy); }
.replay-player {
  max-height: min(52vh, 520px);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(16,24,47,.16);
}
.calendar-hint { margin: -4px 0 12px; font-size: .75rem; }
.count-pill {
  min-width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center;
  background: #e8ecf7; color: var(--navy); font-weight: 800; font-size: .75rem;
}
.seg-item {
  border-radius: 12px;
  transition: .18s var(--ease);
}
.seg-item:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.seg-item.alarm-seg {
  border-color: rgba(242,76,82,.28);
  background: rgba(242,76,82,.05);
}

/* Canal settings tabs */
.canal-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 4px; margin: 0 0 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.canal-tab {
  flex: 1; min-width: 88px;
  height: 34px; padding: 0 10px;
  border-radius: 9px; font-weight: 800; font-size: .76rem;
  color: var(--muted); transition: .18s var(--ease);
}
.canal-tab:hover { color: var(--navy); }
.canal-tab.active {
  background: var(--navy); color: #fff;
  box-shadow: 0 6px 14px rgba(22,32,78,.18);
}
.canal-pane { animation: fadePane .22s var(--ease); }
@keyframes fadePane {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.settings-cam-pick {
  max-height: 220px; overflow: auto; margin-bottom: 8px;
  padding-right: 2px;
}

/* Alarms list polish */
.alarm {
  transition: .18s var(--ease);
}
.alarm:hover { transform: translateX(2px); }
.alarm.active {
  border-color: rgba(22,32,78,.2);
  box-shadow: var(--shadow-sm);
}
.preview-box {
  border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 12px;
  background: #0c1224;
  aspect-ratio: 16 / 9;
}
.preview-box img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Replay calendar + timeline scrub */
.replay-meta-actions { display: flex; align-items: center; gap: 8px; }
.replay-hint { margin: 8px 2px 0; }
.timeline {
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.timeline.is-dragging { cursor: grabbing; }
.timeline.pb-progress .head {
  transition: none;
}
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 10px;
}
.cal-nav strong {
  font-size: .92rem; font-weight: 900; color: var(--navy);
  text-transform: capitalize;
}
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-bottom: 4px; text-align: center;
  font-size: .68rem; font-weight: 800; color: var(--muted);
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-bottom: 12px;
}
.cal-day {
  aspect-ratio: 1; border-radius: 10px;
  font-weight: 800; font-size: .78rem; color: var(--navy);
  background: var(--surface-soft); border: 1px solid transparent;
  transition: .15s var(--ease);
}
.cal-day:hover:not(:disabled) { border-color: rgba(22,32,78,.2); background: #fff; }
.cal-day:disabled { opacity: .28; cursor: default; }
.cal-day.muted { color: var(--muted); font-weight: 600; }
.cal-day.today { box-shadow: inset 0 0 0 1px rgba(22,32,78,.25); }
.cal-day.selected {
  background: var(--navy); color: #fff; border-color: var(--navy);
  box-shadow: 0 6px 14px rgba(22,32,78,.2);
}
.cal-day.has-rec::after {
  content: ""; display: block; width: 4px; height: 4px; margin: 2px auto 0;
  border-radius: 50%; background: var(--red);
}
.cal-day.selected.has-rec::after { background: #fff; }
.cal-quick { margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px);
  background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 12px;
  font-weight: 700; opacity: 0; pointer-events: none; transition: .25s var(--ease); z-index: 50;
  max-width: min(520px, calc(100vw - 32px)); text-align: center; line-height: 1.35;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.ico { display: inline-flex; width: 18px; height: 18px; }
.ico svg { width: 100%; height: 100%; }
.ico.xl { width: 32px; height: 32px; }

@media (max-width: 1100px) {
  :root { --rail: 78px; }
  .brand > div, .nav-btn span:not(.ico), .nav-btn .badge, .sidebar-devices-text { display: none; }
  .nav-btn { justify-content: center; }
  .sidebar-card { display: flex; justify-content: center; background: transparent; border: 0; }
  .sidebar-devices-btn { justify-content: center; padding: 10px; }
  .sidebar-devices-ico { width: 40px; height: 40px; }
  .live-layout, .two-col, .settings-grid, .alarms-layout { grid-template-columns: 1fr; }
  .pb-popover { padding-top: 56px; }
  .live-layout { grid-template-rows: minmax(0, 1fr) auto; }
  .cam-panel { max-height: min(200px, 28vh); }
  .cam-list { flex-direction: row; }
  .cam-item { min-width: 220px; }
  .stage { container-type: size; min-height: 200px; }
  .player {
    width: min(100%, calc(100cqh * var(--ar, 1.7777778)));
    height: min(100%, calc(100cqw / var(--ar, 1.7777778)));
    max-height: min(56vh, 100%);
  }
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100dvh; max-height: none; }
  .workspace { height: auto; overflow: visible; }
  .panel.active { overflow: visible; height: auto; }
  .grid-layout.cols-3 .grid-cells { grid-template-columns: repeat(2, 1fr); }
  .alarm-summary { grid-template-columns: repeat(3, 1fr); }
}
@supports not (width: 1cqw) {
  .player {
    width: 100%;
    height: auto;
    max-height: calc(100dvh - 160px);
    aspect-ratio: var(--ar, 1.7777778);
  }
}
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto;
    flex-direction: row; padding: 8px; z-index: 30;
  }
  .brand, .sidebar-card { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .workspace { padding: 14px 12px 86px; }
  .top { flex-direction: column; align-items: stretch; }
  .search-box { min-width: 0; max-width: none; flex: 1; }
  .view-modes { order: 3; }
  .grid-layout.cols-2 .grid-cells,
  .grid-layout.cols-3 .grid-cells { grid-template-columns: 1fr 1fr; }
  .alarm-summary { grid-template-columns: 1fr; }
}

.count-pill {
  min-width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center;
  background: #e8ecf7; color: var(--navy); font-weight: 800; font-size: .75rem;
  flex-shrink: 0;
}
.warn-line {
  color: var(--red);
  font-weight: 700;
  font-size: .82rem;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(242,76,82,.08);
  border: 1px solid rgba(242,76,82,.18);
}
.stat-pills { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.stat-pill {
  padding: 8px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: .74rem; font-weight: 700; color: var(--muted);
  box-shadow: var(--shadow-sm);
}
.stat-pill strong { color: var(--navy); margin-right: 5px; font-weight: 900; }
.timeline { cursor: pointer; }
.seg-item .seg-dur {
  display: block;
  font-size: .68rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
}


/* Paramètres restent hors navigation */
.nav-btn[data-view="settings"],
#btnSidebarDevices,
.sidebar-card {
  display: none !important;
}

.pb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 14px;
}
.pb-cams {
  min-height: 0;
  height: 100%;
}
.timeline.pb-progress {
  height: 36px;
  border-radius: 10px;
}
.tl-segs {
  position: absolute;
  inset: 7px 8px;
  z-index: 0;
  pointer-events: none;
}
.tl-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  background: rgba(36, 140, 96, 0.72);
}
.tl-seg.is-alarm {
  background: rgba(242, 76, 82, 0.88);
}
.timeline.pb-progress .fill {
  height: 3px;
  top: auto;
  bottom: 3px;
  border-radius: 999px;
}
.alarms-layout.alarms-layout--single {
  grid-template-columns: minmax(0, 1fr) 292px;
  max-width: none;
}
.alarm-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #0b1024;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.alarm-stage video {
  width: 100%;
  height: min(38vh, 320px);
  object-fit: contain;
  background: #0b1024;
  display: block;
}
.alarm-stage-meta {
  padding: 10px 12px 12px;
  background: #12182e;
  color: #fff;
}
.alarm-stage-meta h2 {
  margin: 0;
  font-size: .95rem;
  font-weight: 800;
}
.alarm-stage-meta p {
  margin: 3px 0 0;
  font-size: .78rem;
  opacity: .8;
}
.alarm.has-thumb {
  grid-template-columns: 84px 1fr auto;
}
.alarm-thumb {
  width: 84px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  background: #0b1024;
}
.alarm-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 1100px) {
  .pb-layout,
  .alarms-layout.alarms-layout--single {
    grid-template-columns: 1fr;
  }
  .pb-cams,
  #panel-alarms .cam-panel {
    max-height: 240px;
  }
}

/* alarm-grid-20261026d */
.alarms-layout.alarms-layout--single {
  display: flex;
  flex-direction: column;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
}
#panel-alarms .alarms-main {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
#alarmsList.alarm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
  overflow: auto;
  min-height: 0;
  flex: 1;
  padding: 2px 2px 18px;
}
#alarmsList.alarm-grid .alarm-event.is-active {
  box-shadow: 0 0 0 2px rgba(22, 32, 78, 0.28);
}
@media (max-width: 1100px) {
  #alarmsList.alarm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  #alarmsList.alarm-grid { grid-template-columns: 1fr; }
}

/* live-toolbar-ptz-20261026g */
#panel-live > .top-actions {
  flex: 0 0 auto;
  width: 100%;
  justify-content: flex-start;
  margin: 0 0 10px;
}
#panel-live > .live-layout {
  height: auto;
  flex: 1;
  min-height: 0;
}


/* toolbar-audio-20261026l */
.brand-show { margin-top: 0; }
.cam-panel > .search-box {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0 0 12px;
  flex-shrink: 0;
}
.quality-toggle {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
#panel-live .quality-toggle #btnSd,
#panel-live .quality-toggle #btnHdTop {
  width: auto;
  min-width: 44px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: var(--navy);
  font-weight: 900;
  font-size: .78rem;
  letter-spacing: .04em;
}
#panel-live .quality-toggle #btnSd.active,
#panel-live .quality-toggle #btnHdTop.active {
  background: var(--navy);
  border-color: transparent;
  color: #fff;
  box-shadow: none;
}
.audio-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
