/* =====================================================================
   Phénix App — feuille de style
   Couleurs : bleu nuit + orange (logo). Fond blanc, mode sombre via le bouton lune.
   Ordinateur : menu à gauche. Téléphone (≤ 860 px) : en-tête en haut + onglets en bas.
   ===================================================================== */

:root {
  --navy: #141628;
  --navy-2: #1c1f3d;
  --navy-3: #262a52;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f6fa;
  --surface-3: #eceef5;
  --border: #e4e6ef;
  --border-2: #d5d8e4;
  --text: #141628;
  --text-2: #545a78;
  --text-3: #8a8fa9;
  --accent: #f26b1d;
  --accent-2: #ff8a3d;
  --accent-hover: #dd5a0e;
  --accent-soft: #fff3eb;
  --accent-text: #c04a08;
  --ok: #16a34a;
  --ok-soft: #e9f8ef;
  --gold: #d97706;
  --gold-soft: #fff6e0;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --opp: #0e9f6e;
  --opp-soft: #e3f8f0;
  --sidebar-text: #c3c7de;
  --tab-on: var(--navy);
  --tab-on-text: #ffffff;
  --shadow-sm: 0 1px 2px rgba(20, 22, 40, .06);
  --shadow: 0 1px 2px rgba(20, 22, 40, .04), 0 4px 14px rgba(20, 22, 40, .06);
  --shadow-lg: 0 18px 48px rgba(20, 22, 40, .18);
  --radius: 14px;
  --radius-sm: 10px;
  --h: 40px; /* hauteur des boutons et champs */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d0e1b;
  --surface: #151729;
  --surface-2: #1c1f36;
  --surface-3: #252946;
  --border: #282c4a;
  --border-2: #353a5e;
  --text: #eceef7;
  --text-2: #a7abc6;
  --text-3: #767b9c;
  --accent: #f77a2e;
  --accent-hover: #ff8a40;
  --accent-soft: #2c1a10;
  --accent-text: #ffaa6c;
  --ok-soft: #0f2a1b;
  --gold-soft: #2e2210;
  --danger-soft: #341515;
  --opp: #34d399;
  --opp-soft: #0d2a22;
  --tab-on: var(--accent);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 14px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
svg { flex: none; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
code { font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Mise en page ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.main { padding: 28px 32px 64px; min-width: 0; outline: none; max-width: 1400px; width: 100%; }

/* ---------- Menu (ordinateur) ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 18px 14px 14px; color: var(--sidebar-text);
  background: linear-gradient(180deg, #181b38 0%, var(--navy) 55%, #0f1024 100%);
  border-right: 1px solid #ffffff0d;
}
:root[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #11132a 0%, #0a0b18 100%); }
.brand { display: block; padding: 0 2px 18px; text-decoration: none !important; }
.brand-img { display: block; width: 100%; max-width: 212px; height: auto; border-radius: 12px; }
.brand-fallback { display: flex; flex-direction: column; padding: 6px 8px; }
.brand-name { color: #fff; font-weight: 800; font-size: 17px; }
.brand-sub { font-size: 12px; color: var(--text-3); }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--sidebar-text); text-decoration: none; font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: #ffffff0f; color: #fff; }
.nav a.active { background: linear-gradient(90deg, #f26b1d26, #f26b1d0a); color: #fff; font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.nav a.active .ico { color: var(--accent-2); }
.nav .ico { width: 20px; height: 20px; display: inline-flex; }
.nav .ico svg, .side-btn svg, .icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav .lbl-court { display: none; }
.nav a[data-equipe] { margin-top: 10px; }
.nav a[data-equipe] + a[data-equipe] { margin-top: 0; }

.sidebar-actions { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 12px; border-top: 1px solid #ffffff12; }
.side-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--sidebar-text); cursor: pointer; font-weight: 500; text-align: left; text-decoration: none !important;
}
.side-btn:hover { background: #ffffff10; color: #fff; }
.side-btn small { display: block; font-size: 11px; color: #8a8fb0; font-weight: 400; }
.side-btn.whatsapp svg { color: #25d366; }
.side-btn.email svg { color: var(--accent-2); }
.sidebar-foot { font-size: 10.5px; color: #6f7496; padding: 10px 12px 0; }

/* En-tête : uniquement sur téléphone */
.topbar { display: none; }

/* ---------- En-têtes de page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--h); padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--surface);
  cursor: pointer; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: var(--accent); color: #fff;
  box-shadow: 0 1px 2px rgba(242, 107, 29, .25), 0 4px 12px rgba(242, 107, 29, .22);
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.ok { color: var(--ok); border-color: #16a34a55; background: var(--ok-soft); }
.big-btn { width: 100%; height: 46px; font-size: 15px; margin-bottom: 6px; }

.btn-prospecte { min-width: 128px; color: var(--text-2); }
.btn-prospecte.on { background: var(--ok); border-color: var(--ok); color: #fff; box-shadow: 0 3px 10px #16a34a40; }
.btn-prospecte.on:hover { background: #15803d; }
.btn-prospecte.big { height: 46px; flex: 1; font-size: 15px; }
.btn-client { height: 46px; background: var(--gold-soft); border-color: #d9770666; color: var(--gold); font-weight: 700; }
.btn-client:hover { background: #ffeec2; }
.statut-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Champs ---------- */
.input {
  height: var(--h); padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-2);
  background: var(--surface); min-width: 0; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #f26b1d26; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 76px; line-height: 1.5; }
select.input { padding-right: 28px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; white-space: nowrap; }
.check input, .choix input { accent-color: var(--accent); width: 16px; height: 16px; }
.field-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }

/* ---------- Barres de filtres ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.filters .grow { flex: 1 1 240px; }
.filters-avances { background: var(--surface-2); box-shadow: none; border-style: dashed; margin-top: -6px; }

/* Liste déroulante à choix multiples */
.ms { position: relative; }
.ms-btn {
  height: var(--h); display: inline-flex; align-items: center; gap: 8px; padding: 0 10px 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--surface); cursor: pointer;
  max-width: 300px; white-space: nowrap; line-height: 1;
}
.ms-btn:hover { border-color: var(--text-3); }
.ms-btn::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg) translateY(-2px); flex: none; margin-left: 2px; }
.ms-label { flex: none; color: var(--text-2); font-size: 13px; }
.ms-val { min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ms-count {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.ms.active .ms-btn { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ms.active .ms-val { color: var(--accent-text); }
.ms-pop {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; min-width: 260px; max-width: 360px;
}
.ms.open .ms-pop { display: block; animation: pop .14s ease; }
.ms-actions { display: flex; gap: 4px; padding: 2px 2px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ms-actions button { border: 0; background: var(--surface-2); border-radius: 6px; padding: 4px 9px; cursor: pointer; font-size: 12px; font-weight: 600; }
.ms-actions button:hover { background: var(--surface-3); }
.ms-search { width: 100%; margin-bottom: 4px; height: 36px; }
.ms-list { max-height: 320px; overflow: auto; overscroll-behavior: contain; }
.ms-opt { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; }
.ms-opt:hover { background: var(--surface-2); }
.ms-opt input { accent-color: var(--accent); }
.ms-group {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; cursor: pointer;
  padding: 8px 8px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); text-align: left;
}
.ms-group:hover { color: var(--text); }
.ms-group:not(:first-child) { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; }
.ms-opt .dot, .ms-group .dot, .badge.secteur .dot, .tab .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---------- Cartes, badges, encadrés ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.empty { color: var(--text-2); padding: 34px 20px; text-align: center; line-height: 1.7; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge.secteur { background: var(--surface-2); color: var(--text); font-weight: 500; }
.badge-opp {
  display: inline-flex; align-items: center; padding: 1px 8px; margin-left: 6px; border-radius: 999px; vertical-align: 1px;
  background: var(--opp-soft); color: var(--opp); font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-client {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px;
  background: linear-gradient(180deg, #fff4d6, #ffe7a8); color: #8a4b02; font-weight: 700; font-size: 13px; white-space: nowrap;
  border: 1px solid #f0c45c;
}
:root[data-theme="dark"] .badge-client { background: linear-gradient(180deg, #3b2a0c, #2e2109); color: #ffd27a; border-color: #6b4e14; }
.badge-client.grand { height: 46px; font-size: 15px; padding: 0 16px; }
.bloc-client { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dot-inline { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: 8px; }

.info-criteres {
  display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; padding: 12px 16px;
  border: 1px solid #f26b1d33; border-left: 4px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--accent-soft); font-size: 13px; line-height: 1.55;
}
.info-criteres.complet { border-color: #14162833; border-left-color: var(--navy); background: var(--surface-2); }
:root[data-theme="dark"] .info-criteres.complet { border-left-color: var(--accent); }
.info-ico {
  flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
:root[data-theme="dark"] .info-ico { background: var(--accent); }

.bulkbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px;
  background: var(--accent-soft); border: 1px solid #f26b1d55; border-radius: var(--radius-sm);
}

/* ---------- Résumé de la semaine ---------- */
.resume {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px 12px; margin-bottom: 14px;
}
.resume-ligne { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px; }
.resume-titre { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-right: 4px; }
.stat { font-size: 14px; color: var(--text-2); white-space: nowrap; }
.stat strong { font-size: 20px; font-weight: 800; color: var(--text); margin-right: 3px; font-variant-numeric: tabular-nums; }
.stat.ok strong { color: var(--ok); }
.stat.client strong { color: var(--gold); }
.stat.opp strong { color: var(--opp); }
.stat.refaire strong { color: var(--accent); }
.badge-opp.refaire { background: var(--accent-soft); color: var(--accent); }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ok), #4ade80); transition: width .3s ease; }

/* ---------- Semaine + onglets ---------- */
.week { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.week .week-select { height: var(--h); font-weight: 600; font-size: 14.5px; min-width: 0; max-width: 100%; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; font-weight: 600; color: var(--text-2);
}
.tab:hover { color: var(--text); border-color: var(--text-3); }
.tab.on { background: var(--tab-on); color: var(--tab-on-text); border-color: var(--tab-on); }
.tab-n { font-size: 12px; font-weight: 700; opacity: .7; }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-sm); }
.seg button { border: 0; background: transparent; padding: 0 14px; height: 38px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--navy); color: #fff; }
:root[data-theme="dark"] .seg button.on { background: var(--accent); }

/* ---------- Tableaux ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th {
  font-size: 11.5px; font-weight: 700; color: var(--text-3); background: var(--surface-2); text-transform: uppercase; letter-spacing: .04em;
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
tbody tr.done { opacity: .55; }
tbody tr.ligne-client { background: linear-gradient(90deg, #fff7e3, transparent 60%); }
:root[data-theme="dark"] tbody tr.ligne-client { background: linear-gradient(90deg, #2a2010, transparent 60%); }
td .title { font-weight: 650; font-weight: 600; font-size: 14.5px; }
td .sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
td.check-cell, th.check-cell { width: 40px; }
td.check-cell input, th.check-cell input { accent-color: var(--accent); width: 16px; height: 16px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 440px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 2px; gap: 10px; flex-wrap: wrap; }
.results-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 12px; gap: 10px; flex-wrap: wrap; }
a.addr { color: inherit; display: block; min-width: 160px; }
a.addr:hover { color: var(--accent-text); text-decoration: none; }
a.addr:hover div:first-child { text-decoration: underline; }
.fiche-links { display: inline-flex; gap: 4px; flex-wrap: wrap; vertical-align: middle; }
.fiche-links a:hover { text-decoration: none; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 28px; justify-content: center; }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Panneau latéral (fiche) ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 24, .45); backdrop-filter: blur(2px); z-index: 50; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; height: 100dvh; width: min(660px, 100vw); z-index: 60;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { padding: 20px 22px 14px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 20px; font-weight: 800; }
.drawer-body { padding: 18px 22px; overflow: auto; flex: 1; overscroll-behavior: contain; }
.drawer-foot { padding: 12px 22px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: space-between; background: var(--surface); }
.links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.links a { font-size: 12.5px; padding: 4px 10px; border: 1px solid var(--border-2); border-radius: 999px; color: var(--text-2); }
.links a:hover { color: var(--accent-text); border-color: var(--accent); text-decoration: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.form-grid .input { color: var(--text); font-size: 14px; }
.section-title { font-size: 12px; font-weight: 700; margin: 24px 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.fiche-hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 11px 13px; border-radius: var(--radius-sm); background: var(--accent-soft); line-height: 1.5; }
.choix-site { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.choix-site legend { padding: 0 6px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.choix { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text); }
.choix.opp { color: var(--opp); font-weight: 600; }
.choix.refaire { color: var(--accent); font-weight: 600; }
details.more { margin-top: 20px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 14px; }
details.more summary { cursor: pointer; padding: 13px 0; font-weight: 600; color: var(--text-2); }
details.more[open] { padding-bottom: 14px; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; font-size: 13.5px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.tl-item .tl-type { font-weight: 700; }
.tl-item .tl-date { color: var(--text-3); font-size: 12px; }
.tl-item.statut .tl-type { color: var(--text-3); }
.add-interaction { display: grid; grid-template-columns: 150px 1fr; gap: 8px; margin-bottom: 14px; }
.add-interaction textarea { grid-column: 1 / -1; }
.add-interaction .row-end { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

/* ---------- Carte (Leaflet) ---------- */
.map { height: 600px; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; z-index: 0; box-shadow: var(--shadow); }
.popup { min-width: 210px; font: 13px/1.45 var(--font); }
.popup .title { font-weight: 700; font-size: 14px; }
.popup .sub { color: #5b6080; font-size: 12px; }
.leaflet-popup-content a.addr { color: inherit; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: brightness(.75) contrast(1.1) saturate(.8); }
:root[data-theme="dark"] .leaflet-popup-content-wrapper, :root[data-theme="dark"] .leaflet-popup-tip { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .popup .sub { color: var(--text-2); }

/* ---------- Méthodes de vente ---------- */
.fiches { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-bottom: 8px; }
.fiche { text-align: left; cursor: pointer; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 8px; min-height: 150px; transition: border-color .15s, transform .15s, box-shadow .15s; }
.fiche:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.fiche-titre { font-weight: 700; font-size: 15.5px; }
.fiche-apercu { color: var(--text-2); font-size: 13px; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.fiche-date { font-size: 11.5px; color: var(--text-3); }
.fiche-contenu { min-height: 380px; font-size: 14px; line-height: 1.6; }

/* ---------- Guide d'installation ---------- */
.guide p { margin: 0 0 10px; line-height: 1.55; }
.guide .etapes { margin: 0 0 6px; padding-left: 22px; line-height: 1.7; }
.guide-adresse code { font-size: 15px; font-weight: 700; padding: 7px 11px; border-radius: 8px; background: var(--surface-2); display: inline-block; }
.qr { margin: 12px 0; padding: 10px; background: #fff; border-radius: 12px; width: max-content; border: 1px solid var(--border); }
.kbd { display: inline-block; min-width: 22px; padding: 0 6px; border: 1px solid var(--border-2); border-radius: 5px; background: var(--surface-2); text-align: center; font-size: 12px; }

/* ---------- Connexion ---------- */
.login {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 25% 15%, #2a2e5c 0%, var(--navy) 50%, #090a16 100%);
}
.login::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 80% 85%, #f26b1d33, transparent 40%); pointer-events: none; }
.login-carte {
  position: relative; width: min(400px, 100%); background: var(--surface); color: var(--text); border-radius: 20px; padding: 30px 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5); display: flex; flex-direction: column; gap: 12px;
}
.login-logo { width: 230px; max-width: 100%; align-self: center; border-radius: 14px; margin-bottom: 6px; }
.login-carte h1 { font-size: 21px; text-align: center; font-weight: 800; }
.login-carte > p { margin: -6px 0 4px; text-align: center; font-size: 13px; }
.login-carte label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.login-carte .input { height: 44px; font-size: 15px; }
.login-carte .mdp { display: flex; gap: 6px; }
.login-carte .mdp .input { flex: 1; }
.login-carte .mdp .btn { height: 44px; }
.login-carte label.login-souvenir { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.login-btn { height: 46px; font-size: 15px; margin-top: 4px; }
.login-erreur { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 9px 11px; font-size: 13px; font-weight: 600; }
.login-ok { background: var(--ok-soft); color: var(--ok); border-radius: 8px; padding: 9px 11px; font-size: 13px; font-weight: 600; }
.login-lien { border: 0; background: none; color: var(--accent-text); cursor: pointer; font-size: 13px; font-weight: 600; padding: 4px; align-self: center; }
.login-lien:hover { text-decoration: underline; }

/* ---------- Notifications ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 600; max-width: 380px; animation: pop .18s ease; }
.toast.error { background: var(--danger); }
:root[data-theme="dark"] .toast:not(.error) { background: var(--surface-3); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =====================================================================
   Tablette
   ===================================================================== */
@media (max-width: 1100px) {
  .main { padding: 22px 22px 56px; }
  .app { grid-template-columns: 220px minmax(0, 1fr); }
}

/* =====================================================================
   Téléphone : en-tête en haut, onglets en bas, tableaux en cartes
   ===================================================================== */
@media (max-width: 860px) {
  :root { --h: 44px; } /* zones tactiles plus grandes */
  .app { display: block; }

  /* En-tête */
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    position: sticky; top: 0; z-index: 30; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
    background: var(--navy); box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  }
  .topbar-logo img { display: block; height: 38px; width: auto; border-radius: 8px; }
  .topbar-actions { display: flex; gap: 2px; }
  .icon-btn {
    width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 10px; background: transparent; color: var(--sidebar-text); cursor: pointer;
  }
  .icon-btn:hover, .icon-btn:active { background: #ffffff14; color: #fff; }
  .icon-btn.whatsapp { color: #25d366; }
  .icon-btn.email { color: var(--accent-2); }

  /* Le menu devient une barre d'onglets en bas */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 40;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid #ffffff14;
    background: var(--navy); box-shadow: 0 -4px 18px rgba(0, 0, 0, .25);
  }
  .brand, .sidebar-actions, .sidebar-foot { display: none; }
  .nav { flex-direction: row; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 1 0 64px; flex-direction: column; gap: 3px; padding: 7px 4px; font-size: 11px; text-align: center; border-radius: 10px; }
  .nav a[data-equipe] { margin-top: 0; }
  .nav a.active { background: #f26b1d1f; }
  .nav a.active::before { left: 25%; right: 25%; top: -6px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .nav .lbl { display: none; }
  .nav .lbl-court { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav .ico, .nav .ico svg { width: 22px; height: 22px; }

  .main { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 14px; align-items: flex-start; }
  .page-head h1 { font-size: 22px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn.primary { flex: 1; }

  /* Filtres empilés, pleine largeur */
  .filters { padding: 8px; gap: 6px; }
  .filters > * { flex: 1 1 100%; }
  .filters > .btn, .filters > select.input { flex: 1 1 calc(50% - 6px); }
  .filters .ms, .filters .ms-btn { width: 100%; max-width: none; }
  .filters .check { flex: 1 1 calc(50% - 6px); white-space: normal; font-size: 13px; }
  .ms-pop { min-width: 0; width: 100%; max-width: none; }

  .week { flex-wrap: nowrap; }
  .week .week-select { flex: 1; width: 0; font-size: 14px; }
  .week [data-w="0"] { display: none; }
  .resume { padding: 12px 14px 10px; }
  .resume-ligne { gap: 6px 14px; }
  .resume-titre { flex: 1 1 100%; }
  .stat strong { font-size: 18px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -14px; margin-right: -14px; padding: 0 14px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; }

  /* Tableaux → cartes empilées */
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    position: relative; margin-bottom: 10px; padding: 12px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  }
  .table-wrap tbody tr:hover { background: var(--surface); }
  .table-wrap td { border: 0; padding: 4px 0; }
  .table-wrap td:empty { display: none; }
  .table-wrap td.check-cell { position: absolute; top: 12px; right: 10px; width: auto; padding: 0; }
  .table-wrap td.check-cell input { width: 22px; height: 22px; }
  .table-wrap td.cell-titre, .table-wrap tr > td:nth-child(2) { padding-right: 34px; }
  .table-wrap td[data-label]::before {
    content: attr(data-label); display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-3); margin-bottom: 2px;
  }
  .table-wrap td.cell-statut, .table-wrap td.nowrap:last-child { padding-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
  .table-wrap td.cell-statut .btn-prospecte, .table-wrap td.cell-statut .badge-client { flex: 1; height: 42px; justify-content: center; }
  .table-wrap tbody tr td[colspan] { text-align: center; }
  .clamp { max-width: none; }
  a.addr { min-width: 0; }

  /* Panneau : plein écran, comme une page */
  .drawer { width: 100vw; border-left: 0; }
  .drawer-head { padding: calc(14px + env(safe-area-inset-top)) 16px 12px; }
  .drawer-body { padding: 14px 16px; }
  .drawer-foot { padding-left: 16px; padding-right: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .add-interaction { grid-template-columns: 1fr; }
  .tl-item { grid-template-columns: 1fr auto; }
  .tl-item > div:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .statut-actions > * { flex: 1 1 100%; }

  .map { height: 62vh; }
  .fiches { grid-template-columns: 1fr; }
  .toasts { left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); align-items: center; }
  .toast { max-width: 100%; }
  .info-criteres { font-size: 12.5px; padding: 10px 12px; }
}

/* ---------- Tâches (kanban) ---------- */
.tache-ajout { display: grid; grid-template-columns: minmax(180px, 1fr) 2fr auto; gap: 10px; align-items: start; margin-bottom: 18px; }
.tache-ajout textarea { resize: vertical; min-height: 40px; }
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.kanban-col {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
  min-height: 160px; border-top: 4px solid var(--text-3); transition: box-shadow .15s, border-color .15s;
}
.kanban-col.col-a_faire { border-top-color: var(--accent); }
.kanban-col.col-en_cours { border-top-color: var(--gold); }
.kanban-col.col-termine { border-top-color: var(--ok); }
.kanban-col.survol { box-shadow: 0 0 0 2px var(--accent) inset; }
.kanban-col header { display: flex; align-items: center; justify-content: space-between; margin: 2px 4px 12px; }
.kanban-titre { font-weight: 700; font-size: 15px; }
.kanban-nb { min-width: 26px; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--text-2); }
.kanban-liste { display: flex; flex-direction: column; gap: 10px; }
.kanban-vide { color: var(--text-3); font-size: 13px; text-align: center; padding: 18px 0; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.tache { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 12px 8px; box-shadow: var(--shadow); cursor: grab; }
.tache.glisse { opacity: .45; }
.tache.edition { display: flex; flex-direction: column; gap: 8px; cursor: default; padding-bottom: 12px; }
.tache-entreprise { font-weight: 700; font-size: 15px; word-break: break-word; }
.tache-message { margin-top: 5px; color: var(--text-2); font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.col-termine .tache-entreprise { text-decoration: line-through; text-decoration-color: var(--text-3); }
.tache-actions { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.tache-actions .espace { flex: 1; }
.tache-actions .btn.sm { height: 30px; padding: 0 9px; }
.tache-actions .btn:disabled { opacity: .35; cursor: default; }
.tache .btn.ghost.danger { color: var(--danger); }
.tache .btn.ghost.danger:hover { background: var(--danger-soft); }

@media (max-width: 860px) {
  .tache-ajout { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .kanban-col { min-height: 0; }
  .tache { cursor: default; }
  .tache-actions .btn.sm { height: 36px; padding: 0 12px; }
}
