/* Finly · Veilleuse — mise en page de l'appli, construite sur Nocturne (ds/nocturne.css) et les jetons
   Finly (ds/finly-jetons.css). Ici : uniquement des var(--…) des jetons, aucune couleur en dur. */

:root {
  /* Filet Nocturne : s'estompe sur 48 px à chaque bout. */
  --filet: linear-gradient(to right, transparent, var(--couleur-trait) 48px, var(--couleur-trait) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
  --filet-doux: linear-gradient(to right, transparent, color-mix(in srgb, var(--couleur-texte) 8%, transparent) 48px, color-mix(in srgb, var(--couleur-texte) 8%, transparent) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
  --largeur-nav: 224px;
  color-scheme: dark;
}
[data-mode="clair"] { color-scheme: light; }

html, body { background: var(--couleur-fond); }
body {
  color: var(--couleur-texte);
  font-family: var(--police);
  font-size: var(--taille-texte);
  font-variant-numeric: var(--chiffres);
}
a { color: var(--couleur-accent-texte); }
a:hover { color: var(--couleur-accent); }
input[type="checkbox"] { accent-color: var(--color-accent-500); width: 18px; height: 18px; margin: 0; cursor: pointer; }
.input[type="date"] { max-width: 200px; }
.small { font-size: var(--taille-petit); }
.mini { font-size: var(--taille-mini); }
.text-muted { color: var(--couleur-texte-attenue); }
.alerte { color: var(--couleur-alerte); }
.accent-texte { color: var(--couleur-accent-texte); }
.ico-accent { color: var(--couleur-accent); flex: none; }
.ico-alerte { color: var(--couleur-alerte); flex: none; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ---- Coquille ---------------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--largeur-nav) minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--espace-8) var(--espace-4);
  background: linear-gradient(to bottom, var(--couleur-surface), var(--couleur-fond) 70%);
}
.brand { font-size: 18px; font-weight: var(--graisse-titre); padding: 0 var(--espace-4) var(--espace-8); color: var(--couleur-texte); text-decoration: none; }
.brand:hover { color: var(--couleur-texte); }
.side ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side li a {
  display: flex; align-items: center; justify-content: space-between; min-height: 36px;
  padding: 0 var(--espace-4); border-radius: var(--rayon-moyen);
  color: var(--couleur-texte); text-decoration: none; font-size: 14px;
  transition: background var(--duree);
}
.side li a:hover { background: color-mix(in srgb, var(--couleur-texte) 7%, transparent); color: var(--couleur-texte); }
.side li a[aria-current="page"] { background: var(--couleur-accent-fond); color: var(--couleur-accent-texte); }
.side .count { font-size: var(--taille-mini); color: var(--couleur-texte-attenue); }
.side a[aria-current="page"] .count { color: inherit; }
.mode-toggle { margin-top: auto; align-self: flex-start; font-size: var(--taille-petit); color: var(--couleur-texte-attenue); }

main {
  padding: var(--espace-12) var(--espace-16) var(--espace-24);
  display: flex; flex-direction: column; gap: var(--espace-16);
  min-width: 0; max-width: 1120px; outline: none;
}
main.narrow { max-width: 860px; gap: var(--espace-12); }
.page { display: contents; }  /* le conteneur de page ne change pas la mise en page de <main> */

/* ---- Titres, en-tête ---------------------------------------------------------- */
.page-head { display: flex; align-items: center; gap: var(--espace-6); flex-wrap: wrap; }
.page-title, .page-head h1 { margin: 0; font-size: var(--taille-titre-page); }
.page-head .meta { margin-left: auto; font-size: var(--taille-petit); color: var(--couleur-texte-attenue); }
.section-title { margin: 0 0 var(--espace-3); font-size: var(--taille-titre-section); display: flex; align-items: baseline; gap: var(--espace-3); }
.section-title .count { font-size: var(--taille-petit); font-weight: var(--graisse-normale); color: var(--couleur-texte-attenue); }
.section-title.alerte, .section-title.alerte .count { color: var(--couleur-alerte); }
.section-head { display: flex; align-items: center; gap: var(--espace-4); margin-bottom: var(--espace-3); }
.section-head .section-title { margin: 0; flex: 1; }
section { display: flex; flex-direction: column; min-width: 0; }
.note { font-size: var(--taille-mini); color: var(--couleur-texte-attenue); margin: var(--espace-3) 0 0; }

