/* ── IMPORTS ─────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Mono:ital,wght@0,300;0,400;0,500;1,400&display=swap');

/* ── VARIABLES ───────────────────────────────────────────────────────────── */
/* CSS custom properties = variables réutilisables dans toute la feuille.
   Changer --accent ici met à jour TOUS les boutons, bordures, glows d'un coup. */
:root {
    --accent:    #d94fbd;   /* magenta TNTMom */
    --accent2:   #87CEEB;   /* bleu ciel */
    --green:     #3ecf8e;   /* succès / complété */
    --gold:      #D4AF37;   /* or classique */
    --gold-light: #F0D060;
    --gold-glow:  rgba(212, 175, 55, .35);
    --red:       #ef4444;   /* danger / supprimer */
    --bg:        #0f0f14;   /* fond principal */
    --surface:   #1a1a24;   /* cartes, panels */
    --surface2:  #222230;   /* inputs, hover */
    --border:    #2a2a3a;   /* bordures discrètes */
    --text:      #f0eeff;   /* texte principal */
    --muted:     #6e6e9a;   /* texte secondaire */
    --radius:    8px;
    --radius-lg: 14px;
}

/* ── GOLD THEME — touches dorées subtiles ─────────────────────────────── */
@keyframes gold-glow {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.55)); }
    50%       { filter: drop-shadow(0 0 9px rgba(212, 175, 55, 0.8)); }
}
@keyframes gold-sparkle {
    0%, 72%, 100% { opacity: 0; transform: scale(0); }
    75%            { opacity: 1; transform: scale(1); }
    80%            { opacity: 0; transform: scale(0.5); }
}
@keyframes gold-pulse {
    0%, 100% { box-shadow: 0 0 6px var(--gold-glow); }
    50%       { box-shadow: 0 0 16px var(--gold-glow), 0 0 32px rgba(212,175,55,.15); }
}
.gold-title {
    position: relative;
    display: inline-block;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 40%, #fffde0 55%, var(--gold) 80%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gold-glow 3.5s ease-in-out infinite;
    animation-delay: 0s;
}
.gold-mom::after {
    content: '';
    position: absolute;
    top: 7px;
    right: 1px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, rgba(255,248,180,0.6) 60%, transparent 100%);
    box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.8);
    animation: gold-sparkle 3.5s ease-in-out infinite;
    animation-delay: 0.7s;
    pointer-events: none;
}

.gold-border {
    border-color: var(--gold) !important;
    animation: gold-pulse 2s ease-in-out infinite;
}

/* ── SCROLLBAR CUSTOM ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); border-radius: 999px; }
::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #d94fbd 0%, #5a9ab8 50%, #d94fbd 100%);
    border-radius: 999px;
    box-shadow: 0 0 6px rgba(217, 79, 189, 0.4);
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
}
/* Firefox fallback only — Chrome uses ::-webkit-scrollbar above */
@supports (-moz-appearance: none) {
    * { scrollbar-width: thin; scrollbar-color: #d94fbd transparent; }
}

/* ── RESET & BASE ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'DM Mono', monospace;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.06em;
    line-height: 1.1;
    font-weight: normal;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--accent); }

/* ── LAYOUT ──────────────────────────────────────────────────────────────── */
.app-layout {
    display: grid;
    grid-template-columns: auto 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 2rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    width: 220px;
    min-width: 220px;
    transition: width 0.25s ease, min-width 0.25s ease, padding 0.25s ease, border-color 0.25s ease;
}

body.sidebar-collapsed .sidebar {
    width: 70px;
    min-width: 70px;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
    align-items: center;
}

/* Cache le texte et garde les icônes */
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-cat,
body.sidebar-collapsed .nav-badge {
    display: none;
}

body.sidebar-collapsed .sidebar-header {
    flex-direction: column;
    justify-content: center;
    gap: 0.8rem;
}

body.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 0.6rem 0;
}

body.sidebar-collapsed .sidebar-user {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Ajustement du bouton déconnexion sans texte */
body.sidebar-collapsed .sidebar-user .text-muted {
    display: inline-block;
    margin-top: 0.4rem;
}

/* ── Bouton toggle sidebar ───────────────────────────────────────────────── */
#nav-toggle {
    position: fixed;
    top: 1rem;
    left: calc(220px + 0.6rem);
    z-index: 300;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.3rem 0.55rem;
    cursor: pointer;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
    transition: left 0.25s ease, color 0.15s, background 0.15s;
}
#nav-toggle:hover { color: var(--text); background: var(--surface2); }
body.sidebar-collapsed #nav-toggle { left: 0.6rem; }

/* ── Nouveau bouton intégré (Desktop) ────────────────────────────────────── */
#desktop-nav-toggle {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, color 0.15s;
    outline: none;
}
#desktop-nav-toggle:hover {
    color: var(--accent2);
    transform: scale(1.15);
}

.sidebar-logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.6rem;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-shadow: 0 0 20px rgba(217, 79, 189, 0.4);
}

.sidebar-logo span {
    color: var(--accent2);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
    min-height: 0;      /* permet au flex item de rétrécir et de scroller */
    overflow-y: auto;
    scrollbar-width: none; /* Cache sur Firefox */
}
.sidebar-nav::-webkit-scrollbar {
    display: none; /* Cache sur Chrome/Safari/Edge */
}

.nav-icon {
    font-size: 1.25rem; /* Icônes plus grosses */
    width: 24px;        /* Fixe la largeur pour que les textes soient bien alignés */
    text-align: center;
}

.nav-bullet {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    margin-top: 0.1em;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 40%, #fffde0 55%, var(--gold) 80%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gold-glow 3.5s ease-in-out infinite;
}
.sidebar-nav a:nth-child(1) .nav-bullet { animation-delay: 0.3s; }
.sidebar-nav a:nth-child(2) .nav-bullet { animation-delay: 1.4s; }
.sidebar-nav a:nth-child(3) .nav-bullet { animation-delay: 2.5s; }
.nav-bullet::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, rgba(255,248,180,0.5) 70%, transparent 100%);
    box-shadow: 0 0 3px 1px rgba(255, 255, 255, 0.7);
    pointer-events: none;
}
.sidebar-nav a.active .nav-bullet::after {
    animation: gold-sparkle 2.5s ease-in-out infinite;
    animation-delay: 1.9s;
}

