/* Tunnel de vente — styles. Aucune police ni ressource externe (respect de la vie privée). */
:root {
  --navy: #1F3A5F;
  --navy-dark: #16304F;
  --navy-soft: #DCE6F2;
  --bg: #F6F4EF;
  --card: #FFFFFF;
  --line: #E3DED3;
  --field: #C9CFD6;
  --text: #1B2430;
  --muted: #5B6673;
  --ok: #1F6B45;
  --ok-bg: #DDF0E4;
  --warn: #8A5A00;
  --warn-bg: #FBEBC8;
  --bad: #A12B2B;
  --bad-bg: #F8DCDC;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.45; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--navy); outline-offset: 2px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.ico { width: 20px; height: 20px; flex: 0 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- structure ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: 232px; flex: 0 0 232px; background: var(--navy); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 17px; line-height: 1.2; padding: 0 8px; }
.brand span { display: block; font-weight: 500; font-size: 13px; color: #B9C7DA; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #E6ECF4; min-height: 44px; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a[aria-current="page"] { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.nav .sep { height: 1px; background: rgba(255,255,255,.14); margin: 8px 6px; }
.nav .label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #93A6BF; padding: 6px 12px 2px; }
.side .who { margin-top: auto; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.08); display: flex; flex-direction: column; gap: 8px; }
.side .who .name { font-weight: 600; }
.side .who .role { font-size: 13px; color: #B9C7DA; }
.side .who a, .side .who button { color: #E6ECF4; font-size: 14px; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; font-family: inherit; display: inline-flex; gap: 8px; align-items: center; min-height: 32px; }
.main { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1180px; }
.topbar { display: none; }
.tabbar { display: none; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; min-height: 36px; margin-bottom: 6px; }

/* ---------- cartes, grilles ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card > h2 { margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.cols-detail { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .label { color: var(--muted); font-size: 14px; }
.kpi .hint { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--navy); background: transparent; color: var(--navy); font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; text-align: center; }
.btn:hover { background: #ECE8DE; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); text-decoration: underline; cursor: pointer; }

/* ---------- formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 14px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; border: 1px solid var(--field); border-radius: 10px; padding: 0 14px;
  font: inherit; font-size: 16px; background: #fff; color: var(--text);
}
textarea.input { padding: 12px 14px; min-height: 90px; resize: vertical; line-height: 1.45; }
.input.invalid { border-color: var(--bad); }
.error-text { color: var(--bad); font-size: 14px; }
.help { color: var(--muted); font-size: 13px; line-height: 1.4; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--navy); }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 12px; border: 1px solid var(--field); background: #fff; font-weight: 600; color: var(--text); }
.seg input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--navy); outline-offset: 2px; }
.ttc-box { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--bg); }

/* ---------- messages ---------- */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: #B7DCC4; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: #EDB9B9; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--warn-bg); color: #5A3B00; }
.linkbox { word-break: break-all; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: var(--bg); border: 1px dashed var(--field); border-radius: 10px; padding: 10px 12px; user-select: all; }

/* ---------- pastilles ---------- */
.chip { display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; background: #E9ECF1; color: #3B4655; }
.chip-nouveau { background: #E9ECF1; color: #3B4655; }
.chip-rdv { background: #DDEBF7; color: #1B4F7A; }
.chip-a_faire, .chip-warn { background: #FFE3BF; color: #7A3E00; }
.chip-preparation, .chip-d-draft { background: var(--warn-bg); color: var(--warn); }
.chip-envoye, .chip-d-sent { background: var(--navy-soft); color: var(--navy); }
.chip-signe, .chip-d-signed { background: var(--ok-bg); color: var(--ok); }
.chip-job-todo { background: #E9ECF1; color: #3B4655; }
.chip-job-planned { background: #DDEBF7; color: #1B4F7A; }
.chip-job-done { background: var(--ok-bg); color: var(--ok); }
.chip-job-cancelled { background: #ECE8E8; color: #6B5353; }
.chip-over { background: var(--bad-bg); color: var(--bad); }
.chip-perdu, .chip-d-lost { background: #ECE8E8; color: #6B5353; }
.chip-active { background: var(--ok-bg); color: var(--ok); }
.chip-invited { background: var(--warn-bg); color: var(--warn); }
.chip-disabled { background: #ECE8E8; color: #6B5353; }

/* ---------- listes ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 4px; min-height: 64px; }
a.item:hover { background: #FAF8F3; }
.item .main-col { min-width: 0; }
.item .title { font-weight: 600; overflow-wrap: anywhere; }
.item .meta { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.item .side-col { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; flex: 0 0 auto; }
.amount { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.amount-ttc { font-size: 13px; color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--navy-soft); color: var(--navy); font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 40px; }

.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.filters .q { grid-column: 1 / -1; }
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; gap: 12px; }

/* devis */
.devis { padding: 16px 0; }
.devis + .devis { border-top: 1px solid var(--line); }
.devis .head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.devis .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.devis .actions form { display: inline; }
details.inline { display: inline-block; }
details.inline > summary { list-style: none; cursor: pointer; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline[open] { display: block; width: 100%; }
details.inline form.reason { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
details.inline form.reason .input { flex: 1; min-width: 180px; min-height: 38px; }
details.fold > summary { cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold[open] > summary { margin-bottom: 14px; }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.total-box { padding: 12px 14px; background: var(--bg); border-radius: 12px; }
.note { padding: 10px 0; }
.note + .note { border-top: 1px solid var(--line); }
.note .body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* tableaux (utilisateurs, droits, journal) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.matrix th.center, .matrix td.center { text-align: center; }
.matrix td.label-col { min-width: 220px; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: #C9CFD6; border-radius: 999px; transition: background .15s; }
.switch i::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--navy); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--navy); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + i { opacity: .55; }

/* connexion */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .box { width: 100%; max-width: 420px; }
.auth .logo { text-align: center; margin-bottom: 20px; }
.auth .logo b { font-size: 20px; display: block; }
.auth .logo span { color: var(--muted); font-size: 14px; }

.pill-link { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
.contact-lines { display: flex; flex-direction: column; gap: 8px; }
.contact-lines .line { display: flex; gap: 10px; align-items: flex-start; overflow-wrap: anywhere; }
.contact-lines .line .ico { margin-top: 2px; color: var(--muted); }

/* ---------- téléphone ---------- */
@media (max-width: 860px) {
  .shell { display: block; }
  .side { display: none; }
  .main { padding: 0 0 96px; max-width: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--navy); color: #fff; padding: 14px 16px; position: sticky; top: 0; z-index: 5; }
  .topbar b { font-size: 17px; }
  .content { padding: 16px; }
  h1 { font-size: 24px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); z-index: 6; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; font-size: 12px; color: var(--muted); }
  .tabbar a[aria-current="page"] { color: var(--navy); font-weight: 700; }
  .tabbar a.add { color: #fff; }
  .tabbar a.add span.circle { width: 44px; height: 44px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; margin-top: -14px; box-shadow: 0 2px 6px rgba(31,58,95,.35); }
  .cols-2, .cols-detail, .form-grid { grid-template-columns: 1fr; }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .go { grid-column: 1 / -1; }
  .card { padding: 16px; }
  .btn { min-height: 48px; }
  .btn-sm { min-height: 44px; }
  .page-head { margin-bottom: 14px; }
  .item .side-col { align-items: flex-end; }
}
@media (max-width: 420px) {
  .cols-4 { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 24px; }
}
@media print {
  .side, .tabbar, .topbar, .btn { display: none !important; }
  .main { padding: 0; }
}

/* utilitaires */
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }
.mb { margin-bottom: 16px; }
.mb-sm { margin-bottom: 10px; }
.ink { color: var(--text); }
.normal { font-weight: 400; }
.input-sm { min-height: 38px; font-size: 15px; width: auto; max-width: 100%; }
.amount-input { min-height: 56px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.item.stack-sm { align-items: stretch; flex-direction: column; justify-content: flex-start; padding: 14px 4px; }
dl { margin: 0; } dd { margin: 0; } dt { font-size: 13px; }

.matrix select.input { min-width: 140px; padding: 0 8px; font-size: 14px; }

/* ---------- double authentification ---------- */
.flash-warn { background: var(--warn-bg); color: #5A3B00; border-color: #EBD08A; }
.narrow { max-width: 560px; }
.input.otp { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; letter-spacing: .18em; text-align: center; }
.qr { display: flex; justify-content: center; }
.qr img { border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: #fff; max-width: 100%; height: auto; }
.codes { list-style: none; margin: 0; padding: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; background: var(--bg); border: 1px dashed var(--field); border-radius: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 17px; letter-spacing: .06em; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
details.more { border-top: 1px solid var(--line); padding-top: 12px; }
details.more summary { cursor: pointer; color: var(--navy); font-weight: 600; min-height: 32px; }
details.more[open] summary { margin-bottom: 10px; }

/* ---------- rendez-vous, agenda ---------- */
.duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.days { display: flex; flex-direction: column; gap: 12px; }
.day.today { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }
.day > .row { margin-bottom: 6px; }
.day h2 { font-size: 17px; }
.item .when { flex: 0 0 64px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy); }

/* ---------- photos et documents ---------- */
.upload { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload label.btn { cursor: pointer; }
.upload label.btn:focus-within { outline: 2px solid var(--navy); outline-offset: 2px; }
.upload label.btn.busy { opacity: .6; pointer-events: none; }
.photos { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.photos img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.photos .cap { margin-top: 4px; overflow-wrap: anywhere; }
.photos form { display: inline; }
.docs .doc-ico, .doc-card .doc-ico { flex: 0 0 auto; color: var(--navy); }
.docs .item { justify-content: flex-start; gap: 12px; min-height: 56px; }
.docs .item .main-col { flex: 1; }
.docs a.strong { text-decoration: underline; overflow-wrap: anywhere; }
.devis-files { padding: 10px 12px; background: var(--bg); border-radius: 12px; }
.devis-files .photos { margin-bottom: 8px; }

/* parcours : ligne du temps de la fiche */
.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.tl { position: relative; display: flex; gap: 12px; padding-bottom: 16px; }
.tl:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--line); }
.tl-dot { flex: 0 0 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--navy-soft); color: var(--navy); }
.tl-dot .ico { width: 16px; height: 16px; }
.tl-body { min-width: 0; padding-top: 3px; overflow-wrap: anywhere; }
.tl-title { font-weight: 600; }
.tl-detail { white-space: pre-line; }
.tl-signe .tl-dot { background: var(--ok-bg); color: var(--ok); }
.tl-perdu .tl-dot { background: var(--bad-bg); color: var(--bad); }
.tl.future .tl-dot { background: #fff; border: 2px dashed var(--navy); }
.tl.future .tl-title { color: var(--navy); }

/* visionneuse de photo */
.viewer { display: flex; flex-direction: column; gap: 12px; max-width: 900px; }
.viewer-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.viewer-title { min-width: 0; overflow-wrap: anywhere; }
.viewer-stage { background: #0E1620; border-radius: var(--radius); padding: 8px; display: flex; align-items: center; justify-content: center; min-height: 40vh; }
.viewer-stage img { display: block; max-width: 100%; width: auto; height: auto; max-height: 70vh; max-height: 70dvh; object-fit: contain; border-radius: 8px; }
.viewer-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.viewer-nav .btn { min-height: 48px; }
.viewer-nav .btn.off { opacity: .35; cursor: default; }
.viewer-count { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.offline-bar { position: sticky; top: 0; z-index: 8; background: #FFE3BF; color: #7A3E00; border: 1px solid #E8B77A; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-weight: 600; }
.offline-bar[hidden] { display: none; }
.bar-cell { min-width: 130px; width: 28%; }
.bar-cell progress { width: 100%; height: 12px; accent-color: var(--navy); }
/* Lecteur de PDF plein écran : barre fixe avec la croix, pages dessinées dessous */
body.pdf-open { overflow: hidden; }
.pdfv { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: #3A3F47; }
.pdfv-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; background: var(--navy); color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 8px) calc(env(safe-area-inset-right, 0px) + 12px) 8px calc(env(safe-area-inset-left, 0px) + 16px); }
.pdfv-title { flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.pdfv-title strong, .pdfv-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdfv-title strong { font-size: .95rem; }
.pdfv-title span { font-size: .8rem; opacity: .85; }
.pdfv-btn { flex: 0 0 auto; width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .16); text-decoration: none; }
.pdfv-btn:hover { background: rgba(255, 255, 255, .28); }
.pdfv-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.pdfv-btn svg { width: 24px; height: 24px; }
.pdfv-close { background: rgba(255, 255, 255, .28); }
.pdfv-pages { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 10px 0 calc(env(safe-area-inset-bottom, 0px) + 24px); }
.pdfv-page { position: relative; width: calc(100% - 16px); max-width: 980px; margin: 0 auto 10px; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .35); }
.pdfv-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pdfv-page.failed { display: flex; align-items: center; justify-content: center; min-height: 120px; color: var(--muted); }
.pdfv-msg { color: #fff; text-align: center; padding: 32px 18px; }
.pdfv-msg a { color: #fff; font-weight: 700; text-decoration: underline; }
.doc-head { align-items: center; gap: 14px; }
.doc-name { font-size: 1.05rem; margin: 0; overflow-wrap: anywhere; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.doc-actions .btn { flex: 1 1 200px; min-height: 48px; justify-content: center; }

/* ---------- statistiques ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--field); background: #fff; color: var(--text); font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.stats-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; margin-bottom: 16px; }
.stat-table th[scope="row"] { font-weight: 600; font-size: 15px; color: var(--text); }
.stat-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-table th.num { text-align: right; }
.stat-table .rate { min-width: 150px; }
.stat-table .rate .hbar { vertical-align: middle; margin-right: 8px; }
.hbar { width: 80px; height: 8px; }
.hbar-bg { fill: #E9ECF1; }
.hbar-sent { fill: #3E73B8; }
.hbar-signed { fill: #2FA36B; }
.legend { list-style: none; margin: 0 0 6px; padding: 0; display: flex; gap: 16px; font-size: 14px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch-sent { background: #3E73B8; }
.swatch-signed { background: #2FA36B; }
.chart { width: 100%; height: auto; display: block; }
.bar-sent { fill: #3E73B8; }
.bar-signed { fill: #2FA36B; }
.bar-val { font-size: 12px; fill: var(--text); font-family: var(--font); }
.axis-text { font-size: 12px; fill: var(--muted); font-family: var(--font); }
.axis-line { stroke: var(--field); stroke-width: 1; }
.today-card .today-list { display: flex; gap: 8px; flex-wrap: wrap; }
.today-card a.chip { min-height: 36px; padding: 0 14px; font-size: 14px; }
.chart-wrap { overflow-x: auto; }
@media (max-width: 860px) {
  .stats-filters { grid-template-columns: 1fr; }
  .chart { min-width: 600px; }
  .stat-table .rate { min-width: 0; }
  .hbar { width: 56px; }
}

/* ---------- mails ---------- */
.mailbody { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; line-height: 1.5; }
textarea.input.tall { min-height: 260px; }
dt code { font-size: 13px; background: var(--bg); padding: 1px 6px; border-radius: 6px; }

/* ---------- terrain (téléphone) : actions rapides, onglets de la fiche, recherche ---------- */
.quick, .ftabs, .phone-only, .cam-only, .filters-toggle, .touch-only, .touch-only-block { display: none; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.search-link { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: -8px -8px -8px 0; color: #fff; }
.tabbed { scroll-margin-top: 64px; }
@media (pointer: coarse) {
  .cam-only, .touch-only { display: inline-flex; }
  .touch-only-block { display: block; }
  .mail-default { background: transparent; color: var(--navy); }
}
@media (max-width: 860px) {
  .topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
  [id] { scroll-margin-top: 72px; }
  .phone-only { display: block; }
  .desk-only { display: none; }
  .quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .quick > .btn { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 3px; min-height: 62px; padding: 8px 4px; font-size: 13px; }
  .tabbed[data-active] .ftabs { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .ftabs::-webkit-scrollbar { display: none; }
  .ftabs button { flex: 1 1 auto; min-height: 44px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--field); background: #fff; color: var(--text); font: inherit; font-weight: 600; font-size: 13px; white-space: nowrap; cursor: pointer; }
  .ftabs button[aria-selected="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
  .tabbed[data-active="resume"] [data-tab]:not([data-tab="resume"]),
  .tabbed[data-active="devis"] [data-tab]:not([data-tab="devis"]),
  .tabbed[data-active="chantier"] [data-tab]:not([data-tab="chantier"]),
  .tabbed[data-active="notes"] [data-tab]:not([data-tab="notes"]),
  .tabbed[data-active="photos"] [data-tab]:not([data-tab="photos"]),
  .tabbed[data-active="parcours"] [data-tab]:not([data-tab="parcours"]) { display: none; }
  .tabbed[data-active="devis"] .cols-detail > .stack { display: none; }
  .filters-toggle { display: inline-flex; }
  .filters.collapsed .field:not(.q) { display: none; }
  .upload { flex-direction: column; align-items: stretch; }
  .upload label.btn { width: 100%; }
}

/* ---------- en-tête de fiche compact, date du rendez-vous ---------- */
.client-head { flex-wrap: nowrap; align-items: flex-start; }
.client-title { min-width: 0; flex: 1 1 auto; }
.client-head .edit-btn { flex: 0 0 auto; }
.when { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; white-space: nowrap; vertical-align: middle; }
.when .ico { width: 16px; height: 16px; flex-basis: 16px; }
.mail-default:hover { background: #ECE8DE; }
@media (max-width: 860px) {
  .client-head .edit-btn { min-height: 44px; }
  .stack > .has-rdv { order: -1; }
  .mail-actions { flex-direction: column; align-items: stretch; }
}

/* ---------- feuilles qui montent du bas (Y aller, SMS) ---------- */
dialog.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: #fff; color: var(--text); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(20, 30, 45, .25); }
dialog.sheet::backdrop { background: rgba(20, 30, 45, .5); }
dialog.sheet[open] { animation: sheet-up .2s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-body { padding: 8px 8px calc(16px + env(safe-area-inset-bottom)); }
.sheet-body::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--field); margin: 4px auto 6px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 6px 8px 10px 12px; }
.sheet-head h2 { font-size: 20px; }
.sheet-head p { margin-top: 2px; overflow-wrap: anywhere; }
.sheet-close { flex: 0 0 auto; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: var(--bg); color: var(--text); cursor: pointer; }
.sheet-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sheet-row { display: flex; align-items: center; gap: 14px; padding: 12px; min-height: 68px; border-radius: 16px; background: var(--bg); }
.sheet-row:active { background: var(--navy-soft); }
.sheet-row > .ico { color: var(--muted); }
.sheet-ico { flex: 0 0 46px; width: 46px; height: 46px; border-radius: 50%; background: var(--navy-soft); color: var(--navy); display: flex; align-items: center; justify-content: center; }
.sheet-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sheet-txt .t { font-weight: 700; font-size: 17px; }
.sheet-txt .d { color: var(--muted); font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
body:has(dialog[open]) { overflow: hidden; }

/* ---- sociétés : couleur de repère, pastille et sélecteur ---- */
body.theme-ambre { --navy: #8A4B0F; --navy-dark: #6B3A0A; --navy-soft: #F6E6D0; }
body.theme-vert { --navy: #1E6B4A; --navy-dark: #165236; --navy-soft: #D9EFE2; }
body.theme-violet { --navy: #5B3A8E; --navy-dark: #452B6E; --navy-soft: #E6DDF4; }

.soc-chip { display: inline-flex; align-items: center; min-height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.soc-chip.soc-bleu { background: #DCE6F2; color: #1F3A5F; }
.soc-chip.soc-ambre { background: #F6E6D0; color: #7A410A; }
.soc-chip.soc-vert { background: #D9EFE2; color: #17583B; }
.soc-chip.soc-violet { background: #E6DDF4; color: #4A2E78; }

.soc-switch { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 8px 10px 8px 14px; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--navy); border-radius: 12px; }
.soc-label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.soc-seg { display: flex; flex: 1; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.soc-opt { appearance: none; border: 1px solid var(--field); background: var(--card); color: var(--text); font: inherit; font-size: 15px; font-weight: 600; min-height: 44px; padding: 0 16px; border-radius: 10px; cursor: pointer; }
.soc-opt[aria-current="true"] { background: var(--navy); border-color: var(--navy); color: #fff; cursor: default; }
.soc-opt:not([aria-current="true"]):hover { background: var(--navy-soft); }
@media (max-width: 860px) {
  .soc-switch { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 10px 10px 14px; }
  .soc-label { display: none; }  /* la couleur de l'écran et les boutons suffisent ; gain de place sur téléphone */
  .soc-switch { gap: 0; padding: 8px 8px 8px 12px; }
  .soc-seg { justify-content: stretch; flex-wrap: nowrap; }
  .soc-opt { flex: 1 1 0; padding: 0 6px; font-size: 14px; }
}
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 2px; }
.fieldset legend { padding: 0; font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.check-inline { min-height: 38px; gap: 8px; font-size: 15px; }

/* Installation et SAV */
.job { padding: 14px 0; }
.job + .job { border-top: 1px solid var(--line); }
.job .head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.job .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.job .actions form { display: inline; }
.job-notes { white-space: pre-line; }
.job-hours { display: flex; gap: 28px; flex-wrap: wrap; }
.notice-bad { background: var(--bad-bg); color: var(--bad); }
.time-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.time-list li { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) auto; gap: 4px 10px; align-items: baseline; }
.time-list li .small { overflow-wrap: anywhere; }
.time-list li form { display: inline; }
.time-form { margin-top: 4px; }
.kpi .value.bad { color: var(--bad); }

/* ---------- accueil du poseur : l'intervention à faire maintenant ---------- */
.now-card { border-left: 4px solid var(--navy); }
.now-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin-top: 6px; overflow-wrap: anywhere; }
.now-lines { margin: 10px 0; }
.now-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
@media (max-width: 860px) {
  .now-actions > .btn { flex: 1 1 auto; white-space: nowrap; min-height: 52px; }
}