/* ---- Onglets d'une brique ------------------------------------------------------- */
.tabs { display: flex; gap: var(--espace-6); overflow-x: auto; margin-top: calc(var(--espace-8) * -1); }
.tabs a {
  position: relative; padding: var(--espace-3) 0; white-space: nowrap;
  color: var(--couleur-texte-attenue); text-decoration: none; font-size: 14px;
}
.tabs a:hover { color: var(--couleur-texte); }
.tabs a[aria-current="page"] { color: var(--couleur-accent-texte); }
.tabs a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 20px; height: 2px;
  background: var(--couleur-accent); box-shadow: var(--lueur-accent);
}

/* ---- Chiffre clé ----------------------------------------------------------------- */
.hero { display: flex; flex-direction: column; gap: 6px; }
.hero .label { font-size: var(--taille-petit); color: var(--couleur-texte-attenue); }
.hero .figure { display: flex; align-items: baseline; gap: 2px; font-weight: var(--graisse-titre); letter-spacing: -0.02em; font-variant-numeric: proportional-nums; }
.hero .int { font-size: var(--taille-chiffre-cle); line-height: 1; }
.hero .dec { font-size: 30px; }
.accent-bar { width: 48px; height: 2px; background: var(--couleur-accent); box-shadow: var(--lueur-accent); margin-top: var(--espace-3); }

.cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--espace-24); }

/* ---- Lignes (comptes, banques, récurrents…) --------------------------------------- */
.row { display: flex; align-items: center; gap: var(--espace-4); min-height: 52px; background: var(--filet); }
.row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: var(--taille-mini); color: var(--couleur-texte-attenue); }
.amount { font-size: var(--taille-texte); text-align: right; white-space: nowrap; }
.strong { font-weight: var(--graisse-titre); }

/* Tableau en grille : en-tête + lignes, colonnes fixées par --cols sur le conteneur */
.grid-table { display: flex; flex-direction: column; }
.grid-table .gt-row {
  display: grid; grid-template-columns: var(--cols); gap: var(--espace-4); align-items: center;
  min-height: 44px; font-size: 14px; background: var(--filet);
}
.grid-table .gt-head { min-height: 0; padding: var(--espace-2) 0; font-size: var(--taille-mini); color: var(--couleur-texte-attenue); background: none; }
.grid-table.dense .gt-row:not(.gt-head) { min-height: 40px; background: var(--filet-doux); }
.grid-table .gt-head.ruled { background: var(--filet); }
.num { text-align: right; white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mobile-meta { display: none; }
.is-internal, .is-internal .text-muted { color: var(--couleur-texte-attenue); }
.cell-flex { display: flex; align-items: center; gap: var(--espace-3); min-width: 0; }

/* ---- Étiquettes et boutons propres à Finly ---------------------------------------- */
.tag { white-space: nowrap; flex: none; }
.tag-alerte { background: var(--couleur-alerte-fond); color: var(--couleur-alerte); }
.tag-discret { border: 1px solid var(--couleur-trait-fort); color: var(--couleur-texte-attenue); }
.btn { min-height: 36px; transition: background var(--duree); }
.btn-danger { color: var(--couleur-alerte); border-color: var(--couleur-alerte); }
.btn-danger:hover { background: var(--couleur-alerte-fond); }
.btn-ghost.plain { color: var(--couleur-texte); }
.btn-primary:disabled { opacity: 0.45; }
.btn-icon.round { border-radius: 50%; }

/* ---- Formulaires en carte ---------------------------------------------------------- */
.card-form {
  margin-top: var(--espace-6); padding: var(--espace-6); border-radius: var(--rayon-moyen);
  box-shadow: var(--ombre-1); display: flex; flex-direction: column; gap: var(--espace-4);
}
.card-form.roomy { padding: var(--espace-8); }
.card-form .form-title { font-size: var(--taille-titre-section); font-weight: var(--graisse-titre); }
.card-form .form-head { display: flex; align-items: center; }
.card-form .form-head .form-title { flex: 1; font-size: var(--taille-texte); }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: var(--espace-4); }
.actions { display: flex; gap: var(--espace-3); align-items: center; flex-wrap: wrap; }
.actions .push { margin-left: auto; }
.field-error { font-size: var(--taille-petit); color: var(--couleur-alerte); }
.input[aria-invalid="true"] { border-color: var(--couleur-alerte); }
.steps { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--espace-4); align-items: start; }
.step-num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: var(--taille-mini);
  box-shadow: inset 0 0 0 1px var(--couleur-accent); color: var(--couleur-accent-texte);
}
.step-body { display: flex; flex-direction: column; gap: var(--espace-3); font-size: 14px; }

