/* Kolia Market - feuille de style unique.
   Pensee pour un telephone tenu d'une main, en plein soleil, sur un reseau lent.

   Deux fonds au choix, blanc ou sombre. Sans choix explicite, on suit le
   reglage du telephone ; des que quelqu'un choisit, data-theme tranche dans
   les deux sens. Les valeurs sombres sont ecrites deux fois, c'est le prix
   a payer pour que le bouton l'emporte sur la preference du systeme. */

:root {
  color-scheme: light;
  --fond:        #f4f6f9;
  --carte:       #ffffff;
  --carte-creux: #f7f9fb;
  --encre:       #101a26;
  --doux:        #566677;
  --tres-doux:   #84919f;
  --trait:       #dee5ec;
  --marque:      #144882;
  --marque-fonce:#0e3462;
  --marque-pale: #e6eef8;
  --vert:        #0b6b45;
  --vert-fonce:  #084f34;
  --vert-pale:   #e2f0e9;
  --ambre:       #8f5407;
  --ambre-pale:  #fbeed8;
  --rouge:       #ab2318;
  --rouge-pale:  #fbe6e3;
  --bleu:        #144882;
  --bleu-pale:   #e6eef8;
  --ombre:       0 1px 2px rgba(16, 26, 38, .06), 0 8px 24px -12px rgba(16, 26, 38, .2);
  --marque-solide: #144882;
  --sur-marque:  #ffffff;
  --logo-teinte: none;
  --rayon:       14px;
  --rayon-petit: 10px;
  --bas: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fond:        #0c1219;
    --carte:       #141d27;
    --carte-creux: #101822;
    --encre:       #e9eef4;
    --doux:        #97a5b3;
    --tres-doux:   #6c7c8b;
    --trait:       #22303d;
    --marque:      #74acdf;
    --marque-fonce:#9bc7ef;
    --marque-pale: #12293f;
    --vert:        #3fbb87;
    --vert-fonce:  #64d3a3;
    --vert-pale:   #103026;
    --ambre:       #e0a54a;
    --ambre-pale:  #332510;
    --rouge:       #f08279;
    --rouge-pale:  #3a1a17;
    --bleu:        #74acdf;
    --bleu-pale:   #12293f;
    --ombre:       0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .7);
    --marque-solide: #144882;
  --sur-marque:  #08121c;
  --logo-teinte: brightness(0) invert(1);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --fond:        #0c1219;
  --carte:       #141d27;
  --carte-creux: #101822;
  --encre:       #e9eef4;
  --doux:        #97a5b3;
  --tres-doux:   #6c7c8b;
  --trait:       #22303d;
  --marque:      #74acdf;
  --marque-fonce:#9bc7ef;
  --marque-pale: #12293f;
  --vert:        #3fbb87;
  --vert-fonce:  #64d3a3;
  --vert-pale:   #103026;
  --ambre:       #e0a54a;
  --ambre-pale:  #332510;
  --rouge:       #f08279;
  --rouge-pale:  #3a1a17;
  --bleu:        #74acdf;
  --bleu-pale:   #12293f;
  --ombre:       0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .7);
  --marque-solide: #144882;
  --sur-marque:  #08121c;
  --logo-teinte: brightness(0) invert(1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--fond);
  color: var(--encre);
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 .6em; }
[hidden] { display: none !important; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2;
      stroke-linecap: round; stroke-linejoin: round; }

.nombre { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ------------------------------------------------------------------ marque */
.marque { display: flex; align-items: center; gap: 12px; }
.marque-sigle {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--marque-solide);
  flex: none; overflow: hidden;
}
.marque-sigle.petit { width: 36px; height: 36px; border-radius: 10px; }
.marque-sigle img { width: 72%; height: 72%; object-fit: contain; display: block; }

/* Le verrou complet, sur l'ecran d'entree. Une seule image : en fond sombre
   un filtre la passe en blanc, ce qui evite de charger un second fichier. */
.verrou { display: block; width: 100%; max-width: 262px; height: auto;
          margin: 0 auto 4px; filter: var(--logo-teinte); }

/* Le bouton qui change le fond ; son icone est posee par le script. */
.bouton-icone.fond svg { width: 20px; height: 20px; }
.pied-entree {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-top: 14px; flex-wrap: wrap;
}
.pied-entree .lien-fond { margin: 0; }
.pied-entree a { text-decoration: none; }
.lien-fond {
  display: block; margin: 20px auto 0; padding: 10px 14px;
  border: none; background: none; color: var(--tres-doux);
  font: 550 13.5px/1 inherit; cursor: pointer; border-radius: 8px;
}
.lien-fond:active { background: var(--carte-creux); }

