/* Comptes Ventes — design system unique (clair + sombre). */

/* --- View Transitions : transitions entre onglets (cross-document) --- */
@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none;
  }
}

/* --- Tokens --- */
:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #5b6472;          /* contraste 5.9:1 sur blanc */
  --line: #e5e7eb;
  --accent: #b4552d;          /* contraste blanc 5.2:1 */
  --accent-dark: #96431f;
  --accent-soft: #f7e8e0;
  --green: #1e7a4f;           /* 4.9:1 sur blanc */
  --green-soft: #e0f0e8;
  --red: #b3423a;             /* 5.3:1 sur blanc */
  --red-soft: #f9e8e6;
  --chip: #eceef1;
  --accent-ink: #96431f;      /* texte accent sur fonds clairs (badges, nav active) */
  --btn-ink: #ffffff;          /* texte sur boutons accent */
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lift: 0 2px 6px rgba(16, 24, 40, .08), 0 10px 24px rgba(16, 24, 40, .08);
  --radius: 16px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --fs-xs: .72rem; --fs-s: .8rem; --fs-m: .95rem; --fs-l: 1.45rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1e2126;
    --ink: #e8eaed;
    --muted: #9aa3af;         /* 5.0:1 sur #1e2126 */
    --line: #2e3238;
    --accent: #e08a5f;
    --accent-dark: #c9703f;
    --accent-soft: #3a2a22;
    --green: #4fc08d;
    --green-soft: #1f2f27;
    --red: #e5796e;
    --red-soft: #352422;
    --chip: #2a2e34;
    --accent-ink: #e08a5f;     /* accent clair lisible sur fonds sombres */
    --btn-ink: #14161a;        /* texte sombre sur bouton orange clair (7.9:1) */
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lift: 0 2px 8px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  transition: background .25s ease, color .25s ease;
}
.wrap { max-width: 480px; margin: 0 auto; padding: var(--s4); }

/* --- Micro-animation d'apparition (cartes, pages) --- */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
.card, .balance {
  animation: fade-up .28s ease both;
}
.card:nth-child(2), .balance ~ * .card:nth-child(2) { animation-delay: .04s; }
.card:nth-child(3) { animation-delay: .08s; }
.card:nth-child(4) { animation-delay: .12s; }
.card:nth-child(5) { animation-delay: .16s; }

/* --- Typo --- */
h1 { font-size: 1.35rem; margin: var(--s1) 0 var(--s4); letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: var(--s5) 0 10px; letter-spacing: -.01em; }

/* --- Composants --- */
.card {
  background: var(--card); border-radius: var(--radius); padding: var(--s4);
  margin-bottom: var(--s3); box-shadow: var(--shadow);
  border: 1px solid var(--line);
  transition: box-shadow .2s ease;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.stat .label { font-size: var(--fs-s); color: var(--muted); margin-bottom: var(--s1); }
.stat .value { font-size: var(--fs-l); font-weight: 700; letter-spacing: -.02em; }
.stat .sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; line-height: 1.4; }
.pos { color: var(--green); } .neg { color: var(--red); }

.rowline {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-m);
  gap: var(--s2);
}
.rowline:last-child { border-bottom: none; }
.rowline .meta { color: var(--muted); font-size: var(--fs-s); line-height: 1.35; }

.badge {
  display: inline-block; font-size: var(--fs-xs); padding: 3px 10px; border-radius: 99px;
  background: var(--chip); color: var(--ink); font-weight: 500;
}
.badge.vendu { background: var(--green-soft); color: var(--green); }
.badge.vente { background: var(--accent-soft); color: var(--accent-ink); }

/* --- Formulaires --- */
label { display: block; font-size: .85rem; color: var(--muted); margin: var(--s3) 0 5px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 16px; background: var(--card); color: var(--ink); appearance: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
/* Case à cocher : `appearance: none` (règle ci-dessus) supprime le rendu natif,
   donc l'état coché doit être dessiné explicitement — sinon la case est
   identique cochée ou non (bug signalé le 2026-09-26). */
input[type=checkbox] {
  width: 24px; height: 24px; min-width: 24px; padding: 0;
  border: 1.5px solid var(--line); border-radius: 7px;
  background-color: var(--card);
  background-repeat: no-repeat; background-position: center; background-size: 16px 16px;
  cursor: pointer; flex: none;
}
input[type=checkbox]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5 9.5 18 20 6'/%3E%3C/svg%3E");
}
input[type=checkbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  outline: none;
}
input[type=date] { min-height: 44px; }
textarea { resize: vertical; }