/* ---- Bandeau d'avertissement, messages éphémères ------------------------------------- */
.notice, .toast {
  display: flex; align-items: flex-start; gap: var(--espace-4); padding: var(--espace-4) var(--espace-6);
  border-radius: var(--rayon-moyen); background: var(--couleur-surface); box-shadow: var(--ombre-2); font-size: 14px;
}
.notice svg { margin-top: 3px; }
.notice .notice-text { flex: 1; }
.toast {
  position: fixed; left: calc(var(--largeur-nav) + 40px); bottom: var(--espace-8); z-index: 10;
  align-items: center; max-width: 560px;
}
.toast[hidden] { display: none; }
.toast-text { flex: 1; }
.toast .btn-icon { width: 28px; height: 28px; min-height: 28px; color: var(--couleur-texte); }

/* ---- Chargement, erreur, vide -------------------------------------------------------- */
.skeleton { display: flex; flex-direction: column; gap: var(--espace-6); max-width: 440px; }
.skeleton .stack { display: flex; flex-direction: column; gap: var(--espace-3); }
.row-between { display: flex; justify-content: space-between; }
.skel { border-radius: var(--rayon-petit); background: var(--couleur-surface); }
.load-error { display: flex; flex-direction: column; gap: var(--espace-3); align-items: flex-start; }
.load-error p { margin: 0; }
.empty { padding: var(--espace-8) 0; font-size: 14px; color: var(--couleur-texte-attenue); margin: 0; }
.empty-big { padding: var(--espace-16) 0; display: flex; flex-direction: column; gap: var(--espace-2); }
.empty-big .lead { font-size: var(--taille-titre-section); }

/* ---- Filtres des opérations ------------------------------------------------------------ */
.filters { display: flex; align-items: center; gap: var(--espace-4); flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 240px; max-width: 360px; }
.search svg { position: absolute; left: 10px; top: 12px; opacity: 0.6; pointer-events: none; }
.search .input { padding-left: 34px; min-height: var(--hauteur-champ); }
.filters select.input { width: 220px; min-height: var(--hauteur-champ); }
.check-label { display: flex; align-items: center; gap: var(--espace-3); min-height: var(--hauteur-champ); font-size: 14px; cursor: pointer; }
.filters .total { margin-left: auto; font-size: 14px; }

/* ---- Tâches ------------------------------------------------------------------------------ */
.quick { display: flex; flex-direction: column; gap: var(--espace-3); }
.quick-line { display: flex; gap: var(--espace-3); align-items: center; }
.quick-line .input { flex: 1; min-height: var(--cible-tactile); font-size: var(--taille-texte); }
.quick-line .input.listening { border-color: var(--couleur-accent); }
.mic { width: var(--cible-tactile); height: var(--cible-tactile); flex: none; }
.mic.listening { width: auto; padding-inline: var(--espace-4); background: var(--couleur-accent-fond); box-shadow: var(--lueur-accent); }
.mic.off { opacity: 0.55; cursor: help; }
.mic .mic-label { display: none; }
.mic.listening .mic-label { display: inline; }
.quick .hint { font-size: var(--taille-petit); color: var(--couleur-texte-attenue); margin: 0; }
.quick .hint.live { color: var(--couleur-accent-texte); }
.quick .add-mobile { display: none; }

.task { display: flex; flex-direction: column; background: var(--filet); }
.task-line { display: flex; align-items: center; gap: var(--espace-3); min-height: 48px; }
.task-check { width: 36px; height: 44px; display: grid; place-items: center; flex: none; cursor: pointer; }
.task-title {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: var(--espace-3) 0;
  font: inherit; font-size: var(--taille-texte); color: var(--couleur-texte); cursor: pointer;
  display: flex; flex-direction: column; gap: 1px; border-radius: var(--rayon-petit);
}
.task-title .due-inline { display: none; font-size: var(--taille-mini); color: var(--couleur-texte-attenue); }
.task .due { font-size: var(--taille-petit); color: var(--couleur-texte-attenue); white-space: nowrap; }
.task.late .due, .task.late .due-inline { color: var(--couleur-alerte); }
.star { width: 40px; height: 40px; min-height: 40px; }
.star[aria-pressed="false"] { color: var(--couleur-texte-attenue); }
.task.done .task-title { text-decoration: line-through; color: var(--couleur-texte-attenue); cursor: default; }
.task-edit { margin: 0 0 var(--espace-6) 48px; display: flex; flex-direction: column; gap: var(--espace-4); max-width: 560px; }
.task-edit textarea.input { min-height: 72px; }
.confirm {
  display: flex; align-items: center; gap: var(--espace-3); padding: var(--espace-4);
  border-radius: var(--rayon-moyen); background: var(--couleur-alerte-fond);
}
.confirm span { flex: 1; font-size: 14px; }
.fold {
  display: flex; align-items: center; gap: var(--espace-3); min-height: var(--cible-tactile); align-self: flex-start;
  background: none; border: 0; padding: 0; font: inherit; font-size: var(--taille-titre-section); color: var(--couleur-texte); cursor: pointer;
}
.fold svg { transition: transform var(--duree); }
.fold[aria-expanded="false"] svg { transform: rotate(-90deg); }

