/* Comptes Kapex : un livre de comptes clair. Chiffres en Geist Mono alignés, encre Kapex, bleu Kapex en accent. */
@font-face { font-family: "Geist"; src: url("fonts/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("fonts/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --fond: #f5f6f8; --carte: #ffffff; --encre: #0b1220; --texte: #2b3443; --discret: #5f6878; --trait: #e3e6ec; --trait-fort: #c9ced8;
  --accent: #2140b0; --accent-doux: #e8edfb; --pos: #0b7453; --pos-doux: #e3f4ee; --neg: #b42318; --neg-doux: #fdecea; --attente: #8a5a00; --attente-doux: #fdf3dc;
  --a: #2140b0; --b: #c2410c; --c: #6b7280;
  --g-rec: #3a5bd9; --g-dep: #d97706;
  --ombre: 0 1px 2px rgb(11 18 32 / 0.05), 0 4px 16px rgb(11 18 32 / 0.04);
  --r: 14px; --ease: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0a0f1a; --carte: #111827; --encre: #f1f4f9; --texte: #d4d9e2; --discret: #97a0b0; --trait: #222c3d; --trait-fort: #334056;
    --accent: #8ca2f5; --accent-doux: #1b2547; --pos: #4fd1a5; --pos-doux: #0f2a22; --neg: #f8877c; --neg-doux: #33171a; --attente: #f2c05c; --attente-doux: #2d2410;
    --a: #8ca2f5; --b: #f29a5e; --c: #9ca3af; --g-rec: #6680e8; --g-dep: #c97a12;
    --ombre: 0 1px 2px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { overflow-x: clip; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--texte); font: 15px/1.55 "Geist", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { color: var(--encre); letter-spacing: -0.02em; line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 600; }
h2 { font-size: 1.02rem; font-weight: 600; margin-bottom: 0.6rem; }
a { color: var(--accent); text-underline-offset: 3px; }
/* Montants : chiffres de même largeur (alignés en colonne) sans la virgule large d'une police à chasse fixe */
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; letter-spacing: -0.005em; }
code { font-family: "Geist Mono", ui-monospace, monospace; }
.discret { color: var(--discret); }
.petit-texte { font-size: 0.85rem; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.sauter { position: absolute; left: -999px; } .sauter:focus { left: 12px; top: 12px; z-index: 10; background: var(--carte); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Barre du haut */
.barre { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--fond) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--trait); }
.marque { display: flex; align-items: center; gap: 9px; color: var(--encre); text-decoration: none; font-weight: 600; letter-spacing: -0.01em; }
.marque svg, .connexion-logo { width: 26px; height: 26px; }
.m-fond { fill: var(--encre); } .m-trait { fill: var(--fond); }
.menu { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.menu a { padding: 7px 11px; border-radius: 9px; color: var(--discret); text-decoration: none; white-space: nowrap; font-size: 0.93rem; transition: background-color 150ms ease, color 150ms ease; }
.menu a:hover { color: var(--encre); background: var(--trait); }
.menu a.on { color: var(--encre); background: var(--carte); box-shadow: var(--ombre); }
.compteur { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--carte); font-size: 0.72rem; font-weight: 600; }
.moi { display: flex; align-items: center; gap: 10px; }
.profil { position: relative; }
.profil summary { list-style: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; background: var(--encre); color: var(--fond); font-weight: 600; }
.profil summary::-webkit-details-marker { display: none; }
.profil-menu { position: absolute; right: 0; top: 42px; min-width: 220px; background: var(--carte); border: 1px solid var(--trait); border-radius: 12px; padding: 12px; box-shadow: var(--ombre);
  display: flex; flex-direction: column; gap: 8px; transform-origin: top right; animation: ouvrir 160ms var(--ease); }
@keyframes ouvrir { from { opacity: 0; transform: scale(0.97); } }
.profil-menu p { margin: 0 0 4px; }

/* Page */
.page { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; display: flex; flex-direction: column; gap: 16px; }
.entete-page { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.entete-page p { margin: 4px 0 0; }
.surtitre { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--discret); margin: 0 0 6px; }
.surtitre a { color: inherit; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r); padding: 20px; box-shadow: var(--ombre); min-width: 0; }
.carte-liste { padding: 4px 8px; overflow-x: auto; }
.etroite { max-width: 520px; }
.deux-colonnes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.entete-carte { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.espace-haut { margin-top: 20px; }
.vide { text-align: center; padding: 28px 16px; color: var(--discret); }
.vide p { max-width: 52ch; margin: 0 auto 14px; }

/* Solde + fléau */
.solde { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; align-items: center; padding: 28px; }
.solde-phrase { font-size: clamp(1.6rem, 3.4vw, 2.4rem); font-weight: 600; letter-spacing: -0.035em; margin: 2px 0 10px; }
.solde-texte p { margin: 0 0 14px; }
.qui { white-space: nowrap; }
.qui-a { color: var(--a); } .qui-b { color: var(--b); } .qui-c { color: var(--c); }
.fleau { margin: 0; }
.fleau-svg { width: 100%; height: auto; overflow: visible; }
.fleau-pied, .fleau-barre, .fleau-plateau line { stroke: var(--trait-fort); stroke-width: 3; stroke-linecap: round; fill: none; }
.fleau-barre { stroke: var(--encre); }
.fleau-axe { fill: var(--encre); }
.fleau-bras { transform-origin: 120px 52px; transition: transform 600ms var(--ease); }
.fleau-plateau { transition: transform 600ms var(--ease); }
.plateau { stroke: none; } .plateau-a { fill: var(--a); } .plateau-b { fill: var(--b); } .plateau-c { fill: var(--c); }
.fleau-noms { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--discret); padding: 0 2px; }
@media (prefers-reduced-motion: reduce) { .fleau-bras, .fleau-plateau { transition: none; } }

