/* ======================================================================
   Suivi de projet — 3m promotion
   Design system. Bleu marque #0188CC · gris #656565.
   Display: Space Grotesk · Texte: Manrope.
   ====================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    --blue:        #0188CC;
    --blue-600:    #0173ad;
    --blue-700:    #015d8c;
    --blue-tint:   #e8f5fc;
    --blue-tint-2: #f3fafe;
    --gray:        #656565;
    --ink:         #14222e;
    --ink-soft:    #43525d;
    --line:        #e4ebf0;
    --line-soft:   #eef3f6;
    --bg:          #f5f8fb;
    --card:        #ffffff;
    --ok:          #1f9d6b;
    --ok-tint:     #e7f6ef;
    --warn:        #d98324;
    --warn-tint:   #fdf2e3;
    --danger:      #d24b4b;
    --danger-tint: #fbecec;

    --r-sm: 9px;
    --r:    14px;
    --r-lg: 22px;
    --shadow-sm: 0 1px 2px rgba(20,34,46,.05), 0 2px 6px rgba(20,34,46,.04);
    --shadow:    0 6px 18px rgba(20,34,46,.07), 0 2px 6px rgba(20,34,46,.05);
    --shadow-lg: 0 24px 60px rgba(1,93,140,.14), 0 8px 22px rgba(20,34,46,.08);

    --display: 'Space Grotesk', system-ui, sans-serif;
    --body: 'Manrope', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--body);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
a { color: var(--blue-600); }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; background: var(--blue-tint); padding: 1px 6px; border-radius: 6px; font-size: .88em; }

/* ---------- Boutons --------------------------------------------------- */
.btn {
    --bg: var(--blue);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--body); font-weight: 700; font-size: .94rem;
    padding: 11px 20px; border: 0; border-radius: 999px;
    background: var(--bg); color: #fff; cursor: pointer; text-decoration: none;
    transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
    box-shadow: 0 6px 16px rgba(1,136,204,.22);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(1,136,204,.28); }
