/* ============================================================
   BSPP — Assistant Bilan Médical
   Thème : marine profond / rouge BSPP / laiton — esprit caserne
   ============================================================ */

:root {
  --bg: #0a1322;
  --bg-2: #0e1a2e;
  --surface: #122138;
  --surface-2: #16273f;
  --line: #24395c;
  --line-soft: #1c2e4a;
  --red: #e21e2f;
  --red-deep: #a30e1d;
  --red-glow: rgba(226, 30, 47, 0.35);
  --brass: #c9a24b;
  --text: #e9eef7;
  --muted: #8da0bd;
  --faint: #5d6f8c;
  --ok: #3fae6a;
  --warn: #e0a93c;
  --font-ui: 'Barlow', system-ui, sans-serif;
  --font-cond: 'Barlow Condensed', var(--font-ui);
  --font-stencil: 'Allerta Stencil', var(--font-cond);
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(1100px 500px at 75% -150px, #16294a 0%, transparent 60%),
    radial-gradient(900px 600px at -200px 110%, #101f38 0%, transparent 55%),
    var(--bg);
  overflow: hidden;
}

/* Grain discret sur toute l'interface */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

::selection { background: var(--red-deep); color: #fff; }

/* ---------- Barre supérieure ---------- */
#topbar {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: linear-gradient(180deg, #15263f 0%, #0f1d33 100%);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 10;
}
#topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -7px;
  height: 6px;
  background: repeating-linear-gradient(135deg, var(--red) 0 16px, transparent 16px 32px),
              #0c1729;
  opacity: 0.85;
}
.brand { display: flex; align-items: center; gap: 14px; }
.badge { width: 42px; height: 47px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.5)); }
.brand-text h1 {
  margin: 0;
  font-family: var(--font-stencil);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 2.5px;
  color: var(--text);
  line-height: 1.1;
}
.brand-text .sub {
  font-family: var(--font-cond);
  font-size: 11.5px;
  letter-spacing: 2.5px;
  color: var(--brass);
}
.brand-text .sub em { font-style: italic; letter-spacing: 1px; color: #d9bd76; }
.top-right { display: flex; align-items: center; gap: 14px; }
.clock {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  background: #0a1626;
  border: 1px solid var(--line);
  padding: 5px 12px;
  letter-spacing: 1.5px;
}
.pill {
  font-family: var(--font-cond);
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 10px;
  text-transform: uppercase;
}
.pill.ok { color: var(--ok); border-color: rgba(63, 174, 106, .4); }
.pill.ko { color: var(--warn); border-color: rgba(224, 169, 60, .4); }

/* ---------- Layout 3 colonnes ---------- */
#layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 400px;
  height: calc(100vh - 62px);
  padding-top: 7px;
}
@media (max-width: 1380px) {
  #layout { grid-template-columns: 240px minmax(0, 1fr) 350px; }
}

#sidebar, #panel {
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#sidebar { border-right: 1px solid var(--line-soft); padding: 14px 12px; gap: 12px; }
#panel { border-left: 1px solid var(--line-soft); }

#main {
  min-width: 0;
  overflow-y: auto;
  padding: 18px 22px 80px;
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #243a5e; border-radius: 0; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #30507e; }