.sidebar-nav a {
    display: flex;
    align-items: center; /* Aligne le texte au centre des grosses icônes */
    gap: 0.5rem;
    color: var(--muted);
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    transition: all 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--surface2);
    color: var(--text);
}

.sidebar-user {
    font-size: 0.75rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.sidebar-user strong { color: var(--text); display: block; margin-bottom: 0.3rem; }

/* Animation rouge pour la déconnexion */
.logout-link .nav-icon { transition: all 0.2s ease; }
.logout-link:hover .nav-icon {
    filter: drop-shadow(0 0 6px var(--red));
    transform: scale(1.15);
}

.main {
    padding: 2.5rem 2.8rem;
    overflow-y: auto;
    scrollbar-width: none;
}
.main::-webkit-scrollbar { width: 0; height: 0; }

/* ── PAGE HEADER ─────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 2.8rem;
    color: var(--text);
}

.page-title span { color: var(--accent); }
.page-title .client-nom { color: #87CEEB; }

/* ── Glitch titre (partagé portail + admin) ──────────────────────────────── */
.glitch { position: relative; display: inline-block; color: #87CEEB; }
.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    overflow: hidden;
}
.glitch::before {
    color: #ffffff;
    clip-path: polygon(0 0, 100% 0, 100% 40%, 0 40%);
    transform: translateX(-2px);
    animation: glitch-top 3.5s infinite linear;
}
.glitch::after {
    color: #d94fbd;
    clip-path: polygon(0 60%, 100% 60%, 100% 100%, 0 100%);
    transform: translateX(2px);
    animation: glitch-bot 3.5s infinite linear;
}
@keyframes glitch-top {
    0%, 88%  { transform: translateX(-2px); opacity: 1; }
    89%      { transform: translateX(3px) skewX(-5deg); opacity: 0.8; }
    90%      { transform: translateX(-3px); opacity: 0.6; }
    91%      { transform: translateX(2px); opacity: 1; }
    92%, 100%{ transform: translateX(-2px); opacity: 1; }
}
@keyframes glitch-bot {
    0%, 88%  { transform: translateX(2px); opacity: 1; }
    89%      { transform: translateX(-3px) skewX(5deg); opacity: 0.8; }
    90%      { transform: translateX(3px); opacity: 0.6; }
    91%      { transform: translateX(-2px); opacity: 1; }
    92%, 100%{ transform: translateX(2px); opacity: 1; }
}

.page-sub {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.2rem;
}

/* ── STATS BAR ───────────────────────────────────────────────────────────── */
.stats-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.4rem;
    flex: 1;
    min-width: 110px;
}

.stat-card .stat-value {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.2rem;
    color: var(--accent);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 0.2rem;
}

/* ── CARDS ───────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.6rem;
}

.card + .card { margin-top: 1rem; }

.card-title {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--accent2);
}

/* ── CLIENT TABLE ────────────────────────────────────────────────────────── */
.client-table {
    width: 100%;
    border-collapse: collapse;
}

.client-table th {
    text-align: left;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
}

.client-table td {
    padding: 0.75rem 0.8rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    vertical-align: middle;
}

.client-table tr:last-child td { border-bottom: none; }

.client-table tbody tr {
    cursor: pointer;
    transition: background 0.12s;
}

.client-table tbody tr:hover { background: var(--surface2); }

/* ── BADGES DE STATUT ────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 500;
}

.badge-prospect  { background: rgba(135, 206, 235, 0.15); color: var(--accent2); }
.badge-actif     { background: rgba(62, 207, 142, 0.15);  color: var(--green);   }
.badge-completé  { background: rgba(200, 150, 62, 0.15);  color: var(--gold);    }
.badge-archivé   { background: rgba(110, 110, 154, 0.15); color: var(--muted);   }
.badge-draft      { background: rgba(110, 110, 154, 0.15); color: var(--muted);   }
.badge-envoyé     { background: rgba(135, 206, 235, 0.15); color: var(--accent2); }
.badge-signé      { background: rgba(62, 207, 142, 0.15);  color: var(--green);   }
.badge-en-attente { background: rgba(110, 110, 154, 0.15); color: var(--muted);   }
.badge-en-cours   { background: rgba(217, 79, 189, 0.15);  color: var(--accent);  }
.badge-livré      { background: rgba(135, 206, 235, 0.15); color: var(--accent2); }
.badge-payé       { background: rgba(212, 175, 55, .15);   color: var(--gold-light); border-color: rgba(212,175,55,.3); animation: gold-pulse 2.5s ease-in-out infinite; }
.badge-approuvé   { background: rgba(62, 207, 142, 0.15); color: var(--green); border-color: rgba(62,207,142,0.3); }

/* ── BOUTONS ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius);
    font-family: 'DM Mono', monospace;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: #c43aaa;
    color: white;
    box-shadow: 0 0 18px rgba(217, 79, 189, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--accent2);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    padding: 0.4rem 0.7rem;
}
.btn-ghost:hover { color: var(--text); background: var(--surface2); }

.btn-danger {
    background: transparent;
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
}

/* ── FORMULAIRES ─────────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.4rem;
}

.form-grid .span-2 { grid-column: span 2; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

label {
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 0.88rem;
    padding: 0.6rem 0.8rem;
    width: 100%;
    transition: border-color 0.15s;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(217, 79, 189, 0.15);
}

textarea { resize: vertical; min-height: 80px; }

select { cursor: pointer; }

/* Hack pour les options du select sur fond sombre */
select option { background: var(--surface2); }

.form-actions {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    margin-top: 1.4rem;
    flex-wrap: wrap;
}

