/* ── Réactis Régional — affichage téléphone (Fred, 26/09/2026) ──────────────────────────
   Activé par mobile.js (classe m-mode sur <body>) dans l'application mobile et sur petit écran.
   Pensé pour un directeur de territoire : l'état du territoire se lit en une seconde, les
   établissements en crise d'abord, zones tactiles d'au moins 44 px, barre d'onglets en bas. */
:root {
  --m-bg: #eef2f7;
  --m-card: #ffffff;
  --m-ink: #0f172a;
  --m-ink2: #475569;
  --m-ink3: #94a3b8;
  --m-line: #e2e8f0;
  --m-red: #dc2626;
  --m-red-bg: #fef2f2;
  --m-amber: #b45309;
  --m-amber-bg: #fffbeb;
  --m-green: #15803d;
  --m-green-bg: #f0fdf4;
  --m-brand: #1e293b;
  --m-accent: #2563eb;
  --m-radius: 16px;
  --m-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .06);
  --m-tabs-h: 64px;
}

#m-root { display: none; }
body.m-mode { background: var(--m-bg); -webkit-tap-highlight-color: transparent; }
body.m-mode #app-screen > :not(#m-root) { display: none !important; }
body.m-mode #m-root {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--m-ink);
  min-height: 100vh;
  padding-bottom: calc(var(--m-tabs-h) + env(safe-area-inset-bottom, 0px) + 16px);
}
#m-root * { box-sizing: border-box; }
#m-root button { font-family: inherit; }

