/* Alerte d'urgence (§159, maquettes/urgence.html) : bouton et pastille de la barre du haut, bandeau, bouton flottant du mobile, tiroir, aperçu. */
:root { --alert: #B00020; --alert-dark: #7A0016; }

/* barre du haut (ordinateur) */
.embtn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border: 1.5px solid var(--alert); background: #fff; color: var(--alert); border-radius: 17px; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; margin-right: 6px; }
.embtn:hover { background: var(--alert); color: #fff; }
.emchip { display: inline-flex; align-items: center; gap: 9px; height: 34px; padding: 0 6px 0 14px; border: 0; background: var(--alert); color: #fff; border-radius: 17px; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; margin-right: 6px; animation: em-ring 1.8s infinite; }
.emchip i { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: em-blink 1.1s infinite; }
.emchip b { background: #fff; color: var(--alert); border-radius: 12px; padding: 2px 11px; font-weight: 600; font-size: 12.5px; }
@keyframes em-ring { 0% { box-shadow: 0 0 0 0 rgba(176, 0, 32, .55); } 70% { box-shadow: 0 0 0 9px rgba(176, 0, 32, 0); } 100% { box-shadow: 0 0 0 0 rgba(176, 0, 32, 0); } }
@keyframes em-blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .emchip, .emchip i, .em-bar { animation: none; } }

/* bandeau rouge : toutes les pages, cliquable pour lever */
.em-bar { position: sticky; top: 0; z-index: 70; display: flex; align-items: center; gap: 12px; background: var(--alert); color: #fff; padding: 9px 20px; font-size: 14px; cursor: pointer; }
.em-bar .x { flex: 1; }
.em-bar u { text-underline-offset: 2px; }
.em-bar .b { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .7); border-radius: 4px; padding: 5px 12px; font: inherit; font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; }
.em-bar .b:hover { background: rgba(255, 255, 255, .15); }

/* mobile (app) : bouton flottant, bandeau collé en haut */
.em-fab { display: none; }
body.is-app .em-fab { display: inline-flex; position: fixed; right: 14px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 65; align-items: center; gap: 7px; height: 44px; padding: 0 18px; border: 0; border-radius: 22px; background: var(--alert); color: #fff; font: inherit; font-weight: 600; font-size: 14px; box-shadow: 0 4px 14px rgba(176, 0, 32, .45); cursor: pointer; }
body.is-app .embtn, body.is-app .emchip { display: none; }
body.is-app .em-bar { padding: 10px 14px; font-size: 13px; }
@media (max-width: 760px) { .em-bar .b { display: none; } .em-bar { padding: 10px 14px; } }

/* tiroir : formulaire, rapport, historique */
.emx-note { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.emx-f { margin-top: 14px; }
.emx-f > label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.emx-f > label small { font-weight: 400; color: var(--muted); }
.emx-f .cnt { float: right; font-weight: 400; color: var(--muted); font-size: 12px; }
.emx-f input[type=text], .emx-f textarea, .emx-f select { width: 100%; font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; }
.emx-f textarea { min-height: 78px; resize: vertical; }
.emx-sec { font-size: 12.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 6px; }
.emx-radio { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 9px 12px; margin-bottom: 7px; cursor: pointer; background: #fff; text-align: left; font: inherit; color: inherit; width: 100%; }
.emx-radio.on { border-color: var(--alert); background: #FFF7F6; box-shadow: inset 0 0 0 1px var(--alert); }
.emx-radio .rd { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-2); margin-top: 3px; flex: none; background: #fff; }
.emx-radio.on .rd { border: 5px solid var(--alert); }
.emx-radio small { display: block; color: var(--muted); font-size: 12.5px; }
.emx-pick { border: 1px solid var(--line); border-radius: var(--radius); max-height: 190px; overflow: auto; margin: -2px 0 8px; }
.emx-pick label { display: flex; gap: 9px; align-items: center; padding: 6px 12px; font-size: 14px; border-bottom: 1px solid var(--row); cursor: pointer; }
.emx-pick label:last-child { border-bottom: 0; }
.emx-err { color: var(--danger, #C8372D); font-size: 13.5px; margin-top: 10px; }
.emx-test { margin-top: 8px; border-radius: var(--radius); padding: 8px 12px; font-size: 13.5px; background: #E1F0E8; color: #155A38; }
.emx-tbl { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; border: 1px solid var(--line); }
.emx-tbl th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); background: #FAFBFC; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.emx-tbl td { padding: 9px 12px; border-bottom: 1px solid var(--row); vertical-align: top; }
.emx-tbl tr:last-child td { border-bottom: 0; }
.emx-tbl small { display: block; color: var(--muted); font-size: 12.5px; }
.emx-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 11px; padding: 0 9px; line-height: 21px; font-size: 12.5px; white-space: nowrap; }
.emx-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.emx-pill.ok { background: #E1F0E8; color: #155A38; }
.emx-pill.warn { background: #FBF0DC; color: #7A4F12; }
.emx-pill.bad { background: #FBE4E2; color: #8A231C; }
.emx-pill.red { background: var(--alert); color: #fff; }
.emx-pill.off { background: var(--row); color: var(--muted); }
.emx-btn-red { background: var(--alert) !important; border-color: var(--alert) !important; color: #fff !important; font-weight: 500; }
.emx-btn-red:hover { background: var(--alert-dark) !important; }

/* aperçu : ce que l'écran affichera (mêmes proportions que emergency.js) */
.emx-tv { background: #000; border: 8px solid #1b2a3f; border-radius: 10px; aspect-ratio: 16 / 9; position: relative; overflow: hidden; container-type: size; }
.emx-tv.test .emx-test-lbl { position: absolute; top: 0; left: 0; right: 0; background: #fff; color: var(--alert); font-weight: 700; font-size: 3cqmin; padding: 1cqmin; text-align: center; letter-spacing: .06em; }
.emx-em { position: absolute; inset: 0; background: radial-gradient(120% 120% at 50% 40%, #C4001F 0%, var(--alert) 55%, var(--alert-dark) 100%); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 6cqh 7cqw; }
.emx-em::before { content: ""; position: absolute; inset: 2.2cqmin; border: .9cqmin solid rgba(255, 255, 255, .85); border-radius: 1.2cqmin; opacity: .7; }
.emx-em .ico { width: 15cqmin; height: 15cqmin; margin-bottom: 3cqmin; }
.emx-em .ico svg { width: 100%; height: 100%; }
.emx-em .ti { font-size: 9cqmin; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; line-height: 1.05; max-width: 90cqw; word-wrap: break-word; }
.emx-em .me { font-size: 5.4cqmin; font-weight: 500; line-height: 1.3; max-width: 88cqw; margin-top: 3cqmin; word-wrap: break-word; white-space: pre-line; }
.emx-em.long .ti { font-size: 7cqmin; }
.emx-em.long .me { font-size: 4cqmin; }
.emx-em .ft { position: absolute; left: 0; right: 0; bottom: 3.6cqmin; font-size: 2.6cqmin; opacity: .85; }

.emx-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 20px; margin: 0; }
.emx-tabs button { border: 0; background: none; font: inherit; font-size: 14.5px; color: var(--muted); padding: 8px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.emx-tabs button.on { color: var(--ink); font-weight: 500; border-color: var(--alert); }

/* fenêtres de confirmation (déclencher, lever) : au centre, au-dessus du voile (1100) qui couvre le tiroir ; en feuille du bas sur petit écran */
.em-dlg { position: fixed; z-index: 1101; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; background: #fff; border-radius: 8px; box-shadow: 0 20px 50px rgba(11, 31, 58, .3); }
.em-dlg-h { padding: 18px 22px 4px; }
.em-dlg-h h3 { font-size: 18px; margin: 0; }
.em-dlg-b { padding: 8px 22px 16px; font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.em-dlg-b p { margin: 0; }
.em-dlg-b b { color: var(--ink); font-weight: 500; }
.em-dlg-f { display: flex; gap: 8px; align-items: center; padding: 12px 22px; border-top: 1px solid var(--line); background: #FAFBFC; border-radius: 0 0 8px 8px; }
.em-dlg-f .grow { flex: 1; }
@media (max-width: 640px), (hover: none) and (pointer: coarse) { .em-dlg { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%; border-radius: 12px 12px 0 0; max-height: 92vh; } .em-dlg-f { border-radius: 0; } }

/* modèles de message (puces du formulaire) */
.emx-mods { display: flex; flex-wrap: wrap; gap: 7px; }
.emx-mod { border: 1px solid var(--line-2); background: #fff; border-radius: 16px; padding: 5px 13px; font: inherit; font-size: 13.5px; cursor: pointer; color: inherit; }
.emx-mod:hover { border-color: var(--alert); }
.emx-mod.on { border-color: var(--alert); background: #FFF7F6; color: var(--alert); font-weight: 600; }
.emx-mod.add { border-style: dashed; color: var(--muted); }

/* bouton à maintenir appuyé 1,5 s (hold-confirm.js) */
.em-hold { position: relative; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none; }
.em-hold > span { position: relative; }
.em-hold-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(0, 0, 0, .35); pointer-events: none; }
.em-hold.holding .em-hold-fill { background: var(--alert-dark); }
.em-hold-tip { margin: 0; padding: 0 22px 14px; font-size: 12.5px; color: var(--muted); background: #FAFBFC; border-radius: 0 0 8px 8px; }