/* ── PROCHAINE ÉTAPE ─────────────────────────────────────────────────────── */
.next-action-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--accent);
    background: rgba(99, 102, 241, 0.07);
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}
.next-action-contrat    { border-color: var(--accent);  background: rgba(217, 79, 189, 0.07); }
.next-action-formulaire { border-color: var(--accent2); background: rgba(135, 206, 235, 0.07); }
.next-action-facture    { border-color: #f59e0b;        background: rgba(245, 158, 11, 0.07); }
.next-action-en_cours   { border-color: var(--green);   background: rgba(62, 207, 142, 0.07); }

.na-icon { font-size: 1.6rem; flex-shrink: 0; }
.na-content { flex: 1; min-width: 0; }
.na-eyebrow {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.2rem;
}
.na-label { font-size: 0.9rem; color: var(--text); }
.na-btn   { flex-shrink: 0; white-space: nowrap; }

/* ── BARRE DE PROGRESSION PROJET ─────────────────────────────────────────── */
.projet-progress {
    height: 6px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}
.projet-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 99px;
    transition: width 0.6s ease;
    min-width: 4px;
}
.projet-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

/* ── SECTION COLLAPSIBLE (pour le formulaire nouveau client) ─────────────── */
.collapsible {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.collapsible summary {
    list-style: none;
    padding: 0.9rem 1.4rem;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--accent2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    transition: background 0.12s;
}

.collapsible summary:hover { background: var(--surface2); }
.collapsible[open] summary { border-bottom: 1px solid var(--border); }

.collapsible-body {
    padding: 1.4rem;
    background: var(--surface);
}

/* ── FICHE CLIENT ────────────────────────────────────────────────────────── */
.fiche-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ── SECTION TITRE ───────────────────────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.8rem;
}