/* En-tête */
.m-head {
  position: sticky; top: 0; z-index: 20;
  background: var(--m-brand); color: #fff;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 12px;
}
.m-head-title { flex: 1; min-width: 0; }
.m-head-name { font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-head-sub { font-size: 12px; color: #cbd5e1; margin-top: 1px; }
.m-icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.m-icon-btn:active { background: rgba(255, 255, 255, .25); }
.m-icon-btn.spin span { display: inline-block; animation: m-spin .8s linear infinite; }
@keyframes m-spin { to { transform: rotate(360deg); } }

.m-page { padding: 14px 14px 0; max-width: 640px; margin: 0 auto; }
.m-section-title {
  font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--m-ink2); margin: 20px 4px 10px;
}

/* Bandeau d'état du territoire */
.m-hero { border-radius: var(--m-radius); padding: 18px; box-shadow: var(--m-shadow); color: #fff; }
.m-hero.calm { background: linear-gradient(135deg, #15803d, #16a34a); }
.m-hero.tension { background: linear-gradient(135deg, #b45309, #d97706); }
.m-hero.crisis { background: linear-gradient(135deg, #b91c1c, #dc2626); }
.m-hero.unknown { background: linear-gradient(135deg, #475569, #64748b); }
.m-hero-row { display: flex; align-items: center; gap: 14px; }
.m-hero-big { font-size: 44px; font-weight: 900; line-height: 1; }
.m-hero-icon { font-size: 34px; line-height: 1; }
.m-hero-label { font-size: 19px; font-weight: 800; line-height: 1.2; }
.m-hero-sub { font-size: 13px; opacity: .9; margin-top: 4px; }
.m-hero-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .25); font-size: 13px; font-weight: 600; }

/* Cartes */
.m-card {
  background: var(--m-card); border-radius: var(--m-radius); box-shadow: var(--m-shadow);
  padding: 16px; margin-bottom: 12px; position: relative;
}
.m-card.tap { cursor: pointer; }
.m-card.tap:active { transform: scale(.99); }
.m-card.crisis { border-left: 5px solid var(--m-red); }
.m-card-top { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.m-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.m-dot.red { background: var(--m-red); box-shadow: 0 0 0 0 rgba(220, 38, 38, .6); animation: m-pulse 1.6s infinite; }
.m-dot.green { background: #22c55e; }
.m-dot.amber { background: #f59e0b; }
.m-dot.grey { background: #94a3b8; }
@keyframes m-pulse { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .55); } 70% { box-shadow: 0 0 0 9px rgba(220, 38, 38, 0); } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } }
.m-red { color: var(--m-red); }
.m-since { margin-left: auto; color: var(--m-ink2); font-weight: 700; letter-spacing: 0; }
.m-card-name { font-size: 18px; font-weight: 800; margin-top: 8px; line-height: 1.25; }
.m-card-crisis { font-size: 15px; color: var(--m-ink); margin-top: 4px; line-height: 1.35; }
.m-chip {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: #f1f5f9; color: var(--m-ink2); margin-top: 6px;
}
.m-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.m-kpi { border-radius: 12px; padding: 10px 6px; text-align: center; background: #f8fafc; }
.m-kpi-v { font-size: 24px; font-weight: 900; line-height: 1.1; }
.m-kpi-l { font-size: 11.5px; font-weight: 600; color: var(--m-ink2); margin-top: 2px; }
.m-kpi.red { background: var(--m-red-bg); } .m-kpi.red .m-kpi-v { color: var(--m-red); }
.m-kpi.amber { background: var(--m-amber-bg); } .m-kpi.amber .m-kpi-v { color: var(--m-amber); }
.m-kpi.green { background: var(--m-green-bg); } .m-kpi.green .m-kpi-v { color: var(--m-green); }
.m-meta { font-size: 13px; color: var(--m-ink2); margin-top: 10px; }
.m-tension {
  margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--m-amber-bg);
  color: #92400e; font-size: 13.5px; font-weight: 600; line-height: 1.4;
}
.m-tension.strong { background: var(--m-red-bg); color: #991b1b; }
.m-cr { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--m-line); }
.m-cr-when { font-size: 12px; font-weight: 700; color: var(--m-ink3); text-transform: uppercase; letter-spacing: .04em; }
.m-cr-text {
  font-size: 14px; color: var(--m-ink); margin-top: 4px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.m-more { font-size: 14px; font-weight: 700; color: var(--m-accent); margin-top: 12px; }

/* Liste compacte */
.m-list { background: var(--m-card); border-radius: var(--m-radius); box-shadow: var(--m-shadow); overflow: hidden; }
.m-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px;
  border-top: 1px solid var(--m-line); cursor: pointer;
}
.m-row:first-child { border-top: none; }
.m-row:active { background: #f8fafc; }
.m-row-name { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 700; }
.m-row-name small { display: block; font-size: 12.5px; font-weight: 500; color: var(--m-ink2); margin-top: 2px; }
.m-row-state { font-size: 13px; font-weight: 700; white-space: nowrap; }
.m-row-state.green { color: var(--m-green); } .m-row-state.amber { color: var(--m-amber); } .m-row-state.grey { color: var(--m-ink3); }
.m-empty { text-align: center; color: var(--m-ink3); font-size: 14px; padding: 28px 12px; }
.m-note { font-size: 12.5px; color: var(--m-ink3); text-align: center; margin: 18px 8px 4px; line-height: 1.5; }

/* Qualité */
.m-alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; margin-bottom: 8px; font-size: 14px; line-height: 1.4; background: var(--m-card); box-shadow: var(--m-shadow); }
.m-alert.critique { border-left: 5px solid var(--m-red); }
.m-alert.attention { border-left: 5px solid #f59e0b; }
.m-ok { background: var(--m-green-bg); color: var(--m-green); border-radius: 12px; padding: 14px; font-size: 14px; font-weight: 700; }
.m-rank { display: flex; align-items: center; gap: 12px; }
.m-rank-pos {
  width: 34px; height: 34px; border-radius: 50%; flex: none; background: #f1f5f9; color: var(--m-ink2);
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 15px;
}
.m-rank-name { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 800; }
.m-rank-score { font-size: 26px; font-weight: 900; }
.m-bar { height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden; margin-top: 12px; }
.m-bar > div { height: 100%; border-radius: 4px; }
.m-rates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.m-rates .m-chip { margin-top: 0; }

/* Messages */
.m-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #f1f5f9; padding: 4px; border-radius: 12px; }
.m-seg button {
  border: none; background: transparent; border-radius: 9px; min-height: 42px; font-size: 14.5px; font-weight: 700;
  color: var(--m-ink2); cursor: pointer;
}
.m-seg button.on { background: #fff; color: var(--m-ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.m-seg button.on.alert { color: var(--m-red); }
.m-textarea {
  width: 100%; min-height: 96px; margin-top: 10px; padding: 12px; border: 1.5px solid var(--m-line); border-radius: 12px;
  font: inherit; font-size: 16px; resize: vertical; color: var(--m-ink);
}
.m-textarea:focus { outline: none; border-color: var(--m-accent); }
.m-btn {
  width: 100%; min-height: 50px; border: none; border-radius: 12px; margin-top: 10px;
  background: var(--m-accent); color: #fff; font-size: 16px; font-weight: 800; cursor: pointer;
}
.m-btn:active { filter: brightness(.92); }
.m-btn:disabled { opacity: .55; }
.m-btn.red { background: var(--m-red); }
.m-btn.ghost { background: #fff; color: var(--m-ink); border: 1.5px solid var(--m-line); }
.m-btn.danger { background: #fff; color: var(--m-red); border: 1.5px solid #fecaca; }
.m-msg { background: var(--m-card); border-radius: 14px; box-shadow: var(--m-shadow); padding: 12px 14px; margin-bottom: 10px; }
.m-msg.alerte { border-left: 5px solid var(--m-red); }
.m-msg-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; }
.m-msg-text { font-size: 15px; line-height: 1.45; margin-top: 6px; white-space: pre-wrap; word-wrap: break-word; }
.m-msg-meta { font-size: 12.5px; color: var(--m-ink3); margin-top: 6px; }
.m-msg-del { margin-left: auto; border: none; background: none; color: var(--m-ink3); font-size: 13px; font-weight: 700; min-height: 32px; padding: 0 4px; cursor: pointer; }

/* Plus */
.m-menu { background: var(--m-card); border-radius: var(--m-radius); box-shadow: var(--m-shadow); overflow: hidden; }
.m-menu button, .m-menu a {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 0 16px;
  border: none; border-top: 1px solid var(--m-line); background: none; font-size: 15.5px; font-weight: 600;
  color: var(--m-ink); text-decoration: none; text-align: left; cursor: pointer;
}
.m-menu > :first-child { border-top: none; }
.m-menu .m-chev { margin-left: auto; color: var(--m-ink3); font-size: 20px; }
.m-account { display: flex; align-items: center; gap: 12px; }
.m-avatar {
  width: 46px; height: 46px; border-radius: 50%; background: var(--m-brand); color: #fff; flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px;
}
.m-conseil { border-left: 5px solid #94a3b8; }
.m-conseil.haute, .m-conseil.critique, .m-conseil.urgent { border-left-color: var(--m-red); }
.m-conseil.moyenne, .m-conseil.important { border-left-color: #f59e0b; }
.m-conseil-text { font-size: 15px; font-weight: 700; line-height: 1.4; margin-top: 6px; }
.m-conseil-detail { font-size: 14px; color: var(--m-ink2); line-height: 1.45; margin-top: 6px; }
.m-fb { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.m-fb button {
  min-height: 44px; border-radius: 10px; border: 1.5px solid var(--m-line); background: #fff;
  font-size: 13.5px; font-weight: 700; color: var(--m-ink); cursor: pointer;
}
.m-fb button.yes { border-color: #bbf7d0; background: var(--m-green-bg); color: var(--m-green); }
.m-status { margin-top: 10px; font-size: 13.5px; font-weight: 700; color: var(--m-ink2); }

/* Fiche détail (plein écran, glisse du bas) */
.m-sheet {
  position: fixed; inset: 0; z-index: 50; background: var(--m-bg);
  transform: translateY(100%); transition: transform .25s ease; overflow-y: auto;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
.m-sheet.open { transform: none; }
.m-sheet .m-head { background: #fff; color: var(--m-ink); border-bottom: 1px solid var(--m-line); }
.m-sheet .m-head-sub { color: var(--m-ink2); }
.m-sheet .m-icon-btn { background: #f1f5f9; color: var(--m-ink); }
.m-full-text { font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; margin-top: 6px; }

/* Barre d'onglets */
.m-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--m-line);
  padding-bottom: env(safe-area-inset-bottom, 0px); backdrop-filter: blur(8px);
}
.m-tab {
  position: relative; height: var(--m-tabs-h); border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--m-ink3); font-size: 11.5px; font-weight: 700;
}
.m-tab .ico { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
.m-tab.on { color: var(--m-brand); }
.m-tab.on .ico { filter: none; opacity: 1; }
.m-tab.on::before { content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--m-brand); }
.m-badge {
  position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--m-red); color: #fff; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

.m-skel { height: 88px; border-radius: var(--m-radius); background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%); background-size: 200% 100%; animation: m-skel 1.2s infinite; margin-bottom: 12px; }
@keyframes m-skel { to { background-position: -200% 0; } }

/* Bouton de retour à l'affichage téléphone depuis la version ordinateur */
.m-back-mobile {
  position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  border: none; border-radius: 999px; padding: 12px 16px; background: var(--m-brand); color: #fff;
  font-size: 14px; font-weight: 800; box-shadow: var(--m-shadow); cursor: pointer;
}

/* Écran de connexion sur téléphone */
@media (max-width: 820px) {
  #login-screen { padding: 16px; }
  #login-screen .login-box { width: 100%; max-width: 420px; padding: 28px 20px; }
  #login-screen .login-input, #login-screen .login-btn { min-height: 48px; font-size: 16px; }
}

/* ── Conformité des établissements (26/09/2026, compliance.js) ── */
.cp-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.cp-counts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cp-counts .m-chip { margin-top: 0; }
.cp-issues, .cp-all { margin-top: 10px; border-top: 1px solid #e2e8f0; }
.cp-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.cp-row .cp-dot { margin-top: 5px; }
.cp-row-main { flex: 1; min-width: 0; line-height: 1.4; }
.cp-row-detail { font-size: 12.5px; color: #64748b; margin-top: 2px; }
.cp-toggle { margin-top: 10px; border: none; background: none; color: #2563eb; font-weight: 700; font-size: 14px; padding: 6px 0; cursor: pointer; }
.cp-wrap { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px 18px; }
.cp-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.cp-title { font-size: 15px; font-weight: 800; color: #0f172a; }
.cp-legend { display: flex; gap: 14px; font-size: 12px; color: #475569; }
.cp-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cp-refresh { margin-left: auto; border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.cp-scroll { overflow-x: auto; }
.cp-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cp-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; color: #64748b; padding: 6px 8px; border-bottom: 2px solid #e2e8f0; white-space: nowrap; }
.cp-table td { padding: 8px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.cp-name { font-weight: 700; color: #1e293b; white-space: nowrap; }
.cp-cell { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.cp-muted { color: #94a3b8; }
.cp-foot { font-size: 11px; color: #94a3b8; margin-top: 10px; }

/* ── Demandes d'aide des établissements (26/09/2026, aid-regional.js) ── */
.aid-desktop { margin: 0 0 18px; }
.aid-title { font-size: 15px; font-weight: 800; color: #0f172a; margin: 0 0 10px; }
.aid-none { font-size: 14px; color: #64748b; padding: 6px 2px 10px; }
.aid-card { background: #fff; border: 1px solid #e2e8f0; border-left: 5px solid #b91c1c; border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(15,23,42,.05); }
.aid-card.urgent { box-shadow: 0 0 0 2px #fecaca; }
.aid-top { display: flex; align-items: center; gap: 8px; }
.aid-etab { font-weight: 800; font-size: 15.5px; flex: 1; min-width: 0; }
.aid-status { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.aid-type { font-size: 14.5px; font-weight: 700; margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.aid-urgent { font-size: 11.5px; font-weight: 900; color: #fff; background: #dc2626; padding: 2px 8px; border-radius: 999px; letter-spacing: .04em; }
.aid-text { font-size: 15px; line-height: 1.45; margin-top: 6px; white-space: pre-wrap; word-wrap: break-word; }
.aid-meta { font-size: 12.5px; color: #64748b; margin-top: 6px; }
.aid-hist { margin-top: 8px; padding: 8px 10px; background: #f8fafc; border-radius: 10px; }
.aid-hist-when { font-size: 12px; color: #64748b; }
.aid-hist-text { font-size: 14px; margin-top: 2px; white-space: pre-wrap; }
.aid-ta { width: 100%; box-sizing: border-box; min-height: 70px; margin-top: 12px; padding: 10px 12px; border: 1.5px solid #cbd5e1; border-radius: 12px; font: inherit; font-size: 16px; resize: vertical; }
.aid-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.aid-btn { min-height: 46px; border-radius: 12px; border: 1.5px solid #e2e8f0; background: #fff; font-size: 14.5px; font-weight: 700; color: #0f172a; cursor: pointer; }
.aid-btn.main { grid-column: 1 / -1; background: #0f766e; border-color: #0f766e; color: #fff; }
.aid-btn.ok { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
.aid-btn:disabled { opacity: .55; }
.aid-msg { font-size: 13px; color: #b91c1c; margin-top: 6px; min-height: 16px; }
.aid-more { border: none; background: none; color: #2563eb; font-weight: 700; font-size: 14px; padding: 6px 0 10px; cursor: pointer; }
@media (min-width: 821px) { .aid-actions { grid-template-columns: repeat(4, auto); justify-content: start; } .aid-btn.main { grid-column: auto; } .aid-btn { padding: 0 16px; } }

/* ── Niveau national (groupe, 26/09/2026) : sections par région du tableau de conformité ── */
.cp-sec td { background: #f8fafc; padding-top: 12px; font-size: 13px; }
.cp-sec .cp-counts { display: inline-flex; margin: 0 0 0 8px; vertical-align: middle; }
