/*
 * Mes comptes : interface claire, calme, une seule couleur d'accent (terracotta).
 * Les noms de classes sont ceux des vues existantes : seul le style change.
 */
:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #1f1b16;
  --muted: #6b6258;
  --line: #ede7dd;
  --accent: #b84a33;
  --accent-soft: #f1e4dc;
  --accent-ink: #8a3622;
  --in: #2f6b49;
  --out: #a93b31;
  --warn: #d99a2b;
  --warn-soft: #fbefd3;
  --warn-ink: #7a4f08;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 27, 22, .06), 0 8px 24px rgba(31, 27, 22, .04);
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Fraunces, Georgia, "Times New Roman", serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: .2em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
p { margin: 0 0 .75rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 50; background: var(--card); padding: .4rem .8rem; border-radius: 8px; }
.nowrap { white-space: nowrap; }

/* --- page et barre du haut ------------------------------------------------ */
.book { max-width: 72rem; margin: 0 auto; padding: 0 1.5rem 3rem; }
.sheet { min-height: 100vh; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0;
  margin: 0 0 2rem;
  border-bottom: 1px solid var(--line);
}
.brand { padding: 1rem 0; font: 600 1.35rem var(--serif); color: var(--ink); text-decoration: none; }
.who { display: flex; gap: .9rem; align-items: center; margin: 0; color: var(--muted); font-size: .92rem; }

/* --- navigation : barre du haut sur ordinateur, barre du bas sur téléphone --- */
.tabs { display: flex; gap: 1.75rem; align-self: stretch; }
.tab {
  display: flex;
  align-items: center;
  padding: 0 .15rem;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 500;
  text-decoration: none;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }

/* --- titres et chiffres ------------------------------------------------------ */
h1, h2 { margin: 0; font-weight: 600; }
h1 { margin-bottom: 1rem; font: 600 2rem/1.2 var(--serif); }
h1:has(+ .total) { margin-bottom: .25rem; font: 500 .95rem/1.4 var(--sans); color: var(--muted); }
h2 { margin: 0 0 .9rem; font-size: 1.1rem; line-height: 1.3; }
.total { margin: 0 0 .5rem; font: 600 clamp(3.4rem, 11vw, 6rem)/1 var(--serif); color: var(--ink); }
.total .num { display: inline-block; }
.total.neg { color: var(--out); }
.unit { margin-left: .5rem; font: 500 1.2rem var(--sans); color: var(--muted); }
.month { display: flex; flex-wrap: wrap; gap: .25rem 1.75rem; margin: 0 0 2rem; font-size: .95rem; }
.month div { display: flex; gap: .5rem; align-items: baseline; }
.month dt { color: var(--muted); }
.month dd { margin: 0; font-weight: 600; }
.lead-in { color: var(--muted); margin-bottom: .25rem; }

/* --- montants : seule la couleur du chiffre change ------------------------------ */
.in { color: var(--in); font-weight: 600; }
.out { color: var(--out); font-weight: 600; }
.moved { color: var(--muted); }
.amt { font-weight: 600; white-space: nowrap; }
.empty { color: var(--muted); }

/* --- boutons --------------------------------------------------------------------- */
.btn {
  display: inline-block;
  min-height: 2.9rem;
  padding: 0 1.5rem;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  line-height: 2.9rem;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--accent-ink); }
