/*
 * FEUILLE DE STYLE DE GRESILIO.
 *
 * Mise en page reprise de la démo de référence : barre latérale d'étapes à gauche (en haut sur téléphone),
 * panneau de travail à droite. Seul l'habillage change : couleurs, typographie et logo de la charte Gresilio.
 *
 * CHARTE (section 6 du cahier des charges) :
 *   bleu marine #143A56 → couleur principale : texte, boutons ;
 *   cuivre      #B76932 → accents et illustrations UNIQUEMENT (jamais pour du texte courant ni des boutons) ;
 *   fond clair  #F4F7F8 ;
 *   typographie d'interface : Inter, avec repli sur la police du système.
 *
 * Tout le style est ici : la politique de sécurité du site interdit les styles écrits dans les pages
 * (attribut style="…"). Chaque ancien style en ligne de la démo est devenu une classe (.between, .muted…).
 */

/* Police Inter servie par notre propre serveur : aucun appel à un service tiers (donc aucun traceur). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/polices/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/polices/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --panel: #ffffff;
  --ink: #143a56;
  --muted: #55697a;
  --line: #d5dee4;
  --accent: #143a56;
  --accent-ink: #ffffff;
  --accent-soft: #e3ebf0;
  --cuivre: #b76932;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --warn: #8a5208;
  --warn-soft: #fbf0dc;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --paper: #ffffff;
  --paper-ink: #14232c;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Chiffres : Inter avec chiffres de largeur fixe, pour que les colonnes de montants s'alignent. */
  --f-num: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--f-body); text-wrap: balance; margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
a { color: var(--accent); }

/* ---------- Structure : barre latérale + panneau de travail ---------- */
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100%; }
aside { background: var(--panel); border-right: 1px solid var(--line); padding-block: 20px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: 16px; display: flex; flex-direction: column; gap: 16px; }
.brand { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 2px solid var(--cuivre); }
.brand img { width: 132px; height: auto; display: block; }
.brand small { font-weight: 600; font-size: 0.82rem; color: var(--ink); overflow-wrap: anywhere; }
/* Logo de l'entreprise connectée, au-dessus de son nom. Tant qu'aucun logo n'est déposé, l'image porte l'attribut
   « hidden » : la règle générale « [hidden] » plus bas la garde cachée, malgré le « display: block » de « .brand img ». */