/* ---- Graphique (chart.js) : l'accent du thème, validé en sombre et en clair --------------- */
.chart { position: relative; margin-top: var(--espace-4); }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--couleur-trait); stroke-width: 1; }
.chart .tick { fill: var(--couleur-texte-attenue); font: 12px var(--police); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--couleur-accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--couleur-accent); stroke: var(--couleur-fond); stroke-width: 2; }
.chart .cross { stroke: var(--couleur-trait-fort); stroke-width: 1; }
.chart .end-label { fill: var(--couleur-texte); font: 500 13px var(--police); font-variant-numeric: tabular-nums; }
.chart rect:focus-visible { outline: 2px solid var(--couleur-accent); outline-offset: -2px; }
.chart-tip {
  position: absolute; pointer-events: none; min-width: 140px; padding: var(--espace-3) var(--espace-4);
  background: var(--couleur-surface); box-shadow: var(--ombre-2); border-radius: var(--rayon-moyen);
  display: grid; gap: 2px; font-size: var(--taille-mini); color: var(--couleur-texte-attenue);
}
.chart-tip strong { color: var(--couleur-texte); font-size: 14px; font-weight: var(--graisse-titre); }
.chart .line.forecast { stroke-dasharray: 2 5; opacity: .75; }
.chart .target { stroke: var(--couleur-texte-attenue); stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart .target-label { fill: var(--couleur-texte-attenue); font: 500 12px var(--police); font-variant-numeric: tabular-nums;
  paint-order: stroke; stroke: var(--couleur-fond); stroke-width: 4px; stroke-linejoin: round; }  /* halo : lisible sur les barres */
.chart .baseline { stroke: var(--couleur-trait-fort); }
.chart .bar { fill: var(--couleur-accent); transition: opacity var(--duree); }
.chart .bar.ghost { fill: var(--couleur-accent-fond); stroke: var(--couleur-accent); stroke-width: 1.5; stroke-dasharray: 3 3; }
.chart .bar.dim { opacity: .4; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--espace-2) var(--espace-6); margin-top: var(--espace-2); font-size: var(--taille-mini); color: var(--couleur-texte-attenue); }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 16px; flex: none; }
.swatch-line { border-top: 2px solid var(--couleur-accent); }
.swatch-forecast { border-top: 2px dotted var(--couleur-accent); }
.swatch-target { border-top: 2px dashed var(--couleur-texte-attenue); }
.swatch-bar, .swatch-ghost { height: 10px; width: 10px; border-radius: 2px; background: var(--couleur-accent); }
.swatch-ghost { background: var(--couleur-accent-fond); border: 1.5px dashed var(--couleur-accent); }

/* ---- Objectif d'épargne ------------------------------------------------------------------ */
.goal-status { display: flex; flex-direction: column; gap: 4px; margin-top: var(--espace-3); max-width: 70ch; }
.goal-status strong { display: inline-flex; align-items: center; gap: 8px; font-weight: var(--graisse-titre); }
.goal-ko { color: var(--couleur-alerte); }
.goal-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--espace-2) var(--espace-3); margin-top: var(--espace-3); font-size: 14px; }
.goal-form label { color: var(--couleur-texte-attenue); }
.goal-form .field-hint { flex-basis: 100%; margin-top: 0; }
.tracking-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--espace-2) var(--espace-4); }
.month-rows { margin-top: var(--espace-6); }
.sub-h { margin: var(--espace-4) 0 0; }
@media (max-width: 720px) { .seg.seg-3 { grid-template-columns: repeat(3, 1fr); width: 100%; } }
details.values { margin-top: var(--espace-3); font-size: 14px; }
details.values summary { cursor: pointer; color: var(--couleur-accent-texte); font-size: var(--taille-petit); min-height: 32px; display: flex; align-items: center; }