.btn:active { transform: translateY(0); }
.btn-primary { --bg: linear-gradient(135deg, #06a0e4, var(--blue-600)); }
.btn-block { width: 100%; }
.btn-ghost {
    background: transparent; color: var(--blue-700); box-shadow: none;
    border: 1.5px solid var(--line);
}
.btn-ghost:hover { background: var(--blue-tint-2); border-color: var(--blue); box-shadow: none; }
.btn-danger { background: var(--danger); box-shadow: 0 6px 16px rgba(210,75,75,.2); }
.btn-sm { padding: 7px 14px; font-size: .85rem; }
.btn:focus-visible, a:focus-visible, input:focus-visible, button:focus-visible, [contenteditable]:focus-visible {
    outline: 3px solid rgba(1,136,204,.4); outline-offset: 2px;
}

/* ---------- Alertes --------------------------------------------------- */
.alert { padding: 13px 16px; border-radius: var(--r-sm); font-weight: 600; font-size: .92rem; margin-bottom: 16px; }
.alert-error { background: var(--danger-tint); color: #9a2f2f; }
.alert-ok    { background: var(--ok-tint); color: #14704c; }
.alert-info  { background: var(--blue-tint); color: var(--blue-700); }
.alert-warn  { background: var(--warn-tint); color: var(--warn); }

/* ======================================================================
   Authentification
   ====================================================================== */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.auth-bg {
    position: fixed; inset: 0; z-index: 0;
    background:
        radial-gradient(900px 520px at 12% -10%, rgba(1,136,204,.16), transparent 60%),
        radial-gradient(720px 480px at 110% 120%, rgba(6,160,228,.14), transparent 55%),
        linear-gradient(180deg, #eef5fa, #f5f8fb);
}
.auth-card {
    position: relative; z-index: 1;
    width: 100%; max-width: 420px;
    background: var(--card); border-radius: var(--r-lg);
    padding: 38px 34px; box-shadow: var(--shadow-lg);
    border: 1px solid #fff;
    animation: rise .6s cubic-bezier(.2,.7,.2,1) both;
}
.auth-logo { height: 38px; margin-bottom: 24px; }
.auth-eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 800; color: var(--blue); margin: 0 0 4px; }
.auth-title { font-size: 1.7rem; margin-bottom: 8px; }
.auth-sub { color: var(--ink-soft); font-size: .95rem; margin: 0 0 22px; }
.auth-form { display: grid; gap: 14px; }
.auth-foot { margin: 22px 0 0; font-size: .8rem; color: var(--gray); text-align: center; }
.field { display: grid; gap: 6px; }
.field-label { font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.field input, .field select, .field textarea {
    font-family: var(--body); font-size: .98rem; color: var(--ink);
    padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
    background: #fbfdfe; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--blue); box-shadow: 0 0 0 4px rgba(1,136,204,.12); outline: none; background: #fff;
}
.install-steps { padding-left: 18px; color: var(--ink-soft); line-height: 1.8; }
.install-steps li { margin-bottom: 4px; }
.hint { font-size: .82rem; color: var(--gray); }
.phone-row, .lock-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.phone-row input, .lock-row input { flex: 1; }
.field input:disabled, .phone-row input:disabled { background: var(--line-soft); color: var(--gray); cursor: default; }
.link-edit { color: var(--gray); font-size: .85rem; cursor: pointer; background: none; border: 0; padding: 2px 4px; line-height: 1; flex-shrink: 0; }
.link-edit:hover { color: var(--blue); }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .18s; }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.switch input:checked + .switch-track { background: var(--blue); }
.switch input:checked + .switch-track .switch-knob { transform: translateX(18px); }

/* ======================================================================
   Coque applicative
   ====================================================================== */
.topbar {
    position: sticky; top: 0; z-index: 30;
    background: rgba(255,255,255,.82); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    max-width: 1140px; margin: 0 auto; padding: 14px 24px;
    display: flex; align-items: center; gap: 18px;
}
.topbar .logo { height: 30px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .86rem; color: var(--ink-soft); font-weight: 600; }
.topbar .who strong { color: var(--ink); }

/* ---------- Bandeau bêta/démo (suivi client) -------------------------- */
.beta-banner { background: var(--warn-tint); border-bottom: 1px solid #f1dfa8; }
.beta-banner-inner {
    max-width: 1140px; margin: 0 auto; padding: 10px 24px;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    font-size: .84rem; color: #6b5510; line-height: 1.4;
}
.beta-tag {
    flex: 0 0 auto; background: var(--warn); color: #fff; font-weight: 800;
    font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
    padding: 3px 9px; border-radius: 999px;
}
@media (max-width: 560px) { .beta-banner-inner { padding: 10px 16px; } }
.badge-admin {
    font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
    background: var(--ink); color: #fff; padding: 4px 9px; border-radius: 999px;
}
.admin-nav { display: flex; gap: 4px; }
.admin-nav a {
    font-size: .88rem; font-weight: 700; color: var(--ink-soft); text-decoration: none;
    padding: 8px 14px; border-radius: var(--r-sm); transition: background .15s, color .15s;
}
.admin-nav a:hover { background: var(--blue-tint-2); color: var(--ink); }
.admin-nav a.active { background: var(--blue-tint); color: var(--blue-700); }

/* ---------- Gestion de chantier : tableau de factures ------------------ */
table.grid td.ed { cursor: pointer; }
table.grid td.ed:hover { background: var(--blue-tint-2); }
table.grid td.actions-cell { white-space: nowrap; }
table.grid td.total-ttc { white-space: nowrap; font-weight: 700; color: var(--blue-700); }
table.grid td.actions-cell .link-move { font-size: 1rem; padding: 4px 8px; margin-right: 4px; }
table.grid td.actions-cell .link-del { font-size: .95rem; padding: 4px 8px; }
.cell-edit { width: 100%; min-width: 140px; padding: 8px 10px; border: 1.5px solid var(--blue); border-radius: 6px; font-family: var(--body); font-size: 1rem; box-sizing: border-box; }
textarea.cell-edit { min-width: 260px; min-height: 64px; resize: vertical; line-height: 1.4; }
table.grid td.ed[data-field="amount_ht"],
table.grid td.ed[data-field="amount_ttc"],
table.grid td.ed[data-field="vat_rate"],
table.grid td.ed[data-field="invoice_date"] { white-space: nowrap; }
.chantier-total { white-space: nowrap; }

.calc-flag {
    display: inline-block; margin-left: 6px; padding: 1px 6px;
    font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
    color: var(--gray); background: var(--line-soft); border-radius: 4px; cursor: help;
}
.spinner {
    display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px;
    border: 2px solid var(--line); border-top-color: var(--blue); border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.info-ico {
    font-size: .82rem; color: var(--blue); cursor: help; white-space: nowrap;
}

/* Colonne Fichier réduite à une icône (nom complet en info-bulle au survol),
   pour laisser plus de place aux colonnes de contenu et limiter le scroll horizontal. */
#invoice-table td.file-cell { width: 1%; white-space: nowrap; text-align: center; }
#invoice-table .file-ico { font-size: 1.2rem; text-decoration: none; display: inline-block; }
#invoice-table .file-ico:hover { transform: scale(1.15); }
#invoice-table td.ed[data-field="comment"] { max-width: 220px; }

/* En-têtes de colonnes triables (tableau de factures + tableau de statistiques de visite) */
#invoice-table th.sortable, #visits-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
#invoice-table th.sortable:hover, #visits-table th.sortable:hover { color: var(--blue-700); }
#invoice-table th.sortable::after, #visits-table th.sortable::after { content: '↕'; margin-left: 5px; opacity: .35; font-size: .82em; }
#invoice-table th.sortable.sort-asc::after, #visits-table th.sortable.sort-asc::after { content: '↑'; opacity: 1; color: var(--blue); }
#invoice-table th.sortable.sort-desc::after, #visits-table th.sortable.sort-desc::after { content: '↓'; opacity: 1; color: var(--blue); }

/* Halo bleu temporaire sur une ligne qui vient de changer (édition, remplacement
   de fichier, ré-analyse IA) — fort au départ, puis s'estompe sur 30s. */
tr.row-glow > td { animation: row-glow-fade 30s ease-out forwards; }
@keyframes row-glow-fade {
    0%   { background-color: rgba(1, 136, 204, .55); }
    100% { background-color: rgba(1, 136, 204, 0); }
}

.status-pill.dup {
    background: var(--warn-tint); color: var(--warn); cursor: pointer;
    display: block; width: fit-content; margin-top: 6px; border: 1px solid rgba(0,0,0,.06);
}
.status-pill.dup:hover { filter: brightness(.95); }
.dup-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 14px 0; }
.dup-col h4 { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray); margin-bottom: 8px; }
.dup-col .row { padding: 5px 0; font-size: .9rem; border-bottom: 1px solid var(--line-soft); }
.dup-col .row:last-child { border-bottom: 0; }
.dup-col .k { color: var(--gray); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; display: block; }
.chantier-total { font-family: var(--display); font-weight: 700; color: var(--blue-700); }
.wrap { max-width: 1140px; margin: 0 auto; padding: 28px 24px 80px; }
/* Le tableau de factures a beaucoup de colonnes : sur un écran large, on lui
   laisse plus de place que le .wrap standard pour éviter le scroll horizontal
   interne quand la fenêtre le permet. */
.wrap.wrap-wide { max-width: 1600px; }

/* ---------- En-tête projet (hero) ------------------------------------ */
.hero {
    background: linear-gradient(135deg, #0a96d8 0%, var(--blue-600) 60%, var(--blue-700) 100%);
    color: #fff; border-radius: var(--r-lg); padding: 30px 34px; position: relative; overflow: hidden;
    box-shadow: var(--shadow);
    display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: center;
}
.hero::after {
    content: ""; position: absolute; right: -60px; top: -60px; width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(255,255,255,.16), transparent 60%); pointer-events: none;
}
/* fines lignes "plan d'architecte" en fond */
.hero::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .12;
    background-image: linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px);
    background-size: 34px 34px;
    -webkit-mask-image: linear-gradient(120deg, #000, transparent 70%);
            mask-image: linear-gradient(120deg, #000, transparent 70%);
}
.hero-meta { position: relative; z-index: 1; }
.hero-eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: .72rem; font-weight: 800; opacity: .85; }
.hero h1 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); margin: 6px 0 14px; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.fact { display: flex; flex-direction: column; }
.fact .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; opacity: .8; font-weight: 700; }
.fact .v { font-family: var(--display); font-weight: 600; font-size: 1.02rem; }

/* ---------- Anneau de progression ------------------------------------ */
.ring-wrap { position: relative; z-index: 1; display: grid; place-items: center; }
.ring { width: 150px; height: 150px; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: rgba(255,255,255,.25); stroke-width: 12; }
.ring .prog  { fill: none; stroke: #fff; stroke-width: 12; stroke-linecap: round;
    stroke-dasharray: var(--circ); stroke-dashoffset: var(--circ);
    transition: stroke-dashoffset 1.4s cubic-bezier(.2,.7,.2,1); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-pct { font-family: var(--display); font-weight: 700; font-size: 2.1rem; line-height: 1; }
.ring-cap { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; opacity: .85; font-weight: 700; }

/* ---------- Bandeau de validation ------------------------------------ */
.review-banner {
    margin-top: 22px; display: flex; align-items: center; gap: 14px;
    background: var(--ok-tint); border: 1px solid #cdeede; color: #14704c;
    border-radius: var(--r); padding: 16px 20px; font-weight: 600;
    animation: rise .5s ease both;
}
.review-banner .ico { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
    background: var(--ok); color: #fff; display: grid; place-items: center; font-weight: 800; }

/* ---------- Disposition deux colonnes -------------------------------- */
.cols { display: grid; grid-template-columns: 1fr 360px; gap: 26px; margin-top: 26px; align-items: start; }
.section-title { font-size: 1.18rem; margin-bottom: 4px; }
.section-sub { color: var(--gray); font-size: .9rem; margin: 0 0 18px; }

/* ======================================================================
   Frise des phases (signature)
   ====================================================================== */
.timeline { position: relative; display: grid; gap: 16px; }
.tl-item {
    position: relative; padding-left: 56px;
}
/* ligne verticale */
.tl-item::before {
    content: ""; position: absolute; left: 19px; top: 38px; bottom: -16px; width: 2px;
    background: var(--line);
}
.tl-item:last-child::before { display: none; }
.tl-item.completed::before { background: var(--blue); }
.tl-node {
    position: absolute; left: 0; top: 4px; width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center; font-family: var(--display); font-weight: 700;
    background: #fff; border: 2px solid var(--line); color: var(--gray); z-index: 1;
    transition: all .25s ease;
}
.tl-item.completed .tl-node { background: var(--blue); border-color: var(--blue); color: #fff; }
.tl-item.active .tl-node {
    border-color: var(--blue); color: var(--blue); box-shadow: 0 0 0 6px rgba(1,136,204,.14);
    animation: pulse 2.4s ease-in-out infinite;
}
.phase-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: var(--shadow-sm); overflow: hidden; transition: box-shadow .2s, border-color .2s;
}
.tl-item.active .phase-card { border-color: rgba(1,136,204,.4); box-shadow: var(--shadow); }
.tl-item.upcoming .phase-card { opacity: .82; }
.phase-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; cursor: pointer; user-select: none; }
.phase-head .ph-titles { flex: 1; min-width: 0; }
.phase-head h3 { font-size: 1.05rem; }
.phase-head .ph-desc { color: var(--ink-soft); font-size: .88rem; margin-top: 3px; }
.status-pill { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 5px 11px; border-radius: 999px; white-space: nowrap; }
.status-pill.completed { background: var(--blue-tint); color: var(--blue-700); }
.status-pill.active { background: var(--warn-tint); color: var(--warn); }
.status-pill.upcoming { background: var(--line-soft); color: var(--gray); }
.phase-pct { font-family: var(--display); font-weight: 700; color: var(--blue-700); font-size: .95rem; }
.chev { transition: transform .25s ease; color: var(--gray); }
.phase-body { padding: 0 18px; max-height: 0; overflow: hidden; transition: max-height .35s ease, padding .35s ease; }
.phase-card.open .phase-body { padding: 4px 18px 20px; } /* max-height calculée en JS (initAccordion), pas de valeur fixe : voir client.js */
.phase-card.open .chev { transform: rotate(180deg); }

.minibar { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; margin: 0 18px 14px; }
.minibar > i { display: block; height: 100%; background: linear-gradient(90deg, #06a0e4, var(--blue-600)); border-radius: 999px; width: 0; transition: width 1s cubic-bezier(.2,.7,.2,1); }

/* ---------- Listes d'actions ----------------------------------------- */
.act-group { margin-top: 10px; }
.act-group h4 { font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; color: var(--gray); margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.act-group h4 .dot { width: 8px; height: 8px; border-radius: 50%; }
.act-group.promo h4 .dot { background: var(--gray); }
.act-group.client h4 .dot { background: var(--blue); }

.task { display: flex; align-items: flex-start; gap: 11px; padding: 9px 10px; border-radius: var(--r-sm); transition: background .15s; }
.task + .task { border-top: 1px solid var(--line-soft); }
.task.editable { cursor: pointer; }
.task.editable:hover { background: var(--blue-tint-2); }
.task .box {
    flex: 0 0 auto; width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line);
    display: grid; place-items: center; background: #fff; transition: all .18s ease; margin-top: 1px;
}
.task .box svg { width: 13px; height: 13px; stroke: #fff; stroke-width: 3.4; fill: none; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset .25s ease .03s; }
.task.done .box { background: var(--blue); border-color: var(--blue); }
.task.done.promo .box { background: var(--gray); border-color: var(--gray); }
.task.done .box svg { stroke-dashoffset: 0; }
.task .lbl { font-size: .93rem; color: var(--ink); }
.task.done .lbl { color: var(--gray); text-decoration: line-through; text-decoration-color: rgba(101,101,101,.5); }
.task .ro { font-size: .7rem; color: var(--gray); margin-left: auto; white-space: nowrap; align-self: center; }

.task-more {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    padding: 9px 10px; border: 0; border-top: 1px solid var(--line-soft); background: none;
    cursor: pointer; font-family: var(--body); font-size: .88rem; font-weight: 700; color: var(--blue-600);
}
.task-more:hover { background: var(--blue-tint-2); }
.task-more .dots { font-size: 1.1rem; line-height: 1; color: var(--gray); }

/* ======================================================================
   Aside : documents + messagerie
   ====================================================================== */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 20px; margin-bottom: 22px; }
.panel h2 { font-size: 1.05rem; margin-bottom: 4px; display: flex; align-items: center; gap: 9px; }
.panel .panel-sub { color: var(--gray); font-size: .82rem; margin: 0 0 16px; }

.doc { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.doc:first-of-type { border-top: 0; }
.doc .ic { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; background: var(--blue-tint); color: var(--blue-700); display: grid; place-items: center; font-weight: 800; font-size: .72rem; font-family: var(--display); }
.doc .meta { flex: 1; min-width: 0; }
.doc .meta .n { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc .meta .s { font-size: .76rem; color: var(--gray); }
.doc a.dl { color: var(--blue-600); font-weight: 700; font-size: .82rem; text-decoration: none; white-space: nowrap; }
.empty { color: var(--gray); font-size: .88rem; padding: 8px 0; }

.uploader { margin-top: 14px; border: 1.5px dashed var(--line); border-radius: var(--r-sm); padding: 14px; text-align: center; transition: border-color .2s, background .2s; }
.uploader.drag { border-color: var(--blue); background: var(--blue-tint-2); }
.uploader label { font-weight: 700; color: var(--blue-700); cursor: pointer; font-size: .9rem; }
.uploader .small { font-size: .74rem; color: var(--gray); margin-top: 4px; }

/* ---------- Photos du chantier ---------------------------------------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 16px; }
.photo-tile { position: relative; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--card); cursor: pointer; }
.photo-tile img { display: block; width: 100%; height: 120px; object-fit: cover; }
.photo-tile .pt-cap { font-size: .78rem; font-weight: 600; padding: 7px 9px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-tile .pt-when { font-size: .7rem; color: var(--gray); padding: 2px 9px 9px; }
.photo-tile .pt-del {
    position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
    background: rgba(20,34,46,.55); color: #fff; line-height: 1; display: grid; place-items: center;
}
.photo-tile .pt-del:hover { background: var(--danger); }

/* L'overlay centre .lightbox avec flex (pas de position:fixed indépendante pour
   les boutons : ils vivent DANS le flux, collés à l'image, donc jamais « ailleurs »). */
.lightbox-back { position: fixed; inset: 0; background: rgba(10,16,20,.92); z-index: 60; display: none; align-items: center; justify-content: center; padding: 24px; }
.lightbox-back.show { display: flex; animation: fade .2s ease; }

.lightbox { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 960px; height: 100%; max-height: 90vh; }
.lightbox .lb-stage { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; height: 100%; }
.lightbox img { display: block; max-width: 100%; max-height: 78vh; border-radius: var(--r-sm); object-fit: contain; background: #000; }
.lightbox .lb-cap { color: #fff; font-size: .95rem; text-align: center; max-width: 640px; }
.lightbox .lb-when { color: rgba(255,255,255,.65); font-size: .78rem; }

.lightbox-back .lb-close, .lightbox .lb-prev, .lightbox .lb-next {
    background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 50%; flex: 0 0 auto;
    width: 42px; height: 42px; font-size: 1.1rem; cursor: pointer; display: grid; place-items: center;
}
.lightbox-back .lb-close:hover, .lightbox .lb-prev:hover, .lightbox .lb-next:hover { background: rgba(255,255,255,.25); }
.lightbox-back .lb-close { position: absolute; top: 20px; right: 20px; }

@media (max-width: 640px) {
    .lightbox { gap: 6px; }
    .lightbox .lb-prev, .lightbox .lb-next { width: 34px; height: 34px; font-size: 1rem; }
    .lightbox img { max-height: 68vh; }
}

/* ---------- Messagerie ------------------------------------------------ */
.thread { display: grid; gap: 12px; max-height: 380px; overflow-y: auto; padding-right: 4px; margin-bottom: 14px; }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 14px; font-size: .9rem; line-height: 1.5; box-shadow: var(--shadow-sm); }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin: 0; }
.msg .when { display: block; font-size: .68rem; opacity: .7; margin-top: 6px; font-weight: 600; }
.msg.promo { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.promo .from { font-size: .68rem; font-weight: 800; color: var(--blue-700); text-transform: uppercase; letter-spacing: .06em; display: block; margin-bottom: 3px; }
.msg.client { background: linear-gradient(135deg, #06a0e4, var(--blue-600)); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.msg.client .when { opacity: .85; }

.rt-toolbar { display: flex; gap: 4px; margin-bottom: 6px; }
.rt-toolbar button { width: 32px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 7px; cursor: pointer; font-weight: 800; font-size: .85rem; color: var(--ink-soft); }
.rt-toolbar button:hover { background: var(--blue-tint-2); border-color: var(--blue); }
.editor {
    min-height: 76px; border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px;
    background: #fbfdfe; font-size: .92rem; outline: none;
}
.editor:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(1,136,204,.12); background: #fff; }
.editor:empty::before { content: attr(data-ph); color: var(--gray); }

/* ======================================================================
   Admin
   ====================================================================== */
.admin-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.admin-head h1 { font-size: 1.5rem; }
.admin-head .spacer { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat .n { font-family: var(--display); font-weight: 700; font-size: 1.9rem; color: var(--blue-700); line-height: 1; }
.stat .l { font-size: .78rem; color: var(--gray); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; margin-top: 6px; }

.table-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); overflow-x: auto; overflow-y: hidden; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gray); padding: 13px 18px; border-bottom: 1px solid var(--line); background: var(--blue-tint-2); }
table.grid td { padding: 13px 18px; border-bottom: 1px solid var(--line-soft); font-size: .92rem; vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr:hover td { background: var(--blue-tint-2); }
.tag { font-family: var(--display); font-weight: 600; background: var(--blue-tint); color: var(--blue-700); padding: 3px 9px; border-radius: 7px; font-size: .85rem; }
.pbar { width: 120px; height: 8px; background: var(--line-soft); border-radius: 999px; overflow: hidden; display: inline-block; vertical-align: middle; }
.pbar > i { display: block; height: 100%; background: linear-gradient(90deg, #06a0e4, var(--blue-600)); }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* modale */
.modal-back { position: fixed; inset: 0; background: rgba(20,34,46,.45); backdrop-filter: blur(3px); z-index: 50; display: none; place-items: center; padding: 20px; }
.modal-back.show { display: grid; animation: fade .2s ease; }
.modal { background: #fff; border-radius: var(--r-lg); width: 100%; max-width: 540px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto; animation: rise .35s cubic-bezier(.2,.7,.2,1) both; }
.modal header { padding: 22px 26px 0; }
.modal header h3 { font-size: 1.25rem; }
.modal .body { padding: 18px 26px 26px; display: grid; gap: 14px; }
.modal .foot { display: flex; gap: 10px; justify-content: flex-end; }

.admin-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 22px; }
.phase-admin { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px; margin-bottom: 12px; }
.phase-admin.is-current { border-color: var(--blue); background: var(--blue-tint-2); }
.phase-admin .pa-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.phase-admin .pa-head .pos { font-family: var(--display); font-weight: 700; color: var(--gray); }
.phase-admin .pa-head h4 { flex: 1; font-size: 1rem; }
.adm-task { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: .9rem; }
.adm-task .side { font-size: .66rem; font-weight: 800; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; letter-spacing: .05em; }
.adm-task .side.client { background: var(--blue-tint); color: var(--blue-700); }
.adm-task .side.promo { background: var(--line-soft); color: var(--gray); }
.adm-task .lbl { flex: 1; }
.adm-task.done .lbl { text-decoration: line-through; color: var(--gray); }
.link-del { color: var(--danger); font-size: .8rem; text-decoration: none; font-weight: 700; cursor: pointer; background: none; border: 0; }
.link-move { color: var(--gray); font-size: .7rem; cursor: pointer; background: none; border: 0; padding: 2px 4px; line-height: 1; }
.link-move:hover { color: var(--blue); }

.drag-handle {
    display: inline-grid; grid-template-columns: repeat(2, 3px); grid-auto-rows: 3px; gap: 2px;
    width: 13px; height: 16px; flex-shrink: 0; align-content: center; cursor: grab;
}
.drag-handle i { width: 3px; height: 3px; border-radius: 50%; background: var(--line); display: block; }
.drag-handle:hover i { background: var(--gray); }
.adm-task:active .drag-handle { cursor: grabbing; }
.adm-task.dragging { opacity: .4; }
.adm-task.drag-over-top { box-shadow: inset 0 2px 0 var(--blue); }
.adm-task.drag-over-bottom { box-shadow: inset 0 -2px 0 var(--blue); }
.inline-add { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.inline-add input, .inline-add select { padding: 8px 11px; border: 1.5px solid var(--line); border-radius: var(--r-sm); font-family: var(--body); font-size: .88rem; }
.inline-add input { flex: 1; min-width: 160px; }

.cred-box { background: var(--warn-tint); border: 1px solid #f0dcc0; border-radius: var(--r-sm); padding: 14px 16px; font-size: .9rem; }
.cred-box code { background: #fff; }

.back-link { color: var(--gray); text-decoration: none; font-weight: 700; font-size: .88rem; display: inline-flex; align-items: center; gap: 6px; }
.back-link:hover { color: var(--blue-700); }

/* ---------- Import groupé : écran de triage ---------------------------- */
.batch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 14px; }
.batch-card { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: #fff; transition: opacity .2s; }
.batch-thumb { display: block; width: 100%; height: 140px; object-fit: contain; background: var(--line-soft); }
.batch-thumb.batch-thumb-error { background: var(--line-soft) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23999" stroke-width="1.5"><path d="M6 2h9l5 5v15H6z"/><path d="M15 2v5h5"/></svg>') center/32px no-repeat; }
.batch-card-body { padding: 10px 12px; display: grid; gap: 4px; }
.batch-card-body strong { font-size: .88rem; }
.batch-card-body .btn-sm { margin-top: 6px; }

/* ======================================================================
   Animations
   ====================================================================== */
@keyframes rise  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 6px rgba(1,136,204,.14); } 50% { box-shadow: 0 0 0 11px rgba(1,136,204,.04); } }
.reveal { animation: rise .55s cubic-bezier(.2,.7,.2,1) both; }
.reveal-2 { animation-delay: .08s; }
.reveal-3 { animation-delay: .16s; }
.reveal-4 { animation-delay: .24s; }

/* ======================================================================
   Responsive
   ====================================================================== */
@media (max-width: 920px) {
    .cols { grid-template-columns: 1fr; }
    .hero { grid-template-columns: 1fr; text-align: left; }
    .ring-wrap { justify-self: start; }
}
@media (max-width: 560px) {
    .wrap { padding: 18px 16px 64px; }
    .hero { padding: 24px 20px; }
    .topbar-inner { padding: 12px 16px; }
    .ring { width: 124px; height: 124px; }
    .tl-item { padding-left: 48px; }
    .tl-node { width: 34px; height: 34px; }
    .tl-item::before { left: 16px; }
}

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