:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --line: rgba(60, 60, 67, .14);
  --fill: rgba(118, 118, 128, .12);
  --accent: #111111;
  --on-accent: #ffffff;
  --accent-soft: rgba(17, 17, 17, .08);
  --green: #1f9d55;
  --red: #d62d20;
  --tabbar: rgba(249, 249, 249, .88);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f2f2f7;
    --muted: #8e8e93;
    --line: rgba(84, 84, 88, .55);
    --fill: rgba(118, 118, 128, .24);
    --accent: #ffffff;
    --on-accent: #000000;
    --accent-soft: rgba(255, 255, 255, .14);
    --green: #32d74b;
    --red: #ff453a;
    --tabbar: rgba(22, 22, 24, .88);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(84px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
body.no-tabs { padding-bottom: env(safe-area-inset-bottom); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.page { max-width: 640px; margin: 0 auto; padding: 8px 16px 24px; }
.marque { font-family: Futura, "Avenir Next", sans-serif; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 14px 4px 0; }
h1 { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin: 2px 4px 14px; overflow-wrap: anywhere; }
h2 { font-size: 13px; font-weight: 400; text-transform: uppercase; color: var(--muted); margin: 26px 16px 7px; letter-spacing: .02em; }
.logo-compte { display: block; height: 44px; max-width: 70%; object-fit: contain; object-position: left; margin: 12px 4px 4px; }
.foot { font-size: 13px; color: var(--muted); margin: 7px 16px 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin: 0 -4px; }
.topbar a, .topbar button { color: var(--accent); text-decoration: none; background: none; border: 0; padding: 10px 4px; font-size: 17px; }

/* Groupes façon Réglages iOS */
.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 16px;
  position: relative; text-decoration: none; color: inherit; width: 100%; background: none; border: 0; text-align: left;
}
.row + .row::before, .field + .field::before, .field + .row::before, .row + .field::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--line);
}
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 14px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .val { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.row .val small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.row.chev::after { content: ""; width: 8px; height: 8px; border: solid #c4c4c7; border-width: 2px 2px 0 0; transform: rotate(45deg); margin-left: 4px; flex: none; }
a.row:active, button.row:active { background: var(--fill); }
.row.danger { color: var(--red); justify-content: center; }
.row.action { color: var(--accent); justify-content: center; font-weight: 500; }

/* Formulaires */
.field { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 16px; position: relative; }
.field label { width: 84px; flex: none; }
#fm .field label { width: 118px; }
.field input, .field select, .field textarea {
  flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 8px 0; text-align: right; font-size: 17px;
  -webkit-appearance: none; appearance: none;
}
.field select { direction: rtl; text-overflow: ellipsis; }
.field input[type=date] { min-height: 34px; display: flex; justify-content: flex-end; }
.field input::-webkit-date-and-time-value { text-align: right; }
.field textarea { text-align: left; resize: none; padding: 10px 0; }

/* Étapes de la journée */
.etape { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 12px 8px 16px; position: relative; }
.etape + .etape::before, .etape + .pauses::before, .pauses + .etape::before { content: ""; position: absolute; top: 0; left: 44px; right: 0; border-top: .5px solid var(--line); }
.etape .pt { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #c4c4c7; flex: none; margin-right: 6px; }
.etape.fait .pt { background: var(--accent); border-color: var(--accent); }
.etape .grow { flex: 1; min-width: 0; }
.etape .lbl { font-weight: 500; }
.etape .hint { font-size: 13px; color: var(--muted); min-height: 0; }
input[type=time] {
  border: 0; background: var(--fill); border-radius: 8px; padding: 7px 8px; font-size: 17px; font-weight: 600; min-width: 88px; min-height: 38px;
  text-align: center; font-variant-numeric: tabular-nums; outline: none; -webkit-appearance: none; appearance: none;
}
input[type=time]::-webkit-date-and-time-value { text-align: center; }
.now { border: 0; background: var(--text); color: var(--bg); border-radius: 8px; padding: 0 11px; height: 38px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; flex: none; }
.now:active { opacity: .7; }
.pauses { padding: 10px 12px 12px 44px; position: relative; }
.pauses .lbl { font-weight: 500; margin-bottom: 6px; display: flex; justify-content: space-between; }
.pauses .lbl span { color: var(--muted); font-weight: 400; font-size: 14px; }
.pause { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pause .a { color: var(--muted); font-size: 14px; }
.pause .x { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 4px 8px; margin-left: auto; }
.mini-btn { border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 600; }

/* Totaux */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border-radius: 14px; padding: 14px 6px; text-align: center; }
.stats.q { grid-template-columns: repeat(4, 1fr); }
.stats.q b { font-size: 18px; }
.stats.q span { font-size: 10px; }
.stats b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stats span { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.btn {
  display: block; width: 100%; border: 0; border-radius: 12px; padding: 15px; font-size: 17px; font-weight: 600;
  background: var(--accent); color: var(--on-accent); margin-top: 22px; text-align: center; text-decoration: none;
}
.btn:active { opacity: .8; }
.btn:disabled { opacity: .4; }
.btn.ghost { background: var(--card); color: var(--accent); margin-top: 10px; }
.btn.contour { background: none; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.btn.noir { background: var(--text); color: var(--bg); }
.duo { display: flex; gap: 10px; margin-top: 12px; }
.duo .btn { margin-top: 0; }

.empty { text-align: center; color: var(--muted); padding: 36px 20px; }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 4px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--fill); color: var(--muted); }

.filtre { width: 100%; border: 0; border-radius: 12px; background: var(--card); padding: 13px 16px; font-size: 17px; outline: none; -webkit-appearance: none; appearance: none; }

/* Écran connexion */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; max-width: 380px; margin: 0 auto; padding: 24px; text-align: center; }
.login .logo { width: 132px; height: 132px; margin: 0 auto 18px; color: var(--text); display: block; }
.login h1 { margin: 0; font-family: Futura, "Avenir Next", sans-serif; font-size: 25px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.login .metiers { font-family: Futura, "Avenir Next", sans-serif; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text); margin: 6px 0 30px; }
.login p { color: var(--muted); margin: 0 0 12px; }
.login input { width: 100%; border: 0; border-radius: 12px; background: var(--card); padding: 15px; text-align: center; font-size: 18px; outline: none; }
.login input + input { margin-top: 10px; }
.err { color: var(--red); font-size: 15px; margin-top: 12px; min-height: 20px; }

/* Barre d'onglets */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around; align-items: flex-start;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--tabbar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--line);
}
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 10px; font-weight: 500; padding-top: 2px; }
#tabs a.on { color: var(--accent); }
#tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  background: rgba(30, 30, 30, .92); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 15px; max-width: 90vw; text-align: center;
}