/* ---- Mobile : navigation en bas, cibles de 44 px ----------------------------------------- */
@media (max-width: 1000px) {
  .cols { grid-template-columns: minmax(0, 1fr); gap: var(--espace-12); }
}
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; inset: auto 0 0 0; height: auto; z-index: 5; flex-direction: row;
    padding: var(--espace-1) var(--espace-3) calc(var(--espace-6) + env(safe-area-inset-bottom));
    background: var(--couleur-surface);
  }
  .brand, .mode-toggle { display: none; }
  .side ul { flex-direction: row; flex: 1; }
  .side li { flex: 1; }
  .side li a {
    flex-direction: column; justify-content: center; gap: 5px; min-height: 52px; padding: 0;
    font-size: var(--taille-petit); background: none !important; border-radius: 0;
  }
  .side li a::before { content: ""; width: 20px; height: 2px; background: transparent; }
  .side li a[aria-current="page"]::before { background: var(--couleur-accent); box-shadow: var(--lueur-accent); }
  .side .count { display: none; }

  main { padding: var(--espace-6) var(--espace-8) calc(var(--espace-16) + 96px); gap: var(--espace-12); }
  main.narrow { padding-inline: var(--espace-6); padding-bottom: calc(var(--espace-16) + 170px); gap: var(--espace-8); }
  .page-title, .page-head h1 { font-size: 22px; }
  .page-head .meta { display: none; }
  .page-head .btn .btn-label { display: none; }
  .page-head .btn { width: var(--cible-tactile); height: var(--cible-tactile); padding: 0; }
  .hero .int { font-size: var(--taille-chiffre-cle-mobile); }
  .hero .dec { font-size: 26px; }
  .tabs { margin-top: calc(var(--espace-6) * -1); }

  .row { min-height: 56px; }
  .row-title { font-size: var(--taille-texte); }
  .btn, .input { min-height: var(--cible-tactile); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .filters { flex-direction: column; align-items: stretch; gap: var(--espace-3); }
  .search { max-width: none; }
  .filters select.input { width: 100%; }
  .filters .total { margin-left: 0; font-size: var(--taille-petit); }

  .grid-table .hide-mobile { display: none; }
  .grid-table .gt-row { grid-template-columns: var(--cols-mobile, var(--cols)); min-height: 56px; }
  .grid-table .gt-head { min-height: 0; }
  .mobile-meta { display: block; font-size: var(--taille-mini); color: var(--couleur-texte-attenue); }

  .toast { left: var(--espace-4); right: var(--espace-4); bottom: 84px; max-width: none; }
  body:has(.quick) .toast { bottom: 164px; }

  /* Tâches : saisie en bas, au-dessus de la navigation */
  .quick {
    position: fixed; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 4;
    padding: var(--espace-4) var(--espace-4) var(--espace-3);
    background: linear-gradient(to right, transparent, var(--couleur-trait) 48px, var(--couleur-trait) calc(100% - 48px), transparent) no-repeat top / 100% 1px, var(--couleur-fond);
  }
  .quick-line .input { min-height: 48px; font-size: 16px; }
  .mic { width: 52px; height: 52px; border-radius: 50%; order: 2; }
  .mic.listening { width: 52px; padding: 0; box-shadow: var(--lueur-accent), 0 0 0 6px color-mix(in srgb, var(--couleur-accent) 18%, transparent); }
  .mic.listening .mic-label { display: none; }
  .quick .add-desktop { display: none; }
  .quick .add-mobile { display: inline-flex; order: 3; min-height: 48px; }
  .quick .add-mobile[hidden] { display: none; }
  .quick .hint { font-size: var(--taille-mini); padding: 0 var(--espace-2); }
  .task-line { min-height: 56px; gap: 0; }
  .task-check { width: 44px; height: 48px; }
  .task-title .due-inline { display: block; }
  .task .due { display: none; }
  .star { width: var(--cible-tactile); height: var(--cible-tactile); }
  .task-edit { margin: 0 var(--espace-2) var(--espace-6); }
  .confirm { flex-direction: column; align-items: stretch; }
}

/* ---- Catégories ---------------------------------------------------------------------------- */
.cat-select { min-height: 32px; padding-block: 3px; font-size: var(--taille-petit); max-width: 100%; }
.cat-select.cat-todo { border-color: var(--couleur-accent); color: var(--couleur-accent-texte); }
.row .cat-select { width: 200px; flex: none; }

/* Barres horizontales triées : une teinte (l'accent), extrémité arrondie, valeur au bout de la barre */
.bars { display: flex; flex-direction: column; gap: var(--espace-3); max-width: 920px; }
.bar-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) 240px; gap: var(--espace-4); align-items: center; min-height: 28px; font-size: 14px; }
.bar-track { display: flex; align-items: center; gap: var(--espace-3); min-width: 0; }
.bar { height: 14px; background: var(--couleur-accent); border-radius: 0 var(--rayon-petit) var(--rayon-petit) 0; flex: none; }
.bar-row.is-todo .bar { background: var(--couleur-trait-fort); }
.bar-value { white-space: nowrap; font-size: var(--taille-petit); }
.bar-current { white-space: nowrap; }

