/* Prospection KDevs — espace admin. Mobile d'abord, clair / sombre selon l'appareil. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #eaecf0;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #667085;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #3730a3;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --ok-border: #abefc6;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --warn-border: #fedf89;
  --danger: #d92d20;
  --danger-hover: #b42318;
  --danger-soft: #fef3f2;
  --danger-border: #fecdca;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25);
  --radius: 12px;
  --radius-sm: 8px;
  --side-w: 256px;
  --top-h: 64px;
  --tab-h: 62px;
  --font: ui-sans-serif, -apple-system, "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12;
    --surface: #12151c;
    --surface-2: #181c25;
    --surface-3: #212633;
    --border: #252a36;
    --border-strong: #343b4a;
    --text: #f2f4f7;
    --text-2: #b9c0cc;
    --text-3: #8b94a5;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-soft: rgba(99, 102, 241, .14);
    --accent-text: #a5b4fc;
    --ok: #47cd89;
    --ok-soft: rgba(23, 178, 106, .12);
    --ok-border: rgba(71, 205, 137, .3);
    --warn: #fdb022;
    --warn-soft: rgba(247, 144, 9, .12);
    --warn-border: rgba(253, 176, 34, .3);
    --danger: #f97066;
    --danger-hover: #fda29b;
    --danger-soft: rgba(240, 68, 56, .12);
    --danger-border: rgba(249, 112, 102, .32);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; overflow-wrap: anywhere;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
.sprite { display: none; }
.ic { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--text-3); }
.fine { font-size: 12.5px; color: var(--text-3); }
.center { text-align: center; }

/* Grilles à une colonne : jamais plus larges que l'écran, même avec un objet ou un nom très long */
.item-main, .detail, .dossier, .dossier .d-sec, .editor, .c-body, .todo, .rows, .list-cards, .auth-card, .list-tools,
.banners, .kpi, .switch .sw-text, label.field, .modal form, .modal .m-inner { grid-template-columns: minmax(0, 1fr); }
.c-head b, .detail-head h2, .subject-line b { overflow-wrap: anywhere; }

/* ── Boutons ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer;
  box-shadow: var(--shadow-sm); white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.success { background: #079455; border-color: #079455; color: #fff; }
.btn.success:hover:not(:disabled) { background: #067647; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn.danger-ghost { color: var(--danger); border-color: var(--danger-border); background: var(--surface); }
.btn.danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn.lg { min-height: 48px; font-size: 15px; }
.btn.block { width: 100%; }
.btn .spinner { width: 14px; height: 14px; border-width: 2px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.spinner {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border-strong);
  border-top-color: var(--accent); animation: spin .8s linear infinite;
}
.spinner.sm { width: 20px; height: 20px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { position: fixed; inset: 0; display: grid; place-items: center; }

/* ── Connexion ─────────────────────────────────────────────────────────── */