/* ---------- Boutons ---------- */
.btn {
  font-family: var(--font-cond);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  padding: 9px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
  transition: background .12s, border-color .12s, transform .06s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-red {
  background: linear-gradient(180deg, var(--red) 0%, var(--red-deep) 100%);
  border-color: #f0596a;
  box-shadow: 0 2px 12px var(--red-glow);
}
.btn-red:hover { filter: brightness(1.12); }
.btn-navy { background: #1b3253; border-color: #2c4a78; }
.btn-navy:hover { background: #23406a; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: #3a5685; }
.btn-danger-ghost { background: transparent; border-color: var(--line); color: var(--faint); padding: 9px 12px; }
.btn-danger-ghost:hover { color: var(--red); border-color: var(--red-deep); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Sidebar : prises en charge ---------- */
.side-tabs { display: flex; border: 1px solid var(--line); }
.side-tab {
  flex: 1;
  font-family: var(--font-cond);
  font-size: 12px;
  letter-spacing: 1.8px;
  padding: 7px 0;
  background: transparent;
  color: var(--muted);
  border: 0;
  cursor: pointer;
}
.side-tab.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--red); }

.case-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.case-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--faint);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.case-card:hover { background: var(--surface-2); }
.case-card.selected { border-color: var(--red); border-left-color: var(--red); background: var(--surface-2); }
.case-card .cc-top { display: flex; justify-content: space-between; align-items: center; }
.case-card .cc-num { font-family: var(--font-stencil); font-size: 14px; letter-spacing: 1px; }
.case-card .cc-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }
.case-card .cc-motif {
  margin-top: 4px; font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.case-card .cc-victime { margin-top: 2px; font-size: 11.5px; color: var(--faint); font-family: var(--font-cond); letter-spacing: .5px; }
.case-card.active-case { border-left-color: var(--red); }
.case-card.active-case .cc-num::after {
  content: "●";
  color: var(--red);
  font-size: 9px;
  margin-left: 8px;
  vertical-align: 2px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.case-list .list-empty { color: var(--faint); font-size: 12.5px; text-align: center; padding: 26px 8px; font-family: var(--font-cond); letter-spacing: 1px; }

/* ---------- État vide ---------- */
.empty-state {
  height: 70%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 10px;
}
.empty-badge {
  font-family: var(--font-stencil);
  font-size: 44px;
  color: var(--red);
  border: 3px solid var(--red-deep);
  width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  opacity: .55;
}
.empty-state h2 { font-family: var(--font-stencil); font-weight: 400; font-size: 18px; letter-spacing: 3px; color: var(--muted); margin: 8px 0 0; }
.empty-state p { color: var(--faint); max-width: 380px; }

/* ---------- En-tête du dossier ---------- */
#case-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 16px;
}
.case-id { display: flex; align-items: center; gap: 14px; }
.case-numero { font-family: var(--font-stencil); font-size: 26px; letter-spacing: 2px; }
.status-badge {
  font-family: var(--font-cond);
  font-size: 11px; letter-spacing: 2px;
  padding: 4px 10px;
  text-transform: uppercase;
}
.status-badge.active { color: #ff8d98; border: 1px solid var(--red-deep); background: rgba(226, 30, 47, .12); }
.status-badge.closed { color: var(--muted); border: 1px solid var(--line); background: var(--surface); }
.case-actions { display: flex; gap: 8px; }

.closed-banner {
  background: rgba(224, 169, 60, .1);
  border: 1px solid rgba(224, 169, 60, .35);
  color: var(--warn);
  font-size: 13px;
  padding: 9px 14px;
  margin-bottom: 16px;
  font-family: var(--font-cond);
  letter-spacing: .8px;
}

/* ---------- Blocs du bilan ---------- */
.bloc {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  margin-bottom: 14px;
}
.bloc-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.bloc-num {
  font-family: var(--font-stencil);
  font-size: 15px;
  color: #fff;
  background: var(--red-deep);
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.bloc-head h2 {
  margin: 0; flex: 1;
  font-family: var(--font-cond);
  font-size: 15.5px; font-weight: 600;
  letter-spacing: 2.2px;
  text-transform: uppercase;
}
.bloc-toggle {
  background: none; border: 0; color: var(--muted);
  font-size: 14px; cursor: pointer; padding: 2px 6px;
  transition: transform .15s;
}
.bloc.collapsed .bloc-toggle { transform: rotate(-90deg); }
.bloc-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.bloc.collapsed .bloc-body { display: none; }
.bloc-vital { border-left: 3px solid var(--red); }

.bloc-ia-fill { border: 1px dashed var(--brass); }
.bloc-ia-fill .bloc-head { background: linear-gradient(90deg, rgba(201, 162, 75, .12) 0%, var(--surface) 100%); }
.bloc-num.ia { background: var(--brass); color: #221a06; font-size: 11px; letter-spacing: .5px; }
.ia-fill-hint { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.ia-fill-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ia-fill-status {
  color: var(--brass);
  font-family: var(--font-cond);
  letter-spacing: 1.5px;
  font-size: 12px;
  text-transform: uppercase;
}
.ia-fill-status.working { animation: pulse 1.2s infinite; }

.sub-title {
  margin: 4px 0 0;
  font-family: var(--font-cond);
  font-size: 13px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--brass);
}

/* ---------- Champs ---------- */
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grow { flex: 1; min-width: 0; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span {
  font-family: var(--font-cond);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}
input, select, textarea {
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--text);
  background: #0c1828;
  border: 1px solid var(--line-soft);
  padding: 8px 10px;
  outline: none;
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 38px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(226, 30, 47, .15);
}
input::placeholder, textarea::placeholder { color: #46587a; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
input[type="time"] { font-family: var(--font-mono); }
input[type="number"] { font-family: var(--font-mono); }

form.readonly input, form.readonly select, form.readonly textarea { pointer-events: none; opacity: .65; }
form.readonly .btn, form.readonly .chip { pointer-events: none; opacity: .45; }
form.readonly .bloc-head, form.readonly .bloc-toggle { pointer-events: auto; opacity: 1; }
form.readonly .row-del { display: none; }

/* ---------- XABCDE ---------- */
.xabcde-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px;
  background: #101e34;
  border: 1px solid var(--line-soft);
}
.x-tag {
  font-family: var(--font-stencil);
  font-size: 18px;
  color: var(--red);
  border: 1.5px solid var(--red-deep);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  flex: none;
  margin-top: 16px;
}
.gcs-grid { margin-top: 12px; }
.gcs-total-box { justify-content: flex-start; }
.gcs-total {
  font-family: var(--font-mono);
  font-size: 21px; font-weight: 600;
  color: var(--text);
  background: #0c1828;
  border: 1px solid var(--line-soft);
  padding: 4px 10px;
  text-align: center;
}
.gcs-total.gcs-grave { color: var(--red); border-color: var(--red-deep); }
.gcs-total.gcs-modere { color: var(--warn); }
.gcs-total.gcs-leger { color: var(--ok); }

/* ---------- Tableau constantes ---------- */
.table-wrap { overflow-x: auto; }
.mono-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 12.5px; }
.mono-table th {
  font-family: var(--font-cond);
  font-size: 11px; font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--muted);
  background: #0e1c30;
  border: 1px solid var(--line-soft);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}
.mono-table th small { display: block; font-size: 9px; color: var(--faint); letter-spacing: .5px; }
.mono-table td {
  border: 1px solid var(--line-soft);
  padding: 6px 8px;
  white-space: nowrap;
}
.mono-table tbody tr:nth-child(odd) { background: rgba(255, 255, 255, .015); }
.mono-table td.out-of-range { color: #ff7d8a; font-weight: 600; }
.mono-table td.empty-cell { color: var(--faint); }
.row-del {
  background: none; border: 0; cursor: pointer;
  color: var(--faint); font-size: 13px; padding: 0 4px;
}
.row-del:hover { color: var(--red); }

.add-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.add-row input, .add-row select { width: auto; flex: 1 1 70px; min-width: 64px; }
.add-row input#ct-ta { flex: 1.4 1 90px; }
.add-row .grow { flex: 3 1 200px; }
.add-row .btn { flex: none; }

/* ---------- Chips & timeline ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--font-cond);
  font-size: 12px;
  letter-spacing: 1px;
  padding: 5px 11px;
  background: #16283f;
  color: var(--muted);
  border: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  transition: all .12s;
}
.chip:hover { color: var(--text); border-color: var(--brass); }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.timeline li {
  display: flex; align-items: center; gap: 10px;
  background: #101e34;
  border-left: 2px solid var(--brass);
  padding: 7px 10px;
  font-size: 13px;
}
.timeline .tl-time { font-family: var(--font-mono); font-size: 11.5px; color: var(--brass); flex: none; }
.timeline .tl-label { flex: 1; min-width: 0; }
.timeline .row-del { flex: none; }

/* ---------- Panneau droit ---------- */
.panel-tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.panel-tab {
  flex: 1;
  font-family: var(--font-cond);
  font-size: 13px; font-weight: 600;
  letter-spacing: 2px;
  padding: 12px 0;
  background: transparent;
  color: var(--muted);
  border: 0; cursor: pointer;
}
.panel-tab.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--red); background: var(--surface); }

.panel-section { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* --- Chat IA --- */
.ai-chat { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-hello {
  border: 1px dashed var(--line);
  padding: 12px;
  color: var(--muted);
  font-size: 12.5px;
}
.ai-hello strong { font-family: var(--font-cond); letter-spacing: 1.5px; text-transform: uppercase; color: var(--brass); }
.ai-hello p { margin: 6px 0 0; }
.msg { max-width: 95%; padding: 9px 12px; font-size: 13px; line-height: 1.45; }
.msg-user {
  align-self: flex-end;
  background: #1b3253;
  border: 1px solid #2c4a78;
  white-space: pre-wrap;
}
.msg-ai {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--red);
  width: 95%;
}
.msg-ai h4 { margin: 8px 0 4px; font-family: var(--font-cond); font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--brass); }
.msg-ai ul, .msg-ai ol { margin: 4px 0; padding-left: 20px; }
.msg-ai li { margin: 2px 0; }
.msg-ai p { margin: 5px 0; }
.msg-ai strong { color: #fff; }
.msg-ai .urgent { color: #ff7d8a; font-weight: 700; }
.msg-error { align-self: stretch; background: rgba(226, 30, 47, .1); border: 1px solid var(--red-deep); color: #ff9aa4; font-size: 12.5px; padding: 9px 12px; }
.msg-typing { color: var(--faint); font-family: var(--font-cond); letter-spacing: 2px; font-size: 12px; align-self: flex-start; animation: pulse 1.2s infinite; }

.ai-actions { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line-soft); }
.ai-actions .chip { font-size: 11.5px; }
.ai-form { flex: none; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.ai-form textarea { font-size: 13px; }
.ai-form-row { display: flex; justify-content: space-between; gap: 8px; }

/* --- Références --- */
.ref-tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line-soft); flex: none; }
.ref-tab {
  flex: 1;
  font-family: var(--font-cond);
  font-size: 11.5px; font-weight: 600;
  letter-spacing: 1.2px;
  padding: 9px 2px;
  background: transparent; color: var(--muted);
  border: 0; cursor: pointer;
  white-space: nowrap;
}
.ref-tab.active { color: var(--brass); box-shadow: inset 0 -2px 0 var(--brass); }
.ref-search {
  margin: 10px 14px 6px;
  width: calc(100% - 28px);
  flex: none;
}
.ref-content { flex: 1; overflow-y: auto; padding: 8px 14px 20px; }

.ref-card { border: 1px solid var(--line-soft); background: var(--surface); margin-bottom: 8px; }
.ref-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-cond);
  font-size: 14px; font-weight: 600;
  letter-spacing: 1px;
}
.ref-card > summary::-webkit-details-marker { display: none; }
.ref-card > summary::before { content: "▸"; color: var(--red); font-size: 12px; transition: transform .12s; }
.ref-card[open] > summary::before { transform: rotate(90deg); }
.ref-card .ref-cat {
  margin-left: auto;
  font-size: 10px; letter-spacing: 1.2px;
  color: var(--faint);
  border: 1px solid var(--line-soft);
  padding: 2px 7px;
  text-transform: uppercase;
  white-space: nowrap;
}
.ref-body { padding: 0 12px 12px; font-size: 12.5px; }
.ref-body h5 {
  margin: 10px 0 4px;
  font-family: var(--font-cond);
  font-size: 11px; letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--brass);
}
.ref-body ul, .ref-body ol { margin: 0; padding-left: 18px; }
.ref-body li { margin: 2px 0; color: #c6d2e4; }
.ref-body .rf { color: #ff8d98; }
.ref-body p { margin: 4px 0; color: #c6d2e4; }
.ref-note { color: var(--faint); font-size: 11.5px; font-style: italic; }

.ref-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 6px 0; }
.ref-table th {
  font-family: var(--font-cond);
  font-weight: 600; font-size: 10.5px; letter-spacing: 1.2px;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  background: #0e1c30;
  padding: 5px 7px; text-align: left;
}
.ref-table td { border: 1px solid var(--line-soft); padding: 5px 7px; font-family: var(--font-mono); font-size: 11.5px; }
.ref-table td:first-child { font-family: var(--font-ui); }

/* Calculateur Glasgow */
.gcs-calc { border: 1px solid var(--brass); padding: 12px; margin-bottom: 12px; background: rgba(201, 162, 75, .05); }
.gcs-calc h4 { margin: 0 0 10px; font-family: var(--font-cond); letter-spacing: 2px; text-transform: uppercase; color: var(--brass); font-size: 13px; }
.gcs-calc .field { margin-bottom: 8px; }
.gcs-calc-result {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 16px;
  text-align: center;
  padding: 8px;
  background: #0c1828;
  border: 1px solid var(--line-soft);
}

/* ---------- Aide sur les termes médicaux (info-bulles & notes) ---------- */
.field > span.tip {
  text-decoration: underline dotted var(--faint);
  text-underline-offset: 3px;
  cursor: help;
}
.field-hint, small.field-hint {
  margin: 0;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.45;
  font-family: var(--font-ui);
  letter-spacing: normal;
  text-transform: none;
}

/* ---------- Bouton paramètres (barre du haut) ---------- */
button.pill { background: transparent; cursor: pointer; }
.pill-btn {
  color: var(--brass);
  border-color: rgba(201, 162, 75, .45);
  transition: color .12s, border-color .12s;
}
.pill-btn:hover { color: #e7cc83; border-color: var(--brass); }

/* ---------- Fenêtre modale (paramètres) ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  z-index: 600;
  background: rgba(5, 10, 20, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .65);
}
.modal-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--bg-2) 100%);
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  margin: 0;
  font-family: var(--font-cond);
  font-size: 15px; font-weight: 600;
  letter-spacing: 2.2px;
  text-transform: uppercase;
}
.modal-x {
  background: none; border: 0;
  color: var(--muted);
  font-size: 15px; cursor: pointer;
  padding: 2px 6px;
}
.modal-x:hover { color: var(--red); }
.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.modal-foot {
  flex: none;
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.meds-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 14px;
  max-height: 215px;
  overflow-y: auto;
  border: 1px solid var(--line-soft);
  background: #0c1828;
  padding: 10px 12px;
}
.med-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.med-check:hover { color: var(--text); }
.med-check input[type="checkbox"] {
  width: 14px; height: 14px;
  flex: none;
  padding: 0; margin: 0;
  accent-color: var(--red);
}
.med-check input[type="checkbox"]:checked + span { color: var(--text); }

/* ---------- Références : dotation & lexique ---------- */
.ref-cat.pref { color: var(--brass); border-color: rgba(201, 162, 75, .5); }
.ref-card summary .ref-cat + .ref-cat { margin-left: 6px; }
.lexique-table td { font-family: var(--font-ui); font-size: 12px; }
.lexique-table td:first-child {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* ============================================================
   Plans / NOVI — gestion des événements à nombreuses victimes
   ============================================================ */

/* ---------- Bascule BILANS / PLANS (sidebar) ---------- */
.mode-tabs { display: flex; border: 1px solid var(--line); flex: none; }
.mode-tab {
  flex: 1;
  font-family: var(--font-cond);
  font-size: 12.5px; font-weight: 600;
  letter-spacing: 1.8px;
  padding: 9px 0;
  background: transparent;
  color: var(--muted);
  border: 0;
  cursor: pointer;
}
.mode-tab.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--brass); }
.side-mode { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }

/* ---------- Badges de type de plan ---------- */
.plan-badge {
  font-family: var(--font-cond);
  font-size: 11px; font-weight: 600; letter-spacing: 2px;
  padding: 4px 10px;
  text-transform: uppercase;
  white-space: nowrap;
}
.plan-badge.novi { color: #ffb36b; border: 1px solid #b86a24; background: rgba(224, 123, 47, .12); }
.plan-badge.rouge { color: #ff8d98; border: 1px solid var(--red-deep); background: rgba(226, 30, 47, .12); }
.plan-badge.rouge-alpha {
  color: #ff6b78; border: 1px solid #ff3548; background: rgba(226, 30, 47, .22);
  box-shadow: 0 0 0 1px rgba(201, 162, 75, .45);
}
.plan-badge.crise { color: #c5a8ff; border: 1px solid #6d4fc4; background: rgba(122, 86, 219, .14); }

.event-chrono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--brass);
  border: 1px solid rgba(201, 162, 75, .4);
  padding: 4px 10px;
  letter-spacing: 1px;
}

/* ---------- Cartes événement (sidebar) ---------- */
.event-card .cc-counts {
  margin-top: 5px;
  display: flex; gap: 4px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 10px;
}
.cc-count { padding: 1px 6px; border: 1px solid var(--line-soft); color: var(--muted); }
.cc-count.ua { color: #ff8d98; border-color: var(--red-deep); }
.cc-count.ur { color: var(--warn); border-color: rgba(224, 169, 60, .45); }
.cc-count.imp { color: var(--ok); border-color: rgba(63, 174, 106, .45); }
.cc-count.dcd { color: #b9c2d4; border-color: #4a5870; }

/* ---------- Tableau de bord du tri ---------- */
.tri-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
@media (max-width: 1100px) { .tri-board { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tri-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px 8px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-top: 3px solid var(--faint);
}
.tri-cell .n { font-family: var(--font-mono); font-size: 26px; font-weight: 600; line-height: 1; }
.tri-cell .l {
  font-family: var(--font-cond);
  font-size: 9.5px; letter-spacing: 1.2px;
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
}
.tri-ua { border-top-color: var(--red); } .tri-ua .n { color: #ff5f6e; }
.tri-ur { border-top-color: var(--warn); } .tri-ur .n { color: var(--warn); }
.tri-imp { border-top-color: var(--ok); } .tri-imp .n { color: var(--ok); }
.tri-dcd { border-top-color: #6a7886; } .tri-dcd .n { color: #b9c2d4; }
.tri-evac { border-top-color: #3a7bd5; } .tri-evac .n { color: #6ea8ff; }
.tri-total { border-top-color: var(--brass); } .tri-total .n { color: var(--brass); }

/* ---------- Tri rapide ---------- */
.tri-quick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tri-quick-label {
  font-family: var(--font-cond);
  font-size: 11px; letter-spacing: 1.8px;
  color: var(--muted);
}
.tri-btn { border-width: 1px; font-size: 12.5px; padding: 7px 14px; background: transparent; }
.tri-btn-ua { color: #ff5f6e; border-color: var(--red-deep); }
.tri-btn-ua:hover { background: rgba(226, 30, 47, .15); }
.tri-btn-ur { color: var(--warn); border-color: rgba(224, 169, 60, .5); }
.tri-btn-ur:hover { background: rgba(224, 169, 60, .12); }
.tri-btn-imp { color: var(--ok); border-color: rgba(63, 174, 106, .5); }
.tri-btn-imp:hover { background: rgba(63, 174, 106, .12); }
.tri-btn-dcd { color: #b9c2d4; border-color: #4a5870; }
.tri-btn-dcd:hover { background: rgba(255, 255, 255, .06); }
.tri-quick-hint { flex-basis: 100%; }

/* ---------- Tableau des victimes ---------- */
.victimes-table input, .victimes-table select {
  border-color: transparent;
  background: transparent;
  padding: 4px 6px;
  font-size: 12.5px;
  min-width: 0;
}
.victimes-table input:hover, .victimes-table select:hover { border-color: var(--line-soft); }
.victimes-table input:focus, .victimes-table select:focus { border-color: var(--red); background: #0c1828; }
.victimes-table select { background-position: calc(100% - 12px) 12px, calc(100% - 7px) 12px; padding-right: 22px; }
.victimes-table td { padding: 2px 2px; }
.victimes-table .vt-tag { font-weight: 600; color: var(--text); padding: 4px 8px; white-space: nowrap; }
.victimes-table .vt-heure { color: var(--faint); font-size: 11px; padding: 4px 6px; }
.victimes-table .vt-w-tag { width: 56px; } .victimes-table .vt-w-heure { width: 52px; }
.victimes-table .vt-w-cat { width: 86px; } .victimes-table .vt-w-age { width: 52px; }
.victimes-table .vt-w-sexe { width: 56px; } .victimes-table .vt-w-site { width: 100px; }
.victimes-table .vt-w-devenir { width: 130px; } .victimes-table .vt-w-actions { width: 86px; }
.victimes-table tr[data-cat="UA"] { box-shadow: inset 3px 0 0 var(--red); }
.victimes-table tr[data-cat="UR"] { box-shadow: inset 3px 0 0 var(--warn); }
.victimes-table tr[data-cat="IMP"] { box-shadow: inset 3px 0 0 var(--ok); }
.victimes-table tr[data-cat="DCD"] { box-shadow: inset 3px 0 0 #6a7886; opacity: .8; }
select.vt-cat { font-family: var(--font-cond); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
select.vt-cat.cat-ua { color: #ff5f6e; }
select.vt-cat.cat-ur { color: var(--warn); }
select.vt-cat.cat-imp { color: var(--ok); }
select.vt-cat.cat-dcd { color: #b9c2d4; }
.vt-actions { white-space: nowrap; }
.vt-pec-btn {
  font-family: var(--font-cond);
  font-size: 10.5px; letter-spacing: 1px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 3px 7px;
  cursor: pointer;
}
.vt-pec-btn:hover { color: var(--text); border-color: var(--brass); }
.vt-pec-btn.linked { color: var(--brass); border-color: rgba(201, 162, 75, .5); }
form.readonly .vt-pec-btn.linked { pointer-events: auto; opacity: 1; }

/* ---------- Sites / chantiers ---------- */
.sites-list { display: flex; flex-direction: column; gap: 6px; }
.site-row { display: flex; gap: 8px; align-items: center; }
.site-row input { flex: 1; }

/* ---------- Main courante ---------- */
.mc-list li { border-left-color: #3a7bd5; }

/* ---------- Choix du plan (modal de déclenchement) ---------- */
.plan-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 700px) { .plan-choices { grid-template-columns: 1fr; } }
.plan-choice {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px;
  background: #0c1828;
  border: 1px solid var(--line-soft);
  cursor: pointer;
  transition: border-color .12s, background .12s;
  position: relative;
}
.plan-choice:hover { border-color: var(--line); }
.plan-choice input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.plan-choice strong {
  font-family: var(--font-stencil);
  font-weight: 400;
  font-size: 14px; letter-spacing: 1.5px;
}
.plan-choice small { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.plan-choice.novi strong { color: #ffb36b; }
.plan-choice.rouge strong { color: #ff8d98; }
.plan-choice.rouge-alpha strong { color: #ff6b78; }
.plan-choice.crise strong { color: #c5a8ff; }
.plan-choice:has(input:checked) { border-color: var(--red); background: rgba(226, 30, 47, .08); box-shadow: 0 0 0 1px var(--red); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  background: #1b3253;
  border: 1px solid #2c4a78;
  border-left: 3px solid var(--red);
  color: var(--text);
  padding: 11px 18px;
  font-size: 13px;
  z-index: 1000;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
}
.toast.err { border-left-color: var(--warn); }

/* ============================================================
   Authentification : écran de connexion & gestion des comptes
   ============================================================ */

/* ---------- Écran de connexion ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 75% -150px, #16294a 0%, transparent 60%),
    radial-gradient(900px 600px at -200px 110%, #101f38 0%, transparent 55%),
    var(--bg);
}
.login-screen--hidden { display: none; }

.login-box {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 30px 30px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55);
}
.login-badge { width: 58px; height: 65px; margin-bottom: 12px; }
.login-box h1 {
  margin: 0;
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 1px;
  text-align: center;
  color: var(--text);
}
.login-sub {
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.login-box form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.login-box .field input { font-family: var(--font-mono); letter-spacing: 1px; }
.login-error {
  margin: -2px 0 2px;
  padding: 8px 11px;
  border-radius: 6px;
  background: rgba(226, 30, 47, .12);
  border: 1px solid var(--red-deep);
  color: #ffd9dd;
  font-size: 13px;
}

/* ---------- Gestion des comptes ---------- */
.users-table { width: 100%; }
.users-table th { text-align: left; }
.users-table td { vertical-align: middle; }
.users-table .u-mat { font-weight: 600; }
.users-table .u-self { color: var(--faint); font-weight: 400; }
.users-table .u-admin { color: var(--brass); text-align: center; }
.users-table .u-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.field-check { justify-content: flex-end; }
.check-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}
.check-inline input { width: auto; }

/* ---------- Permissions (tableau des comptes) ---------- */
.users-table .u-perm {
  text-align: center;
  cursor: pointer;
  user-select: none;
  color: var(--faint);
  font-weight: 600;
}
.users-table .u-perm.on { color: var(--ok); }
.users-table .u-perm:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Journal d'audit ---------- */
.modal-wide { max-width: 920px; width: 94vw; }
.logs-wrap { max-height: 60vh; overflow: auto; }
.logs-table { width: 100%; }
.logs-table th { text-align: left; position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.logs-table td { vertical-align: top; }
.logs-table .lg-time { white-space: nowrap; color: var(--muted); }
.logs-table .lg-who { white-space: nowrap; }
.logs-table .lg-act { white-space: nowrap; color: var(--brass); }
.logs-table .lg-w-time { width: 130px; }
.logs-table .lg-w-who { width: 200px; }
.logs-table .lg-w-act { width: 150px; }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; }

/* ---------- Traçabilité (auteur création / modification) ---------- */
.record-meta {
  margin: 2px 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.2px;
}
.record-meta:empty { display: none; }

/* ---------- Pastille de synchronisation temps réel ---------- */
#live-pill { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.3px; }
#live-pill.live-ok { color: var(--ok); border-color: rgba(63, 174, 106, 0.45); }
#live-pill.live-off { color: var(--warn); border-color: rgba(224, 169, 60, 0.45); }
