/* =====================================================================
   Educanet · Envoi de SMS aux enseignants
   Charte reprise du logo :
   - sarcelle du mot « Educanet », orange de la toque, vert du slogan
   - titres en Saira italique grasse, comme le logotype
   - coupe en biais (−15°) des lettres du logo → badges, onglets, KPI
   ===================================================================== */

:root {
  --teal: #049A90;
  --teal-700: #037C74;
  --teal-900: #03524D;
  --teal-50: #E8F5F4;
  --orange: #F08100;
  --orange-50: #FEF1E2;
  --green: #86C152;
  --green-700: #5E9530;
  --green-50: #EFF7E7;
  --amber: #E7A500;
  --red: #D6452F;

  --ink: #17302E;
  --muted: #5B6F6D;
  --line: #DCE7E5;
  --paper: #F3F7F6;
  --white: #FFFFFF;

  --slant: 10px;              /* largeur de la coupe en biais */
  --radius: 12px;
  --font-display: 'Saira', 'Arial Narrow', sans-serif;
  --font-body: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; }
a { color: var(--teal-700); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }

/* ----------------------------------------------------------- Structure */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 264px; flex: none;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 24px 18px 18px;
  background: var(--white);
  border-right: 1px solid var(--line);
  z-index: 30;
}
.brand img { width: 176px; display: block; }
.brand-sub { margin: 6px 0 28px; color: var(--muted); font-size: 13px; font-weight: 700; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}
.nav a:hover { background: var(--teal-50); color: var(--teal-900); }
.nav a.active { background: var(--teal); color: var(--white); }
.nav a.active::after {               /* coupe orange, rappel du logo */
  content: ''; position: absolute; right: 10px; top: 50%;
  width: 8px; height: 22px; margin-top: -11px;
  background: var(--orange);
  transform: skewX(-15deg);
}
.nav-badge { margin-left: auto; }
.nav a.active .nav-badge { margin-right: 18px; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.who { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.who strong { display: block; font-size: 14px; }
.who small { color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 36px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar h1 {
  font-size: 26px; font-weight: 800; font-style: italic;
  color: var(--teal-700);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar p { margin: 2px 0 0; color: var(--muted); font-weight: 600; }
.menu-toggle { display: none; background: none; border: 0; padding: 6px; color: var(--ink); cursor: pointer; }

.bell { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--teal-700); background: var(--teal-50); }
.bell .notif-badge { position: absolute; top: -3px; right: -5px; }

.content { padding: 28px 36px 48px; width: 100%; max-width: 1360px; }
.content-narrow { max-width: 860px; }

/* ----------------------------------------------------------- Éléments */
.avatar {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  font: 800 13px/1 var(--font-display);
  color: var(--white);
}
.av-staff { background: var(--teal); }
.av-client { background: var(--orange); }
.av-sm { width: 26px; height: 26px; font-size: 11px; }

.notif-badge {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  background: var(--orange); color: var(--white);
  font: 800 11px/1 var(--font-body);
}
.notif-badge.is-hidden { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border: 0; border-radius: 8px;
  font: 800 14px/1.2 var(--font-body);
  text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { background: var(--teal-700); }
.btn-accent { background: var(--orange); color: var(--white); }
.btn-accent:hover { background: #D97200; }
.btn-green { background: var(--green-700); color: var(--white); }
.btn-green:hover { background: #4E7E27; }
.btn-ghost { background: var(--white); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover { box-shadow: inset 0 0 0 1.5px var(--teal); color: var(--teal-900); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 26px; font-size: 15px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--teal-700); font: 700 13px var(--font-body); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link { font-weight: 700; font-size: 14px; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Badges de statut : parallélogrammes coupés comme le « E » du logo */
.badge {
  display: inline-block;
  padding: 4px calc(var(--slant) + 6px);
  clip-path: polygon(var(--slant) 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%);
  font: 700 12px/1.4 var(--font-body);
  white-space: nowrap;
}
.badge-lg { padding: 6px calc(var(--slant) + 10px); font-size: 13px; }
.st-new      { background: var(--orange);  color: var(--white); }
.st-progress { background: var(--teal);    color: var(--white); }
.st-waiting  { background: #FFE7A3;        color: #6B4C00; }
.st-resolved { background: var(--green);   color: #1F3A08; }
.st-closed   { background: #E3E9E8;        color: var(--muted); }

.prio { font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.prio::before, .prio-dot { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.prio-dot { display: inline-block; width: 10px; height: 10px; }
.pr-low { color: var(--muted); }
.pr-normal { color: var(--teal-700); }
.pr-high { color: #C46A00; }
.pr-urgent { color: var(--red); }

.ref { font: 700 13px var(--font-display); letter-spacing: .02em; color: var(--teal-700); text-decoration: none; white-space: nowrap; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.panel h3 { font-size: 17px; font-weight: 700; color: var(--teal-900); margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.panel-head h3 { margin: 0; }

.empty { text-align: center; padding: 36px 24px; color: var(--muted); }
.empty p { margin: 0 0 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.chart-box { position: relative; height: 260px; }

/* ----------------------------------------------------------- KPI */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 20px 18px 26px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink); text-decoration: none;
}
.kpi::before {                    /* tranche en biais sur le bord gauche */
  content: ''; position: absolute; left: -6px; top: 0; bottom: 0; width: 14px;
  background: var(--k, var(--muted));
  transform: skewX(-12deg);
}
.kpi:hover { border-color: var(--k, var(--teal)); }
.kpi-num { font: italic 800 38px/1 var(--font-display); color: var(--k, var(--ink)); }
.kpi-lbl { color: var(--muted); font-weight: 700; font-size: 14px; }
.kpi-teal { --k: var(--teal); }
.kpi-orange { --k: var(--orange); }
.kpi-green { --k: var(--green-700); }
.kpi-red { --k: var(--red); }

/* ----------------------------------------------------------- Listes de tickets */
.ticket-rows, .notif-list { list-style: none; margin: 0; padding: 0; }
.ticket-rows li + li, .notif-list li + li { border-top: 1px solid var(--line); }
.ticket-rows a, .notif-list a {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 4px;
  color: inherit; text-decoration: none;
}
.ticket-rows a:hover .row-main strong, .notif-list a:hover strong { color: var(--teal-700); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-main strong { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { color: var(--muted); font-size: 13px; }
time { color: var(--muted); font-size: 13px; white-space: nowrap; }

.hero-client {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 28px 32px; margin-bottom: 20px;
  border-radius: var(--radius);
  color: var(--white);
  background:
    linear-gradient(105deg, transparent 72%, rgba(255,255,255,.10) 72%, rgba(255,255,255,.10) 78%, transparent 78%),
    var(--teal);
}
.hero-client h2 { font-size: 26px; font-style: italic; font-weight: 800; }
.hero-client p { margin: 6px 0 0; max-width: 60ch; opacity: .92; }
.hero-client + .kpis { margin-bottom: 20px; }
.kpis + .panel { margin-top: 20px; }

/* ----------------------------------------------------------- Barre d'outils / filtres */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.tabs { display: flex; gap: 2px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.tabs a { padding: 7px 16px; color: var(--muted); font-weight: 700; font-size: 14px; text-decoration: none; }
.tabs a.on {
  background: var(--teal); color: var(--white);
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel], input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 8px;
  background: var(--white); color: var(--ink);
  font: 15px/1.4 var(--font-body);
}
.filters select, .filters input { width: auto; min-width: 180px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-50); }
textarea { resize: vertical; }

/* ----------------------------------------------------------- Tableau */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 12px 16px; font-size: 13px; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); background: #FAFCFB; white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td small { display: block; color: var(--muted); font-size: 12.5px; }
.cell-subject { min-width: 260px; max-width: 420px; }
.table td:nth-child(3) { min-width: 150px; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--teal-50); }
.row-off td { opacity: .5; }
.assignee { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.inline-reset { display: flex; gap: 8px; align-items: center; }
.inline-reset input { width: 170px; padding: 6px 10px; font-size: 13px; }
.role-pill { font-weight: 700; font-size: 13px; }
.r-ADMIN { color: var(--orange); }
.r-ASSISTANT { color: var(--teal-700); }
.r-CLIENT { color: var(--muted); }

/* ----------------------------------------------------------- Formulaires */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 700; font-size: 14px; padding: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 18px; }
.err { color: var(--red); font-style: normal; font-size: 13px; font-weight: 600; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; margin-top: 20px; }
.span-2 { grid-column: span 2; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.seg { display: flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; position: relative; cursor: pointer; }
.seg label + label { border-left: 1.5px solid var(--line); }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 9px 4px; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg input:checked + span { background: currentColor; }
.seg label.pr-low input:checked + span { background: #E3E9E8; color: var(--ink); }
.seg label.pr-normal input:checked + span { background: var(--teal); color: var(--white); }
.seg label.pr-high input:checked + span { background: var(--orange); color: var(--white); }
.seg label.pr-urgent input:checked + span { background: var(--red); color: var(--white); }
.seg input:focus-visible + span { outline: 3px solid var(--orange); outline-offset: -3px; }

.create-user { margin-bottom: 20px; }
.create-user summary { list-style: none; }
.create-user summary::-webkit-details-marker { display: none; }
.create-user[open] summary { background: var(--white); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }

.alert { padding: 12px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.alert-err { background: #FCEAE7; color: #8E2A1A; }
.alert-ok { background: var(--green-50); color: #36601A; }

/* ----------------------------------------------------------- Ticket : discussion */
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.thread { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.thread-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--line); }

.resolve-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; background: var(--green-50); border-bottom: 1px solid var(--line); }
.resolve-bar p { margin: 0; font-weight: 700; color: #36601A; }
.resolve-bar > div { display: flex; gap: 8px; flex-wrap: wrap; }
.waiting-bar { background: #FFF6DB; }
.waiting-bar p { color: #6B4C00; }

.stream {
  list-style: none; margin: 0;
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
  max-height: 62vh; overflow-y: auto;
  background: linear-gradient(var(--paper), var(--paper)) padding-box;
}
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 78%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: var(--white); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 10px 14px 12px; min-width: 0; }
.msg.mine .bubble { background: var(--teal); border-color: var(--teal); color: var(--white); border-radius: 14px 14px 4px 14px; }
.msg.from-staff:not(.mine) .bubble { background: var(--teal-50); border-color: #C9E7E4; }
.bubble header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 4px; font-size: 13px; }
.bubble header time { font-size: 12px; }
.msg.mine .bubble header time, .msg.mine .role-tag { color: rgba(255,255,255,.8); }
.role-tag { color: var(--muted); font-size: 12px; font-weight: 600; }
.bubble p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }

.sys { align-self: center; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; max-width: 90%; text-align: center; font-size: 13px; color: var(--muted); font-weight: 600; }
.sys span { padding: 3px 14px; background: var(--white); border: 1px dashed var(--line); border-radius: 20px; }
.sys time { font-size: 12px; align-self: center; }

.composer { display: flex; gap: 10px; align-items: flex-end; padding: 16px 24px 4px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 46px; }
.composer-hint { margin: 0; padding: 0 24px 14px; font-size: 12px; color: var(--muted); }
.closed-note { padding: 18px 24px; border-top: 1px solid var(--line); background: #F0F3F3; color: var(--muted); font-weight: 600; text-align: center; }

.side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.facts dl { margin: 0; display: grid; grid-template-columns: 112px 1fr; gap: 10px 12px; font-size: 14px; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Suivi du statut */
.track { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.track li { position: relative; padding: 0 0 14px 26px; color: var(--muted); font-size: 14px; font-weight: 600; }
.track li::before { content: ''; position: absolute; left: 3px; top: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); background: var(--white); }
.track li::after { content: ''; position: absolute; left: 9px; top: 18px; bottom: 2px; width: 2px; background: var(--line); }
.track li:last-child::after { display: none; }
.track li.done { color: var(--ink); }
.track li.done::before { background: var(--green); border-color: var(--green); }
.track li.done::after { background: var(--green); }
.track li.now { color: var(--teal-900); font-weight: 800; }
.track li.now::before { background: var(--orange); border-color: var(--orange); box-shadow: 0 0 0 4px var(--orange-50); }

/* ----------------------------------------------------------- Notifications */
.notif-list { padding: 4px 20px; }
.notif-list li.unseen strong { color: var(--ink); }
.notif-list li.seen strong { font-weight: 600; color: var(--muted); }
.notif-ico { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--line); }
.unseen .notif-ico { background: var(--orange); box-shadow: 0 0 0 4px var(--orange-50); }

/* ----------------------------------------------------------- Toasts */
.flash-zone { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px 14px 20px;
  border-radius: 10px;
  background: var(--teal-900); color: var(--white);
  font-weight: 600; font-size: 14px;
  text-decoration: none;
  box-shadow: 0 10px 30px rgba(3, 82, 77, .25);
  border-left: 6px solid var(--green);
  animation: toast-in .25s ease-out;
}
.toast span { flex: 1; }
.toast-err { background: #7E2416; border-left-color: var(--orange); }
.toast-live { border-left-color: var(--orange); }
.toast-x { background: none; border: 0; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; opacity: .7; padding: 0; }
.toast.out { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ----------------------------------------------------------- Connexion */
.auth-body { background: var(--white); }
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-brand {
  position: relative; overflow: hidden;
  display: flex; align-items: center;
  padding: 64px 7vw;
  background: var(--teal);
  color: var(--white);
}
.auth-brand-inner { position: relative; z-index: 1; max-width: 520px; }
.auth-brand h1 { font-size: clamp(36px, 4.4vw, 60px); font-style: italic; font-weight: 800; line-height: 1.02; letter-spacing: -.01em; }
.auth-steps { list-style: none; margin: 40px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; font-weight: 700; font-size: 16px; }
.auth-steps b {
  display: inline-grid; place-items: center; width: 34px; height: 28px; margin-right: 12px;
  background: var(--orange);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  font: italic 800 15px var(--font-display);
}
/* Les trois coupes en biais du « E » du logo */
.cuts { position: absolute; right: -60px; top: 0; bottom: 0; width: 46%; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.cuts i { display: block; height: 70px; background: rgba(255,255,255,.08); clip-path: polygon(70px 0, 100% 0, calc(100% - 70px) 100%, 0 100%); }
.cuts i:nth-child(2) { margin-left: -40px; background: rgba(255,255,255,.12); }
.cuts i:nth-child(3) { margin-left: -80px; background: var(--green); opacity: .35; }

.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 64px 7vw; max-width: 560px; width: 100%; justify-self: center; }
.auth-logo { width: 220px; margin-bottom: 36px; }
.auth-panel h2 { font-size: 22px; font-weight: 700; margin-bottom: 22px; color: var(--teal-900); }
.auth-help { margin-top: 22px; color: var(--muted); font-size: 14px; }

.error-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.error-page h1 { font-size: 34px; font-style: italic; font-weight: 800; color: var(--teal-700); }
.error-page p { color: var(--muted); max-width: 46ch; margin: 10px 0 24px; }

/* ----------------------------------------------------------- Pièces jointes */
.attachments { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.att {
  display: flex; align-items: center; gap: 10px;
  max-width: 260px; padding: 8px 12px 8px 8px;
  background: var(--white); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); text-decoration: none;
}
.att:hover { border-color: var(--teal); }
.att-ext {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 34px;
  background: var(--orange); color: var(--white);
  font: italic 800 11px var(--font-display);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}
.att-meta { min-width: 0; display: flex; flex-direction: column; }
.att-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta small { color: var(--muted); font-size: 12px; }
.att-img { flex-direction: column; align-items: stretch; padding: 6px; }
.att-img img { width: 100%; max-height: 160px; object-fit: cover; border-radius: 6px; display: block; }
.msg.mine .att { color: var(--ink); }

.attach-btn {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 8px;
  color: var(--teal-700); background: var(--teal-50); cursor: pointer;
}
.attach-btn:hover { background: #D4EEEC; }
.file-chip {
  display: inline-block; margin: 0 6px 6px 0; padding: 3px 10px;
  background: var(--teal-50); color: var(--teal-900);
  border-radius: 20px; font-size: 12px; font-weight: 700;
}
.file-chip.too-big { background: #FCEAE7; color: #8E2A1A; }
#composer-files { display: block; }
.file-input { padding: 10px; border: 1.5px dashed var(--line); border-radius: 8px; background: #FAFCFB; }

/* =====================================================================
   Application SMS
   ===================================================================== */
.small { font-size: 13px; }
.center { text-align: center; }
.no-margin { margin: 0; }
.nowrap { white-space: nowrap; }
.num { text-align: right; }
.tel { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[dir=rtl], .sms-text, .phone-bubble { font-family: var(--font-body), 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif; }

.topbar-cta { flex: none; }
.st-failed { background: var(--red); color: var(--white); }
.kpis-3 { grid-template-columns: repeat(3, 1fr); }
.panel-gap { margin-top: 20px; }
.table-plain th, .table-plain td { padding: 9px 4px; }
.table-flat { border: 0; border-radius: 0; margin: 0 -24px -22px; border-top: 1px solid var(--line); }

/* Boutons-icônes des tableaux */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px; border: 0;
  background: var(--teal-50); color: var(--teal-700); cursor: pointer;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: #D4EEEC; }
.icon-danger { background: #FCEAE7; color: var(--red); }
.icon-danger:hover { background: #F8D5CF; }
.actions-end { justify-content: flex-end; gap: 6px; flex-wrap: nowrap; }
.btn-danger { color: var(--red); }
.btn-danger:hover { box-shadow: inset 0 0 0 1.5px var(--red); color: var(--red); }

/* Groupes d'un enseignant */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-block; padding: 2px 10px;
  background: var(--green-50); color: #36601A;
  border-radius: 20px; font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.chip:hover { background: #E0F0D0; }
.also a + a::before { content: ', '; color: var(--muted); }

/* Formulaires */
.field-row-eq { grid-template-columns: 1fr 1fr; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.check-card {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px;
  font-weight: 700; font-size: 14px; cursor: pointer;
}
.check-card:has(input:checked) { border-color: var(--teal); background: var(--teal-50); color: var(--teal-900); }
input[type=checkbox], input[type=radio] { accent-color: var(--teal); width: 16px; height: 16px; flex: none; }

/* Liste d'enseignants à cocher */
.picker-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 10px; }
.picker-tools input[type=search] { flex: 1; min-width: 180px; }
.picker-tools select { width: auto; min-width: 180px; }
.picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px;
  max-height: 340px; overflow-y: auto; padding: 2px;
}
.picker-compact { grid-template-columns: 1fr; max-height: 380px; margin-bottom: 14px; }
.pick {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 8px; cursor: pointer;
}
.pick input { grid-row: span 2; }
.pick-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick small { color: var(--muted); font-size: 12px; }
.pick.on { border-color: var(--teal); background: var(--teal-50); }
.pick[hidden] { display: none; }

/* Grille des groupes */
.dep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.dep-card { display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dep-card:hover { border-color: var(--teal); }
.dep-main { position: relative; flex: 1; padding: 20px 22px 16px 28px; color: var(--ink); text-decoration: none; }
.dep-main::before { content: ''; position: absolute; left: -6px; top: 0; bottom: 0; width: 14px; background: var(--teal); transform: skewX(-12deg); }
.dep-main h3 { font-size: 20px; font-style: italic; font-weight: 800; color: var(--teal-900); margin: 6px 0; }
.dep-main p { margin: 0; font-size: 14px; }
.dep-count { font-size: 13px; font-weight: 700; color: var(--muted); }
.dep-count b { font: italic 800 22px/1 var(--font-display); color: var(--orange); margin-right: 2px; }
.dep-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px 10px 22px; border-top: 1px solid var(--line); background: #FAFCFB; }
.dep-foot .actions { gap: 6px; }

/* Membres d'un groupe */
.member-list { list-style: none; margin: 0; padding: 0; }
.member-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.member-list li + li { border-top: 1px solid var(--line); }
.member-list .actions { gap: 6px; }
.danger-zone h3 { color: var(--red); }

/* ----------------------------------------------------------- Page d'envoi */
.sms-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.sms-main { display: flex; flex-direction: column; gap: 20px; }
.step {
  display: inline-grid; place-items: center; width: 30px; height: 24px; margin-right: 8px;
  background: var(--orange); color: var(--white);
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
  font: italic 800 14px var(--font-display);
}
.cible-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.cible-tab { position: relative; cursor: pointer; }
.cible-tab input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.cible-tab > span {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px; border: 1.5px solid var(--line); border-radius: 10px;
  color: var(--muted); text-align: center; font-size: 14px;
}
.cible-tab > span svg { width: 24px; height: 24px; }
.cible-tab:hover > span { border-color: var(--teal); color: var(--teal-900); }
.cible-tab.on > span, .cible-tab input:checked + span { border-color: var(--teal); background: var(--teal); color: var(--white); }
.cible-tab input:focus-visible + span { outline: 3px solid var(--orange); outline-offset: 2px; }
.cible-pane[hidden] { display: none; }
.info-line { margin: 0; padding: 14px 16px; background: var(--teal-50); border-radius: 8px; color: var(--teal-900); }

.sms-text { font-size: 16px; line-height: 1.6; min-height: 150px; }
.sms-text.is-invalid { border-color: var(--red); }
.counter { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin-top: 12px; font-size: 14px; }
.counter b { font-variant-numeric: tabular-nums; }
.lang-badge {
  display: inline-block; padding: 3px 14px;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  background: var(--teal); color: var(--white); font-weight: 800; font-size: 12.5px;
}
.lang-ARABE { background: var(--green-700); }
.lang-SPECIAL { background: var(--amber); color: #3D2B00; }
.lang-sm { padding: 1px 10px; font-size: 11px; margin-right: 4px; }
.seg-bar { display: flex; gap: 4px; margin-top: 10px; }
.seg-block { flex: 1; max-width: 120px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.seg-block i { display: block; height: 100%; background: var(--teal); transition: width .1s; }
.seg-block.over i { background: var(--red); }

.recap dl { margin: 0 0 16px; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 14px; }
.recap dt { color: var(--muted); font-weight: 600; }
.recap dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.recap-total { color: var(--orange); font-size: 18px; }
.recap-total b { font: italic 800 26px/1 var(--font-display); }
.recap .btn[disabled] { opacity: .45; cursor: not-allowed; }
.recap p { margin: 10px 0 0; }

/* Aperçu téléphone */
.phone { background: #EEF3F2; border-radius: 18px; padding: 12px 12px 16px; margin-bottom: 16px; }
.phone-head { text-align: center; font-weight: 800; font-size: 12px; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.phone-bubble {
  background: var(--white); border-radius: 16px 16px 16px 4px; padding: 10px 14px;
  font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow-y: auto;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.phone-bubble[dir=rtl] { border-radius: 16px 16px 4px 16px; text-align: right; }
.phone-bubble.placeholder { color: var(--muted); font-style: italic; }

/* ----------------------------------------------------------- Historique */
.filters-bar { margin-bottom: 18px; align-items: center; }
.filters-bar input[type=search] { min-width: 240px; }
.date-field { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--muted); }
.date-field input { width: auto; }
.cell-msg { min-width: 260px; max-width: 460px; }
.msg-excerpt {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--ink); text-decoration: none; font-weight: 600; overflow-wrap: anywhere;
}
.table td.num small { white-space: nowrap; }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 18px; }

/* Administration */
.account { padding: 4px 0; }
.account + .account { border-top: 1px dashed var(--line); }
.account small { display: block; color: var(--muted); }
.account .inline-reset { margin-top: 4px; }

/* ----------------------------------------------------------- Crédit SMS */
.quota {
  display: grid; grid-template-columns: auto auto auto; grid-template-rows: auto 6px; column-gap: 14px; row-gap: 7px;
  align-items: end; padding: 8px 16px 10px;
  background: var(--teal-50); border: 1.5px solid #CDE9E6; border-radius: 12px;
  color: var(--teal-900); text-decoration: none; flex: none;
}
.quota:hover { border-color: var(--teal); }
.quota-item { display: flex; flex-direction: column; line-height: 1.1; }
.quota-item small { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.quota-item b { font: italic 800 20px/1.1 var(--font-display); }
.quota-item i { font-style: normal; color: var(--muted); }
.quota-left { color: var(--teal-700); }
.quota-sep { width: 1px; height: 30px; background: #CDE9E6; align-self: center; }
.quota-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: #D6ECEA; overflow: hidden; }
.quota-bar i { display: block; height: 100%; background: var(--teal); border-radius: 3px; transition: width .2s; }
.quota-bar-lg { height: 8px; margin: 6px 0; }
.quota-low { background: #FFF6DB; border-color: #F2D98A; }
.quota-low .quota-left { color: #A86B00; }
.quota-low .quota-bar i, .quota-bar.is-low i { background: var(--orange); }
.quota-out { background: #FCEAE7; border-color: #F2B8AE; }
.quota-out .quota-left { color: var(--red); }
.quota-out .quota-bar i, .quota-bar.is-out i { background: var(--red); }
.btn.is-disabled { opacity: .45; pointer-events: none; }
.txt-red { color: var(--red); }
.txt-amber { color: #A86B00; }

.credit-banner { padding: 12px 36px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--line); }
.credit-out { background: #FCEAE7; color: #8E2A1A; }
.credit-low { background: #FFF6DB; color: #6B4C00; }

.credit-cell { min-width: 200px; }
.credit-cell small { display: block; color: var(--muted); }
.credit-nums b { font: italic 800 20px var(--font-display); color: var(--teal-700); margin-right: 4px; }
.credit-cell .inline-reset { margin-top: 8px; }
.credit-cell .inline-reset input { width: 100px; }

.recap-credit { padding: 12px 14px; margin-bottom: 16px; background: var(--teal-50); border-radius: 10px; font-size: 14px; }
.recap-credit-row { display: flex; justify-content: space-between; gap: 10px; }
.recap-credit-row + .recap-credit-row { margin-top: 4px; }
.recap-credit-row span { color: var(--muted); font-weight: 600; }
.recap-credit .quota-bar i { background: var(--orange); }
.recap-credit.is-over { background: #FCEAE7; }
.recap-credit.is-over .quota-bar i { background: var(--red); }
.recap-credit p { margin: 6px 0 0; }

.blocked { max-width: 560px; margin: 20px auto; }
.blocked h3 { font-size: 22px; font-style: italic; font-weight: 800; color: var(--red); margin: 10px 0 6px; }
.blocked-ico { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #FCEAE7; color: var(--red); }
.blocked-ico svg { width: 30px; height: 30px; }

/* ----------------------------------------------------------- Fenêtre de confirmation */
body.modal-open { overflow: hidden; }
.modal-wrap {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background: rgba(3, 50, 47, .45); backdrop-filter: blur(3px);
  animation: modal-fade .18s ease-out;
}
.modal-wrap.out { opacity: 0; transition: opacity .18s; }
.modal {
  position: relative; overflow: hidden;
  width: min(480px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--white); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(3, 50, 47, .35);
  animation: modal-in .22s cubic-bezier(.2, .9, .3, 1.2);
}
.modal::before {               /* bandeau en biais, rappel du logo */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 6px;
  background: linear-gradient(105deg, var(--teal) 0 62%, var(--orange) 62% 80%, var(--green) 80%);
}
.modal-head { display: flex; align-items: center; gap: 14px; padding: 26px 26px 6px; }
.modal-head h2 { font-size: 22px; font-style: italic; font-weight: 800; color: var(--teal-900); }
.modal-ico {
  display: grid; place-items: center; flex: none;
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--teal-50); color: var(--teal-700);
}
.modal-ico svg { width: 22px; height: 22px; }
.modal-accent .modal-ico { background: var(--orange-50); color: var(--orange); }
.modal-danger .modal-ico { background: #FCEAE7; color: var(--red); }
.modal-body { padding: 10px 26px 4px; color: var(--ink); font-size: 15px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 26px 24px; }
.btn-red { background: var(--red); color: var(--white); }
.btn-red:hover { background: #A8321F; }
@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }

/* contenu de la confirmation d'envoi */
.cf-target { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.cf-type { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cf-target b { font-size: 16px; color: var(--teal-900); }
.cf-bubble {
  background: #EEF3F2; border-radius: 14px 14px 14px 4px; padding: 12px 14px;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow-y: auto; font-size: 14px;
}
.cf-bubble[dir=rtl] { border-radius: 14px 14px 4px 14px; text-align: right; }
.cf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 10px; }
.cf-stats div { display: flex; flex-direction: column; align-items: center; padding: 10px 6px; border: 1.5px solid var(--line); border-radius: 10px; }
.cf-stats b { font: italic 800 26px/1 var(--font-display); color: var(--teal-700); }
.cf-stats small { color: var(--muted); font-size: 12px; font-weight: 700; margin-top: 4px; text-align: center; }
.cf-stats .cf-total { background: var(--orange-50); border-color: #FFD9AD; }
.cf-stats .cf-total b { color: var(--orange); }
.cf-credit { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; font-size: 13px; color: var(--muted); }
.cf-credit b { color: var(--ink); }
.cf-lang { font-weight: 700; }

.btn.is-loading svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------- Responsive */
.scrim { display: none; }
@media (max-width: 1150px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .sms-layout { grid-template-columns: 1fr; }
  .ticket-layout { grid-template-columns: 1fr; }
  .side { position: static; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(3,82,77,.35); z-index: 20; }
  .menu-toggle { display: block; }
  .topbar { padding: 14px 18px; }
  .topbar h1 { font-size: 21px; }
  .content { padding: 20px 16px 40px; }
  .grid-2, .field-row, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .hero-client { flex-direction: column; align-items: flex-start; padding: 22px; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 40px 24px; }
  .auth-steps { margin-top: 24px; }
  .auth-panel { padding: 36px 24px; }
  .msg { max-width: 92%; }
  .stream { padding: 16px; max-height: none; }
  .composer, .thread-head, .resolve-bar { padding-left: 16px; padding-right: 16px; }
  .filters select, .filters input { min-width: 0; flex: 1; }
  .cible-tabs { grid-template-columns: 1fr 1fr; }
  .field-row-eq { grid-template-columns: 1fr; }
  .topbar-cta span { display: none; }
  .quota { column-gap: 8px; padding: 6px 10px 8px; }
  .quota-item small { font-size: 10px; }
  .quota-item b { font-size: 16px; }
  .credit-banner { padding: 10px 16px; }
  .cf-stats b { font-size: 21px; }
  .topbar-cta { padding: 10px 12px; }
}
@media (max-width: 620px) {
  .topbar { flex-wrap: wrap; }
  .topbar-title { flex-basis: calc(100% - 60px); }
  .quota { order: 3; flex: 1; }
  .topbar-cta { order: 4; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-num { font-size: 30px; }
  .ticket-rows time { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