.section-title {
    font-size: 1.1rem;
    color: var(--muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ── CONSULTATION ITEM ───────────────────────────────────────────────────── */
.consult-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.consult-item summary {
    list-style: none;
    padding: 0.7rem 1rem;
    background: var(--surface2);
    cursor: pointer;
    font-size: 0.82rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
}

.consult-item summary:hover { background: #2a2a3e; }

.consult-body {
    padding: 1rem;
    background: var(--surface);
}

.q-row {
    margin-bottom: 0.8rem;
}
.q-row .q-label {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 0.15rem;
}
.q-row .q-value {
    font-size: 0.85rem;
    color: var(--text);
}

/* ── MILESTONES EDITOR ───────────────────────────────────────────────────── */
.milestones-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.milestone-row {
    display: grid;
    grid-template-columns: 1fr 1fr 100px 120px auto;
    gap: 0.5rem;
    align-items: center;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
}

.milestone-row input,
.milestone-row select {
    background: var(--bg);
    border-color: transparent;
    font-size: 0.82rem;
    padding: 0.35rem 0.5rem;
    color: var(--text);
}

/* Couleur du texte et du picker natif pour input[type=date] */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

.milestone-row input:focus,
.milestone-row select:focus {
    border-color: var(--accent);
}

.milestones-total {
    text-align: right;
    font-size: 0.9rem;
    color: var(--green);
    padding: 0.4rem 0;
}

.milestones-total strong {
    font-size: 1.1rem;
}

/* ── CONTRAT PREVIEW ─────────────────────────────────────────────────────── */
.contrat-preview {
    background: #0a0a10;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    font-size: 0.85rem;
    line-height: 1.8;
}

.contrat-preview h2 {
    font-size: 1.8rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
}

.contrat-preview h3 {
    font-size: 1.1rem;
    color: var(--accent2);
    margin: 1.2rem 0 0.4rem;
}

.contrat-preview p { color: var(--muted); }

/* ── QUESTIONNAIRE CLIENT (page publique) ────────────────────────────────── */
.q-page {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    justify-content: center;
    padding: 3rem 1rem;
}

.q-container {
    width: 100%;
    max-width: 640px;
}

.q-logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    color: var(--accent);
    letter-spacing: 0.08em;
    margin-bottom: 2rem;
    text-align: center;
}

.q-intro {
    text-align: center;
    margin-bottom: 2rem;
}

.q-intro h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.q-intro p {
    font-size: 0.85rem;
    color: var(--muted);
}

.q-form .form-group { margin-bottom: 1.2rem; }

.q-success {
    text-align: center;
    padding: 3rem;
    background: var(--surface);
    border: 1px solid var(--green);
    border-radius: var(--radius-lg);
    margin-top: 2rem;
}

.q-success h2 {
    font-size: 2rem;
    color: var(--green);
    margin-bottom: 0.8rem;
}

/* ── LOGIN ───────────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 60% 50% at 20% 30%, rgba(217, 79, 189, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 80% 70%, rgba(135, 206, 235, 0.06) 0%, transparent 60%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
}

.login-logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.2rem;
    color: var(--accent);
    text-align: center;
    letter-spacing: 0.08em;
    text-shadow: 0 0 30px rgba(217, 79, 189, 0.35);
    margin-bottom: 0.3rem;
}

.login-sub {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
    letter-spacing: 0.06em;
    margin-bottom: 2rem;
}

.login-card .form-group { margin-bottom: 1rem; }

.error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
    border-radius: var(--radius);
    padding: 0.5rem 0.8rem;
    font-size: 0.82rem;
    margin-bottom: 1rem;
}

/* ── DIVIDER ─────────────────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.2rem 0;
}

/* ── UTILITIES ───────────────────────────────────────────────────────────── */
.flex         { display: flex; }
.gap-sm       { gap: 0.5rem; }
.gap-md       { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted   { color: var(--muted); font-size: 0.82rem; }
.text-accent  { color: var(--accent); }
.text-green   { color: var(--green); }
.mt-sm        { margin-top: 0.5rem; }
.mt-md        { margin-top: 1rem; }
.mt-lg        { margin-top: 1.5rem; }
.empty-state  {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    font-size: 0.85rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* ── TIMELINE — scroll horizontal sur mobile ─────────────────────────────── */
.timeline-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.4rem;
}
/* ── RESPONSIVE TABLETTE ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .app-layout { grid-template-columns: 1fr; align-content: start; }

    /* On cache la flèche desktop (inutile sur mobile) */
    #desktop-nav-toggle { display: none !important; }

    /* Le toggle flotte en haut à droite sur mobile (la sidebar est en barre horizontale) */
    #nav-toggle {
        position: static;
        margin-left: auto;
        order: 99;
    }

    /* La sidebar verticale devient une barre horizontale en haut */
    .sidebar {
        position: static;
        height: auto;
        width: auto;
        min-width: 0;
        flex-direction: row;
        align-items: center;
        padding: 0.9rem 1.2rem;
        flex-wrap: wrap;
        gap: 0.6rem;
        transition: none;
        overflow: visible;
    }

    body.sidebar-collapsed .sidebar {
        display: none;
    }

    .sidebar-nav { flex-direction: row; flex: none; }

    /* L'info user (nom + logout) est poussée à droite avec margin-left: auto */
    .sidebar-user {
        border-top: none;
        padding-top: 0;
        border-left: 1px solid var(--border);
        padding-left: 1rem;
        margin-left: auto;
    }

    .main { padding: 1.5rem 1.2rem; }

    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .milestone-row { grid-template-columns: 1fr 1fr; gap: 0.4rem; }

    /* Table admin scrollable horizontalement sur tablette */
    .client-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Sidebar portail en mode horizontal : cache la desc BMC, garde juste le bouton */
    .bmc-desc { display: none; }
    .bmc-btn { margin-top: 0; }

    /* Sidebar-user portail : empêche le client-nom de prendre trop de place */
    .client-nom { font-size: 1rem; }
}

/* ── RESPONSIVE TÉLÉPHONE ────────────────────────────────────────────────── */
@media (max-width: 540px) {
    .sidebar { padding: 0.75rem 1rem; gap: 0.5rem; }
    .sidebar-logo { font-size: 1.25rem; }

    /* Nav admin : scroll horizontal pour ne pas wrapper sur 2 lignes */
    .sidebar-nav { flex-wrap: nowrap; overflow-x: auto; gap: 0.3rem; -webkit-overflow-scrolling: touch; }
    .sidebar-nav a { font-size: 0.75rem; padding: 0.35rem 0.5rem; white-space: nowrap; flex-shrink: 0; }

    .sidebar-user strong { display: none; }
    .sidebar-user { border-left: none; padding-left: 0; font-size: 0.72rem; }

    .main { padding: 1rem 0.85rem; }
    .page-title { font-size: 1.9rem; }
    .card { padding: 1rem; }

    /* Stats bar : grille 2×2 au lieu de flex qui donne des largeurs inégales */
    .stats-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .stat-card { padding: 0.75rem 0.9rem; }
    .stat-card .stat-value { font-size: 1.7rem; }

    /* Timeline : scroll horizontal plutôt que labels minuscules */
    .timeline {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
        flex-wrap: nowrap;
    }
    .timeline-point { min-width: 68px; flex-shrink: 0; }
    .timeline-label { font-size: 0.62rem; max-width: 64px; }

    /* Cibles touch : primaire 40px, utilitaires ghost/danger 36px */
    .btn          { min-height: 40px; padding: 0.5rem 0.85rem; }
    .btn-ghost    { min-height: 36px; }
    .btn-danger   { min-height: 36px; }

    .page-header { flex-direction: column; align-items: flex-start; margin-bottom: 1.2rem; }
    .milestone-row { grid-template-columns: 1fr 1fr; }
    .contrat-preview { padding: 1.2rem; }

    /* Login */
    .login-card { padding: 1.8rem 1.2rem; margin: 1rem; }

    /* Form inline projet → pleine largeur */
    .projet-new-input { width: 100% !important; margin-bottom: 0.5rem; }
    .projet-new-form { flex-direction: column; }

    /* ── UX admin mobile ─────────────────────────────────────────────────── */
    /* Section-header : titre + bouton action wrap si besoin, bouton compact */
    .section-header { flex-wrap: wrap; gap: 0.4rem 0.8rem; }
    .section-header .btn { min-height: 34px; padding: 0.28rem 0.6rem; font-size: 0.77rem; }

    /* Header fiche client : actions plus compactes */
    .fiche-hdr-actions .btn { min-height: 34px; }

    /* Facture table : masquer N° — colonne non critique mobile */
    .fiche-invoice-wrap table th:nth-child(1),
    .fiche-invoice-wrap table td:nth-child(1) { display: none; }

    /* Fichiers partagés : wrap sur petits écrans */
    .fiche-file-row { flex-wrap: wrap; gap: 0.4rem; }
    .fiche-file-row > div:first-child { flex: 1; min-width: 0; }

    /* Upload fichier : bouton pleine largeur sur mobile */
    .fiche-upload-form { flex-direction: column; }
    .fiche-upload-form .btn { width: 100%; }

    /* ── Portail client UX ──────────────────────────────────────────────── */
    /* Factures table → card layout : N°|Description|Montant|Statut|PDF */
    .factures-table-wrap { overflow-x: visible; }
    .factures-table-wrap table thead { display: none; }
    .factures-table-wrap table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        padding: 0.8rem 0;
        border-bottom: 1px solid var(--border);
        gap: 0.15rem 0.6rem;
    }
    .factures-table-wrap table tbody tr:last-child { border-bottom: none; }
    .factures-table-wrap table td { display: block; padding: 0; border: none; }
    .factures-table-wrap table td:nth-child(1) { display: none; }
    .factures-table-wrap table td:nth-child(2) { grid-column: 1; grid-row: 1; }
    .factures-table-wrap table td:nth-child(3) { grid-column: 2; grid-row: 1; text-align: right !important; align-self: start; }
    .factures-table-wrap table td:nth-child(4) { grid-column: 1; grid-row: 2; }
    .factures-table-wrap table td:nth-child(5) { grid-column: 2; grid-row: 2; text-align: right !important; }

    /* Chat reply : textarea pleine largeur, bouton aligné à droite */
    .chat-reply-form { flex-direction: column; align-items: flex-end; }
    .chat-reply-form textarea { width: 100%; box-sizing: border-box; min-height: 72px; }
}