button, .btn {
  display: inline-block; width: 100%; padding: 13px; margin-top: 18px;
  background: var(--accent); color: var(--btn-ink); border: none; border-radius: 12px;
  font-size: 1rem; font-weight: 600; cursor: pointer; text-align: center;
  text-decoration: none;
  transition: background .15s ease, transform .1s ease, box-shadow .2s ease;
}
button:hover, .btn:hover { background: var(--accent-dark); }
button:active, .btn:active { transform: scale(.98); }
.btn.small { width: auto; padding: 6px 14px; font-size: var(--fs-s); margin: 0;
  background: var(--chip); color: var(--ink); border-radius: 99px; }
.btn.small:hover { background: var(--line); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.small.primary { background: var(--accent); color: var(--btn-ink); }
.btn.small.primary:hover { background: var(--accent-dark); }
.online-btn { font-size: .9rem; line-height: 1; padding: 4px 10px; min-width: 36px; min-height: 32px;
  background: var(--chip); }
.online-btn.on { background: var(--green-soft); }

/* Focus visible — outline uniquement, jamais surchargé (voir skill pitfall 1) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Navigation basse --- */
nav.bottom {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: var(--s1) 0 max(var(--s1), env(safe-area-inset-bottom));
  z-index: 10;
  view-transition-name: bottom-nav;
}
nav.bottom a {
  text-decoration: none; color: var(--muted); font-size: .62rem; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: var(--s1) 6px; min-width: 48px; min-height: 44px; justify-content: center;
  border-radius: 10px;
  transition: color .15s ease, background .15s ease;
}
nav.bottom a.active { color: var(--accent-ink); }
nav.bottom .ico { width: 22px; height: 22px; }
nav.bottom svg { width: 22px; height: 22px; }

/* --- Icônes SVG (sprite inline, base.html) --- */
.ico { width: 1.1em; height: 1.1em; vertical-align: -0.18em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- Divers --- */
.top { display: flex; justify-content: space-between; align-items: center; }
.logout { font-size: var(--fs-s); color: var(--muted); text-decoration: none; }
.logout:hover { color: var(--accent); }
.balance {
  text-align: center; padding: 18px; background: var(--card);
  border-radius: var(--radius); margin-bottom: var(--s3);
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.balance .who { font-size: 1.15rem; font-weight: 700; margin-top: 6px; }
.error { color: var(--red); font-size: var(--fs-m); margin-top: 10px; text-align: center; }
.login-logo { text-align: center; margin: 48px 0 28px; color: var(--accent); }
.login-logo svg { width: 48px; height: 48px; }

.filters { display: flex; gap: var(--s2); margin: 14px 0; }
.filters a {
  flex: 1; text-align: center; padding: 9px; border-radius: 99px;
  text-decoration: none; font-size: .85rem; font-weight: 500;
  background: var(--chip); color: var(--ink);
  border: 1px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.filters a.active { background: var(--accent); color: var(--btn-ink); }

.search-bar input {
  margin-bottom: var(--s2);
}

/* --- Historique / stats --- */
.monthbar { height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; margin-top: 6px; }
.monthbar > div { height: 100%; background: var(--green); border-radius: 99px; }
.montrow { padding: 10px 0; border-bottom: 1px solid var(--line); }
.montrow:last-child { border-bottom: none; }
.monthgrid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2);
  margin-top: 6px;
}
.monthgrid > div { min-width: 0; }
.monthgrid .mv { font-weight: 700; font-size: var(--fs-m); letter-spacing: -.02em; }
.monthgrid .meta { font-size: var(--fs-xs); line-height: 1.25; color: var(--muted); }
details.yearblock { padding: 10px 0; border-bottom: 1px solid var(--line); }
details.yearblock:last-child { border-bottom: none; }
details.yearblock > summary { list-style: none; cursor: pointer; }
details.yearblock > summary::-webkit-details-marker { display: none; }
details.monthrow { padding: var(--s2) 0 var(--s2) var(--s3); border-bottom: 1px dashed var(--line); }
details.monthrow:last-child { border-bottom: none; }
details.monthrow > summary { list-style: none; cursor: pointer; }
details.monthrow > summary::-webkit-details-marker { display: none; }
.chev {
  display: inline-block; color: var(--muted); font-size: .75rem;
  transition: transform .15s ease; margin-right: 2px;
}
details[open] > summary .chev { transform: rotate(90deg); }

/* Carte « Investi » repliable du dashboard : summary = toute la tête de carte. */
details.invest-details > summary { list-style: none; cursor: pointer; }
details.invest-details > summary::-webkit-details-marker { display: none; }
details.invest-details > summary .chev { transform: rotate(0deg); margin-left: 4px; }
details.invest-details[open] > summary .chev { transform: rotate(180deg); }

/* ==========================================================================
   Pages publiques (connexion, inscription, mot de passe, pages légales)
   et landing — mêmes tokens que l'app, pour un rendu homogène.
   ========================================================================== */

main { display: block; }

/* --- Authentification (écrans centrés) --- */
.auth { max-width: 420px; margin: 0 auto; }
.auth .brand, .hero .brand {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent-ink);
}
.auth .brand svg { width: 26px; height: 26px; }
.auth .lede { color: var(--muted); font-size: var(--fs-m); margin-bottom: var(--s4); }
.auth form { margin-top: var(--s4); }
.switch { text-align: center; font-size: var(--fs-s); color: var(--muted); margin-top: var(--s4); }
.switch a, .prose a, .note a, .auth a { color: var(--accent-ink); }
.field-group { display: flex; gap: var(--s2); align-items: stretch; }
.field-group input { flex: 1; }
.field-action {
  width: auto; min-width: 44px; margin: 0; padding: 0 12px;
  background: var(--chip); color: var(--muted); border-radius: 12px;
}
.field-action:hover { background: var(--line); }
.field-hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }
.checkline { display: flex; gap: var(--s2); align-items: flex-start; font-size: var(--fs-s); }
.checkline input { width: auto; margin-top: 2px; flex: none; min-height: 24px; cursor: pointer; }
.checkline span { padding-top: 1px; }
.ico-sm { width: .95em; height: .95em; }

