/* SENTINEL Dashboard - charte ICARE Suite (core.css + auth.css repris à l'identique) */
:root {
  --red:        #E11709;
  --red-light:  rgba(225,23,9,.08);
  --red-mid:    rgba(225,23,9,.14);
  --dark:       #111111;
  --sidebar-bg: #141414;
  --main-bg:    #F5F4F1;
  --card-bg:    #FFFFFF;
  --border:     #E5E3DC;
  --text-1:     #1A1A1A;
  --text-2:     #6B6B6B;
  --text-3:     #ABABAB;
}

* { box-sizing: border-box; }

body {
  font-family: 'Poppins', Arial, sans-serif;
  background: var(--main-bg);
  min-height: 100vh;
  margin: 0;
  color: var(--text-1);
}

/* ── AUTH SCREEN (repris tel quel d'ICARE Suite) ── */
#auth-screen { display: none; min-height: 100vh; }
#auth-screen.active { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }

.auth-brand {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--main-bg); padding: 60px 48px; position: relative; overflow: hidden;
}
.auth-brand::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 1px; background: var(--border); }
.auth-brand-logo { display: flex; flex-direction: column; align-items: center; gap: 0; }
.auth-brand-logo img { width: 160px; height: auto; }
.auth-brand-tagline { margin-top: 32px; font-size: 14px; font-weight: 500; color: #888; text-align: center; letter-spacing: .3px; }
.auth-brand-tagline span { color: var(--red); font-weight: 600; }

.auth-form-area { display: flex; flex-direction: column; justify-content: center; background: #fff; padding: 60px 64px; }
.auth-title { font-size: 26px; font-weight: 700; color: var(--text-1); margin-bottom: 6px; }
.auth-sub { font-size: 14px; color: #888; margin-bottom: 36px; font-weight: 400; }
.auth-field { margin-bottom: 18px; }
.auth-field-label { font-size: 12px; font-weight: 600; color: #444; display: block; margin-bottom: 8px; }
.auth-input {
  width: 100%; padding: 13px 16px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none; color: var(--text-1); background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.auth-input::placeholder { color: #bbb; }
.auth-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-mid); }
.pwd-wrap { position: relative; }
.pwd-wrap .auth-input { padding-right: 42px; }
.pwd-toggle {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 2px; color: var(--text-3); display: flex; align-items: center;
}
.pwd-toggle:hover { color: var(--text-2); }
.auth-btn-login {
  width: 100%; margin-top: 8px; padding: 14px 24px; background: var(--red); color: #fff;
  border: none; border-radius: 50px; font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .2s, transform .15s, box-shadow .2s;
}
.auth-btn-login:hover { background: #c01507; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(225,23,9,.25); }
.auth-btn-login:active { transform: translateY(0); }
.auth-error { font-size: 13px; color: var(--red); margin-bottom: 8px; min-height: 18px; }
.auth-footer-note { margin-top: 40px; font-size: 11px; color: #bbb; text-align: center; }
.auth-mobile-logo { display: none; }

@media (max-width: 768px) {
  #auth-screen.active { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-form-area { padding: 48px 28px 48px; justify-content: flex-start; padding-top: 80px; }
  .auth-mobile-logo { display: flex !important; justify-content: center; margin-bottom: 36px; }
  .auth-mobile-logo img { width: 100px; }
}

/* ── APP SHELL ── */
.app { display: none; height: 100vh; overflow: hidden; }
.app.active { display: flex; }
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  height: 52px; background: var(--card-bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 12px; flex-shrink: 0;
}
.topbar-title { font-size: 14px; font-weight: 700; color: var(--text-1); }

.screen-area { flex: 1; overflow-y: auto; position: relative; }
.screen { display: none; padding: 32px 40px; min-height: 100%; }
.screen.active { display: block; animation: fadeUp .2s ease forwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── SIDEBAR ── */
#sidebar {
  width: 220px; background: var(--sidebar-bg); color: #fff; display: flex; flex-direction: column;
  flex-shrink: 0; transition: transform .22s cubic-bezier(.4,0,.2,1); overflow: hidden;
}
.sidebar-header { display: flex; align-items: center; justify-content: center; padding: 26px 16px 22px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar-header img { height: 68px; width: auto; display: block; }
.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav-section { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: rgba(255,255,255,.28); padding: 14px 10px 6px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px; border-radius: 7px; cursor: default;
  font-size: 13px; color: rgba(255,255,255,.6); background: none; border: none; font-family: inherit;
  width: 100%; text-align: left; transition: background .12s, color .12s; position: relative;
}
.sidebar-link.active { background: var(--red-light); color: #fff; }
.sidebar-link.active::before { content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2.5px; background: var(--red); border-radius: 0 2px 2px 0; }
.sidebar-link svg { flex-shrink: 0; opacity: .8; }
.sidebar-footer { padding: 10px 8px; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-footer-user { padding: 6px 10px 10px; font-size: 12px; color: rgba(255,255,255,.55); display: flex; align-items: center; gap: 8px; }
.sidebar-footer-avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--red); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #fff; flex-shrink: 0; }
.sidebar-logout { cursor: pointer; color: rgba(255,255,255,.4); }
.sidebar-logout:hover { background: rgba(255,255,255,.05); color: #ff6b6b; }

#sidebar-toggle {
  position: fixed; left: 12px; top: 12px; z-index: 299; background: var(--sidebar-bg);
  border: 1px solid rgba(255,255,255,.12); color: #fff; border-radius: 8px; padding: 8px;
  cursor: pointer; display: none; align-items: center; justify-content: center;
}
#sidebar-toggle.visible { display: flex; }
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 299; }
#sidebar-overlay.visible { display: block; }

@media (max-width: 768px) {
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 400; transform: translateX(-220px); }
  #sidebar.sb-mobile-open { transform: translateX(0); }
  .main-content { width: 100%; }
  #sidebar-toggle { display: flex !important; }
  .screen { padding: 20px 16px; }
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }

.meta-line { color: var(--text-3); font-size: 12.5px; margin-bottom: 18px; }

/* ── LEAD CARDS (charte tool-card) ── */
.leads-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; align-items: start; }

.lead-card {
  background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 14px; padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.lead-card:hover { border-color: var(--red); box-shadow: 0 4px 20px rgba(225,23,9,.1); transform: translateY(-1px); }

.lead-card-header { display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.lead-header-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lead-ref { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 10.5px; font-weight: 700; letter-spacing: .01em; background: #f4f4f4; color: var(--text-2); padding: 3px 8px; border-radius: 6px; }
.lead-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.lead-open-row {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  cursor: pointer; color: var(--text-3); font-size: 11.5px; font-weight: 600;
  padding-top: 10px; margin-top: 2px; border-top: 1px solid #f5f5f3; transition: color .15s;
}
.lead-open-row:hover { color: var(--red); }

.lead-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--text-1); }
.lead-subtitle { font-size: 12.5px; color: var(--text-2); }

.pill { font-size: 10.5px; font-weight: 600; background: #f4f4f4; color: var(--text-2); padding: 3px 9px; border-radius: 20px; display: inline-block; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 10.5px; font-weight: 500; background: var(--red-light); color: var(--red); padding: 3px 9px; border-radius: 6px; }

/* ── FICHE (tableau cle/valeur, charte Nicoka) ── */
.fiche-table { width: 100%; border-collapse: collapse; }
.fiche-table th, .fiche-table td { text-align: left; padding: 7px 0; font-size: 12.5px; vertical-align: top; border-bottom: 1px solid #f5f5f3; }
.fiche-table tr:last-child th, .fiche-table tr:last-child td { border-bottom: none; }
.fiche-table th { width: 108px; min-width: 108px; font-weight: 600; color: var(--text-2); padding-right: 12px; }
.fiche-table td { color: var(--text-1); line-height: 1.5; width: 100%; }

.lead-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; padding-top: 12px; border-top: 1px solid #f5f5f3; }
.btn-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1.5px solid var(--border); border-radius: 20px;
  color: var(--text-2); font-size: 11.5px; font-weight: 600; text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-link svg { flex-shrink: 0; opacity: .75; }
.btn-link:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }
.btn-link:hover svg { opacity: 1; }

.placeholder-box { border: 2px dashed var(--border); border-radius: 8px; padding: 40px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ── TOPBAR (support) ── */
.btn-support {
  margin-left: auto; display: flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 20px; border: 1.5px solid var(--border); background: #fff;
  color: var(--text-2); font-size: 12.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-support:hover { border-color: var(--red); color: var(--red); }

/* ── TABS ── */
.tabs-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: #ece9e3; border-radius: 10px; padding: 4px; }
.tab-btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 7px;
  background: none; color: var(--text-2); font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: background .15s, color .15s;
}
.tab-btn.active { background: #fff; color: var(--text-1); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.tab-count {
  font-size: 10.5px; font-weight: 700; background: rgba(0,0,0,.08); color: var(--text-2);
  padding: 1px 7px; border-radius: 20px;
}
.tab-btn.active .tab-count { background: var(--red-light); color: var(--red); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 8px;
  border: 1.5px solid var(--border); background: #fff; color: var(--text-1); font-size: 12.5px;
  font-weight: 600; font-family: inherit; cursor: pointer; transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--red); color: var(--red); }

/* ── LEAD CARD ACTIONS (compactes, visibles carte fermee ou ouverte) ── */
.btn-icon-sm, .btn-icon-lg {
  border-radius: 50%; border: 1.5px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .15s; flex-shrink: 0;
}
.btn-icon-sm { width: 26px; height: 26px; }
.btn-icon-lg { width: 40px; height: 40px; }
.btn-icon-reject { color: var(--text-2); }
.btn-icon-reject:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }
.btn-icon-accept { color: #166534; }
.btn-icon-accept:hover { border-color: #166534; background: #dcfce7; }
.btn-icon-reopen { color: var(--text-3); }
.btn-icon-reopen:hover { border-color: #1d4ed8; color: #1d4ed8; background: #eff6ff; }

.rdv-toggle { position: relative; color: var(--text-3); }
.rdv-toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.rdv-toggle:has(input:checked) { border-color: #1d4ed8; color: #1d4ed8; background: #eff6ff; }

.pill-rdv { background: #dbeafe; color: #1d4ed8; }

.lead-outcome-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.lead-outcome-badge.outcome-gagne { background: #dcfce7; color: #166534; }
.lead-outcome-badge.outcome-refuse { background: #f4f4f4; color: var(--text-2); }

/* ── PANNEAU DE DETAIL (slide-over, la grille de cartes ne bouge jamais) ── */
.detail-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 480;
  opacity: 0; transition: opacity .25s ease; display: none;
}
.detail-overlay:not([hidden]) { display: block; }
.detail-overlay.open { opacity: 1; }

.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 92vw;
  background: #fff; z-index: 490; box-shadow: -10px 0 34px rgba(0,0,0,.18);
  transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.detail-panel:not([hidden]) { display: flex; }
.detail-panel.open { transform: translateX(0); }

.detail-panel-header {
  padding: 22px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-shrink: 0;
}
.detail-panel-body { padding: 22px 24px; overflow-y: auto; flex: 1; }
.detail-panel-footer {
  padding: 16px 24px; border-top: 1px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}
.detail-panel-footer:empty { display: none; }
.detail-panel-close {
  background: none; border: none; cursor: pointer; color: var(--text-3); padding: 4px;
  border-radius: 6px; transition: color .15s, background .15s; flex-shrink: 0;
}
.detail-panel-close:hover { color: var(--red); background: var(--red-light); }

@media (max-width: 600px) {
  .detail-panel { width: 100vw; max-width: 100vw; }
}

/* ── MODALES ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 500; align-items: center; justify-content: center; padding: 20px; display: none; }
.modal-overlay:not([hidden]) { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 28px 28px 24px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-title { font-size: 17px; font-weight: 700; color: var(--text-1); margin-bottom: 18px; }
.modal .field input, .modal .field textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 13.5px; font-family: inherit; color: var(--text-1); outline: none; transition: border-color .2s; resize: vertical;
}
.modal .field input:focus, .modal .field textarea:focus { border-color: var(--red); }
.btn-row { display: flex; gap: 10px; margin-top: 22px; justify-content: flex-end; }
.btn { padding: 10px 20px; border-radius: 8px; border: none; font-size: 13.5px; font-weight: 600; font-family: inherit; cursor: pointer; transition: opacity .15s; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.modal .btn-secondary { border: 1.5px solid var(--border); }

.radio-cards { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.radio-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid #e8e8e8; border-radius: 9px; cursor: pointer; transition: all .15s; }
.radio-card:hover { border-color: #ccc; background: #fafafa; }
.radio-card.selected { border-color: var(--red); background: var(--red-light); }
.radio-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #ccc; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: border-color .15s; }
.radio-card.selected .radio-dot { border-color: var(--red); }
.radio-dot::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--red); opacity: 0; transition: opacity .15s; }
.radio-card.selected .radio-dot::after { opacity: 1; }
.radio-card-title { font-size: 13px; font-weight: 600; color: var(--text-1); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--dark); color: #fff; padding: 11px 20px; border-radius: 8px; font-size: 13px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 999; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── DASHBOARD ── */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.pipeline-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.pipeline-card.featured { border-color: var(--red); background: linear-gradient(135deg,#fff 80%,rgba(225,23,9,.04)); }
.pipeline-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 8px; }
.pipeline-value { font-size: 26px; font-weight: 800; color: var(--text-1); }
.pipeline-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }

.dash-section-title { font-size: 13px; font-weight: 700; color: var(--text-1); margin: 28px 0 12px; }
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 220px 1fr 32px; align-items: center; gap: 12px; }
.bar-label { font-size: 12.5px; color: var(--text-2); }
.bar-track { background: #ece9e3; border-radius: 6px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--red); height: 100%; border-radius: 6px; transition: width .3s; }
.bar-value { font-size: 12.5px; font-weight: 700; color: var(--text-1); text-align: right; }

/* ── SETTINGS ── */
.settings-card { max-width: 560px; margin-bottom: 18px; padding: 24px 26px; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--text-1); }
.card-subtitle { font-size: 12.5px; color: var(--text-2); margin-top: 3px; margin-bottom: 18px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0; }
.toggle-label { font-size: 13.5px; font-weight: 600; color: var(--text-1); }
.toggle-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.toggle { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #ddd; border-radius: 24px; cursor: pointer; transition: background .2s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.toggle input:checked + .toggle-slider { background: var(--red); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

.settings-card .field { margin-top: 4px; }
.settings-card .field input, .settings-card .field select, .settings-card .field textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13.5px;
  font-family: inherit; color: var(--text-1); outline: none; transition: border-color .2s; resize: vertical; box-sizing: border-box;
}
.settings-card .field input:focus, .settings-card .field select:focus, .settings-card .field textarea:focus { border-color: var(--red); }
.settings-card .btn { margin-top: 14px; }
.settings-msg { font-size: 12.5px; color: #166534; margin-top: 10px; min-height: 16px; }
.settings-msg.error { color: var(--red); }

@media (max-width: 600px) {
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .bar-value { text-align: left; }
}