/* Associés */
.grille-associes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.associe h2 { display: flex; align-items: center; gap: 8px; }
.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pastille-a { background: var(--a); } .pastille-b { background: var(--b); } .pastille-c { background: var(--c); }
.chiffres { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.chiffres dt { font-size: 0.8rem; color: var(--discret); }
.chiffres dd { margin: 0; }
.chiffres dd.mono { font-size: 1.05rem; color: var(--encre); font-weight: 500; }
.chiffres dd.discret { font-size: 0.78rem; }
.position.pos { color: var(--pos); } .position.neg { color: var(--neg); }
.plafond { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--trait); }
.plafond p { margin: 0 0 6px; }
.jauge { height: 6px; background: var(--trait); border-radius: 3px; overflow: hidden; }
.jauge-plein { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; }
.jauge-plein.alerte { background: var(--attente); }

/* Chiffres clés */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: stretch; }
.kpi { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r); padding: 14px 16px; }
.kpi p { margin: 0; font-size: 0.83rem; color: var(--discret); }
.kpi .kpi-v { font-size: 1.35rem; color: var(--encre); font-weight: 500; margin: 2px 0; letter-spacing: -0.01em; }
.kpi .kpi-v.neg { color: var(--neg); }
.kpi-annee { display: flex; flex-direction: column; justify-content: center; gap: 4px; }

.alertes { display: flex; gap: 10px; flex-wrap: wrap; }
.alerte { padding: 10px 14px; border-radius: 12px; background: var(--attente-doux); color: var(--attente); text-decoration: none; font-size: 0.93rem; }
.alerte-forte { background: var(--neg-doux); color: var(--neg); }

