/* ── Contacts client (destinataires proforma) ─────────────────────────── */
.contacts-head { display:flex; align-items:center; flex-wrap:wrap; gap:8px; font-family:var(--font-brand); font-size:0.8rem; font-weight:600; letter-spacing:1.5px; text-transform:uppercase; color:var(--text); margin-bottom:14px; padding-bottom:10px; border-bottom:1px solid var(--border); }
.contacts-head .sub { text-transform:none; letter-spacing:0; font-weight:400; font-size:0.75rem; color:var(--muted); }

.contacts-list { display:flex; flex-direction:column; gap:8px; margin-bottom:16px; }

.contact-card { display:flex; align-items:center; gap:12px; padding:10px 12px; background:var(--bg3); border:1px solid var(--border); border-radius:var(--radius-md); transition:border-color .15s, box-shadow .15s; }
.contact-card:hover { border-color:var(--blue); box-shadow:0 0 0 1px rgba(74,144,217,0.25); }

.contact-avatar { flex:0 0 auto; width:38px; height:38px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:0.85rem; color:#fff; background:linear-gradient(135deg, var(--blue), #2f6fb0); text-transform:uppercase; letter-spacing:.5px; }

.contact-main { flex:1 1 auto; min-width:0; display:flex; flex-direction:column; gap:1px; }
.contact-name { font-weight:600; font-size:0.9rem; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.contact-email { font-size:0.8rem; color:var(--blue); text-decoration:none; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.contact-email:hover { text-decoration:underline; }

.contact-role { flex:0 0 auto; font-size:0.66rem; font-weight:700; letter-spacing:.5px; text-transform:uppercase; color:var(--blue); background:rgba(74,144,217,0.12); border:1px solid rgba(74,144,217,0.35); padding:3px 9px; border-radius:999px; white-space:nowrap; }

/* Coche « reçoit le mail auto » : indépendante du rôle, plusieurs contacts
   peuvent être cochés en même temps. Réutilisée dans la card ET dans le
   formulaire d'ajout (cf. .contact-field.f-mailauto). */
.contact-mail-toggle { flex:0 0 auto; display:inline-flex; align-items:center; gap:5px; font-size:0.7rem; font-weight:600; color:var(--muted); cursor:pointer; white-space:nowrap; padding:3px 9px; border-radius:999px; border:1px solid var(--border); background:var(--bg2); transition:all .15s; }
.contact-mail-toggle input { margin:0; cursor:pointer; }
.contact-mail-toggle:has(input:checked) { color:var(--green); border-color:var(--green); background:rgba(46,204,113,0.12); }

.contact-del { flex:0 0 auto; width:32px; height:32px; display:flex; align-items:center; justify-content:center; background:none; border:1px solid transparent; border-radius:var(--radius-sm); color:var(--muted); cursor:pointer; font-size:0.9rem; transition:all .15s; }
.contact-del:hover { color:var(--red); border-color:var(--red-dim); background:var(--red-glow); }

.contacts-empty { display:flex; align-items:center; gap:10px; padding:16px; background:var(--bg3); border:1px dashed var(--border); border-radius:var(--radius-md); color:var(--muted); font-size:0.85rem; line-height:1.4; margin-bottom:16px; }
.contacts-empty .ico { font-size:1.4rem; opacity:.75; flex:0 0 auto; }

.contact-form { background:var(--bg3); border:1px solid var(--border); border-radius:var(--radius-md); padding:14px; }
.contact-form-title { font-size:0.72rem; font-weight:600; letter-spacing:1px; text-transform:uppercase; color:var(--muted); margin-bottom:10px; }
.contact-form-grid { display:grid; grid-template-columns:minmax(140px,.8fr) 1fr 1fr auto auto; gap:10px; align-items:end; }
.contact-field { display:flex; flex-direction:column; gap:4px; min-width:0; }
.contact-field label { font-size:0.68rem; color:var(--muted); font-weight:500; }
.contact-field select, .contact-field input { width:100%; min-height:40px; background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius-sm); padding:8px 10px; color:var(--text); font-size:0.85rem; margin:0; transition:border-color .15s; }
.contact-field select:focus, .contact-field input:focus { border-color:var(--blue); outline:none; }
/* La coche mail-auto du formulaire porte les 3 classes SUR LE MÊME <label>
   (contact-field + f-mailauto + contact-mail-toggle, cf. commercial.js) — pas
   imbriquées. Les sélecteurs ci-dessous doivent donc être des classes chaînées
   (sans espace), pas des descendants : avec un espace ils ne matchent RIEN (bug
   corrigé). Sans ce correctif, la checkbox héritait aussi de la règle générique
   « .contact-field input » (width:100%; min-height:40px; padding:8px 10px…)
   destinée aux <input type=text/email> — d'où une case à cocher énorme, étirée
   en carré plein cadre. */
.contact-field.f-mailauto { min-height:40px; justify-content:center; }
.contact-field.f-mailauto.contact-mail-toggle {
    min-height:40px; box-sizing:border-box; padding:0 10px; gap:6px;
    font-size:0.78rem; white-space:nowrap;
}
.contact-field.f-mailauto.contact-mail-toggle input[type="checkbox"] {
    width:14px; height:14px; min-height:0; flex:none;
    padding:0; border:none; background:none;
}

.contact-submit { min-height:40px; padding:0 20px; background:var(--blue); color:#fff; border:none; border-radius:var(--radius-sm); font-weight:600; font-size:0.85rem; cursor:pointer; transition:background .15s; white-space:nowrap; }
.contact-submit:hover { background:var(--red-dim); }

@media (max-width:640px) {
    .contact-form-grid { grid-template-columns:1fr 1fr; }
    .contact-form-grid .f-email, .contact-form-grid .f-mailauto, .contact-form-grid .contact-submit { grid-column:1 / -1; }
}
@media (max-width:420px) {
    .contact-form-grid { grid-template-columns:1fr; }
}

/* ── Mini formulaire "Accord de retour" (contact magasin + palette) ──────
   Modal via bp-confirm-backdrop/modal (globals.js) — contenu spécifique ici.
   Champs empilés (pas de grid multi-colonnes) : le modal reste étroit
   (min(420px,96vw)) donc pas de media-query supplémentaire à prévoir. */
.retour-form-fields { display:flex; flex-direction:column; gap:12px; margin:14px 0; }
.retour-form-section-label { font-size:0.72rem; font-weight:600; letter-spacing:1px; text-transform:uppercase; color:var(--muted); margin-bottom:2px; }
.retour-radio-group { display:flex; flex-wrap:wrap; gap:8px; }
.retour-radio-pill { display:inline-flex; align-items:center; gap:6px; font-size:0.82rem; color:var(--text); background:var(--bg3); border:1px solid var(--border); border-radius:999px; padding:7px 12px; cursor:pointer; transition:all .15s; }
.retour-radio-pill input { margin:0; cursor:pointer; }
.retour-radio-pill:has(input:checked) { color:var(--blue); border-color:var(--blue); background:rgba(74,144,217,0.12); font-weight:600; }

/* Commercial badges */
.vrp-badge { display:inline-block; font-size:0.68rem; font-weight:700; padding:2px 7px; border-radius:var(--radius-lg); white-space:nowrap; }

/* Commandes */
#commandesContent { max-width: 100%; margin: 0 auto; }
.cmd-table { width:100%; border-collapse:collapse; font-size:0.82rem; margin: 0 auto; }
.cmd-table th { background:var(--bg3); color:var(--muted); padding:8px 12px; text-align:center; font-size:0.72rem; font-weight:600; border-bottom:1px solid var(--border); border-right:1px solid rgba(42,42,53,0.3); letter-spacing:1px; text-transform:uppercase; }
.cmd-table th:last-child { border-right:none; }
.cmd-table td { padding:9px 12px; border-bottom:1px solid var(--border); border-right:1px solid rgba(42,42,53,0.3); color:var(--text); vertical-align:middle; text-align:center; }
.cmd-table td:last-child { border-right:none; }
.cmd-table td:nth-child(1) { text-align:center; }
.cmd-table td:nth-child(2) { text-align:left; }
.cmd-table td:nth-child(3) { text-align:left; }
.cmd-table tr:hover td { background:var(--bg3); cursor:pointer; }
.cmd-table tr.alerte td { background:#DC262608; }
.cmd-table tr.alerte:hover td { background:#DC262615; }
.alerte-badge { display:inline-block; background:var(--red); color:white; font-size:var(--font-xs); padding:2px 7px; border-radius:var(--radius-md); font-weight:700; }
.ok-badge { display:inline-block; background:#1E8449; color:white; font-size:var(--font-xs); padding:2px 7px; border-radius:var(--radius-md); font-weight:700; }
.grp-badge { display:inline-block; background:#1A4A8A; color:var(--blue); border:1px solid var(--blue); font-size:var(--font-xs); padding:2px 7px; border-radius:var(--radius-md); font-weight:700; }

/* ── Tons partagés "tag" (pill/badge/delta) ── une seule définition par couleur,
   réutilisée par .pill-* (layout-commercial.css), .delta-* (idem) et .trk-badge--*
   (tracking-rupture.css). Ne pas redéclarer background/color/border ailleurs pour
   ces classes — modifier ICI se répercute partout. */
.pill-green, .trk-badge--ok, .delta-up      { background:#16A34A22; color:var(--green);  border:1px solid #16A34A44; }
.pill-orange, .trk-badge--warning           { background:#EA580C22; color:var(--orange); border:1px solid #EA580C44; }
.pill-red, .delta-down, .trk-badge--critical{ background:#DC262622; color:var(--red);    border:1px solid #DC262644; }
.trk-badge--info                            { background:#0EA5E922; color:var(--blue);   border:1px solid #0EA5E944; }
.pill-grey, .delta-flat                     { background:rgba(150,150,150,0.12); color:var(--muted); border:1px solid var(--border); }
.cmd-table tr.groupage td { background:#0EA5E908; border-left: 3px solid #0EA5E9; }
.cmd-table tr.groupage:hover td { background:#0EA5E915; }
.cmd-table tr.selected td { background: rgba(14,165,233,0.16) !important; font-weight: 600; }
.cmd-table tr.selected td:first-child { border-left: 4px solid var(--blue); padding-left: 8px; }
.cmd-table tr.selected:hover td { background: rgba(14,165,233,0.22) !important; }
.jour-btn { padding:5px 12px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--bg3); color:var(--muted); font-size:0.75rem; cursor:pointer; transition:all 0.15s; }
.jour-btn:hover { border-color:var(--blue); color:var(--blue); }
.jour-btn.active { border-color:var(--blue); background:var(--blue); color:white; }
.kpi-mini { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-bottom:14px; }
.kpi-mini-box { background:var(--bg3); border-radius:var(--radius-md); padding:10px; text-align:center; border-left: 2px solid var(--border); }
.kpi-mini-box:first-child { border-left: none; }
.kpi-mini-box .lbl { font-size:0.68rem; color:var(--muted); margin-bottom:3px; }
.kpi-mini-box .val { font-size:1rem; font-weight:700; }

#statsMois { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 20px !important; }

#calendarGrid {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 8px !important;
    grid-auto-rows: auto;
}
.health-bar-wrap { flex:1; background:var(--bg3); border-radius:3px; height:14px; overflow:hidden; }
.health-bar-fill { height:100%; border-radius:3px; opacity:0.8; }

/* Utility text classes */
.text-muted  { color: var(--muted) !important; }
.text-red    { color: var(--red) !important; }
.text-green  { color: var(--green) !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* Primary button */
.btn-primary {
    background: var(--blue);
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    color: white;
    cursor: pointer;
    font-size: var(--font-base);
    font-weight: 600;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--blue-dim); }

/* Filter buttons */
.btn-filter {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-filter:hover {
    border-color: var(--text);
    color: var(--text);
}
.btn-filter.active {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
}

/* Ghost button */
.btn-ghost {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    color: var(--muted);
    cursor: pointer;
    font-size: var(--font-base);
    transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--text); color: var(--text); }

/* Sync badge */
.sync-badge {
    font-size: 0.8rem;
    color: var(--muted);
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Status dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    background: var(--muted);
}
.status-dot.online { background: var(--green); }

/* Green export button variant */
.export-btn.green {
    border-color: var(--green);
    color: var(--green);
}

/* Fix .b-warn to be orange not red */
.b-warn { background: var(--orange) !important; }

/* Global scrollbar styling */
*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-track { background: var(--bg3); border-radius: 6px; }
*::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 6px; border: 3px solid var(--bg3); background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--blue); border: 2px solid var(--bg3); background-clip: padding-box; }
/* Firefox */
* { scrollbar-width: auto; scrollbar-color: var(--muted) var(--bg3); }

/* Page title styling */
.page-title {
    font-family: var(--font-brand);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

/* Glassmorphism header */
.hdr {
    backdrop-filter: blur(10px);
}

/* Subtle card shadow */
.card {
    box-shadow: var(--shadow-sm);
}

/* Accordéon générique <details class="card devis-acc"> : carte dépliable au clic
   sur son <summary class="devis-acc-head">. Partagé par « Ma commande »
   (commande.js) et la fiche client (commercial.js::_renderClientPieces). */
.devis-acc { margin-bottom:14px; }
.devis-acc-head { cursor:pointer; font-weight:700; font-size:.95rem;
    display:flex; align-items:center; gap:8px; list-style:none; user-select:none; }
.devis-acc-head::-webkit-details-marker { display:none; }
.devis-acc-head::before { content:'▸'; color:var(--muted); font-size:.8rem; transition:transform .15s; }
.devis-acc[open] .devis-acc-head::before { content:'▾'; }

/* Responsive grid - tablet view (1024px and below) */
@media (max-width: 1024px) {
    .top-row { grid-template-columns: 1fr 1fr; }
    .main-row { grid-template-columns: 1fr 1fr; }
    .results-grid { grid-template-columns: 1fr; }
    #statsMois { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Flash button (gros �clair) */
.btn-flash {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--blue);
    border: none;
    color: white;
    font-size: 2.2rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 0 0 var(--blue-glow);
    animation: flashGlow 2s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.btn-flash:hover {
    background: var(--blue-dim);
    transform: scale(1.1);
    box-shadow: 0 0 24px var(--blue-glow);
}
@keyframes flashGlow {
    0% { box-shadow: 0 0 0 0 var(--blue-glow); }
    50% { box-shadow: 0 0 0 8px rgba(14, 165, 233, 0); }
    100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); }
}

/* Calendar styling - Compact circle days */
#calendarContainer {
    width: 100%;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
}
#calendarGrid {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 8px !important;
    align-items: center;
    justify-items: center;
}
.calendar-day {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--muted);
    padding: 0;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg3);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    border-right: 1px solid rgba(120, 120, 160, 0.2);
    border-bottom: 1px solid rgba(120, 120, 160, 0.15);
    margin-right: 7px;
    margin-bottom: 7px;
}
.calendar-day:nth-child(7n) {
    border-right: none;
    margin-right: 0;
}
.calendar-day:nth-last-child(-n+7) {
    border-bottom: none;
    margin-bottom: 0;
}
.calendar-day:hover {
    border-color: var(--blue);
    background: var(--bg4);
    transform: scale(1.15);
    box-shadow: 0 0 12px rgba(14,165,233,0.3);
}
.calendar-day.today {
    border-color: var(--blue);
    border-width: 2.5px;
    background: rgba(14,165,233,0.15);
}
.calendar-day.active {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
    box-shadow: 0 0 16px rgba(14,165,233,0.5);
}
.calendar-day.has-cmd {
    border-color: var(--orange);
    border-width: 2.5px;
    background: rgba(243, 156, 18, 0.25);
}
.calendar-day.has-cmd.today {
    background: rgba(234,88,12,0.3);
    border-color: var(--orange);
}
.calendar-day.has-cmd.active {
    background: var(--orange);
    border-color: var(--orange);
}
.calendar-day-num {
    font-weight: 700;
    font-size: 0.7rem;
    line-height: 1;
}
.calendar-day-count {
    font-size: 0.5rem;
    color: var(--muted);
    line-height: 1;
    margin-top: 0;
}
.calendar-day.active .calendar-day-count,
.calendar-day.active .calendar-day-num {
    color: white;
}
.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 0 8px 0;
    border-bottom: 0.5px solid var(--border);
}
.calendar-header-day {
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 4px 0;
}

/* Calendar navigation */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.calendar-nav-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s;
}
.calendar-nav-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}
.calendar-nav-title {
    font-weight: 600;
    color: var(--text);
    font-size: 0.85rem;
    text-transform: capitalize;
}

/* Responsive grid - tablet view (1024px and below) */
@media (max-width: 1024px) {
    .top-row { grid-template-columns: 1fr 1fr; }
    .main-row { grid-template-columns: 1fr 1fr; }
    .results-grid { grid-template-columns: 1fr; }
    #statsMois { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Responsive grid - mobile view (768px and below) */
@media (max-width: 768px) {
    .top-row { grid-template-columns: 1fr; }
    .main-row { grid-template-columns: 1fr; }
    .hdr { flex-wrap: wrap; height: auto; padding: 10px; }
    .nav-tabs { gap: 4px; flex-wrap: wrap; }
    #statsMois { grid-template-columns: repeat(2, 1fr) !important; }
    .page { padding: 14px; }
    .btn-flash { width: 48px; height: 48px; font-size: 1.4rem; }
    #btnToggleCalendar { font-size: 0.75rem; }
}

