/* Tableau de bord TARN COMPTA — feuille unique.
   Palette, typographie et mise en page reprises du modèle « Rentabilité
   mensuelle » (31EME SIECLE) choisi par le cabinet : encre marine, accent bleu,
   sarcelle pour ce qui va bien, rouge pour les pertes, Fraunces pour les titres
   et Inter pour le reste. Polices servies par le site (aucun appel à Google). */

@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('polices/fraunces-latin-variable.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('polices/inter-latin-variable.woff2') format('woff2'); }

:root {
  --paper: #FBFCFE; --surface: #FFFFFF; --ink: #14213D; --muted: #5B6782; --rule: #DDE3EE; --rule-strong: #B9C3D6;
  --accent: #1E3FCC; --accent-soft: #E8ECFB; --teal: #1F8C8C; --teal-soft: #E2F5F5; --loss: #B3261E; --loss-soft: #FBEAE8;
  --synth: #F3F5FA; --input: #FFFFFF; --gold: #8A5A00; --gold-soft: #FFF3D6;
  --titre: Fraunces, Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F1626; --surface: #151E33; --ink: #E6EBF5; --muted: #99A5BF; --rule: #26324D; --rule-strong: #3A4868;
    --accent: #7D95FF; --accent-soft: #1D2A55; --teal: #6FD3D3; --teal-soft: #123638; --loss: #FF8A80; --loss-soft: #3A1C1F;
    --synth: #1A2440; --input: #0F1626; --gold: #F0C060; --gold-soft: #33290F;
  }
}
:root[data-theme="dark"] {
  --paper: #0F1626; --surface: #151E33; --ink: #E6EBF5; --muted: #99A5BF; --rule: #26324D; --rule-strong: #3A4868;
  --accent: #7D95FF; --accent-soft: #1D2A55; --teal: #6FD3D3; --teal-soft: #123638; --loss: #FF8A80; --loss-soft: #3A1C1F;
  --synth: #1A2440; --input: #0F1626; --gold: #F0C060; --gold-soft: #33290F;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; font-family: var(--titre); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 28px; line-height: 1.1; }
h2 { font-size: 18px; margin-bottom: 12px; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, textarea:focus-visible, summary:focus-visible,
tr.grp:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.aide { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.num { text-align: right; white-space: nowrap; }
.droite { text-align: right; }

/* --- Barre de l'application --------------------------------------------------- */
.entete {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px;
  padding: 10px 28px; padding-top: max(10px, env(safe-area-inset-top, 0px));
  background: var(--surface); border-bottom: 1px solid var(--rule);
}
.marque { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.marque:hover { text-decoration: none; }
.marque strong { display: block; font-size: 13px; letter-spacing: .06em; }
.marque small { display: block; color: var(--muted); font-size: 12px; margin-top: -1px; }
.pastille {
  width: 30px; height: 30px; border-radius: 7px; background: var(--accent);
  display: inline-flex; align-items: flex-end; justify-content: center; gap: 3px; padding: 7px 6px;
}
.pastille i { display: block; width: 4px; background: #fff; border-radius: 1px; }
.pastille i:nth-child(1) { height: 40%; } .pastille i:nth-child(2) { height: 70%; } .pastille i:nth-child(3) { height: 100%; }
.nav-principale { display: flex; gap: 4px; flex: 1; }
.nav-principale a { padding: 6px 11px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav-principale a:hover { background: var(--synth); color: var(--ink); text-decoration: none; }
.nav-principale a.actif { background: var(--accent-soft); color: var(--accent); }
.entete-droite { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.btn-icone { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); cursor: pointer; }
.menu-utilisateur { position: relative; }
.menu-utilisateur summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 2px; border-radius: 6px; }
.menu-utilisateur summary::-webkit-details-marker { display: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.nom-utilisateur { font-weight: 500; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-deroulant { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; padding: 6px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; box-shadow: 0 8px 24px rgba(20, 33, 61, .12); }
.menu-deroulant a { display: block; padding: 7px 10px; border-radius: 5px; color: var(--ink); }
.menu-deroulant a:hover { background: var(--synth); text-decoration: none; }
.form-deconnexion button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 5px; font-size: 14px; }
.form-deconnexion button:hover { background: var(--synth); color: var(--ink); }
.menu-email { padding: 7px 10px; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--rule); margin-bottom: 4px; word-break: break-all; }

/* --- Mise en page générale ----------------------------------------------------- */
.contenu { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 28px 32px; flex: 1; }
.contenu-plein { max-width: none; padding: 0; }
.pied { color: var(--muted); font-size: 12px; padding: 14px 28px 24px; }
.titre-page { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.panneau { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.panneau.etroit { max-width: 480px; }
.panneau.vide { text-align: center; padding: 40px 20px; }
details.panneau summary { cursor: pointer; }
details.panneau[open] summary { margin-bottom: 14px; }
.colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.colonnes > .panneau { margin-bottom: 0; }
.colonnes + .panneau, .colonnes + section { margin-top: 20px; }
.colonnes.trois { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.etat h2 { margin-bottom: 8px; }

/* --- Formulaires et boutons ----------------------------------------------------- */
.formulaire { display: flex; flex-direction: column; gap: 14px; }
.formulaire.en-ligne { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
label.case { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--input); border: 1px solid var(--rule-strong); border-radius: 6px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-strong); border-radius: 6px; padding: 6px 11px; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-principal { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; padding: 8px 14px; }
.btn-principal:hover { color: #fff; filter: brightness(1.08); }
.btn-discret { border-color: transparent; background: transparent; color: var(--muted); }
.btn-petit { padding: 4px 9px; font-size: 12.5px; }
.lien-discret { text-align: center; font-size: 13px; color: var(--muted); }
.recherche input { min-width: 260px; }
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 6px; background: var(--synth); border: 1px solid var(--rule); word-break: break-word; }
.flash.success { background: var(--teal-soft); color: var(--teal); border-color: transparent; }
.flash.danger { background: var(--loss-soft); color: var(--loss); border-color: transparent; }
.flash.warning { background: var(--gold-soft); color: var(--gold); border-color: transparent; }

.btn-passkey { width: 100%; padding: 10px 14px; font-size: 14px; }
.btn-danger:hover { border-color: var(--loss); color: var(--loss); }
.separateur { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 6px 0 18px; }
.separateur::before, .separateur::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
form.renommer { display: flex; gap: 6px; align-items: center; }
form.renommer input { padding: 4px 8px; max-width: 220px; }
#passkey-etat:empty { display: none; }
.centre { text-align: center; }

/* --- Pages seules (connexion, activation) -------------------------------------- */
.page-seule { align-items: center; justify-content: center; padding: 32px 16px; }
.carte-seule { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 32px; }
.marque-centre { justify-content: center; margin-bottom: 24px; }
.carte-seule h1 { font-size: 24px; }
.mention-seule { color: var(--muted); font-size: 12px; margin-top: 16px; }

/* --- Tableaux de l'espace cabinet ------------------------------------------------ */
.tableau-donnees { width: 100%; border-collapse: collapse; }
.tableau-donnees th { text-align: left; font-weight: 600; font-size: 12.5px; padding: 6px 9px; border-bottom: 2px solid var(--ink); }
.tableau-donnees td { padding: 7px 9px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.tableau-donnees tr:last-child td { border-bottom: 0; }
.tableau-donnees td.vide { text-align: center; color: var(--muted); padding: 24px; }
.panneau:has(> .tableau-donnees) { overflow-x: auto; }
.etiquette { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--synth); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.etiquette.ok { background: var(--teal-soft); color: var(--teal); }
.etiquette.ko { background: var(--loss-soft); color: var(--loss); }
.etiquette.attente { background: var(--gold-soft); color: var(--gold); }
.fiche { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 20px; }
.fiche dt { color: var(--muted); }
.fiche dd { margin: 0; font-weight: 500; }
.liste-simple { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.choix-dossiers { border: 1px solid var(--rule); border-radius: 6px; padding: 12px; margin: 0; }
.choix-dossiers legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
.liste-cases { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }

/* --- Accueil : cartes de dossiers ------------------------------------------------- */
.grille-dossiers { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.carte-dossier { display: flex; flex-direction: column; gap: 2px; padding: 18px; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; }
.carte-dossier:hover { text-decoration: none; border-color: var(--accent); }
.carte-dossier strong { font-family: var(--titre); font-size: 17px; font-weight: 600; }
.carte-dossier span { color: var(--muted); }
.carte-dossier small { color: var(--muted); margin-top: 8px; }

/* =====================================================================
   Calcul de rentabilité mensuel (reprise fidèle du modèle 31EME SIECLE)
   ===================================================================== */
.rt-header { max-width: 1100px; padding: 32px 28px 8px; }
.rt-firm { font-size: 13px; color: var(--muted); margin: 0 0 18px; }
.rt-header h1 { font-size: 40px; line-height: 1.05; }
.rt-sub { margin: 8px 0 0; color: var(--muted); }
.rt-choix { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.rt-choix select { width: auto; font-size: 13px; padding: 5px 8px; }
.verdict { font-family: var(--titre); font-size: 21px; line-height: 1.4; max-width: 62ch; margin: 22px 0 4px; }
.verdict b { font-weight: 600; }
.verdict .neg { color: var(--loss); } .verdict .pos { color: var(--teal); }
.rt-message { max-width: 80ch; margin: 14px 0 0; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); white-space: pre-wrap; }
.rt-message b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-bottom: 2px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 28px; align-items: center; }
.hint { color: var(--muted); font-size: 12.5px; margin-left: auto; max-width: 56ch; }
.rt-source { color: var(--muted); font-size: 12px; }
.rt-source b { color: var(--accent); font-weight: 600; }
.wrap { overflow: auto; max-height: calc(100vh - 40px); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: var(--surface); }
#t { border-collapse: separate; border-spacing: 0; min-width: 100%; }
#t th, #t td { padding: 5px 9px; min-width: 74px; border-bottom: 1px solid var(--rule); white-space: nowrap; text-align: right; }
#t thead th { position: sticky; top: 0; z-index: 3; background: var(--surface); font-weight: 600; font-size: 12.5px; border-bottom: 2px solid var(--ink); vertical-align: bottom; }
#t .lab { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; min-width: 320px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--rule); }
#t thead .lab { z-index: 4; }
.acc { font-size: 11.5px; color: var(--muted); margin-right: 8px; }
.mon label { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; cursor: pointer; font-weight: 600; font-size: 12.5px; }
.mon input { margin: 0; accent-color: var(--accent); }
.mon small, small.nbm { font-weight: 400; color: var(--muted); font-size: 11px; }
#t td.off, #t th.off { color: var(--muted); opacity: .55; }
#t .syn { background: var(--synth); }
#t .sep { border-left: 2px solid var(--rule-strong); }
#t tr.grp td { font-weight: 600; background: var(--paper); cursor: pointer; border-top: 1px solid var(--rule-strong); }
#t tr.grp td.lab { background: var(--paper); }
#t tr.grp td.syn { background: var(--synth); }
.caret { display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
tr.grp.closed .caret { transform: rotate(-90deg); }
tr.det.hide { display: none; }
#t tr.det td { font-size: 13px; }
#t tr.det.empty td:not(.lab):not(.saisie) { color: var(--muted); }
.chip { font-size: 11px; font-weight: 600; padding: 1px 0; width: 22px; border-radius: 4px; margin-right: 6px; line-height: 16px; display: inline-block; text-align: center; }
.chip.F { background: var(--surface); color: var(--muted); }
.chip.V { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.V:hover { color: #fff; }
#t td.saisie { padding: 2px 4px; }
#t td.saisie input { width: 92px; font: inherit; font-size: 13px; text-align: right; color: var(--ink); background: var(--input); border: 1px solid var(--rule-strong); border-radius: 4px; padding: 3px 6px; font-variant-numeric: tabular-nums; }
#t td.saisie input::placeholder { color: var(--muted); font-style: italic; opacity: .8; }
#t td.saisie input.set { border-color: var(--accent); background: var(--accent-soft); }
#t tbody.ana tr.title td { font-family: var(--titre); font-size: 17px; font-weight: 600; text-align: left; padding-top: 22px; border-bottom: 2px solid var(--ink); background: var(--surface); }
#t tbody.ana td { font-weight: 500; }
#t tbody.ana tr.key td { font-weight: 600; }
#t tbody.ana tr.res td { border-top: 1px solid var(--ink); }
#t .neg { color: var(--loss); }
#t tr.sr td { background: var(--accent-soft); border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); padding-top: 9px; padding-bottom: 9px; vertical-align: top; }
#t tr.sr td.lab { background: var(--accent-soft); font-family: var(--titre); font-size: 16px; font-weight: 600; color: var(--accent); }
tr.sr .v { font-size: 15px; font-weight: 600; color: var(--accent); }
tr.sr .st { display: block; font-size: 11px; font-weight: 500; margin-top: 3px; }
tr.sr .st.ok { color: var(--teal); } tr.sr .st.ko { color: var(--loss); }
.bar { display: block; height: 4px; border-radius: 2px; background: var(--rule); margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--loss); }
.bar i.ok { background: var(--teal); }
.rt-footer { max-width: 1100px; padding: 18px 28px 40px; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.rt-footer p { margin: 0 0 6px; max-width: 90ch; }
.rt-vide { padding: 8px 28px 40px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--paper); padding: 7px 14px; border-radius: 6px; font-size: 13px; transition: opacity .2s, transform .2s; z-index: 50; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.erreur { background: var(--loss); }

@media (max-width: 700px) {
  .entete { padding-left: 16px; padding-right: 16px; gap: 10px; flex-wrap: wrap; }
  .nav-principale { order: 3; flex-basis: 100%; overflow-x: auto; }
  .nom-utilisateur, .marque small { display: none; }
  .contenu { padding: 20px 16px; }
  .contenu-plein { padding: 0; }
  .recherche input { min-width: 0; }
  .rt-header h1 { font-size: 30px; }
  #t .lab { min-width: 200px; max-width: 200px; }
  .verdict { font-size: 18px; }
  .rt-header, .toolbar, .rt-footer, .rt-vide, .pied { padding-left: 16px; padding-right: 16px; }
  .hint { margin-left: 0; }
}
@media print {
  @page { size: A3 landscape; margin: 10mm; }
  .entete, .pied, .toolbar, .rt-choix, #t td.saisie input::placeholder { display: none !important; }
  .wrap { overflow: visible; max-height: none; border: 0; }
  #t thead th, #t .lab { position: static; }
  body { font-size: 10px; }
  #t td.saisie input { border: 0; background: none; width: 70px; }
}
@media (prefers-reduced-motion: reduce) { .caret { transition: none; } }
