/* =====================================================================
   Salle de Situation SENARE — feuille de style
   Palette d'inspiration bogolan : terre, ocre, coton écru.
   Deux thèmes complets : clair (défaut) et sombre.
   ===================================================================== */

:root{
  --bg:#E9E4D9;
  --surface:#F8F5EE;
  --surface-2:#F0EBDF;
  --line:#D6CEBE;
  --line-strong:#B8AE9A;
  --text:#241E17;
  --text-muted:#6B6153;
  --text-faint:#988E80;
  --accent:#A86A17;
  --accent-ink:#FFFFFF;
  --accent-soft:#EFDFC1;
  --ok:#2C7A4C;      --ok-bg:#DCEBDF;
  --warn:#9C6A0C;    --warn-bg:#F2E5C6;
  --alert:#A63A22;   --alert-bg:#F3DCD4;
  --map-land:#DED6C6;
  --map-stroke:#B0A490;
  --radius:10px;
  --shadow:0 1px 2px rgba(36,30,23,.06), 0 8px 24px -14px rgba(36,30,23,.22);
}

@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#191410;
    --surface:#221C16;
    --surface-2:#2A231B;
    --line:#3A3128;
    --line-strong:#514537;
    --text:#EFE6D6;
    --text-muted:#A2947E;
    --text-faint:#786B5A;
    --accent:#DFA745;
    --accent-ink:#1B1409;
    --accent-soft:#3A2C15;
    --ok:#5AB37D;      --ok-bg:#1D3226;
    --warn:#D9A03C;    --warn-bg:#33280F;
    --alert:#D96143;   --alert-bg:#3A1F17;
    --map-land:#2C251C;
    --map-stroke:#524637;
    --shadow:0 1px 2px rgba(0,0,0,.4), 0 10px 28px -16px rgba(0,0,0,.8);
  }
}

:root[data-theme="dark"]{
  --bg:#191410;
  --surface:#221C16;
  --surface-2:#2A231B;
  --line:#3A3128;
  --line-strong:#514537;
  --text:#EFE6D6;
  --text-muted:#A2947E;
  --text-faint:#786B5A;
  --accent:#DFA745;
  --accent-ink:#1B1409;
  --accent-soft:#3A2C15;
  --ok:#5AB37D;      --ok-bg:#1D3226;
  --warn:#D9A03C;    --warn-bg:#33280F;
  --alert:#D96143;   --alert-bg:#3A1F17;
  --map-land:#2C251C;
  --map-stroke:#524637;
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 10px 28px -16px rgba(0,0,0,.8);
}

*{box-sizing:border-box}

html{ -webkit-text-size-adjust:100% }

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:"Public Sans", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  font-size:15px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}

.num{
  font-family:"JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric:tabular-nums;
}

h1,h2,h3{
  font-family:"Bricolage Grotesque","Public Sans",sans-serif;
  margin:0; text-wrap:balance; letter-spacing:-.015em;
}

.wrap{max-width:1180px; margin:0 auto; padding:0 16px 56px}

.visually-hidden{
  position:absolute; width:1px; height:1px; margin:-1px;
  padding:0; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* ---------------------------------------------------------------
   Barre de commandement
   --------------------------------------------------------------- */
.bar{position:sticky; top:0; z-index:40; background:var(--surface); border-bottom:1px solid var(--line)}
.bar-in{max-width:1180px; margin:0 auto; padding:10px 16px; display:flex; align-items:center; gap:14px; flex-wrap:wrap}
.bar-in + .bar-in{padding-top:0}

.crest{
  width:36px; height:36px; flex:none; border-radius:7px;
  background:var(--accent); color:var(--accent-ink);
  display:grid; place-items:center;
  font-family:"Bricolage Grotesque",sans-serif; font-weight:800; font-size:15px; letter-spacing:-.03em;
}

.bar-id{display:flex; flex-direction:column; min-width:0; margin-right:auto}
.bar-id .k{font-size:10px; letter-spacing:.14em; text-transform:uppercase; color:var(--text-faint); font-weight:600}
.bar-id h1{font-size:17px; font-weight:700; line-height:1.15}

.live{
  display:inline-flex; align-items:center; gap:6px;
  font-size:11px; font-weight:700; letter-spacing:.1em; text-transform:uppercase;
  color:var(--ok); background:var(--ok-bg); padding:4px 9px; border-radius:999px;
}
.live i{width:6px; height:6px; border-radius:50%; background:var(--ok); animation:pulse 2s infinite}
.live[data-state="offline"]{color:var(--warn); background:var(--warn-bg)}
.live[data-state="offline"] i{background:var(--warn); animation:none}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.25}}

.clock{font-size:12px; color:var(--text-muted); text-align:right; line-height:1.35}
.clock b{display:block; color:var(--text); font-size:13px}

/* ---------------------------------------------------------------
   Commutateurs
   --------------------------------------------------------------- */
