/* Mailior v2 — feuille de style unique (login + back-office). Vanilla, sans framework. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e4e8f0;
  --text: #1e2433;
  --muted: #6b7488;
  --primary: #2f6bff;
  --primary-dark: #2456d8;
  --primary-soft: #e8f0ff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --success: #2f9e5c;
  --warn: #d98a00;
  --shadow: 0 1px 3px rgba(20, 30, 60, .06), 0 8px 24px rgba(20, 30, 60, .06);
  --radius: 12px;
  --sidebar-w: 244px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2, h3 { margin: 0; font-weight: 650; }

/* --- Boutons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: 9px;
  font-size: 14px; font-weight: 600; cursor: pointer; line-height: 1;
  background: var(--surface-2); color: var(--text); transition: all .15s;
}
.btn:hover { filter: brightness(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); filter: none; }
.btn--ghost { background: transparent; border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #c93a3f; filter: none; }
.btn--sm { padding: 6px 11px; font-size: 13px; }
.btn--block { width: 100%; }

/* --- Champs --- */
.field { margin-bottom: 14px; }
.field__label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; font-family: inherit; color: var(--text); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { resize: vertical; min-height: 76px; }

/* --- Messages --- */
.msg { font-size: 13.5px; margin: 10px 0 0; min-height: 18px; }
.msg--error { color: var(--danger); }
.msg--success { color: var(--success); }
.muted { color: var(--muted); }

/* --- Badges --- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 12px; font-weight: 600; }
.badge--actif { background: #e6f6ec; color: var(--success); }
.badge--prospect { background: var(--primary-soft); color: var(--primary-dark); }
.badge--inactif { background: #eef0f4; color: var(--muted); }
.badge--admin { background: #f3e8ff; color: #8b5cf6; }
.badge--user { background: #eef0f4; color: var(--muted); }
.badge--on { background: #e6f6ec; color: var(--success); }
.badge--off { background: var(--danger-soft); color: var(--danger); }

/* =========================================================================
   LOGIN
   ========================================================================= */
.auth {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e8f0ff 0%, var(--bg) 55%);
}
.auth__card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: 32px 30px;
}
.auth__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth__logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.auth__title { font-size: 20px; }
.auth__subtitle { color: var(--muted); font-size: 14px; margin: 4px 0 22px; }
.auth__qr { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 6px 0 16px; }
.auth__qr img { border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 8px; }
.auth__hint { font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.5; }
.auth__code { text-align: center; letter-spacing: 6px; font-size: 22px; font-weight: 600; }

/* =========================================================================
   SHELL BACK-OFFICE
   ========================================================================= */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: #131a2b; color: #c7cede; display: flex; flex-direction: column;
  padding: 18px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px; }
