/* Budget Clinkss
   Mise en page : une colonne sur téléphone ; sur ordinateur, un bandeau « reste du mois » puis une grille.
   Identité : carnet de famille. Prune pour la marque, abricot pour le quotidien, vert pour les revenus.
   Les couleurs d'état (vert, ambre, brique) restent séparées de la marque. */
@font-face { font-family: "Manrope"; src: url("/static/fonts/manrope-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("/static/fonts/manrope-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("/static/fonts/manrope-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("/static/fonts/manrope-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("/static/fonts/manrope-latin-800-normal.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/static/fonts/fraunces-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/static/fonts/fraunces-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f4f2f6;
  --surface: #ffffff;
  --surface-2: #faf8fb;
  --ink: #221d26;
  --muted: #6b6472;
  --line: #e6e1ea;
  --brand: #6b3f7d;
  --brand-ink: #5a3369;
  --brand-soft: #f1e9f4;
  --on-brand: #ffffff;
  /* séries de graphiques (palette validée daltonisme, thème clair) */
  --c-income: #2f8f5b;
  --c-fixed: #6b3f7d;
  --c-daily: #d9822b;
  --c-unknown: #a59fab;
  --c-more: #c4553a;
  --c-less: #0a8a9f;
  /* états */
  --good: #2f7d4f; --good-soft: #e4f1e8;
  --warn: #a96a12; --warn-soft: #fbf0dc;
  --bad: #b83a2e;  --bad-soft: #f8e3e0;
  --track: #ece7ef;
  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141217; --surface: #1e1a22; --surface-2: #231f28; --ink: #eeeaf2; --muted: #a69dae; --line: #332d3a;
    --brand: #c39bd8; --brand-ink: #d6b6e6; --brand-soft: #2e2436; --on-brand: #1b1420;
    --c-income: #3fa36b; --c-fixed: #a06bbe; --c-daily: #c77a2e; --c-unknown: #6f6876; --c-more: #d9735a; --c-less: #2aa6b5;
    --good: #6cc48e; --good-soft: #1d3326; --warn: #e2a64a; --warn-soft: #3a2c12; --bad: #ef8a7d; --bad-soft: #3d1f1b;
    --track: #2d2833;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font-ui);
  font-feature-settings: "tnum" 1;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 900px) { body { padding-bottom: 0; } }
a { color: var(--brand-ink); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0 0 .5rem; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: 1.7rem; letter-spacing: -.01em; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
h3 { font-size: .95rem; font-weight: 700; }
.num, td.n, .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.mt { margin-top: 1rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.25rem max(16px, env(safe-area-inset-left, 0px)) 2.5rem max(16px, env(safe-area-inset-right, 0px)); }

/* Barre du haut */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.topbar .inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 1rem;
  padding: .6rem max(16px, env(safe-area-inset-left, 0px)) .6rem max(16px, env(safe-area-inset-right, 0px)); }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: .55rem; }
.brand svg { width: 30px; height: 30px; flex: none; }
.nav { display: none; gap: .15rem; margin-left: .75rem; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: .42rem .7rem; border-radius: 999px; font-weight: 600; font-size: .92rem; }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); }
.nav a:hover { color: var(--ink); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.help { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); text-decoration: none; color: var(--brand-ink); font-weight: 800; }
.me { display: inline-flex; align-items: center; gap: .45rem; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .9rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 800; font-size: .8rem;
  background: var(--brand-soft); color: var(--brand-ink); flex: none; }
@media (min-width: 900px) { .nav { display: flex; } }
@media (max-width: 899px) { .me span.nm { display: none; } }

/* Barre du bas sur téléphone */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 0 max(0px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(0px, env(safe-area-inset-left, 0px)); z-index: 6; }
.tabbar a { text-align: center; padding: .55rem .2rem .5rem; font-size: .72rem; color: var(--muted); text-decoration: none; font-weight: 600; }
.tabbar a.on { color: var(--brand-ink); }
.tabbar svg { display: block; margin: 0 auto 3px; width: 22px; height: 22px; }
@media (min-width: 900px) { .tabbar { display: none; } }

/* Blocs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.15rem; min-width: 0; }
.card > h2:first-child, .card .head h2 { margin: 0; }
.head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .85rem; }
.head .sub { color: var(--muted); font-size: .85rem; }
.grid { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.main { grid-template-columns: 1.45fr 1fr; } }
.stack { display: grid; gap: 1rem; align-content: start; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; }

/* En-tête du tableau de bord */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.hello { color: var(--muted); font-weight: 600; margin: 0 0 .15rem; }
.monthbar { display: flex; align-items: center; gap: .5rem; }
.monthbar h1 { margin: 0; text-transform: capitalize; }
.arrow { display: inline-grid; place-items: center; width: 34px; height: 34px; text-decoration: none; border: 1px solid var(--line);
  border-radius: 50%; color: var(--ink); background: var(--surface); font-size: 1.1rem; }
