/* =========================================================
   CRM interne — feuille de style unique
   Toutes les couleurs sont des variables (thème clair + sombre)
   ========================================================= */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef0f5;
  --border: #e4e7ee;
  --border-strong: #d3d8e2;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;
  --on-accent: #ffffff;
  --success: #059669;
  --success-soft: #e7f8f1;
  --warning: #b45309;
  --warning-soft: #fef5e6;
  --danger: #dc2626;
  --danger-soft: #fdeeee;
  --info: #0284c7;
  --info-soft: #e8f5fc;

  --side-bg: #0f1424;
  --side-text: #a5adc2;
  --side-text-strong: #ffffff;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(129, 140, 248, .16);

  /* Étapes du pipeline */
  --st-nouveau: #8b5cf6;
  --st-contact: #0ea5e9;
  --st-attente_infos: #64748b;
  --st-devis: #f59e0b;
  --st-gagne: #10b981;
  --st-enquete: #06b6d4;
  --st-rapport: #6366f1;
  --st-med: #ef4444;
  --st-clos: #475569;
  --st-non_rentable: #a16207;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .16);
  --avatar-l: 92%;
  --avatar-t: 32%;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e17;
    --surface: #131827;
    --surface-2: #171d2e;
    --surface-3: #1d2437;
    --border: #232b40;
    --border-strong: #2e3750;
    --text: #e8ebf3;
    --text-2: #c3c9d8;
    --muted: #8f99b0;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #1f2447;
    --accent-text: #a5b4fc;
    --on-accent: #0b0e17;
    --success: #34d399;
    --success-soft: #0f2a22;
    --warning: #fbbf24;
    --warning-soft: #2e2410;
    --danger: #f87171;
    --danger-soft: #331819;
    --info: #38bdf8;
    --info-soft: #0f2533;
    --side-bg: #080b13;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, .02);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    --avatar-l: 24%;
    --avatar-t: 82%;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.02rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
code { font-size: .85em; background: var(--surface-3); padding: .1em .35em; border-radius: 5px; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.xs { font-size: .76rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.strong { font-weight: 600; }
.overdue { color: var(--danger); }
.row { display: flex; gap: .75rem; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Icônes (sprite SVG dans header.ejs) */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.i.sm { width: 15px; height: 15px; vertical-align: -2px; }
.i.lg { width: 22px; height: 22px; }

/* ---------- Mise en page ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.app.no-nav { grid-template-columns: minmax(0, 1fr); }

.sidebar {
  background: var(--side-bg);
  overflow-x: hidden;
  color: var(--side-text);
  padding: 1.1rem .8rem;
  display: flex; flex-direction: column; gap: .15rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--side-text-strong); font-weight: 700; font-size: 1rem; padding: .2rem .55rem 1.1rem; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-banner { display: block; padding: .1rem .15rem 1rem; min-width: 0; }
.brand-banner img { display: block; width: 100%; max-width: 100%; height: auto; border-radius: 12px; box-shadow: 0 4px 18px rgba(34, 211, 238, .18); }
.auth-brand img.auth-emblem { border-radius: 50%; box-shadow: 0 0 22px rgba(34, 211, 238, .35); }
.brand-logo { width: 34px; height: 34px; flex: none; border-radius: 10px; box-shadow: 0 4px 14px rgba(99, 102, 241, .35); }
.brand-name { display: block; font-size: 1.05rem; font-weight: 800; letter-spacing: .06em; line-height: 1.1; }
.brand-sub { display: block; font-size: .72rem; font-weight: 500; color: var(--side-text); max-width: 160px; }
.auth-brand { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.6rem; }
.auth-brand img { border-radius: 16px; box-shadow: 0 8px 24px rgba(99, 102, 241, .35); }
.auth-name { font-size: 1.5rem; font-weight: 800; letter-spacing: .05em; line-height: 1.1; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; font-size: .85rem; font-weight: 800; flex: none; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #5d6680; padding: .9rem .65rem .35rem; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .52rem .65rem; border-radius: 9px; color: var(--side-text); font-weight: 500;
  position: relative;
}
.nav a:hover { background: var(--side-hover); color: var(--side-text-strong); text-decoration: none; }
.nav a.active { background: var(--side-active); color: var(--side-text-strong); }
.nav a.active::before { content: ""; position: absolute; left: -.8rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #818cf8; }
.nav .count { margin-left: auto; background: #ef4444; color: #fff; border-radius: 999px; font-size: .7rem; padding: .05rem .45rem; font-weight: 700; min-width: 20px; text-align: center; }
.nav .count.violet { background: #8b5cf6; }
.side-foot { margin-top: auto; padding-top: .8rem; border-top: 1px solid rgba(255, 255, 255, .07); }
.me { display: flex; align-items: center; gap: .6rem; padding: .5rem .45rem; }
.me .name { color: var(--side-text-strong); font-weight: 600; font-size: .88rem; }
.me .role { font-size: .75rem; }
.me form { margin-left: auto; }
.me button { background: none; border: 0; color: var(--side-text); cursor: pointer; padding: .35rem; border-radius: 7px; }
.me button:hover { background: var(--side-hover); color: #fff; }
.backdrop { display: none; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 2rem; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .spacer { flex: 1; }
.main { padding: 1.6rem 2rem 4rem; width: 100%; max-width: 1440px; }

/* Recherche globale */
.search { position: relative; flex: 1; max-width: 520px; }
.search > .i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.3rem; padding-right: 2.6rem; background: var(--surface); height: 38px; border-radius: 10px; }
.search kbd { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: .35rem; display: none; max-height: 440px; overflow-y: auto;
}
.search-results.open { display: block; }
.search-results a { display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--surface-3); text-decoration: none; }
.search-results .group { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .5rem .6rem .25rem; font-weight: 600; }
.search-results .none { padding: .8rem; color: var(--muted); font-size: .88rem; }
kbd { font: 600 .7rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: .18rem .35rem; background: var(--surface-2); }

/* Menu déroulant (details/summary) */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 250px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .35rem;
}
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: .65rem; width: 100%; padding: .55rem .65rem; border-radius: 8px;
  color: var(--text); font: inherit; background: none; border: 0; cursor: pointer; text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); text-decoration: none; }
