/* Appli technicien — mobile d'abord (375 px, cadre de téléphone du CRM), centrée à 480 px sur
   ordinateur. Cibles tactiles ≥ 48 px, barre d'actions en bas, zones sûres respectées.
   Tout est préfixé (.tech, .t-…) : cette feuille est aussi chargée par le CRM. */

html.tech-root body { background: #e4e8e3; }
html.t-locked, html.t-locked body { overflow: hidden; }
/* Le toast partagé (ui.js) passe sous l'en-tête : en bas, il masquerait la barre d'actions. */
html.tech-root #toast { top: calc(70px + env(safe-area-inset-top)); bottom: auto; transform: translate(-50%, -12px); max-width: calc(100vw - 32px); text-align: center; }
html.tech-root #toast.show { transform: translate(-50%, 0); }

.tech { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--bg); font-size: 15px; position: relative; }
@media (min-width: 520px) { .tech { box-shadow: 0 0 0 1px var(--line), 0 12px 40px rgba(16, 24, 20, .08); } }
.tech .t-input, .tech input.input, .tech textarea.input { font-size: 16px; } /* pas de zoom iOS au focus */
.tech .btn { font-size: 15px; }
.t-screen { min-height: 100vh; min-height: 100dvh; }

/* --- En-tête -------------------------------------------------------------------------- */
.t-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; min-height: 60px;
  padding: calc(8px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  background: var(--brand-dark); color: #fff; }
.t-top-title { flex: 1; min-width: 0; }
.t-top-title h1 { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-top-title small { display: block; font-size: 12.5px; opacity: .78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-top-title small::first-letter { text-transform: uppercase; }
.t-top-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; border: 0; background: none; color: #fff; cursor: pointer; text-decoration: none; }
.t-top-btn:hover { background: rgba(255, 255, 255, .12); }
.t-top-btn.dark { color: var(--ink-2); }
.t-top-btn.dark:hover { background: var(--line-2); }
.t-mark { width: 38px; height: 38px; flex: none; border-radius: 10px; background: #fff; padding: 3px; object-fit: contain; }
.t-me { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; text-decoration: none; }
.t-me .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, .85); }

/* --- Page et barre du bas ---------------------------------------------------------------- */
.t-page { padding: 16px max(14px, env(safe-area-inset-left)) calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.t-page.has-bar { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.t-page.has-bar.bar-mid { padding-bottom: calc(130px + env(safe-area-inset-bottom)); }
.t-page.has-bar.bar-tall { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }
.t-bar { position: fixed; z-index: 25; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; display: grid; gap: 8px;
  padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(16, 24, 20, .06); }
.tech .t-btn { width: 100%; min-height: 52px; border-radius: 14px; font-size: 15.5px; white-space: normal; line-height: 1.2; text-align: center; }
.t-btn span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.t-duo { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; }
.t-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.t-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; border-radius: 14px; border: 0;
  background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 14px; cursor: pointer; }
.t-tool:active { filter: brightness(.95); }
.t-tool:disabled { opacity: .6; }
.t-closed { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--green); font-weight: 700; }

/* --- Titres ------------------------------------------------------------------------------- */
.t-h { font-size: 21px; font-weight: 700; }
.t-lead { margin-top: -8px; }
.t-sub { font-size: 15px; margin-top: 4px; }
.t-hello h2 { font-size: 22px; }
.t-hello p { margin-top: 2px; }
.t-section { display: flex; flex-direction: column; gap: 10px; }
.t-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.t-hint { display: flex; gap: 6px; align-items: flex-start; font-size: 13.5px; color: var(--ink-3); }
.t-hint.warn { color: var(--amber); background: var(--amber-soft); padding: 9px 11px; border-radius: 10px; font-weight: 600; }
.t-hint .icon { margin-top: 1px; }
.t-empty { color: var(--ink-3); background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.t-link { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; min-height: 44px; border: 0; background: none; color: var(--brand); font-weight: 700; cursor: pointer; padding: 0; text-decoration: none; }

/* --- Listes : techniciens, journée ---------------------------------------------------------- */
.t-list { display: flex; flex-direction: column; gap: 8px; }
.t-group { display: flex; flex-direction: column; gap: 8px; }
.t-group-title { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.t-group-title i { width: 10px; height: 10px; border-radius: 3px; }
.t-tech { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px; padding: 10px 12px; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); }
.t-tech.current { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.t-tech-main { flex: 1; min-width: 0; }
.t-tech-main b { display: block; font-size: 15.5px; }
.t-tech-main small { display: block; color: var(--ink-3); font-size: 12.5px; }
.t-tech-main small::first-letter { text-transform: uppercase; }
.t-tech-count { font-size: 12.5px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.t-tech > .icon { color: var(--ink-3); }

.t-job { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 76px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--ink); }
.t-job.current { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.t-job.done { background: #fafbf9; }
.t-job.done .t-job-title, .t-job.done .t-job-time b { color: var(--ink-3); }
.t-job > .icon { color: var(--ink-3); }
.t-job.done > .icon { color: var(--green); }
.t-job-time b { display: block; font-size: 17px; }
.t-job-time small { display: block; color: var(--ink-3); font-size: 12px; }
.t-job-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.t-job-main > small { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-job-title { font-size: 15px; line-height: 1.3; }
.t-job-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.t-status { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; }
.t-status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tone-text-gray { color: var(--gray); } .tone-text-blue { color: var(--blue); } .tone-text-amber { color: var(--amber); } .tone-text-green { color: var(--green); }
.t-fold { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 50px; padding: 0 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel); font-weight: 700; color: var(--ink-2); }
.t-fold .icon { transition: transform .15s; }
.t-fold .icon.rot { transform: rotate(90deg); }
.t-switch { display: inline-flex; align-items: center; gap: 6px; align-self: center; min-height: 44px; color: var(--ink-2); font-weight: 600; text-decoration: none; }
.t-demo { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); text-align: center; }
.t-demo .link { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; background: none; border: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; font-size: 12px; }

/* --- Intervention ---------------------------------------------------------------------------- */
.t-hero { display: flex; flex-direction: column; gap: 6px; }
.t-hero h2 { font-size: 20px; line-height: 1.25; }
.t-desc { color: var(--ink-2); }
.t-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.t-kv { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.t-kv:last-child { border-bottom: 0; }
.t-kv.full { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.t-kv > span { font-size: 12.5px; font-weight: 700; color: var(--ink-3); padding-top: 1px; }
.t-kv > div { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.t-kv small { color: var(--ink-3); font-size: 13px; }
.t-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; margin-top: 6px; padding: 0 14px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 14px; text-decoration: none; }
.t-fluid { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 3px 9px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 12.5px; font-weight: 700; }
.t-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.t-history li { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; font-size: 13.5px; }
.t-history b { display: block; font-weight: 600; }
.t-history small { display: block; }

.t-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.t-entry { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; position: relative; padding-bottom: 14px; }
.t-entry::before { content: ''; position: absolute; left: 15px; top: 30px; bottom: 0; width: 2px; background: var(--line); }
.t-entry:last-child::before { display: none; }
.t-entry-dot { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); color: var(--ink-2); }
.k-status .t-entry-dot { background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand-dark); }
.k-voice .t-entry-dot { background: var(--blue-soft); border-color: var(--blue-soft); color: var(--blue); }
.t-entry-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-top: 5px; }
.t-entry-body p { background: var(--panel); border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; padding: 9px 11px; }
.t-entry-meta { font-size: 12px; color: var(--ink-3); }
.t-photo { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; max-width: 240px; }
.t-photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: var(--line-2); }
.t-entry.pending { opacity: .6; }
.t-zoom { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .88); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.t-zoom img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.t-doc { overflow: hidden; }
.t-doc summary, .t-doc-row { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 10px 14px; cursor: pointer; list-style: none; }
.t-doc summary::-webkit-details-marker { display: none; }
.t-doc summary > span:not(.badge), .t-doc-row > span:not(.badge) { flex: 1; min-width: 0; }
.t-doc summary b, .t-doc-row b { display: block; }
.t-doc small { display: block; color: var(--ink-3); font-size: 13px; }
.t-doc .icon { color: var(--brand); }
.t-doc-sec { padding: 10px 14px; border-top: 1px solid var(--line-2); }
.t-doc-sec h4 { margin: 0 0 3px; font-size: 13px; color: var(--ink-2); }

/* --- Feuille du bas ------------------------------------------------------------------------------ */
.t-sheet-backdrop { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(18, 24, 20, .45); }
.t-sheet { width: 100%; max-width: 480px; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; background: var(--panel); border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .2); animation: t-up .18s ease-out; }
@keyframes t-up { from { transform: translateY(32px); } to { transform: none; } }
.t-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 18px; }
.t-sheet-body { padding: 8px 16px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.t-sheet-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-2); }
.t-sheet-body:last-child { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.t-samples { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.t-samples button { padding: 0; border: 0; background: none; cursor: pointer; }
.t-samples img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }

/* --- Dictée ----------------------------------------------------------------------------------- */
.t-dictate { display: flex; flex-direction: column; gap: 10px; }
.t-mic { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 60px; border-radius: 16px; cursor: pointer;
  border: 2px solid var(--brand); background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 16.5px; }
.t-mic:disabled { opacity: .7; cursor: wait; }
.t-mic.rec { background: var(--red); border-color: var(--red); color: #fff; }
.t-mic.rec .num { opacity: .9; font-weight: 600; }
.t-mic.busy { cursor: default; background: var(--panel); border-color: var(--line); }
.t-mic.busy .working { padding: 0; }
.t-rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; animation: t-pulse 1s ease-in-out infinite; }
@keyframes t-pulse { 50% { opacity: .3; transform: scale(.8); } }
.tech textarea.t-input { min-height: 0; }

/* --- Parcours guidés ---------------------------------------------------------------------------- */
.t-steps { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.t-steps i { height: 4px; border-radius: 2px; background: var(--line); }
.t-steps i.on { background: var(--brand); }
.t-choices { display: flex; flex-direction: column; gap: 8px; }
.t-choice { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 14px; text-align: left; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); }
.t-choice b { display: block; font-size: 15.5px; }
.t-choice small { display: block; color: var(--ink-3); font-size: 13px; }
.t-choice-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--line-2); color: var(--ink-3); }
.t-choice.on { border-color: var(--c); box-shadow: 0 0 0 2px var(--c-soft); }
.t-choice.on .t-choice-icon { background: var(--c); color: #fff; }
.c-green { --c: var(--green); --c-soft: var(--green-soft); }
.c-amber { --c: var(--amber); --c-soft: var(--amber-soft); }
.c-red { --c: var(--red); --c-soft: var(--red-soft); }
.t-writing { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 48px 12px; }
.t-writing .working { flex-direction: column; gap: 12px; text-align: center; }
.t-writing-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); margin-bottom: 4px; }
.t-outcome { padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); }
.t-field { display: flex; flex-direction: column; gap: 6px; }
.t-field > span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.tech .t-field input.input { min-height: 48px; }
.t-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--line-2); }
.t-toggle button { min-height: 46px; border: 0; border-radius: 11px; background: none; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.t-toggle button.on { background: var(--panel); color: var(--brand-dark); box-shadow: var(--shadow); }
/* Formulaire du métier à la clôture : cases larges, pavé numérique, choix en boutons. */
.t-form { display: flex; flex-direction: column; gap: 10px; }
.t-check { min-height: 56px; }
.t-check .t-choice-icon { width: 30px; height: 30px; border-radius: 9px; border: 1.5px solid var(--line); background: var(--panel); }
.t-check.on .t-choice-icon { border-color: var(--c); }
.t-all { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 700; }
.t-num { display: flex; align-items: center; gap: 10px; }
.t-num input.input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.t-num b { min-width: 34px; color: var(--ink-2); }
.t-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.t-seg button { flex: 1 1 auto; min-height: 46px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--panel); font-weight: 700; color: var(--ink-2); cursor: pointer; }
.t-seg button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.t-field > span em { font-style: normal; font-weight: 400; }
.t-done { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 8px 8px; }
.t-done-icon { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; background: var(--brand); color: #fff; margin-bottom: 8px; box-shadow: 0 0 0 10px var(--brand-soft); }
.t-done h2 { font-size: 22px; }
.t-done p { color: var(--ink-2); max-width: 32ch; }
.t-done-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 18px; }

