:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --accent: #3b82f6;
  --accent2: #f97316;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #d97706;
  --purple: #9333ea;
  --text: #0f172a;
  --muted: #64748b;
  --safe-top: env(safe-area-inset-top,0px);
  --safe-bottom: env(safe-area-inset-bottom,0px);
}
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html{height:100%}
body{background:var(--bg);color:var(--text);font-family:-apple-system,'SF Pro Display','Segoe UI',system-ui,sans-serif;min-height:100vh}

/* ─── LAYOUT ─── */
.app-shell{display:flex;flex-direction:column;height:100vh}
@media(min-width:900px){
  .app-shell{flex-direction:row}
  .sidebar{width:260px;flex-shrink:0;background:var(--surface);border-right:1px solid var(--border);display:flex;flex-direction:column;height:100vh;position:sticky;top:0}
  .main-area{flex:1;overflow-y:auto;height:100vh;padding-bottom:0!important}
  .mobile-header{display:none}
  .bottom-tabs{display:none!important}
}
@media(max-width:899px){
  .sidebar{display:none}
  .main-area{flex:1;padding-bottom:calc(70px + var(--safe-bottom))}
  .mobile-header{display:flex;align-items:center;gap:12px;padding:calc(12px + var(--safe-top)) 16px 12px;background:var(--surface);border-bottom:1px solid var(--border)}
  .mobile-header h1{font-size:18px;font-weight:800}
  .mobile-header h1 span{color:var(--accent)}
  .mobile-api-row{display:flex;align-items:center;gap:8px;margin-left:auto}
  /* 📱 iOS anti-zoom : tous les inputs ≥ 16px */
  input,textarea,select{font-size:16px!important}
  /* 👆 Touch targets min 44px */
  .btn{min-height:44px;padding:10px 16px}
  .btn-sm{min-height:36px}
  /* 🎯 Triage actions : 2 colonnes sur mobile */
  .triage-actions{grid-template-columns:repeat(2,1fr)!important}
  /* 📋 Page padding réduit */
  .page{padding:12px}
  /* 🗂 CRM panel full width */
  #crm-action-panel{border-radius:0}
  /* 🔎 Search input tap-friendly */
  #search-input{font-size:16px!important;padding:12px 14px!important}
  /* 📅 Date input visible */
  input[type=date]{min-width:140px;background:var(--surface2);border:1px solid var(--border);border-radius:8px;padding:8px 10px}
  /* 🃏 Cards full width */
  .crm-record{margin:0 0 8px}
  /* Evite overflow horizontal */
  .page,.card{overflow-x:hidden}
  /* Statut grid : 2 colonnes max sur petit écran */
  .statut-grid{grid-template-columns:repeat(2,1fr)!important}
  /* CRM tabs scroll horizontal */
  .crm-tabs{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;padding-bottom:4px}
  .crm-tab{white-space:nowrap;flex-shrink:0}
}

