/* ==========================================================================
   Appli terrain — mobile d'abord.
   Gros boutons (gants), contraste fort (plein soleil), utilisable d'une main :
   les actions principales sont en bas de l'écran, à portée du pouce.
   Préfixe t- pour ne rien casser ailleurs.
   ========================================================================== */

/* ---------- Coquille dédiée aux rôles terrain ---------- */
.terrain-coquille { background: var(--bg); }
.t-shell { min-height: 100vh; display: flex; flex-direction: column; }
.t-haut { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px;
          padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
          background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
          border-bottom: 1px solid var(--line); }
.t-marque { display: flex; align-items: center; gap: 10px; color: var(--fg); font-family: var(--ff-d); font-size: 18px; }
.t-marque:hover { text-decoration: none; }
.t-marque .brand-mark { width: 30px; height: 30px; font-size: 16px; }
.t-haut-actions { display: flex; align-items: center; gap: 2px; }
.t-haut-actions .btn-icone { width: 44px; height: 44px; }
.t-haut-actions .ti { font-size: 21px; }
.t-moi { position: relative; }
.t-moi summary { list-style: none; cursor: pointer; padding: 6px; border-radius: 99px; }
.t-moi summary::-webkit-details-marker { display: none; }
.t-moi summary .avatar { width: 34px; height: 34px; font-size: 12.5px; }
.t-moi-menu { position: absolute; right: 0; top: calc(100% + 6px); width: 240px; padding: 10px; z-index: 40; box-shadow: var(--ombre-pop); }
.t-moi-nom { display: flex; flex-direction: column; padding: 4px 8px 10px; }
.t-contenu { width: 100%; max-width: 760px; margin: 0 auto; padding: 14px 14px calc(110px + env(safe-area-inset-bottom)); flex: 1; }

/* Barre basse : toujours visible pour les rôles terrain (même sur grand écran) */
.t-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: var(--surface);
         border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around;
         box-shadow: 0 -4px 18px rgba(17,22,27,.06); }
.t-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; color: var(--fg-2);
           padding: 7px 6px; border-radius: 12px; flex: 1; max-width: 120px; min-height: 56px; justify-content: center; }
.t-nav a .ti { font-size: 25px; }
.t-nav a:hover { text-decoration: none; background: var(--surface-2); }
.t-nav a.actif { color: var(--accent-fg); background: var(--accent-doux); }
.terrain-coquille .toasts { left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); align-items: center; }
.terrain-coquille .toast { font-size: 15px; padding: 13px 18px; }
@media (max-width: 860px) { .terrain-app .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); } }

