:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --blue: #1d4ed8;
  --blue-dark: #1e40af;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--blue); }

.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* ---------- Barre de navigation ---------- */
.topbar { background: #1e293b; color: #fff; }
.topbar-inner { display: flex; align-items: center; gap: 22px; min-height: 58px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-mark { color: #f59e0b; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: #cbd5e1; text-decoration: none; padding: 7px 13px;
  border-radius: 6px; font-size: 14px; white-space: nowrap;
}
.nav a:hover { background: #334155; color: #fff; }
.nav a.on { background: var(--blue); color: #fff; }
.badge {
  display: inline-block; background: #f59e0b; color: #422006; font-size: 11px;
  font-weight: 700; padding: 1px 6px; border-radius: 9px; margin-left: 3px;
}
.logout { color: #94a3b8; text-decoration: none; font-size: 13px; }
.logout:hover { color: #fff; }

.page { padding-top: 26px; padding-bottom: 60px; }

/* ---------- Titres ---------- */
h1 { font-size: 23px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 14px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

/* ---------- Cartes ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-bottom: 20px;
}
.card-tight { padding: 16px 18px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 20px; align-items: start; }

/* ---------- Statistiques ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; }
.stat b { display: block; font-size: 25px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.stat.ok b { color: var(--green); }
.stat.ko b { color: var(--red); }
.stat.wait b { color: var(--amber); }

/* ---------- Formulaires ---------- */
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 7px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }
textarea { min-height: 130px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.field { margin-bottom: 16px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 17px; border-radius: 7px; border: 1px solid transparent;
  background: var(--blue); color: #fff; font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--blue-dark); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-sec { background: #fff; color: var(--ink); border-color: #cbd5e1; }
.btn-sec:hover { background: #f8fafc; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Messages ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; border: 1px solid; }
.flash-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.flash-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.flash ul { margin: 8px 0 0; padding-left: 20px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f8fafc; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.rep-traitee { opacity: .6; }
td.nowrap, th.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.check-col { width: 36px; text-align: center; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--blue); cursor: pointer; margin: 0; }

/* ---------- Pastilles de statut ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-sent { background: #d1fae5; color: #065f46; }
.pill-failed { background: #fee2e2; color: #991b1b; }
.pill-pending { background: #f1f5f9; color: #475569; }
.pill-rep { background: #dbeafe; color: #1e40af; }

/* ---------- Barre d'outils ---------- */
.toolbar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px;
}
.toolbar .field { margin: 0; }
.toolbar input[type=text], .toolbar select { min-width: 170px; width: auto; }

.bulkbar {
  position: sticky; bottom: 0; z-index: 5; margin-top: 16px;
  background: #1e293b; color: #fff; border-radius: var(--radius);
  padding: 12px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.bulkbar b { color: #fbbf24; }
.bulkbar .btn-sec { background: #334155; color: #fff; border-color: #475569; }
.bulkbar .btn-sec:hover { background: #475569; }

.pager { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.pager a, .pager span {
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; text-decoration: none; font-size: 13px;
}
.pager .on { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Progression d'envoi ---------- */
.progress { height: 9px; background: var(--line); border-radius: 20px; overflow: hidden; margin-bottom: 14px; }
.progress i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .25s ease; }
.log {
  max-height: 320px; overflow: auto; background: #0f172a; color: #cbd5e1;
  border-radius: 8px; padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.7;
}
.log-line { white-space: pre-wrap; word-break: break-word; }
.log-ok { color: #6ee7b7; }
.log-ko { color: #fca5a5; }
.log-info { color: #93c5fd; }

/* ---------- Aperçu e-mail ---------- */
.preview-frame { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: 8px; background: #f1f5f9; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.vars code {
  background: #f1f5f9; border: 1px solid var(--line); border-radius: 5px;
  padding: 2px 7px; font-size: 12.5px; cursor: pointer;
}
.vars code:hover { background: #e2e8f0; }

/* ---------- Connexion ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-box { width: 100%; max-width: 390px; }
.login-box .card { padding: 28px; }
.login-title { text-align: center; margin-bottom: 20px; }
.login-title .brand-mark { font-size: 30px; color: var(--blue); }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 24px 0 34px; }

/* ---------- Formulaire public client ---------- */
.pub { background: var(--bg); }
.pub-wrap { max-width: 640px; margin: 0 auto; padding: 28px 18px 60px; }
.pub-head { background: #1e293b; color: #fff; padding: 26px 0; margin-bottom: 26px; }
.pub-head .wrap { max-width: 640px; }
.pub-head h1 { font-size: 20px; margin: 0; }
.pub-head p { margin: 5px 0 0; color: #94a3b8; font-size: 14px; }
.pub-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 26px; margin-bottom: 18px; }
.pub-card h2 { font-size: 16px; margin: 0 0 6px; }
.q { margin-bottom: 26px; }
.q > .q-label { font-weight: 700; font-size: 15.5px; margin-bottom: 10px; display: block; }
.choices { display: flex; gap: 12px; flex-wrap: wrap; }
.choice {
  flex: 1 1 160px; display: flex; align-items: center; gap: 10px;
  border: 2px solid var(--line); border-radius: 9px; padding: 13px 15px;
  cursor: pointer; font-weight: 600; background: #fff;
}
.choice:hover { border-color: #93c5fd; }
.choice input { margin: 0; }
.choice.sel { border-color: var(--blue); background: #eff6ff; }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 9px; }
.month {
  display: flex; align-items: center; gap: 9px; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; cursor: pointer; background: #fff; font-size: 14px;
}
.month:hover { border-color: #93c5fd; }
.month.sel { border-color: var(--blue); background: #eff6ff; font-weight: 600; }
.pub-note { color: var(--muted); font-size: 13px; text-align: center; padding: 10px 0 0; }
.done { text-align: center; padding: 20px 0; }
.done-mark {
  width: 62px; height: 62px; border-radius: 50%; background: #d1fae5; color: #059669;
  font-size: 33px; line-height: 62px; margin: 0 auto 16px; text-align: center;
}
.recap { background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; padding: 16px 18px; text-align: left; margin-top: 20px; font-size: 14px; }
.recap div { padding: 3px 0; }

@media (max-width: 700px) {
  .topbar-inner { min-height: auto; padding: 10px 0; }
  .nav { order: 3; width: 100%; }
  th, td { padding: 9px 10px; }
}
