:root {
  --accent: #1f6f4a;
  --accent-dark: #16543a;
  --accent-light: #e7f3ec;
  --ink: #16191b;
  --muted: #8a8f93;
  --border: #efefef;
  --bg: #fafafa;
  --card: #ffffff;
  --red: #ed4956;
  --amber: #b8860b;
  --blue: #0095f6;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

/* --- Mode embarqué (intégration dans un autre ERP) --- */
.embed-topbar { display: none; }
html.embed-mode .embed-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--accent-dark);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
html.embed-mode .embed-topbar a { color: #dff0e6; font-weight: 600; }
html.embed-mode .embed-topbar a:hover { color: #fff; }
html.embed-mode .sidebar { display: none; }
html.embed-mode .main { max-width: 100%; padding: 20px 28px; }

.sidebar {
  width: 232px;
  background: #fff;
  border-right: 1px solid var(--border);
  color: var(--ink);
  padding: 24px 14px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  letter-spacing: -0.02em;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  padding: 11px 12px;
  border-radius: 12px;
  margin-bottom: 2px;
  font-size: 0.93rem;
  font-weight: 500;
}

.sidebar nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-light); color: var(--accent-dark); font-weight: 700; }

.sidebar .badge-count {
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 1px 7px;
  margin-left: auto;
}

.sidebar .nav-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin: 18px 10px 6px;
}

.main { flex: 1; padding: 28px 40px 60px; max-width: 1240px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar h1 { font-size: 1.5rem; margin: 0; font-weight: 800; letter-spacing: -0.02em; }
.topbar .subtitle { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card.tight { padding: 14px 16px; }
.card.clickable { cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.card.clickable:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.06), 0 12px 28px rgba(0,0,0,0.07); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 1000px) {
  .grid-3, .grid-4, .grid-5, .grid-2 { grid-template-columns: 1fr; }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--red); }
.btn.ghost { background: transparent; color: var(--muted); padding: 6px 10px; }
.btn.ghost:hover { background: var(--bg); text-decoration: none; }
.btn.small { padding: 5px 12px; font-size: 0.78rem; }
.btn:disabled { background: #d7d7d7; cursor: not-allowed; }

input[type=text], input[type=email], input[type=password], input[type=datetime-local],
input[type=number], input[type=date], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  font-size: 0.92rem;
  font-family: inherit;
  margin-top: 4px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }

label { font-size: 0.82rem; font-weight: 700; color: var(--muted); display: block; margin-top: 14px; }