/* ─── SIDEBAR ─── */
.sidebar-logo{padding:24px 20px 20px;border-bottom:1px solid var(--border)}
.sidebar-logo h1{font-size:20px;font-weight:800;letter-spacing:-0.5px}
.sidebar-logo h1 span{color:var(--accent)}
.sidebar-logo p{font-size:11px;color:var(--muted);margin-top:2px}
.sidebar-cfg{padding:14px 20px;border-bottom:1px solid var(--border)}
.sidebar-cfg label{font-size:10px;color:var(--muted);font-weight:700;text-transform:uppercase;letter-spacing:.6px;display:block;margin-bottom:4px}
.cfg-row{display:flex;align-items:center;gap:6px;margin-bottom:8px}
.cfg-input{background:var(--surface2);border:1px solid var(--border);border-radius:8px;padding:7px 10px;font-size:11px;color:var(--text);flex:1;font-family:monospace}
.api-dot{width:8px;height:8px;border-radius:50%;background:var(--red);flex-shrink:0;transition:background .3s}
.api-dot.on{background:var(--green)}
.sidebar-nav{flex:1;padding:12px;overflow-y:auto}
.nav-item{display:flex;align-items:center;gap:12px;padding:11px 14px;border-radius:10px;cursor:pointer;font-size:14px;font-weight:500;color:var(--muted);transition:all .15s;margin-bottom:2px}
.nav-item:hover{background:var(--surface2);color:var(--text)}
.nav-item.active{background:rgba(59,130,246,.15);color:var(--accent)}
.nav-item .nav-icon{font-size:18px;width:24px;text-align:center}
.nav-badge{background:var(--red);color:#fff;font-size:10px;font-weight:700;padding:2px 6px;border-radius:10px;margin-left:auto}
.sidebar-footer{padding:14px 20px;border-top:1px solid var(--border)}
.sidebar-footer p{font-size:10px;color:var(--muted);line-height:1.5}

/* ─── BOTTOM TABS ─── */
.bottom-tabs{position:fixed;bottom:0;left:0;right:0;height:calc(60px + var(--safe-bottom));background:var(--surface);border-top:1px solid var(--border);display:flex;align-items:flex-start;padding-top:8px;z-index:100}
.btab{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;font-size:9px;font-weight:600;color:var(--muted);cursor:pointer;border:none;background:none;padding:4px 2px}
.btab .btab-icon{font-size:18px}
.btab.active{color:var(--accent)}

/* ─── PAGE / CONTENT ─── */
.page{display:none;padding:20px;max-width:900px;margin:0 auto}
.page.active{display:block}
.page-title{font-size:22px;font-weight:800;margin-bottom:4px}
.page-sub{font-size:13px;color:var(--muted);margin-bottom:20px}

/* CRM pleine largeur */
#page-crm{max-width:none;padding:24px 32px}

/* ─── CARDS / INPUTS ─── */
.card{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:18px;margin-bottom:16px}
.card-title{font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.6px;margin-bottom:14px}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.grid3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:12px}
@media(max-width:600px){.grid2,.grid3{grid-template-columns:1fr}}
.field{display:flex;flex-direction:column;gap:5px}
.field label{font-size:12px;color:var(--muted);font-weight:600}
.field input,.field select,.field textarea{background:var(--surface2);border:1px solid var(--border);border-radius:9px;padding:10px 12px;font-size:14px;color:var(--text);outline:none;transition:border .2s;font-family:inherit;width:100%}
.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--accent)}
.field textarea{resize:vertical;min-height:80px}
.field select option{background:var(--surface2)}
.toggle-row{display:flex;align-items:center;gap:10px}
.toggle{width:42px;height:24px;background:var(--surface2);border-radius:12px;border:1px solid var(--border);cursor:pointer;position:relative;transition:background .2s}
.toggle.on{background:var(--accent)}
.toggle::after{content:'';position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .2s}
.toggle.on::after{left:21px}