.dropdown-menu .hint { display: block; color: var(--muted); font-size: .76rem; }
.dropdown-menu .i { color: var(--accent-text); }

/* ---------- En-tête de page ---------- */
.page-head { display: flex; gap: 1rem; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: .25rem; font-size: .92rem; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: .35rem; display: flex; gap: .35rem; align-items: center; }
.crumbs a { color: var(--muted); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.15rem 1.3rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .9rem; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.card-head h2 .i { color: var(--muted); }
.card.flush .card-head { padding: 1rem 1.3rem .9rem; margin: 0; }
.card-head a { font-size: .84rem; font-weight: 500; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.mb { margin-bottom: 1rem; }

/* Indicateurs */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.05rem 1.2rem; box-shadow: var(--shadow); display: block; color: inherit; transition: border-color .15s, transform .15s; }
a.stat:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-1px); }
.stat .top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .84rem; font-weight: 500; }
.chip { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.chip.green { background: var(--success-soft); color: var(--success); }
.chip.red { background: var(--danger-soft); color: var(--danger); }
.chip.amber { background: var(--warning-soft); color: var(--warning); }
.chip.violet { background: color-mix(in srgb, var(--st-nouveau) 15%, transparent); color: var(--st-nouveau); }
.chip.blue { background: var(--info-soft); color: var(--info); }
.stat .value { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: .35rem 0 .1rem; }
.stat .hint { font-size: .8rem; color: var(--muted); }
.stat.danger .value { color: var(--danger); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.card > .table-wrap { margin: 0 -1.3rem -1.15rem; }
.card.flush > .table-wrap { margin: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 1.3rem; }
th:last-child, td:last-child { padding-right: 1.3rem; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tr[data-href] { cursor: pointer; }
th.num, td.num { text-align: right; }

/* ---------- Pastilles / badges ---------- */
.avatar {
  --h: 230;
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: .78rem; letter-spacing: .02em;
  background: hsl(var(--h) 70% var(--avatar-l)); color: hsl(var(--h) 55% var(--avatar-t));
}
.avatar.sm { width: 28px; height: 28px; border-radius: 8px; font-size: .68rem; }
.avatar.lg { width: 58px; height: 58px; border-radius: 16px; font-size: 1.15rem; }
.avatar.round { border-radius: 999px; }
.who { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.who .name { font-weight: 600; color: var(--text); display: block; }
.who .meta { font-size: .8rem; color: var(--muted); display: block; }
a.who:hover { text-decoration: none; }
a.who:hover .name { color: var(--accent-text); }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1.55; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent-text); }
.badge.violet { background: color-mix(in srgb, var(--st-nouveau) 14%, transparent); color: var(--st-nouveau); }
.badge .i { width: 13px; height: 13px; }
.dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; display: inline-block; flex: none; }
.stage-badge { background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--c); }
.pulse { width: 8px; height: 8px; border-radius: 99px; background: var(--st-nouveau); box-shadow: 0 0 0 0 rgba(139, 92, 246, .6); animation: pulse 2s infinite; display: inline-block; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(139, 92, 246, 0); } 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); } }

/* ---------- Formulaires ---------- */
label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .3rem; color: var(--text-2); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .55rem .75rem;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { min-height: 110px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0 .5rem 0 0; accent-color: var(--accent); flex: none; }
.field { margin-bottom: .95rem; }
.help { font-size: .78rem; color: var(--muted); margin-top: .25rem; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 1rem; }
.check { display: flex; align-items: center; font-weight: 500; margin-bottom: .55rem; color: var(--text); }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 650; padding: 0 .35rem; }
.section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin: .4rem 0 .8rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 600; font-size: .88rem;
  height: 38px; padding: 0 .95rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.small { height: 30px; padding: 0 .65rem; font-size: .8rem; border-radius: 8px; }
