/* Territoria — démo ShiftCore Technology. Données fictives. */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);

  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --aqua: #1baf7a;
  --yellow: #eda100;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --nav-bg: #0f2038;
  --nav-ink: #b9c7dc;
  --nav-active: #17304f;

  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Bandeau démo ---------- */
.demo-ribbon {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--nav-bg);
  color: #d7e2f2;
  font-size: 12.5px;
  text-align: center;
}
.demo-ribbon strong { color: #ffffff; font-weight: 600; }
.demo-ribbon a { color: #7db4f0; text-decoration: none; font-weight: 600; }
.demo-ribbon a:hover { text-decoration: underline; }

/* ---------- Squelette ---------- */
.shell { display: flex; min-height: calc(100vh - 34px); }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--nav-bg);
  color: var(--nav-ink);
  display: flex;
  flex-direction: column;
  padding: 20px 12px 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 18px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2a78d6, #1baf7a);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.brand-name { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: 0.3px; }
.brand-sub { font-size: 11px; color: var(--nav-ink); margin-top: -2px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--nav-ink);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
}
.nav a svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a.active { background: var(--nav-active); color: #fff; }
.nav a .pill {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
}
.sidebar-foot {
  margin-top: auto;
  padding: 14px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  color: #7e8fa0;
  color: #7e8da0;
}
.sidebar-foot a { color: #7db4f0; text-decoration: none; }

.main { flex: 1; min-width: 0; padding: 22px 28px 48px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 12px;
  color: var(--muted);
  min-width: 210px;
}
.search input { border: 0; outline: 0; background: transparent; font: inherit; color: var(--ink); width: 100%; }
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1c5cab; color: #fff; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #1c5cab;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}

/* ---------- Cartes & grilles ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card h2 { font-size: 14.5px; margin: 0 0 2px; font-weight: 650; }
.card .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; }

.stat .label { color: var(--ink-2); font-size: 12.5px; }
.stat .value { font-size: 27px; font-weight: 650; margin-top: 2px; }
.stat .delta { font-size: 12px; margin-top: 2px; font-weight: 600; }
.stat .delta.up { color: #006300; }
.stat .delta.down { color: var(--critical); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-top: 14px; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ---------- Graphiques ---------- */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 2px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.tooltip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(11, 11, 11, 0.12);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 12.5px;
  color: var(--ink);
  display: none;
  max-width: 260px;
}
.tooltip .tt-title { font-weight: 650; margin-bottom: 3px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tooltip .tt-row i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.tooltip .tt-row b { color: var(--ink); margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

/* ---------- Listes / activité ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--grid); }
.feed li:last-child { border-bottom: 0; }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; }
.feed .quand { color: var(--muted); font-size: 11.5px; }

/* ---------- Filtres & table ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input {
  font: inherit;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
.filters input:focus, .filters select:focus { border-color: var(--accent); }

.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 780px;
}
table.data th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: #f3f6fa; }
table.data tbody tr:last-child td { border-bottom: 0; }
.benef-nom { font-weight: 600; }
.benef-id { color: var(--muted); font-size: 11.5px; }

.meter { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.meter .track { flex: 1; height: 7px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 999px; background: var(--accent); }
.meter .pct { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; width: 34px; text-align: right; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: #f2f2ef;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.badge i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Pédagogie ---------- */
.module-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.module .disp { font-size: 11.5px; color: var(--accent); font-weight: 650; text-transform: uppercase; letter-spacing: 0.4px; }
.module h3 { margin: 4px 0 10px; font-size: 15px; }
.module .row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); margin-top: 7px; }
.module .row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.module .next { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--grid); font-size: 12.5px; color: var(--ink-2); }

/* ---------- Messagerie ---------- */
.mail { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
.threads { padding: 6px; }
.thread {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 11px 12px;
  cursor: pointer;
  color: var(--ink);
}
.thread:hover { background: #f3f6fa; }
.thread.active { background: var(--accent-soft); }
.thread .t-top { display: flex; align-items: center; gap: 8px; }
.thread .t-sujet { font-weight: 600; font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .t-unread { background: var(--accent); color: #fff; border-radius: 999px; font-size: 10.5px; font-weight: 700; padding: 1px 7px; }
.thread .t-apercu { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }

.conv { display: flex; flex-direction: column; min-height: 420px; }
.conv-head { padding: 14px 18px; border-bottom: 1px solid var(--grid); font-weight: 650; }
.conv-body { flex: 1; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 76%; }
.msg .who { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.msg .bulle {
  padding: 9px 13px;
  border-radius: 12px;
  background: #f2f2ef;
  font-size: 13.5px;
}
.msg.moi { align-self: flex-end; }
.msg.moi .who { text-align: right; }
.msg.moi .bulle { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg:not(.moi) .bulle { border-bottom-left-radius: 4px; }
.conv-foot { display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--grid); }
.conv-foot input {
  flex: 1;
  font: inherit;
  padding: 9px 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  outline: none;
}

/* ---------- Impact ---------- */
.hero-card { text-align: center; padding: 30px 24px 26px; }
.hero-value { font-size: 52px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.hero-label { font-size: 14.5px; color: var(--ink-2); margin-top: 6px; }
.hero-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.social-list { list-style: none; margin: 0; padding: 0; }
.social-list li { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--grid); font-size: 13.5px; }
.social-list li:last-child { border-bottom: 0; }
.social-list b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.metho { font-size: 12.5px; color: var(--muted); margin-top: 14px; }

/* ---------- Fiche bénéficiaire (modale) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 20, 34, 0.45);
  z-index: 80;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
}
.overlay.open { display: flex; }
.sheet {
  background: var(--surface);
  border-radius: 14px;
  width: 560px;
  max-width: 100%;
  max-height: 86vh;
  overflow: auto;
  padding: 22px 24px;
}
.sheet-head { display: flex; align-items: flex-start; gap: 12px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-close {
  margin-left: auto;
  border: 0;
  background: #f2f2ef;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  font-size: 15px;
  cursor: pointer;
  color: var(--ink-2);
}
.sheet dl { display: grid; grid-template-columns: 150px 1fr; gap: 7px 12px; margin: 16px 0; font-size: 13.5px; }
.sheet dt { color: var(--muted); }
.sheet dd { margin: 0; font-weight: 550; }
.steps { list-style: none; margin: 10px 0 0; padding: 0; }
.steps li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; font-size: 13.5px; }
.steps .ok { color: var(--good); font-weight: 700; }
.steps .todo { color: var(--baseline); font-weight: 700; }
.steps li.pending { color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  background: var(--nav-bg);
  color: #fff;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.view { display: none; }
.view.active { display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 920px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; overflow-x: auto; }
  .brand { padding: 0 8px 0 0; }
  .brand-sub, .sidebar-foot { display: none; }
  .nav { flex-direction: row; margin: 0; }
  .nav a { padding: 8px 11px; white-space: nowrap; }
  .main { padding: 16px 14px 40px; }
  .grid-2, .grid-2-even { grid-template-columns: 1fr; }
  .mail { grid-template-columns: 1fr; }
  .search { display: none; }
}
@media (max-width: 640px) {
  .cards, .module-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .hero-value { font-size: 40px; }
}