.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow-lg); display: grid; gap: 16px;
}
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-sub { text-align: center; color: var(--text-2); font-size: 14px; margin-top: -8px; }
.logo {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; margin: 0 auto;
  background: linear-gradient(135deg, #6366f1, #4338ca); color: #fff; font-weight: 800; font-size: 22px;
  box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .6);
}
.logo.sm { width: 34px; height: 34px; border-radius: 9px; font-size: 16px; margin: 0; }
.auth-wait {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--text); font-size: 14px;
}
.auth-wait > div:nth-child(2) { flex: 1; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.token-login summary { cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 14px; text-align: center; list-style: none; }
.token-login summary::-webkit-details-marker { display: none; }
.token-login form { display: flex; gap: 8px; margin-top: 12px; }
.token-login input { flex: 1; min-width: 0; }
.form-error { color: var(--danger); font-size: 14px; text-align: center; }

/* ── Champs ────────────────────────────────────────────────────────────── */

input[type=text], input[type=password], input[type=search], input[type=number], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
label.field .muted { font-weight: 400; }

.switch { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 38px; height: 22px; border-radius: 11px;
  background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 1px 0 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.switch .sw-text { display: grid; gap: 2px; font-size: 14px; }
.switch .sw-text .muted { font-size: 13px; }

/* ── Coquille : barre latérale, en-tête, contenu ───────────────────────── */

.shell { min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 40;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; height: var(--top-h); }
.side-brand-text { display: grid; line-height: 1.15; flex: 1; }
.side-brand-text b { font-size: 15px; }
.side-brand-text span { font-size: 12px; color: var(--text-3); }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; display: grid; align-content: start; gap: 1px; }
.nav-label { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 7px 10px;
  border-radius: var(--radius-sm); color: var(--text-2); font-weight: 550; font-size: 14px; border: 0;
  background: transparent; cursor: pointer; text-align: left; text-decoration: none !important;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-item span:first-of-type { flex: 1; }
.pill {
  min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 12px; font-weight: 700;
  display: inline-grid; place-items: center; background: var(--surface-3); color: var(--text-2);
}
.pill:empty { display: none; }
.pill.accent { background: var(--accent); color: #fff; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.side-foot { border-top: 1px solid var(--border); padding: 10px; display: grid; gap: 4px; }
.next-send { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 13px; color: var(--text-3); }
.next-send span { flex: 1; }
.next-send b { color: var(--text); font-weight: 650; }

.main { margin-left: var(--side-w); min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.titles { flex: 1; min-width: 0; }
.titles h1 { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titles p { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { flex: 1; padding: 24px 28px 40px; width: 100%; max-width: 1180px; }
.content.wide { max-width: none; padding: 0; }
.scrim { position: fixed; inset: 0; background: rgba(15, 17, 23, .45); z-index: 35; }
.only-mobile { display: none !important; }

/* ── Cartes et blocs ───────────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.card + .card, .stack > * + * { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card h2 { font-size: 16px; font-weight: 700; }
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.section-title { font-size: 15px; font-weight: 700; margin: 28px 0 12px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow-sm); display: grid; gap: 4px; text-align: left; cursor: default; color: inherit;
}
button.kpi, a.kpi { cursor: pointer; font: inherit; text-decoration: none !important; }
button.kpi:hover, a.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.kpi .k-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); font-weight: 600; }
.kpi .k-value { font-size: 28px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; }
.kpi .k-sub { font-size: 12.5px; color: var(--text-3); }
.kpi .k-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.kpi.ok .k-icon { background: var(--ok-soft); color: var(--ok); }
.kpi.warn .k-icon { background: var(--warn-soft); color: var(--warn); }

.todo { display: grid; gap: 2px; }
.todo-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.todo-row:last-child { border-bottom: 0; }
.todo-row .t-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.todo-row .t-text { flex: 1; min-width: 0; }
.todo-row .t-text b { display: block; font-size: 14.5px; }
.todo-row .t-text span { font-size: 13px; color: var(--text-3); }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.grid-2 > .card { margin-top: 0; }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); font-size: 14px; }
.banner .ic { margin-top: 2px; }
.banner > div { flex: 1; min-width: 0; }
.banner b { display: block; }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.banner li + li { margin-top: 3px; }
.banner.ok { background: var(--ok-soft); border-color: var(--ok-border); }
.banner.ok .ic { color: var(--ok); }
.banner.warn { background: var(--warn-soft); border-color: var(--warn-border); }
.banner.warn .ic { color: var(--warn); }
.banner.danger { background: var(--danger-soft); border-color: var(--danger-border); }
.banner.danger .ic { color: var(--danger); }
.banner.info { background: var(--accent-soft); border-color: transparent; }
.banner.info .ic { color: var(--accent-text); }
.banners { display: grid; gap: 10px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-border); }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.tag.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.empty { display: grid; place-items: center; text-align: center; gap: 10px; padding: 56px 20px; color: var(--text-3); }
.empty .e-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.empty b { color: var(--text); font-size: 15px; }
.empty p { max-width: 380px; font-size: 14px; }
.error-box { color: var(--danger); }

.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Liste + détail (brouillons) ───────────────────────────────────────── */

.split { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); height: calc(100dvh - var(--top-h)); }
.list-pane { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.list-tools { padding: 12px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.list-search { position: relative; }
.list-search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.list-search input { padding-left: 36px; min-height: 38px; }
.bulk { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 13px; }
.bulk .ic { color: var(--accent-text); }
.bulk span { flex: 1; color: var(--text); }
.items { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.item { display: flex; gap: 12px; padding: 12px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.item + .item { margin-top: 2px; }
.item:hover { background: var(--surface-2); }
.item.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.avatar {
  width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center; font-weight: 750;
  font-size: 13.5px; color: #fff; letter-spacing: .02em;
}
.avatar.lg { width: 48px; height: 48px; border-radius: 12px; font-size: 16px; }
.item-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.item-top { display: flex; gap: 8px; align-items: baseline; }
.item-top b { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-top time { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.item-subject { font-size: 13.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-note { font-size: 12.5px; color: var(--text-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .tags { margin-top: 3px; }
.list-count { font-size: 12.5px; color: var(--text-3); padding: 0 4px; }

.detail-pane { overflow-y: auto; min-height: 0; background: var(--bg); }
.detail { padding: 24px 28px 48px; max-width: 1180px; display: grid; gap: 16px; }
.detail-head { display: flex; gap: 14px; align-items: center; }
.detail-head .dh-text { flex: 1; min-width: 0; }
.detail-head h2 { font-size: 20px; font-weight: 750; }
.detail-head .meta { font-size: 13px; color: var(--text-3); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .sep { flex: 1; }
.subject-line { display: flex; gap: 10px; align-items: baseline; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.subject-line .label { white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.subject-line b { font-size: 15.5px; }
.seg { display: none; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 10px; width: max-content; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; font-weight: 600; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.detail-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.preview-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.preview-box .pb-head { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-3); }
.preview-box .pb-head .ic { color: var(--text-3); }
.preview { display: block; width: 100%; height: min(72vh, 760px); border: 0; background: #fff; }
.dossier { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; font-size: 14px; display: grid; gap: 14px; box-shadow: var(--shadow-sm); }
.dossier h4 { font-size: 11.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 6px; }
.dossier ul { margin: 0; padding-left: 18px; }
.dossier li + li { margin-top: 4px; }
.dossier .avoid li { color: var(--danger); }
.dossier .d-sec { display: grid; gap: 4px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 15px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text) !important; font-size: 13px; font-weight: 600; text-decoration: none !important; }
.chip:hover { background: var(--surface-2); }
.reply-body { white-space: pre-wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }
.editor { display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.editor textarea { min-height: 320px; }
.working { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--radius); background: var(--accent-soft); }
.working b { display: block; }
.detail-empty { height: 100%; display: grid; place-items: center; }

.conf { display: flex; align-items: center; gap: 12px; }
.ring { --v: 0; width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12.5px; font-weight: 750;
  background: conic-gradient(var(--ring, var(--accent)) calc(var(--v) * 1%), var(--surface-3) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; }

/* ── Tableaux, pipeline, fiches ────────────────────────────────────────── */

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { text-align: left; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid td { padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td:first-child { white-space: normal; font-weight: 600; }
.rows { display: grid; }
.row { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row .r-main { flex: 1; min-width: 0; }
.row .r-main b { display: block; }
.row .r-main .meta { font-size: 13px; color: var(--text-3); }
.pipe-edit { display: grid; grid-template-columns: 170px 120px minmax(120px, 1fr) auto; gap: 8px; margin-top: 10px; }
.search-form { display: flex; gap: 8px; }
.search-form input { flex: 1; }
.list-cards { display: grid; gap: 12px; }
.list-cards .card { padding: 18px; }
.c-head { display: flex; gap: 12px; align-items: flex-start; }
.c-head .c-text { flex: 1; min-width: 0; }
.c-head b { font-size: 15px; }
.c-head .meta { font-size: 13px; color: var(--text-3); }
.c-body { margin-top: 12px; display: grid; gap: 10px; }
.c-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sys-list { list-style: none; padding: 0; margin: 0; display: grid; }
.sys-list li { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.sys-list li:last-child { border-bottom: 0; }
.sys-list .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ok); }
.sys-list .ko .dot { background: var(--danger); }
.sys-list .s-name { font-weight: 650; }
.sys-list .s-detail { flex: 1; color: var(--text-3); font-size: 13px; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 8px; }
.subgroup { margin: 8px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.subgroup > .muted { font-size: 13px; font-weight: 600; }

/* ── Fenêtres, notifications ───────────────────────────────────────────── */

.modal { border: 0; padding: 0; border-radius: 16px; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(15, 17, 23, .5); backdrop-filter: blur(2px); }
.modal form, .modal .m-inner { display: grid; gap: 16px; padding: 22px; }
.modal h3 { font-size: 17px; font-weight: 750; }
.modal .m-text { color: var(--text-2); font-size: 14px; }
.modal .m-list { max-height: 260px; overflow-y: auto; margin: 0; padding: 10px 12px 10px 28px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13.5px; }
.modal .m-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.modal textarea { min-height: 96px; }
.chips-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-select button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 18px; padding: 7px 13px; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; min-height: 36px; }
.chips-select button.on { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }

.toasts { position: fixed; z-index: 60; right: 20px; bottom: 20px; display: grid; gap: 10px; width: min(400px, calc(100vw - 24px)); }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: #101828; color: #f2f4f7;
  box-shadow: var(--shadow-lg); font-size: 14px; animation: toast-in .18s ease-out; }
@media (prefers-color-scheme: dark) { .toast { background: #2a3040; } }
.toast .ic { color: #6ce9a6; }
.toast.err .ic { color: #fda29b; }
.toast span { flex: 1; min-width: 0; }
.toast button { border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-weight: 700; font-size: 13px; padding: 6px 10px; border-radius: 7px; cursor: pointer; }
.toast button:hover { background: rgba(255, 255, 255, .2); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ── Écrans moyens ─────────────────────────────────────────────────────── */

@media (max-width: 1279px) {
  .detail-body { grid-template-columns: minmax(0, 1fr); }
  .seg { display: flex; }
  .detail-body[data-view="apercu"] .dossier, .detail-body[data-view="dossier"] .preview-box { display: none; }
}

@media (max-width: 1023px) {
  .grid-2 { grid-template-columns: 1fr; }
  .split { grid-template-columns: 300px minmax(0, 1fr); }
  .detail { padding: 20px; }
}

/* ── Téléphone et petite tablette ──────────────────────────────────────── */

@media (max-width: 860px) {
  .only-mobile { display: inline-grid !important; }
  nav.only-mobile { display: grid !important; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; width: min(300px, 86vw); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 8px 0 4px; height: 56px; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .titles h1 { font-size: 17px; }
  .content { padding: 16px 16px 28px; }
  .content.wide { padding: 0; }
  .split { display: block; height: auto; }
  .list-pane { border-right: 0; background: transparent; }
  .list-tools { border-bottom: 0; padding: 12px 16px 4px; }
  .items { padding: 4px 10px 12px; overflow: visible; }
  .item { background: var(--surface); border: 1px solid var(--border); }
  .item + .item { margin-top: 8px; }
  .detail-pane { display: none; }
  .split.has-detail .list-pane { display: none; }
  .split.has-detail .detail-pane { display: block; overflow: visible; }
  .detail { padding: 14px 16px 28px; gap: 14px; }
  .detail-head h2 { font-size: 18px; }
  .toolbar { position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 10; margin: 0 -16px; padding: 10px 16px;
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--border); order: 99; }
  .toolbar .btn { flex: 1 1 auto; }
  .toolbar .btn.ghost { flex: 0 0 auto; }
  .toolbar .btn.ghost .b-label { display: none; }
  .detail-head .avatar.lg { display: none; }
  .toolbar .sep { display: none; }
  .preview { height: 62vh; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .k-value { font-size: 24px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .pipe-edit { grid-template-columns: 1fr 1fr; }
  .pipe-edit input[type=text], .pipe-edit .btn { grid-column: 1 / -1; }
  .search-form { flex-direction: column; }
  .toasts { left: 12px; right: 12px; width: auto; bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom)); }
  .modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92dvh; }
  .modal form, .modal .m-inner { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .modal .m-actions .btn { flex: 1; }
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.tab { display: grid; justify-items: center; align-content: center; gap: 3px; border: 0; background: transparent; color: var(--text-3);
  font-size: 11px; font-weight: 650; cursor: pointer; position: relative; -webkit-tap-highlight-color: transparent; min-width: 0; }
.tab.active { color: var(--accent-text); }
.tab .pill { position: absolute; top: 5px; left: calc(50% + 6px); height: 17px; min-width: 17px; padding: 0 5px; font-size: 10.5px; }

/* Téléphone : cartes et tableaux sans défilement de côté */
@media (max-width: 600px) {
  /* L'étiquette (« site partagé avec d'autres entreprises », suggestion de l'IA…) passe sous le nom au lieu de
     l'écraser ; les adresses de site longues se coupent n'importe où */
  .c-head { flex-wrap: wrap; }
  .c-head > .tags { flex: 1 1 100%; }
  .c-head .tag { white-space: normal; }
  .c-head .meta { overflow-wrap: anywhere; }
  /* Tableaux : chaque ligne devient une petite fiche « intitulé : valeur » */
  .table-wrap { overflow-x: visible; margin: 0; padding: 0; }
  table.grid thead { display: none; }
  table.grid, table.grid tbody, table.grid tr { display: block; width: 100%; }
  table.grid tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.grid tr:last-child { border-bottom: 0; }
  table.grid td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0;
    white-space: normal; text-align: right; }
  table.grid td::before { content: attr(data-label); color: var(--text-3); font-size: 12.5px; font-weight: 600; text-align: left; }
  table.grid td:first-child { display: block; padding-bottom: 6px; font-size: 15px; text-align: left; overflow-wrap: anywhere; }
  table.grid td:first-child::before { content: none; }
}

@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .k-value { font-size: 21px; }
  .detail-head .avatar.lg { display: none; }
}

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