/* Thème du CRM : clair par défaut, sombre selon le système. Aucune ressource externe (CSP 'self'). */
:root {
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #4338ca;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e5e7eb;
  --border-strong: #cbd5e1;
  --ring: rgba(79, 70, 229, .28);
  --side-bg: #0b1020;
  --side-text: #cbd5e1;
  --side-muted: #64748b;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(99, 102, 241, .18);
  --ok: #059669; --ok-soft: #ecfdf5;
  --warn: #d97706; --warn-soft: #fffbeb;
  --error: #dc2626; --error-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px -6px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 45px -15px rgba(15, 23, 42, .25);
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #818cf8;
    --accent-strong: #a5b4fc;
    --accent-soft: rgba(129, 140, 248, .14);
    --accent-text: #a5b4fc;
    --bg: #0b1020;
    --surface: #111827;
    --surface-2: #0f172a;
    --surface-3: #1e293b;
    --text: #e5e7eb;
    --text-2: #cbd5e1;
    --muted: #94a3b8;
    --border: #1f2937;
    --border-strong: #334155;
    --ring: rgba(129, 140, 248, .35);
    --side-bg: #070b16;
    --ok: #34d399; --ok-soft: rgba(52, 211, 153, .12);
    --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12);
    --error: #f87171; --error-soft: rgba(248, 113, 113, .12);
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 50px -20px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; line-height: 1.5; font-size: 15px; }
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -.02em; margin: 0; font-weight: 700; }
h2 { font-size: 1rem; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: .72rem; margin: 1.1rem 0 .45rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 650; }
p { margin: .4rem 0; }
a { color: var(--accent-text); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-3); padding: .1rem .35rem; border-radius: 5px; }
svg.icon { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); display: block; }
.error-text { color: var(--error); }
::selection { background: var(--ring); }

/* --- Structure -------------------------------------------------------------------------------- */

