*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b1221;
  --surface: #131c2e;
  --surface2: #1a2438;
  --border: #28344a;
  --text: #e6ebf5;
  --text2: #9aa5be;
  --muted: #5b6b85;
  --accent: #8b5cf6;
  --accent2: #a78bfa;
  --accent-light: rgba(139,92,246,0.14);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
}

body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; overflow: hidden; font-size: 13.5px; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }

/* LOGIN */
#login-screen {
  position: fixed; inset: 0; z-index: 999;
  background: radial-gradient(circle at 30% 20%, #2a1652 0%, #0b1221 60%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 440px; max-width: 95vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.6);
}
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 32px; }
.login-brand { font-size: 22px; font-weight: 800; }
.login-brand span { color: var(--accent2); }
.login-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-desc { font-size: 13px; color: var(--text2); margin-bottom: 28px; }
.login-field { margin-bottom: 18px; }
.login-field label { display: block; font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 7px; }
.login-field input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; padding: 11px 14px; outline: none; transition: border-color 0.15s; font-family: inherit; }
.login-field input:focus { border-color: var(--accent2); }
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 44px; }
.pwd-eye { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 16px; color: var(--muted); }
.login-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--danger); margin-bottom: 14px; }
.demo-creds { margin-top: 24px; background: var(--accent-light); border: 1px solid rgba(139,92,246,0.3); border-radius: 10px; padding: 16px 18px; }
.demo-creds-title { font-size: 12px; font-weight: 700; color: var(--accent2); margin-bottom: 10px; }
.demo-creds-row { font-size: 13px; color: var(--text2); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.demo-creds-row span { color: var(--muted); }
.demo-pwd { color: var(--text); font-size: 14px; letter-spacing: 0.5px; }
.copy-btn { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; color: var(--text2); font-size: 11px; padding: 3px 8px; cursor: pointer; transition: all 0.15s; }
.copy-btn:hover { border-color: var(--accent2); color: var(--accent2); }
.login-footer { margin-top: 20px; text-align: center; font-size: 12px; color: var(--muted); }

/* SIDEBAR */
.sidebar { width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; }
.sidebar-logo { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 36px; height: 36px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.logo-text { font-size: 15px; font-weight: 700; }
.logo-text span { color: var(--accent2); }
.version { font-size: 10px; color: var(--muted); margin-top: 1px; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section { margin-bottom: 18px; }
.nav-section-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; padding: 0 10px; margin-bottom: 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text2); transition: all 0.15s; margin-bottom: 2px; border: none; background: none; width: 100%; text-align: left; font-family: inherit; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent2); }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.badge { margin-left: auto; padding: 1px 7px; border-radius: 20px; font-size: 10px; font-weight: 700; background: var(--accent-light); color: var(--accent2); }
.badge.warn { background: rgba(245,158,11,0.18); color: var(--warning); }
.badge.success { background: rgba(34,197,94,0.18); color: var(--success); }
.badge.danger { background: rgba(239,68,68,0.18); color: var(--danger); }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; color: #fff; }
.avatar-info .name { font-size: 13px; font-weight: 600; }
.avatar-info .role { font-size: 11px; color: var(--muted); }

/* MAIN */
.main { flex: 1; overflow-y: auto; height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(11,18,33,0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); padding: 0 28px; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-title { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: all 0.15s; font-family: inherit; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #7c3aed; }
.btn-outline { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--accent2); color: var(--accent2); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warn { background: var(--warning); color: #0b1221; }
.btn-ghost { background: var(--surface2); color: var(--text2); border: 1px solid transparent; }
.btn-ghost:hover { color: var(--text); border-color: var(--border); }

/* PAGES */
.page { display: none; padding: 28px; }
.page.active { display: block; }

/* GREETING */
.greeting { background: linear-gradient(135deg, var(--accent-light), rgba(167,139,250,0.05)); border: 1px solid rgba(139,92,246,0.25); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 24px; display: flex; align-items: center; gap: 14px; }
.greeting-emoji { font-size: 28px; }
.greeting-text { flex: 1; }
.greeting-title { font-size: 15px; font-weight: 700; color: var(--text); }
.greeting-sub { font-size: 12.5px; color: var(--text2); margin-top: 2px; text-transform: capitalize; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; position: relative; overflow: hidden; min-height: 110px; }
.kpi-card::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--kpi-color, var(--accent)); }
.kpi-card.warn::after { --kpi-color: var(--warning); }
.kpi-card.success::after { --kpi-color: var(--success); }
.kpi-card.info::after { --kpi-color: var(--info); }
.kpi-card.danger::after { --kpi-color: var(--danger); }
.kpi-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.6px; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; margin-bottom: 6px; letter-spacing: -0.5px; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-icon { position: absolute; right: 16px; top: 20px; font-size: 30px; opacity: 0.16; }

/* GRID */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 20px; }