.marque-entreprise { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.brand img.logo-entreprise { width: auto; max-width: 132px; max-height: 56px; object-fit: contain; }
/* Logo en haut du dossier chantier (écran et impression). */
.entete-chantier { margin-bottom: 12px; }
.logo-chantier { display: block; max-height: 72px; max-width: 240px; }
.compte { font-size: 0.82rem; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.compte b { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.compte .row { gap: 6px; }
nav { display: flex; flex-direction: column; gap: 4px; }
nav .grp { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 10px 0 2px; }
nav button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); font-weight: 500; }
nav button .n { font-family: var(--f-num); font-variant-numeric: tabular-nums; font-size: 0.8rem; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); color: var(--muted); flex: none; }
nav button:hover { background: var(--accent-soft); }
/* Écran actif : fond bleu marine, liseré cuivre (accent). */
nav button.on { background: var(--accent); color: var(--accent-ink); box-shadow: inset 4px 0 0 var(--cuivre); }
nav button.on .n { border-color: transparent; background: rgba(255, 255, 255, 0.22); color: inherit; }
nav button:disabled { opacity: 0.4; cursor: not-allowed; }
nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cur { font-size: 0.85rem; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.cur b { font-family: var(--f-num); font-variant-numeric: tabular-nums; font-weight: 600; }
.pied { margin-top: auto; font-size: 0.72rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.pied a { color: var(--muted); }
main { padding-block: 24px 60px; padding-left: 24px; padding-right: max(24px, env(safe-area-inset-right, 0px)); min-width: 0; }
.wrap { max-width: 1000px; display: flex; flex-direction: column; gap: 20px; }
.head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.head p { margin: 4px 0 0; color: var(--muted); max-width: 65ch; }
/* Petit trait cuivre sous le titre de l'écran : accent décoratif de la charte. */
.head h1::after { content: ""; display: block; width: 40px; height: 3px; border-radius: 2px; background: var(--cuivre); margin-top: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }

/* ---------- Champs et boutons ---------- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 0.95rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { min-height: 90px; font-family: var(--f-mono); font-size: 0.82rem; }
textarea.texte { font-family: var(--f-body); font-size: 0.92rem; }
input[type="file"] { padding: 6px; }
/* Case à cocher suivie de son texte, sur une ligne (écran d'acceptation des conditions) : sans cette règle, la case
   prendrait toute la largeur comme les autres champs. */
label.case { flex-direction: row; align-items: flex-start; gap: 10px; font-size: 0.9rem; color: var(--ink); }
label.case input { width: auto; flex: none; margin-top: 3px; }
.btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 8px; font-weight: 600; font-size: 0.9rem; background: var(--accent); color: var(--accent-ink); }
.btn.sec { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.btn.petit { padding: 5px 10px; font-size: 0.8rem; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.note { font-size: 0.85rem; color: var(--ink); border-left: 3px solid var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: 0 8px 8px 0; }
.note.info { border-color: var(--accent); background: var(--accent-soft); }
.note.bad { border-color: var(--bad); background: var(--bad-soft); }
/* Mention obligatoire sur la puissance calculée. */
.mention { font-size: 0.8rem; color: var(--muted); font-style: italic; margin: 0; }

/* ---------- Tableaux ---------- */
.tbl { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-family: var(--f-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
.mono { font-family: var(--f-num); font-variant-numeric: tabular-nums; }

/* ---------- Visite ---------- */
.piece { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--panel); }
.piece-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.power { display: flex; flex-wrap: wrap; gap: 18px; align-items: baseline; background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; }
.power .big { font-family: var(--f-num); font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 600; color: var(--accent); }
.power span { font-size: 0.82rem; color: var(--muted); }
.diff { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.diff button { all: unset; cursor: pointer; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.diff button b { font-family: var(--f-num); font-size: 1.3rem; }
.diff button span { font-size: 0.78rem; color: var(--muted); }
.diff button.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.diff button:focus-visible { outline: 2px solid var(--accent); }

/* ---------- Chiffrage ---------- */
.checks { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; }
.checks div { display: flex; gap: 10px; align-items: baseline; }
.props { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.tot { display: flex; justify-content: space-between; font-family: var(--f-num); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.tot.ttc { font-size: 1.1rem; font-weight: 600; border-top: 1px solid var(--line); padding-top: 6px; }

/* ---------- Divers ---------- */
.empty { color: var(--muted); text-align: center; padding: 28px; }
.timeline { display: flex; flex-direction: column; gap: 8px; font-size: 0.88rem; }
.timeline div { display: flex; gap: 12px; }
.timeline time { font-family: var(--f-num); font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; font-size: 0.8rem; }
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: 0.9rem; z-index: 20; max-width: min(92vw, 640px); text-align: center; }
.sms { font-family: var(--f-mono); font-size: 0.82rem; background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.lien { font-family: var(--f-mono); font-size: 0.8rem; background: var(--bg); border: 1px dashed var(--accent); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; }
.sub { margin: 0; color: var(--muted); font-size: 0.88rem; }
.next { font-size: 0.82rem; color: var(--muted); }
.next.late { color: var(--bad); font-weight: 600; }
[hidden] { display: none !important; }

/* ---------- Agenda ---------- */
.daytabs { display: flex; gap: 6px; flex-wrap: wrap; }
.daytabs button { all: unset; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.daytabs button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.daytabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Le nombre de colonnes dépend du nombre de techniciens : il est posé par le script (propriété grid-template-columns). */
.agenda-wrap { overflow-x: auto; }
.agenda { display: grid; grid-template-columns: 62px repeat(3, minmax(96px, 1fr)); gap: 6px; font-size: 0.78rem; }
.agenda .hd.mono { white-space: nowrap; font-size: 0.74rem; }
.agenda .hd { color: var(--muted); font-weight: 600; align-self: center; text-align: center; overflow: hidden; text-overflow: ellipsis; }
.agenda .cell { border-radius: 8px; padding: 9px 4px; text-align: center; border: 1px solid var(--line); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda button.cell { all: unset; box-sizing: border-box; cursor: pointer; display: block; width: 100%; border: 1px dashed var(--accent); border-radius: 8px; padding: 9px 4px; text-align: center; color: var(--accent); font-weight: 600; }
.agenda button.cell:hover { background: var(--accent-soft); }
.agenda button.cell:focus-visible { outline: 2px solid var(--accent); }
.agenda .busy { background: var(--bg); color: var(--muted); }
.agenda .sel { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }

/* ---------- Photos ---------- */
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.gal.big { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.phc { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.phc .zoom { all: unset; cursor: zoom-in; display: block; aspect-ratio: 4/3; background: var(--bg); max-width: 100%; }
.phc .zoom:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.phc img { width: 100%; height: 100%; object-fit: cover; display: block; }
.phc figcaption { padding: 8px 10px; font-size: 0.78rem; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.phc figcaption b { font-size: 0.8rem; }
.phc figcaption small { color: var(--muted); }
.lnk { all: unset; cursor: pointer; color: var(--bad); font-size: 0.75rem; font-weight: 600; margin-top: 4px; align-self: flex-start; }
.lnk:focus-visible { outline: 2px solid var(--accent); }
.lb { position: fixed; inset: 0; background: rgba(8, 14, 18, 0.9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 30; padding: 20px; cursor: zoom-out; }
.lb img { max-width: 100%; max-height: 78vh; border-radius: 6px; }
.lb p { color: #fff; margin: 0; text-align: center; max-width: 70ch; }
.kv { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 0.9rem; }
.kv dt { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.kv dd { margin: 0; min-width: 0; }
.printonly { display: none; }
.logo-apercu { max-height: 64px; max-width: 220px; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: #fff; }

/* ---------- Pages simples : connexion, mot de passe, pages légales ---------- */
.page-simple { display: grid; place-items: start center; padding: 6vh 16px 40px; }
.page-simple main { padding: 0; width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 18px; }
.page-simple.large main { max-width: 760px; }
.page-simple .logo { width: 150px; height: auto; align-self: center; }
.page-simple .card { border-top: 3px solid var(--cuivre); }
.page-simple form { display: flex; flex-direction: column; gap: 14px; }
.page-simple .btn { justify-content: center; }
.page-simple footer { font-size: 0.78rem; color: var(--muted); text-align: center; display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; }
.page-simple footer a { color: var(--muted); }
.legal h2 { margin-top: 10px; }
.legal p, .legal li { color: var(--ink); }
.a-completer { background: var(--warn-soft); color: var(--warn); font-weight: 600; padding: 0 4px; border-radius: 4px; }

/* ---------- Administration ---------- */
.admin { max-width: 1040px; margin: 0 auto; padding: 24px 16px 60px; display: flex; flex-direction: column; gap: 20px; }
.admin header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 2px solid var(--cuivre); }
.admin header img { width: 120px; height: auto; }
/* Pied de page légal de la page d'administration (même allure que celui des pages simples). */
.pied-legal { font-size: 0.78rem; color: var(--muted); text-align: center; display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; }
.pied-legal a { color: var(--muted); }
.etape { border: 1px solid var(--bad); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--bad-soft); }

/* ---------- Téléphone et tablette : la barre latérale passe en haut ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  aside { border-right: 0; border-bottom: 1px solid var(--line); padding-right: max(16px, env(safe-area-inset-right, 0px)); gap: 10px; padding-block: 12px; }
  .brand { flex-direction: row; align-items: center; justify-content: space-between; padding-bottom: 10px; }
  .brand img { width: 96px; }
  /* Sur téléphone : le logo de l'entreprise et son nom se rangent à droite, en plus petit. */
  .marque-entreprise { align-items: flex-end; text-align: right; }
  .brand img.logo-entreprise { max-width: 96px; max-height: 40px; }
  .compte { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  nav { flex-direction: row; flex-wrap: wrap; }
  nav .grp { display: none; }
  nav button { padding: 8px 10px; }
  .pied { margin-top: 0; }
  main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px 60px; }
  .diff { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Sur le terrain : zones de saisie et boutons faciles à toucher du doigt. */
  input, select, textarea { font-size: 16px; padding: 10px; }
  .btn { padding: 11px 14px; }
  h1 { font-size: 1.3rem; }
}

/* ---------- Impression (devis, dossier chantier) ---------- */
@media print {
  aside, .noprint, .head, .toast { display: none !important; }
  .app { display: block; }
  main { padding: 0; }
  body { background: #fff; }
  .lb { display: none !important; }
  .printonly { display: block; }
  .card { border: 0; padding: 0; }
  .gal.big { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phc { break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
