:root {
  --bg: #f4f6fb; --panel: #fff; --text: #1d2433; --muted: #6b7489; --line: #e3e7ef;
  --primary: #2f5aa8; --primary-dark: #234685; --ok: #1f8a4c; --warn: #b7791f; --danger: #c0392b;
  --side: #1b2540;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: flex; min-height: 100vh; }
.side { width: 220px; background: var(--side); color: #c9d2e8; padding: 18px 0; flex-shrink: 0; }
.side .brand { color: #fff; font-size: 20px; font-weight: 700; padding: 0 20px 18px; letter-spacing: .3px; }
.side .brand span { color: #7fa6ff; }
.side nav a { display: block; color: #c9d2e8; padding: 9px 20px; border-left: 3px solid transparent; }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side nav a.active { background: rgba(127,166,255,.15); color: #fff; border-left-color: #7fa6ff; }
.side .worker-status { margin: 0 14px 14px; padding: 7px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; }
.side .worker-status.on { background: rgba(34,163,90,.18); color: #8be0ad; }
.side .worker-status.off { background: rgba(210,74,60,.22); color: #ffb3aa; }
.side .bottom button.side-backup { border: 1px solid rgba(255,255,255,.25); border-radius: 7px; padding: 5px 10px; color: #fff; font-weight: 600; }
.side .bottom button.side-backup:hover { background: rgba(255,255,255,.08); }
.side .badge { background: #e05555; color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; margin-left: 6px; }
.side .bottom { padding: 18px 20px; font-size: 12px; color: #8b95b0; }
.side .bottom button { background: none; border: 0; color: #c9d2e8; cursor: pointer; padding: 0; font: inherit; }
main { flex: 1; padding: 26px 32px; max-width: 1300px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar h1 { margin: 0; margin-right: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
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); text-transform: uppercase; letter-spacing: .3px; font-weight: 600; background: #fafbfd; }
tr:hover td { background: #fafbff; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.btn { display: inline-block; background: var(--primary); color: #fff; border: 1px solid var(--primary); padding: 7px 14px;
       border-radius: 7px; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.light { background: #fff; color: var(--primary); }
.btn.light:hover { background: #eef3ff; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.warn { background: var(--warn); border-color: var(--warn); }
.btn.danger { background: #fff; color: var(--danger); border-color: #e7b7b1; }
.btn.danger:hover { background: #fdf0ee; }
.btn.small { padding: 3px 9px; font-size: 12px; }
form.inline { display: inline; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label.check { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd5e2; border-radius: 7px; font: inherit; background: #fff; }
textarea { min-height: 120px; font-family: Consolas, "Courier New", monospace; font-size: 13px; }
textarea.body { min-height: 300px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9cdf7; border-color: var(--primary); }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.help { color: var(--muted); font-size: 12px; margin-top: 3px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; border: 1px solid; }
.flash.success { background: #eaf7ef; border-color: #b7e2c7; color: #17663a; }
.flash.error { background: #fdeeee; border-color: #f0c2c2; color: #962d2d; }
.flash.info { background: #eef4ff; border-color: #c7d7f6; color: #284a8c; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; background: #eef1f6; color: #4b5568; white-space: nowrap; }
.pill.sent, .pill.valid, .pill.running, .pill.active, .pill.reply { background: #e5f0ff; color: #2456b3; }
.pill.replied, .pill.completed, .pill.done { background: #e3f6ea; color: #1b7a43; }
.pill.failed, .pill.invalid, .pill.bounced, .pill.bounce, .pill.stopped { background: #fde8e6; color: #b03a2e; }
.pill.optout, .pill.paused { background: #fff3dc; color: #95600c; }
.pill.new, .pill.draft { background: #eef1f6; color: #5b6578; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.status-dot.on { background: #22a35a; } .status-dot.off { background: #d24a3c; }
.preview { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.preview .head { padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfd; font-size: 13px; }
.preview .content { padding: 14px; }
pre.plain { white-space: pre-wrap; font: 13px/1.5 Consolas, monospace; background: #fafbfd; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 0; }
.vars code { background: #eef1f6; padding: 1px 6px; border-radius: 4px; margin-right: 4px; display: inline-block; margin-bottom: 4px; }
.checklist { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.bar { height: 7px; background: #e8ecf4; border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > div { height: 100%; background: var(--primary); }
.auth { max-width: 380px; margin: 9vh auto; }
.auth .brand { text-align: center; font-size: 28px; font-weight: 700; margin-bottom: 18px; color: var(--side); }
.auth .brand span { color: var(--primary); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs a { padding: 6px 12px; border-radius: 7px; background: #e9edf5; color: var(--text); }
.tabs a.active { background: var(--primary); color: #fff; }
.problems { border-left: 4px solid var(--warn); background: #fff8ea; }
.unread td { font-weight: 600; }
.card.spam { border-left: 4px solid var(--warn); }
.card.spam.clean { border-left-color: var(--ok); }
.issues { margin: 0 0 8px; padding-left: 4px; list-style: none; }
.issues li { padding: 4px 0; }
.issues li.error { color: #b03a2e; font-weight: 600; }
.issues li.warn { color: #95600c; }
.issues li.info { color: var(--muted); }
.ok-line { color: var(--ok); font-weight: 600; }
details summary { cursor: pointer; color: var(--primary); }
@media (max-width: 800px) { .layout { flex-direction: column; } .side { width: 100%; } main { padding: 16px; } }

/* Langue */
.lang-switch { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.lang-switch a { padding: 3px 9px; border-radius: 6px; border: 1px solid rgba(127,166,255,.35); color: #c9d2e8; font-size: 12px; text-decoration: none; }
.lang-switch a.active { background: #7fa6ff; color: #0f1b33; border-color: #7fa6ff; }
.auth .lang-switch { justify-content: center; }
.auth .lang-switch a { color: #2f5aa8; }
.auth .lang-switch a.active { color: #fff; background: #2f5aa8; border-color: #2f5aa8; }
/* Arabe : de droite à gauche */
[dir=rtl] body { font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif; }
[dir=rtl] .side nav a { border-left: 0; border-right: 3px solid transparent; }
[dir=rtl] .side nav a.active { border-right-color: #7fa6ff; }
[dir=rtl] .side .badge { margin-left: 0; margin-right: 6px; }
[dir=rtl] .toolbar h1 { margin-right: 0; margin-left: auto; }
[dir=rtl] th, [dir=rtl] td { text-align: right; }
[dir=rtl] .num { text-align: left; }
[dir=rtl] .status-dot { margin-right: 0; margin-left: 6px; }
[dir=rtl] .vars code { margin-right: 0; margin-left: 4px; }
[dir=rtl] .problems, [dir=rtl] .card.spam { border-left: 0; border-right: 4px solid var(--warn); }
[dir=rtl] .card.spam.clean { border-right-color: var(--ok); }
[dir=rtl] .issues { padding-left: 0; padding-right: 4px; }
[dir=rtl] textarea, [dir=rtl] code, [dir=rtl] pre, [dir=rtl] input[type=email], [dir=rtl] input[type=url] { direction: ltr; text-align: left; }
[dir=rtl] td, [dir=rtl] td div, [dir=rtl] .card p, [dir=rtl] .flash { unicode-bidi: plaintext; }