.demo-controls{display:flex; gap:8px; flex-wrap:wrap; align-items:center}
.seg{display:inline-flex; background:var(--surface-2); border:1px solid var(--line); border-radius:8px; padding:2px; gap:2px}
.seg button{
  font:inherit; font-size:12px; font-weight:600; border:0; background:transparent;
  color:var(--text-muted); padding:5px 10px; border-radius:6px; cursor:pointer; white-space:nowrap;
}
.seg button[aria-pressed="true"]{background:var(--accent); color:var(--accent-ink)}
.seg button:focus-visible{outline:2px solid var(--accent); outline-offset:2px}
.seg-label{font-size:10px; letter-spacing:.12em; text-transform:uppercase; color:var(--text-faint); font-weight:700}
.seg button .sm{display:none}

/* ---------------------------------------------------------------
   Bandeaux
   --------------------------------------------------------------- */
.proto{background:var(--accent-soft); border-bottom:1px solid var(--line); font-size:12px; color:var(--text-muted)}
.proto div{max-width:1180px; margin:0 auto; padding:7px 16px}
.proto b{color:var(--text)}
body[data-source="live"] .proto{display:none}

.offline{
  display:none; margin-top:16px; border:1px solid var(--warn); background:var(--warn-bg);
  border-radius:var(--radius); padding:12px 14px; align-items:center; gap:12px; flex-wrap:wrap;
}
body.is-offline .offline,
body.has-queue .offline{display:flex}
body:not(.is-offline).has-queue .offline{border-color:var(--accent)}
.offline .t{font-weight:700; color:var(--text); font-size:14px}
.offline .s{font-size:13px; color:var(--text-muted); margin-right:auto}

.btn{
  font:inherit; font-size:13px; font-weight:600; cursor:pointer;
  background:var(--accent); color:var(--accent-ink); border:0; border-radius:8px; padding:8px 14px;
}
.btn[disabled]{opacity:.45; cursor:not-allowed}
.btn:focus-visible{outline:2px solid var(--text); outline-offset:2px}

/* ---------------------------------------------------------------
   Indicateurs
   --------------------------------------------------------------- */
.kpis{display:grid; gap:10px; margin-top:16px; grid-template-columns:repeat(4,1fr)}
.kpi{background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:13px 14px}
.kpi .k{font-size:10px; letter-spacing:.11em; text-transform:uppercase; color:var(--text-faint); font-weight:700}
.kpi .v{
  font-family:"Bricolage Grotesque",sans-serif; font-weight:700; font-size:29px;
  line-height:1.1; margin-top:5px; letter-spacing:-.02em; font-variant-numeric:tabular-nums;
}
.kpi .d{font-size:12px; color:var(--text-muted); margin-top:2px}
.kpi .d em{font-style:normal; color:var(--ok); font-weight:600}

/* ---------------------------------------------------------------
   Grilles et cartes
   --------------------------------------------------------------- */
.grid{display:grid; gap:10px; margin-top:10px; grid-template-columns:1.15fr .85fr}
.grid2{display:grid; gap:10px; margin-top:10px; grid-template-columns:.8fr 1.2fr}

.card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  overflow:hidden; display:flex; flex-direction:column;
}
.card-h{display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; padding:12px 14px 10px; border-bottom:1px solid var(--line)}
.card-h h2{font-size:14px; font-weight:700}
.card-h .sub{font-size:12px; color:var(--text-faint); margin-left:auto}

/* ---------------------------------------------------------------
   Carte du Mali
   --------------------------------------------------------------- */
.mapwrap{padding:6px 10px 0}
svg.map{display:block; width:100%; height:auto}
.dot{cursor:pointer; transition:opacity .15s ease}
.dot:hover{stroke-width:2.5}
.dot:focus-visible{outline:2px solid var(--accent); outline-offset:2px}
.maplabel{pointer-events:none}

.maplegend{
  display:flex; gap:14px; flex-wrap:wrap; padding:8px 14px 12px;
  font-size:12px; color:var(--text-muted); border-top:1px solid var(--line); margin-top:6px;
}
.maplegend span{display:inline-flex; align-items:center; gap:6px}
.maplegend i{width:9px; height:9px; border-radius:50%; display:inline-block}
.maphint{padding:0 14px 10px; font-size:12px; color:var(--text-faint)}

/* ---------------------------------------------------------------
   Flux des remontées
   --------------------------------------------------------------- */
/* flex-basis 0 : le flux ne dicte pas la hauteur de la carte, il
   remplit exactement la hauteur imposée par la colonne voisine. */