/* ── DASHBOARD FICHIERS CLIENT — layout mobile ───────────────────────────── */
@media (max-width: 480px) {
    /* Nom de fichier + bouton télécharger : passe en colonne sur très petit écran */
    .fichier-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .fichier-row .btn { width: 100%; justify-content: center; }
}

/* ── RESPONSIVE TRÈS PETIT (iPhone SE, 375px etc.) ──────────────────────── */
@media (max-width: 380px) {
    .page-title { font-size: 1.55rem; }
    .sidebar-nav a { font-size: 0.7rem; padding: 0.3rem 0.4rem; }
    .milestone-row { grid-template-columns: 1fr; }
    .stats-bar { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
    .main { padding: 0.75rem 0.65rem; }
    .card { padding: 0.8rem; }

    /* Next-action card : bouton CTA pleine largeur sur très petits écrans */
    .next-action-card { flex-direction: column; align-items: flex-start; }
    .na-btn { width: 100%; text-align: center; justify-content: center; }
}

/* ── FLASH MESSAGES ─────────────────────────────────────────────────────── */
.flash-container {
    margin-bottom: 1.2rem;
}

.flash {
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.flash-success {
    background: rgba(80, 200, 120, 0.15);
    border: 1px solid var(--green);
    color: var(--green);
}

.flash-error {
    background: rgba(220, 80, 80, 0.15);
    border: 1px solid var(--red);
    color: var(--red);
}

.flash-info {
    background: rgba(135, 206, 235, 0.12);
    border: 1px solid #87CEEB;
    color: #87CEEB;
}

/* ── TABS FICHE CLIENT ───────────────────────────────────────────────────── */
.fiche-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.2rem;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
    gap: 0;
}
.fiche-tabs::-webkit-scrollbar { width: 0; height: 0; }
.tab-btn {
    background: none;
    border: none;
    padding: 1.25rem 1.1rem;
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: color 0.15s, box-shadow 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); font-weight: 600; box-shadow: inset 0 -3px 0 var(--accent); }
.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: 0.58rem;
    font-weight: 700;
    border-radius: 99px;
    padding: 1px 5px;
    min-width: 15px;
    margin-left: 4px;
    vertical-align: middle;
}
.tab-panel { display: none; }
.tab-panel.active { display: flex; flex-direction: column; gap: 1rem; }

/* ── COMMAND CENTER DASHBOARD ────────────────────────────────────────────── */
.cmd-center {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.2rem;
}
.cmd-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.cmd-section-title {
    padding: 0.6rem 1rem;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
}
.cmd-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    gap: 0.8rem;
    cursor: pointer;
    transition: background 0.12s;
    text-decoration: none;
    color: inherit;
}
.cmd-row:last-child { border-bottom: none; }
.cmd-row:hover { background: var(--surface2); }
.cmd-row-left { flex: 1; min-width: 0; }
.cmd-row-left strong { display: block; font-size: 0.85rem; margin-bottom: 0.1rem; color: var(--text); }
.cmd-subject { display: block; font-size: 0.72rem; color: var(--accent2); margin-bottom: 0.15rem; }
.cmd-preview {
    display: block; font-size: 0.78rem; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cmd-row-right {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
}
.cmd-time { font-size: 0.67rem; color: var(--muted); }
.cmd-empty { padding: 0.8rem 1rem; font-size: 0.82rem; color: var(--muted); font-style: italic; }
.cmd-montant { font-size: 0.88rem; font-weight: 700; color: var(--green); }
@media (max-width: 700px) { .cmd-center { grid-template-columns: 1fr; } }

/* ── SKELETON LOADING ────────────────────────────────────────────────────── */
.skeleton {
    background: var(--surface2);
    background: linear-gradient(110deg, rgba(255,255,255,0.03) 8%, rgba(255,255,255,0.08) 18%, rgba(255,255,255,0.03) 33%);
    background-size: 200% 100%;
    animation: skeleton-shine 1.5s linear infinite;
    border-radius: var(--radius);
    border: none !important;
}
@keyframes skeleton-shine {
    to { background-position-x: -200%; }
}
.skeleton-text { height: 0.9rem; margin-bottom: 0.4rem; border-radius: 4px; width: 100%; }
.skeleton-text.short { width: 30%; }
.skeleton-text.medium { width: 60%; }
.skeleton-avatar { width: 32px; height: 32px; border-radius: 50%; }
.skeleton-block { height: 60px; margin-bottom: 0.5rem; border-radius: var(--radius); }

/* ── BADGES NAV MESSAGES ─────────────────────────────────────────────────── */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: 0.58rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 99px;
    padding: 0 4px;
    margin-left: 5px;
    vertical-align: middle;
    line-height: 1;
}

.pbn-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: #fff;
    font-size: 0.5rem;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

.pbn-icon { position: relative; display: inline-block; }

/* ── BADGES CONVERSATION ─────────────────────────────────────────────────── */
.thread-new-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: 99px;
    margin-left: 0.5rem;
    vertical-align: middle;
    text-transform: uppercase;
    animation: dot-pulse 2s ease-in-out infinite;
}

.chat-bubble--new {
    border-left-color: var(--accent) !important;
    background: rgba(217, 79, 189, 0.1) !important;
}