.quiet { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
.quiet:hover { color: var(--ink); }
.quiet.danger { color: var(--out); }
.submit { margin: 1.25rem 0 0; }

/* --- messages ----------------------------------------------------------------------- */
.flashes { margin-bottom: 1.25rem; }
.flash { margin: 0 0 .5rem; padding: .7rem 1rem; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
.flash-ok { background: #e6f1ea; color: #1f4d33; }
.flash-err { background: #f9e3e0; color: #7d2a22; font-weight: 600; }

/* --- cartes ---------------------------------------------------------------------------- */
.cols > section, .cols > aside,
[aria-labelledby="recent-title"],
.space, .budget-row, .tbl-wrap, .auth-forms {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.cols > section, .cols > aside, [aria-labelledby="recent-title"], .space, .budget-row { padding: 1.5rem; }
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; margin-bottom: 1.5rem; }
.space, .budget-row { margin-bottom: 1rem; }

/* --- la phrase à trous ------------------------------------------------------------------ */
.note, .sentence { margin: 0; }
.sentence { line-height: 2.5; font-size: 1.05rem; }
.blank {
  min-width: 3rem;
  max-width: 100%;
  margin: 0 .15rem;
  padding: .1rem .3rem;
  border: 0;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
}
.blank:focus { outline: none; border-bottom-color: var(--accent); }
.blank::placeholder { color: var(--muted); font-weight: 400; }
select.blank { cursor: pointer; }
select.blank option { background: var(--card); color: var(--ink); }
input[type="date"].blank { min-width: 9.5rem; }
.blank-amount { width: 9ch; text-align: right; }
.blank-label { width: 20ch; }

.cats { margin: 1.25rem 0 0; padding: 0; border: 0; }
.cats legend { padding: 0; margin-bottom: .6rem; font-weight: 600; }
.chips { position: relative; display: flex; flex-wrap: wrap; gap: .5rem; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chip { display: inline-block; padding: .5rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: .92rem; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chips input:checked + .chip { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 600; }
.chips input:focus-visible + .chip { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --- listes ---------------------------------------------------------------------------------- */
.ledger { margin: 0; padding: 0; list-style: none; }
.ledger > li { display: flex; gap: .75rem; align-items: baseline; justify-content: space-between; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.ledger > li:last-child { border-bottom: 0; }
.lbl { display: flex; flex: 1; gap: .5rem; align-items: baseline; min-width: 0; }
.txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead { display: none; }
.tag { padding: .1rem .6rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: .78rem; white-space: nowrap; }
.ledger.ops > li { display: grid; grid-template-columns: 4.4rem minmax(0, 1fr) auto; column-gap: .75rem; row-gap: 0; }
.date { color: var(--muted); font-size: .92rem; }
.meta, .meta-inline { color: var(--muted); font-size: .85rem; }
.meta-inline { white-space: nowrap; }
.ledger.ops .meta { grid-column: 2; }
.members .amt { display: flex; gap: .9rem; align-items: baseline; font-weight: 500; }
form.inline { display: inline; margin: 0; }
.space h2 .tag { vertical-align: middle; margin-left: .5rem; font-weight: 500; }
.space .note { margin-top: 1rem; }

details summary { cursor: pointer; font-weight: 600; color: var(--accent); min-height: 2.75rem; display: flex; align-items: center; }
.open-account { margin-top: 1rem; }

/* --- formulaires empilés ---------------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; margin: 0; }
.stack label { font-weight: 600; font-size: .92rem; margin-bottom: .25rem; }
.line {
  width: 100%;
  min-height: 2.9rem;
  margin-bottom: 1.1rem;
  padding: .5rem .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}
.line:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.line::placeholder { color: var(--muted); }

/* --- journal ------------------------------------------------------------------------------------ */
.filters { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: baseline; margin-bottom: 1.5rem; }
.filters label { display: inline-flex; gap: .4rem; align-items: baseline; color: var(--muted); font-size: .92rem; }
.filter-actions { display: inline-flex; gap: 1rem; align-items: center; }
.tbl-wrap { overflow-x: auto; padding: .5rem 1.5rem 1rem; }
.tbl { width: 100%; min-width: 38rem; border-collapse: collapse; }
.tbl th { padding: .9rem .5rem; border-bottom: 1px solid var(--line); text-align: left; color: var(--muted); font-size: .8rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.tbl td { padding: .8rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .meta { display: block; }
.tbl tfoot td { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 600; }
.tbl .act form { margin: 0; }
.pager { display: flex; gap: 1.25rem; align-items: baseline; margin-top: 1.5rem; }

/* --- budgets --------------------------------------------------------------------------------------- */
.budget-head { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; justify-content: space-between; }
.budget-head .name { font-weight: 600; }
.budget-head .blank-amount { width: 15ch; }
.gauge { display: block; width: 100%; height: .6rem; margin: .7rem 0; border-radius: 99px; overflow: hidden; }
.gauge .track { fill: var(--line); }
.gauge .fill.ok { fill: var(--accent); }
.gauge .fill.warn { fill: var(--warn); }
.gauge .fill.over { fill: var(--out); }
.gauge .ticks { fill: none; stroke: var(--card); stroke-width: 1; vector-effect: non-scaling-stroke; }
.msg { margin: 0; color: var(--muted); font-size: .92rem; }
.warn-note { display: inline-block; padding: .1rem .7rem; border-radius: 999px; background: var(--warn-soft); color: var(--warn-ink); font-weight: 600; }
.over-note { display: inline-block; padding: .1rem .8rem; border-radius: 999px; background: #f9e3e0; color: var(--out); font-weight: 600; }

/* --- connexion --------------------------------------------------------------------------------------- */
.guest-main { max-width: 62rem; margin: 0 auto; padding: 2rem 1rem 3rem; }
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cover { display: flex; flex-direction: column; gap: 1.25rem; justify-content: center; padding: 2.5rem 2rem; background: var(--accent-soft); color: var(--ink); }
.cover h1 { margin: 0; font-size: 2.6rem; line-height: 1.1; }
.cover p { margin: 0; color: var(--accent-ink); }
.label-box, .fill-line { display: none; }
.auth-forms { padding: 2rem; border-radius: 0; box-shadow: none; }
.register { margin-top: 1rem; }
.register form { margin-top: 1rem; }

/* --- erreur ---------------------------------------------------------------------------------------------- */
.errpage { padding-top: 2rem; }
.err-code { display: inline-block; margin-bottom: 1rem; padding: .3rem 1.4rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font: 600 2rem var(--serif); }

/* --- boîte de confirmation ------------------------------------------------------------------------------------ */
.dlg { max-width: min(26rem, 90vw); padding: 1.5rem; border: 0; border-radius: var(--radius); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(31, 27, 22, .25); }
.dlg::backdrop { background: rgba(31, 27, 22, .45); }
.dlg-actions { display: flex; gap: 1.25rem; align-items: center; justify-content: flex-end; margin-top: 1.25rem; }

/* --- tablette et téléphone ---------------------------------------------------------------------------------------- */
@media (max-width: 64rem) {
  .cols { display: block; }
  .cols > section, .cols > aside { margin-bottom: 1.5rem; }
}
@media (max-width: 52rem) {
  .book { padding: 0 1rem 6rem; }
  .sheet-head { margin-bottom: 1.25rem; }
  .brand { font-size: 1.2rem; }
  .who span { display: none; }
  .tabs {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    gap: 0;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: var(--card);
  }
  .tab {
    flex: 1;
    min-height: 3.4rem;
    justify-content: center;
    padding: 0;
    border-bottom: 0;
    border-top: 3px solid transparent;
    font-size: .8rem;
  }
  .tab[aria-current="page"] { border-top-color: var(--accent); }
  h1 { font-size: 1.7rem; }
  .cols > section, .cols > aside, [aria-labelledby="recent-title"], .space, .budget-row { padding: 1.1rem; }
  .tbl-wrap { padding: .25rem 1rem .75rem; }
  .sentence { font-size: 1rem; }
  .blank-label { width: 14ch; }
  .auth { display: block; }
  .auth-forms { padding: 1.5rem 1.25rem; }
  .guest-main { padding: 1rem .75rem 2rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .chip, .tab { transition: background-color .15s, color .15s, border-color .15s; }
}
