:root {
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f2f1ec; --border: #e1e0d9; --axis: #c3c2b7;
  --text: #0b0b0b; --text-2: #52514e; --muted: #898781;
  --brand: #1f3a68; --accent: #2a78d6;
  --s-revenus: #2a78d6; --s-depenses: #eb6834; --s-epargne: #1baf7a; --s-4: #eda100; --s-5: #e87ba4; --s-6: #008300; --s-7: #6250d6; --s-8: #e34948;
  --good: #0ca30c; --good-text: #006300; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--text); background: var(--page);
}
:root[data-theme="dark"] {
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --border: #2c2c2a; --axis: #383835;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #898781; --brand: #3987e5; --accent: #3987e5;
  --s-revenus: #3987e5; --s-depenses: #d95926; --s-epargne: #199e70; --s-4: #c98500; --s-5: #d55181; --s-6: #008300; --s-7: #9085e9; --s-8: #e66767;
  --good-text: #0ca30c; --shadow: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); }
.hidden { display: none !important; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }
h3 { font-size: 1rem; margin-bottom: .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--good-text); } .neg { color: var(--critical); }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: #fff; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
:root[data-theme="dark"] .sidebar { background: #121211; border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; padding: 4px 10px 18px; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
nav a { color: rgba(255,255,255,.82); text-decoration: none; padding: 9px 12px; border-radius: 9px; display: flex; gap: 10px; align-items: center; }
nav a i { font-style: normal; width: 20px; text-align: center; opacity: .9; }
nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.sidebar-foot { display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot .btn { color: rgba(255,255,255,.8); border-color: rgba(255,255,255,.2); }
main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.topbar h2 { font-size: 1.25rem; flex: 1; min-width: 140px; }
#menu-toggle { display: none; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.month-picker { display: flex; align-items: center; gap: 2px; }
.view { padding: 22px 24px 60px; display: flex; flex-direction: column; gap: 18px; max-width: 1500px; }

/* Controls */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--axis); border-radius: 8px; padding: 7px 10px; min-width: 0; }
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { font: inherit; border: 1px solid var(--axis); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--critical); border-color: var(--critical); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn.icon { padding: 5px 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--text-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: end; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; flex: 1; }
.grid { display: grid; gap: 18px; align-items: start; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: stretch; } /* cadres d’une même rangée à la même hauteur */
.grid.two { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--text-2); font-size: .85rem; }
.kpi .value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 200px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--text-2); margin-bottom: 8px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--c); vertical-align: -1px; }
.legend span.line::before { height: 2px; vertical-align: 3px; }
.legend span.dash::before { height: 0; border-top: 2px dashed var(--c); background: none; vertical-align: 3px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--text-2); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; background: var(--surface); position: sticky; top: 0; }
tr.group-row td { background: var(--surface-2); font-weight: 650; }
tr.total-row td { font-weight: 700; border-top: 2px solid var(--axis); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td input.budget-input { width: 100px; text-align: right; padding: 4px 6px; }
td input.budget-input.auto { border-style: dashed; color: var(--text-2); }
.grid-table th:first-child, .grid-table td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 200px; }
.grid-table tr.group-row td:first-child { background: var(--surface-2); }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; min-width: 80px; }
.bar > div { height: 100%; border-radius: 4px; background: var(--s-revenus); }
.bar > div.warn { background: var(--warning); } .bar > div.over { background: var(--critical); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; background: var(--surface-2); color: var(--text-2); }
.pill.auto { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.pill.ok { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-text); }
details.mapping-wrap > summary { cursor: pointer; color: var(--text-2); font-size: .85rem; margin: 6px 0; }
details.mapping-wrap[open] > summary { margin-bottom: 10px; }
.group-box { border-left: 4px solid var(--accent); padding: 8px 12px; margin-top: 12px; background: var(--surface-2); border-radius: 8px; }

