:root {
  --bg: #0d1017;
  --panel: #151a24;
  --panel2: #1b2130;
  --border: #262e40;
  --text: #e8ecf4;
  --muted: #8b94a8;
  --accent: #4f7cff;
  --accent2: #7c5cff;
  --green: #2ecc8f;
  --orange: #f5a623;
  --red: #ff5d6c;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--panel); border-right: 1px solid var(--border);
  padding: 20px 12px; position: fixed; top: 0; bottom: 0; display: flex; flex-direction: column;
}
.logo { font-size: 19px; font-weight: 800; padding: 4px 12px 20px; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--muted); cursor: pointer; font-weight: 500; margin-bottom: 2px; user-select: none;
}
.nav-item:hover { background: var(--panel2); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; }
.sidebar .foot { margin-top: auto; padding: 12px; color: var(--muted); font-size: 12px; }

.main { margin-left: 220px; flex: 1; padding: 28px 32px; max-width: 1300px; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 24px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
}
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card.green .value { color: var(--green); }
.card.orange .value { color: var(--orange); }
.card.red .value { color: var(--red); }
.card.blue .value { color: var(--accent); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; padding: 8px 10px; border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel2); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; border: none;
  padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: var(--panel2); border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--red); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn:disabled { opacity: 0.5; cursor: default; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.running, .badge.valid, .badge.ok, .badge.active, .badge.sent { background: rgba(46,204,143,0.15); color: var(--green); }
.badge.paused, .badge.risky, .badge.unknown { background: rgba(245,166,35,0.15); color: var(--orange); }
.badge.draft { background: rgba(139,148,168,0.15); color: var(--muted); }
.badge.done, .badge.completed { background: rgba(79,124,255,0.15); color: var(--accent); }
.badge.invalid, .badge.error, .badge.failed, .badge.bounced { background: rgba(255,93,108,0.15); color: var(--red); }
.badge.replied { background: rgba(124,92,255,0.18); color: #a48dff; }
.badge.unsubscribed, .badge.stopped { background: rgba(139,148,168,0.15); color: var(--muted); }

input, select, textarea {
  width: 100%; background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 130px; resize: vertical; font-family: 'SF Mono', Menlo, monospace; font-size: 12.5px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
.row { display: flex; gap: 14px; }
.row > * { flex: 1; }
.checkline { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.checkline input { width: auto; }
.checkline span { font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: flex-start;
  justify-content: center; z-index: 100; padding: 40px 20px; overflow-y: auto;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px;
  width: 100%; max-width: 640px;
}
.modal.wide { max-width: 900px; }
.modal h2 { font-size: 17px; margin-bottom: 6px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* Séquence / éditeur d'étapes */
.step-box { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.step-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.step-head b { font-size: 14px; }
.variant-box { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-top: 10px; }
.variant-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.chip { background: var(--accent2); color: #fff; padding: 1px 8px; border-radius: 5px; font-size: 11px; font-weight: 700; }
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attach-list .att { background: var(--panel2); border: 1px solid var(--border); padding: 3px 9px; border-radius: 6px; font-size: 12px; display: flex; gap: 6px; align-items: center; }
.attach-list .att b { cursor: pointer; color: var(--red); }

/* Graph */
.chart-wrap { overflow-x: auto; }
.legend { display: flex; gap: 18px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

.progress { height: 8px; background: var(--panel2); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.3s; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--panel2); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 10px; z-index: 200; font-weight: 500; box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.toast.error { border-color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.mono { font-family: 'SF Mono', Menlo, monospace; font-size: 12px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv span:first-child { color: var(--muted); }
.copy-key { background: var(--panel2); border: 1px solid var(--border); padding: 10px 12px; border-radius: 8px; font-family: monospace; font-size: 12px; word-break: break-all; cursor: pointer; }
.tabs2 { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs2 .t { padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.tabs2 .t.active { background: var(--panel2); color: var(--text); }

/* Boîte de réception unifiée */
.inbox-layout { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
.inbox-list { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; max-height: 78vh; overflow-y: auto; }
.inbox-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.inbox-item:hover { background: var(--panel2); }
.inbox-item.active { background: var(--panel2); border-left: 3px solid var(--accent); }
.inbox-item.unread .ii-from { font-weight: 700; }
.inbox-item.unread .ii-subject { color: var(--text); font-weight: 600; }
.ii-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ii-from { font-size: 13.5px; }
.ii-date { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ii-subject { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ii-snippet { font-size: 12px; color: var(--muted); margin-top: 3px; opacity: 0.8;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ii-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.ii-mailbox { font-size: 10.5px; background: var(--panel2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; color: var(--muted); }
.inbox-detail { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-height: 300px; }
.msg-body { background: #fff; color: #111; border-radius: 8px; padding: 16px; margin-top: 14px; max-height: 45vh; overflow-y: auto; }
.msg-body a { color: #1a56db; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; }

/* Aperçu d'un email de séquence */
.preview-head { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 12px; }
.preview-head .kv span:last-child { text-align: right; max-width: 70%; word-break: break-word; }
.modal .actions { flex-wrap: wrap; }
#inboxBadge:not(:empty) { background: var(--red); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; margin-left: 4px; }
