/* KzLoyers — démo PWA. Charte KzSuite (ui/core/kz_theme.py), émeraude KzLoyers.
   Couleurs vives pour les pastilles seulement ; le texte prend les teintes foncées. */
@font-face { font-family: "Lato"; src: url(polices/Lato-Medium.ttf); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "Lato"; src: url(polices/Lato-Bold.ttf); font-weight: 700 800; font-display: swap; }
@font-face { font-family: "Lato"; src: url(polices/Lato-Black.ttf); font-weight: 900; font-display: swap; }
:root {
  --navy: #0B2545; --bleu: #1565D8; --bleu-fonce: #0E4CA8; --emeraude: #0E8A5F;
  --fond: #EEF4FF; --surface: #FFFFFF; --ligne: #E2E8F0; --texte: #0B2545; --texte2: #64748B;
  --side-texte: #B8C7DD; --side-survol: #16365F; --selection: #DCE8F9;
  --vert: #17A673; --vert-bg: #E3F6EE; --vert-txt: #0F7A52;
  --ambre: #F5A524; --ambre-bg: #FFF4DD; --ambre-txt: #8A5300;
  --rouge: #E5484D; --rouge-bg: #FDE7E8; --rouge-txt: #B4232A;
  --rayon: 12px; --ombre: 0 1px 6px rgba(11, 37, 69, .07);
  font-family: "Lato", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--texte); background: var(--fond); font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; min-height: 42px; padding: 0 14px; }
button:active { transform: scale(.98); }
.b-primaire { background: var(--bleu); color: #fff; font-weight: 700; }
.b-primaire:hover { background: var(--bleu-fonce); }
.b-clair { background: var(--fond); color: var(--texte); border: 1px solid var(--ligne); font-weight: 600; }
.b-clair:hover { background: var(--selection); }
.b-danger { background: var(--rouge-bg); color: var(--rouge-txt); font-weight: 600; }
.b-lien { background: none; color: var(--bleu); min-height: 32px; padding: 0 6px; text-decoration: underline; }
.lien-bouton { display: inline-flex; align-items: center; min-height: 42px; padding: 0 18px; border-radius: 10px; text-decoration: none; }
input, select { height: 42px; border: 1px solid var(--ligne); border-radius: 10px; padding: 0 12px; background: var(--surface); min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--bleu); outline-offset: -1px; }