/* --- Notes / bandeaux --- */
.note {
  display: flex; gap: var(--s2); align-items: flex-start;
  background: var(--chip); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--s3); margin-bottom: var(--s3);
  font-size: var(--fs-s); color: var(--ink);
}
.note.ok { background: var(--green-soft); border-color: transparent; color: var(--green); }
.note.info { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }

/* --- Pages légales --- */
.prose { font-size: var(--fs-m); line-height: 1.65; }
.prose h1 { font-size: 1.28rem; }
.prose h2 { font-size: 1rem; margin: var(--s5) 0 var(--s2); }
.prose p, .prose li { color: var(--ink); }
.prose ul { padding-left: var(--s5); margin: var(--s2) 0; }
.prose li { margin-bottom: 4px; }
.prose em { color: var(--muted); }
.legal-footer {
  text-align: center; font-size: var(--fs-xs); color: var(--muted);
  padding: var(--s2) var(--s4) var(--s5);
}
.legal-footer a { color: var(--muted); text-decoration: none; }
.legal-footer a:hover { color: var(--accent-ink); }
.legal-footer .sep { margin: 0 6px; }

/* --- Démarrage (onboarding) --- */
.onboarding-steps .step {
  display: flex; gap: var(--s3); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s4); margin-bottom: var(--s3); box-shadow: var(--shadow);
}
.step-num {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--btn-ink); font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: var(--fs-s);
}
.step-body h3 { font-size: var(--fs-m); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.step-body p { font-size: var(--fs-s); color: var(--muted); margin-bottom: var(--s3); }
.step-body .btn { width: auto; }
.onboarding-help { text-align: center; font-size: var(--fs-s); color: var(--muted); margin-top: var(--s5); }
.onboarding-help h3 { font-size: var(--fs-m); color: var(--ink); margin-bottom: 2px; }

/* --- Annonce (brouillon + copie) --- */
.steps { padding-left: var(--s5); font-size: var(--fs-s); color: var(--muted); margin: var(--s2) 0; }
.copy-block {
  white-space: pre-wrap; background: var(--chip); border-radius: 12px;
  padding: var(--s3); font-size: var(--fs-s); margin: var(--s2) 0 var(--s3);
  max-height: 240px; overflow: auto;
}
.btn.icon { display: inline-flex; align-items: center; justify-content: center; }

/* --- Landing --- */
.landing { padding-bottom: var(--s7); }
.site-wrap { max-width: 960px; margin: 0 auto; padding: var(--s4); }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.wordmark { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 700; text-decoration: none; color: var(--ink); }
.wordmark .ico { width: 20px; height: 20px; color: var(--accent-ink); }
.site-header nav { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.site-header nav a { text-decoration: none; color: var(--muted); font-size: var(--fs-s); }
.site-header nav a:hover { color: var(--accent-ink); }
.site-header nav a.cta { background: var(--accent); color: var(--btn-ink); padding: 8px 14px; border-radius: 99px; }
.hero { padding: var(--s7) 0 var(--s5); max-width: 640px; }
.hero h1 { font-size: 1.9rem; margin: var(--s4) 0 var(--s2); }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs);
  color: var(--accent-ink); background: var(--accent-soft); border-radius: 99px; padding: 5px 12px; }