/* --- Devis ------------------------------------------------------------------------------------- */
.t-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.t-line { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.t-line-head { display: flex; gap: 6px; align-items: flex-start; }
.t-line-head > span { flex: 1; min-width: 0; }
.t-line-head b { display: block; font-size: 14.5px; line-height: 1.3; }
.t-line-head small { display: block; color: var(--ink-3); font-size: 12.5px; }
.t-line-x { display: grid; place-items: center; width: 40px; height: 40px; flex: none; margin-top: -6px; border: 0; border-radius: 10px; background: none; color: var(--ink-3); cursor: pointer; }
.t-line-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-right: 8px; }
.t-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.t-stepper button { width: 46px; height: 44px; border: 0; background: var(--line-2); font-size: 20px; font-weight: 700; cursor: pointer; color: var(--ink); }
.t-stepper button:disabled { color: var(--ink-3); opacity: .5; }
.t-stepper span { min-width: 64px; text-align: center; font-weight: 700; font-size: 14px; }
.t-add { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border: 1.5px dashed var(--brand); border-radius: 14px; background: none; color: var(--brand); font-weight: 700; cursor: pointer; }
.t-totals { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px; }
.t-totals > div { display: flex; justify-content: space-between; padding: 6px 0; color: var(--ink-2); }
.t-totals > .ttc { border-top: 1px solid var(--line); margin-top: 2px; padding-top: 10px; font-size: 18px; font-weight: 700; color: var(--ink); }
.t-search { position: relative; display: block; }
.t-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.tech .t-search input { padding-left: 38px; min-height: 48px; }
.t-catalog { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.t-catalog button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 56px; padding: 8px 4px; text-align: left; border: 0; border-bottom: 1px solid var(--line-2); background: none; cursor: pointer; }
.t-catalog b { display: block; font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.t-catalog small { display: block; color: var(--ink-3); font-size: 12px; }
.t-catalog .num { text-align: right; font-weight: 700; white-space: nowrap; }
.t-agree { padding: 14px; display: flex; flex-direction: column; gap: 8px; }

/* --- Signature (lib/signature.js) --------------------------------------------------------------- */
.sig { display: flex; flex-direction: column; gap: 6px; }
.sig-canvas { display: block; width: 100%; background: #fff; border: 1.5px dashed #c9cec8; border-radius: 14px; touch-action: none; cursor: crosshair; }
.sig-foot { display: flex; align-items: center; justify-content: space-between; }
.sig-line { font-size: 13px; color: var(--ink-3); }
.sig-clear { min-height: 44px; padding: 0 12px; border: 0; background: none; color: var(--brand); font-weight: 700; cursor: pointer; }
