:root {
    --nuit: #1b2540;
    --nuit-2: #26325a;
    --or: #b48a3c;
    --or-clair: #f3ead6;
    --fond: #f5f3ee;
    --carte: #ffffff;
    --texte: #20242e;
    --discret: #6b7080;
    --bord: #d9d5c9;
    --ok: #2e7d4f;
    --danger: #b3261e;
    --rayon: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--fond);
    color: var(--texte);
    font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--nuit-2); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; color: var(--nuit); }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; color: var(--nuit); }

/* ---- barre du haut ---- */
.topbar {
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
    background: var(--nuit); color: #fff; padding: .6rem 1.25rem;
    position: sticky; top: 0; z-index: 10;
}
.brand { color: var(--or-clair); text-decoration: none; font-size: 1.35rem; font-weight: 700; letter-spacing: .03em; }
.brand small { font-weight: 400; font-size: .8rem; color: #c9cde0; letter-spacing: 0; margin-left: .25rem; }
.menu { display: flex; gap: .25rem; flex: 1; }
.menu a {
    color: #dfe2f0; text-decoration: none; padding: .7rem 1.1rem; border-radius: 10px; font-weight: 500;
}
.menu a.actif { background: var(--or); color: #fff; }
.usager { display: flex; align-items: center; gap: .6rem; font-size: .95rem; color: #c9cde0; }
.usager form { margin: 0; }

.contenu { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }

/* ---- boutons et champs (cibles tactiles >= 46 px) ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 46px; padding: 0 1.2rem; border-radius: 10px; border: 1px solid var(--nuit);
    background: var(--nuit); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--nuit-2); }
.btn-or { background: var(--or); border-color: var(--or); }
.btn-or:hover { background: #9c7630; }
.btn-clair { background: #fff; color: var(--nuit); border-color: var(--bord); }
.btn-clair:hover { background: var(--or-clair); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fdecea; }
.btn-ghost { background: transparent; border-color: #5b6693; color: #fff; min-height: 38px; }
.btn-petit { min-height: 38px; padding: 0 .9rem; font-size: .95rem; }

label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .95rem; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=search], select, textarea {
    width: 100%; min-height: 46px; padding: .55rem .75rem; font: inherit; color: inherit;
    border: 1px solid var(--bord); border-radius: 10px; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #d8c28c; border-color: var(--or); }
input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--nuit); vertical-align: middle; }
.case { display: flex; align-items: center; gap: .6rem; min-height: 46px; font-weight: 500; }
.case label { margin: 0; font-weight: 500; }
.aide { color: var(--discret); font-size: .88rem; margin-top: .25rem; }

.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1.1rem 1.25rem; margin-bottom: 1.1rem; }
.grille { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grille .large { grid-column: 1 / -1; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.entete { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.entete h1 { margin: 0; }

/* ---- alertes ---- */
.alerte { border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem; }
.alerte.ok { background: #e6f3ea; border: 1px solid #b5d8c1; color: #1d5a37; }
.alerte.erreur { background: #fdecea; border: 1px solid #f1b8b3; color: #7a1c16; }
.alerte ul { margin: .3rem 0 0 1.1rem; padding: 0; }

/* ---- filtres ---- */
.filtres { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filtres > div { flex: 1 1 170px; }
.filtres .recherche { flex: 3 1 260px; }

/* ---- tableaux ---- */
.tableau-wrap { overflow-x: auto; background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem .9rem; border-bottom: 1px solid #ece8dc; vertical-align: middle; }
th { background: #faf8f2; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--discret); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfaf4; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.vide { padding: 2rem; text-align: center; color: var(--discret); }
.miniature { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--bord); background: #eee; display: block; }

.pastille { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.pastille.attente { background: #fff4d6; color: #7a5a00; }
.pastille.message { background: #e2ebff; color: #1d3f8f; }
.pastille.termine { background: #e1f3e8; color: #1d5a37; }
.pastille.archive { background: #eceaf0; color: #5a5668; }
.pastille.estime { background: var(--or-clair); color: #7a5a14; }

/* ---- pagination ---- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 1.1rem 0; }
.pagination .page {
    display: inline-flex; align-items: center; min-height: 46px; padding: 0 1.1rem; border-radius: 10px;
    border: 1px solid var(--bord); background: #fff; text-decoration: none; color: var(--nuit); font-weight: 600;
}
.pagination .page.disabled { color: #b4b1a8; background: #f3f1ea; }
.pagination .page-info { color: var(--discret); }

/* ---- formulaire d'un bon ---- */
.bijou-bloc { border: 2px solid var(--bord); border-radius: var(--rayon); padding: 1rem 1.1rem; margin-bottom: 1rem; background: #fffdf8; }
.bijou-bloc > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.bijou-bloc h3 { margin: 0; color: var(--nuit); }
.photo-zone { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.photo-apercu { width: 120px; height: 120px; border-radius: 10px; border: 1px dashed var(--bord); background: #f3f1ea; object-fit: cover; }
.photo-apercu.vide-img { display: grid; place-items: center; color: var(--discret); font-size: .85rem; text-align: center; }

.resultats { border: 1px solid var(--bord); border-radius: 10px; background: #fff; margin-top: .35rem; max-height: 280px; overflow: auto; }
.resultats button {
    display: flex; justify-content: space-between; width: 100%; text-align: left; background: none; border: 0;
    border-bottom: 1px solid #ece8dc; padding: .8rem 1rem; font: inherit; cursor: pointer; min-height: 48px;
}
.resultats button:hover { background: var(--or-clair); }
.client-choisi { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--or-clair); border-radius: 10px; padding: .7rem 1rem; }

/* ---- connexion ---- */
.connexion { max-width: 380px; margin: 8vh auto 0; }
.connexion .carte { padding: 1.6rem; }
.connexion h1 { text-align: center; font-size: 1.5rem; }
.connexion .logo { text-align: center; color: var(--or); font-size: .9rem; letter-spacing: .25em; text-transform: uppercase; margin-bottom: .25rem; }

.menu-gestion { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.menu-gestion a { padding: .6rem 1rem; border-radius: 10px; background: #fff; border: 1px solid var(--bord); text-decoration: none; font-weight: 600; color: var(--nuit); }
.menu-gestion a.actif { background: var(--nuit); color: #fff; border-color: var(--nuit); }

@media (max-width: 720px) {
    .contenu { padding: .8rem; }
    .menu { order: 3; flex-basis: 100%; overflow-x: auto; }
    .topbar { padding: .6rem .8rem; }
}

/* ---- boutons à icône seule ---- */
.btn-icone { width: 44px; min-width: 44px; padding: 0; min-height: 44px; }
.btn-icone svg { display: block; }
.btn-icone.btn-petit { width: 40px; min-width: 40px; min-height: 40px; }
.actions-ligne { display: flex; gap: .4rem; justify-content: flex-end; align-items: center; }
.actions-ligne form { margin: 0; }
td.col-actions { white-space: nowrap; }

/* ---- iPad en portrait et plus étroit : masquer les colonnes secondaires, garder les actions visibles ---- */
td { overflow-wrap: anywhere; }
td.col-actions { overflow-wrap: normal; }
@media (max-width: 900px) {
    .peu-prioritaire { display: none; }
    th, td { padding: .65rem .6rem; }
}

/* ---- groupes X / Oui / Non ---- */
fieldset.radios { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.radios legend { font-weight: 600; font-size: .95rem; padding: 0; margin-bottom: .3rem; }
fieldset.radios label {
    display: inline-flex; align-items: center; gap: .4rem; margin: 0 .35rem .35rem 0;
    min-height: 46px; padding: 0 .9rem; border: 1px solid var(--bord); border-radius: 10px; background: #fff;
    font-weight: 500; cursor: pointer;
}
fieldset.radios label:has(input:checked) { background: var(--or-clair); border-color: var(--or); }
fieldset.radios input[type=radio] { width: 22px; height: 22px; accent-color: var(--nuit); }

/* ---- bloc bijou : coût + Gratuit + Acceptée sur une ligne, les trois dates sur la suivante ---- */
.ligne-statut { display: flex; flex-wrap: wrap; gap: .9rem 2rem; align-items: flex-start; }
.ligne-statut > div:first-child { flex: 0 0 150px; }
.ligne-statut fieldset.radios { flex: 0 0 auto; }
.ligne-statut fieldset.radios label { margin-right: .25rem; padding: 0 .75rem; }
.ligne-dates { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.pastille.refusee { background: #fdecea; color: #8a1f17; }

/* ---- bons archivés : ligne biffée, boutons Modifier/Imprimer grisés, crochet vert pour réactiver ---- */
tr.ligne-archivee td:not(.col-actions) { text-decoration: line-through; color: #8d8a80; }
tr.ligne-archivee .miniature { opacity: .45; filter: grayscale(1); }
.btn.desactive { opacity: .4; cursor: not-allowed; pointer-events: none; background: #f3f1ea; }
.btn-ok { background: #fff; color: var(--ok); border-color: var(--ok); }
.btn-ok:hover { background: #e6f3ea; }

/* ---- photos cliquables + agrandissement ---- */
img.miniature, img.photo-apercu { cursor: zoom-in; }
.sans-defilement { overflow: hidden; }
.lightbox {
    position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
    background: rgba(15, 20, 35, .88); padding: 1rem; cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; border-radius: 8px; background: #fff; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox-fermer {
    position: absolute; top: .75rem; right: .75rem; width: 48px; height: 48px; border-radius: 50%;
    border: 0; background: rgba(255,255,255,.92); color: var(--nuit); font-size: 2rem; line-height: 1; cursor: pointer;
}

/* ---- double authentification ---- */
.qr { width: 220px; height: 220px; background: #fff; border: 1px solid var(--bord); border-radius: 10px; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.cle-secrete { font-family: ui-monospace, Consolas, monospace; font-size: 1.25rem; letter-spacing: .08em; background: var(--or-clair); padding: .6rem .9rem; border-radius: 10px; word-break: break-all; }
.codes-secours { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .6rem; }
.codes-secours li { font-family: ui-monospace, Consolas, monospace; font-size: 1.2rem; letter-spacing: .06em; background: #fff; border: 1px dashed var(--bord); border-radius: 10px; padding: .6rem .9rem; text-align: center; }
.lien-securite { color: #dfe2f0; text-decoration: none; padding: .4rem .6rem; border-radius: 8px; }
.lien-securite:hover { background: rgba(255,255,255,.12); }
.qr { margin-bottom: 1.25rem; }

/* ---- une ligne de téléphone = téléphone + type + poste (3 colonnes égales, 1 colonne sur petit écran) ---- */
.grille.telephone { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) { .grille.telephone { grid-template-columns: 1fr; } }

/* ---- bouton retour de l'entête ---- */
.btn-retour {
    display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; flex: 0 0 auto;
    margin-right: -.5rem; border-radius: 10px; border: 1px solid #5b6693; color: #fff; text-decoration: none;
}
.btn-retour:hover { background: rgba(255,255,255,.14); }

/* La flèche retour se place devant le titre de la page (h1), pas dans la barre du haut */
h1 .btn-retour {
    width: 44px; height: 44px; margin: 0 .6rem 0 0; vertical-align: middle; color: var(--nuit);
    border: 1px solid var(--bord); background: #fff;
}
h1 .btn-retour:hover { background: var(--or-clair); }

/* ---- total des frais dans l'entête d'un bon ---- */
.totaux-bon { margin-left: auto; margin-right: 1rem; display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: 1.05rem; font-weight: 600; color: var(--nuit); }
.totaux-bon b { font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .totaux-bon { margin-left: 0; order: 3; flex-basis: 100%; } }

/* ---- champ date avec bouton « × » pour l'effacer ---- */
.champ-date { display: flex; gap: .4rem; align-items: stretch; }
.champ-date input[type=date] { flex: 1 1 auto; min-width: 0; }
.effacer-date {
    flex: 0 0 46px; min-height: 46px; border-radius: 10px; border: 1px solid var(--bord); background: #fff;
    color: var(--discret); font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.effacer-date:hover { background: #fdecea; color: var(--danger); border-color: var(--danger); }

/* ---- date d'acceptation (largeur fixe) + « Réparation acceptée » à sa droite ; deux dates sur la ligne suivante ---- */
.ligne-acceptation > div:first-child { flex: 0 0 260px; }
.ligne-dates { grid-template-columns: repeat(auto-fit, minmax(230px, 340px)); }

/* ---- photo introuvable dans les listes ---- */
.miniature-absente {
    width: 54px; height: 54px; border-radius: 8px; border: 1px dashed var(--bord); background: #f3f1ea;
    display: grid; place-items: center; text-align: center; font-size: .62rem; line-height: 1.1; color: var(--discret); padding: 2px;
}