/* CARDS */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 14px; font-weight: 700; }
.card-body { padding: 20px; }

/* PRIORITIES */
.priority-section { margin-bottom: 16px; }
.priority-section:last-child { margin-bottom: 0; }
.priority-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.priority-pill { padding: 2px 8px; border-radius: 99px; font-size: 10px; font-weight: 700; }
.priority-pill.late { background: rgba(239,68,68,0.16); color: var(--danger); }
.priority-pill.today { background: rgba(245,158,11,0.18); color: var(--warning); }
.priority-pill.hot { background: var(--accent-light); color: var(--accent2); }
.priority-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
.priority-item .pi-icon { font-size: 18px; flex-shrink: 0; }
.priority-item .pi-body { flex: 1; min-width: 0; }
.priority-item .pi-title { font-size: 13px; font-weight: 600; }
.priority-item .pi-meta { font-size: 11.5px; color: var(--text2); margin-top: 2px; }
.priority-item .pi-actions { display: flex; gap: 6px; flex-shrink: 0; }
.priority-empty { font-size: 12.5px; color: var(--muted); padding: 8px 4px; font-style: italic; }

/* PIPELINE / KANBAN */
.pipeline-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; min-height: 480px; }
.pipeline-col { min-width: 240px; flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; }
.pipeline-col-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.pipeline-col-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.pipeline-col-count { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.pipeline-col-amount { font-size: 11px; color: var(--muted); padding: 4px 0 0 0; }
.pipeline-cards { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.deal-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; cursor: pointer; transition: all 0.15s; }
.deal-card:hover { border-color: var(--accent2); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(139,92,246,0.18); }
.deal-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.deal-company { font-size: 12px; color: var(--text2); margin-bottom: 8px; display: flex; align-items: center; gap: 5px; }
.deal-footer { display: flex; align-items: center; justify-content: space-between; }
.deal-amount { font-size: 13px; font-weight: 700; color: var(--accent2); }
.deal-prob { font-size: 11px; color: var(--muted); }
.deal-date { font-size: 11px; color: var(--muted); }
.deal-contact-age { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 99px; margin-top: 8px; }
.deal-contact-age.fresh { background: rgba(34,197,94,0.14); color: var(--success); }
.deal-contact-age.mid { background: rgba(245,158,11,0.16); color: var(--warning); }
.deal-contact-age.cold { background: rgba(239,68,68,0.14); color: var(--danger); }
.deal-contact-age.never { background: rgba(91,107,133,0.18); color: var(--muted); }

/* STATUS COLORS */
.col-prospect .pipeline-col-header { border-top: 3px solid #38bdf8; border-radius: var(--radius) var(--radius) 0 0; }
.col-prospect .pipeline-col-count { background: rgba(56,189,248,0.15); color: #38bdf8; }
.col-qualifie .pipeline-col-header { border-top: 3px solid var(--warning); border-radius: var(--radius) var(--radius) 0 0; }
.col-qualifie .pipeline-col-count { background: rgba(245,158,11,0.15); color: var(--warning); }
.col-proposition .pipeline-col-header { border-top: 3px solid var(--accent2); border-radius: var(--radius) var(--radius) 0 0; }
.col-proposition .pipeline-col-count { background: var(--accent-light); color: var(--accent2); }
.col-gagne .pipeline-col-header { border-top: 3px solid var(--success); border-radius: var(--radius) var(--radius) 0 0; }
.col-gagne .pipeline-col-count { background: rgba(34,197,94,0.15); color: var(--success); }
.col-perdu .pipeline-col-header { border-top: 3px solid var(--danger); border-radius: var(--radius) var(--radius) 0 0; }
.col-perdu .pipeline-col-count { background: rgba(239,68,68,0.15); color: var(--danger); }

/* TABLES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { padding: 11px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid rgba(40,52,74,0.5); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }
.contact-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-pill.prospect { background: rgba(56,189,248,0.14); color: var(--info); }
.status-pill.qualifie { background: rgba(245,158,11,0.14); color: var(--warning); }
.status-pill.client { background: rgba(34,197,94,0.14); color: var(--success); }
.status-pill.inactif { background: rgba(91,107,133,0.2); color: var(--muted); }

/* FILTER BAR */
.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; }
.search-box input { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; padding: 9px 12px 9px 36px; outline: none; transition: border-color 0.15s; font-family: inherit; }
.search-box input:focus { border-color: var(--accent2); }
.select-input { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 12px; font-size: 13px; font-family: inherit; outline: none; cursor: pointer; }
.select-input:focus { border-color: var(--accent2); }

/* TASKS */
.task-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.task-tab { background: var(--surface); border: 1px solid var(--border); color: var(--text2); border-radius: 99px; padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.task-tab:hover { color: var(--text); }
.task-tab.active { background: var(--accent-light); border-color: rgba(139,92,246,0.4); color: var(--accent2); }
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: all 0.15s; }
.task-row:hover { border-color: rgba(139,92,246,0.4); }
.task-row.done { opacity: 0.5; }
.task-row.done .task-title { text-decoration: line-through; }
.task-check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: transparent; color: var(--success); font-size: 14px; transition: all 0.15s; }
.task-check.done { background: var(--success); border-color: var(--success); color: #fff; }
.task-check:hover { border-color: var(--accent2); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13.5px; font-weight: 600; }
.task-meta { font-size: 11.5px; color: var(--text2); margin-top: 3px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.task-due { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.task-due.late { background: rgba(239,68,68,0.16); color: var(--danger); }
.task-due.today { background: rgba(245,158,11,0.18); color: var(--warning); }
.task-due.future { background: rgba(56,189,248,0.14); color: var(--info); }
.task-due.done { background: rgba(34,197,94,0.14); color: var(--success); }

/* HISTORIQUE */
.interaction-list { display: flex; flex-direction: column; gap: 12px; }
.interaction-item { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; display: flex; gap: 14px; align-items: flex-start; }
.interaction-icon { font-size: 20px; flex-shrink: 0; width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--accent-light); }
.interaction-body { flex: 1; min-width: 0; }
.interaction-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.interaction-meta { font-size: 12px; color: var(--text2); margin-bottom: 5px; }
.interaction-note { font-size: 12px; color: var(--muted); font-style: italic; }
.interaction-date { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* CONTACT HISTORY MODAL */
.history-section { margin-bottom: 18px; }
.history-section:last-child { margin-bottom: 0; }
.history-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); margin-bottom: 10px; }
.history-empty { font-size: 12.5px; color: var(--muted); font-style: italic; padding: 8px 0; }
.history-deal { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.history-deal-title { font-size: 13px; font-weight: 600; }
.history-deal-meta { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 500; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 580px; max-width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 7px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; padding: 10px 12px; outline: none; transition: border-color 0.15s; font-family: inherit; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent2); }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* TOAST */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 18px; font-size: 13px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 9999; opacity: 0; transform: translateY(10px); transition: all 0.3s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* PROGRESS BAR */
.progress-bar { height: 5px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress-bar-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width 0.4s; }

/* RESPONSIVE */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .page { padding: 24px; }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .page { padding: 16px; }
  .topbar { padding: 0 16px; }
  .form-row { grid-template-columns: 1fr; }
}
