/* Kwitt — feuille de style de l'application (PC d'abord). */
:root {
  --marque: #c2410c; --marque-f: #9a3412; --marque-p: #fff4ed;   /* orange « équerre » de Kwitt (logo D, 30/09/2026) */
  --info: #1f5eff; --info-f: #1848c9; --info-p: #eef3ff; --encre: #1d2330; --gris: #5b6270; --gris-c: #8a909c;
  --trait: #e3e6eb; --fond: #f5f6f8; --blanc: #fff; --vert: #0f9d58; --vert-p: #e7f6ee; --rouge: #d93025; --rouge-p: #fdecea;
  --orange: #e37400; --orange-p: #fff3e0; --ombre: 0 1px 2px rgba(20, 25, 40, .06), 0 4px 16px rgba(20, 25, 40, .06);
  --rayon: 10px; --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--police); font-size: 14px; color: var(--encre); background: var(--fond); -webkit-font-smoothing: antialiased; }
a { color: var(--marque); }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); }
.chargement { display: grid; place-items: center; height: 100vh; color: var(--gris-c); font-size: 18px; }

/* ── structure ── */
.coque { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.barre { background: #10152b; color: #cfd5e6; display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
.marque { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: #fff; padding: 4px 8px 18px; letter-spacing: -.02em; }
.marque .logo { width: 28px; height: 28px; display: block; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #cfd5e6; text-decoration: none; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.actif { background: rgba(251, 146, 60, .20); color: #fff; box-shadow: inset 3px 0 0 #fb923c; }
.nav .compteur { margin-left: auto; background: var(--rouge); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; }
.barre .bas { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 12px; font-size: 12.5px; }
.barre .entreprise { color: #fff; font-weight: 600; padding: 0 8px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre .utilisateur { padding: 0 8px 8px; color: #9aa3ba; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre select { width: 100%; background: #1b2240; color: #fff; border: 1px solid #2c3560; border-radius: 6px; padding: 5px; margin-bottom: 8px; }
.principal-zone { min-width: 0; }
.entete { display: flex; align-items: center; gap: 12px; padding: 18px 28px; background: var(--blanc); border-bottom: 1px solid var(--trait); position: sticky; top: 0; z-index: 5; }
.entete .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.contenu { padding: 22px 28px 60px; }
.bandeau { padding: 10px 28px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.bandeau.alerte { background: var(--orange-p); color: #7a4100; }
.bandeau.dev { background: #fff7cc; color: #6b5400; }
.bandeau button { margin-left: auto; }

/* ── boutons ── */
.btn { font: inherit; font-weight: 600; border: 1px solid var(--trait); background: var(--blanc); color: var(--encre); border-radius: 8px; padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.btn:hover { border-color: #c9ced8; background: #fafbfc; }
.btn.principal { background: var(--marque); border-color: var(--marque); color: #fff; }
.btn.principal:hover { background: var(--marque-f); }
.btn.danger { color: var(--rouge); border-color: #f1c5c1; }
.btn.danger:hover { background: var(--rouge-p); }
.btn.petit { padding: 5px 10px; font-size: 12.5px; }
.btn.lien { border: none; background: none; color: var(--marque); padding: 4px 6px; }
.btn:disabled, .btn.occupe { opacity: .55; cursor: progress; }
.btn-icone { border: none; background: none; color: var(--gris); cursor: pointer; padding: 5px; border-radius: 6px; display: inline-grid; place-items: center; }
.btn-icone:hover { background: #eef0f3; color: var(--encre); }

/* ── formulaires ── */
.champ { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.champ .libelle { font-size: 12.5px; font-weight: 600; color: var(--gris); }
.champ .aide { font-size: 12px; color: var(--gris-c); }
.saisie { font: inherit; border: 1px solid #d5d9e0; border-radius: 8px; padding: 8px 10px; background: var(--blanc); color: var(--encre); width: 100%; }
.saisie:focus { outline: none; border-color: var(--marque); box-shadow: 0 0 0 3px rgba(194, 65, 12, .16); }
/* mot de passe avec œil (écran de connexion) : le bouton se pose à droite DANS le champ, mais hors du <label> */
.champ-oeil { position: relative; margin-bottom: 12px; }
.champ-oeil > .champ { margin-bottom: 0; }
.champ-oeil > .oeil { position: absolute; right: 3px; bottom: 2px; width: 32px; height: calc(100% - 4px); max-height: 30px; }
.saisie.avec-oeil { padding-right: 40px; }
.saisie.avec-oeil::-ms-reveal { display: none; }   /* Edge a son propre œil : un seul suffit */
textarea.saisie { resize: vertical; min-height: 60px; line-height: 1.4; }
.grille { display: grid; gap: 0 14px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: 1fr 1fr 1fr; } .g4 { grid-template-columns: repeat(4, 1fr); }
.case { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; cursor: pointer; line-height: 1.4; }
.case input { margin-top: 3px; }

/* ── cartes, listes, pastilles ── */
.carte { background: var(--blanc); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 18px; box-shadow: var(--ombre); }
.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.chiffre { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.sous { color: var(--gris); font-size: 12.5px; }
.pastille { display: inline-block; font-size: 11.5px; font-weight: 600; border-radius: 20px; padding: 2px 9px; white-space: nowrap; }
.pastille.gris { background: #eef0f3; color: var(--gris); } .pastille.bleu { background: var(--info-p); color: var(--info-f); }
.pastille.vert { background: var(--vert-p); color: var(--vert); } .pastille.rouge { background: var(--rouge-p); color: var(--rouge); }
.pastille.orange { background: var(--orange-p); color: var(--orange); }
table.liste { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--blanc); border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; }
table.liste th { text-align: left; font-size: 12px; color: var(--gris); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--trait); background: #fafbfc; cursor: pointer; user-select: none; white-space: nowrap; }
table.liste td { padding: 10px 12px; border-bottom: 1px solid #f0f1f4; vertical-align: middle; }
table.liste tr:last-child td { border-bottom: none; }
table.liste tbody tr { cursor: pointer; } table.liste tbody tr:hover td { background: #f8f9fb; }
table.liste tr.choisi td { background: var(--marque-p); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vide { text-align: center; color: var(--gris-c); padding: 40px; }
.filtres { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.onglets { display: flex; gap: 4px; background: #eceef2; border-radius: 9px; padding: 3px; }
.onglets button { border: none; background: none; font: inherit; font-weight: 600; padding: 6px 12px; border-radius: 7px; color: var(--gris); cursor: pointer; }
.onglets button.actif { background: var(--blanc); color: var(--encre); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.a-faire { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.a-faire .carte h2 { display: flex; align-items: center; gap: 8px; }
.ligne-doc { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid #f0f1f4; cursor: pointer; }
.ligne-doc:hover { color: var(--marque); }
.ligne-doc .d { text-align: right; white-space: nowrap; }

/* ── mise en page liste + aperçu latéral ── */
.deux { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; align-items: start; }
.lateral { position: sticky; top: 90px; }
.defile-x { min-width: 0; overflow-x: auto; }   /* une liste trop large défile dans sa colonne au lieu de passer sous le panneau */
/* écran de portable : la liste prend toute la largeur (Montant et Statut visibles), l'aperçu latéral est réservé aux grands écrans */
@media (max-width: 1599px) { .deux.apercu-large { grid-template-columns: minmax(0, 1fr); } .deux.apercu-large > .lateral { display: none; } }

/* ── éditeur de document ── */
.editeur { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 38%); gap: 18px; padding: 18px 22px 80px; align-items: start; }
.editeur .gauche { min-width: 0; }
.editeur .droite { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; background: #dfe3ea; border-radius: var(--rayon); padding: 14px; }
.bloc { background: var(--blanc); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 14px 16px; margin-bottom: 14px; }
.bloc-titre { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 700; }
.section { border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--blanc); margin-bottom: 12px; }
.section-tete { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--trait); background: #fafbfc; border-radius: var(--rayon) var(--rayon) 0 0; }
.section-tete input { font-weight: 700; border-color: transparent; background: transparent; }
.section-tete input:hover, .section-tete input:focus { border-color: #d5d9e0; background: #fff; }
.lignes { width: 100%; border-collapse: collapse; table-layout: fixed; }
.lignes select.saisie { padding: 6px 2px; }
.lignes select.type-ligne { width: 44px; flex: none; font-size: 11px; color: var(--gris); border-color: transparent; background: #f3f4f7; }
.lignes .outils .btn-icone { padding: 3px; }
.lignes th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--gris-c); font-weight: 600; padding: 6px 6px; text-align: left; }
.lignes td { padding: 4px 4px; vertical-align: top; border-top: 1px solid #f2f3f5; }
.lignes .saisie { padding: 6px 7px; border-color: transparent; background: transparent; }
.lignes .saisie:hover { border-color: #e0e3e8; } .lignes .saisie:focus { border-color: var(--marque); background: #fff; }
.lignes textarea.saisie { min-height: 34px; resize: none; overflow: hidden; }
.lignes .num .saisie { text-align: right; }
.lignes tr.option td { background: #fbfbf4; } .lignes tr.texte td { background: #fafbfd; }
.lignes .total { padding-top: 11px; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lignes .outils { white-space: nowrap; opacity: .35; } .lignes tr:hover .outils { opacity: 1; }
.pied-section { display: flex; gap: 6px; padding: 8px 10px; flex-wrap: wrap; align-items: center; }
.pied-section .st { margin-left: auto; color: var(--gris); font-weight: 600; }
.totaux { width: 100%; } .totaux td { padding: 4px 0; } .totaux .fort td { font-weight: 700; font-size: 15px; border-top: 1px solid var(--trait); padding-top: 8px; }
.marge { font-size: 12.5px; color: var(--gris); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--trait); }
.sauvegarde { font-size: 12.5px; color: var(--gris-c); display: inline-flex; align-items: center; gap: 5px; }
.sauvegarde.erreur { color: var(--rouge); }
.recherche-pop { position: absolute; z-index: 30; background: #fff; border: 1px solid var(--trait); border-radius: 10px; box-shadow: 0 10px 30px rgba(20, 25, 40, .16); width: 560px; max-height: 360px; overflow: auto; }
.recherche-pop .item { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid #f2f3f5; }
.recherche-pop .item:hover, .recherche-pop .item.actif { background: var(--marque-p); }
.recherche-pop .item .sous { white-space: nowrap; }

/* ── aperçu papier ── */
.feuilles { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.feuille { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); overflow: hidden; font-family: Helvetica, Arial, "Liberation Sans", sans-serif; }
.feuille .f-t { position: absolute; white-space: pre; line-height: 1; }
.feuille .f-r { position: absolute; }

/* ── fenêtres, messages ── */
.modale-fond { position: fixed; inset: 0; background: rgba(15, 20, 35, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modale { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modale.large { width: min(860px, 100%); }
.modale-tete { display: flex; align-items: center; padding: 16px 20px 6px; } .modale-tete h2 { margin: 0; } .modale-tete .btn-icone { margin-left: auto; }
.modale-corps { padding: 10px 20px; overflow: auto; } .modale-corps p { line-height: 1.5; }
.modale-pied { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--trait); }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: #1d2330; color: #fff; padding: 11px 16px; border-radius: 10px; max-width: 420px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); transition: opacity .3s, transform .3s; line-height: 1.4; }
.toast.succes { background: #0f7a45; } .toast.erreur { background: #b3261e; } .toast.sortie { opacity: 0; transform: translateY(8px); }
.note { background: var(--info-p); border-radius: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.45; color: #22325f; margin: 8px 0; }
.note.alerte { background: var(--orange-p); color: #6b3a00; } .note.rouge { background: var(--rouge-p); color: #8a1c14; }

/* ── pages de connexion ── */
.accueil { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.accueil .pitch { background: linear-gradient(145deg, #10152b 0%, #1a2a6b 100%); color: #dfe5f7; padding: 60px; display: flex; flex-direction: column; justify-content: center; }
.accueil .pitch h1 { font-size: 34px; color: #fff; line-height: 1.15; margin: 18px 0; }
.accueil .pitch li { margin: 10px 0; line-height: 1.4; }
.accueil .formulaire { display: grid; place-items: center; padding: 40px; }
.accueil .formulaire .carte { width: min(420px, 100%); padding: 28px; }
.accueil .formulaire h2 { font-size: 21px; margin-bottom: 18px; }
.plein { width: 100%; justify-content: center; padding: 10px; }
.petit-lien { font-size: 13px; margin-top: 12px; text-align: center; color: var(--gris); }

@media (max-width: 1100px) { .editeur { grid-template-columns: 1fr; } .editeur .droite { position: static; max-height: none; } .deux { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .coque { grid-template-columns: 1fr; } .barre { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } .accueil { grid-template-columns: 1fr; } .accueil .pitch { display: none; } .g3, .g4 { grid-template-columns: 1fr 1fr; } }

.antirobot:not(:empty) { margin: 10px 0; min-height: 65px; }   /* widget anti-robot (Turnstile) */

/* ── éditeur : marges ; aperçu plein écran et bouton « Aperçu » réservés au téléphone ── */
.zone-editeur .contenu { padding: 18px 22px 80px; }
.seulement-mobile, .apercu-tete { display: none; }
body.sans-defilement { overflow: hidden; }

/* ── tablette et téléphone : menu compact, une bande d'icônes en haut (les libellés restent lus par l'accessibilité) ── */
@media (max-width: 860px) {
  .barre { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 2px; padding: 6px 8px; }
  .marque { font-size: 0; gap: 0; padding: 0 6px 0 2px; }
  .nav { display: flex; flex: 1; min-width: 0; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .nav a { flex: none; margin: 0; padding: 10px; font-size: 0; }
  .nav a.actif { box-shadow: inset 0 -3px 0 #fb923c; }
  .barre .bas { margin: 0; padding: 0; border: 0; display: flex; align-items: center; gap: 6px; }
  .barre .entreprise, .barre .utilisateur { display: none; }
  .barre .bas .btn { font-size: 0; gap: 0; padding: 8px; }
  .barre select { width: 120px; margin: 0; }
  .coque { grid-template-rows: auto 1fr; }                          /* la bande de menu ne s'étire pas sur une page courte */
}

/* ── téléphone (Android comme iPhone dans le navigateur) ── */
@media (max-width: 700px) {
  input, select, textarea, .saisie { font-size: 16px; }          /* pas de zoom automatique au toucher d'un champ */
  .entete { position: static; flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .entete h1 { font-size: 18px; min-width: 0; }
  .entete .actions { margin-left: 0; width: 100%; }
  .contenu, .zone-editeur .contenu { padding: 14px 12px 40px; }
  .bandeau { padding: 8px 14px; flex-wrap: wrap; }
  .g2, .g3, .g4, .a-faire { grid-template-columns: 1fr; }
  .modale-fond { padding: 10px; } .modale { max-height: calc(100dvh - 20px); }
  .toasts { left: 10px; right: 10px; bottom: 100px; } .toast { max-width: none; }
  .recherche-pop { max-width: calc(100vw - 20px); z-index: 50; }   /* devant la barre d'actions du bas */
  table.liste { display: block; overflow-x: auto; }
  .grille[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* éditeur : les actions en barre fixe en bas, sous le pouce ; « Aperçu » remplace le téléchargement du PDF */
  .zone-editeur .contenu { padding: 12px 10px calc(118px + env(safe-area-inset-bottom)); }
  .zone-editeur .entete .actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; width: auto; gap: 6px; flex-wrap: wrap;
    background: #fff; border-top: 1px solid var(--trait); box-shadow: 0 -4px 16px rgba(20, 25, 40, .08); padding: 7px 10px calc(9px + env(safe-area-inset-bottom)); }
  .zone-editeur .entete .actions .sauvegarde { flex: 1 0 100%; text-align: center; font-size: 11.5px; }
  .zone-editeur .entete .actions .btn { flex: 1 1 auto; justify-content: center; padding: 11px 10px; }
  .zone-editeur .entete .actions .btn-pdf { display: none; }
  .seulement-mobile { display: inline-flex; }
  .zone-editeur .bloc .recherche-pop { left: 0; right: 0; width: auto; }

  /* aperçu masqué ; « Aperçu » l'ouvre en plein écran */
  .zone-editeur .editeur .droite { display: none; }
  .zone-editeur.apercu-ouvert .editeur .droite { display: block; position: fixed; inset: 0; z-index: 60; max-height: none; border-radius: 0; overflow: auto; padding: 0 10px 24px; }
  .apercu-ouvert .apercu-tete { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: sticky; top: 0; z-index: 2; background: #dfe3ea; padding: 12px 4px; }
  .apercu-tete .sous { flex: 1; font-size: 12px; line-height: 1.3; }

  /* lignes du document en CARTES : désignation en pleine largeur, puis les champs nommés */
  .lignes, .lignes tbody { display: block; width: 100%; }
  .lignes colgroup, .lignes thead { display: none; }
  .lignes tr { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; padding: 12px 10px; border-top: 1px solid var(--trait); }
  .lignes tbody tr:first-child { border-top: 0; }
  .lignes td { display: block; flex: 1 1 28%; min-width: 0; padding: 0; border: 0; }
  .lignes td:first-child { flex-basis: 100%; }
  .lignes td[data-libelle]::before { content: attr(data-libelle); display: block; margin: 0 0 3px 2px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .03em; color: var(--gris-c); text-align: left; }
  .lignes .saisie { border-color: #d5d9e0; background: #fff; }
  .lignes select.type-ligne { width: 62px; }
  .lignes .num .saisie { text-align: left; }
  .lignes .total { flex: 1 1 auto; padding: 0 0 10px; text-align: left; font-size: 16px; }
  .lignes .outils { flex: 0 0 auto; margin-left: auto; opacity: 1; }
  .lignes .outils .btn-icone { padding: 9px; }
  .lignes tr.texte td:empty { display: none; }
  .pied-section .st { flex-basis: 100%; text-align: right; }
  .pied-section .btn { padding: 9px 12px; }

  /* tableau de bord : les chiffres du mois deux par deux, comme dans l'appli iPhone */
  .cartes { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cartes .carte { padding: 12px; }
  .cartes .chiffre { font-size: 20px; }

  /* liste des documents en CARTES : numéro · type · montant / client · statut / objet · date */
  table.liste.liste-docs { display: block; overflow: visible; }
  .liste-docs thead { display: none; }
  .liste-docs tbody { display: block; }
  .liste-docs tr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "num type montant" "client client statut" "objet objet date";
    gap: 3px 10px; align-items: center; padding: 11px 12px; border-top: 1px solid var(--trait); }
  .liste-docs tbody tr:first-child { border-top: 0; }
  .liste-docs td { padding: 0; border: 0; min-width: 0; }
  .liste-docs td:nth-child(1) { grid-area: num; }
  .liste-docs td:nth-child(2) { grid-area: type; color: var(--gris); font-size: 13px; }
  .liste-docs td:nth-child(3) { grid-area: client; font-weight: 600; max-width: none !important; }
  .liste-docs td:nth-child(4) { grid-area: objet; color: var(--gris); font-size: 13px; max-width: none !important; }
  .liste-docs td:nth-child(5) { grid-area: date; color: var(--gris-c); font-size: 12px; text-align: right; }
  .liste-docs td:nth-child(6) { grid-area: montant; font-weight: 700; }
  .liste-docs td:nth-child(7) { grid-area: statut; text-align: right; }
  .liste-docs td[colspan] { grid-column: 1 / -1; }
}