@media (max-width: 720px) {
  .bar-row { grid-template-columns: minmax(0, 1fr); gap: var(--espace-1); }
  .bar-current { display: none; }
  .row .cat-select { width: 150px; }
}

/* ---- Affichage : masquer vraiment, mobile / ordinateur ---------------------------------------- */
[hidden] { display: none !important; }  /* sinon un display: flex/grid l'emporte sur l'attribut hidden */
.only-mobile { display: none; }
.filter-pair { display: contents; }     /* ordinateur : les deux listes restent dans la ligne de filtres */
.bar { max-width: calc(100% - 9.5rem); } /* garde la place de la valeur au bout de la plus longue barre */

@media (max-width: 720px) {
  .hide-mobile { display: none !important; }
  .only-mobile { display: revert; }
  .row-sub, .mobile-meta { font-size: var(--taille-petit); }
  .side li a { font-size: 14px; }

  /* Onglets : libellés courts, défilement discret si besoin */
  .tabs { gap: var(--espace-4); scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }

  /* Filtres des opérations : les deux listes côte à côte */
  .filter-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--espace-3); }
  .filter-pair select.input { width: 100%; }

  /* Récurrents : nom et étiquettes sur une ligne qui peut passer à la ligne, décision en dessous */
  .cell-flex { flex-wrap: wrap; row-gap: 2px; }
  .grid-table .decision-cell { grid-column: 1 / -1; padding-bottom: var(--espace-3); }
  .grid-table .decision-cell select { width: 100%; min-height: var(--cible-tactile); }

  /* À classer : nom et montant, puis la liste des catégories sur toute la largeur */
  .todo-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--espace-2); padding: var(--espace-3) 0; }
  .row.todo-row .cat-select { grid-column: 1 / -1; width: 100%; min-height: var(--cible-tactile); }

  /* Micro disponible : contour accent, comme dans la maquette */
  .mic:not(.off):not(.listening) { color: var(--couleur-accent); border-color: var(--couleur-accent); }
}

/* ---- Assistant ---------------------------------------------------------------------------- */
.thread { display: flex; flex-direction: column; gap: var(--espace-6); }
.thread:empty { display: none; }
.msg { max-width: 92%; font-size: var(--taille-texte); line-height: 1.6; overflow-wrap: anywhere; }
.msg-user {
  align-self: flex-end; padding: var(--espace-3) var(--espace-6); border-radius: var(--rayon-moyen);
  background: var(--couleur-surface); box-shadow: var(--ombre-1); white-space: pre-wrap;
}
.msg-ai { align-self: flex-start; padding-left: var(--espace-6); box-shadow: inset 2px 0 0 var(--couleur-accent); }
.msg-ai p { margin: 0 0 var(--espace-3); }
.msg-ai p:last-child { margin-bottom: 0; }
.msg-ai ul { margin: 0 0 var(--espace-3); padding-left: var(--espace-8); }
.msg-ai li { margin-bottom: var(--espace-1); }
.msg-ai strong { font-weight: var(--graisse-titre); color: var(--couleur-accent-texte); }
.msg-pending { display: flex; align-items: center; gap: var(--espace-3); color: var(--couleur-texte-attenue); }
.msg-error { color: var(--couleur-alerte); box-shadow: inset 2px 0 0 var(--couleur-alerte); }
.ask-form { display: flex; flex-direction: column; gap: var(--espace-3); }
.ask-input { min-height: 72px; font-size: var(--taille-texte); }
.chips { display: flex; flex-wrap: wrap; gap: var(--espace-3); }
.chip { font-size: var(--taille-petit); font-weight: var(--graisse-normale); text-align: left; }

@media (max-width: 720px) {
  .msg { max-width: 100%; }
  .ask-input { font-size: 16px; }  /* évite le zoom automatique d'iOS sur les champs < 16 px */
  .ask-form .actions .mini { display: none; }
}

/* ---- Formulaires longs (profil, biens, crédits) ------------------------------------------------ */
.form-group { margin: var(--espace-4) 0 0; font-size: var(--taille-texte); font-weight: var(--graisse-titre); color: var(--couleur-accent-texte); }
.form-group:first-child { margin-top: 0; }
.form-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--espace-4) var(--espace-6); align-items: start; }
.field-hint { display: block; margin-top: 5px; font-size: var(--taille-mini); color: var(--couleur-texte-attenue); }
.label-like { display: block; font-size: 12px; margin-bottom: 5px; color: color-mix(in srgb, var(--couleur-texte) 70%, transparent); }
.seg { flex-wrap: wrap; }
.objectives { display: flex; flex-direction: column; gap: var(--espace-3); }
.objective {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) 90px 130px 110px auto;
  gap: var(--espace-3); align-items: end; padding-bottom: var(--espace-3); background: var(--filet);
}
.objective .btn-icon { margin-bottom: 2px; }

