:root {
  --bg: #f5f6fa; --panel: #fff; --ink: #14161f; --muted: #6b7083; --line: #e6e8ef;
  --brand: #2f5bff; --brand-soft: #e9eeff; --live: #ff2d55;
  --ok: #12a150; --ok-soft: #e4f6ec; --warn: #c98a00; --warn-soft: #fff5d6;
  --bad: #d92d3a; --bad-soft: #fde8ea; --violet: #7a4cff; --violet-soft: #efe9ff; --blue-soft: #e6f0ff;
  --radius: 14px; --shadow: 0 1px 2px rgba(20,22,31,.05), 0 4px 16px rgba(20,22,31,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 Inter, Cairo, system-ui, sans-serif; }
[dir=rtl] body, body[dir=rtl] { font-family: Cairo, Inter, system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }

.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-inline-end: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 4px 10px 18px; }
.logo i { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #7a4cff); display: grid; place-items: center; color: #fff; font-style: normal; font-size: 15px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.main { padding: 28px 32px 60px; min-width: 0; }

h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 0 0 22px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px; font-weight: 600; background: var(--panel); border: 1px solid var(--line); }
.btn:hover { border-color: #cfd3df; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi .v { font-size: 26px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .d { font-size: 12px; margin-top: 2px; }
.up { color: var(--ok); } .down { color: var(--bad); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-weight: 500; color: var(--muted); font-size: 13px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { opacity: .7; margin-inline-start: 4px; }

.sessions { display: flex; flex-direction: column; }
.srow { display: grid; grid-template-columns: 44px minmax(200px, 1.6fr) repeat(5, minmax(78px, 1fr)) 20px; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.srow:last-child { border-bottom: 0; }
.srow:hover { background: #fafbfd; }
.sicon { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; }
.sicon.fb { background: #1877f2; } .sicon.demo { background: var(--violet); }
.stitle { font-weight: 600; }
.smeta { color: var(--muted); font-size: 12.5px; }
.stat { text-align: center; }
.stat b { display: block; font-size: 16px; }
.stat span { color: var(--muted); font-size: 11.5px; }
.stars { color: #f5a300; font-size: 12px; letter-spacing: 1px; }
.stars .off { color: #dfe2ea; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--live); font-weight: 600; font-size: 12px; }
.live-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.c-blue { color: var(--brand); } .c-red { color: var(--bad); } .c-orange { color: #e07800; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 16px; }
.search { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); min-width: 220px; }
select.inp, input.inp, textarea.inp { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); width: 100%; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.cust { padding: 14px; display: flex; flex-direction: column; gap: 10px; transition: background .3s; }
.cust.flash { background: #fffbe8; }
.cust[data-st=confirme] { border-color: #b8e6cb; }
.cust[data-st=refuse], .cust[data-st=invalide] { opacity: .65; }
.who { display: flex; gap: 10px; align-items: center; }
.av { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--line); flex: none; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.who .n { font-weight: 600; line-height: 1.2; }
.who .h { color: var(--muted); font-size: 12.5px; }
.phones { display: flex; gap: 6px; flex-wrap: wrap; }
.phone { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; background: var(--blue-soft); color: var(--brand); font-weight: 700; letter-spacing: .02em; direction: ltr; }
.wa { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #e5f8ec; color: #128c4a; }
.nophone { color: var(--muted); font-size: 12.5px; font-style: italic; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px; font-weight: 600; font-size: 12.5px; }
.st-non_appele { background: #f0f1f5; color: #4b5064; }
.st-pas_reponse { background: var(--warn-soft); color: var(--warn); }
.st-repondu { background: var(--blue-soft); color: var(--brand); }
.st-confirme { background: var(--ok-soft); color: var(--ok); }
.st-refuse { background: var(--bad-soft); color: var(--bad); }
.st-rappel { background: var(--violet-soft); color: var(--violet); }
.st-invalide { background: #fff0e0; color: #c25e00; }
.last { background: var(--bg); border-radius: 9px; padding: 8px 10px; font-size: 13px; }
.last small { color: var(--muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; display: block; }
.foot { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.link { color: var(--brand); font-weight: 500; }
.note { font-size: 13px; background: #fffbe6; border-radius: 8px; padding: 6px 10px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }

.modal-bg { position: fixed; inset: 0; background: rgba(20,22,31,.35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(440px, 100%); max-height: 86vh; overflow: auto; padding: 20px; }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.opt { display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 11px; border: 1px solid transparent; width: 100%; text-align: start; }
.opt:hover { background: var(--bg); }
.opt.on { border-color: var(--brand); background: var(--brand-soft); }
.opt .t { font-weight: 600; } .opt .d { color: var(--muted); font-size: 12px; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--line); }
.comment time { color: var(--muted); font-size: 11.5px; }
.comment mark { background: var(--blue-soft); color: var(--brand); border-radius: 4px; padding: 0 3px; }
label.f { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 4px; }

.plist .prow { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.plist .prow:last-child { border-bottom: 0; }
.pf { width: 40px; height: 40px; border-radius: 10px; background: #111; color: #fff; display: grid; place-items: center; font-weight: 700; }
.pf.fb { background: #1877f2; } .pf.demo { background: var(--violet); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { text-align: start; padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.t th { color: var(--muted); font-weight: 600; font-size: 12.5px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(360px, 100%); padding: 28px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; }
#toast.on { opacity: 1; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; align-items: center; }
  .logo { padding: 4px 8px; }
  .nav { display: flex; gap: 2px; flex-wrap: wrap; }
  .nav a span { display: none; }
  .side .bottom { margin: 0; flex-direction: row; margin-inline-start: auto; }
  .main { padding: 18px 16px 50px; }
  .srow { grid-template-columns: 40px 1fr; }
  .srow .stat, .srow .chev { display: none; }
  .srow .mstats { display: block !important; grid-column: 2; }
}
