* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Arial, sans-serif;
  background: #e8e8e8;
  color: #1a1a1a;
  font-size: 14px;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  height: 480px;
  background-image: url('/static/wp-logo-bg.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
}

/* HEADER */
header {
  background: #1a1a1a;
  color: #fff;
  padding: 0 24px;
  height: 54px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid #333;
}
.header-inner { display: flex; align-items: center; gap: 16px; flex: 1; }
.header-wp { font-size: 17px; font-weight: bold; letter-spacing: 0.5px; color: #fff; }
.header-logo { height: 36px; width: auto; display: block; flex-shrink: 0; }
.header-sub { font-size: 13px; color: #888; }
header { justify-content: space-between; }
.btn-header-icon {
  background: none;
  border: 1px solid #555;
  color: #aaa;
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.btn-header-icon:hover { color: #fff; border-color: #888; }
.btn-nav-active { background: rgba(255,255,255,0.15) !important; color: #fff !important; border-color: #aaa !important; cursor: default !important; }

/* MAIN */
main {
  max-width: 860px;
  margin: 28px auto;
  padding: 0 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* CARD */
.card {
  background: #f4f4f4;
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  padding: 24px;
}
.card h2 {
  font-size: 13px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #555;
  margin-bottom: 18px;
}

/* GRILLE */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.col-2 { grid-column: span 2; }

/* CHAMPS */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label {
  font-size: 11px;
  color: #555;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.field input,
.field textarea,
.field select {
  border: 1px solid #c8c8c8;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: Arial, sans-serif;
  color: #1a1a1a;
  background: #ffffff;
  transition: border-color 0.15s;
  /* 16.08.2026 — le <select> CFC (options assez longues) dépassait du cadre gris
     de la carte sur iPhone : sans largeur explicite, un <select> dans un parent
     flex/grid peut se dimensionner sur son contenu (l'option la plus longue) au
     lieu de la largeur disponible — bug connu Safari iOS. width:100% + min-width:0
     force le respect du conteneur (box-sizing:border-box déjà global en haut du
     fichier, donc la bordure/padding restent bien dans les 100%). */
  width: 100%;
  min-width: 0;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: #22c55e;
  background: #f8fff8;
}

.field select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.field textarea {
  resize: vertical;
  min-height: 70px;
}

/* SECTION HEADER */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h2 { margin-bottom: 0; }

/* BOUTON AJOUTER POSTE */
.btn-add {
  background: #22c55e;
  color: #000;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  font-family: Arial, sans-serif;
}
.btn-add:hover { background: #16a34a; }

/* POSTE */
.poste {
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 12px;
  background: #efefef;
  position: relative;
}
.poste-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.poste-num {
  font-size: 11px;
  font-weight: bold;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn-remove {
  background: none;
  border: 1px solid #c8c8c8;
  color: #aaa;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-remove:hover { border-color: #f87171; color: #f87171; }

.poste-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.btn-insert {
  background: none;
  border: 1px dashed #c0c0c0;
  color: #aaa;
  height: 26px;
  padding: 0 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.btn-insert:hover { border-color: #888; color: #555; background: #e4e4e4; }

.btn-insert-top {
  background: none;
  border: 1px dashed #c0c0c0;
  color: #aaa;
  height: 26px;
  padding: 0 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  width: 100%;
}
.btn-insert-top:hover { border-color: #888; color: #555; background: #e4e4e4; }

.poste-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* LIGNE PRIX */
.prix-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.prix-artisan { flex: 1; }
.prix-marge { width: 120px; }
.prix-resultat {
  font-size: 13px;
  color: #555;
  padding-bottom: 8px;
  white-space: nowrap;
  min-width: 140px;
}
.prix-resultat strong { color: #1a1a1a; }

/* EN COURS */
.en-cours-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.en-cours-row input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.en-cours-row label { font-size: 13px; color: #555; cursor: pointer; }

/* RÉSUMÉ FINANCIER */
.resume-fin {
  margin-top: 24px;
  border-top: 1px solid #cccccc;
  padding-top: 20px;
}
.recap-table {
  margin-top: 16px;
  max-width: 400px;
  margin-left: auto;
}
.recap-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #d0d0d0;
  font-size: 13px;
  color: #555;
}
.recap-row span:last-child { color: #1a1a1a; font-weight: bold; }
.recap-row.bold { font-weight: bold; }
.recap-row.highlight {
  background: #f0f0f0;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #c8c8c8;
  margin-top: 4px;
  font-size: 15px;
  color: #1a1a1a;
}

.ttc-arr-wrap { display: flex; align-items: center; gap: 6px; }
.ttc-arr-input {
  background: transparent;
  border: none;
  border-bottom: 1px dashed #aaa;
  color: #1a1a1a;
  font-weight: bold;
  font-size: 15px;
  text-align: right;
  width: 140px;
  padding: 2px 4px;
  outline: none;
}
.ttc-arr-input:focus { border-bottom-color: #22c55e; }
.ttc-arr-input.manual { border-bottom-color: #f59e0b; color: #f59e0b; }
.ttc-arr-reset {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
}
.ttc-arr-reset:hover { color: #22c55e; }

/* COLLAPSIBLE */
.collapsible .card-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.collapsible .card-toggle h2 { margin-bottom: 0; }
.toggle-hint { font-size: 11px; color: #666; font-weight: normal; margin-left: 6px; }
.chevron { color: #666; font-size: 12px; transition: transform 0.2s; }
.chevron.open { transform: rotate(180deg); }
.card-body { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }

/* BOUTON GÉNÉRER */
.generate-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 0;
}
.btn-generate {
  background: #22c55e;
  color: #000;
  border: none;
  padding: 11px 28px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: bold;
  font-family: Arial, sans-serif;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s;
}
.btn-generate:hover { background: #16a34a; }
.btn-generate:disabled { background: #c8e6c9; color: #aaa; cursor: not-allowed; }

.gen-status { font-size: 13px; }
.gen-status.loading { color: #888; }
.gen-status.success { color: #22c55e; font-weight: bold; }
.gen-status.error   { color: #f87171; }

/* IMPORT IA */
.ia-badge {
  background: #22c55e;
  color: #000;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 1px;
}
.ia-hint {
  font-size: 13px;
  color: #555;
  margin-bottom: 12px;
}
.drop-zone {
  border: 2px dashed #c0c0c0;
  border-radius: 8px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #eeeeee;
  color: #aaa;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: #888;
  background: #e4e4e4;
  color: #555;
}
.drop-zone.has-files { border-color: #22c55e; background: #e8fff0; color: #16a34a; }
.drop-icon { font-size: 28px; margin-bottom: 6px; }
.drop-label { font-weight: bold; font-size: 14px; }
.drop-sub { font-size: 12px; color: #aaa; margin-top: 4px; }

.files-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f0f0f0;
  border: 1px solid #d0d0d0;
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 12px;
  color: #666;
  max-width: 220px;
}
.file-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}
.file-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #bbb;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.file-chip-remove:hover { color: #f87171; }

.btn-ia {
  background: #22c55e;
  color: #000;
  border: none;
  padding: 10px 22px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  font-family: Arial, sans-serif;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-ia:hover { background: #16a34a; }
.btn-ia:disabled { background: #c8e6c9; color: #aaa; cursor: not-allowed; }

.btn-clear-files {
  background: none;
  border: 1px solid #c8c8c8;
  color: #888;
  padding: 9px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-family: Arial, sans-serif;
  cursor: pointer;
}
.btn-clear-files:hover { border-color: #f87171; color: #f87171; }

/* HISTORIQUE */
.hist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid #d0d0d0;
  border-left: 3px solid transparent;
  font-size: 13px;
  transition: background 0.15s, border-left-color 0.15s;
  cursor: default;
}
.hist-item:hover {
  background: rgba(34,197,94,0.18);
  border-left-color: #22c55e;
}
.hist-num { font-weight: bold; min-width: 60px; color: #1a1a1a; }
.hist-client { flex: 1; padding: 0 12px; color: #555; }
.hist-ttc { font-weight: bold; color: #1a1a1a; min-width: 110px; text-align: right; }
.hist-date { color: #666; margin-left: 12px; min-width: 80px; text-align: right; }
.btn-reload {
  background: none;
  border: 1px solid #c8c8c8;
  color: #888;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: Arial, sans-serif;
  margin-left: 10px;
  white-space: nowrap;
}
.btn-reload:hover { border-color: #888; color: #555; background: #e0e0e0; }

/* ── Barre d'onglets mobile (bas d'écran) — remplace la nav du header sur iPhone,
   demande Claudio 09.08.2026 (débordement de "Chantiers"), option B validée.
   Base cachée ICI (display:none), activée en display:flex dans la media query
   ci-dessous — DOIT rester déclarée AVANT la media query, sinon cette règle
   unconditionnelle (même spécificité, plus tardive dans le fichier) écrase le
   display:flex du mobile et la barre reste invisible malgré le viewport. ──── */
.bottom-tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 190;
  background: #1a1a1a; border-top: 1px solid #333;
  padding: 10px 2px calc(10px + env(safe-area-inset-bottom));
}
.bottom-tabbar .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: #7c7c7c; padding: 4px 0;
}
.bottom-tabbar .tab svg { width: 22px; height: 22px; }
.bottom-tabbar .tab .lbl { font-size: 11px; font-weight: 600; }
.bottom-tabbar .tab.active { color: #3ecf7a; }

@media (max-width: 600px) {
  header { height: auto; min-height: 54px; padding: 8px 12px; flex-wrap: wrap; gap: 4px; }
  /* viewport-fit=cover (09.08.2026, safe-area barre du bas) fait aussi passer le
     contenu sous l'encoche/heure en haut — sans cette compensation, le header
     sticky se colle à top:0 SOUS la barre de statut au lieu d'en dessous. */
  header { padding-top: calc(8px + env(safe-area-inset-top)); }
  .header-inner { gap: 8px; flex-wrap: wrap; }
  .header-wp { font-size: 15px; }
  .header-sub { font-size: 11px; }
  body { overflow-x: hidden; }
  /* Watermark masqué sur mobile (16.08.2026) — à 480px sur un viewport ~390px, les
     traits du logo/texte ressortaient comme des bandes grises derrière le formulaire.
     Une 1ère tentative en réduisant la taille (240px, opacity 0.05) restait visible,
     juste confinée à la carte alors centrée dans le viewport (le fond reste
     position:fixed centré sur l'écran, donc suit le scroll et retombe toujours sur
     ce qui est affiché au milieu) — masqué complètement plutôt que réduit encore. */
  body::before { display: none; }
  main { margin: 12px auto; padding: 0 10px 210px; }
  .grid-2 { grid-template-columns: 1fr; }
  .col-2 { grid-column: span 1; }
  .poste-grid { grid-template-columns: 1fr; }
  .section-header { flex-wrap: wrap; gap: 8px; }
  .btn-add { font-size: 13px; padding: 7px 12px; }
  .prix-row { flex-direction: column; align-items: stretch; }
  .prix-artisan, .prix-marge { width: 100%; }
  .prix-resultat { min-width: auto; white-space: normal; padding-bottom: 0; }
  .hist-item { flex-wrap: wrap; gap: 2px 8px; }
  .hist-client { flex-basis: 100%; padding: 2px 0; }
  .hist-ttc { min-width: auto; }
  .hist-date { min-width: auto; margin-left: 0; }
  .btn-reload { margin-left: auto; margin-top: 4px; }

  /* Nav de pages déplacée dans .bottom-tabbar — masquée du header sur mobile */
  .hnav { display: none !important; }
  .bottom-tabbar { display: flex; }
  /* Doit dépasser la hauteur RÉELLE de .bottom-tabbar (10 haut + ~38 contenu +
     10 base bas + safe-area) sinon le bouton Dicter chevauche le haut de la
     barre (les icônes) en laissant les labels visibles en dessous — bug vécu
     le 09.08.2026 après avoir agrandi icônes/labels sans recalculer ceci. */
  .capture-bar { bottom: calc(62px + env(safe-area-inset-bottom)) !important; }
}

/* ── Barre de capture (Dicter) — commune à toutes les pages ─────────────────── */
.capture-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  display: flex; justify-content: center; padding: 10px 0 16px;
  background: linear-gradient(to top, rgba(232,232,232,0.97) 60%, rgba(232,232,232,0));
  pointer-events: none;
}
.capture-bar-btn {
  pointer-events: auto; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.capture-bar-circle {
  width: 56px; height: 56px; border-radius: 50%; background: #ff2828;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(255,40,40,.45);
}
.capture-bar-circle svg {
  width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.capture-bar-label { font-size: 11px; color: #555; font-weight: bold; }

.capture-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  align-items: flex-end; justify-content: center; z-index: 300;
}
.capture-overlay.open { display: flex; }
.capture-sheet {
  background: #fff; border-radius: 16px 16px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 480px; max-height: 80vh; overflow-y: auto;
}
.capture-sheet h3 { margin: 0 0 14px 0; font-size: 15px; color: #1a1a1a; }
.capture-choice-btn {
  display: block; width: 100%; text-align: left; background: #f4f4f4;
  border: 1px solid #d0d0d0; border-radius: 8px; padding: 14px 16px;
  font-size: 14px; font-weight: bold; color: #1a1a1a; cursor: pointer; margin-bottom: 8px;
}
.capture-choice-btn:hover { border-color: #22c55e; }
.capture-cancel {
  display: block; width: 100%; text-align: center; background: none;
  border: none; padding: 10px; font-size: 13px; color: #888; cursor: pointer; margin-top: 4px;
}
.capture-input-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.capture-input-row input {
  flex: 1; border: 1px solid #d0d0d0; border-radius: 8px; padding: 10px 12px;
  font-size: 14px; color: #1a1a1a; background: #fff;
}
.capture-input-row input:focus { outline: none; border-color: #22c55e; }
.capture-input-row button:not(.mic-btn) {
  border: 1px solid #1a1a1a; background: #1a1a1a; color: #fff; border-radius: 8px;
  padding: 10px 16px; font-size: 13px; font-weight: bold; cursor: pointer; white-space: nowrap;
}
.capture-empty { color: #888; font-size: 13px; padding: 10px 0; text-align: center; }
.capture-error { color: #dc2626; font-size: 13px; padding: 10px 0; text-align: center; }
.capture-result-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #f4f4f4; border: 1px solid #d0d0d0; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px;
}
.capture-result-main { min-width: 0; flex: 1; }
.capture-result-title { font-weight: bold; font-size: 13px; color: #1a1a1a; }
.capture-result-sub { font-size: 12px; color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.capture-btn-small {
  border: 1px solid #d0d0d0; background: #fff; border-radius: 6px; padding: 5px 10px;
  font-size: 12px; font-weight: bold; color: #1a1a1a; text-decoration: none; white-space: nowrap;
}
.capture-field { margin-bottom: 10px; }
.capture-field label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  color: #666; font-weight: bold; margin-bottom: 4px;
}
.capture-field input {
  width: 100%; border: 1px solid #d0d0d0; border-radius: 6px; padding: 8px 10px;
  font-size: 14px; color: #1a1a1a; box-sizing: border-box;
}
.capture-field input:focus { outline: none; border-color: #22c55e; }
.capture-btn-primary {
  background: #1a1a1a; color: #fff; border: none; border-radius: 8px;
  padding: 10px 18px; font-size: 13px; font-weight: bold; cursor: pointer; width: 100%;
}
.capture-btn-primary:hover { background: #333; }

.mic-btn {
  width: 42px; height: 42px; min-width: 42px; border-radius: 50%; border: none;
  background: #ff2828; display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; box-shadow: 0 4px 14px rgba(255,40,40,.4);
  touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.mic-btn:hover { background: #e01f1f; }
.mic-btn svg {
  width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.mic-btn.listening { animation: mic-pulse 1.3s infinite; }
@keyframes mic-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,40,40,.55); }
  70%  { box-shadow: 0 0 0 22px rgba(255,40,40,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,40,40,0); }
}