/* Sélecteurs de vue / d'affichage, saisie directe */
.view-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.segmented { display: inline-flex; border: 1px solid var(--axis); border-radius: 9px; overflow: hidden; background: var(--surface); }
.segmented button { font: inherit; font-size: .88rem; border: none; background: none; color: var(--text-2); padding: 6px 14px; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button:hover { background: var(--surface-2); }
.segmented button.active { background: var(--accent); color: #fff; font-weight: 600; }
.quick-entry { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quick-entry .sign { min-width: 105px; color: var(--critical); border-color: var(--critical); }
.quick-entry .sign.in { color: var(--good-text); border-color: var(--good-text); }
.btn.add { padding: 0 7px; line-height: 1.4; color: var(--accent); }
td.editable { cursor: pointer; }
td.editable:hover { background: var(--surface-2); outline: 1px solid var(--accent); outline-offset: -1px; }
td input.budget-input.cell { width: 72px; }
/* Ventilation par personne */
.kpi.person { border-top: 3px solid var(--c); }
.kpi.person .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; }
td.foyer-col { font-weight: 650; background: var(--surface-2); }
select.small-select { padding: 3px 6px; font-size: .85rem; max-width: 190px; }

/* Grille des opérations façon Excel */
.grid-table.excel td, .grid-table.excel th { padding: 3px 4px; }
.grid-table.excel td:first-child { padding-left: 10px; }
input.cell-input { width: 76px; text-align: right; padding: 4px 6px; border-color: transparent; background: transparent; border-radius: 4px; font-variant-numeric: tabular-nums; }
input.cell-input:hover { border-color: var(--axis); }
input.cell-input:focus { background: var(--surface); border-color: var(--accent); }
.grid-table.excel td.editable { padding-right: 10px; }
.grid-table.excel .multi { border-bottom: 1px dashed var(--muted); }
input.cell-input.src-defaut { color: var(--muted); }
input.cell-input.src-auto { color: var(--accent); font-style: italic; }
input.cell-input.total-input { font-weight: 650; width: 90px; }
.grid-table th.current { color: var(--accent); }
/* Courses façon Excel */
.sheet input.cell-input { text-align: left; }
.sheet input.sheet-date { width: 138px; }
.sheet input.sheet-store, .sheet input.sheet-category { width: 130px; }
.sheet input.sheet-article { width: 190px; }
.sheet input.sheet-qty, .sheet input.sheet-unit { width: 56px; }
.sheet input.sheet-qty, .sheet input.sheet-unit_price, .sheet input.sheet-total { text-align: right; }
.sheet input.sheet-comment { width: 170px; }
.sheet tr.blank-row input.cell-input { border-color: var(--border); }
.sheet tr.pending td { background: color-mix(in srgb, var(--warning) 10%, transparent); }
.sheet tr.pending input.sheet-article { border-color: var(--warning); }
.sheet tr.added td { background: color-mix(in srgb, var(--accent) 16%, transparent); transition: background .8s; }
.sheet tr.saved td { background: color-mix(in srgb, var(--good) 14%, transparent); transition: background .6s; }
.sheet input::placeholder { color: var(--muted); opacity: .6; }
.grid-table.sheet td:first-child, .grid-table.sheet th:first-child { min-width: 0; }
tr.subtotal-row td { font-weight: 600; color: var(--text-2); border-bottom: 2px solid var(--border); }
.modal:has(.quick-entry) { width: min(880px, 100%); }
.modal .quick-entry input[placeholder^="Libellé"] { min-width: 200px; }

/* Alerts (status : icône + libellé, jamais la couleur seule) */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border); border-left-width: 4px; background: var(--surface); font-size: .9rem; }
.alert .tag { font-weight: 700; font-size: .75rem; text-transform: uppercase; white-space: nowrap; }
.alert.critique { border-left-color: var(--critical); } .alert.critique .tag { color: var(--critical); }
.alert.attention { border-left-color: var(--warning); } .alert.attention .tag { color: #a26b00; }
:root[data-theme="dark"] .alert.attention .tag { color: var(--warning); }
.alert.info { border-left-color: var(--accent); } .alert.info .tag { color: var(--accent); }

/* Calendar (vue journalière) */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar .dow { text-align: center; font-size: .75rem; color: var(--muted); font-weight: 600; }
.calendar .day { border: 1px solid var(--border); border-radius: 8px; padding: 6px; min-height: 72px; font-size: .78rem; cursor: pointer; position: relative; background: var(--surface); }
.calendar .day:hover { outline: 2px solid var(--accent); }
.calendar .day.selected { outline: 2px solid var(--accent); }
.calendar .day.today { border-color: var(--accent); }
.calendar .day.future { opacity: .55; }
.calendar .day .d { font-weight: 700; color: var(--text-2); }
.calendar .day .out { color: var(--text); font-variant-numeric: tabular-nums; }
.calendar .day .in { color: var(--good-text); font-variant-numeric: tabular-nums; }
.calendar .day .heat { position: absolute; inset: auto 6px 6px 6px; height: 4px; border-radius: 2px; background: var(--s-depenses); }

/* Import */
.dropzone { border: 2px dashed var(--axis); border-radius: var(--radius); padding: 36px; text-align: center; color: var(--text-2); cursor: pointer; background: var(--surface); }
.dropzone.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.mapping { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }

/* Chat IA */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 520px; overflow-y: auto; padding: 4px; }
.msg { padding: 10px 14px; border-radius: 12px; max-width: 85%; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); }
.markdown h1, .markdown h2, .markdown h3 { margin: 14px 0 6px; font-size: 1.05rem; }
.markdown p { margin: 6px 0; } .markdown ul, .markdown ol { margin: 6px 0; padding-left: 22px; }
.markdown table { margin: 8px 0; }

