/* RSE Copilot Best Events — design system « nature premium » (dérivé sales-copilot) */
:root {
  --bg: #0c1310;
  --bg-soft: #0f1713;
  --surface: #121b16;
  --surface-2: #18241d;
  --surface-3: #1e2c24;
  --border: #223328;
  --border-soft: #1a281f;
  --text: #e7f0e9;
  --muted: #8fa697;
  --accent: #3fb96b;
  --accent-strong: #55d283;
  --accent-soft: rgba(63, 185, 107, 0.14);
  --warn: #d9a441;
  --warn-soft: rgba(217, 164, 65, 0.15);
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.15);
  --info: #5b9bd9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(63, 185, 107, 0.07), transparent 60%),
    radial-gradient(800px 420px at -10% 110%, rgba(63, 185, 107, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
}
a { color: var(--accent-strong); text-decoration: none; }
button { font-family: inherit; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 380px; max-width: 100%;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: 18px;
  padding: 38px 34px; box-shadow: var(--shadow);
}
.login-card .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-card .logo img { width: 42px; height: 42px; }
.login-card h1 { font-size: 21px; letter-spacing: 0.2px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.login-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 14px 0 5px; }
.login-error {
  background: var(--danger-soft); border: 1px solid rgba(229, 72, 77, 0.4);
  color: #ffb3b5; border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; margin-top: 14px;
}

/* ---------- Inputs ---------- */
input, select, textarea {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select { cursor: pointer; }
textarea { resize: vertical; min-height: 70px; }
.inline-input { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #06130a; border: none;
  border-radius: var(--radius-sm); padding: 9px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform 0.1s, background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--accent-strong); box-shadow: 0 4px 14px rgba(63,185,107,.25); }
.btn:active { transform: translateY(1px); }
.btn.full { width: 100%; justify-content: center; margin-top: 20px; }
.btn.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-strong); box-shadow: none; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.danger { background: transparent; border: 1px solid rgba(229,72,77,.5); color: #ff9a9e; }
.btn.danger:hover { background: var(--danger-soft); box-shadow: none; }
.btn[disabled] { opacity: 0.5; cursor: wait; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 224px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  background: var(--bg-soft); border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; padding: 18px 12px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.sidebar .brand img { width: 34px; height: 34px; }
.sidebar .brand b { font-size: 15px; }
.sidebar .brand span { display: block; font-size: 11px; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14px; cursor: pointer; border: none;
  background: transparent; width: 100%; text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-link .ico { width: 18px; text-align: center; }
.sidebar .spacer { flex: 1; }
.sidebar .me { padding: 10px 12px; border-top: 1px solid var(--border-soft); font-size: 13px; }
.sidebar .me .name { font-weight: 600; }
.sidebar .me .role { color: var(--muted); font-size: 11.5px; }

.main { flex: 1; padding: 26px 32px 60px; max-width: 1240px; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.topbar h2 { font-size: 21px; flex: 1; }
.audit-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px; font-size: 13px;
}
.audit-chip b { color: var(--warn); }
.audit-chip .pct { color: var(--accent-strong); font-weight: 700; }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card {
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 18px 20px;
}
.card h3 { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 11.5px; }
.big-num { font-size: 30px; font-weight: 700; line-height: 1.1; }
.big-num small { font-size: 13px; color: var(--muted); font-weight: 400; }

/* ---------- Score gauge ---------- */
.score-flex { display: flex; gap: 22px; align-items: center; }
.gauge { position: relative; width: 130px; height: 130px; flex-shrink: 0; }
.gauge svg { transform: rotate(-90deg); }
.gauge .val {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.gauge .val b { font-size: 26px; }
.gauge .val span { font-size: 10.5px; color: var(--muted); }
.legend { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.dot.ok { background: var(--accent); }
.dot.mid { background: var(--warn); }
.dot.ko { background: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: 10px 12px; background: var(--surface-3);
  color: var(--muted); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 0.05em; white-space: nowrap;
}
td { padding: 9px 12px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
tr:hover td { background: rgba(63, 185, 107, 0.035); }
td select, td input { padding: 5px 8px; font-size: 13px; }
.t-title { max-width: 420px; }
.t-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge.fait, .badge.covered, .badge.analyse { background: var(--accent-soft); color: var(--accent-strong); }
.badge.en_cours, .badge.partial, .badge.envoye { background: var(--warn-soft); color: var(--warn); }
.badge.a_faire, .badge.non_envoye { background: rgba(139, 160, 148, 0.16); color: var(--muted); }
.badge.missing, .badge.late { background: var(--danger-soft); color: #ff9a9e; }
.badge.recu { background: rgba(91, 155, 217, 0.16); color: var(--info); }
.badge.prio1 { background: var(--danger-soft); color: #ff9a9e; }
.badge.prio2 { background: var(--warn-soft); color: var(--warn); }
.badge.prio3 { background: rgba(91, 155, 217, 0.16); color: var(--info); }

/* ---------- Filtres ---------- */
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 140px; }
.filters .grow { flex: 1; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); border-radius: 999px; padding: 5px 13px;
  font-size: 12.5px; cursor: pointer; transition: all 0.12s;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }

/* ---------- ISO ---------- */
.iso-card { margin-bottom: 12px; }
.iso-head { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.iso-head .clause {
  font-weight: 700; color: var(--accent-strong); min-width: 42px; font-size: 15px;
}
.iso-head .title { flex: 1; font-weight: 600; }
.iso-body { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.iso-desc { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.link-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--bg-soft); border-radius: var(--radius-sm);
  margin-bottom: 6px; font-size: 13px;
}
.link-row .x { margin-left: auto; }

/* ---------- KPIs ---------- */
.kpi-card .kval { font-size: 24px; font-weight: 700; margin: 4px 0; }
.kpi-card .kval small { color: var(--muted); font-size: 13px; font-weight: 400; }
.kpi-card .target { color: var(--muted); font-size: 12.5px; }
.sparkline { margin-top: 10px; }
.kpi-name { font-size: 13.5px; font-weight: 600; min-height: 40px; }

/* ---------- Chat ---------- */
.chat-layout { display: grid; grid-template-columns: 260px 1fr; gap: 18px; min-height: 65vh; }
.conv-list { display: flex; flex-direction: column; gap: 6px; }
.conv-item {
  padding: 10px 13px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; font-size: 13px; color: var(--muted);
  background: var(--surface); text-align: left; width: 100%;
}
.conv-item:hover { color: var(--text); border-color: var(--border); }
.conv-item.active { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.chat-pane { display: flex; flex-direction: column; }
.chat-msgs {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  gap: 14px; padding: 6px 4px 18px; max-height: 62vh;
}
.msg { max-width: 82%; padding: 12px 16px; border-radius: 14px; font-size: 14px;
  white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent-soft);
  border: 1px solid rgba(63, 185, 107, 0.3); }
.msg.assistant { align-self: flex-start; background: var(--surface-2);
  border: 1px solid var(--border-soft); }
.msg.assistant.thinking { color: var(--muted); font-style: italic; }
.chat-input { display: flex; gap: 10px; margin-top: 12px; }
.chat-input textarea { flex: 1; min-height: 52px; max-height: 160px; }
.chat-hello { color: var(--muted); font-size: 13.5px; padding: 20px;
  border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(5, 10, 7, 0.72);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal {
  width: 620px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 16px; padding: 26px 28px; box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.modal .row { margin-bottom: 12px; }
.modal .row label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal.wide { width: 900px; }
.modal iframe { width: 100%; height: 68vh; border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); background: #fff; }

/* ---------- Divers ---------- */
.empty { color: var(--muted); padding: 26px; text-align: center; font-size: 13.5px; }
.section-title { font-size: 15px; font-weight: 600; margin: 26px 0 12px; }
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 90;
  background: var(--surface-3); border: 1px solid var(--accent);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 12px 18px; font-size: 13.5px; box-shadow: var(--shadow);
  animation: slide-in 0.2s ease-out;
}
.toast.err { border-color: var(--danger); }
@keyframes slide-in { from { transform: translateY(12px); opacity: 0; } }
.muted { color: var(--muted); }
.mt { margin-top: 16px; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row;
    overflow-x: auto; align-items: center; gap: 4px; padding: 10px; }
  .sidebar .brand { padding: 0 8px; }
  .sidebar .brand span, .sidebar .me, .sidebar .spacer { display: none; }
  .nav-link { white-space: nowrap; padding: 8px 10px; }
  .main { padding: 18px 14px 50px; }
  .chat-layout { grid-template-columns: 1fr; }
}