.chat-new-dot {
    color: var(--accent);
    font-size: 0.6rem;
    font-weight: 700;
    margin-left: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── FORMULAIRE RÉPONSE INLINE ───────────────────────────────────────────── */
.chat-reply-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.chat-reply-form textarea {
    flex: 1;
    resize: none;
    font-size: 0.85rem;
    padding: 0.45rem 0.7rem;
    min-height: 60px;
}

.chat-reply-form .btn {
    flex-shrink: 0;
    align-self: flex-end;
    font-size: 0.8rem;
    padding: 0.45rem 0.9rem;
    min-height: unset;
}

/* ── CHAT MESSAGES ───────────────────────────────────────────────────────── */
.chat-row { margin-bottom: 0.5rem; }

.chat-bubble {
    width: 100%;
    padding: 0.45rem 0.7rem;
    border-radius: var(--radius);
    font-size: 0.84rem;
    line-height: 1.5;
    white-space: pre-wrap;
    text-align: left;
}
.chat-bubble.client {
    background: rgba(100, 200, 255, 0.07);
    border-left: 3px solid rgba(100, 200, 255, 0.5);
}
.chat-bubble.admin {
    background: rgba(217, 79, 189, 0.07);
    border-left: 3px solid rgba(217, 79, 189, 0.4);
}
.chat-meta {
    font-size: 0.63rem;
    color: var(--muted);
    margin-bottom: 0.15rem;
}

.badge-unread {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 0.4rem;
    vertical-align: middle;
}

@keyframes glitch {
    /* ── calme ── */
    0%, 18%, 45%, 63%, 100% { text-shadow: none; transform: none; opacity: 1; }

    /* ── burst 1 ── */
    20% { text-shadow: -4px 0 #ff2d78, 4px 0 #87CEEB; transform: skewX(-3deg) translateX(3px); opacity: 0.85; }
    22% { text-shadow: 5px 0 #ff2d78, -5px 0 #87CEEB; transform: skewX(3deg) translateX(-3px); opacity: 1; }
    24% { text-shadow: none; transform: translateX(2px); }
    26% { text-shadow: -3px 0 #87CEEB, 3px 0 #ff2d78; transform: skewX(-2deg); opacity: 0.9; }
    28% { text-shadow: 2px 0 #ff2d78; transform: skewX(1deg) translateX(-1px); }
    30% { text-shadow: -5px 0 #ff2d78, 5px 0 #87CEEB; transform: skewX(-3deg); opacity: 0.8; }
    32% { text-shadow: none; transform: none; opacity: 1; }

    /* ── burst 2 ── */
    65% { text-shadow: -3px 0 #ff2d78, 3px 0 #87CEEB; transform: skewX(-2deg) translateX(2px); opacity: 0.9; }
    67% { text-shadow: 6px 0 #ff2d78, -6px 0 #87CEEB; transform: skewX(4deg) translateX(-3px); opacity: 0.75; }
    69% { text-shadow: none; transform: skewX(-1deg); }
    71% { text-shadow: -2px 0 #87CEEB, 2px 0 #ff2d78; transform: translateX(1px); opacity: 0.95; }
    73% { text-shadow: 3px 0 #ff2d78; transform: skewX(1.5deg); }
    75% { text-shadow: -4px 0 #ff2d78, 4px 0 #87CEEB; transform: skewX(-2deg); opacity: 0.85; }
    77% { text-shadow: none; transform: none; opacity: 1; }
}

.client-name-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.client-tag {
    position: relative;
    display: inline-block;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
    border: 1px solid rgba(212, 175, 55, 0.4);
    padding: 1px 7px;
    border-radius: 4px;
    width: fit-content;
}
.client-tag::after {
    content: '';
    position: absolute;
    top: calc(50% - 1px);
    left: 9px;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, rgba(255,248,180,0.6) 60%, transparent 100%);
    box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.8);
    animation: gold-sparkle 3.5s ease-in-out infinite;
    animation-delay: 2.8s;
    pointer-events: none;
}

.client-nom {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    letter-spacing: 0.08em;
    color: #fff;
    display: block;
    animation: glitch 3.5s infinite;
    animation-delay: 1.2s;
}

.page-title .client-nom {
    font-size: inherit;
    display: inline-block;
    letter-spacing: 0.04em;
}

.bmc-desc {
    font-size: 0.62rem;
    color: var(--muted);
    line-height: 1.5;
    margin-top: 0.4rem;
    font-style: italic;
}

.bmc-btn {
    display: inline-block;
    background: #FFDD00;
    color: #111;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.2s;
    margin-top: 0.75rem;
    white-space: nowrap;
}
.bmc-btn:hover { opacity: 0.85; }

.chat-thread {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    overflow: hidden;
}
.chat-thread summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.8rem;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    background: var(--surface2);
    list-style: none;
    user-select: none;
}
.chat-thread summary::-webkit-details-marker { display: none; }
.chat-thread summary::after {
    content: '›';
    font-size: 1rem;
    color: var(--muted);
    transition: transform 0.2s;
}
.chat-thread[open] summary::after { transform: rotate(90deg); }
.chat-thread-body {
    padding: 0.7rem 0.8rem 0.4rem;
}

/* ── ÉTAPES PROJET (portail client) ─────────────────────────────────────── */
.ms-steps { display: flex; flex-direction: column; margin-top: 1rem; }

.ms-step {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    position: relative;
}

.ms-step:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 13px;
    top: 30px;
    bottom: 0;
    width: 2px;
    background: var(--border);
    z-index: 0;
}
.ms-step.done:not(:last-child)::after    { background: var(--green);  opacity: 0.35; }
.ms-step.approuve:not(:last-child)::after { background: var(--green);  opacity: 0.25; }
.ms-step.livre:not(:last-child)::after   { background: var(--accent2); opacity: 0.25; }
.ms-step.active:not(:last-child)::after  { background: var(--accent);  opacity: 0.25; }

.ms-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    z-index: 1;
    position: relative;
    margin-top: 0.1rem;
}
.ms-step.done .ms-icon {
    background: var(--green);
    border-color: var(--green);
    color: #0f0f14;
    font-weight: 900;
    font-size: 0.68rem;
}
.ms-step.approuve .ms-icon {
    background: rgba(62,207,142,0.2);
    border-color: var(--green);
    color: var(--green);
    font-size: 0.78rem;
}
.ms-step.livre .ms-icon {
    background: rgba(135,206,235,0.15);
    border-color: var(--accent2);
    color: var(--accent2);
    font-size: 0.78rem;
}
.ms-step.active .ms-icon {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    animation: dot-pulse 2s ease-in-out infinite;
}

.ms-body {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.15rem 0 1rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
    min-width: 0;
}
.ms-step:last-child .ms-body { border-bottom: none; padding-bottom: 0.1rem; }

.ms-titre {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.35;
}
.ms-step.done .ms-titre    { color: var(--text); }
.ms-step.approuve .ms-titre { color: var(--text); }
.ms-step.livre .ms-titre   { color: var(--accent2); font-weight: 600; }
.ms-step.active .ms-titre  { color: var(--accent); font-weight: 600; }

.ms-meta {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.2rem;
    opacity: 0.7;
}

.ms-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    flex-shrink: 0;
}

.ms-prix {
    font-size: 0.78rem;
    color: var(--muted);
}
.ms-step.done .ms-prix    { color: var(--green); }
.ms-step.approuve .ms-prix { color: var(--green); }
.ms-step.livre .ms-prix   { color: var(--accent2); }
.ms-step.active .ms-prix  { color: var(--accent); }

.ms-badge-step {
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
    background: var(--surface2);
    color: var(--muted);
}
.ms-step.done .ms-badge-step   { background: rgba(62,207,142,0.1); color: var(--green); }
.ms-step.active .ms-badge-step { background: rgba(217,79,189,0.1); color: var(--accent); }

/* ── TIMELINE MILESTONES (portail client) ────────────────────────────────── */
.timeline {
    display: flex;
    align-items: flex-start;
    position: relative;
    padding: 0 0 0.5rem;
    margin-top: 1rem;
}

/* La ligne horizontale — positionnée au centre du dot (3rem section au-dessus + 7px demi-dot) */
.timeline::before {
    content: '';
    position: absolute;
    top: calc(3rem + 7px);
    left: 7px;
    right: 7px;
    height: 2px;
    background: var(--border);
}

.timeline-point {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Zone fixe au-dessus du dot — contient le titre du milestone */
.timeline-above {
    height: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 0.35rem;
    overflow: hidden;
    width: 100%;
}

.timeline-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg);
    z-index: 1;
    margin-bottom: 0.6rem;
    transition: all 0.3s;
}

.timeline-point.done .timeline-dot {
    background: var(--green);
    border-color: var(--green);
    box-shadow: 0 0 10px rgba(62, 207, 142, 0.6);
}

.timeline-point.active .timeline-dot {
    background: var(--accent);
    border-color: var(--accent);
    animation: dot-pulse 2s ease-in-out infinite;
}

.timeline-point.blocked .timeline-dot {
    background: transparent;
    border-color: rgba(255,255,255,0.12);
    cursor: not-allowed;
}

.timeline-point.blocked .timeline-dot-btn {
    cursor: not-allowed;
    opacity: 0.4;
}

.timeline-point.blocked .timeline-label {
    opacity: 0.4;
}

@keyframes dot-pulse {
    0%, 100% { box-shadow: 0 0 6px rgba(217, 79, 189, 0.5); }
    50%       { box-shadow: 0 0 18px rgba(217, 79, 189, 0.9); }
}

.timeline-label {
    font-size: 0.7rem;
    text-align: center;
    color: var(--muted);
    max-width: 80px;
    line-height: 1.3;
}

.timeline-point.done .timeline-label  { color: var(--green); }
.timeline-point.active .timeline-label { color: var(--accent); }

/* Indicateur "En cours" dans la zone au-dessus du dot */
.timeline-step-badge {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    white-space: nowrap;
    margin-bottom: 0.15rem;
}

/* Bouton transparent qui enveloppe le dot dans la vue admin — le dot garde tous ses styles */
.timeline-dot-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.6rem;
}

/* Le dot lui-même n'a plus besoin de margin quand il est dans le bouton */
.timeline-dot-btn .timeline-dot { margin-bottom: 0; }

/* Feedback visuel au survol */
.timeline-dot-btn:hover .timeline-dot {
    transform: scale(1.3);
    border-color: var(--accent2);
}

/* Marqueur deadline — tiret vertical qui croise le trait horizontal entre deux dots */
.timeline-deadline-at-mid {
    position: absolute;
    right: 0;
    top: calc(3rem + 7px);     /* même niveau que ::before — centre du dot */
    transform: translateX(50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    pointer-events: none;
}

.deadline-vline {
    width: 2px;
    height: 14px;
    margin-top: -7px;          /* centré sur la ligne : s'étend 7px au-dessus et 7px en-dessous */
    background: var(--accent);
    opacity: 0.85;
    border-radius: 1px;
}

.deadline-date-label {
    font-size: 0.53rem;
    color: var(--accent);
    white-space: nowrap;
    margin-top: 4px;
    font-family: 'DM Mono', monospace;
    letter-spacing: 0.02em;
}

/* ── FORMULAIRE BUILDER ──────────────────────────────────────────────────── */
.q-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    transition: border-color 0.15s, opacity 0.15s;
    cursor: default;
}
.q-card:hover { border-color: rgba(217,79,189,0.25); }
.q-card.dragging { opacity: 0.35; }
.q-card.drag-over { border-color: var(--accent); border-style: dashed; }

.q-drag-handle {
    color: var(--muted);
    cursor: grab;
    font-size: 1.1rem;
    padding: 0.1rem 0;
    user-select: none;
    flex-shrink: 0;
    line-height: 1.4;
}
.q-drag-handle:active { cursor: grabbing; }

.q-body { flex: 1; min-width: 0; }

.q-header { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.q-titre {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    flex: 1;
}
.q-requis { color: var(--accent); font-size: 0.75rem; }

.q-sous-titre {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.2rem;
}

.q-options-preview {
    margin-top: 0.4rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.6rem;
    font-size: 0.72rem;
    color: var(--muted);
}

.q-type-badge {
    font-size: 0.62rem;
    padding: 2px 7px;
    border-radius: var(--radius);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex-shrink: 0;
}
.q-type-texte     { background: rgba(217,79,189,0.1);  color: var(--accent);  border: 1px solid rgba(217,79,189,0.3); }
.q-type-paragraphe{ background: rgba(135,206,235,0.1); color: var(--accent2); border: 1px solid rgba(135,206,235,0.3); }
.q-type-choix     { background: rgba(62,207,142,0.1);  color: var(--green);   border: 1px solid rgba(62,207,142,0.3); }
.q-type-cases     { background: rgba(212,175,55,0.1);  color: var(--gold);    border: 1px solid rgba(212,175,55,0.3); }
.q-type-note      { background: rgba(255,159,67,0.1);  color: #ff9f43;        border: 1px solid rgba(255,159,67,0.3); }
.q-type-date      { background: rgba(90,154,184,0.1);  color: #5a9ab8;        border: 1px solid rgba(90,154,184,0.3); }
.q-type-oui_non   { background: rgba(110,110,154,0.1); color: var(--muted);   border: 1px solid var(--border); }
.q-type-section   { background: transparent; color: var(--muted); border: 1px solid var(--border); }

.q-actions { display: flex; gap: 0.3rem; align-items: center; flex-shrink: 0; }

.q-edit-form {
    display: none;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}
.q-edit-form.open { display: block; }

/* Grille du formulaire d'ajout de question */
.add-q-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}
@media (max-width: 600px) { .add-q-grid { grid-template-columns: 1fr; } }

/* ── FACTURES TABLE CLIENT — scroll horizontal ──────────────────────────── */
.factures-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Formulaires-list cards */
.formulaire-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    transition: border-color 0.15s;
    cursor: pointer;
}
.formulaire-card:hover { border-color: rgba(217,79,189,0.35); }

/* ── PORTAIL BOTTOM NAV (mobile only) ──────────────────────────────────── */
.portail-bottom-nav {
    display: none; /* caché sur desktop */
}

@media (max-width: 600px) {
    /* Masque la sidebar nav + user info côté PORTAIL seulement — remplacés par la bottom bar */
    /* La sidebar admin (.sidebar sans .sidebar-portail) garde sa nav visible */
    .sidebar-portail .sidebar-nav,
    .sidebar-portail .sidebar-user { display: none; }

    /* Le header sidebar portail devient juste le logo centré */
    .sidebar-portail {
        justify-content: center;
        padding: 0.6rem 1rem;
    }

    /* Espace en bas pour ne pas cacher le contenu derrière la bottom bar (portail seulement) */
    .sidebar-portail ~ .main { padding-bottom: 80px; }

    /* Bottom tab bar */
    .portail-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: var(--surface);
        border-top: 1px solid var(--border);
        height: 60px;
    }

    .pbn-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        text-decoration: none;
        color: var(--muted);
        font-size: 0.6rem;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        transition: color 0.15s;
        padding: 0.3rem 0;
    }

    .pbn-item.active {
        color: var(--accent);
    }

    .pbn-icon {
        font-size: 1.1rem;
        line-height: 1;
    }

    .pbn-label {
        font-size: 0.58rem;
        font-family: 'DM Mono', monospace;
    }

    /* Cache le texte bmc sur mobile, garde juste le bouton */
    .bmc-desc { display: none; }

    /* Bouton déconnexion dans la bottom nav */
    .pbn-logout { color: var(--red); opacity: 0.6; }
    .pbn-logout:hover { opacity: 1; }
}

/* ── ADMIN BOTTOM NAV (mobile only) ─────────────────────────────────────────── */
.admin-bottom-nav { display: none; }

@media (max-width: 600px) {
    /* Cache la sidebar nav + user admin sur mobile — remplacés par la bottom bar */
    .sidebar:not(.sidebar-portail) .sidebar-nav,
    .sidebar:not(.sidebar-portail) .sidebar-user { display: none; }

    /* Sidebar admin réduite au logo centré */
    .sidebar:not(.sidebar-portail) { justify-content: center; padding: 0.6rem 1rem; }

    /* Espace en bas pour ne pas masquer le contenu */
    .sidebar:not(.sidebar-portail) ~ .main { padding-bottom: 80px; }

    /* Bottom bar admin visible */
    .admin-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 100;
        background: var(--surface);
        border-top: 1px solid var(--border);
        height: 60px;
    }
}

/* ── CLIENT FICHE ADMIN — mobile fixes ─────────────────────────────────────── */
.fiche-file-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.fiche-invoice-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.facture-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
    margin-bottom: 0.7rem;
}