@media (max-width: 720px) {
  .form-cols { grid-template-columns: minmax(0, 1fr); }
  .objective { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .objective .field:first-child, .objective .field:nth-child(2) { grid-column: 1 / -1; }
  .seg { display: grid; grid-template-columns: 1fr 1fr; }
  .seg-opt { justify-content: center; min-height: var(--cible-tactile); }
  .seg-opt + .seg-opt { border-left: 0; }
}

/* ---- Lignes modifiables, en-têtes de section, onglets nombreux -------------------------------- */
.section-head { flex-wrap: wrap; }
@media (max-width: 720px) {
  .tabs { flex-wrap: wrap; row-gap: 0; overflow: visible; }  /* 6 onglets : passage à la ligne plutôt que coupés */
  .section-head .section-title { flex-basis: 100%; }
  .row.editable {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main amount" "tag action";
    row-gap: 0; padding: var(--espace-3) 0;
  }
  .row.editable .row-main { grid-area: main; }
  .row.editable .amount { grid-area: amount; }
  .row.editable .row-tag { grid-area: tag; justify-self: start; }
  .row.editable .row-action { grid-area: action; justify-self: end; }
}

/* ---- Bilan ---------------------------------------------------------------------------------------- */
.check-list { margin: var(--espace-2) 0; padding-left: var(--espace-8); display: flex; flex-direction: column; gap: var(--espace-1); }
.notice-text strong { font-weight: var(--graisse-titre); }
.bars-compact .bar-row { grid-template-columns: 200px minmax(0, 1fr); }
.bars-compact .bar { max-width: calc(100% - 11rem); }
@media (max-width: 720px) {
  .bars-compact .bar-row { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Rapport IA ------------------------------------------------------------------------------------ */
.report-toolbar { display: flex; flex-wrap: wrap; gap: var(--espace-3); align-items: center; }
.report { display: flex; flex-direction: column; gap: var(--espace-8); max-width: 760px; }
.report-lead { font-size: var(--taille-titre-section); line-height: 1.6; margin: 0; }
.report-h { font-size: var(--taille-titre-section); margin: 0 0 var(--espace-3); }
.report-item { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: var(--espace-4); padding: var(--espace-4) 0; background: var(--filet); }
.report-item svg { margin-top: 4px; }
.report-item p, .report-steps p { margin: var(--espace-1) 0 0; color: color-mix(in srgb, var(--couleur-texte) 85%, transparent); line-height: 1.6; }
.report-item-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--espace-3); }
.report strong { font-weight: var(--graisse-titre); }
.report-steps { list-style: none; margin: 0; padding: 0; }
.report-steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--espace-4); padding: var(--espace-4) 0; background: var(--filet); }
.report-questions { margin: 0; padding-left: var(--espace-8); display: flex; flex-direction: column; gap: var(--espace-2); line-height: 1.6; }
.report-check { display: flex; gap: var(--espace-3); align-items: flex-start; margin: 0; font-size: var(--taille-petit); color: var(--couleur-texte-attenue); }
.report-check svg { margin-top: 2px; }