/* ─── BUTTONS ─── */
.btn{display:inline-flex;align-items:center;gap:8px;padding:11px 18px;border-radius:10px;font-size:14px;font-weight:600;cursor:pointer;border:none;transition:all .15s;font-family:inherit}
.btn-primary{background:var(--accent);color:#fff}
.btn-primary:hover{background:#2563eb}
.btn-secondary{background:var(--surface2);color:var(--text);border:1px solid var(--border)}
.btn-secondary:hover{background:var(--border)}
.btn-green{background:var(--green);color:#fff}
.btn-red{background:var(--red);color:#fff}
.btn-orange{background:var(--accent2);color:#fff}
.btn-purple{background:var(--purple);color:#fff}
.btn-sm{padding:7px 12px;font-size:12px;border-radius:8px}
.btn-full{width:100%;justify-content:center}
.btn-row{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.mic-btn{background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:10px;font-size:20px;cursor:pointer;transition:all .2s}
.mic-btn.recording{background:rgba(239,68,68,.2);border-color:var(--red);animation:pulse 1s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.5}}

/* ─── URL RESULTS ─── */
.url-cards{display:flex;flex-direction:column;gap:10px;margin-top:14px}
.url-card{background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:14px}
.url-card-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
.url-card-head strong{font-size:14px}
.url-card-actions{display:flex;gap:8px}
.url-card-actions .btn-open{background:var(--accent);color:#fff;border:none;border-radius:9px;padding:10px 16px;font-size:13px;font-weight:700;cursor:pointer;display:flex;align-items:center;gap:6px}
.url-card-actions .btn-open:hover{background:#2563eb}
.url-card-actions .btn-copy{background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:9px;padding:10px 16px;font-size:13px;font-weight:700;cursor:pointer;display:flex;align-items:center;gap:6px}
.url-card-actions .btn-copy:hover{border-color:var(--accent);color:var(--accent)}
.url-pill{font-size:11px;color:var(--muted);word-break:break-all;margin-bottom:8px;font-family:monospace}

/* ─── AI RESULT ─── */
.ai-result{background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:16px;margin-top:12px}
.ai-result-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}
.ai-result-head span{font-size:12px;color:var(--muted);font-weight:600}
.ai-content{white-space:pre-wrap;font-size:13px;line-height:1.7;color:var(--text)}
.hidden{display:none}
.loading{display:flex;align-items:center;gap:10px;color:var(--muted);font-size:13px;padding:16px}
.spinner{width:18px;height:18px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ─── CRM STYLES ─── */
.crm-tabs{display:flex;gap:6px;margin-bottom:16px;flex-wrap:wrap}
.crm-tab{padding:7px 14px;border-radius:8px;font-size:12px;font-weight:600;cursor:pointer;border:1px solid var(--border);background:var(--surface2);color:var(--muted);transition:all .15s}
.crm-tab.active{background:var(--accent);color:#fff;border-color:var(--accent)}
.crm-record{background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:14px;margin-bottom:10px;cursor:pointer;transition:border .15s}
.crm-record:hover,.crm-record.selected{border-color:var(--accent)}
.crm-record-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin-bottom:8px}
.crm-record-title{font-size:14px;font-weight:700;flex:1}
.crm-record-meta{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.badge{display:inline-flex;align-items:center;padding:3px 8px;border-radius:6px;font-size:11px;font-weight:600}
.badge-score{background:rgba(59,130,246,.2);color:var(--accent)}
.badge-statut{background:var(--surface);border:1px solid var(--border);color:var(--text)}
.badge-temp{background:rgba(239,68,68,.15);color:var(--red)}
.crm-record-notes{font-size:12px;color:var(--muted);margin-top:6px;font-style:italic}
.crm-record-footer{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}
.crm-action-panel{background:rgba(59,130,246,.05);border:1px solid rgba(59,130,246,.2);border-radius:10px;padding:16px;margin-bottom:16px}
.crm-action-panel h3{font-size:14px;font-weight:700;margin-bottom:12px;color:var(--accent)}
.statut-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px;margin-bottom:12px}
.statut-btn{padding:8px 10px;border-radius:8px;font-size:12px;font-weight:600;cursor:pointer;border:1px solid var(--border);background:var(--surface2);color:var(--text);text-align:center;transition:all .15s}
.statut-btn:hover{border-color:var(--accent);color:var(--accent)}
.crm-note-row{display:flex;gap:8px;margin-top:10px}
.crm-note-row input{flex:1;background:var(--surface2);border:1px solid var(--border);border-radius:8px;padding:9px 12px;font-size:13px;color:var(--text);outline:none;font-family:inherit}
.crm-note-row input:focus{border-color:var(--accent)}
.voice-cmd-area{background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:12px;margin-bottom:14px}
.voice-cmd-display{font-size:14px;color:var(--text);min-height:24px;font-style:italic}
.voice-cmd-status{font-size:11px;color:var(--muted);margin-top:4px}
.crm-stats{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-bottom:16px}
@media(max-width:600px){.crm-stats{grid-template-columns:repeat(2,1fr)}}
.stat-box{background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:12px;text-align:center}
.stat-box .stat-n{font-size:24px;font-weight:800}
.stat-box .stat-l{font-size:11px;color:var(--muted);margin-top:2px}
.warning-box{background:rgba(239,68,68,.1);border:1px solid rgba(239,68,68,.3);border-radius:10px;padding:14px;margin-bottom:16px}
.warning-box h3{color:var(--red);font-size:13px;font-weight:700;margin-bottom:8px}

/* ─── LINKEDIN STYLES ─── */
.post-preview{background:linear-gradient(135deg,#0f172a,#1e2d4a);border:1px solid var(--border);border-radius:14px;padding:20px;margin-top:12px}
.post-preview-header{display:flex;align-items:center;gap:10px;margin-bottom:14px}
.avatar{width:40px;height:40px;border-radius:50%;background:var(--accent);display:flex;align-items:center;justify-content:center;font-weight:800;font-size:16px}
.post-preview-name{font-size:14px;font-weight:700;color:#f1f5f9}
.post-preview-sub{font-size:11px;color:#94a3b8}
.post-preview-content{font-size:14px;line-height:1.7;white-space:pre-wrap;color:#e2e8f0}
.canva-prompt{background:rgba(168,85,247,.1);border:1px solid rgba(168,85,247,.3);border-radius:10px;padding:14px;margin-top:12px}
.canva-prompt h4{font-size:12px;font-weight:700;color:var(--purple);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}
.canva-prompt p{font-size:13px;line-height:1.6;color:var(--text)}

/* ─── PROSPECTION BATCH ─── */
.url-list-input{background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:12px;font-size:13px;color:var(--text);width:100%;min-height:160px;resize:vertical;outline:none;font-family:monospace;line-height:1.6}
.url-list-input:focus{border-color:var(--accent)}
.url-count-badge{display:inline-block;background:var(--accent);color:#fff;font-size:12px;font-weight:700;padding:2px 8px;border-radius:6px;margin-left:8px}
.send-log{background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:12px;margin-top:12px;font-size:12px;font-family:monospace;color:var(--text);max-height:200px;overflow-y:auto}

/* ─── TOAST ─── */
#toast{position:fixed;bottom:calc(80px + var(--safe-bottom));left:50%;transform:translateX(-50%) translateY(20px);background:#1e293b;color:#f1f5f9;padding:10px 20px;border-radius:20px;font-size:13px;font-weight:600;opacity:0;transition:all .3s;pointer-events:none;z-index:999;border:1px solid var(--border)}
#toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
#toast.error{background:rgba(239,68,68,.9);border-color:var(--red)}

/* ─── MISC ─── */
.section-sep{height:1px;background:var(--border);margin:20px 0}
.info-box{background:rgba(59,130,246,.08);border:1px solid rgba(59,130,246,.2);border-radius:10px;padding:12px 14px;font-size:13px;color:var(--muted);margin-bottom:14px}
.info-box strong{color:var(--accent)}
hr{border:none;border-top:1px solid var(--border);margin:16px 0}
/* ─── PAGE PRIX 2 colonnes desktop ─── */
@media (max-width: 899px) {
  #prix-layout { flex-direction: column !important; }
  #prix-result-col { width: 100% !important; position: static !important; }
}
@media (min-width: 900px) {
  #prix-result-col { width: 380px !important; }
}
.crm2-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .15s;
}
.crm2-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.crm2-tab:hover:not(.active) {
  border-color: var(--accent);
  color: var(--accent);
}
.crm2-panel { min-height: 80px; }
.crm2-panel.hidden { display: none; }

.crm2-record {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color .15s;
}
.crm2-record:hover, .crm2-record.selected {
  border-color: var(--accent);
}
.crm2-record-panel {
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 10px 10px;
  margin-top: -6px;
  margin-bottom: 6px;
}
.crm2-record-panel.hidden { display: none; }

/* ── TODO 2 colonnes ── */
@media (max-width: 700px) {
  .todo-2col {
    grid-template-columns: 1fr !important;
  }
  /* #19 Cacher flèches sur mobile — swipe suffit */
  .todo-arrow-left, .todo-arrow-right {
    display: none !important;
  }
  #crm2-panel-todo {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
}

/* Desktop large : TODO 2 colonnes équilibrées avec plus d'espace */
@media (min-width: 1200px) {
  .todo-2col {
    grid-template-columns: 3fr 2fr !important;
    gap: 16px !important;
  }
}
@media (min-width: 1500px) {
  .todo-2col {
    grid-template-columns: 3fr 2fr !important;
    gap: 20px !important;
  }
  /* Carte véhicule : plus haute sur grands écrans */
  #crm2-panel-todo .todo-2col > div:first-child > div {
    min-height: 480px;
  }
  /* Zone notes agrandie */
  #crm2-panel-todo textarea {
    min-height: 100px !important;
  }
}

/* Flèches overlay : marge pour ne pas déborder */
#crm2-panel-todo {
  padding-left: 24px;
  padding-right: 24px;
}
@media (max-width: 899px) {
  #crm2-panel-todo {
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
}

/* KPIs : 5 colonnes fixes sur desktop, s'adaptent */
@media (min-width: 900px) {
  #page-crm .crm-kpi-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* CRM record dans les listes : 2 colonnes sur desktop large */
@media (min-width: 1400px) {
  #crm2-panel-nouveau .crm2-records-grid,
  #crm2-panel-relancer .crm2-records-grid,
  #crm2-panel-retours .crm2-records-grid,
  #crm2-panel-suivi .crm2-records-grid,
  #crm2-panel-passe .crm2-records-grid,
  #crm2-panel-perdus .crm2-records-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}