.feed{
  overflow-y:auto; flex:1 1 0; min-height:220px;
  -webkit-mask-image:linear-gradient(to bottom, #000 calc(100% - 26px), transparent 100%);
          mask-image:linear-gradient(to bottom, #000 calc(100% - 26px), transparent 100%);
}
.ev{display:grid; grid-template-columns:52px 1fr; gap:10px; padding:11px 14px; border-bottom:1px solid var(--line)}
.ev:last-child{border-bottom:0}
.ev .t{font-size:12px; color:var(--text-faint); padding-top:2px}
.ev .r{font-size:10px; letter-spacing:.1em; text-transform:uppercase; font-weight:700; color:var(--accent)}
.ev .ti{font-size:14px; font-weight:600; margin:1px 0 2px; line-height:1.35}
.ev .m{font-size:12px; color:var(--text-muted)}
.ev.fresh{background:var(--accent-soft)}

.tag{
  display:inline-block; font-size:10px; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
  padding:2px 6px; border-radius:4px; background:var(--surface-2); color:var(--text-muted); margin-left:6px;
}
.tag.q{background:var(--warn-bg); color:var(--warn)}

/* ---------------------------------------------------------------
   Tableau des antennes
   --------------------------------------------------------------- */
.alert-strip{
  display:flex; gap:10px; align-items:flex-start; padding:11px 14px;
  background:var(--alert-bg); border-bottom:1px solid var(--line); font-size:13px; color:var(--text);
}
.alert-strip b{color:var(--alert)}
.alert-strip[data-state="ok"]{background:var(--ok-bg)}
.alert-strip[data-state="ok"] b{color:var(--ok)}

.tablewrap{overflow-x:auto}
table{width:100%; border-collapse:collapse; font-size:13px; min-width:560px}
th{
  text-align:left; font-size:10px; letter-spacing:.11em; text-transform:uppercase; color:var(--text-faint);
  font-weight:700; padding:9px 14px; border-bottom:1px solid var(--line); white-space:nowrap;
}
td{padding:8px 14px; border-bottom:1px solid var(--line)}
tbody tr:last-child td{border-bottom:0}
tbody tr{cursor:pointer}
tbody tr:hover{background:var(--surface-2)}
tbody tr.sel{background:var(--accent-soft)}
td.n{text-align:right; font-family:"JetBrains Mono",monospace; font-variant-numeric:tabular-nums}
.name{font-weight:600}

.bar-mini{height:6px; border-radius:3px; background:var(--surface-2); overflow:hidden; min-width:60px; display:block}
.bar-mini i{display:block; height:100%; background:var(--accent)}

.chip{display:inline-block; font-size:11px; font-weight:700; padding:2px 8px; border-radius:999px; white-space:nowrap}
.chip.ok{background:var(--ok-bg); color:var(--ok)}
.chip.warn{background:var(--warn-bg); color:var(--warn)}
.chip.alert{background:var(--alert-bg); color:var(--alert)}

/* ---------------------------------------------------------------
   AES et mur des messages
   --------------------------------------------------------------- */
.aes-row{display:flex; align-items:center; gap:12px; padding:10px 14px; border-bottom:1px solid var(--line)}
.aes-row:last-child{border-bottom:0}
.aes-row .c{font-weight:600; margin-right:auto}
.aes-row .n{font-family:"JetBrains Mono",monospace; font-size:15px; font-weight:700; font-variant-numeric:tabular-nums}
.aes-row .u{font-size:11px; color:var(--text-faint); text-transform:uppercase; letter-spacing:.08em}
.flagchip{width:8px; height:22px; border-radius:2px; flex:none}

.msgs{display:grid; grid-template-columns:1fr 1fr}
.msg{padding:12px 14px; border-bottom:1px solid var(--line)}
.msg:nth-child(odd){border-right:1px solid var(--line)}
.msg p{margin:0 0 6px; font-size:14px; line-height:1.45; font-style:italic}
.msg .who{font-size:11px; color:var(--text-faint); letter-spacing:.04em}

footer{
  margin-top:22px; padding-top:16px; border-top:1px solid var(--line);
  font-size:12px; color:var(--text-muted); display:flex; gap:16px; flex-wrap:wrap;
}
footer b{color:var(--text)}

/* ---------------------------------------------------------------
   Adaptatif
   --------------------------------------------------------------- */
@media (max-width:900px){
  .grid,.grid2{grid-template-columns:1fr}
  .kpis{grid-template-columns:repeat(2,1fr)}
  .feed{flex:none; max-height:420px}
  .bar-id h1{font-size:15px}
  .clock{display:none}
}

@media (max-width:700px){
  .bar-in{padding:8px 12px; gap:9px; flex-wrap:nowrap}
  .bar-in + .bar-in{padding-bottom:9px}
  .crest{width:30px; height:30px; font-size:13px; border-radius:6px}
  .bar-id .k{white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; font-size:9px; letter-spacing:.1em}
  .bar-id h1{font-size:15px}
  .seg-label{display:none}
  .seg{flex:1}
  .seg button{font-size:11px; padding:5px 8px; flex:1}
  .seg button .lg{display:none}
  .seg button .sm{display:inline}
  .demo-controls{width:100%; flex-wrap:wrap; gap:6px}
  .live{font-size:0; gap:0; padding:6px}
  .live i{width:8px; height:8px}
  .wrap{padding:0 12px 44px}
}

@media (max-width:560px){
  .msgs{grid-template-columns:1fr}
  .msg:nth-child(odd){border-right:0}
  .kpi .v{font-size:25px}
}

@media (prefers-reduced-motion:reduce){
  *{animation:none !important; transition:none !important}
}

@media print{
  .bar,.demo-controls,.proto,.offline{display:none !important}
  .card{break-inside:avoid}
}