/* ---------- Page ---------- */
.t-page { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.terrain-app:not(.terrain-coquille) .t-page { margin: 0 auto; padding-top: 12px; }
.t-entete { display: flex; align-items: center; gap: 10px; margin: 2px 0 2px; }
.t-entete h1 { font-size: 25px; line-height: 1.15; overflow-wrap: anywhere; }
.t-surtitre { font-size: 13.5px; color: var(--fg-3); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-retour { width: 46px; height: 46px; border-radius: 14px; flex: none; }
.t-retour .ti { font-size: 22px; }
.t-section { font-size: 17px; display: flex; align-items: baseline; gap: 8px; margin: 8px 2px 8px; }
.t-intro { color: var(--fg-2); margin: 0; }
.t-centre { text-align: center; margin: 0; }
.t-ok { color: var(--good); font-weight: 600; } .t-attente { color: var(--warn); font-weight: 600; }

/* État du réseau / file d'attente */
.t-reseau { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; font-weight: 600; font-size: 14.5px;
            background: var(--warn-bg); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.t-reseau.hors { background: #2a2318; color: #fff7e4; border-color: #2a2318; }
.t-reseau .ti { font-size: 20px; }
.t-reseau .btn { margin-left: auto; }
.t-reseau.envoi .ti { animation: t-tourne 1s linear infinite; }
@keyframes t-tourne { to { transform: rotate(360deg); } }

/* ---------- Ma journée ---------- */
.t-hero { padding: 4px 2px 0; }
.t-hero-date { font-size: 14px; color: var(--fg-3); font-weight: 600; }
.t-hero h1 { font-size: 30px; letter-spacing: -.02em; margin: 2px 0 4px; }
.t-hero-sous { color: var(--fg-2); margin: 0; }
.t-chantier { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; border-left: 5px solid var(--good); }
.t-chantier-tete { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.t-numero { font-size: 13.5px; font-weight: 600; color: var(--fg-3); }
.t-chantier-nom { font-family: var(--ff-d); font-size: 22px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.t-chantier-objet { color: var(--fg-2); }
.t-phase { margin-top: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; }
.t-equipe { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.t-equipe .avatar { border: 2px solid var(--surface); margin-right: -8px; }
.t-equipe .muted { margin-left: 14px; }
.t-chantier-voir { margin-top: 4px; font-weight: 700; color: var(--accent-fg); display: flex; align-items: center; gap: 2px; }
.t-autres-chantiers { display: flex; flex-wrap: wrap; gap: 8px; }
.t-choix-chantier select { min-height: 52px; font-size: 16px; }
.t-choix-chantier .btn { min-height: 52px; padding: 0 22px; }

.t-tuiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 620px) { .t-tuiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.t-tuile { --c: var(--accent); --cf: #fff; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-height: 128px;
           padding: 16px; border-radius: 20px; background: var(--c); color: var(--cf); box-shadow: var(--ombre);
           position: relative; overflow: hidden; transition: transform var(--t-rapide), box-shadow var(--t-rapide), filter var(--t-rapide);
           -webkit-tap-highlight-color: transparent; }
.t-tuile:hover { text-decoration: none; box-shadow: var(--ombre-h); filter: brightness(1.05); }
.t-tuile:active { transform: scale(.97); }
.t-tuile .ti { font-size: 36px; position: absolute; top: 14px; left: 16px; }
.t-tuile strong { font-family: var(--ff-d); font-size: 19px; line-height: 1.15; }
.t-tuile span { font-size: 13px; opacity: .88; font-weight: 500; }
.t-tuile.accent { --c: var(--accent); }
.t-tuile.sombre { --c: #2a2318; }
.t-tuile.warn { --c: #8c6433; }
.t-tuile.vente { --c: var(--vente); }
.t-tuile.info { --c: #3e6a86; }
.t-tuile.bad { --c: var(--bad); }
.t-tuile.depot { --c: #4a7139; }
:root[data-theme="dark"] .t-tuile { --cf: #1b160f; }
:root[data-theme="dark"] .t-tuile.sombre { --c: #fff7e4; }

.t-liste-consignes { list-style: none; margin: 0; padding: 0 20px 14px; display: flex; flex-direction: column; gap: 8px; }
.t-liste-consignes li { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 10px 12px;
                        border-radius: 10px; background: var(--warn-bg); color: var(--fg); font-weight: 500; }
.t-consigne-form { gap: 8px; }
.t-consigne-form input { flex: 1; }

/* ---------- Formulaires terrain : gros, lisibles ---------- */
.t-form { display: flex; flex-direction: column; gap: 14px; }
.t-form .card-pad { padding: 16px; }
.terrain-app .t-form input[type=text], .terrain-app .t-form input[type=tel], .terrain-app .t-form input[type=number],
.terrain-app .t-form select, .terrain-app .t-form textarea { min-height: 52px; font-size: 16.5px; border-radius: 12px; padding: 11px 14px; }
.terrain-app .t-form textarea { min-height: 88px; }
.t-form .champ label, .t-form .label { font-size: 14px; color: var(--fg); }
.t-fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.t-fieldset legend { padding: 0; margin-bottom: 8px; }
.t-choix-gros label { padding: 11px 16px; font-size: 15px; min-height: 46px; display: inline-flex; align-items: center; font-weight: 600; }
.t-qte { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.t-btn-xl { min-height: 60px; font-size: 17.5px; border-radius: 16px; padding: 14px 20px; }
.t-btn-xl .ti { font-size: 23px; }
.t-pied-fixe { position: sticky; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 20; padding-top: 4px; }
.terrain-app:not(.terrain-coquille) .t-pied-fixe { bottom: 12px; }
@media (max-width: 860px) { .terrain-app:not(.terrain-coquille) .t-pied-fixe { bottom: calc(78px + env(safe-area-inset-bottom)); } }
.t-pied-fixe .btn { box-shadow: 0 8px 24px rgba(17,22,27,.22); }
.btn.envoi-en-cours { opacity: .85; pointer-events: none; }
.btn.envoi-en-cours .ti { animation: t-tourne 1s linear infinite; }
.t-case { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer; }
.t-case input { width: 26px; height: 26px; flex: none; margin: 0; accent-color: var(--accent); }

/* Pointage : une carte par personne */
.t-personne { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); padding: 14px; margin: 0; min-width: 0;
              display: flex; flex-direction: column; gap: 12px; box-shadow: var(--ombre); transition: opacity var(--t); }
.t-personne.zero { opacity: .72; }
.t-personne-tete { display: flex; align-items: center; gap: 12px; }
.t-personne-tete .avatar { width: 40px; height: 40px; font-size: 14px; }
.t-personne-nom { font-weight: 700; font-size: 16.5px; }
.t-stepper { display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; gap: 10px; align-items: stretch; }
.t-pas { min-height: 64px; border-radius: 16px; border: 2px solid var(--fg); background: var(--surface); color: var(--fg); cursor: pointer;
         display: grid; place-items: center; transition: transform var(--t-rapide), background var(--t-rapide); -webkit-tap-highlight-color: transparent; }
.t-pas .ti { font-size: 28px; }
.t-pas:active { transform: scale(.94); background: var(--surface-3); }
.t-stepper-valeur { display: flex; align-items: center; justify-content: center; gap: 4px; border-radius: 16px; background: var(--surface-2);
                    border: 1px solid var(--line-2); }
.terrain-app .t-stepper-valeur input { border: 0; background: transparent; text-align: right; font: 700 32px var(--ff-num); width: 4.2ch;
                                       padding: 0; min-height: 0; box-shadow: none; -moz-appearance: textfield; }
.t-stepper-valeur input::-webkit-outer-spin-button, .t-stepper-valeur input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.t-stepper-valeur span { font: 600 20px var(--ff-num); color: var(--fg-3); }
.t-stepper-valeur:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
.t-options { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.t-seg { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.t-seg-titre { font-size: 13px; font-weight: 700; color: var(--fg-2); margin-right: 4px; }
.t-seg input { position: absolute; opacity: 0; pointer-events: none; }
.t-seg label { min-width: 46px; min-height: 46px; padding: 0 12px; display: grid; place-items: center; border-radius: 12px; cursor: pointer;
               border: 1px solid var(--line-2); background: var(--surface); font-weight: 700; font-size: 15px; color: var(--fg-2); }
.t-seg input:checked + label { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.t-seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.t-autres summary { cursor: pointer; font-weight: 700; padding: 14px 16px; border-radius: 14px; border: 1px dashed var(--line-2);
                    display: flex; align-items: center; gap: 8px; color: var(--fg-2); list-style: none; }
.t-autres summary::-webkit-details-marker { display: none; }
.t-semaine .t-total { font-size: 20px; font-weight: 700; }
.t-jour { width: 76px; flex: none; font-weight: 700; font-size: 14px; }
.t-semaine .liste-ligne .sous { white-space: normal; }
.t-aujourdhui { background: var(--accent-doux); }

/* Photos */
.t-capture { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
             min-height: 170px; padding: 20px; border-radius: 22px; background: #2a2318; color: #fff7e4; cursor: pointer;
             box-shadow: var(--ombre-h); transition: transform var(--t-rapide); -webkit-tap-highlight-color: transparent; }
.t-capture:active { transform: scale(.98); }
.t-capture.info { background: #1f5f9c; }
.t-capture .ti { font-size: 50px; }
.t-capture strong { font-family: var(--ff-d); font-size: 21px; }
.t-capture span { opacity: .8; }
.t-capture input, .t-galerie-choix input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.t-galerie-choix { position: relative; min-height: 52px; }
.t-capture:focus-within, .t-form label.btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.t-apercu { display: flex; flex-wrap: wrap; gap: 8px; }
.t-apercu:empty { display: none; }
.t-apercu-item { position: relative; width: 74px; height: 74px; border-radius: 12px; overflow: hidden; background: var(--surface-3);
                 display: grid; place-items: center; color: var(--fg-2); font-size: 11px; text-align: center; padding: 4px; }
.t-apercu-item img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.t-apercu-total { align-self: center; font-weight: 700; color: var(--good); font-size: 14px; }
.t-galerie { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 620px) { .t-galerie { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.t-vignette { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-3); display: block; }
.t-vignette img, .t-vignette video { width: 100%; height: 100%; object-fit: cover; }
.t-vignette.audio { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 6px; color: var(--info); }
.t-vignette.audio .ti { font-size: 30px; }
.t-vignette.audio audio { width: 100%; }
.t-vignette-tag { position: absolute; right: 6px; top: 6px; background: var(--vente); color: #fff; border-radius: 99px; width: 24px; height: 24px;
                  display: grid; place-items: center; }
.t-vignette-tag .ti { font-size: 14px; }
.t-note audio { width: 100%; margin-top: 8px; }
.t-dictaphone { display: flex; align-items: center; gap: 12px; }
.t-dictaphone .btn.enregistre { background: var(--bad); border-color: var(--bad); color: #fff; }
.t-dicta-temps { font-size: 22px; font-weight: 700; min-width: 60px; text-align: right; }

/* Matériel */
.t-bascule { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface);
             border: 1px solid var(--line); border-radius: 16px; }
.t-bascule a, .t-bascule label { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border-radius: 12px;
                                 font-weight: 700; color: var(--fg-2); cursor: pointer; text-align: center; padding: 6px 8px; }
.t-bascule a:hover { text-decoration: none; background: var(--surface-2); }
.t-bascule a.actif, .t-bascule input:checked + label { background: var(--fg); color: var(--bg); }
.t-bascule a.actif.manque { background: var(--vente); color: #fff; }
.t-bascule input { position: absolute; opacity: 0; pointer-events: none; }
.t-bascule input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.t-bascule.petite { margin-bottom: 14px; }

/* Relevé */
.t-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 620px) { .t-types { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.t-type { display: flex; flex-direction: column; gap: 4px; padding: 16px; min-height: 118px; border-radius: 18px; background: var(--surface);
          border: 1px solid var(--line); box-shadow: var(--ombre); color: var(--fg); justify-content: flex-end;
          transition: transform var(--t-rapide), border-color var(--t-rapide), box-shadow var(--t-rapide); }
.t-type:hover { text-decoration: none; border-color: var(--vente); box-shadow: var(--ombre-h); }
.t-type:active { transform: scale(.97); }
.t-type .ti { font-size: 32px; color: var(--vente); margin-bottom: auto; }
.t-type strong { font-family: var(--ff-d); font-size: 17px; }
.t-etape { display: flex; align-items: center; gap: 10px; font-size: 18px; margin-bottom: 14px; }
.t-etape .badge { margin-left: auto; }
.t-etape-num { width: 30px; height: 30px; border-radius: 50%; background: var(--vente); color: #fff; display: grid; place-items: center;
               font: 700 15px var(--ff-num); flex: none; }
.t-cotes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.t-cotes .plein { grid-column: 1 / -1; }
.t-photos-imposees { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.t-photos-imposees li { display: flex; flex-direction: column; gap: 4px; }
.t-photo-prise { position: relative; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px 8px 8px;
                 border: 2px solid var(--line-2); border-radius: 14px; cursor: pointer; background: var(--surface); }
.t-photo-prise:active { transform: scale(.99); }
.t-photo-coche { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-3); display: grid; place-items: center; flex: none; }
.t-photo-coche .ti { font-size: 22px; }
.t-photo-nom { font-weight: 700; flex: 1; }
.t-photo-etat { color: var(--fg-3); font-weight: 600; }
.t-photo-manuelle { display: flex; align-items: center; gap: 6px; color: var(--fg-3); padding-left: 10px; cursor: pointer; }
.t-photo-manuelle input { width: 18px; height: 18px; }
li.prise .t-photo-prise { border-color: var(--good); background: var(--good-bg); }
li.prise .t-photo-coche { background: var(--good); color: #fff; }
li.prise .t-photo-etat { color: var(--good); }

/* Signaler */
.t-gravites { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.t-gravites input { position: absolute; opacity: 0; pointer-events: none; }
.t-gravite { display: flex; flex-direction: column; gap: 2px; padding: 14px; min-height: 108px; border-radius: 18px; cursor: pointer;
             border: 2px solid var(--line-2); background: var(--surface); justify-content: flex-end; transition: all var(--t-rapide); }
.t-gravite .ti { font-size: 28px; margin-bottom: auto; color: var(--fg-2); }
.t-gravite strong { font-size: 17px; font-family: var(--ff-d); }
.t-gravite span { font-size: 12.5px; color: var(--fg-3); }
.t-gravites input:checked + .t-gravite { border-color: var(--fg); background: var(--fg); color: var(--bg); }
.t-gravites input:checked + .t-gravite .ti, .t-gravites input:checked + .t-gravite span { color: inherit; opacity: .9; }
.t-gravites input:checked + .t-gravite.accident { background: var(--bad); border-color: var(--bad); color: #fff; }
.t-gravites input:focus-visible + .t-gravite { outline: 3px solid var(--accent); outline-offset: 2px; }
.t-alerte-accident { font-size: 15px; }
.t-tel { font-weight: 800; font-size: 17px; color: inherit; text-decoration: underline; }

/* Vue affaire */
.t-fiche { display: flex; flex-direction: column; gap: 10px; }
.t-fiche-ligne { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; }
.t-fiche-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.t-raccourcis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.t-raccourci { --c: var(--accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 78px;
               border-radius: 16px; background: var(--c); color: #fff; font-weight: 700; font-size: 13px; }
.t-raccourci .ti { font-size: 26px; }
.t-raccourci:hover { text-decoration: none; filter: brightness(1.06); }
.t-raccourci:active { transform: scale(.96); }
.t-raccourci.sombre { --c: #2a2318; } .t-raccourci.warn { --c: #8c6433; } .t-raccourci.bad { --c: var(--bad); }
:root[data-theme="dark"] .t-raccourci { color: #1b160f; }
:root[data-theme="dark"] .t-raccourci.sombre { --c: #fff7e4; }

@media (max-width: 380px) {
  .t-stepper { grid-template-columns: 56px minmax(0, 1fr) 56px; }
  .t-cotes { grid-template-columns: minmax(0, 1fr); }
  .t-raccourcis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media print { .t-nav, .t-haut, .t-pied-fixe { display: none !important; } }