/* Modal & toasts */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 20px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--page); padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow); max-width: 380px; font-size: .9rem; }
.toast.error { background: var(--critical); color: #fff; }
.toast { display: flex; align-items: center; gap: 12px; }
.toast-action { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 6px; padding: 3px 10px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.toast-action:hover { background: color-mix(in srgb, currentColor 15%, transparent); }
.chart-tooltip-note { font-size: .8rem; color: var(--muted); }
.empty { text-align: center; padding: 30px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 8px 12px; font: inherit; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
pre { background: var(--surface-2); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: .82rem; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; }
.error { color: var(--critical); min-height: 1em; margin: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  #menu-toggle { display: inline-block; }
  .view { padding: 14px 12px 60px; }
  .topbar { padding: 10px 12px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .calendar .day { min-height: 54px; font-size: .7rem; padding: 4px; }
}
@media print {
  .sidebar, .topbar .filters, #menu-toggle, .btn { display: none !important; }
  .layout { display: block; } .card { break-inside: avoid; box-shadow: none; }
}

/* Multi-devise */
select.currency-select { width: auto; min-width: 72px; }
.quick-entry select.currency-select { flex: 0 0 auto; }
.fx-note { font-weight: 400; white-space: nowrap; }

/* Barre « Rechercher ou saisir » */
.palette-backdrop { place-items: start center; padding-top: 10vh; }
.palette { background: var(--surface); border-radius: var(--radius); width: min(680px, 100%); box-shadow: 0 12px 40px rgba(0,0,0,.25); display: flex; flex-direction: column; overflow: hidden; }
.palette-input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 16px 18px; font-size: 1.05rem; background: transparent; }
.palette-input:focus { outline: none; }
.palette-results { max-height: 55vh; overflow-y: auto; padding: 6px; }
.palette-group { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.palette-item > div { flex: 1; min-width: 0; }
.palette-item.active { background: var(--surface-2); }
.palette-item.add { border: 1px solid var(--accent); }
.palette-icon { width: 24px; text-align: center; color: var(--muted); }
.palette-item.add .palette-icon { color: var(--accent); font-weight: 700; }
.palette-hint { border-top: 1px solid var(--border); padding: 8px 14px; }
.palette-empty, .palette-loading { padding: 10px 12px; margin: 0; }
.search-trigger { display: flex; align-items: center; gap: 8px; color: var(--muted); min-width: 220px; justify-content: space-between; }
.search-trigger kbd { font: inherit; font-size: .75rem; border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
.fab { display: none; position: fixed; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 1.8rem; box-shadow: 0 6px 18px rgba(0,0,0,.25); z-index: 40; cursor: pointer; }
@media (max-width: 760px) { .fab { display: block; } .search-trigger { min-width: 0; } .search-trigger kbd { display: none; } .toasts { bottom: 86px; } }
.card.notice { border-left: 4px solid var(--accent); }
.user-chip { color: rgba(255,255,255,.85); font-size: .85rem; padding: 4px 10px; }

/* Assistant de démarrage */
.wizard-steps { display: flex; gap: 8px; flex-wrap: wrap; }
.wizard-steps button { font: inherit; display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.wizard-steps button.active { border-color: var(--accent); color: var(--text); font-weight: 600; }
.wizard-num { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: .8rem; }
.wizard-steps .active .wizard-num { background: var(--accent); color: #fff; }
.wizard-steps .done .wizard-num { background: var(--s-epargne); color: #fff; }
.wizard-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }

/* Objectifs d'épargne */
.grid.goals { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: stretch; } /* même hauteur par rangée */
.card.goal > .row:last-child { margin-top: auto; } /* boutons alignés en bas */
.card.goal { display: flex; flex-direction: column; gap: 10px; }
.goal-amounts { display: flex; align-items: baseline; gap: 6px; }
.goal-now { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.goal-bar { height: 10px; position: relative; overflow: visible; }
.goal-bar > div { background: var(--s-epargne); }
.goal-marker { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--text-2); border-radius: 1px; }
.goal-list { display: flex; flex-direction: column; gap: 12px; }
.goal-list .bar > div { background: var(--s-epargne); }
.status { font-size: .8rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; color: var(--text-2); }
.status.good { border-color: var(--good); } .status.good span { color: var(--good-text); }
.status.warn { border-color: var(--warning); } .status.warn span { color: var(--critical); }
.status.info span { color: var(--accent); }
.modal:has(.table-wrap table) { width: min(920px, 100%); }
.demo-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 16px; font-size: .85rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.pill.warn { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--text); }
.pill.bad { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--critical); }
.express-list { display: flex; flex-direction: column; gap: 6px; }
.express-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.express-item > button { margin-left: auto; }
.notice-inline { border-left: 3px solid var(--accent); padding: 4px 10px; background: color-mix(in srgb, var(--accent) 7%, transparent); border-radius: 6px; }
.bank-conn { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.bank-conn td { vertical-align: top; }
.bank-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; max-height: 50vh; overflow: auto; }
.bank-item { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.bank-item:hover { border-color: var(--accent); }
.bank-item img { width: 28px; height: 28px; object-fit: contain; }
.wizard-howto { display: grid; gap: 10px; padding-left: 1.2em; margin: 0; font-size: .9rem; }
.copy-box { padding: 6px 10px; background: var(--surface-2); border-radius: 6px; font-size: .8rem; word-break: break-all; }
.warn-text { color: var(--warning); }

/* Licence */
.demo-banner.readonly { background: color-mix(in srgb, var(--warning) 16%, var(--surface)); border-bottom-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 8px 0 12px; }
.facts dt { color: var(--text-2); } .facts dd { margin: 0; }
.steps { display: grid; gap: 12px; padding-left: 20px; }
.pair-code { font: 600 2rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; margin: 8px 0; padding: 10px 16px; display: inline-block;
  background: var(--surface-2, color-mix(in srgb, var(--text) 6%, transparent)); border-radius: 10px; }
.meter { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--text) 10%, transparent); overflow: hidden; margin: 8px 0 4px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.spinner { width: 14px; height: 14px; border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
a.btn { text-decoration: none; }
.steps .pair-code { display: block; width: max-content; }
details > summary.small { margin-top: 10px; }
.recovery-code { font: 600 1.05rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; word-spacing: .3em; padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--text) 6%, transparent); user-select: all; }

/* Chasse aux abonnements */
.segmented.small button { font-size: .78rem; padding: 4px 9px; }
table.subs tr.muted td { color: var(--muted); }
details.card > summary { cursor: pointer; padding: 2px 0; }
details.card[open] > summary { margin-bottom: 12px; }

/* Reste à vivre du jour (tableau de bord) */
.reste-vivre { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; border-left: 4px solid var(--good); }
.reste-vivre.warn { border-left-color: var(--warning); } .reste-vivre.bad { border-left-color: var(--critical); }
.rv-main { display: flex; flex-direction: column; min-width: 220px; }
.rv-label { color: var(--text-2); font-size: .85rem; }
.rv-value { font-size: 2.4rem; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rv-value small { font-size: 1rem; font-weight: 500; color: var(--text-2); }
.rv-until { color: var(--text-2); }
.rv-side { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; flex: 1; min-width: 240px; }
.status.bad { border-color: var(--critical); } .status.bad span { color: var(--critical); }

/* Calendrier des échéances */
.calendar.agenda { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar.agenda .day { min-height: 92px; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden; }
.calendar.agenda .day.past { background: var(--surface-2); }
.calendar.agenda .day.short { border-color: var(--critical); }
.calendar .ev { display: flex; gap: 4px; justify-content: space-between; font-size: .7rem; line-height: 1.25; padding: 1px 4px; border-radius: 4px;
  background: color-mix(in srgb, var(--s-depenses) 12%, transparent); }
.calendar .ev.in { background: color-mix(in srgb, var(--good) 14%, transparent); }
.calendar .ev.paid { opacity: .6; text-decoration: line-through; }
.calendar .ev-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.calendar .ev-a { font-variant-numeric: tabular-nums; white-space: nowrap; }
.calendar .solde { margin-top: auto; font-size: .7rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.calendar .solde.neg { color: var(--critical); font-weight: 600; }
@media (max-width: 700px) { .calendar .ev-l { display: none; } .calendar.agenda .day { min-height: 70px; } }

/* Ticket de caisse rattaché à une opération */
.receipt-pill { border: none; cursor: pointer; margin-left: 6px; font: inherit; font-size: .75rem; }
.receipt-pill:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

/* Espace enfants */
.card.kid { border-top: 4px solid var(--c); display: flex; flex-direction: column; gap: 10px; }
.kid-avatar { font-size: 2rem; line-height: 1; }
.kid-balance { display: flex; flex-direction: column; } .kid-balance strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
body.kid-mode .sidebar, body.kid-mode .topbar, body.kid-mode .fab, body.kid-mode .demo-banner { display: none; }
body.kid-mode .layout { grid-template-columns: 1fr; }
.kid-screen { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; padding: 12px 4px 40px; text-align: center; }
.kid-exit { align-self: flex-start; }
.kid-hello { font-size: 2rem; font-weight: 750; }
.kid-piggy { display: flex; align-items: center; justify-content: center; gap: 18px; background: var(--surface); border-radius: 24px; padding: 22px; border: 3px solid var(--c); }
.kid-pig { font-size: 4.5rem; line-height: 1; }
.kid-label { font-size: 1.15rem; color: var(--text-2); font-weight: 600; }
.kid-amount { font-size: 3.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kid-next { font-size: 1.15rem; }
.kid-goal { background: var(--surface); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--border); }
.kid-bar { position: relative; height: 34px; border-radius: 17px; background: var(--surface-2); overflow: hidden; }
.kid-bar > div { height: 100%; background: var(--c); border-radius: 17px; }
.kid-bar > span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; }
.kid-msg { font-size: 1.25rem; font-weight: 600; }
.kid-moves { display: flex; flex-direction: column; gap: 6px; text-align: left; background: var(--surface); border-radius: 18px; padding: 16px; border: 1px solid var(--border); }
.kid-move { display: grid; grid-template-columns: 2rem 1fr auto; gap: 8px; font-size: 1.05rem; }
.kid-month { color: var(--text-2); }

/* Coffre à papiers */
.row.nowrap { flex-wrap: nowrap; }
a.receipt-pill { text-decoration: none; }

/* Aide à la déclaration d'impôts */
.tax-line { display: flex; flex-wrap: wrap; gap: 12px 40px; align-items: flex-start; }
.tax-amount { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
@media print { .no-print, .sidebar, .topbar, .fab, .demo-banner { display: none !important; } details { display: block; } }

/* Bilan du mois */
.review-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.review-facts > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.review-facts strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

/* Mode magasin (codes-barres) */
.store-mode { display: flex; flex-direction: column; gap: 10px; min-width: min(560px, 86vw); }
.basket-total { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.basket-budget { display: flex; flex-direction: column; gap: 4px; }
.scan-box { position: relative; display: grid; place-items: center; min-height: 54px; }
.scan-video { width: 100%; max-height: 34vh; object-fit: cover; border-radius: 12px; background: #000; }
.scan-aim { position: absolute; left: 15%; right: 15%; top: 50%; height: 2px; background: var(--critical); box-shadow: 0 0 8px var(--critical); }

/* Paramètres › Catégories : groupes repliables */
.cat-group { border: 1px solid var(--border); border-radius: 10px; margin: 10px 0; background: var(--surface); }
.cat-group > summary { display: flex; align-items: center; gap: 6px; padding: 10px 14px; cursor: pointer; list-style: none; flex-wrap: wrap; }
.cat-group > summary::-webkit-details-marker { display: none; }
.cat-group > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
.cat-group[open] > summary::before { transform: rotate(90deg); }
.cat-group[open] > summary { border-bottom: 1px solid var(--border); }
.cat-group .cat-actions { gap: 4px; }
.cat-group .table-wrap { padding: 4px 10px 10px; }
.cat-group tr.cat-off td { opacity: .5; }
.cat-group tr.cat-off td:first-child { opacity: 1; }

/* Paramètres › IA : choix du fournisseur */
.ai-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.ai-tile { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
.ai-tile:hover { border-color: var(--accent); }
.ai-tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.ai-detect { margin: 10px 0; }
.ai-found { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin: 6px 0; }
.card details.small { margin: 12px 0; }
.card details.small > summary { cursor: pointer; font-weight: 600; }
.cat-group > summary .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
/* sélecteur de couleur en pastille ronde (membres) */
input[type="color"] { -webkit-appearance: none; appearance: none; width: 30px; height: 30px; min-width: 30px; padding: 0; border: 2px solid var(--border); border-radius: 50%; background: none; cursor: pointer; overflow: hidden; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 50%; }
.notice-inline.warn { border-left-color: var(--warning, #c98a00); background: color-mix(in srgb, var(--warning, #c98a00) 10%, transparent); }

/* Courrier de résiliation */
.letter-dialog { display: flex; flex-direction: column; gap: 12px; }
.letter-dialog textarea { width: 100%; font: inherit; }
.letter-text { font-family: Georgia, 'Times New Roman', serif !important; line-height: 1.5; white-space: pre-wrap; }
#print-letter { display: none; }
@media print {
  body.printing-letter > *:not(#print-letter) { display: none !important; }
  body.printing-letter #print-letter { display: block; white-space: pre-wrap; font: 12pt/1.5 Georgia, 'Times New Roman', serif; color: #000; background: #fff; padding: 2cm; }
}
.modal:has(.letter-dialog) { width: min(880px, 100%); }

/* Planner papier : vérification des lignes lues */
.planner-review input, .planner-review select { min-width: 0; }
.planner-review td:nth-child(5) input { min-width: 180px; width: 100%; }
.planner-review tr.uncertain td { background: color-mix(in srgb, var(--coral, #e2876a) 10%, transparent); }