@media (max-width: 540px) {
    /* !important needed to beat inline style align-items: flex-end */
    .fiche-hdr-actions { align-items: flex-start !important; width: 100%; }
    .fiche-hdr-actions form select { width: 100%; box-sizing: border-box; }
    .fiche-hdr-actions > div { flex-wrap: wrap; }
    .facture-form-grid { grid-template-columns: 1fr; }

    /* ── Dashboard client table → card list ──────────────────────── */
    .client-table-wrap { overflow-x: visible; }
    .client-table thead { display: none; }
    .client-table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        padding: 0.8rem 0;
        gap: 0.1rem 0.6rem;
        border-bottom: 1px solid var(--border);
    }
    .client-table tbody tr:last-child { border-bottom: none; }
    .client-table td {
        display: block;
        padding: 0;
        border: none;
    }
    /* Nom + email → colonne gauche, rangée 1 */
    .client-table td:nth-child(1) { grid-column: 1; grid-row: 1; }
    /* Statut → colonne droite, rangée 1, centré verticalement */
    .client-table td:nth-child(4) { grid-column: 2; grid-row: 1; align-self: center; }
    /* Entreprise → rangée 2, pleine largeur, texte discret */
    .client-table td:nth-child(2) {
        grid-column: 1 / 3; grid-row: 2;
        font-size: 0.75rem; color: var(--muted);
    }
    /* Secteur + Ajouté → masqués (info non critique sur mobile) */
    .client-table td:nth-child(3),
    .client-table td:nth-child(5) { display: none; }
}