.marque-nom { font-size: 20px; font-weight: 680; letter-spacing: -.015em; }
.marque-grande .marque-sigle { width: 56px; height: 56px; border-radius: 16px; }
.marque-grande .marque-nom { font-size: 25px; }

/* --------------------------------------------------------------- demarrage */
.demarrage {
  position: fixed; inset: 0; display: grid; place-content: center;
  justify-items: center; gap: 26px; background: var(--fond); z-index: 60;
}
.chargement {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--trait); border-top-color: var(--marque);
  animation: tourne .8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chargement { animation-duration: 2.4s; } }

/* --------------------------------------------------------------- connexion */
.connexion {
  min-height: 100svh; display: grid; place-items: center;
  padding: 24px 18px calc(24px + var(--bas));
}
.connexion-boite { width: 100%; max-width: 380px; }
.connexion-intro { color: var(--doux); margin: 18px 0 22px; }

.champ { display: block; margin-bottom: 16px; }
.champ-titre {
  display: block; font-size: 13px; font-weight: 600; color: var(--doux);
  margin-bottom: 6px; letter-spacing: .01em;
}
.champ-aide { display: block; font-size: 12.5px; color: var(--tres-doux); margin-top: 5px; }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=tel], select, textarea {
  width: 100%; padding: 13px 14px; font: inherit; color: var(--encre);
  background: var(--carte); border: 1.5px solid var(--trait);
  border-radius: var(--rayon-petit); appearance: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--marque); box-shadow: 0 0 0 3px var(--marque-pale);
}
textarea { min-height: 68px; resize: vertical; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23566677' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
  padding-right: 40px;
}

.code-cache { position: absolute; opacity: 0; pointer-events: none; height: 0; width: 0; }
.code-points { display: flex; gap: 12px; justify-content: center; padding: 10px 0 4px; }
.code-points i {
  width: 14px; height: 14px; border-radius: 50%;
  background: transparent; border: 2px solid var(--trait);
  transition: background .12s, border-color .12s, transform .12s;
}
.code-points i.plein { background: var(--marque); border-color: var(--marque); transform: scale(1.08); }

.clavier {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 18px;
}
.clavier button {
  height: 58px; font: 600 22px/1 inherit; color: var(--encre);
  background: var(--carte); border: 1.5px solid var(--trait);
  border-radius: var(--rayon-petit); cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background .1s, transform .06s;
}
.clavier button:active { background: var(--marque-pale); transform: scale(.97); }
.clavier button.vide { visibility: hidden; }
.clavier button.action svg { width: 24px; height: 24px; }

/* --------------------------------------------------------------- boutons */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 18px; font: 600 16px/1 inherit;
  border-radius: var(--rayon-petit); border: 1.5px solid var(--trait);
  background: var(--carte); color: var(--encre); cursor: pointer;
  transition: background .12s, transform .06s, border-color .12s;
}
.bouton:active { transform: scale(.985); }
.bouton:disabled { opacity: .55; cursor: default; }
.bouton-plein { width: 100%; background: var(--marque); border-color: var(--marque); color: var(--sur-marque); }
.bouton-plein:active { background: var(--marque-fonce); }
.bouton-large { width: 100%; }
.bouton-danger { color: var(--rouge); border-color: var(--rouge-pale); background: var(--rouge-pale); }
.bouton-petit { min-height: 38px; padding: 0 12px; font-size: 14px; }

.bouton-icone {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: none; background: transparent; color: var(--doux);
  border-radius: 10px; cursor: pointer;
}
.bouton-icone:active { background: var(--trait); }

/* ---------------------------------------------------------------- entete */
.entete {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--carte);
  border-bottom: 1px solid var(--trait);
}
.entete-gauche { display: flex; align-items: center; gap: 11px; min-width: 0; }
.entete-droite { display: flex; align-items: center; gap: 2px; }
.entete-nom { font-weight: 660; font-size: 16px; line-height: 1.2; }
.entete-sous { font-size: 12.5px; color: var(--tres-doux); line-height: 1.3; }

.puce-file {
  border: none; background: var(--ambre-pale); color: var(--ambre);
  font: 600 12.5px/1 inherit; padding: 8px 11px; border-radius: 20px; cursor: pointer;
}

/* ------------------------------------------------------------------- vue */
.vue {
  padding: 16px 14px calc(88px + var(--bas));
  max-width: 720px; margin: 0 auto; outline: none;
}
.vue > * + * { margin-top: 14px; }

.titre-section {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 22px 0 -2px;
}
.titre-section h2 { font-size: 15px; letter-spacing: .01em; }
.titre-section span { font-size: 13px; color: var(--tres-doux); }