.shell { min-height: 100vh; }
main { width: 100%; padding: 1.25rem 1rem 6rem; max-width: 1360px; margin: 0 auto; }
.loading { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 3rem 0; justify-content: center; }
.spinner { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
main > * { animation: rise .25s ease-out; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Barre latérale (bureau) / barre haute + onglets bas (mobile) */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .9rem; padding-top: max(.6rem, env(safe-area-inset-top));
  background: var(--side-bg); color: var(--side-text);
}
#topbar[hidden] { display: none; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; }
.brand img { border-radius: 9px; }
.brand span { display: grid; line-height: 1.1; }
.brand strong { font-size: .95rem; letter-spacing: -.01em; }
.brand small { color: var(--side-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 600; }
.business-switch { margin-left: auto; display: grid; min-width: 0; }
.business-switch .label { display: none; }
.business-switch select {
  background: rgba(255, 255, 255, .07); color: #fff; border: 1px solid rgba(255, 255, 255, .1);
  max-width: 11rem; padding: .4rem 1.9rem .4rem .7rem; background-repeat: no-repeat; background-position: right .55rem center; background-size: 1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
}
.business-switch select option { color: #0f172a; background: #fff; }
.sidebar-foot { display: flex; align-items: center; gap: .5rem; }
.user { display: none; }
.icon-button {
  display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0;
  background: transparent; border: 1px solid transparent; color: var(--side-text); border-radius: var(--radius-sm); cursor: pointer;
}
.icon-button:hover { background: var(--side-hover); color: #fff; }

#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
  padding: .3rem .4rem max(.3rem, env(safe-area-inset-bottom));
}
#nav a {
  position: relative; display: grid; justify-items: center; gap: .1rem; padding: .35rem .25rem;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600; border-radius: var(--radius-sm);
}
#nav a svg.icon { width: 1.35rem; height: 1.35rem; }
#nav a.active { color: var(--accent-text); }
.badge {
  display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem;
  background: var(--error); color: #fff; border-radius: 999px; font-size: .68rem; font-weight: 700; line-height: 1;
}
#nav a .badge { position: absolute; top: .1rem; left: calc(50% + .35rem); }

/* --- Composants --------------------------------------------------------------------------------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.page-head .eyebrow { display: block; font-size: .75rem; font-weight: 650; color: var(--accent-text); text-transform: uppercase; letter-spacing: .1em; margin-bottom: .3rem; }
.page-head p { margin: .35rem 0 0; color: var(--muted); max-width: 60ch; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: var(--warn-soft); }
.card.error { border-color: color-mix(in srgb, var(--error) 45%, var(--border)); background: var(--error-soft); }
.card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.card-head .icon-wrap { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); }
.card-head .count { margin-left: auto; color: var(--muted); font-size: .8rem; font-weight: 600; }

input, select, textarea, button, .button {
  font: inherit; font-size: .9rem; padding: .55rem .75rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s, color .15s;
}
select { appearance: none; padding-right: 2rem; background-repeat: no-repeat; background-position: right .55rem center; background-size: 1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); }
input, select, textarea { min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; padding: 0; accent-color: var(--accent); vertical-align: -.2em; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-sm); white-space: nowrap;
}
@media (prefers-color-scheme: dark) { button, .button { color: #0b1020; } }
button:hover, .button:hover { background: var(--accent-strong); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.secondary, .button.secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
button.secondary:hover, .button.secondary:hover { background: var(--surface-3); color: var(--text); }
button.ghost { background: transparent; color: var(--muted); border-color: transparent; box-shadow: none; }
button.ghost:hover { background: var(--surface-3); color: var(--text); }
button.small, .button.small { padding: .38rem .7rem; font-size: .82rem; }
button.link { background: none; border: 0; text-decoration: underline; padding: 0; color: var(--accent-text); box-shadow: none; }
.button.gmail { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.button.gmail svg { color: #ea4335; }
.button.whatsapp { background: #25d366; color: #052e16; }
.button.whatsapp:hover { background: #1fb457; }
.button.gmail:hover { background: var(--surface-3); }

.pill {
  display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .6rem; border-radius: 999px;
  font-size: .76rem; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2);
}
.pill::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; opacity: .85; }
.tone-blue { background: #eff6ff; color: #1d4ed8; }
.tone-violet { background: #f5f3ff; color: #6d28d9; }
.tone-amber { background: #fffbeb; color: #b45309; }
.tone-green { background: #ecfdf5; color: #047857; }
.tone-red { background: #fef2f2; color: #b91c1c; }
.tone-slate { background: #f1f5f9; color: #475569; }
.tone-cyan { background: #ecfeff; color: #0e7490; }
.tone-pink { background: #fdf2f8; color: #be185d; }
@media (prefers-color-scheme: dark) {
  .tone-blue { background: rgba(59, 130, 246, .15); color: #93c5fd; }
  .tone-violet { background: rgba(139, 92, 246, .16); color: #c4b5fd; }
  .tone-amber { background: rgba(245, 158, 11, .14); color: #fcd34d; }
  .tone-green { background: rgba(16, 185, 129, .14); color: #6ee7b7; }
  .tone-red { background: rgba(239, 68, 68, .15); color: #fca5a5; }
  .tone-slate { background: rgba(148, 163, 184, .14); color: #cbd5e1; }
  .tone-cyan { background: rgba(6, 182, 212, .14); color: #67e8f9; }
  .tone-pink { background: rgba(236, 72, 153, .14); color: #f9a8d4; }
}

.avatar {
  display: inline-grid; place-items: center; flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  font-weight: 700; font-size: .85rem; letter-spacing: .02em; color: #fff;
}
.avatar.lg { width: 3.6rem; height: 3.6rem; font-size: 1.2rem; border-radius: 18px; }
.av-0 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.av-1 { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.av-2 { background: linear-gradient(135deg, #10b981, #0ea5e9); }
.av-3 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.av-4 { background: linear-gradient(135deg, #ec4899, #8b5cf6); }
.av-5 { background: linear-gradient(135deg, #14b8a6, #22c55e); }
.av-6 { background: linear-gradient(135deg, #f97316, #ec4899); }
.av-7 { background: linear-gradient(135deg, #64748b, #334155); }

.lid { font-family: var(--mono); font-weight: 650; letter-spacing: .08em; color: var(--accent-text); font-size: .85rem; }
.lid-chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .3rem .25rem .65rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text); font-family: var(--mono); font-weight: 700; letter-spacing: .1em; font-size: .9rem;
}
.lid-chip button { padding: .2rem; background: transparent; color: inherit; box-shadow: none; border-radius: 999px; }
.lid-chip button:hover { background: var(--ring); }

.empty { display: grid; justify-items: center; gap: .4rem; text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty svg.icon { width: 2.5rem; height: 2.5rem; stroke-width: 1.5; color: var(--border-strong); }
.empty strong { color: var(--text-2); font-size: 1rem; }

/* --- Connexion ---------------------------------------------------------------------------------- */

.login-page { min-height: calc(100vh - 8rem); display: grid; align-items: center; }
.login-wrap {
  display: grid; width: 100%; max-width: 980px; margin: 0 auto; overflow: hidden;
  border-radius: 24px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.login-hero {
  display: none; position: relative; padding: 2.5rem; color: #e0e7ff; overflow: hidden;
  background: radial-gradient(circle at 15% 15%, #6366f1 0, transparent 45%), radial-gradient(circle at 85% 80%, #a855f7 0, transparent 45%), #1e1b4b;
}
.login-hero .brand strong { font-size: 1.05rem; }
.login-hero .brand small { color: #a5b4fc; }
.login-hero h2 { font-size: 2rem; line-height: 1.15; letter-spacing: -.03em; color: #fff; margin: 3.5rem 0 1rem; font-weight: 750; }
.login-hero ul { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .7rem; }
.login-hero li { display: flex; gap: .6rem; align-items: center; font-size: .92rem; }
.login-hero li svg.icon { color: #a5b4fc; }
.login { display: grid; gap: 1rem; padding: 2.25rem 1.5rem; align-content: center; }
.login .brand { color: var(--text); margin-bottom: .5rem; }
.login .brand small { color: var(--muted); }
.login h1 { font-size: 1.5rem; }
.login label { display: grid; gap: .35rem; font-size: .85rem; font-weight: 600; color: var(--text-2); }
.login input { padding: .7rem .85rem; font-size: .95rem; }
.login button[type="submit"] { padding: .75rem; font-size: .95rem; margin-top: .25rem; }

/* --- Liste des dossiers ------------------------------------------------------------------------- */

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.kpi { position: relative; padding: .9rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.kpi .kpi-label { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--muted); font-weight: 600; }
.kpi .kpi-value { font-size: 1.65rem; font-weight: 750; letter-spacing: -.03em; margin-top: .2rem; }
.kpi .bar { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: .5rem; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.kpi.k-reservation .bar i { background: #f59e0b; }
.kpi.k-paiement .bar i { background: #10b981; }
.kpi.k-alert .kpi-value { color: var(--warn); }

.toolbar { display: grid; gap: .6rem; margin-bottom: .9rem; }
.search { position: relative; }
.search svg.icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding-left: 2.4rem; }
.toolbar .selects { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

.chips { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .2rem; margin-bottom: 1rem; scrollbar-width: none; }
.chip {
  background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 999px;
  padding: .32rem .85rem; font-size: .82rem; font-weight: 600; box-shadow: none;
}
.chip:hover { background: var(--surface); color: var(--text); }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }

.list-card { padding: 0; overflow: hidden; }
.list-head { display: none; }
.case-list { list-style: none; padding: 0; margin: 0; }
.case-list li + li { border-top: 1px solid var(--border); }
.case-row {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "av who time" "av meta meta";
  gap: .15rem .8rem; align-items: center; padding: .85rem 1rem; color: inherit; text-decoration: none; transition: background .12s;
}
.case-row:hover { background: var(--surface-2); }
.case-row .avatar { grid-area: av; align-self: start; }
.case-row .who { grid-area: who; display: grid; min-width: 0; }
.case-row .who strong { font-weight: 600; }
.case-row .who strong, .case-row .who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-row .who small { color: var(--muted); }
.case-row .meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; margin-top: .3rem; }
.case-row .c-lid, .case-row .c-stage, .case-row .c-status, .case-row .flags { display: contents; }
.case-row time { grid-area: time; font-size: .78rem; color: var(--muted); white-space: nowrap; align-self: start; }
.flags { display: inline-flex; gap: .35rem; }
.flag { display: inline-flex; align-items: center; gap: .25rem; font-size: .76rem; font-weight: 600; color: var(--muted); padding: .12rem .45rem; border-radius: 6px; background: var(--surface-3); }
.flag.warn { color: var(--warn); background: var(--warn-soft); }

.steps { display: inline-flex; align-items: center; gap: .25rem; }
.steps i { width: .5rem; height: .5rem; border-radius: 50%; background: var(--border-strong); }
.steps i.on { background: var(--accent); }
.steps i.on.s-reservation { background: #f59e0b; }
.steps i.on.s-paiement { background: #10b981; }
.steps span { font-size: .78rem; color: var(--text-2); font-weight: 600; margin-left: .3rem; }
.list-foot { padding: .7rem 1rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border); background: var(--surface-2); }

/* --- Fiche dossier ------------------------------------------------------------------------------ */

.back { display: inline-flex; align-items: center; gap: .35rem; text-decoration: none; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .8rem; }
.back:hover { color: var(--text); }
.case-hero { padding: 1.3rem 1.3rem 1.1rem; }
.case-hero .top { display: flex; gap: 1rem; align-items: center; }
.case-hero .ident { min-width: 0; display: grid; gap: .35rem; }
.case-hero h1 { overflow-wrap: anywhere; }
.case-hero .sub { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; color: var(--muted); font-size: .85rem; }
.head-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1.1rem; }
.head-actions select { font-weight: 600; }
.head-actions .spacer { flex: 1; }

.stepper { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; list-style: none; padding: 0; margin: 1.2rem 0 0; counter-reset: step; }
.stepper li { position: relative; display: grid; justify-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; color: var(--muted); text-align: center; }
.stepper li::before {
  counter-increment: step; content: counter(step); position: relative; z-index: 1;
  display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong); color: var(--muted); font-size: .8rem;
}
.stepper li + li::after { content: ""; position: absolute; top: .95rem; right: 50%; width: 100%; height: 2px; background: var(--border-strong); }
.stepper li.reached { color: var(--text); }
.stepper li.reached::before { content: "✓"; background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper li.reached::after { background: var(--accent); }

.case-grid { display: grid; gap: 0 1rem; grid-template-columns: minmax(0, 1fr); }
.case-grid .col { min-width: 0; }

.fields dl { display: grid; grid-template-columns: 1fr; gap: .2rem; margin: 0 0 .8rem; }
.fields dt { font-size: .76rem; font-weight: 600; color: var(--muted); margin-top: .5rem; }
.fields dd { margin: 0; display: grid; gap: .2rem; }
.fields dd input { width: 100%; background: var(--surface-2); }
.fields dd input:hover { border-color: var(--muted); }
.fields dd.has-conflict input { border-color: var(--warn); background: var(--warn-soft); }
.fields .form-foot { display: flex; justify-content: flex-end; }

.facts, .missing, .conflicts { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.facts li, .missing li { display: flex; gap: .55rem; align-items: baseline; }
.facts li::before { content: ""; flex: none; width: .45rem; height: .45rem; border-radius: 50%; background: var(--accent); transform: translateY(-.1rem); }
.facts small { display: block; }
.missing li { color: var(--warn); font-weight: 500; }
.missing li::before { content: "○"; font-weight: 700; }
.conflicts li { padding: .7rem .8rem; border-radius: var(--radius-sm); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.conflicts .actions { display: flex; gap: .4rem; margin-top: .5rem; }
.ok-banner { display: flex; gap: .5rem; align-items: center; padding: .55rem .75rem; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); font-weight: 600; font-size: .88rem; }

.notes, .tasks, .timeline, .reco, .events { list-style: none; padding: 0; margin: .5rem 0 0; }
.note-form { display: grid; gap: .5rem; justify-items: end; margin-bottom: .6rem; }
.notes li { padding: .75rem .85rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); margin-top: .5rem; }
.notes p { margin: 0 0 .3rem; white-space: pre-wrap; }
.tasks li { display: flex; align-items: center; gap: .5rem; padding: .5rem .2rem; border-top: 1px solid var(--border); }
.tasks li:first-child { border-top: 0; }
.tasks label { display: flex; align-items: center; gap: .55rem; flex: 1; cursor: pointer; }
.tasks li.done label { text-decoration: line-through; color: var(--muted); }
.due { display: inline-flex; align-items: center; gap: .25rem; font-size: .76rem; color: var(--muted); }
.due.late { color: var(--error); font-weight: 600; }

.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before { content: ""; position: absolute; left: .35rem; top: .4rem; bottom: .4rem; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: .1rem 0 .85rem; font-size: .88rem; }
.timeline li::before {
  content: ""; position: absolute; left: -1.4rem; top: .35rem; width: .75rem; height: .75rem; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}
.timeline li.kind-conflict::before { border-color: var(--warn); }
.timeline li.kind-event::before, .timeline li.kind-stage::before { background: var(--accent); }
.timeline li.kind-task_done::before, .timeline li.kind-conflict_resolved::before { border-color: var(--ok); background: var(--ok); }
.timeline time { display: block; color: var(--muted); font-size: .75rem; font-weight: 600; }
.timeline .kind-conflict span { color: var(--warn); }
.events li { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .45rem 0; border-top: 1px solid var(--border); font-size: .85rem; }
.events li:first-child { border-top: 0; }

textarea { width: 100%; resize: vertical; }
.inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }
.inline input { flex: 1 1 10rem; }

/* --- Rapprochement ------------------------------------------------------------------------------ */

.reco { display: grid; gap: .8rem; margin: 0; }
.reco > li.card { margin: 0; }
.reco-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.reco-head strong { display: flex; gap: .5rem; align-items: center; }
.reco-head strong svg { color: var(--warn); }
.reco .tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .6rem 0; }
.reco .tags span { font-size: .76rem; padding: .15rem .5rem; border-radius: 6px; background: var(--surface-3); color: var(--text-2); }
details summary { cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--accent-text); }
pre { background: #0b1020; color: #e2e8f0; padding: .85rem 1rem; border-radius: var(--radius-sm); overflow: auto; font: .78rem/1.55 var(--mono); max-height: 22rem; }
.segmented { display: inline-flex; padding: .2rem; border-radius: 10px; background: var(--surface-3); gap: .2rem; }
.segmented a { padding: .32rem .8rem; border-radius: 8px; font-size: .82rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* --- Configuration ------------------------------------------------------------------------------ */

textarea.code { font: .8rem/1.6 var(--mono); background: #0b1020; color: #e2e8f0; border-color: #1e293b; tab-size: 2; }
.config-grid { display: grid; gap: 0 1rem; grid-template-columns: minmax(0, 1fr); }
.table-wrap { overflow-x: auto; margin: 0 -1.2rem; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; background: var(--surface-2); }
th, td { text-align: left; padding: .6rem 1.2rem; border-top: 1px solid var(--border); vertical-align: middle; }
td .row-actions { display: flex; gap: .35rem; justify-content: flex-end; }
tr.inactive { color: var(--muted); }
.token { display: block; word-break: break-all; padding: .7rem; background: var(--surface); border: 1px dashed var(--warn); border-radius: var(--radius-sm); font-size: .85rem; }
.messages ul { padding-left: 1.1rem; }
.messages .ok-text { font-weight: 600; }

/* --- Toast -------------------------------------------------------------------------------------- */

#toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%) translateY(20px); opacity: 0;
  display: flex; align-items: center; gap: .5rem;
  background: #0f172a; color: #fff; padding: .7rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow-lg);
  transition: transform .2s, opacity .2s; z-index: 50; max-width: 90vw; font-size: .9rem; font-weight: 500;
}
#toast:not(.show) { visibility: hidden; }
#toast.show { transform: translateX(-50%); opacity: 1; }
#toast.ok { background: #065f46; }
#toast.error { background: #991b1b; }

/* --- Écrans larges ------------------------------------------------------------------------------ */

@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1fr auto; }
  .toolbar .selects { grid-template-columns: 11rem 11rem; }
  .login-wrap { grid-template-columns: 1fr 1fr; }
  .login-hero { display: block; }
  .login { padding: 3rem 2.75rem; }
  .login .brand { display: none; }
}

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
  .shell:has(#topbar[hidden]) { display: block; }
  #topbar {
    position: sticky; top: 0; height: 100vh; flex-direction: column; align-items: stretch; gap: 1.25rem; padding: 1.25rem .9rem;
    border-right: 1px solid rgba(255, 255, 255, .04);
  }
  .brand { padding: 0 .4rem; }
  .business-switch { margin: 0; gap: .35rem; }
  .business-switch .label { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--side-muted); font-weight: 650; padding: 0 .4rem; }
  .business-switch select { max-width: none; width: 100%; padding: .55rem 2rem .55rem .75rem; }
  #nav { position: static; display: grid; grid-auto-flow: row; gap: .15rem; background: none; backdrop-filter: none; border: 0; padding: 0; }
  #nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; font-size: .9rem; font-weight: 550; color: var(--side-text); }
  #nav a svg.icon { width: 1.15rem; height: 1.15rem; color: var(--side-muted); }
  #nav a:hover { background: var(--side-hover); color: #fff; }
  #nav a.active { background: var(--side-active); color: #fff; }
  #nav a.active svg.icon { color: #a5b4fc; }
  #nav a .badge { position: static; margin-left: auto; }
  .sidebar-foot { margin-top: auto; padding: .75rem .4rem 0; border-top: 1px solid rgba(255, 255, 255, .07); }
  .user { display: flex; align-items: center; gap: .6rem; min-width: 0; flex: 1; }
  .user .avatar { width: 2.1rem; height: 2.1rem; font-size: .75rem; }
  .user span { display: grid; min-width: 0; line-height: 1.25; }
  .user strong { color: #fff; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user small { color: var(--side-muted); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding: 2rem 2.25rem 3rem; }
  #toast { bottom: 1.5rem; }

  .list-head, .case-row {
    grid-template-columns: minmax(0, 2.4fr) 6.5rem minmax(9rem, 1.1fr) minmax(8rem, 1fr) 6rem 7.5rem;
    grid-template-areas: none; gap: 1rem; padding: .8rem 1.25rem;
  }
  .list-head { display: grid; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; background: var(--surface-2); border-bottom: 1px solid var(--border); }
  .case-row .meta { display: contents; }
  .case-row .c-lid, .case-row .c-stage, .case-row .c-status, .case-row .flags { display: flex; }
  .case-row .whobox { display: flex; gap: .8rem; align-items: center; min-width: 0; }
  .case-row .avatar { align-self: center; }
  .case-row time { grid-area: auto; align-self: center; text-align: right; }
  .list-head span:last-child { text-align: right; }

  .fields dl { grid-template-columns: 10rem 1fr; align-items: start; column-gap: 1rem; }
  .fields dt { margin-top: .6rem; }
}

@media (max-width: 899.98px) {
  .case-row .whobox { display: contents; }
}

@media (min-width: 1180px) {
  .case-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .config-grid { grid-template-columns: 1fr 1fr; }
}

/* --- Administration ----------------------------------------------------------------------------- */

.admin > .card { margin-bottom: 1rem; }
.admin td select { min-width: 8.5rem; padding: .35rem 1.8rem .35rem .55rem; font-size: .84rem; }
.admin-user { display: flex; align-items: center; gap: .6rem; min-width: 14rem; flex-wrap: wrap; }
.admin-user > span:not(.pill):not(.avatar) { display: grid; line-height: 1.25; }
.admin td .row-actions .button { text-decoration: none; }
label.check { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-2); white-space: nowrap; }
label.check input { flex: none; width: auto; }
[hidden] { display: none !important; }