/* Feuilles (confirmation, nouveau contrat) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; display: flex; align-items: flex-end; }
.sheet { width: 100%; max-width: 640px; margin: 0 auto; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
.sheet .group { border-radius: 14px; margin-bottom: 8px; }
.sheet .msg { text-align: center; color: var(--muted); font-size: 13px; padding: 14px 16px; }
.sheet .msg b { display: block; color: var(--text); font-size: 17px; margin-bottom: 2px; }
.sheet .row { justify-content: center; font-size: 20px; color: var(--accent); min-height: 56px; }
.sheet .row.cancel { font-weight: 600; }
.sheet .row.destroy { color: var(--red); }
.sheet .field input { text-align: left; }
.sheet .field label { width: 118px; }
.avis { white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet.haut { align-self: flex-start; padding-top: calc(12px + env(safe-area-inset-top)); }
@media (prefers-color-scheme: dark) { .logo-compte { background: #fff; padding: 5px 8px; border-radius: 8px; height: 54px; } }

/* Choix à deux options (point de départ) */
.seg { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; flex: none; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
h2 .badge { text-transform: none; margin-left: 6px; }

/* Sélecteur de semaine */
.semaine { display: flex; align-items: center; background: var(--card); border-radius: 12px; }
.semaine button { border: 0; background: none; font-size: 28px; line-height: 1; padding: 10px 20px 14px; color: var(--accent); }
.semaine div { flex: 1; text-align: center; }
.semaine b { display: block; font-weight: 600; }
.semaine span { font-size: 13px; color: var(--muted); }

/* ================= Habillage : béton, noir et blanc ================= */
:root {
  --bg: #e9e8e5;
  --titre: Futura, "Avenir Next", "Century Gothic", "Trebuchet MS", sans-serif;
  --ombre: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(0, 0, 0, .07);
  --bandeau: #111111;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0b0c; --card: #19191b; --ombre: 0 0 0 .5px rgba(255, 255, 255, .08); --bandeau: #19191b; }
}
/* Grain discret, comme une dalle polie */
body {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* Bandeau de marque en haut des pages principales */
.bandeau {
  display: flex; align-items: center; gap: 14px; color: #fff; background: var(--bandeau);
  margin: calc(-8px - env(safe-area-inset-top)) -16px 20px; padding: calc(20px + env(safe-area-inset-top)) 20px 20px;
  border-radius: 0 0 24px 24px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.bandeau .logo { width: 46px; height: 46px; flex: none; }
.bandeau .nom { font-family: var(--titre); font-weight: 700; font-size: 17px; letter-spacing: .06em; text-transform: uppercase; line-height: 1.15; }
.bandeau .app { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; opacity: .6; margin-top: 3px; }
.bandeau.clair { background: #fff; color: #111; justify-content: space-between; }
.bandeau.clair .logo-compte { height: 46px; max-width: 62%; margin: 0; padding: 0; background: none; border-radius: 0; }
.bandeau.clair .app { margin: 0; text-align: right; }

/* Titres */
h1 { font-family: var(--titre); font-weight: 700; font-size: 30px; letter-spacing: .01em; text-transform: uppercase; margin: 4px 4px 16px; line-height: 1.1; }
h2 { font-family: var(--titre); font-weight: 700; font-size: 11px; letter-spacing: .16em; margin: 28px 6px 9px; }
.marque { margin-left: 4px; }

/* Cartes */
.group, .semaine, .filtre { border-radius: 16px; box-shadow: var(--ombre); }
.row { min-height: 54px; }
.row .val { font-family: var(--titre); font-size: 17px; }
.row .val small { font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif; }

/* Totaux : carte noire, chiffres en gros */
.stats { background: var(--accent); color: var(--on-accent); border-radius: 18px; padding: 18px 6px 16px; box-shadow: 0 10px 28px rgba(0, 0, 0, .2); }
.stats b { font-family: var(--titre); font-size: 22px; letter-spacing: 0; white-space: nowrap; }
.stats.q b { font-size: 19px; }
.stats span { color: inherit; opacity: .6; letter-spacing: .1em; font-size: 10px; }
.stats > div + div { border-left: .5px solid color-mix(in srgb, currentColor 22%, transparent); }

/* Boutons */
.btn { font-family: var(--titre); text-transform: uppercase; letter-spacing: .1em; font-size: 15px; font-weight: 700; padding: 17px; border-radius: 14px; box-shadow: 0 8px 22px rgba(0, 0, 0, .16); transition: transform .08s; }
.btn:active { transform: scale(.985); opacity: .9; }
.btn.ghost, .btn.contour { box-shadow: none; }
.btn.ghost { box-shadow: var(--ombre); }
.btn.contour { box-shadow: inset 0 0 0 2px var(--accent); }
.now { font-family: var(--titre); border-radius: 10px; letter-spacing: .06em; }
.mini-btn { font-family: var(--titre); letter-spacing: .04em; }
input[type=time] { border-radius: 10px; }

/* Étapes de la journée : une ligne du temps relie les points */
.etape, .pauses { --rail: 21px; }
.etape::after, .pauses::after { content: ""; position: absolute; left: var(--rail); top: 0; bottom: 0; width: 2px; background: var(--line); }
.etape:first-child::after { top: 50%; }
.etape:last-child::after { bottom: 50%; }
.etape .pt { position: relative; z-index: 1; background: var(--card); width: 14px; height: 14px; margin-left: -1px; }
.etape.fait .pt { box-shadow: 0 0 0 4px var(--accent-soft); }
.etape .lbl { font-weight: 600; }

/* Barre d'onglets */
#tabs a { font-family: var(--titre); letter-spacing: .08em; text-transform: uppercase; font-size: 9.5px; font-weight: 700; position: relative; padding-top: 6px; }
#tabs a.on::before { content: ""; position: absolute; top: -6px; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }

/* Connexion */
.login input { border-radius: 14px; box-shadow: var(--ombre); }
.login .logo { width: 140px; height: 140px; }

/* Connexion : icône de l'application */
.login .icone { width: 148px; height: 148px; margin: 0 auto 22px; display: block; border-radius: 22.5%; box-shadow: 0 14px 34px rgba(0, 0, 0, .28); }
.login .metiers { color: var(--muted); letter-spacing: .1em; font-size: 11px; margin: 8px 0 30px; }

/* Connexion : toujours sur fond noir, pour que le logo Chrono Chantier s'y fonde */
body.ecran-login { background: #0c0c0c; color: #f2f2f7; }
.login .logo-app {
  display: block; width: 290px; max-width: 84%; height: auto; margin: 0 auto 2px;
  /* seuls les bords s'estompent, pour ne pas ternir le nom au bas du logo */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 9%, #000 91%, transparent), linear-gradient(to bottom, transparent, #000 7%, #000 95%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 9%, #000 91%, transparent), linear-gradient(to bottom, transparent, #000 7%, #000 95%, transparent);
  mask-composite: intersect;
}
body.ecran-login .login .metiers { color: #8e8e93; margin: 0 0 28px; }
body.ecran-login .login input { background: #1c1c1e; color: #fff; box-shadow: none; }
body.ecran-login .login input::placeholder { color: #8e8e93; }
body.ecran-login .login .btn { background: #f5a41c; color: #111; box-shadow: 0 8px 24px rgba(245, 164, 28, .25); }
body.ecran-login .err { color: #ff6b61; }

/* Adresse : suggestions sous le champ, et liens Google Maps dans la fiche du contrat */
.sugg { border-top: .5px solid var(--line); padding: 4px 8px 8px; }
.sugg button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 8px; border-radius: 10px; font: inherit; color: var(--text); cursor: pointer; }
.sugg button:active, .sugg button:hover { background: var(--fill); }
.sugg button b { display: block; font-weight: 600; font-size: 16px; }
.sugg button span { display: block; font-size: 13px; color: var(--muted); }
.sugg .src { font-size: 11px; color: var(--muted); padding: 4px 8px 0; }
.adresse-carte { margin: -8px 4px 16px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; color: var(--muted); }
.adresse-carte div { display: flex; gap: 8px; flex-wrap: wrap; }
.adresse-carte a { font-family: var(--titre); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; color: var(--text); background: var(--card); box-shadow: var(--ombre); border-radius: 10px; padding: 9px 14px; }

/* GPS et approbation */
.alerte, .sub.alerte, .row .val small.alerte { color: var(--red); }
.row .val small.ok { color: var(--green); }
.appro { background: color-mix(in srgb, var(--green) 14%, var(--card)); color: var(--green); border-radius: 14px; padding: 12px 16px; margin: 0 0 16px; font-weight: 600; font-size: 15px; box-shadow: var(--ombre); }
.appro.rouge { background: color-mix(in srgb, var(--red) 12%, var(--card)); color: var(--red); }
.appro.gris { background: var(--card); color: var(--muted); font-weight: 400; }

/* Clients, soumissions et factures */
a.marque { display: inline-block; text-decoration: none; }
.badge.vert { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.badge.rouge { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.badge.bleu { background: var(--accent-soft); color: var(--text); }
.row .sub .badge { font-size: 11px; padding: 1px 6px; margin-right: 2px; }
.stats.argent b { font-size: 15px; }
.seg.large button { flex: 1; padding: 9px; font-size: 15px; }
.lien { font-size: 14px; font-weight: 600; color: var(--accent); flex: none; }
.titre-doc { margin: -8px 4px 16px; color: var(--muted); font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.desc b { white-space: pre-wrap !important; }
.totaux .row { min-height: 46px; font-variant-numeric: tabular-nums; }
.row.total { font-family: var(--titre); font-weight: 700; font-size: 19px; }
.ligne-doc { margin-bottom: 10px; }
.ligne-doc .field { align-items: flex-start; }
.ligne-doc .field textarea { font-weight: 500; }
.ligne-doc .x { border: 0; background: none; color: var(--muted); font-size: 24px; line-height: 1; padding: 8px 0 8px 8px; }
.chiffres { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; padding: 0 16px 12px; }
.chiffres label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.chiffres input { border: 0; background: var(--fill); border-radius: 10px; padding: 9px 10px; font-size: 17px; outline: none; width: 100%; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.chiffres .montant { grid-column: 1 / -1; text-align: right; font-family: var(--titre); font-weight: 700; min-height: 0; }
.chiffres .montant:empty { display: none; }
#fr .field label { width: 120px; }
#fr .field textarea { text-align: left; }
#fr .field select { font-size: 16px; }

/* Structura Pro : accueil des outils */
.tuiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tuile { background: var(--card); border-radius: 16px; box-shadow: var(--ombre); padding: 16px; text-decoration: none; color: inherit; display: flex; flex-direction: column; min-height: 118px; transition: transform .08s; }
.tuile:active { transform: scale(.97); }
.tuile svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-bottom: auto; }
.tuile b { font-family: var(--titre); text-transform: uppercase; letter-spacing: .06em; font-size: 15px; margin-top: 14px; }
.tuile span { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tuile.vedette { background: #f5a41c; color: #111; }
.tuile.vedette span { color: rgba(17, 17, 17, .65); }
.tuile.off { opacity: .45; box-shadow: none; border: 1.5px dashed var(--line); background: none; }
#tabs a span { white-space: nowrap; }

/* ================= Habillage Structura Pro : marine et cuivre ================= */
:root {
  --bg: #f2efea; --card: #ffffff; --text: #14203a; --muted: #687188;
  --line: rgba(20, 32, 58, .12); --fill: rgba(20, 32, 58, .06);
  --accent: #14203a; --on-accent: #ffffff; --accent-soft: rgba(167, 101, 58, .14);
  --cuivre: #a7653a; --cuivre-texte: #94552c; --cuivre-clair: #d9a273;
  --marine: #14203a; --marine-2: #22365c;
  --green: #1d8a4e; --red: #c8341f;
  --titre: Montserrat, "Avenir Next", system-ui, sans-serif;
  --ombre: 0 1px 2px rgba(20, 32, 58, .06), 0 10px 28px rgba(20, 32, 58, .08);
  --bandeau: linear-gradient(135deg, #14203a, #22365c);
  --tabbar: rgba(255, 255, 255, .92);
  --graph: #a7653a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1524; --card: #152036; --text: #eef1f6; --muted: #8e9ab0;
    --line: rgba(142, 154, 176, .2); --fill: rgba(142, 154, 176, .14);
    --accent: #d9a273; --on-accent: #0d1524; --accent-soft: rgba(217, 162, 115, .16);
    --cuivre: #c97a45; --cuivre-texte: #d9a273;
    --green: #4cc38a; --red: #ff6b5b;
    --ombre: 0 0 0 1px rgba(142, 154, 176, .12);
    --bandeau: linear-gradient(135deg, #1b2b4a, #152036);
    --tabbar: rgba(13, 21, 36, .92);
    --graph: #c97a45;
  }
}
body { background-image: none; }
h1 { font-family: var(--titre); font-weight: 800; letter-spacing: .01em; }
h2 { font-family: var(--titre); color: var(--cuivre-texte); }
.marque { font-family: var(--titre); color: var(--cuivre-texte); }
.bandeau { background: var(--bandeau); border-bottom: 2px solid var(--cuivre-clair); }
.bandeau .nom { font-family: var(--titre); }
.bandeau .app { color: var(--cuivre-clair); opacity: 1; }
.stats { background: linear-gradient(135deg, #14203a, #22365c); color: #fff; }
.stats span { color: var(--cuivre-clair); opacity: 1; }
@media (prefers-color-scheme: dark) { .stats { background: linear-gradient(135deg, #1f3256, #182641); box-shadow: 0 0 0 1px rgba(217, 162, 115, .18); } }
.btn, .now, .mini-btn, #tabs a, .tuile b, .row .val, .stats b { font-family: var(--titre); }
.etape.fait .pt { background: var(--cuivre); border-color: var(--cuivre); }
#tabs a.on { color: var(--cuivre-texte); }
#tabs a.on::before { background: var(--cuivre); }
.tuile.vedette { background: linear-gradient(135deg, #b8743f, #d9a273); color: #14203a; }
.tuile.vedette span { color: rgba(20, 32, 58, .7); }
.seg button.on { color: var(--text); }

/* Logo */
.logo-structura { display: flex; flex-direction: column; align-items: center; color: var(--cuivre-clair); }
.logo-structura .symbole { width: 150px; height: auto; }
.logo-structura .mot { text-align: center; font-family: var(--titre); text-transform: uppercase; line-height: 1.1; margin-top: 6px; }
.logo-structura .mot b { display: block; font-size: 34px; font-weight: 600; letter-spacing: .12em; }
.logo-structura .mot span { font-size: 19px; font-weight: 600; letter-spacing: .32em; margin-right: -.32em; }

/* Connexion : fond marine */
body.ecran-login { background: radial-gradient(120% 80% at 50% 0%, #22365c 0%, #101a2c 55%, #0b1220 100%); }
.login .marque-app { margin-bottom: 4px; }
.login .marque-app svg { width: 150px; height: auto; border-radius: 0; box-shadow: none; }
body.ecran-login .login .metiers { font-family: var(--titre); color: #d9a273; opacity: .8; letter-spacing: .2em; font-size: 10.5px; margin: 10px 0 30px; }
body.ecran-login .login input { background: rgba(255, 255, 255, .07); box-shadow: inset 0 0 0 1px rgba(217, 162, 115, .25); }
body.ecran-login .login .btn { background: linear-gradient(135deg, #c27d47, #d9a273); color: #14203a; box-shadow: 0 10px 28px rgba(217, 162, 115, .25); }

/* Tableau de bord */
.titre-tableau { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; margin: 4px 4px 16px; }
.titre-tableau h1 { margin: 0; }
.titre-tableau span { color: var(--muted); font-size: 14px; }
.titre-tableau span::first-letter { text-transform: uppercase; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border-radius: 18px; box-shadow: var(--ombre); padding: 14px 14px 12px; text-decoration: none; color: inherit; display: flex; flex-direction: column; min-width: 0; }
.kpi .t { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.kpi b { font-family: var(--titre); font-size: 24px; font-weight: 700; margin: 4px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: auto; padding-top: 6px; }
.kpi:first-child { background: linear-gradient(135deg, #14203a, #22365c); color: #fff; }
.kpi:first-child .t, .kpi:first-child .s { color: #d9a273; }
.kpi:first-child { --graph: #d9a273; }
.courbe { position: relative; height: 36px; }
.courbe svg { width: 100%; height: 100%; display: block; overflow: visible; }
.courbe .ligne { fill: none; stroke: var(--graph); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.courbe .aire { fill: var(--graph); opacity: .16; }
.courbe .barre { fill: var(--graph); opacity: .55; }
.courbe .barre.fin { opacity: 1; }
.courbe i { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--graph); box-shadow: 0 0 0 2px var(--card); }
.kpi:first-child .courbe i { box-shadow: 0 0 0 2px #1b2b4a; }
.pastille { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--fill); color: var(--muted); margin-top: 5px; }
.pastille.vert { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.pastille.orange { background: var(--accent-soft); color: var(--cuivre-texte); }
.deux-col section { min-width: 0; }

/* Menu de côté : caché sur téléphone */
#tabs .cote { display: none; }

/* ================= Tablette et ordinateur : menu de côté ================= */
@media (min-width: 900px) {
  body { padding: 0 0 0 250px; }
  body.no-tabs { padding-left: 0; }
  #tabs {
    top: 0; bottom: 0; right: auto; width: 250px; flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 4px;
    padding: 28px 16px; border-top: 0; background: linear-gradient(180deg, #14203a, #0f192d); -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  #tabs .cote { display: block; margin: 0 0 30px; }
  #tabs .cote .symbole { width: 96px; height: auto; stroke-width: 1.6; }
  #tabs .cote .mot b { font-size: 22px; }
  #tabs .cote .mot span { font-size: 13px; }
  #tabs a { flex: none; flex-direction: row; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; font-size: 13px; letter-spacing: .06em; color: rgba(255, 255, 255, .62); }
  #tabs a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
  #tabs a.on { background: rgba(217, 162, 115, .14); color: #d9a273; }
  #tabs a.on::before { display: none; }
  #tabs svg { width: 22px; height: 22px; }
  .page { max-width: 760px; padding: 28px 32px 56px; }
  .page.tableau { max-width: 1180px; }
  .bandeau { margin: 0 0 24px; border-radius: 20px; padding: 20px 24px; }
  .kpis { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .kpi { padding: 18px 18px 14px; }
  .kpi b { font-size: 28px; }
  .courbe { height: 44px; }
  .deux-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .tuiles { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  #toast { bottom: 32px; margin-left: 125px; }
  .sheet-bg { padding-left: 250px; }
}

/* Finitions haut de gamme : coins très arrondis, bordure fine semi-transparente, léger reflet en mode foncé */
.group, .kpi, .tuile, .semaine, .filtre { border-radius: 22px; }
.stats { border-radius: 22px; }
.btn { border-radius: 16px; }
.group, .kpi, .tuile:not(.off), .semaine, .filtre { border: 1px solid rgba(20, 32, 58, .06); }
@media (prefers-color-scheme: dark) {
  .group, .kpi, .tuile:not(.off), .semaine, .filtre {
    border: 1px solid rgba(217, 162, 115, .14);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, 0) 60%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
  .tuile.vedette { background-image: linear-gradient(135deg, #b8743f, #d9a273); }
  .kpi:first-child { background-image: linear-gradient(135deg, #22365c, #182641); border-color: rgba(217, 162, 115, .3); }
  #tabs { border-top: 1px solid rgba(217, 162, 115, .14); }
}

/* Catalogue de produits et modèles */
.boutons-lignes { display: flex; gap: 8px; flex-wrap: wrap; margin: 2px 4px 0; }
.liste-cat { max-height: 52vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.cat-titre { font-family: var(--titre); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--cuivre-texte); padding: 14px 16px 4px; }
.sheet .liste-cat .row { justify-content: flex-start; font-size: 17px; color: var(--text); min-height: 54px; text-align: left; }
.row.choix.on { background: var(--accent-soft); }
.row.choix.on b::before { content: "✓ "; color: var(--cuivre-texte); }

/* Fiche d'une soumission : les longues descriptions sont limitées à 4 lignes à l'écran (complètes dans le PDF) */
.doc-lignes .desc:not(:has(b)), .doc-lignes .clause { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.sheet #ff-apercu b { display: inline; font-size: inherit; margin: 0; }

/* Calculatrice de quantités */
.sheet.calc { max-height: 100vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet.calc .row { justify-content: flex-start; font-size: 17px; color: var(--text); min-height: 50px; }
.sheet.calc .row .val { margin-left: auto; }
.sheet.calc .chiffres { padding-top: 10px; }
.chiffres.trois { grid-template-columns: 1fr 1fr 1fr; padding: 6px 0 0; }
.zone { position: relative; padding: 10px 44px 6px 16px; border-top: .5px solid var(--line); }
.zone .nom { width: 100%; border: 0; background: none; font-size: 16px; font-weight: 600; outline: none; padding: 4px 0; color: var(--text); }
.zone .aire { align-self: end; text-align: right; font-family: var(--titre); font-weight: 700; padding-bottom: 10px; font-size: 15px; }
.zone .x { position: absolute; top: 8px; right: 6px; border: 0; background: none; color: var(--muted); font-size: 24px; padding: 6px 10px; }
.field.appliquer label { width: auto; flex: 1; min-width: 0; font-size: 15px; }
.field.appliquer label span { display: block; font-size: 12px; color: var(--muted); }
.field.appliquer select { flex: none; max-width: 52%; font-size: 15px; direction: ltr; text-align: right; }
.sheet.calc .row.cancel, .sheet.calc [data-act=fermer] { justify-content: center; }
.sheet.calc .chiffres label { justify-content: flex-end; }

/* Suivi des paiements d'une soumission */
.paiement-suivi { background: var(--card); border-radius: 22px; box-shadow: var(--ombre); border: 1px solid rgba(20, 32, 58, .06); padding: 16px 18px 14px; margin-bottom: 10px; }
.paiement-suivi .t { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.paiement-suivi .t span { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.paiement-suivi b { font-family: var(--titre); font-size: 20px; }
.paiement-suivi b small { font-size: 13px; color: var(--muted); font-weight: 500; }
.paiement-suivi .barre { height: 8px; border-radius: 4px; background: var(--fill); margin: 10px 0 8px; overflow: hidden; }
.paiement-suivi .barre i { display: block; height: 100%; border-radius: 4px; background: var(--green); }
.paiement-suivi .s { font-size: 13px; color: var(--muted); }
.btn.ghost.alerte { color: var(--red); }
/* Montants des cartes du tableau de bord : lisibles en entier sur téléphone */
@media (max-width: 899px) { .kpi b { font-size: 20px; text-overflow: clip; } }

/* Horaire des équipes */
.prevu { display: block; text-decoration: none; color: var(--text); background: var(--accent-soft); border-radius: 16px; padding: 12px 16px; margin: -4px 0 14px; font-size: 15px; }
.sheet.affect { max-height: 100vh; overflow-y: auto; }
.sheet .heures { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.sheet .heures span { color: var(--muted); }
.sheet .heures input[type=time] { min-width: 96px; }
.sheet .row.case-emp { justify-content: flex-start; font-size: 17px; color: var(--text); gap: 12px; min-height: 50px; }
.sheet .row.case-emp input { width: 22px; height: 22px; accent-color: var(--cuivre); flex: none; }
.sheet .row.case-emp small { margin-left: auto; color: var(--cuivre-texte); font-size: 12px; }
h2.aujourdhui { color: var(--text); }
.carte-aff { margin-bottom: 10px; }
.carte-aff .sub.note { white-space: normal; }

/* Photos de chantier */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photos button { padding: 0; border: 0; background: var(--fill); border-radius: 12px; overflow: hidden; aspect-ratio: 1; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (min-width: 900px) { .photos { grid-template-columns: repeat(5, 1fr); gap: 10px; } }
.photo-bg { background: rgba(0, 0, 0, .82); align-items: flex-start; overflow-y: auto; }
.photo-grande img { width: 100%; max-height: 62vh; object-fit: contain; border-radius: 14px; margin-bottom: 8px; display: block; background: #000; }
.lien-h2 { color: inherit; text-decoration: none; }
.choix-photos button { position: relative; opacity: .55; }
.choix-photos button.choisie { opacity: 1; box-shadow: 0 0 0 3px var(--cuivre); }
.choix-photos button.choisie::after { content: "✓"; position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--cuivre); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.sheet a.row { text-decoration: none; }
.sheet.liens .row { justify-content: center; color: var(--accent); }

/* Bouton du compte (se déconnecter) en haut à droite du bandeau */
.compte-btn { margin-left: auto; flex: none; width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(217, 162, 115, .45); background: rgba(255, 255, 255, .08); color: #d9a273; display: grid; place-items: center; padding: 0; }
.compte-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.bandeau.clair .compte-btn { margin-left: 10px; background: #14203a; color: #d9a273; }
.bandeau.clair .app { margin-left: auto; }
#tabs .cote-bas { display: none; }
@media (min-width: 900px) {
  #tabs .cote-bas { display: flex; align-items: center; gap: 14px; margin-top: auto; padding: 12px 14px; border: 0; border-radius: 12px; background: none; color: rgba(255, 255, 255, .55); font-family: var(--titre); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
  #tabs .cote-bas:hover { background: rgba(255, 255, 255, .05); color: #fff; }
}

/* Mode hors-ligne : pastille en haut de l'écran, envois en attente */
#horsligne {
  position: fixed; top: calc(6px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 25;
  background: #3a3f4a; color: #fff; border: 0; border-radius: 16px; padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2); white-space: nowrap;
}
#horsligne.erreur { background: var(--red); }
#horsligne[hidden] { display: none; }
.attente { color: var(--muted); font-weight: 600; }
.sheet .row.envoi { justify-content: space-between; font-size: 15px; color: var(--text); min-height: 52px; text-align: left; gap: 10px; }

/* Tableau de bord : ventes par mois, comptes à recevoir, rentabilité */
.carte { background: var(--card); border-radius: 18px; box-shadow: var(--ombre); padding: 14px; }
.carte .t, .carte-tete .t { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: block; }
.carte .s { font-size: 12px; color: var(--muted); display: block; }
.chiffres { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.chiffres b, .carte-tete b { display: block; font-family: var(--titre); font-size: 19px; font-weight: 700; margin: 3px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.carte-tete b { font-size: 24px; }
.carte-tete { margin-bottom: 8px; }
.graph-mois { margin-top: 12px; }
.graph-mois svg { width: 100%; height: auto; display: block; overflow: visible; }
.graph-mois .base { stroke: var(--line); stroke-width: 1; }
.graph-mois .barre { fill: var(--graph); opacity: .45; }
.graph-mois .fin .barre { opacity: 1; }
.graph-mois g:hover .barre { opacity: .8; }
.graph-mois .cible { fill: transparent; }
.graph-mois text { font-size: 10px; text-anchor: middle; fill: var(--muted); font-family: inherit; }
.graph-mois .val { fill: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.note-graph { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.tranche { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 9px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; font-size: 14px; }
.tranche .m { font-weight: 600; font-variant-numeric: tabular-nums; }
.tranche .piste { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.tranche .piste i { display: block; height: 100%; border-radius: 3px; background: var(--graph); }
.bon { color: var(--green); }
.moyen { color: var(--cuivre-texte); }
.val small .alerte, .val small .bon, .val small .moyen { font-weight: 600; }
@media (max-width: 420px) { .chiffres b { font-size: 16px; } }

/* Lien vers le guide sous le formulaire de connexion */
.login .lien-guide { margin-top: 22px; font-size: 14px; color: #d9a273; text-decoration: none; }
.login .lien-guide:hover { text-decoration: underline; }

/* Rapport mensuel CCQ : choix du mois */
.mois-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card); border-radius: 12px; padding: 6px; margin-top: 4px; box-shadow: var(--ombre); }
.mois-nav b { font-family: var(--titre); font-size: 17px; text-transform: capitalize; }
.mois-nav button { border: 0; background: var(--fill); color: var(--text); width: 40px; height: 36px; border-radius: 9px; font-size: 22px; line-height: 1; cursor: pointer; }
.duo a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.sheet .msg.aide { text-align: left; font-size: 13px; }

/* Acceptation des conditions et avis aux employés */
.page.conditions { max-width: 560px; margin: 0 auto; }
.page.conditions .marque-app.petit { margin: 10px 0 6px; }
.page.conditions .marque-app.petit .logo-structura .symbole { width: 54px; height: 62px; }
.page.conditions .marque-app.petit .mot b { font-size: 20px; }
.resume { margin: 0; padding: 14px 16px 14px 34px; display: grid; gap: 10px; font-size: 15px; line-height: 1.45; }
.resume li::marker { color: var(--cuivre); }
.accepte { display: flex; gap: 12px; align-items: flex-start; margin: 18px 4px 14px; font-size: 15px; line-height: 1.4; cursor: pointer; }
.accepte input { width: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--cuivre); }
.page.conditions .btn { width: 100%; }
.page.conditions .btn:disabled { opacity: .45; }
.page.conditions .btn.ghost { margin-top: 8px; }
.login .liens-legaux { margin-top: 14px; font-size: 12px; color: #8e8e93; }
.login .liens-legaux a { color: #aab3c5; text-decoration: none; }
.page.conditions a:not(.row):not(.btn) { color: var(--cuivre-clair, #d9a273); }

/* Dépenses d'un contrat : case « taxes incluses », aperçu du reçu ; carte de marge sur toute la largeur */
.row.case { gap: 12px; align-items: flex-start; cursor: pointer; }
.row.case input { width: 22px; height: 22px; flex: none; margin-top: 2px; accent-color: var(--cuivre, #a7653a); }
.recu-apercu { display: block; max-width: 100%; max-height: 260px; margin: 10px auto; border-radius: 8px; object-fit: contain; }
.kpi.large { grid-column: 1 / -1; }
.sheet .row.case { justify-content: flex-start; font-size: 15px; color: var(--text); text-align: left; min-height: 0; padding-top: 12px; padding-bottom: 12px; }
.row .etats { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--muted); }
.row .etats .pastille { margin-top: 0; }