.btn.icon { width: 38px; padding: 0; }
.btn.small.icon { width: 30px; }
.btn.link { border: 0; background: none; color: var(--accent-text); padding: 0; height: auto; font-weight: 500; box-shadow: none; }
button:disabled, .btn[aria-disabled=true] { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ---------- Messages ---------- */
.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast {
  display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 12px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: toast-in .25s ease-out;
}
.toast .i { margin-top: 1px; }
.toast.success > .i { color: var(--success); }
.toast.error > .i { color: var(--danger); }
.toast.warning > .i { color: var(--warning); }
.toast.info > .i, .toast.call > .i { color: var(--accent); }
.toast.call { border-color: var(--accent); }
.toast .close { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 .1rem; }
.toast.hide { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.callout { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-size: .9rem; }
.callout > .i { margin-top: 1px; }
.callout.info { background: var(--accent-soft); color: var(--accent-text); }
.callout.warning { background: var(--warning-soft); color: var(--warning); }
.callout.error { background: var(--danger-soft); color: var(--danger); }
.callout.success { background: var(--success-soft); color: var(--success); }
.callout a { color: inherit; font-weight: 600; text-decoration: underline; }

.empty { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.empty > .i { width: 38px; height: 38px; stroke-width: 1.4; color: var(--border-strong); margin-bottom: .5rem; }
.empty strong { display: block; color: var(--text); font-size: .98rem; margin-bottom: .2rem; }
.empty .btn { margin-top: .9rem; }

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: .45rem; padding: .6rem .85rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs .n { font-size: .72rem; background: var(--surface-3); color: var(--muted); border-radius: 99px; padding: 0 .45rem; }
.segmented { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented a { padding: .32rem .8rem; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .84rem; display: inline-flex; gap: .35rem; align-items: center; }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented a:hover { text-decoration: none; color: var(--text); }

/* ---------- Fil d'activité ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline li { position: relative; display: flex; gap: .9rem; padding: .6rem 0; }
.t-icon { width: 36px; height: 36px; border-radius: 99px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--muted); border: 3px solid var(--surface); position: relative; z-index: 1; }
.t-icon.mail-in { background: var(--info-soft); color: var(--info); }
.t-icon.mail-out { background: var(--success-soft); color: var(--success); }
.t-icon.call { background: var(--accent-soft); color: var(--accent-text); }
.t-icon.call-missed { background: var(--danger-soft); color: var(--danger); }
.t-icon.lead { background: color-mix(in srgb, var(--st-nouveau) 15%, transparent); color: var(--st-nouveau); }
.t-icon.money { background: var(--warning-soft); color: var(--warning); }
.t-body { flex: 1; min-width: 0; padding-top: .2rem; }
.t-meta { font-size: .78rem; color: var(--muted); display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-bottom: .15rem; }
.t-title { font-weight: 600; }
.t-body details summary { cursor: pointer; font-weight: 600; list-style: none; }
.t-body details summary::-webkit-details-marker { display: none; }
.t-body details summary::after { content: " · lire"; color: var(--muted); font-weight: 400; font-size: .82rem; }
.t-body details[open] summary::after { content: " · réduire"; }
.bubble { margin-top: .45rem; font-size: .9rem; background: var(--surface-2); border: 1px solid var(--border); padding: .7rem .85rem; border-radius: 10px; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
audio { width: 100%; max-width: 360px; height: 34px; margin-top: .4rem; display: block; }

.kv { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: .55rem .75rem; font-size: .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }

/* ---------- Listes ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.list > li:first-child { padding-top: 0; }

/* À faire aujourd'hui */
.todo { display: flex; align-items: center; gap: .85rem; padding: .7rem .8rem; border-radius: 11px; color: var(--text); border: 1px solid var(--border); background: var(--surface-2); margin-bottom: .5rem; }
.todo:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface); }
.todo .title { font-weight: 600; display: block; }
.todo .desc { font-size: .8rem; color: var(--muted); display: block; }
.todo .go { color: var(--muted); }

/* Guide de démarrage */
.setup { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .6rem; }
.setup-item { display: flex; gap: .6rem; align-items: center; padding: .7rem .8rem; border-radius: 11px; border: 1px dashed var(--border-strong); color: var(--text); font-weight: 500; font-size: .88rem; }
.setup-item:hover { text-decoration: none; border-color: var(--accent); }
.setup-item.done { border-style: solid; background: var(--success-soft); border-color: transparent; color: var(--success); }
.setup-item .tick { width: 22px; height: 22px; border-radius: 99px; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.setup-item.done .tick { background: var(--success); border-color: var(--success); color: #fff; }
.setup-item .tick .i { width: 13px; height: 13px; stroke-width: 3; }
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: .2rem 0 1rem; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: 99px; }

/* ---------- Pipeline ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(255px, 1fr); gap: .8rem; overflow-x: auto; padding-bottom: .75rem; align-items: start; }
.column { background: var(--surface-3); border-radius: var(--radius); padding: .55rem; min-height: 340px; transition: background .15s, box-shadow .15s; }
.column.drop { background: color-mix(in srgb, var(--c) 10%, var(--surface-3)); box-shadow: inset 0 0 0 2px var(--c); }
.col-head { padding: .45rem .5rem .7rem; }
.col-head .row { gap: .5rem; }
.col-head .title { font-weight: 650; font-size: .88rem; }
.col-head .n { font-size: .72rem; font-weight: 700; color: var(--muted); background: var(--surface); border-radius: 99px; padding: 0 .45rem; }
.col-head .total { margin-left: auto; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.col-head .bar { height: 3px; border-radius: 3px; background: var(--c); margin-top: .55rem; }
.deal {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .75rem .8rem;
  margin-bottom: .55rem; cursor: grab; box-shadow: var(--shadow-sm); color: var(--text); transition: box-shadow .15s, transform .15s, border-color .15s;
}
.deal:hover { box-shadow: var(--shadow); border-color: var(--border-strong); text-decoration: none; }
.deal.dragging { opacity: .45; transform: rotate(1.5deg); }
.deal.is-new { border-color: color-mix(in srgb, var(--st-nouveau) 50%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-nouveau) 10%, transparent); }
.deal .t { font-weight: 600; font-size: .9rem; line-height: 1.35; display: flex; gap: .45rem; align-items: center; }
.deal .c { font-size: .8rem; color: var(--muted); margin-top: .35rem; display: flex; gap: .45rem; align-items: center; }
.deal .foot { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; margin-top: .65rem; gap: .5rem; }
.deal .amount { font-weight: 650; font-variant-numeric: tabular-nums; }
.deal .date { color: var(--muted); display: inline-flex; gap: .25rem; align-items: center; }
.deal .date.late { color: var(--danger); }
.deal .msg { font-size: .8rem; line-height: 1.4; color: var(--text-2); margin-top: .5rem; background: var(--surface-2); border-radius: 8px; padding: .4rem .55rem; }
.deal .msg span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.col-empty { font-size: .8rem; color: var(--muted); text-align: center; padding: 1.4rem .5rem; border: 1.5px dashed var(--border-strong); border-radius: 10px; }

/* Barre d'étapes (fiche opportunité) */
.stepper { display: flex; gap: 4px; margin-bottom: 1.25rem; flex-wrap: wrap; }
.stepper form { display: contents; }
.stepper button {
  flex: 1; min-width: 96px; border: 0; cursor: pointer; font: inherit; font-size: .8rem; font-weight: 600; padding: .6rem .4rem;
  background: var(--surface-3); color: var(--muted); border-radius: 8px;
}
.stepper button.done { background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: var(--c); }
.stepper button.current { background: var(--c); color: #fff; }
.stepper button:hover:not(.current) { filter: brightness(.96); }

/* ---------- Lignes de devis/facture ---------- */
.lines td { padding: .45rem .35rem; vertical-align: top; border-bottom: 0; }
.lines th { padding: .5rem .35rem; }
.lines td:first-child, .lines th:first-child { padding-left: 0; }
.lines input, .lines select { padding: .45rem .55rem; }
.lines .line-total { padding-top: .8rem; font-weight: 600; }
.totals { margin: 1rem 0 0 auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: .25rem 0; color: var(--text-2); }
.totals .grand { font-weight: 700; font-size: 1.08rem; color: var(--text); border-top: 1px solid var(--border); margin-top: .35rem; padding-top: .55rem; }

/* ---------- Fiche client ---------- */
.hero { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.3rem; }
.hero h1 { margin: 0; }
.hero .tags { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .4rem; align-items: center; font-size: .86rem; color: var(--muted); }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .6rem; margin-bottom: 1.1rem; }
.quick a, .quick button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; padding: .8rem .5rem; border-radius: 12px; min-height: 74px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font: inherit; font-weight: 600; font-size: .84rem; cursor: pointer; box-shadow: var(--shadow-sm);
}
.quick a:hover, .quick button:hover { border-color: var(--accent); color: var(--accent-text); text-decoration: none; }
.quick .i { color: var(--accent-text); width: 20px; height: 20px; }
.quick form { display: contents; }

/* ---------- Connexion ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--bg); }
.auth .card { width: 100%; max-width: 410px; padding: 2rem; box-shadow: var(--shadow-lg); }
.auth .brand { color: var(--text); padding: 0 0 1.4rem; font-size: 1.1rem; }

/* ---------- Intégrations ---------- */
.integration { display: flex; gap: 1rem; align-items: flex-start; }
.logo { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; font-size: .85rem; letter-spacing: -.02em; }
.logo.pl { background: linear-gradient(135deg, #10b981, #047857); }
.logo.io { background: linear-gradient(135deg, #0ea5e9, #1d4ed8); }
.logo.ghl { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.logo.ro { background: linear-gradient(135deg, #22c55e, #15803d); }
.copy { display: flex; gap: .4rem; }
.copy input { font: .8rem ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); }
pre.code { font: .78rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .75rem; overflow-x: auto; margin: .5rem 0; }
.steps { margin: .5rem 0 0; padding-left: 1.2rem; font-size: .88rem; color: var(--text-2); }
.steps li { margin-bottom: .35rem; }
.integration details > summary { cursor: pointer; font-weight: 600; font-size: .86rem; color: var(--accent-text); margin-top: .5rem; }

/* ---------- Mobile ---------- */
.menu-toggle { display: none; }
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; height: 100vh; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .backdrop.open { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .45); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: .6rem 1rem; }
  .topbar kbd, .hide-mobile { display: none; }
  .main { padding: 1.1rem 1rem 4rem; }
  .grid-2, .split { grid-template-columns: minmax(0, 1fr); }
  .stat .value { font-size: 1.35rem; }
  .kv { grid-template-columns: 95px minmax(0, 1fr); }
  th:first-child, td:first-child { padding-left: 1rem; }
  th:last-child, td:last-child { padding-right: 1rem; }
  .card > .table-wrap { margin: 0 -1.3rem -1.15rem; }
}
@media (max-width: 600px) {
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .quick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .stat .value { font-size: 1.4rem; }
  .topbar .btn .lbl { display: none; }
}
.notif-dot { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: #ef4444; color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }

/* Suivi de bout en bout (vente → enquête → livraison) */
.process { display: flex; align-items: flex-start; gap: 0; margin: .2rem 0 1.25rem; overflow-x: auto; padding-bottom: .25rem; }
.process .step { flex: 1; min-width: 78px; text-align: center; position: relative; font-size: .74rem; color: var(--muted); font-weight: 600; }
.process .step::before { content: ""; position: absolute; top: 11px; left: -50%; right: 50%; height: 3px; background: var(--border); z-index: 0; }
.process .step:first-child::before { display: none; }
.process .node { width: 24px; height: 24px; border-radius: 99px; margin: 0 auto .35rem; display: grid; place-items: center; background: var(--surface-3); border: 2px solid var(--border-strong); position: relative; z-index: 1; color: #fff; }
.process .node .i { width: 13px; height: 13px; stroke-width: 3; }
.process .step.done { color: var(--text-2); }
.process .step.done .node { background: var(--success); border-color: var(--success); }
.process .step.done::before, .process .step.current::before { background: var(--success); }
.process .step.current { color: var(--accent-text); }
.process .step.current .node { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.process.lost .step.current .node { background: var(--danger); border-color: var(--danger); }
.process .phase { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Fichiers et dépôt */
.file-row { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.file-row:last-child { border-bottom: 0; }
.file-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--muted); font-size: .62rem; font-weight: 800; text-transform: uppercase; }
.file-ico.rapport { background: var(--success-soft); color: var(--success); }
.dropzone { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 1.3rem; text-align: center; background: var(--surface-2); transition: border-color .15s, background .15s; position: relative; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .i { width: 28px; height: 28px; color: var(--accent-text); }
.dropzone .picked { font-size: .84rem; color: var(--text); margin-top: .4rem; font-weight: 600; }

/* Messages d'un dossier */
.chat { display: flex; flex-direction: column; gap: .6rem; max-height: 460px; overflow-y: auto; padding: .2rem; }
.msg-item { max-width: 85%; }
.msg-item .b { background: var(--surface-3); padding: .6rem .8rem; border-radius: 12px 12px 12px 4px; white-space: pre-wrap; word-break: break-word; font-size: .9rem; }
.msg-item.me { align-self: flex-end; }
.msg-item.me .b { background: var(--accent-soft); color: var(--text); border-radius: 12px 12px 4px 12px; }
.msg-item .m { font-size: .72rem; color: var(--muted); margin: .2rem .3rem 0; }
.msg-item.me .m { text-align: right; }
.case-card { display: block; color: var(--text); }
.case-card:hover { text-decoration: none; border-color: var(--border-strong); }
.notif-line { display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.notif-line .notif { flex: 1; border-bottom: 0; }
.notif-line form { padding-right: .6rem; }
.back-btn { flex-shrink: 0; }
.notif { display: flex; gap: .75rem; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); }
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.unread { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.notif.unread .text { font-weight: 600; }

/* ---------- Page de connexion : thème néon cyan du logo CONAN (toujours sombre) ---------- */
.auth-page { background: #0b0f13; }
.auth.neon {
  --n-cyan: #22d3ee; --n-cyan-soft: rgba(34, 211, 238, .14); --n-text: #e6f7fb; --n-muted: #8aa4ad; --n-line: rgba(34, 211, 238, .28);
  color-scheme: dark; color: var(--n-text);
  background:
    radial-gradient(700px 420px at 50% 32%, rgba(34, 211, 238, .12), transparent 70%),
    linear-gradient(135deg, transparent 0 62%, rgba(34, 211, 238, .06) 62% 62.3%, transparent 62.3%),
    linear-gradient(35deg, transparent 0 22%, rgba(34, 211, 238, .05) 22% 22.25%, transparent 22.25%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 5px),
    linear-gradient(180deg, #161c22, #0b0f13);
}
.auth.neon .card {
  background: rgba(10, 16, 22, .82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--n-line); border-radius: 20px;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, .06), 0 0 38px rgba(34, 211, 238, .16), 0 24px 60px rgba(0, 0, 0, .55);
}
.neon-brand { text-align: center; margin-bottom: 1.4rem; }
.neon-emblem { display: block; margin: -.2rem auto .8rem; border-radius: 50%; box-shadow: 0 0 34px rgba(34, 211, 238, .45); }
.neon-name { font-size: 1.9rem; font-weight: 800; letter-spacing: .22em; color: var(--n-cyan); text-shadow: 0 0 12px rgba(34, 211, 238, .75), 0 0 28px rgba(34, 211, 238, .35); line-height: 1.1; }
.neon-sub { font-size: .8rem; color: var(--n-muted); margin-top: .35rem; }
.auth.neon h1 { color: var(--n-text); }
.auth.neon .muted { color: var(--n-muted); }
.auth.neon label { color: #b9d6dd; }
.auth.neon input {
  background: #0d151c; color: var(--n-text); border: 1px solid rgba(34, 211, 238, .22);
}
.auth.neon input::placeholder { color: #55707a; }
.auth.neon input:focus { border-color: var(--n-cyan); box-shadow: 0 0 0 3px var(--n-cyan-soft), 0 0 14px rgba(34, 211, 238, .25); outline: none; }
.auth.neon .help { color: var(--n-muted); }
.auth.neon .btn.primary {
  background: linear-gradient(180deg, #3ee0f5, #13b8d4); color: #04232a; border: 0; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 0 18px rgba(34, 211, 238, .45);
}
.auth.neon .btn.primary:hover { background: linear-gradient(180deg, #5fe8f8, #1ec7e2); box-shadow: 0 0 26px rgba(34, 211, 238, .6); }
.auth.neon .callout.error { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .45); color: #fecaca; }
.auth.neon .neon-check { color: #b9d6dd; font-size: .88rem; }
.auth.neon .neon-check input { accent-color: #22d3ee; }

/* ---------- Téléphone Ringover intégré ---------- */
.phone-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 10000; display: inline-flex; align-items: center; gap: .5rem;
  padding: .7rem 1.1rem; border: 0; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 700;
  background: #16a34a; color: #fff; box-shadow: 0 8px 24px rgba(22, 163, 74, .35);
}
.phone-fab .i { width: 20px; height: 20px; }
.phone-fab:hover { background: #15803d; }
.phone-fab.open { background: #0f172a; box-shadow: 0 8px 24px rgba(15, 23, 42, .3); }
.phone-fab.ringing { background: #16a34a; animation: phone-ring 1s ease-in-out infinite; }
.phone-fab.in-call { background: #dc2626; box-shadow: 0 8px 24px rgba(220, 38, 38, .35); }
@keyframes phone-ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 80% { transform: rotate(5deg); } }
.phone-panel {
  position: fixed; right: 20px; bottom: 80px; z-index: 10000; width: 360px; height: min(600px, calc(100vh - 110px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.phone-panel[hidden] { display: flex; visibility: hidden; pointer-events: none; }
.phone-head { display: flex; align-items: center; gap: .5rem; padding: .55rem .6rem .55rem .9rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: .9rem; }
.phone-head .muted { font-weight: 500; }
.phone-min { display: inline-flex; align-items: center; gap: .25rem; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; padding: .3rem .6rem; cursor: pointer; font: inherit; font-size: .8rem; }
.phone-body { flex: 1; min-height: 0; position: relative; }
.phone-body iframe { width: 100%; height: 100%; border: 0; }
@media (max-width: 520px) { .phone-panel { right: 8px; left: 8px; width: auto; } .phone-fab span { display: none; } .phone-fab { padding: .8rem; } }

/* Bandeau « Activer micro, son et notifications » */
.perms-banner { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-bottom: 1rem; padding: .75rem 1rem; border-radius: 12px;
  background: color-mix(in srgb, #16a34a 10%, var(--surface)); border: 1px solid color-mix(in srgb, #16a34a 40%, var(--border)); font-size: .9rem; }
.perms-banner .i { color: #16a34a; flex: none; }
.perms-banner.denied { background: color-mix(in srgb, #f59e0b 12%, var(--surface)); border-color: color-mix(in srgb, #f59e0b 45%, var(--border)); }
.perms-banner.denied .i { color: #d97706; }
.deal .received { display: flex; align-items: center; gap: .3rem; font-size: .75rem; color: var(--muted); margin: .35rem 0 0; }

/* Page « Installer l'application » */
.install-hero { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.install-hero img { border-radius: 16px; }
.install-card.mine { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.install-card.mine .card-head h2::after { content: "Votre appareil"; margin-left: .5rem; font-size: .7rem; font-weight: 600; padding: .15rem .5rem; border-radius: 99px; background: var(--accent); color: #fff; vertical-align: middle; }
.os-ico { margin-right: .2rem; }
.install-hero[hidden], .callout[hidden] { display: none; }

/* Sécurité du compte */
.qr-box { display: inline-block; background: #fff; padding: .6rem; border-radius: 12px; border: 1px solid var(--border); margin: .3rem 0 .6rem; }
.qr-box svg { display: block; width: 200px; height: 200px; }
.secret-key { font-size: .95rem; letter-spacing: .08em; user-select: all; }

/* ================================================================
   Compatibilité et adaptation à tous les écrans
   (téléphones, tablettes, ordinateurs, iPhone installé, anciens navigateurs)
   ================================================================ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent; }
img, svg, video, iframe { max-width: 100%; }
td, th { overflow-wrap: normal; }

/* Hauteur réelle de l'écran sur mobile (barre d'adresse qui apparaît / disparaît) */
@supports (height: 100dvh) {
  .app, .auth { min-height: 100dvh; }
  .sidebar { height: 100dvh; }
  .phone-panel { height: min(600px, calc(100dvh - 110px)); }
}

/* iPhone installé (encoche, barre d'accueil) */
.topbar { padding-top: max(.7rem, env(safe-area-inset-top)); padding-left: max(2rem, env(safe-area-inset-left)); padding-right: max(2rem, env(safe-area-inset-right)); }
.sidebar { padding-top: max(1.1rem, env(safe-area-inset-top)); padding-bottom: max(1.1rem, env(safe-area-inset-bottom)); }
.main { padding-bottom: calc(4rem + env(safe-area-inset-bottom)); }
.phone-fab { bottom: calc(20px + env(safe-area-inset-bottom)); right: calc(20px + env(safe-area-inset-right)); }
.phone-panel { bottom: calc(80px + env(safe-area-inset-bottom)); }
.toasts { bottom: calc(76px + env(safe-area-inset-bottom)); } /* au-dessus du bouton Téléphone */
.auth { padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }

/* Écrans tactiles : cibles assez grandes pour le doigt, pas de zoom automatique de l'iPhone sur les champs (16 px minimum) */
@media (pointer: coarse), (max-width: 900px) {
  input, select, textarea { font-size: 16px; }
  .btn { min-height: 42px; }
  .btn.small { min-height: 36px; }
  .btn.icon { min-width: 42px; }
  .nav a { padding-top: .6rem; padding-bottom: .6rem; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
}

@media (max-width: 900px) {
  .topbar { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); gap: .4rem; }
  .topbar .search { flex: 1; min-width: 0; }
  .page-head { flex-wrap: wrap; gap: .75rem; }
  .page-head .actions, .hero .actions { width: 100%; }
  /* Pipeline : une colonne par écran, on glisse de colonne en colonne */
  .board { grid-auto-columns: minmax(82vw, 1fr); scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
  .board > * { scroll-snap-align: start; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .perms-banner { font-size: .82rem; }
  .perms-banner .grow { flex: 1 1 calc(100% - 2.5rem); }
  .perms-banner .btn { flex: 0 1 auto; margin-left: auto; }
  .topbar .search + .spacer { display: none; } /* la recherche prend toute la place libre */
}
@media (max-width: 480px) {
  .main { padding-left: max(.8rem, env(safe-area-inset-left)); padding-right: max(.8rem, env(safe-area-inset-right)); }
  .card { padding-left: 1rem; padding-right: 1rem; }
  .card > .table-wrap { margin-left: -1rem; margin-right: -1rem; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .inline-form > * { flex: 1 1 100%; }
  .inline-form > .btn { flex: 1 1 auto; }
  h1 { font-size: 1.4rem; }
  .qr-box svg { width: 180px; height: 180px; }
}
/* Grands écrans : le contenu ne s'étire pas à l'infini */
@media (min-width: 1800px) { .main { max-width: 1600px; } }

/* Animations réduites (réglage d'accessibilité du téléphone / de l'ordinateur) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Anciens navigateurs sans color-mix() (Safari avant 16.2, Chrome avant 111) : couleurs de remplacement */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .topbar { background: var(--bg); }
  .stage-badge { background: var(--surface-3); }
  .chip.violet, .badge.violet, .t-icon.lead { background: rgba(139, 92, 246, .15); }
  input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px rgba(99, 102, 241, .25); }
  input::placeholder, textarea::placeholder { color: var(--muted); }
  .deal.is-new { border-color: rgba(139, 92, 246, .5); box-shadow: 0 0 0 3px rgba(139, 92, 246, .12); }
  .column.drop { background: var(--surface-3); }
  .stepper button.done { background: var(--surface-2); }
  .process .step.current .node { box-shadow: 0 0 0 4px rgba(99, 102, 241, .22); }
  .notif.unread { background: var(--accent-soft); }
  .perms-banner { background: rgba(22, 163, 74, .1); border-color: rgba(22, 163, 74, .4); }
  .perms-banner.denied { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .45); }
  .install-card.mine { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }
  .auth:not(.neon) { background: var(--bg); }
  .brand-banner img { box-shadow: none; }
}

/* Impression (fiche client, dossier, rapport…) : uniquement le contenu */
@media print {
  .sidebar, .topbar, .backdrop, .toasts, .phone-fab, .phone-panel, .perms-banner, .btn, form button, .stepper, .dropzone { display: none !important; }
  .app { display: block; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* Recherche dans le pipeline */
.pipeline-search { position: relative; display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.pipeline-search > .i { position: absolute; left: .8rem; color: var(--muted); pointer-events: none; }
.pipeline-search input { padding-left: 2.4rem; max-width: 520px; }
.deal[hidden] { display: none !important; }

/* Fiches trouvées par la recherche du pipeline */
.search-results-panel { margin-bottom: 1rem; }
.result-row { display: flex; align-items: center; gap: .75rem; padding: .6rem 0 .6rem .75rem; border-top: 1px solid var(--border); border-left: 3px solid var(--c); }
.result-main { display: flex; flex-direction: column; min-width: 0; color: var(--text); }
.result-main:hover { text-decoration: none; }
.result-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-stage select { width: auto; min-width: 210px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 600px) {
  .result-row { flex-wrap: wrap; }
  .result-stage, .result-stage select { width: 100%; min-width: 0; }
}
#pipeline-search-count { white-space: nowrap; }
@media (max-width: 600px) { #pipeline-search-count { display: none; } }

/* Téléphone en mode fenêtre */
.phone-fab .i-sm, .phone-fab svg:last-child:not(:first-child) { width: 14px; height: 14px; opacity: .8; }
.phone-back { position: fixed; right: calc(20px + env(safe-area-inset-right)); bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 10000;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 99px; padding: .25rem .7rem; font: inherit; font-size: .75rem; cursor: pointer; box-shadow: var(--shadow); }

/* Montant du préjudice */
.prejudice-form { flex-wrap: nowrap; gap: .35rem; }
.prejudice-form input { max-width: 130px; padding: .35rem .55rem; }
.deal .prejudice-line { font-size: .75rem; color: var(--text-2); margin-top: .3rem; }

/* Pipeline : recherche à droite, colonnes réparties selon la largeur de l'écran */
.pipeline-head { align-items: flex-start; }
.pipeline-tools { display: flex; flex-direction: column; align-items: flex-end; gap: .6rem; margin-left: auto; }
.pipeline-head .pipeline-search { margin: 0; width: min(380px, 100%); }
.pipeline-head .pipeline-search input { max-width: none; }
.pipeline-head #pipeline-search-count { position: absolute; right: .8rem; pointer-events: none; }
.pipeline-head .pipeline-search input { padding-right: 6.5rem; }
/* Une seule ligne : les colonnes s'élargissent pour remplir l'écran quand il est assez grand, sinon on fait défiler */
@media (min-width: 901px) { .board { grid-auto-columns: minmax(148px, 1fr); } }
.main.wide { max-width: none; }
.board .column { min-width: 0; }
.board .col-head .row { flex-wrap: wrap; row-gap: .15rem; }
@media (max-width: 900px) {
  .pipeline-tools { width: 100%; align-items: stretch; margin-left: 0; }
  .pipeline-head .pipeline-search { width: 100%; }
}

/* Clients injoignables */
.reach-card { padding-top: .9rem; padding-bottom: .9rem; }
.reach-card.unreachable { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.deal .nrp-line { display: flex; align-items: center; gap: .25rem; font-size: .72rem; font-weight: 600; color: var(--danger); margin-top: .3rem; }
@supports not (color: color-mix(in srgb, red 50%, blue)) { .reach-card.unreachable { border-color: var(--danger); } }

/* Agenda */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.day { background: var(--surface-3); border-radius: var(--radius); padding: .6rem; min-height: 160px; }
.day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.day.weekend { opacity: .7; }
.day-head { font-size: .85rem; margin-bottom: .5rem; text-transform: capitalize; }
.day-empty { margin: .2rem 0; }
.rdv { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; padding: .5rem .6rem; margin-bottom: .45rem; display: flex; flex-direction: column; gap: .3rem; }
.rdv.done { opacity: .55; border-left-color: var(--success); }
.rdv.late { border-left-color: var(--danger); }
.rdv-time { font-weight: 700; font-size: .85rem; }
.rdv-main { display: flex; flex-direction: column; color: var(--text); min-width: 0; }
.rdv-main:hover { text-decoration: none; }
.rdv-main strong { font-size: .82rem; overflow-wrap: anywhere; }
.rdv-actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.i.flip { transform: rotate(180deg); }
@media (max-width: 1200px) { .week { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 900px) { .week { grid-template-columns: minmax(0, 1fr); } .day { min-height: 0; } .day.weekend { display: none; } }
/* Accueil : semaine */
.week-list .wl-day { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: .7rem 0 .3rem; }
.week-list .wl-item { display: flex; gap: .6rem; align-items: center; padding: .35rem 0; color: var(--text); }
.week-list .wl-item:hover { text-decoration: none; }
.week-list .wl-time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2rem; }