/* Impression / PDF : seulement le rapport */
@media print {
  .side, .tabs, .page-head, .notice:not(.report .notice), .no-print, .toast { display: none !important; }
  .app { display: block; }
  main { padding: 0; max-width: none; }
  html, body { background: #fff; color: #000; }
  .report-item, .report-steps li { background: none; border-bottom: 1px solid #ccc; }
}

/* ---- Réglages de l'assistant ---- */
.assistant-settings { display: flex; flex-wrap: wrap; gap: var(--espace-3) var(--espace-8); align-items: flex-end; }
.assistant-settings .field-hint { flex-basis: 100%; margin-top: 0; }

/* ---- IA privée ------------------------------------------------------------------------------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.text-alerte { color: var(--couleur-alerte); }
.setup-steps { margin: var(--espace-2) 0 0; padding-left: 1.2em; display: grid; gap: 4px; font-size: 14px; }
.session-card {
  display: flex; flex-direction: column; gap: var(--espace-3); padding: var(--espace-6);
  border-radius: var(--rayon-moyen); background: var(--couleur-surface);
}
.session-head { display: flex; align-items: center; gap: var(--espace-2); flex-wrap: wrap; font-size: var(--taille-titre-section); }
.session-head .text-muted { font-size: 14px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--couleur-texte-attenue); }
.status-prete { background: var(--couleur-accent); }
.status-installation { background: transparent; border: 2px solid var(--couleur-accent); }
.status-suppression { background: var(--couleur-alerte); }
.session-line { display: flex; align-items: center; gap: var(--espace-2); margin: 0; font-size: 14px; }
.session-line svg { flex: none; }
.session-head strong { margin-right: var(--espace-1); }
.session-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--espace-3); margin-top: var(--espace-2); }
.credentials { display: flex; flex-direction: column; gap: 2px; }
.credentials-pwd { display: flex; align-items: center; gap: var(--espace-1); }
.mono-input { font-variant-numeric: tabular-nums; letter-spacing: .02em; width: auto; }
.offer-list { display: flex; flex-direction: column; gap: var(--espace-2); }
.offer {
  display: flex; align-items: center; gap: var(--espace-4); padding: var(--espace-4); cursor: pointer;
  border: 1px solid var(--couleur-trait); border-radius: var(--rayon-moyen);
}
.offer:hover { border-color: var(--couleur-trait-fort); }
.offer:has(input:checked) { border-color: var(--couleur-accent); background: var(--couleur-accent-fond); }
.offer:has(input:focus-visible) { outline: 2px solid var(--couleur-accent); outline-offset: 2px; }
.offer input { accent-color: var(--couleur-accent); margin: 0; flex: none; }
.offer-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.offer-title { display: flex; align-items: center; gap: var(--espace-2); flex-wrap: wrap; font-weight: var(--graisse-titre); }
.offer-price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.zones { display: flex; flex-wrap: wrap; gap: 2px var(--espace-3); font-size: var(--taille-mini); margin-top: 2px; }
.zone { display: inline-flex; align-items: center; gap: 5px; color: var(--couleur-texte-attenue); }
.zone::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--couleur-trait-fort); }
.zone-available { color: var(--couleur-texte); }
.zone-available::before { background: var(--couleur-accent); }
.zone-scarce::before { background: transparent; border: 1.5px solid var(--couleur-accent); }
.zone-shortage::before { background: var(--couleur-alerte); }
.start-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--espace-3) var(--espace-4); font-size: 14px; }
.start-row .btn { margin-left: auto; }
@media (max-width: 720px) {
  .start-row .btn { margin-left: 0; width: 100%; }
  .session-actions .btn, .session-actions a.btn { flex: 1 1 auto; }
}

/* ---- Vast.ai --------------------------------------------------------------------------------- */
.logs {
  margin: 0; max-height: 260px; overflow: auto; padding: var(--espace-3); border-radius: var(--rayon-moyen);
  background: var(--couleur-fond); font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-all;
}
.key-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--espace-1); font-size: 14px; }
.key-list li { display: flex; align-items: center; gap: var(--espace-2); }
.key-add { display: flex; gap: var(--espace-3); align-items: flex-start; flex-wrap: wrap; }
.key-add textarea { flex: 1 1 320px; }
.deploy-panel { min-width: 0; max-width: 100%;
  display: flex; flex-direction: column; gap: var(--espace-3); margin: var(--espace-2) 0 var(--espace-4);
  padding: var(--espace-4); border: 1px solid var(--couleur-accent); border-radius: var(--rayon-moyen); background: var(--couleur-accent-fond);
}
.price-detail { display: grid; grid-template-columns: max-content 1fr; gap: 4px var(--espace-4); margin: var(--espace-2) 0 0; font-size: 13px; }
.price-detail dt { color: var(--couleur-texte-attenue); }
.price-detail dd { margin: 0; font-variant-numeric: tabular-nums; }
.price-box summary { cursor: pointer; color: var(--couleur-accent-texte); }
.offers-table .gt-row .num { font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .price-detail { grid-template-columns: 1fr; gap: 0; } .price-detail dd { margin-bottom: var(--espace-2); } }

/* ---- Connexion ------------------------------------------------------------------------------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--espace-6); }
.login-card {
  display: flex; flex-direction: column; gap: var(--espace-3); width: min(360px, 100%); padding: var(--espace-8);
  border-radius: var(--rayon-moyen); background: var(--couleur-surface); box-shadow: var(--ombre-2);
}
.login-card label { font-size: var(--taille-petit); color: var(--couleur-texte-attenue); }
.login-card .btn { margin-top: var(--espace-2); min-height: var(--cible-tactile); }
.login-brand { margin: 0 0 var(--espace-4); font-size: var(--taille-titre-page); }
.login-error { margin: 0; font-size: var(--taille-petit); color: var(--couleur-alerte); }
.logout { margin: 0; }