.lede { font-size: var(--fs-m); color: var(--muted); }
.actions { display: flex; gap: var(--s3); flex-wrap: wrap; margin: var(--s4) 0 var(--s3); }
.actions .btn { width: auto; margin: 0; }
.btn.secondary { background: var(--chip); color: var(--ink); }
.btn.secondary:hover { background: var(--line); }
.reassure { display: flex; gap: var(--s2); align-items: center; font-size: var(--fs-xs); color: var(--muted); }
.section { padding: var(--s6) 0; border-top: 1px solid var(--line); }
.section-head h2 { margin-top: 0; }
.section-head p { color: var(--muted); font-size: var(--fs-m); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s3); margin-top: var(--s4); }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); }
.feature .icon { color: var(--accent-ink); display: inline-flex; margin-bottom: var(--s2); }
.feature .icon svg { width: 22px; height: 22px; }
.feature h3 { font-size: var(--fs-m); margin-bottom: 4px; }
.feature p { font-size: var(--fs-s); color: var(--muted); }
.preview { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); align-items: center; }
.preview ul { list-style: none; margin: var(--s3) 0; }
.preview li { display: flex; gap: var(--s2); font-size: var(--fs-s); color: var(--muted); margin-bottom: var(--s2); }
.preview li .ico { flex: none; margin-top: 3px; color: var(--green); }
.mock { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s4); box-shadow: var(--shadow-lift); }
.mock-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s3); }
.mock-title { font-weight: 600; font-size: var(--fs-s); }
.mock-row { display: flex; justify-content: space-between; gap: var(--s2); align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-s); }
.mock-row:last-child { border-bottom: none; }
.pricing { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s5); max-width: 420px; box-shadow: var(--shadow); }
.price { font-size: 1.6rem; font-weight: 700; }
.price span { font-size: var(--fs-s); font-weight: 400; color: var(--muted); }
.tagline { color: var(--muted); font-size: var(--fs-s); margin: var(--s2) 0; }
.pricing ul { list-style: none; margin: var(--s3) 0; }
.pricing li { display: flex; gap: var(--s2); font-size: var(--fs-s); margin-bottom: var(--s2); }
.pricing li .ico { color: var(--green); flex: none; }
.faq-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: var(--s3) var(--s4); margin-bottom: var(--s2); }
.faq-item summary { cursor: pointer; font-weight: 600; font-size: var(--fs-m); }
.faq-item p { color: var(--muted); font-size: var(--fs-s); margin-top: var(--s2); }
.site-footer { border-top: 1px solid var(--line); margin-top: var(--s5); padding-top: var(--s4); text-align: center; }
.site-footer nav { display: flex; gap: var(--s3); justify-content: center; flex-wrap: wrap; margin-bottom: var(--s2); }
.site-footer a { color: var(--muted); text-decoration: none; font-size: var(--fs-s); }
.site-footer p { font-size: var(--fs-xs); color: var(--muted); }
@media (max-width: 700px) { .preview { grid-template-columns: 1fr; } .hero h1 { font-size: 1.6rem; } }