/* Menu latéral (bas de l'écran sur téléphone) */
.menu { width: 230px; flex: none; background: var(--navy); color: var(--side-texte); display: flex; flex-direction: column; padding: 14px 10px; gap: 4px; }
.marque { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 21px; color: #fff; padding: 4px 8px 18px; }
.marque b { color: #4FD1A1; font-weight: 900; }
.marque img { border-radius: 8px; }
.marque em { font-style: normal; font-size: 11px; font-weight: 700; background: var(--ambre); color: var(--navy); padding: 2px 8px; border-radius: 99px; }
.menu > button { display: flex; align-items: center; gap: 12px; background: none; color: var(--side-texte); text-align: left; font-weight: 600; }
.menu > button i { font-style: normal; width: 22px; text-align: center; color: #5F7BA6; font-weight: 900; }
.menu > button:hover { background: var(--side-survol); }
.menu > button.actif { background: var(--bleu); color: #fff; }
.menu > button.actif i { color: #fff; }
.menu > button b { margin-left: auto; background: var(--rouge); color: #fff; border-radius: 99px; padding: 1px 8px; font-size: 12px; }
.menu-pied { margin-top: auto; }
.b-menu { background: none; color: var(--side-texte); text-decoration: underline; width: 100%; text-align: left; }

.contenu { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 22px 26px 40px; min-width: 0; min-height: 0; }
.titre { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 16px; }
.titre h1 { margin: 0; font-size: 26px; font-weight: 900; }
.sous-titre { color: var(--texte2); }
.outils { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.outils input[type=search] { width: 280px; }
.annee { font-size: 18px; min-width: 52px; text-align: center; }
.coche { display: flex; align-items: center; gap: 6px; color: var(--texte2); }
.coche input { height: auto; }
.aide { color: var(--texte2); font-size: 14px; margin: 0 0 10px; }

.carte { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; margin-bottom: 16px; }
.carte h2 { margin: 0 0 12px; font-size: 16px; font-weight: 800; }
.deux { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 14px 16px; border-top: 4px solid var(--bleu); }
.kpi span { display: block; color: var(--texte2); font-size: 13px; font-weight: 600; }
.kpi b { display: block; font-size: 24px; font-weight: 900; margin-top: 6px; white-space: nowrap; }
.kpi small { color: var(--texte2); }
.kpi.vert { border-top-color: var(--vert); } .kpi.rouge { border-top-color: var(--rouge); } .kpi.ambre { border-top-color: var(--ambre); }

.graphe { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 8px; border-bottom: 1px solid var(--ligne); }
.mois-barres { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.mois-barres .barres { display: flex; align-items: flex-end; gap: 2px; height: 100%; width: 100%; justify-content: center; }
.mois-barres .barres div { width: 40%; max-width: 16px; border-radius: 4px 4px 0 0; min-height: 2px; }
.mois-barres .a { background: #C9D5E6; } .mois-barres .e { background: var(--bleu); }
.mois-barres small { color: var(--texte2); font-size: 11px; margin-bottom: -20px; }
.legende { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--texte2); font-size: 13px; margin-top: 26px; }
.pt { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: -8px; }
.pt.attendu { background: #C9D5E6; } .pt.encaisse { background: var(--bleu); }
.pt.paye { background: var(--vert); } .pt.partiel { background: var(--ambre); } .pt.retard { background: var(--rouge); } .pt.attente { background: #C9D5E6; }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--ligne); }
.liste li:last-child { border-bottom: 0; }
.liste .nom { flex: 1; font-weight: 700; }
.liste .nom small { display: block; color: var(--texte2); font-weight: 400; }
.vide { color: var(--texte2); padding: 18px 4px; text-align: center; }

.tableau-defile { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; color: var(--texte2); background: var(--fond); padding: 10px; font-weight: 700; white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--ligne); white-space: nowrap; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--selection); }
.table .n { text-align: right; }
.table .parti td { color: var(--texte2); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; }
.badge.vert { background: var(--vert-bg); color: var(--vert-txt); }
.badge.ambre { background: var(--ambre-bg); color: var(--ambre-txt); }
.badge.rouge { background: var(--rouge-bg); color: var(--rouge-txt); }
.badge.gris { background: var(--fond); color: var(--texte2); }
.actions-ligne { display: flex; gap: 6px; justify-content: flex-end; }
.actions-ligne button, .actions-ligne a { min-height: 34px; font-size: 14px; }
.wa { display: inline-flex; align-items: center; padding: 0 12px; border-radius: 10px; background: var(--vert-bg); color: var(--vert-txt); font-weight: 700; text-decoration: none; }

/* Grille des loyers */
.grille { border-collapse: separate; border-spacing: 3px; min-width: 100%; }
.grille th { font-size: 12px; color: var(--texte2); font-weight: 700; padding: 6px 4px; }
.grille th.loc, .grille td.loc { position: sticky; left: 0; background: var(--surface); text-align: left; z-index: 1; min-width: 170px; }
.grille td.loc b { display: block; } .grille td.loc small { color: var(--texte2); }
.grille td.case { min-width: 58px; height: 44px; text-align: center; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; }
.grille td.case:hover { outline: 2px solid var(--bleu); }
.case.paye { background: var(--vert-bg); color: var(--vert-txt); }
.case.partiel { background: var(--ambre-bg); color: var(--ambre-txt); }
.case.retard { background: var(--rouge-bg); color: var(--rouge-txt); }
.case.attente { background: var(--fond); color: var(--texte2); }
.case.hors { background: none; cursor: default; }
.case.hors:hover { outline: 0; }
.grille td.total, .grille th.total { text-align: right; font-weight: 800; padding: 0 8px; white-space: nowrap; }
.grille tr.pied td { font-weight: 800; border-top: 2px solid var(--ligne); padding-top: 8px; text-align: center; font-size: 12px; }

/* Fenêtres */
dialog.fenetre { border: 0; border-radius: 16px; padding: 22px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(11, 37, 69, .3); color: var(--texte); }
dialog::backdrop { background: rgba(11, 37, 69, .45); }
dialog h2 { margin: 0 0 14px; font-weight: 900; font-size: 20px; padding-bottom: 10px; border-bottom: 2px solid var(--bleu); }
.champs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.champs label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--texte2); }
.champs label.large { grid-column: 1 / -1; }
.fenetre-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.espace { flex: 1; }
.erreur { background: var(--rouge-bg); color: var(--rouge-txt); padding: 10px 12px; border-radius: 10px; margin: 12px 0 0; }
.qui { margin: 0 0 10px; font-weight: 700; }
.du { display: flex; justify-content: space-between; align-items: center; background: var(--fond); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.du b:last-child { font-size: 22px; font-weight: 900; }
.deja { font-size: 14px; color: var(--texte2); }
.deja button { min-height: 30px; font-size: 13px; padding: 0 8px; }

/* Quittance, relevé */
.document-fenetre { width: min(760px, calc(100vw - 24px)) !important; }
.document { font-size: 14px; }
.document .entete { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--navy); padding-bottom: 10px; margin-bottom: 16px; }
.document .entete h3 { margin: 0; font-size: 20px; font-weight: 900; }
.document .entete small { color: var(--texte2); }
.document .bloc { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.document .bloc div { background: var(--fond); border-radius: 8px; padding: 10px 12px; }
.document .bloc span { display: block; color: var(--texte2); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.document .montant { font-size: 22px; font-weight: 900; text-align: right; margin: 12px 0; }
.document .mention { color: var(--texte2); font-size: 13px; }
.document .signature { text-align: right; margin-top: 26px; }
.document table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.document th { text-align: left; background: var(--fond); padding: 6px 8px; font-size: 12px; }
.document td { padding: 6px 8px; border-bottom: 1px solid var(--ligne); }
.document .n { text-align: right; }
.document tr.solde td { font-weight: 900; border-top: 2px solid var(--navy); }
.document .filigrane { color: var(--rouge-txt); font-weight: 900; text-align: center; border: 2px dashed var(--rouge); padding: 6px; border-radius: 8px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--ombre); z-index: 10; max-width: 90vw; }

/* Tablette et téléphone : menu en bas */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .deux { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { flex-direction: column-reverse; }
  .menu { width: 100%; flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); gap: 2px; }
  .marque, .menu-pied { display: none; }
  .contenu { width: 100%; }
  .grille th.loc, .grille td.loc { min-width: 128px; }
  .menu > button { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 2px; min-height: 54px; position: relative; }
  .menu > button b { position: absolute; top: 2px; right: 10%; }
  .contenu { padding: 14px 12px 24px; }
  .titre h1 { font-size: 22px; }
  .titre h1::after { content: " ⓘ"; font-size: 16px; color: var(--texte2); cursor: pointer; }
  .outils { margin-left: 0; width: 100%; }
  .outils input[type=search] { width: 100%; }
  .kpi b { font-size: 19px; }
  .champs { grid-template-columns: 1fr; }
  .document .bloc { grid-template-columns: 1fr; }
}

/* Impression : le document seul */
@media print {
  body > *:not(#d-document) { display: none !important; }
  #d-document { position: static; box-shadow: none; width: 100% !important; max-height: none; padding: 0; }
  #d-document .fenetre-actions { display: none; }
  .document .bloc div { background: none; border: 1px solid var(--ligne); }
}