/* Graphique */
.legende { display: flex; gap: 14px; list-style: none; margin: 0; padding: 0; font-size: 0.85rem; color: var(--discret); }
.legende li { display: flex; align-items: center; gap: 6px; }
.cle { width: 10px; height: 10px; border-radius: 3px; }
.cle-rec { background: var(--g-rec); } .cle-dep { background: var(--g-dep); }
.graph { width: 100%; height: auto; }
.graph-base { stroke: var(--trait-fort); stroke-width: 1; }
.barre-rec { fill: var(--g-rec); } .barre-dep { fill: var(--g-dep); }
.graph-cible { fill: transparent; }
.graph-mois:hover .graph-cible { fill: var(--trait); opacity: 0.5; }
.graph-mois-txt { fill: var(--discret); font: 13px "Geist", sans-serif; text-anchor: middle; }
.tableau-donnees { margin-top: 8px; font-size: 0.88rem; }
.tableau-donnees summary { cursor: pointer; color: var(--accent); }

/* Listes */
.ligne-simple { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--trait); }
.ligne-simple:last-of-type { border-bottom: 0; }
.ligne-simple form { margin: 0; }
.liste { width: 100%; border-collapse: collapse; }
.liste th { text-align: left; font-size: 0.78rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--discret); padding: 10px 10px; border-bottom: 1px solid var(--trait); white-space: nowrap; }
.liste td { padding: 11px 10px; border-bottom: 1px solid var(--trait); vertical-align: top; }
.liste tbody tr:last-child td { border-bottom: 0; }
.liste tfoot th { border-top: 1px solid var(--trait-fort); border-bottom: 0; color: var(--encre); font-size: 0.9rem; text-transform: none; letter-spacing: 0; }
.num { text-align: right !important; white-space: nowrap; }
.op-date { white-space: nowrap; color: var(--discret); font-size: 0.88rem; }
.op-lib a { color: var(--encre); text-decoration: none; font-weight: 500; }
.op-lib a:hover { text-decoration: underline; }
.op-depense .op-montant { color: var(--encre); } .op-recette .op-montant { color: var(--pos); } .op-virement .op-montant { color: var(--discret); }
.qui-mini { display: inline-flex; align-items: center; gap: 5px; margin-right: 8px; font-size: 0.88rem; white-space: nowrap; }
.eteint td { opacity: 0.55; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 0.75rem; font-weight: 500; white-space: nowrap; vertical-align: middle; }
.badge-a_valider { background: var(--attente-doux); color: var(--attente); }
.badge-valide { background: var(--pos-doux); color: var(--pos); }
.badge-conteste { background: var(--neg-doux); color: var(--neg); }

