:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #16202c;
  --muted: #68778a;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --chip: #eef2f7;
  --shadow: 0 1px 2px rgba(16, 32, 44, .06), 0 8px 24px rgba(16, 32, 44, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1420; --card: #161d2b; --ink: #e8edf4; --muted: #9aa7b8;
    --line: #273142; --brand: #3b82f6; --chip: #1e2635;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
}
code { background: var(--chip); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.error { color: var(--bad); }

/* --- Connexion --- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; box-shadow: var(--shadow); width: 100%; max-width: 460px;
}
.login .card { max-width: 380px; }
.card h1, .card h2 { margin: 0 0 6px; }
.card label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 13px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
button {
  margin-top: 16px; padding: 10px 16px; border: 0; border-radius: 10px;
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button.ghost {
  margin: 0; background: transparent; color: var(--brand); border: 1px solid var(--line); font-weight: 600;
}
.notice { margin-top: 12px; color: var(--ok); }
.notice.bad { color: var(--bad); }

/* --- Barre du haut --- */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
.dot.up { background: var(--ok); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tab {
  margin: 0; background: transparent; color: var(--muted); border: 0; border-radius: 8px;
  padding: 8px 12px; font-weight: 600;
}
.tab.active { background: var(--chip); color: var(--ink); }
#logout { margin: 0; }

/* --- Contenu --- */
.content { max-width: 980px; margin: 0 auto; padding: 18px 16px 40px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.panel-head h2 { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.stat .num { font-size: 32px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.msg { white-space: normal; max-width: 320px; }
tr:last-child td { border-bottom: 0; }
.empty { padding: 22px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--chip); color: var(--muted); }
.badge.sent { background: rgba(37,99,235,.14); color: var(--brand); }
.badge.delivered { background: rgba(22,163,74,.15); color: var(--ok); }
.badge.pending, .badge.dispatched { background: rgba(217,119,6,.15); color: var(--warn); }
.badge.failed { background: rgba(220,38,38,.15); color: var(--bad); }

/* --- Accueil (choix client / admin) --- */
a { color: var(--brand); }
body.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.landing { text-align: center; max-width: 720px; width: 100%; }
.landing h1 { margin: 0 0 4px; font-size: 28px; }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 22px; }
.choice-card {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left;
  padding: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
}
.choice-card:hover { border-color: var(--brand); }
.choice-card .ico { font-size: 28px; }
.choice-card strong { font-size: 18px; }

/* Ajout de telephone (espace client) : fiche + QR + boutons Copier */
.steps { margin: 0 0 1rem 1.2rem; padding: 0; color: var(--muted, #667085); }
.steps li { margin: .25rem 0; }
.pair { display: flex; flex-wrap: wrap; gap: 1rem; margin: .5rem 0 1rem; }
.pair-field { flex: 1 1 220px; }
.pair-field .lbl { display: block; font-size: .8rem; color: var(--muted, #667085); margin-bottom: .25rem; }
.copyrow { display: flex; align-items: center; gap: .5rem; }
.copyrow code { font-size: 1rem; word-break: break-all; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin: 1rem 0; }
.qr-wrap #qr { background: #fff; padding: 10px; border-radius: 8px; line-height: 0; }
