:root {
  --black: #0c0c0c;
  --black2: #181818;
  --black3: #242424;
  --ink: #111111;
  --muted: #71717a;
  --line: #eaeaea;
  --bg: #f8f8f8;
  --white: #ffffff;
  --yellow: #ffcc00;
  --yellow-soft: #fff8db;
  --red: #e30613;
  --red-soft: #fef2f2;
  --green: #16a34a;
  --green-soft: #ecfdf3;
  --fr: "Avenir Next", Avenir, "Nunito Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--fr); background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
.ar, :lang(ar) { font-family: "Almarai", var(--fr) !important; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
.hidden { display: none !important; }
svg { display: block; flex: none; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-card h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 800; font-style: italic; font-size: 16px; }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.brand-dot { color: var(--yellow); }
.brand-sub { font-size: 10px; font-weight: 700; letter-spacing: .14em; color: var(--red); margin-top: 2px; }

/* ---------- Shell & Black Sidebar ---------- */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 244px; flex: none; background: var(--black); color: #fff; padding: 20px 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.sb-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.sb-brand .brand-sub { color: #a1a1aa; }
.sb-section { font-size: 10px; font-weight: 700; letter-spacing: .14em; color: #63636b; padding: 10px 10px 4px; }
.sb-divider { height: 1px; background: #1e1e1e; margin: 10px 6px; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px;
  color: #b4b4bc; cursor: pointer; font-weight: 600; font-size: 13.5px; transition: background .12s, color .12s;
  text-decoration: none; user-select: none;
}
.sidebar nav a:hover { background: var(--black2); color: #fff; }
.sidebar nav a.active { background: var(--yellow); color: var(--black); }
.sidebar nav a.chan-active { background: var(--black3); color: #fff; }
.sb-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; min-width: 22px; text-align: center; }
.sidebar nav a.active .sb-badge { background: var(--black); color: var(--yellow); }
.ai-dot { width: 7px; height: 7px; border-radius: 50%; margin-left: auto; background: #52525b; }
.ai-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }

.ch { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; font-size: 9.5px; font-weight: 800; color: #fff; flex: none; }
.ch.ig { background: linear-gradient(45deg, #f59e0b, #ec4899, #8b5cf6); }
.ch.fb { background: #1877f2; }

.sb-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid #1e1e1e; }
.sb-user { flex: 1; min-width: 0; }
.sb-user b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user small { display: block; font-size: 11.5px; color: #71717a; }

/* ---------- Topbar & Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 54px; flex: none; background: var(--white); border-bottom: 1px solid var(--line);
  padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.top-left, .top-right { display: flex; align-items: center; gap: 10px; }
.top-left b { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.live-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700;
  color: var(--green); background: var(--green-soft); padding: 3px 9px; border-radius: 999px;
}
.live-pill.off { color: var(--muted); background: #f1f1f2; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
.live-pill.off .live-dot { background: #a1a1aa; animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

main { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 24px; }
main.inbox-mode { padding: 16px 20px; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- Components ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.025em; }
.page-head h1 span { color: var(--red); }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-start { display: flex; align-items: center; gap: 8px; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 14px; }
.card h3 { margin: 0 0 3px; font-size: 15.5px; font-weight: 800; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 9px; padding: 8px 14px;
  font-weight: 700; font-size: 13px; cursor: pointer; background: var(--black); color: #fff;
  text-decoration: none; transition: opacity .12s, background .12s;
}
.btn:hover { opacity: .9; }
.btn.primary { background: var(--red); color: #fff; }
.btn.yellow { background: var(--yellow); color: var(--black); }
.btn.outline { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn.outline:hover { background: var(--bg); opacity: 1; }
.btn.ghost { background: transparent; color: var(--muted); padding: 6px 10px; }
.btn.ghost:hover { background: var(--bg); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--white);
  color: var(--ink); display: grid; place-items: center; cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn.dark { background: transparent; border-color: transparent; color: #8c8c96; }
.icon-btn.dark:hover { background: var(--black2); color: #fff; }
.icon-btn.active { border-color: var(--yellow); background: var(--yellow-soft); }

.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; background: #f1f1f2; color: var(--muted); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.yellow { background: var(--yellow-soft); color: #8a6d00; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; position: relative; background: #f1f1f2; color: var(--ink); }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; background: var(--yellow); color: var(--black); }
.av-badge { position: absolute; right: -2px; bottom: -2px; width: 15px; height: 15px; border-radius: 4px; font-size: 7.5px; border: 2px solid #fff; }

.alert { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; border: 1px solid transparent; }
.alert.err { background: var(--red-soft); color: #b91c1c; border-color: #fecaca; }
.alert.ok { background: var(--green-soft); color: #15803d; border-color: #bbf7d0; }
.alert.warn { background: var(--yellow-soft); color: #854d0e; border-color: #fde68a; }

label { display: block; font-size: 12.5px; font-weight: 700; margin: 12px 0 5px; color: #27272a; }
.input, textarea.input, select.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--white); color: var(--ink); outline: none; transition: border-color .12s;
}
.input:focus { border-color: var(--black); }
textarea.input { resize: vertical; min-height: 76px; line-height: 1.45; }
.copy { display: flex; gap: 8px; }
.copy .input { background: var(--bg); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* Switch toggle */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.slider { width: 40px; height: 22px; border-radius: 999px; background: #d4d4d8; transition: .18s; position: relative; flex: none; }
.slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .18s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch.lg .slider { width: 48px; height: 26px; }
.switch.lg .slider::after { width: 20px; height: 20px; }
.switch.lg input:checked + .slider::after { transform: translateX(22px); }

/* ---------- Minimalist KPI strip ---------- */
.kpi-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; flex: none; }
.kpi-mini {
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between;
}
.kpi-mini.hl { background: var(--yellow); border-color: var(--yellow); }
.kpi-mini .l { font-size: 12px; font-weight: 700; color: var(--muted); }
.kpi-mini.hl .l { color: var(--black); }
.kpi-mini .n { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }

/* ---------- Inbox (full height, minimalist) ---------- */
.inbox {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 330px 1fr;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
.list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.search { width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); outline: none; font-size: 13px; }
.search:focus { border-color: var(--black); background: var(--white); }
.tabs { display: flex; background: var(--bg); border-radius: 9px; padding: 3px; gap: 2px; }
.tabs button { flex: 1; border: 0; background: none; padding: 5px 6px; border-radius: 7px; font-weight: 700; font-size: 12px; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--white); color: var(--ink); border: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--yellow-soft); border: 1px solid var(--yellow); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; cursor: pointer; }

.items { overflow-y: auto; flex: 1; }
.item { display: flex; gap: 10px; padding: 11px 13px; border-bottom: 1px solid #f4f4f5; cursor: pointer; border-left: 2.5px solid transparent; transition: background .1s; }
.item:hover { background: #fafafa; }
.item.sel { background: var(--yellow-soft); border-left-color: var(--black); }
.item .body { flex: 1; min-width: 0; }
.item .name { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .prev { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.item .meta-row { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; font-size: 11px; color: #8c8c96; }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); display: inline-block; }

.thread { display: flex; flex-direction: column; min-height: 0; background: var(--white); }
.thread-head { padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 11px; }
.thread-head small { color: var(--muted); display: block; font-size: 12px; }
.ctx { background: var(--bg); padding: 7px 18px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.msgs { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.sep { text-align: center; font-size: 11px; color: #a1a1aa; margin: 4px 0; }
.msg { max-width: 72%; }
.msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }
.msg .bubble { padding: 9px 13px; border-radius: 13px; background: #f4f4f5; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg.agent { align-self: flex-end; }
.msg.agent .meta { justify-content: flex-end; }
.msg.agent .bubble { background: var(--yellow-soft); }
.msg.ai .bubble { background: #18181b; color: #fff; }

.composer { margin: 0 16px 14px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--white); }
.composer:focus-within { border-color: var(--black); }
.composer .lbl { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; }
.composer textarea { width: 100%; border: 0; outline: 0; resize: none; min-height: 52px; max-height: 140px; line-height: 1.4; }
.emojis { display: flex; gap: 2px; }
.emojis button { border: 0; background: none; font-size: 15px; cursor: pointer; padding: 3px 5px; border-radius: 6px; }
.emojis button:hover { background: var(--bg); }
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 24px; font-size: 13px; }

/* ---------- Tables, Perm grid, AI topics ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; padding: 9px 10px; border-bottom: 1px solid var(--line); }
td { padding: 11px 10px; border-bottom: 1px solid #f4f4f5; vertical-align: middle; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.perm-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 12.5px; font-weight: 600; }

.topic-card { border: 1px solid var(--line); border-radius: 11px; padding: 13px; margin-bottom: 10px; background: #fcfcfc; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--red-soft); color: #b91c1c; border: 1px solid #fecaca; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.tag button { border: 0; background: none; color: inherit; cursor: pointer; font-weight: 800; padding: 0; }

.acc { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.acc-line { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 13px; }
code { background: var(--bg); padding: 2px 6px; border-radius: 5px; font-size: 12px; }
details summary { cursor: pointer; font-weight: 700; font-size: 13px; }
.statbar { height: 8px; border-radius: 999px; background: rgba(0,0,0,.1); overflow: hidden; display: flex; margin-top: 8px; }

/* Popovers, Modal, Toast */
.popover {
  position: absolute; right: 0; top: 40px; background: var(--white); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.09); z-index: 20; width: 255px;
  display: flex; flex-direction: column; gap: 8px;
}
.modal-bg { position: fixed; inset: 0; background: rgba(12,12,12,.45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--white); border-radius: 16px; padding: 22px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--black); color: #fff; padding: 10px 15px; border-radius: 10px; font-size: 13px; font-weight: 600; z-index: 50; }

/* ---------- Analytics Dashboard & Mobile Responsive ---------- */
.mob-only { display: none !important; }
.sb-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 29; }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bar-row { margin-bottom: 12px; }
.bar-track { height: 7px; border-radius: 999px; background: #f1f1f2; overflow: hidden; margin-top: 5px; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--black); }
.bar-fill.red { background: var(--red); }
.bar-fill.yellow { background: var(--yellow); }
.rank-num { width: 22px; height: 22px; border-radius: 6px; background: var(--bg); font-size: 11.5px; font-weight: 800; display: inline-grid; place-items: center; flex: none; }
.rank-num.top { background: var(--yellow); color: var(--black); }
.post-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f4f4f5; }
.post-row:last-child { border-bottom: 0; }
.sec-banner { background: var(--yellow-soft); border: 1px solid var(--yellow); border-radius: 10px; padding: 8px 14px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; flex: none; }

@media (max-width: 960px) {
  .mob-only { display: inline-grid !important; }
  .shell { height: 100dvh; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .topbar { padding: 0 14px; }
  main { padding: 16px 14px; }
  main.inbox-mode { padding: 10px; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .grid2, .grid3, .perm-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
}

@media (max-width: 820px) {
  .inbox { grid-template-columns: 1fr; }
  .inbox .thread { display: none; }
  .inbox.show-thread .list { display: none; }
  .inbox.show-thread .thread { display: flex; }
  .thread-head { padding: 10px 12px; gap: 8px; }
  .msgs { padding: 12px; }
  .msg { max-width: 86%; }
  .composer { margin: 0 10px 10px; }
  .live-pill { display: none; }
}

/* ---------- Infographics, SVG Charts, Media Links & Extra Minimalist Polish ---------- */
.media-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.media-link {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 700;
  background: var(--white); color: var(--ink); border: 1px solid var(--line);
  text-decoration: none; transition: border-color .12s, background .12s;
}
.media-link:hover { border-color: var(--black); background: var(--bg); }
.msg.ai .media-link { background: #27272a; color: #fff; border-color: #3f3f46; }
.inline-link { color: var(--red); text-decoration: underline; word-break: break-all; }

.donut-wrap { display: flex; align-items: center; gap: 22px; margin-top: 14px; flex-wrap: wrap; }
.donut-svg { width: 152px; height: 152px; flex: none; }
.donut-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 9px; }
.leg-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.leg-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.leg-val { margin-left: auto; font-weight: 800; }

.hours-svg { width: 100%; height: 148px; margin-top: 10px; display: block; }
.ring-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ring-svg { width: 58px; height: 58px; flex: none; }

/* ---------- Guide Agents (Base d'infos & Réponses rapides) ---------- */
.guide-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.guide-search-wrap { flex: 1; min-width: 220px; max-width: 380px; }
.guide-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-pill {
  border: 1px solid var(--line); background: var(--white); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 700;
  cursor: pointer; transition: all .12s; display: inline-flex; align-items: center; gap: 6px;
}
.cat-pill:hover { border-color: var(--black); color: var(--ink); }
.cat-pill.on { background: var(--black); border-color: var(--black); color: #fff; }
.cat-pill .cnt { font-size: 11px; opacity: .75; }

.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.guide-card {
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; display: flex; flex-direction: column; gap: 11px;
  transition: border-color .15s, box-shadow .15s;
}
.guide-card:hover { border-color: #d4d4d8; box-shadow: 0 6px 18px rgba(0,0,0,.04); }
.guide-card.pinned { border-color: var(--yellow); box-shadow: 0 0 0 1px rgba(255,204,0,.25); }
.guide-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.guide-title { margin: 6px 0 0; font-size: 15.5px; font-weight: 800; line-height: 1.25; }
.guide-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.guide-notes {
  background: var(--bg); border-left: 3px solid var(--black); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  color: #27272a;
}
.guide-reply {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: #fcfcfc;
}
.guide-reply.fr { border-left: 3px solid var(--yellow); }
.guide-reply.ar-box { border-left: 3px solid var(--red); }
.guide-reply-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 6px; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.guide-reply-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--ink); }
.guide-foot {
  margin-top: auto; padding-top: 8px; border-top: 1px solid #f4f4f5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--muted);
}
.guide-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.guide-tag { background: #f4f4f5; color: #52525b; border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 600; }

/* Popover Guide rapide dans le composer Inbox */
.composer { position: relative; }
.guide-popover {
  position: absolute; bottom: calc(100% + 8px); right: 0; width: min(440px, calc(100vw - 36px));
  max-height: 390px; background: var(--white); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.14); z-index: 25;
  display: flex; flex-direction: column; overflow: hidden;
}
.guide-pop-head { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; background: #fafafa; }
.guide-pop-list { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.guide-pop-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  background: var(--white); display: flex; flex-direction: column; gap: 6px;
}
.guide-pop-item:hover { border-color: #d4d4d8; background: #fcfcfc; }
.guide-pop-note { font-size: 12px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pop-tabs { display: flex; background: #ededef; border-radius: 8px; padding: 2px; gap: 2px; }
.pop-tabs button { flex: 1; border: 0; background: none; padding: 5px 8px; border-radius: 6px; font-weight: 700; font-size: 12px; color: var(--muted); cursor: pointer; }
.pop-tabs button.on { background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* ---------- Nos Agences & Localisations ---------- */
.agency-ai-bar {
  background: var(--white); border: 1px solid var(--line); border-left: 3.5px solid var(--green);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.agency-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.agency-card {
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.agency-card:hover { border-color: #d4d4d8; box-shadow: 0 6px 18px rgba(0,0,0,.04); }
.agency-card.inactive { opacity: .62; }
.agency-meta { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #27272a; }
.agency-line { display: flex; align-items: flex-start; gap: 8px; line-height: 1.4; }
.agency-line svg { margin-top: 2px; color: var(--muted); }
.agency-maps-row {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.agency-maps-url {
  font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 120px; text-decoration: none;
}
.agency-maps-url:hover { color: var(--red); text-decoration: underline; }
.agency-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

@media (max-width: 960px) {
  .guide-grid, .agency-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { height: 50px; padding: 0 12px; }
  .top-left b { font-size: 14px; }
  .page-head h1 { font-size: 22px; }
  .card { padding: 15px; border-radius: 12px; }
  .kpi-mini { padding: 10px 12px; }
  .kpi-mini .n { font-size: 19px; }
  .composer { margin: 0 8px calc(8px + env(safe-area-inset-bottom, 0px)); padding: 8px 10px; }
  .donut-wrap { justify-content: center; }
  .donut-legend { width: 100%; }
  .post-row { flex-wrap: wrap; gap: 6px; }
  .modal { padding: 18px; border-radius: 14px; }
}