.arrow.off { opacity: .35; pointer-events: none; }
.monthpick select { min-height: 36px; padding: .3rem .6rem; border-radius: 999px; }

/* Bandeau reste du mois */
.hero { display: grid; gap: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.35rem 1.4rem; }
@media (min-width: 900px) { .hero { grid-template-columns: minmax(260px, .8fr) 1.6fr; align-items: center; gap: 2.5rem; } }
.hero .lbl { font-size: .82rem; font-weight: 700; color: var(--muted); letter-spacing: .03em; }
.hero .big { font-size: clamp(2.6rem, 6vw, 3.4rem); font-weight: 800; line-height: 1.05; letter-spacing: -.02em; margin: .2rem 0 .35rem; }
.hero .big.neg { color: var(--bad); }
.hero .big.pos { color: var(--good); }
.hero .line { color: var(--muted); font-size: .92rem; }
.flow { display: grid; gap: .6rem; min-width: 0; }
.flow svg { width: 100%; height: 34px; display: block; }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem 1rem; }
@media (min-width: 640px) { .legend { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.legend .it { display: grid; grid-template-columns: 12px 1fr; column-gap: .45rem; align-items: baseline; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; transform: translateY(1px); }
.legend .k { font-size: .8rem; color: var(--muted); font-weight: 600; }
.legend .v { grid-column: 2; font-weight: 700; font-size: 1.02rem; }
.sw.income { background: var(--c-income); } .sw.fixed { background: var(--c-fixed); }
.sw.daily { background: var(--c-daily); } .sw.unknown { background: var(--c-unknown); }
.sw.more { background: var(--c-more); } .sw.less { background: var(--c-less); }
.flow-note { font-size: .82rem; color: var(--muted); }

/* Enveloppes */
.envgrid { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .envgrid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .envgrid { grid-template-columns: repeat(3, 1fr); } }
.env { border: 1px solid var(--line); border-radius: 12px; padding: .75rem .85rem .7rem; display: grid; gap: .4rem; background: var(--surface-2); text-decoration: none; color: inherit; }
.env:hover { border-color: var(--brand); }
.env .top { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.env .name { font-weight: 700; font-size: .93rem; }
.env .amt { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.env .amt b { color: var(--ink); font-weight: 700; }
.env .foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .8rem; color: var(--muted); }
.meter { width: 100%; height: 8px; display: block; }
.meter .track { fill: var(--track); }
.meter .fill.vert { fill: var(--good); }
.meter .fill.orange { fill: var(--warn); }
.meter .fill.rouge { fill: var(--bad); }
.meter .pace { stroke: var(--ink); stroke-width: 1.5; opacity: .55; }
.state { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; white-space: nowrap; }
.state svg { width: 12px; height: 12px; }
.state.vert { background: var(--good-soft); color: var(--good); }
.state.orange { background: var(--warn-soft); color: var(--warn); }
.state.rouge { background: var(--bad-soft); color: var(--bad); }
.pill { display: inline-block; font-size: .75rem; padding: .08rem .55rem; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.pill.vert { background: var(--good-soft); color: var(--good); }
.pill.orange { background: var(--warn-soft); color: var(--warn); }
.pill.rouge { background: var(--bad-soft); color: var(--bad); }
.pill.gris { background: var(--track); color: var(--muted); }

/* Graphiques */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 600 14.5px var(--font-ui); }
.chart .val { fill: var(--ink); font-weight: 700; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.chart .b-income { fill: var(--c-income); }
.chart .b-spent { fill: var(--c-fixed); }
.chart .b-more { fill: var(--c-more); }
.chart .b-less { fill: var(--c-less); }
.chart .seg-fixed { fill: var(--c-fixed); } .chart .seg-daily { fill: var(--c-daily); }
.chart .seg-unknown { fill: url(#hatch); } .chart .seg-track { fill: var(--track); }
.chart .hatch-bg { fill: var(--c-unknown); } .chart .hatch-ln { stroke: var(--surface); stroke-width: 1.5; }
.chart .cur { fill: var(--ink); }
.chart .over { stroke: var(--bad); stroke-width: 2; }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); font-weight: 600; margin-top: .4rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
details.table-view { margin-top: .6rem; font-size: .85rem; }
details.table-view summary { cursor: pointer; color: var(--muted); font-weight: 600; }

/* Tableaux */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .45rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
td.n, th.n { text-align: right; }
td.pos, .pos { color: var(--good); }
tr:last-child td { border-bottom: 0; }
.label-cell { min-width: 14rem; }
.label-cell a { color: var(--ink); text-decoration: none; font-weight: 600; }
.label-cell a:hover { text-decoration: underline; }
.tag { font-size: .78rem; color: var(--muted); }

/* À identifier */
.unk-list { display: grid; }
.unk { border-bottom: 1px solid var(--line); }
.unk:last-child { border-bottom: 0; }
.unk summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem; padding: .65rem 0; }
.unk summary::-webkit-details-marker { display: none; }
.unk .lbl { font-weight: 700; font-size: .92rem; word-break: break-word; }
.unk .meta { font-size: .8rem; color: var(--muted); grid-column: 1; }
.unk .amt { font-weight: 700; white-space: nowrap; }
.unk .act { grid-column: 2; grid-row: 2; font-size: .8rem; color: var(--brand-ink); font-weight: 700; text-align: right; }
.unk[open] .act { visibility: hidden; }
.unk form { display: grid; gap: .5rem; padding: 0 0 .9rem; }
@media (min-width: 640px) { .unk form { grid-template-columns: 1fr 1fr auto; align-items: end; } .unk .chk { grid-column: 1 / -1; } }

/* Qui a dépensé */
.people { display: grid; gap: .75rem; }
.person { display: grid; grid-template-columns: 34px 1fr auto; gap: .6rem; align-items: center; }
.person .avatar { width: 34px; height: 34px; }
.person .avatar.none { background: var(--track); color: var(--muted); }
.person .nm { font-weight: 700; font-size: .9rem; }
.person svg { width: 100%; height: 6px; display: block; margin-top: .25rem; }
.person svg .track { fill: var(--track); } .person svg .fill { fill: var(--brand); }

/* Formulaires */
label { display: grid; gap: .25rem; font-size: .88rem; font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; font-weight: 500; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); min-height: 42px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 500; }
.check input { margin-top: .3rem; accent-color: var(--brand); }
button, .btn { font: inherit; font-weight: 700; border: 1px solid var(--brand); background: var(--brand); color: var(--on-brand);
  border-radius: 999px; padding: .5rem 1.05rem; cursor: pointer; text-decoration: none; display: inline-block; min-height: 42px; }
button.ghost, .btn.ghost { background: transparent; color: var(--brand-ink); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.link { background: none; border: 0; color: var(--brand-ink); padding: 0; min-height: 0; font-weight: 600; }
.form-grid { display: grid; gap: .8rem; }
@media (min-width: 700px) { .form-grid.cols { grid-template-columns: repeat(3, 1fr); align-items: end; } }
.checks { display: grid; gap: .35rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); border: 0; padding: 0; margin: 0; }
.filters { display: grid; gap: .6rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(5, minmax(0, 1fr)) auto; align-items: end; } }

.notice { padding: .75rem .95rem; border-radius: 10px; background: var(--brand-soft); }
.notice.err { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--good-soft); color: var(--good); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

/* Connexion */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth .card { width: 100%; max-width: 410px; display: grid; gap: 1rem; padding: 1.6rem; }
.auth .qr { background: #fff; padding: .5rem; border-radius: 10px; justify-self: center; }
.auth .brandline { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.secret { font-variant-numeric: tabular-nums; word-break: break-all; font-size: .85rem; letter-spacing: .04em; }

/* Guide */
.guide { display: grid; gap: 1rem; }
@media (min-width: 900px) { .guide { grid-template-columns: 250px 1fr; align-items: start; } }
.guide nav a { display: block; padding: .4rem .6rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; }
.guide nav a.on { background: var(--brand-soft); color: var(--brand-ink); }
.prose { max-width: 70ch; }
.prose h1 { font-size: 1.55rem; }
.prose h2 { margin-top: 1.5rem; }
.prose table { margin: .75rem 0; }
.prose code { background: var(--brand-soft); padding: 0 .3rem; border-radius: 4px; font-size: .9em; }

.pager { display: flex; gap: .5rem; justify-content: center; align-items: center; margin-top: 1rem; }
.empty { text-align: center; padding: 2.5rem 1rem; display: grid; gap: .75rem; justify-items: center; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
