/* 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;
}
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); }