/* Filtres, pages */
.filtres { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px; }
.filtres input[type=search] { flex: 1 1 220px; }
.champ-date { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--discret); white-space: nowrap; }
.pages { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

/* Formulaires */
label { display: flex; flex-direction: column; gap: 5px; font-size: 0.88rem; color: var(--texte); font-weight: 500; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--encre); background: var(--carte); border: 1px solid var(--trait-fort); border-radius: 10px; padding: 9px 11px; min-height: 42px; width: 100%; min-width: 0; }
.filtres input, .filtres select, .en-ligne input, .en-ligne select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--accent); }
textarea { resize: vertical; }
.court { max-width: 120px; }
.aide { font-size: 0.8rem; font-weight: 400; color: var(--discret); margin: 0; }
ul.aide { padding-left: 18px; }
.champs-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.champs-grille .large { grid-column: span 2; }
.form-op { display: flex; flex-direction: column; gap: 4px; }
.choix { border: 0; padding: 0; margin: 6px 0 12px; }
.choix legend { font-weight: 600; color: var(--encre); margin-bottom: 8px; font-size: 0.93rem; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce { flex-direction: row; align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--trait-fort); border-radius: 22px; cursor: pointer; font-weight: 500; min-height: 42px;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms var(--ease); }
.puce:active { transform: scale(0.97); }
.puce:has(input:checked) { border-color: var(--accent); background: var(--accent-doux); color: var(--accent); }
.puce input { position: absolute; opacity: 0; pointer-events: none; }
.puce:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.sous-champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 10px; }
[data-si][hidden] { display: none; }
.options { border: 1px solid var(--trait); border-radius: 12px; padding: 12px 14px; margin: 6px 0 12px; }
.options summary { cursor: pointer; font-weight: 500; color: var(--encre); }
.options[open] summary { margin-bottom: 12px; }
.case { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; margin: 6px 0; flex-wrap: wrap; }
.case .aide { flex-basis: 100%; padding-left: 26px; }
.fichier { margin: 6px 0 10px; }
.apercu { min-height: 1.4em; margin: 8px 0; padding: 10px 14px; border-radius: 10px; background: var(--accent-doux); color: var(--encre); font-size: 0.93rem; }
.apercu:empty { display: none; }
.actions-form { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.en-ligne { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.onglets { display: flex; gap: 6px; flex-wrap: wrap; }
.onglets a { padding: 9px 16px; border-radius: 22px; text-decoration: none; color: var(--discret); border: 1px solid var(--trait-fort); }
.onglets a.on { background: var(--encre); color: var(--fond); border-color: var(--encre); }
.montant-grand { font-size: 1.9rem; font-weight: 500; margin: 0; color: var(--encre); letter-spacing: -0.02em; }
.montant-grand.recette { color: var(--pos); }
.note { font-style: italic; background: var(--fond); padding: 8px 12px; border-radius: 10px; }
.form-statut { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.modifier summary { list-style: none; cursor: pointer; }
.modifier summary h2 { display: inline; }
.modifier summary::after { content: " ▾"; color: var(--discret); }
.supprimer { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--trait); }
.utilisateur { padding: 10px 0; border-bottom: 1px solid var(--trait); }
.utilisateur p { margin: 0 0 8px; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--trait-fort);
  background: var(--carte); color: var(--encre); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms var(--ease); }
.btn:hover { border-color: var(--encre); }
.btn:active { transform: scale(0.97); }
.btn.primaire { background: var(--encre); color: var(--fond); border-color: var(--encre); }
.btn.primaire:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--neg); }
.btn.petit { min-height: 34px; padding: 0 12px; font-size: 0.88rem; }
.btn.large { width: 100%; }
.lien { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.lien.danger { color: var(--neg); }

.flash { margin: 0; padding: 12px 16px; border-radius: 12px; }
.flash-ok { background: var(--pos-doux); color: var(--pos); }
.flash-erreur { background: var(--neg-doux); color: var(--neg); }
.flash-info { background: var(--accent-doux); color: var(--accent); }

.connexion { max-width: 400px; margin: 10vh auto 0; display: flex; flex-direction: column; gap: 10px; padding: 32px; }
.connexion form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }

@media (max-width: 860px) {
  .solde { grid-template-columns: 1fr; padding: 22px; }
  .fleau { max-width: 240px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deux-colonnes { grid-template-columns: 1fr; }
  .barre { flex-wrap: wrap; row-gap: 6px; }
  .menu { order: 3; flex-basis: 100%; }
  .moi { margin-left: auto; }
  .cache-mobile, .op-qui { display: none; }
  .fleau { max-width: 220px; margin: 0 auto; }
  /* Opérations : une petite carte par ligne */
  .liste tr.op { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "lib montant" "date statut";
    column-gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--trait); }
  .liste tbody tr.op:last-child { border-bottom: 0; }
  .liste tr.op td { padding: 0; border: 0; }
  .op .op-lib { grid-area: lib; } .op .op-montant { grid-area: montant; } .op .op-date { grid-area: date; font-size: 0.8rem; padding-top: 3px; }
  .op .op-statut { grid-area: statut; text-align: right; padding-top: 3px; }
  .liste:has(tr.op) thead { display: none; }
  .champs-grille .large { grid-column: auto; }
  .chiffres { grid-template-columns: 1fr 1fr; }
  .page { padding-top: 16px; }
}