.sidebar__logo {
  width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 800;
}
.sidebar__brand-name { color: #fff; font-weight: 700; font-size: 17px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav__item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px;
  color: #c7cede; text-decoration: none; font-size: 14.5px; font-weight: 550; cursor: pointer;
  background: none; border: none; width: 100%; text-align: left; transition: background .15s, color .15s;
}
.nav__item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav__item.is-active { background: var(--primary); color: #fff; }
.nav__icon { width: 18px; height: 18px; flex: none; }
.sidebar__foot { margin-top: auto; font-size: 12px; color: #6b7488; padding: 12px 8px 0; }

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

.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-size: 17px; font-weight: 650; }

/* Menu profil (haut a droite) */
.profile { position: relative; }
.profile__btn {
  display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 5px; border: 1px solid var(--border);
  border-radius: 100px; background: var(--surface); cursor: pointer;
}
.profile__btn:hover { background: var(--surface-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.profile__name { font-size: 13.5px; font-weight: 600; }
.profile__caret { color: var(--muted); font-size: 11px; }
.profile__menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 240px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; z-index: 30;
}
.profile__menu[hidden] { display: none; }
.profile__head { padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.profile__head-name { font-weight: 650; font-size: 14px; }
.profile__head-mail { color: var(--muted); font-size: 12.5px; margin-top: 2px; word-break: break-all; }
.profile__action {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: none;
  background: none; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text); text-align: left;
}
.profile__action:hover { background: var(--surface-2); }
.profile__action--danger { color: var(--danger); }

.content { padding: 24px; max-width: 1080px; width: 100%; }

/* --- Cartes / stats --- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.card__label { color: var(--muted); font-size: 13px; font-weight: 600; }
.card__value { font-size: 30px; font-weight: 720; margin-top: 6px; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.panel__title { font-size: 15.5px; font-weight: 650; }
.panel__body { padding: 4px 0; }

/* --- Tableaux --- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 20px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table__actions { display: flex; gap: 6px; justify-content: flex-end; }
.table__empty { padding: 34px 20px; text-align: center; color: var(--muted); }

/* --- Modale --- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__overlay { position: absolute; inset: 0; background: rgba(19, 26, 43, .48); }
.modal__box {
  position: relative; width: 100%; max-width: 460px; background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow); padding: 24px; max-height: 90vh; overflow: auto;
}
.modal__title { font-size: 17px; margin-bottom: 16px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* --- Dossiers : pastille couleur + selecteur --- */
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 9px; vertical-align: middle; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 26px; height: 26px; border-radius: 7px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.swatch:hover { transform: scale(1.08); }
.color-input { width: 44px; height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); cursor: pointer; }

.view-intro { color: #475063; font-size: 13.5px; background: #f4f8ff; border: 1px solid #dbe7ff; border-radius: 10px; padding: 11px 14px; margin: 0 0 18px; }
.hint { font-size: 12px; color: #8b95ac; margin: 6px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.chip { background: #eef2f9; color: #475063; border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 600; }
.chip--addr { background: #e8f0ff; color: #2456d8; }

.cr-src { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 100px; margin-left: 8px; vertical-align: middle; }
.cr-src--rule { background: #e8f0ff; color: #2456d8; }
.cr-src--ai { background: #f3e8ff; color: #8b5cf6; }

.obadge { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 100px; }
.obadge--on { background: #e6f6ec; color: var(--success); }
.obadge--off { background: #eef0f4; color: var(--muted); }

/* --- Sous-onglets (Parametres) --- */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.subtab {
  border: none; background: none; padding: 10px 16px; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subtab:hover { color: var(--text); }
.subtab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* --- Ecran bloquant : changement de mot de passe force --- */
.gate {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #e8f0ff 0%, var(--bg) 55%);
}
.gate__card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: 30px 28px;
}
.gate__title { font-size: 20px; }
.gate__sub { color: var(--muted); font-size: 13.5px; margin: 6px 0 20px; }

/* --- Regle graduee + curseur (frequence) --- */
.freq-readout { font-size: 15px; color: var(--text); margin-bottom: 20px; }
.freq-readout strong { color: var(--primary); font-size: 20px; }
.ruler { position: relative; height: 72px; margin: 4px 6px 0; }
/* 11px = moitie du pouce (22px) : aligne les crans avec le centre du curseur aux extremites. */
.ruler__line { position: absolute; left: 11px; right: 11px; top: 33px; height: 2px; background: #131a2b; }
.ruler__ticks { position: absolute; left: 11px; right: 11px; top: 26px; display: flex; justify-content: space-between; }
.ruler__tick { width: 2px; height: 16px; background: #131a2b; border-radius: 1px; }
.ruler__range {
  position: absolute; left: 0; right: 0; top: 21px; width: 100%; height: 26px; margin: 0;
  background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer;
}
.ruler__range:focus { outline: none; }
.ruler__range:focus::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--primary-soft), 0 1px 4px rgba(20, 30, 60, .3); }
.ruler__range::-webkit-slider-runnable-track { background: transparent; height: 26px; }
.ruler__range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 26px; border-radius: 6px;
  background: var(--primary); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(20, 30, 60, .3); cursor: grab;
}
.ruler__range::-webkit-slider-thumb:active { cursor: grabbing; }
.ruler__range::-moz-range-track { background: transparent; height: 26px; }
.ruler__range::-moz-range-thumb {
  width: 22px; height: 26px; border-radius: 6px; background: var(--primary); border: 2px solid #fff; cursor: grab;
}
.ruler__labels { position: absolute; left: 11px; right: 11px; top: 48px; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.wk-summary { margin-top: 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; line-height: 1.6; }
code { background: #eef2f9; border-radius: 4px; padding: 1px 5px; font-size: 12px; }

.classify-result { margin-top: 14px; border-radius: 10px; padding: 12px 14px; font-size: 13.5px; }
.classify-result--ok { background: #e9f7ef; border: 1px solid #b8e6c8; }
.classify-result--none { background: #fff8ec; border: 1px solid #f2dca8; color: #8a6300; }
.classify-result--err { background: var(--danger-soft); border: 1px solid #f5c2c4; color: var(--danger); }
.cr-head { font-size: 14.5px; display: flex; align-items: center; }
.cr-reason { color: #475063; margin-top: 6px; font-size: 13px; }

.section { margin-bottom: 26px; }
.section__title { font-size: 15px; font-weight: 650; margin-bottom: 4px; }
.section__desc { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar__brand { padding: 0 10px 0 4px; }
  .nav { flex-direction: row; }
  .sidebar__foot { display: none; }
  .row2 { grid-template-columns: 1fr; }
  .profile__name { display: none; }
}
