:root {
  /* Codes visuels de Wheels : bandeau bleu nuit, bleu d'action, rouge d'appel à l'action, champs à saisir jaune pâle */
  --navy: #00204f; --wheels-blue: #0173c7; --wheels-red: #ed1c24; --field-yellow: #ffffe1; --label: #44588b;
  --bg: #fafafa; --panel: #fff; --ink: #1f2937; --muted: #5b6b8c; --line: #dfe4ec; --line2: #c9d1de;
  --side: var(--navy); --side-ink: #dbe4f3; --accent: var(--wheels-blue); --accent-ink: #fff;
  --blue: var(--wheels-blue); --green: #15803d; --green-bg: #dcfce7; --red: #b91c1c; --red-bg: #fee2e2; --amber: #b45309; --amber-bg: #fef3c7;
  --blue-bg: #e3f0fa; --grey-bg: #f1f3f7; --radius: 4px;
  font: 14px/1.45 "Segoe UI", Roboto, system-ui, -apple-system, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.brand i { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-style: normal; font-size: 13px; }
.side a { color: var(--side-ink); padding: 8px 12px; border-radius: 6px; display: flex; justify-content: space-between; align-items: center; }
.side a:hover { background: #1f2937; text-decoration: none; }
.side a.on { background: #374151; color: #fff; }
.side .sep { margin: 12px 12px 4px; font-size: 11px; text-transform: uppercase; color: #6b7280; letter-spacing: .06em; }
.side .foot { margin-top: auto; padding: 10px 12px; font-size: 12px; color: #9ca3af; border-top: 1px solid #1f2937; }
.side .foot a { display: inline; padding: 0; color: #9ca3af; }
.side .foot a:hover { background: none; color: #fff; }
.side .foot b { color: #fff; display: block; }
.side .badge-n { background: var(--red); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; }

main { padding: 22px 28px 60px; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 16px; }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 24px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi.bad .v { color: var(--red); }

.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: var(--amber-bg); border-color: #fcd34d; color: #78350f; }
.banner.info { background: var(--blue-bg); border-color: #93c5fd; color: #1e3a8a; }
.banner.err { background: var(--red-bg); border-color: #fca5a5; color: #7f1d1d; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafafa; position: sticky; top: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafafa; }
.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.tablewrap table td:first-child, .tablewrap table th:first-child { padding-left: 14px; }
.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--grey-bg); color: #374151; white-space: nowrap; }
.pill.sent, .pill.open, .pill.ok { background: var(--green-bg); color: var(--green); }
.pill.failed, .pill.error { background: var(--red-bg); color: var(--red); }
.pill.scheduled, .pill.held, .pill.warning, .pill.returned { background: var(--amber-bg); color: var(--amber); }
.pill.queued, .pill.sending, .pill.info, .pill.wheels { background: var(--blue-bg); color: var(--blue); }

button, .btn { font: inherit; border: 1px solid var(--line2); background: #fff; color: var(--ink); padding: 7px 14px; border-radius: 6px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
button:hover, .btn:hover { background: #f9fafb; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: #015fa5; color: var(--accent-ink); font-weight: 600; }
button.primary:hover { background: #015fa5; }
button.danger { color: var(--red); border-color: #fca5a5; }
button.ghost { border-color: transparent; background: transparent; }
button.sm { padding: 3px 9px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 7px 10px; border: 1px solid var(--line2); border-radius: 6px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #fcd34d; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
input[type=checkbox] { width: auto; }
.field { margin-bottom: 12px; }
.field.miss input { border-color: var(--red); background: #fff7f7; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters > * { width: auto; min-width: 140px; }
.filters input[type=search] { min-width: 240px; }

.preview { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font-size: 14px; }
.phone { background: #e5e7eb; border-radius: 22px; padding: 16px 12px; }
.bubble { background: #fff; border-radius: 16px 16px 16px 4px; padding: 10px 12px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px #0001; }
.bubble mark { background: #fecaca; color: var(--red); border-radius: 3px; padding: 0 2px; }
.counter { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.counter b.bad { color: var(--amber); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11px; padding: 2px 7px; border-radius: 4px; background: var(--grey-bg); border: 1px solid var(--line); cursor: pointer; font-family: ui-monospace, monospace; }
.chip:hover { background: var(--amber-bg); }

.tpl-list { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.tpl-list .grp { font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 8px 10px 4px; background: #fafafa; position: sticky; top: 0; letter-spacing: .04em; }
.tpl-list button { width: 100%; justify-content: space-between; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; white-space: normal; }
.tpl-list button.on { background: var(--amber-bg); font-weight: 600; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 14px 14px; position: relative; }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--line2); position: absolute; left: -6px; top: 4px; }
.timeline li.sent::before { background: var(--green); }
.timeline li.failed::before { background: var(--red); }
.timeline li.scheduled::before, .timeline li.planned::before { background: var(--accent); }
.timeline .txt { white-space: pre-wrap; font-size: 13px; background: #f8fafc; border-radius: 6px; padding: 8px; margin-top: 4px; }

.notif { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.notif:last-child { border-bottom: 0; }
.notif .b { flex: 1; }

dialog { border: 0; border-radius: 10px; padding: 0; width: min(760px, 94vw); box-shadow: 0 20px 50px #0004; }
dialog::backdrop { background: #1118277a; }
#modal-body { padding: 20px; max-height: 86vh; overflow: auto; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 420px; box-shadow: 0 6px 20px #0003; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

.login { min-height: 100vh; display: grid; place-items: center; background: var(--side); }
.login .card { width: 360px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
pre { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; }
.tabs button.on { border-bottom-color: var(--accent); font-weight: 600; }

@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .sep, .side .foot { display: none; }
  main { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
.grid2 > .card, .grid3 > .card { margin-top: 0; }

.testbar { background: repeating-linear-gradient(45deg, #f5b301, #f5b301 12px, #111827 12px, #111827 24px); color: #fff; text-align: center; font-weight: 700; padding: 4px; text-shadow: 0 0 3px #000, 0 0 3px #000; font-size: 12px; letter-spacing: .03em; }

/* ---- Habillage Wheels ---- */
.side { box-shadow: inset -1px 0 0 #0a2d63; }
.side a:hover { background: #0a2d63; }
.side a.on { background: var(--wheels-blue); color: #fff; }
.side .foot { border-top-color: #0a2d63; }
.brand i { background: var(--wheels-red); color: #fff; }
.side .badge-n { background: var(--wheels-red); }
h1 { color: var(--navy); }
h2, label { color: var(--label); }
.tabs button.on { border-bottom-color: var(--wheels-blue); color: var(--wheels-blue); }
input[required], textarea[required], .field.required input { background: var(--field-yellow); }
th { background: #eef2f8; color: var(--label); }
