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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --accent: #e8c84a;
  --text: #f0f0f0;
  --text2: #888;
  --red: #e05555;
  --green: #4caf7d;
  --blue: #5b9cf6;
}

body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; height: 100vh; overflow: hidden; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* HEADER */
header { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
header h1 { font-size: 15px; font-weight: 800; letter-spacing: 3px; color: var(--accent); }
header .subtitle { color: var(--text2); font-size: 11px; }
header .spacer { flex: 1; }
header .stats { display: flex; gap: 24px; }
header .stat .val { font-size: 17px; font-weight: 700; color: var(--accent); }
header .stat .lbl { font-size: 10px; color: var(--text2); text-align: right; }

/* TOOLBAR */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.toolbar input[type=text] { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 7px 12px; border-radius: 6px; width: 240px; font-size: 13px; }
.toolbar input[type=text]:focus { outline: none; border-color: var(--accent); }
.toolbar select { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 7px 10px; border-radius: 6px; font-size: 13px; }
.toolbar .spacer { flex: 1; }
.btn { padding: 7px 14px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; transition: opacity 0.15s; }
.btn:hover { opacity: 0.8; }
.btn-accent { background: var(--accent); color: #000; }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: #2a1a1a; color: var(--red); border: 1px solid #3a1a1a; }

/* VIEW TOGGLE */
.view-toggle { display: flex; gap: 2px; }
.view-btn { padding: 6px 10px; font-size: 14px; }
.view-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

/* MAIN */
.main { display: flex; flex: 1; overflow: hidden; }

/* TABLE */
.table-wrap { flex: 1; overflow: auto; }
.table-wrap.hidden { display: none; }
table { width: 100%; border-collapse: collapse; }
thead th { position: sticky; top: 0; background: var(--surface); padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; }
thead th:hover { color: var(--text); }
tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; }
tbody tr:hover { background: var(--surface); }
tbody tr.selected { background: #1c2418; }
tbody tr.studio-change { border-top: 2px solid var(--accent); }
tbody td { padding: 9px 14px; vertical-align: middle; }
.img-cell { width: 52px; }
.th-draft { width: 36px; }
.row-draft-cell { width: 36px; text-align: center; padding: 0 !important; }
.btn-row-draft { background: none; border: none; color: var(--text2); font-size: 14px; cursor: pointer; padding: 6px 8px; border-radius: 5px; opacity: 0; transition: opacity 0.15s, color 0.15s; }
tbody tr:hover .btn-row-draft { opacity: 1; }
.btn-row-draft:hover { color: var(--accent); }
.img-cell img, .img-cell .no-img { width: 36px; height: 36px; border-radius: 6px; object-fit: contain; background: #fff; padding: 3px; }
.img-cell .no-img { background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 15px; padding: 0; }

/* BADGES */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-nouveau    { background: #1a2535; color: var(--blue); }
.badge-contacté   { background: #2a2510; color: var(--accent); }
.badge-discussion { background: #142514; color: var(--green); }
.badge-client     { background: #0f2a1a; color: #6fcf97; }
.badge-perdu      { background: #2a1414; color: var(--red); }
.badge-haute      { background: #2a1414; color: var(--red); }
.badge-moyenne    { background: #2a2510; color: var(--accent); }
.badge-basse      { background: #1a1a2a; color: var(--text2); }
.pertinence-oui   { background: #142514; color: #6fcf97; }
.pertinence-maybe { background: #2a2510; color: var(--accent); }
.pertinence-non   { background: #2a1414; color: var(--red); }
.type-tag { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; background: var(--surface2); color: var(--text2); }

/* KANBAN VIEW */
.kanban-view { flex: 1; display: flex; gap: 12px; padding: 16px; overflow-x: auto; overflow-y: hidden; align-items: flex-start; }
.kanban-view.hidden { display: none; }

.k-col { flex-shrink: 0; width: 250px; display: flex; flex-direction: column; max-height: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.k-col.drag-over { border-color: var(--accent); background: #1c2010; }
.k-col-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 2px solid var(--border); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; flex-shrink: 0; }
.k-nouveau .k-col-header    { border-bottom-color: var(--blue); color: var(--blue); }
.k-contacte .k-col-header   { border-bottom-color: var(--accent); color: var(--accent); }
.k-discussion .k-col-header { border-bottom-color: var(--green); color: var(--green); }
.k-client .k-col-header     { border-bottom-color: #6fcf97; color: #6fcf97; }
.k-perdu .k-col-header      { border-bottom-color: var(--red); color: var(--red); }
.k-count { font-size: 12px; background: var(--surface2); border-radius: 10px; padding: 1px 8px; font-weight: 700; }
.k-cards { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }

.k-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: pointer; transition: border-color 0.15s, background 0.1s; }
.k-card:hover { border-color: #555; background: var(--surface2); }
.k-card.selected { border-color: var(--accent); background: #1c2418; }
.k-card-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.k-card-top img, .k-card-top .no-img { width: 28px; height: 28px; border-radius: 4px; object-fit: contain; background: #fff; padding: 2px; flex-shrink: 0; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.k-card-top .no-img { background: var(--surface2); }
.k-card-info { flex: 1; min-width: 0; }
.k-card-studio { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-card-contact { font-size: 11px; color: var(--text2); margin-top: 2px; }
.k-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 4px; flex-wrap: wrap; }
.k-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.k-email { font-size: 10px; color: var(--blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.k-more { text-align: center; font-size: 11px; color: var(--text2); padding: 6px; border: 1px dashed var(--border); border-radius: 6px; }

/* DETAIL PANEL */
.detail-panel { width: 360px; flex-shrink: 0; border-left: 1px solid var(--border); overflow-y: auto; background: var(--surface); display: flex; flex-direction: column; }
.detail-panel.hidden { display: none; }
.detail-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
.detail-header img, .detail-header .no-img { width: 52px; height: 52px; border-radius: 8px; object-fit: contain; flex-shrink: 0; background: #fff; padding: 4px; }
.detail-header .no-img { background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 22px; padding: 0; }
.detail-header .info { flex: 1; }
.detail-header .info h2 { font-size: 15px; font-weight: 700; }
.detail-header .info .studio { color: var(--accent); font-size: 13px; margin-top: 2px; }
.detail-header .info .loc { color: var(--text2); font-size: 12px; margin-top: 2px; }
.detail-close { background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer; line-height: 1; }
.detail-close:hover { color: var(--text); }

.detail-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.detail-section h3 { font-size: 10px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
.field-row { display: flex; gap: 8px; margin-bottom: 7px; align-items: flex-start; }
.field-row .lbl { color: var(--text2); font-size: 11px; min-width: 85px; padding-top: 1px; flex-shrink: 0; }
.field-row .val { font-size: 13px; flex: 1; word-break: break-word; }
.field-row .val a { color: var(--blue); text-decoration: none; }
.field-row .val a:hover { text-decoration: underline; }

.strategie-box { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 12px; line-height: 1.7; color: #ccc; white-space: pre-wrap; }
.produit-pill { display: inline-block; background: #142514; color: var(--green); border: 1px solid #1e3a1e; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.social-links { display: flex; gap: 6px; flex-wrap: wrap; }
.social-links a { padding: 3px 9px; background: var(--surface2); border: 1px solid var(--border); border-radius: 5px; color: var(--text2); text-decoration: none; font-size: 11px; }
.social-links a:hover { color: var(--text); border-color: var(--accent); }
.action-bar { padding: 14px 16px; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); margin-top: auto; }

/* MODAL (base) */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 580px; max-height: 85vh; overflow-y: auto; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-body .full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 11px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select, .form-group textarea { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 6px; font-size: 13px; font-family: inherit; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* INLINE EDIT */
.editable { cursor: text; user-select: none; border-radius: 4px; transition: background 0.1s; }
.editable:hover { background: #242424; outline: 1px dashed #3a3a3a; }
.editable::after { content: ' ✎'; font-size: 10px; color: #444; opacity: 0; transition: opacity 0.15s; }
.editable:hover::after { opacity: 1; }

/* COUNT INDICATOR */
.count-indicator { font-size: 11px; color: var(--text2); margin-right: 4px; font-variant-numeric: tabular-nums; }

/* COLUMN PICKER */
.col-picker-wrap { position: relative; }
.col-picker { position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); width: 220px; max-height: 420px; overflow-y: auto; display: grid; gap: 2px; }
.col-picker.hidden { display: none; }
.col-pick-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 5px; font-size: 13px; cursor: pointer; user-select: none; }
.col-pick-item:hover { background: var(--surface2); }
.col-pick-item input { accent-color: var(--accent); }

/* CELL EDIT */
.cell-edit { position: relative; }
.cell-edit:hover { background: rgba(232, 200, 74, 0.06); box-shadow: inset 0 0 0 1px rgba(232, 200, 74, 0.25); }
.cell-input { width: 100%; min-width: 180px; background: var(--surface2); color: var(--text); border: 2px solid var(--accent); border-radius: 6px; padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none; box-shadow: 0 4px 14px rgba(0,0,0,0.4); }

/* MISC */
.loading { display: flex; align-items: center; justify-content: center; height: 200px; color: var(--text2); flex-direction: column; gap: 8px; }
#table-state { display: none; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* MODAL BROUILLON */
.email-modal { width: 640px; }
.email-modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.draft-step-info { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; }
.canal-tag { font-size: 11px; font-weight: 600; color: var(--text2); }
.tpl-field { display: flex; flex-direction: column; gap: 6px; }
.tpl-label-row { display: flex; justify-content: space-between; align-items: center; }
.tpl-label-row label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); }
.tpl-input { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 6px; font-size: 13px; font-family: inherit; outline: none; }
.tpl-input:focus { border-color: var(--accent); }
.tpl-textarea { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 12px; border-radius: 6px; font-size: 12px; font-family: inherit; line-height: 1.6; resize: vertical; min-height: 220px; outline: none; }
.tpl-textarea:focus { border-color: var(--accent); }
.tpl-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tpl-hint { font-size: 11px; color: var(--text2); font-style: italic; }

/* SEQUENCE TAG */
.seq-tag { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; background: #1a2030; color: var(--blue); border: 1px solid #243049; white-space: nowrap; }
.desc-tag { font-size: 12px; color: #b9a44a; font-style: italic; }
.detail-header .desc-studio { font-size: 11px; color: #b9a44a; font-style: italic; margin-top: 3px; line-height: 1.3; }

/* VUE SUIVI */
.suivi-view { flex: 1; overflow-y: auto; padding: 16px 20px; }
.suivi-view.hidden { display: none; }

.suivi-recap { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.suivi-stat { flex: 1; min-width: 110px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; text-align: center; }
.suivi-stat .n { font-size: 26px; font-weight: 800; line-height: 1; }
.suivi-stat .l { font-size: 11px; color: var(--text2); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.suivi-stat.retard { border-color: #3a1a1a; } .suivi-stat.retard .n { color: var(--red); }
.suivi-stat.today  { border-color: #2a2510; } .suivi-stat.today .n { color: var(--accent); }
.suivi-stat.week   { border-color: #142514; } .suivi-stat.week .n { color: var(--green); }
.suivi-stat.start  { border-color: #2e2e2e; } .suivi-stat.start .n { color: var(--text2); }
.suivi-stat.total  { border-color: #243049; } .suivi-stat.total .n { color: var(--blue); }

.suivi-section { margin-bottom: 22px; }
.suivi-section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; font-weight: 700; }
.suivi-count { background: var(--surface2); border-radius: 10px; padding: 1px 9px; font-size: 12px; }
.suivi-hint { font-size: 11px; color: var(--text2); font-weight: 400; font-style: italic; }
.suivi-section.retard .suivi-section-header { color: var(--red); }
.suivi-section.today .suivi-section-header { color: var(--accent); }
.suivi-section.week .suivi-section-header { color: var(--green); }

.suivi-cards { display: flex; flex-direction: column; gap: 6px; }
.suivi-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; cursor: pointer; transition: border-color 0.12s, background 0.1s; }
.suivi-card:hover { border-color: #555; background: var(--surface2); }
.suivi-card-main { min-width: 0; flex: 1; }
.suivi-card-studio { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suivi-card-contact { font-size: 11px; color: var(--text2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suivi-card-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.echeance { font-size: 11px; color: var(--text2); white-space: nowrap; }
.echeance.retard { color: var(--red); font-weight: 600; }
.echeance.today { color: var(--accent); font-weight: 600; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.suivi-more { text-align: center; font-size: 11px; color: var(--text2); padding: 6px; }
.suivi-empty { text-align: center; color: var(--text2); padding: 60px 20px; font-size: 14px; }

/* MODAL LOG ACTION */
.log-modal { width: 460px; }
.log-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.log-contact { font-size: 15px; font-weight: 700; color: var(--accent); }
.log-row { display: flex; align-items: center; gap: 10px; }
.log-label { font-size: 12px; color: var(--text2); }
.log-field { display: flex; flex-direction: column; gap: 5px; }
.log-field label { font-size: 11px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.log-field select, .log-field input { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 6px; font-size: 13px; font-family: inherit; }
.log-field select:focus, .log-field input:focus { outline: none; border-color: var(--accent); }
.log-next { background: #142514; border: 1px solid #1e3a1e; border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.log-next-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
.log-next-val { font-size: 14px; font-weight: 700; color: var(--green); }

/* ── État de la relation (Température / Prochaine action / Relance) ───────── */
.temp-pos  { background:#142514; color:#6fcf97; }
.temp-moy  { background:#2a2410; color:#e8c84a; }
.temp-neg  { background:#2a1414; color:#e57373; }
.temp-none { background:#1c1c1c; color:#8a8a8a; }

.relance.retard { color:#e57373; font-weight:700; }
.relance.today  { color:#e8c84a; font-weight:700; }
.relance.ok     { color:#6fcf97; }
.relance.none   { color:#8a8a8a; }

.pa-badge { display:inline-block; padding:2px 8px; border-radius:5px; font-size:11px; font-weight:600; white-space:nowrap; border:1px solid transparent; }
.pa-hot   { background:#142514; color:#6fcf97; border-color:#1f4d2f; }
.pa-start { background:#1a2030; color:#7fb3ff; border-color:#243049; }
.pa-send  { background:#1a2030; color:#7fb3ff; border-color:#243049; }
.pa-due   { background:#2a2410; color:#e8c84a; border-color:#4d4413; }
.pa-wait  { background:#1c1c1c; color:#9a9a9a; border-color:#2a2a2a; }
.pa-done  { background:#1c1c1c; color:#8a8a8a; border-color:#2a2a2a; }

/* Bandeau résumé dans le panneau détail */
.relation-summary { background:#15151a; border:1px solid #242430; border-radius:8px; padding:10px 12px; margin-bottom:10px; }
.relation-summary .rs-meta { font-size:11.5px; color:var(--text2); line-height:1.7; margin-bottom:8px; }
.relation-summary .rs-row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }

/* PAGINATION */
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--surface); }
.pagination .page-info { font-size: 12px; color: var(--text2); }

/* ÉCRAN DE CONNEXION */
#login-screen { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 48px 40px; display: flex; flex-direction: column; align-items: center; gap: 20px; width: 360px; }
.login-box h1 { font-size: 22px; font-weight: 800; letter-spacing: 4px; color: var(--accent); }
.login-sub { font-size: 12px; color: var(--text2); letter-spacing: 1px; margin-top: -12px; }
.login-field { display: flex; gap: 8px; width: 100%; }
.login-field input { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; color: var(--text); font-size: 14px; outline: none; }
.login-field input:focus { border-color: var(--accent); }
.login-error { color: var(--red); font-size: 13px; }