.stat-tile { text-align: center; }
.stat-tile .value { font-size: 1.7rem; font-weight: 800; color: var(--ink); }
.stat-tile .label { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

.pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.pill.connected { background: var(--accent-light); color: var(--accent-dark); }
.pill.disconnected { background: #fdf3e3; color: var(--amber); }
.pill.simulated { background: #eef1fd; color: #4a55c9; }
.pill.published { background: var(--accent-light); color: var(--accent-dark); }
.pill.failed { background: #fde8ea; color: var(--red); }
.pill.pending, .pill.scheduled { background: #fdf3e3; color: var(--amber); }
.pill.draft { background: #f1f1f1; color: #666; }
.pill.active { background: var(--accent-light); color: var(--accent-dark); }
.pill.paused { background: #fdf3e3; color: var(--amber); }
.pill.completed { background: #f1f1f1; color: #666; }

.platform-checks { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.platform-check {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
}
.platform-check input { margin: 0; }
.platform-check.checked { border-color: var(--accent); background: var(--accent-light); }
.platform-check.disabled-opt { opacity: 0.45; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }

.notif-item { display: flex; gap: 12px; padding: 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); margin-bottom: 8px; }
.notif-item.unread { background: var(--accent-light); border-color: transparent; }
.notif-item .meta { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.notif-item .body { flex: 1; min-width: 0; }

.empty-state { color: var(--muted); text-align: center; padding: 34px 12px; font-size: 0.9rem; }

.flash { padding: 11px 15px; border-radius: 12px; margin-bottom: 16px; font-size: 0.88rem; font-weight: 600; }
.flash.error { background: #fde8ea; color: var(--red); }
.flash.success { background: var(--accent-light); color: var(--accent-dark); }

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.auth-card { width: 360px; }

.helptext { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

/* --- Badges plateforme (icône ronde couleur de marque) --- */
.platform-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  flex-shrink: 0;
}
.platform-badge.lg { width: 32px; height: 32px; font-size: 0.9rem; }
.platform-label-row { display: flex; align-items: center; gap: 8px; }

/* --- Avatars --- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 0.75rem; }

/* --- Tabs --- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 9px 14px; font-size: 0.85rem; font-weight: 700; color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

/* --- Switch (feed / story) --- */
.segmented { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 3px; border: 1px solid var(--border); }
.segmented button {
  border: none; background: transparent; padding: 7px 16px; border-radius: 999px;
  font-size: 0.83rem; font-weight: 700; color: var(--muted); cursor: pointer;
}
.segmented button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* --- Score d'optimisation --- */
.score-wrap { display: flex; align-items: center; gap: 14px; }
.score-circle {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem; color: #fff;
  background: conic-gradient(var(--accent) calc(var(--score, 0) * 1%), #eee 0);
}
.score-circle span { background: #fff; color: var(--ink); width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.score-tips { list-style: none; margin: 8px 0 0; padding: 0; }
.score-tips li { font-size: 0.83rem; padding: 5px 0; display: flex; gap: 8px; }
.score-tips li.ok { color: var(--accent-dark); }
.score-tips li.warn { color: var(--amber); }

/* --- Messagerie --- */
.inbox-layout { display: grid; grid-template-columns: 320px 1fr; gap: 0; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: #fff; box-shadow: var(--shadow); min-height: 560px; }
.conv-list { border-right: 1px solid var(--border); overflow-y: auto; max-height: 640px; }
.conv-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: flex-start; }
.conv-item:hover { background: var(--bg); }
.conv-item.active { background: var(--accent-light); }
.conv-item .name { font-weight: 700; font-size: 0.88rem; display: flex; align-items: center; gap: 6px; }
.conv-item .preview { font-size: 0.8rem; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .time { font-size: 0.7rem; color: var(--muted); margin-left: auto; flex-shrink: 0; }
.conv-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex-shrink: 0; margin-top: 5px; }

.thread { display: flex; flex-direction: column; height: 100%; }
.thread-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.thread-messages { flex: 1; padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; max-height: 480px; }
.msg-bubble { max-width: 65%; padding: 9px 13px; border-radius: 16px; font-size: 0.87rem; line-height: 1.4; }
.msg-bubble.in { background: var(--bg); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-bubble.out { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.thread-reply { padding: 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.thread-reply textarea { margin-top: 0; resize: none; }

/* --- Publicités --- */
.campaign-card { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 10px; }
.campaign-card .info { flex: 1; min-width: 0; }
.campaign-card .metrics { display: flex; gap: 22px; }
.campaign-card .metric { text-align: right; }
.campaign-card .metric .v { font-weight: 800; font-size: 1rem; }
.campaign-card .metric .l { font-size: 0.7rem; color: var(--muted); }

/* --- Grille de publications type Instagram --- */
.post-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.post-grid .cell {
  aspect-ratio: 1; background: var(--bg); border-radius: 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.post-grid .cell img, .post-grid .cell video { width: 100%; height: 100%; object-fit: cover; }
.post-grid .cell .type-badge { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,0.55); color: #fff; font-size: 0.65rem; padding: 2px 6px; border-radius: 999px; }
@media (max-width: 700px) { .post-grid { grid-template-columns: repeat(3, 1fr); } }

/* --- Boost / mise en avant --- */
.boost-box { background: linear-gradient(120deg, var(--accent-light), #eef1fd); border-radius: 14px; padding: 14px 16px; margin-top: 10px; }
.boost-box .title { font-weight: 800; font-size: 0.88rem; margin-bottom: 6px; }
.boost-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* --- Chips (hashtags / mentions) --- */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 0.78rem; }

/* --- Aperçus mockup par plateforme --- */
.mock-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; font-size: 0.78rem; margin-bottom: 14px; }
.mock-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.mock-head .name { font-weight: 700; font-size: 0.8rem; }
.mock-head .sub { font-size: 0.68rem; color: var(--muted); }
.mock-media { width: 100%; background: #eee; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.mock-media img, .mock-media video { width: 100%; height: 100%; object-fit: cover; }
.mock-body { padding: 8px 10px; }
.mock-icons { display: flex; gap: 14px; padding: 6px 10px 10px; color: var(--muted); font-size: 0.85rem; }

.mock-ig .mock-media { aspect-ratio: 1; }
.mock-fb .mock-media, .mock-li .mock-media { aspect-ratio: 1.91 / 1; }
.mock-tt .mock-media { aspect-ratio: 9 / 16; background: #000; max-width: 160px; margin: 0 auto; position: relative; }
.mock-tt .mock-body { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(0,0,0,0.75)); color: #fff; padding: 20px 10px 10px; }
.mock-tt { background: #000; }
.mock-yt .mock-media { aspect-ratio: 16 / 9; }
.mock-yt .mock-body { font-weight: 700; }