/* ----------------------------------------------------------------- cartes */
.carte {
  background: var(--carte); border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: 16px; box-shadow: var(--ombre);
}
.carte-titre { font-size: 13px; font-weight: 600; color: var(--doux); margin-bottom: 3px; }

.vedette { display: grid; gap: 3px; }
.vedette .valeur { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.vedette .devise { font-size: 15px; font-weight: 600; color: var(--tres-doux); margin-left: 4px; }
.vedette .precision { font-size: 13px; color: var(--doux); line-height: 1.45; }

.grille { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grille-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 360px) { .grille-3 { grid-template-columns: repeat(2, 1fr); } }

.tuile {
  background: var(--carte); border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: 13px 14px;
}
.tuile .etiquette { font-size: 12.5px; color: var(--doux); font-weight: 550; }
.tuile .chiffre { font-size: 20px; font-weight: 690; letter-spacing: -.015em; margin-top: 3px; }
.tuile .chiffre small { font-size: 12px; font-weight: 600; color: var(--tres-doux); margin-left: 3px; }
.tuile .sous { font-size: 12px; color: var(--tres-doux); margin-top: 2px; }
.tuile.vert  { background: var(--vert-pale);  border-color: transparent; }
.tuile.vert .chiffre { color: var(--vert-fonce); }
.tuile.ambre { background: var(--ambre-pale); border-color: transparent; }
.tuile.ambre .chiffre { color: var(--ambre); }
.tuile.rouge { background: var(--rouge-pale); border-color: transparent; }
.tuile.rouge .chiffre { color: var(--rouge); }
.tuile.bleu  { background: var(--bleu-pale);  border-color: transparent; }
.tuile.bleu .chiffre { color: var(--bleu); }

.avis {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 14px; border-radius: var(--rayon); font-size: 14px; line-height: 1.45;
}
.avis svg { flex: none; margin-top: 1px; }
.avis-ambre { background: var(--ambre-pale); color: var(--ambre); }
.avis-rouge { background: var(--rouge-pale); color: var(--rouge); }
.avis-vert  { background: var(--vert-pale);  color: var(--vert-fonce); }
.avis strong { font-weight: 660; }

/* ------------------------------------------------------------------ listes */
.liste { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; }
.ligne {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-top: 1px solid var(--trait); min-height: 58px;
}
.liste .ligne:first-child { border-top: none; }
.ligne-cliquable { cursor: pointer; width: 100%; text-align: left; background: none; border-left: none;
                   border-right: none; border-bottom: none; font: inherit; color: inherit; }
.ligne-cliquable:active { background: var(--carte-creux); }
.ligne-corps { flex: 1; min-width: 0; }
.ligne-titre { font-weight: 580; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-sous { font-size: 12.5px; color: var(--tres-doux); margin-top: 2px;
              overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-fin { text-align: right; flex: none; }
.ligne-montant { font-weight: 650; font-size: 15px; }
.ligne-extra { font-size: 12px; color: var(--tres-doux); margin-top: 2px; }
.ligne.annulee .ligne-titre, .ligne.annulee .ligne-montant { text-decoration: line-through; opacity: .55; }

.pastille {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 10px; font-size: 15px; background: var(--carte-creux);
}
.pastille svg { width: 18px; height: 18px; }
.p-vente { background: var(--vert-pale);  color: var(--vert-fonce); }
.p-achat { background: var(--bleu-pale);  color: var(--bleu); }
.p-depense { background: var(--rouge-pale); color: var(--rouge); }
.p-om    { background: var(--ambre-pale); color: var(--ambre); }
.p-remise { background: var(--carte-creux); color: var(--doux); }
.p-emprunt { background: var(--rouge-pale); color: var(--rouge); }
.p-remboursement { background: var(--vert-pale); color: var(--vert-fonce); }

.jeton {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; background: var(--carte-creux); color: var(--doux);
}
.jeton.alerte { background: var(--ambre-pale); color: var(--ambre); }
.jeton.rupture { background: var(--rouge-pale); color: var(--rouge); }
.jeton.vert { background: var(--vert-pale); color: var(--vert-fonce); }

.vide-message { text-align: center; color: var(--tres-doux); padding: 30px 16px; font-size: 14.5px; }

/* Chaque recette a son bandeau : on voit d'un coup d'oeil ou l'on est. */
.bandeau {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 26px 0 2px; padding: 0 2px;
  border-left: 3px solid var(--marque); padding-left: 11px;
}
.bandeau h2 { font-size: 17px; letter-spacing: -.01em; }
.bandeau span { font-size: 12.5px; color: var(--tres-doux); text-align: right; }
.vue > .bandeau:first-child { margin-top: 4px; }

/* Le dernier releve, glisse sous le solde calcule. */
.rappel {
  display: grid; gap: 1px; margin-top: 12px; padding: 10px 12px;
  background: var(--carte-creux); border-radius: var(--rayon-petit);
  font-size: 13px; line-height: 1.4;
}
.rappel b { font-weight: 620; color: var(--vert-fonce); }
.rappel span { color: var(--tres-doux); font-size: 12.5px; }
.rappel-alerte { background: var(--ambre-pale); }
.rappel-alerte b { color: var(--ambre); }
.rappel-alerte span { color: var(--ambre); opacity: .85; }

/* ----------------------------------------------------------------- filtres */
.filtres { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.filtres button {
  flex: none; padding: 8px 14px; border-radius: 18px; font: 550 13.5px/1 inherit;
  border: 1.5px solid var(--trait); background: var(--carte); color: var(--doux); cursor: pointer;
  white-space: nowrap;
}
.filtres button[aria-pressed=true] { background: var(--marque); border-color: var(--marque); color: var(--sur-marque); }

/* --------------------------------------------------------------- graphique */
.graphique { width: 100%; height: 150px; display: block; overflow: visible; }
.graphique .barre { fill: var(--marque); }
.graphique .barre-creuse { fill: var(--trait); }
.graphique text { font-size: 10px; fill: var(--tres-doux); stroke: none; font-weight: 500; }

/* ------------------------------------------------------------- navigation */
.navigation {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; background: var(--carte); border-top: 1px solid var(--trait);
  padding-bottom: var(--bas);
}
.navigation button {
  flex: 1; display: grid; justify-items: center; gap: 3px;
  padding: 9px 2px 8px; border: none; background: none; cursor: pointer;
  color: var(--tres-doux); font: 550 11px/1.2 inherit;
}
.navigation button[aria-current=page] { color: var(--marque); }
.navigation button svg { width: 21px; height: 21px; }

/* ------------------------------------------------------------------ panneau */
.panneau { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; }
.panneau-voile { position: absolute; inset: 0; background: rgba(10, 18, 15, .45); }
.panneau-boite {
  position: relative; width: 100%; max-height: 92svh; overflow-y: auto;
  background: var(--carte); border-radius: 20px 20px 0 0;
  padding-bottom: calc(18px + var(--bas));
  animation: monte .2s cubic-bezier(.2, .8, .3, 1);
  max-width: 720px; margin: 0 auto;
}
@keyframes monte { from { transform: translateY(18px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .panneau-boite { animation: none; } }
.panneau-tete {
  position: sticky; top: 0; background: var(--carte); z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 14px 12px; border-bottom: 1px solid var(--trait);
}
.panneau-tete h2 { font-size: 17px; }
.panneau-corps { padding: 16px 14px 4px; }

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.apercu {
  font-size: 13px; color: var(--vert-fonce); font-weight: 600; margin-top: 5px; min-height: 18px;
}
.choix { display: grid; gap: 8px; }
.choix label {
  display: flex; align-items: center; gap: 11px; padding: 12px 13px;
  border: 1.5px solid var(--trait); border-radius: var(--rayon-petit); cursor: pointer;
}
.choix label:has(input:checked) { border-color: var(--marque); background: var(--marque-pale); }
.choix input { accent-color: var(--marque); width: 19px; height: 19px; flex: none; }
.choix .texte { min-width: 0; }
.choix .texte b { display: block; font-weight: 600; font-size: 14.5px; }
.choix .texte span { display: block; font-size: 12.5px; color: var(--doux); margin-top: 1px; }

.message { font-size: 14px; padding: 11px 13px; border-radius: var(--rayon-petit); margin: 0 0 12px; }
.message:not(.bien) { background: var(--rouge-pale); color: var(--rouge); }
.message.bien { background: var(--vert-pale); color: var(--vert-fonce); }

/* ------------------------------------------------------------------- notes */
.notes {
  position: fixed; left: 12px; right: 12px; bottom: calc(76px + var(--bas));
  z-index: 70; display: grid; gap: 8px; pointer-events: none;
}
.note {
  background: var(--encre); color: var(--fond); padding: 12px 15px;
  border-radius: var(--rayon-petit); font-size: 14px; line-height: 1.4;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
  animation: monte .18s ease-out; max-width: 720px; margin: 0 auto; width: 100%;
}
.note.bien   { background: var(--vert-fonce); color: #fff; }
.note.erreur { background: var(--rouge); color: #fff; }

@media (min-width: 700px) {
  .vue { padding-top: 22px; }
  .grille-3 { grid-template-columns: repeat(3, 1fr); }
}
