/* Compta annexe — registre de travail : papier chaud, encre, un seul vert pour l'action. */

:root {
  --bg: #f6f7f5;
  --panel: #eceeea;
  --field: #ffffff;
  --strip: #eef1ed;
  --line: #dfe3dd;
  --line-strong: #c5cbc3;
  --text: #1a201c;
  --muted: #5b625c;
  --faint: #6c736c;
  --accent: #1f6f4f;
  --accent-hover: #185b40;
  --accent-soft: #e1ece5;
  --on-accent: #ffffff;
  --danger: #a8352b;
  --danger-soft: #f6e3df;
  --warn: #8a5a0c;
  --warn-soft: #f5ead4;
  --info: #2c5a8a;
  --info-soft: #e3ebf3;
  --bar-in: #1f6f4f;
  --bar-out: #bf8b3f;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151714;
    --panel: #1b1e1a;
    --field: #1f231f;
    --strip: #1d201c;
    --line: #2b2f2a;
    --line-strong: #3b4039;
    --text: #e6e7e1;
    --muted: #a0a398;
    --faint: #8a8d84;
    --accent: #5cb98c;
    --accent-hover: #74c89f;
    --accent-soft: #1d3328;
    --on-accent: #0c1912;
    --danger: #ea8075;
    --danger-soft: #3a211d;
    --warn: #ddb064;
    --warn-soft: #352a17;
    --info: #86b2e0;
    --info-soft: #1b2836;
    --bar-in: #5cb98c;
    --bar-out: #c99a55;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151714;
  --panel: #1b1e1a;
  --field: #1f231f;
  --strip: #1d201c;
  --line: #2b2f2a;
  --line-strong: #3b4039;
  --text: #e6e7e1;
  --muted: #a0a398;
  --faint: #8a8d84;
  --accent: #5cb98c;
  --accent-hover: #74c89f;
  --accent-soft: #1d3328;
  --on-accent: #0c1912;
  --danger: #ea8075;
  --danger-soft: #3a211d;
  --warn: #ddb064;
  --warn-soft: #352a17;
  --info: #86b2e0;
  --info-soft: #1b2836;
  --bar-in: #5cb98c;
  --bar-out: #c99a55;
  color-scheme: dark;
}

/* Espace Perso : même interface, accent bleu pour ne jamais confondre avec le Pro. */
body[data-space="perso"] { --accent: #2f5f98; --accent-hover: #264f80; --accent-soft: #e2eaf4; --bar-in: #2f5f98; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body[data-space="perso"] { --accent: #7fb0e6; --accent-hover: #98c1ee; --accent-soft: #1b2a3c; --bar-in: #7fb0e6; }
}
:root[data-theme="dark"] body[data-space="perso"] { --accent: #7fb0e6; --accent-hover: #98c1ee; --accent-soft: #1b2a3c; --bar-in: #7fb0e6; }

/* Base -------------------------------------------------------------------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 100%; scrollbar-color: var(--line-strong) transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: .875rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent);
}
::selection { background: var(--accent-soft); color: var(--text); }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; font-weight: 600; }
h1 { font-size: 1.4375rem; letter-spacing: -.01em; }
h2 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .8125rem; }
.num, .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 6px; font-weight: 600; text-decoration: none; transition: top .15s var(--ease); }
.skip-link:focus { top: 12px; color: var(--on-accent); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.main:focus { outline: none; }
.main h1:focus { outline: none; }
kbd { font-family: inherit; font-size: .75rem; color: var(--muted); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; margin-left: 2px; }
.btn.primary kbd { color: var(--on-accent); border-color: color-mix(in srgb, var(--on-accent) 45%, transparent); }
svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Structure --------------------------------------------------------------- */

.app { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 20px;
  padding: 22px 12px 16px;
}
.wordmark { font-weight: 650; font-size: 1rem; letter-spacing: -.01em; padding: 0 10px; }
.year { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px; color: var(--muted); font-size: .8125rem; }
.year select { width: auto; min-height: 30px; padding: 3px 26px 3px 8px; font-weight: 600; color: var(--text); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.space-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; margin: 0 4px; border-radius: 8px; background: color-mix(in srgb, var(--text) 7%, transparent); }
.space-switch a { text-align: center; padding: 6px 8px; border-radius: 6px; color: var(--muted); font-weight: 600; text-decoration: none; transition: background-color .15s var(--ease), color .15s var(--ease); }
.space-switch a:hover { color: var(--text); }
.space-switch a[aria-current="page"] { background: var(--field); color: var(--accent); box-shadow: 0 1px 2px rgba(30, 28, 20, .1); }
.term.result.negative .t-value { color: var(--danger); }
td.amount.in { color: var(--accent); }
.over { color: var(--danger); }
.pro-bridge { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin: -24px 0 36px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--strip); }
.budget-input { width: 8rem; text-align: right; font-variant-numeric: tabular-nums; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  color: var(--muted); text-decoration: none; font-weight: 500;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.nav a[aria-current="page"] { background: var(--field); color: var(--text); box-shadow: 0 1px 2px rgba(30, 28, 20, .08); }
.nav a[aria-current="page"] svg { color: var(--accent); }
.save-status { margin-top: auto; padding: 0 10px; font-size: .75rem; color: var(--faint); }
.save-status.err { color: var(--danger); }
.save-status button { font: inherit; color: var(--danger); background: none; border: none; padding: 0; text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
.theme-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; padding: 2px; background: var(--field); }
.theme-switch label { position: relative; padding: 5px 12px; border-radius: 5px; cursor: pointer; color: var(--muted); font-weight: 500; transition: background-color .15s var(--ease), color .15s var(--ease); }
.theme-switch input { position: absolute; opacity: 0; pointer-events: none; }
.theme-switch label:has(input:checked) { background: var(--accent-soft); color: var(--text); }
.theme-switch label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

.main { padding: 32px 40px 72px; max-width: 1180px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head .lede { margin-top: 6px; color: var(--muted); max-width: 62ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.section { margin-top: 40px; }
.section > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line-strong); margin-bottom: 4px; }
.section > header .aside { color: var(--muted); font-size: .8125rem; }
.cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.cols-even { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.cols > .section, .cols-even > .section { margin-top: 0; }

/* Synthèse : l'équation du résultat --------------------------------------- */

.equation {
  display: flex; align-items: flex-end; gap: 6px 18px; flex-wrap: wrap;
  padding: 4px 0 20px; border-bottom: 1px solid var(--line-strong);
}
.term { display: flex; flex-direction: column; gap: 2px; }
.term .t-label { color: var(--muted); font-size: .8125rem; }
.term .t-value { font-size: 1.1875rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.term.result .t-value { color: var(--accent); }
.op { color: var(--faint); font-size: 1.1875rem; padding-bottom: 1px; }
.equation-note { margin: 10px 0 40px; color: var(--muted); font-size: .8125rem; }

/* Liste « à faire » */
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { border-bottom: 1px solid var(--line); }
.todo a, .todo .row {
  display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline;
  padding: 12px 2px; color: var(--text); text-decoration: none;
}
.todo a:hover .todo-title { color: var(--accent); }
.todo .mark { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); transform: translateY(-1px); }
.todo .mark.danger { background: var(--danger); }
.todo .mark.warn { background: var(--warn); }
.todo .mark.ok { background: var(--accent); }
.todo-title { font-weight: 500; transition: color .15s var(--ease); }
.todo-sub { grid-column: 2 / 3; color: var(--muted); font-size: .8125rem; }
.todo-when { color: var(--muted); font-size: .8125rem; white-space: nowrap; }

/* Graphique */
.chart { width: 100%; height: auto; display: block; margin-top: 14px; }
.chart text { fill: var(--faint); font-size: 12px; font-family: inherit; }
.chart .gridline { stroke: var(--line); }
.chart .baseline { stroke: var(--line-strong); }
.chart-data { margin-top: 10px; }
.chart-data summary { cursor: pointer; color: var(--muted); font-size: .8125rem; width: fit-content; border-radius: 4px; }
.chart-data summary:hover { color: var(--text); }
.chart-data table { margin-top: 8px; }
.chart-empty { height: 200px; display: grid; place-items: center; text-align: center; color: var(--muted); border-bottom: 1px solid var(--line-strong); margin-top: 14px; }
.legend { display: flex; gap: 14px; font-size: .8125rem; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* Jauge de seuil intégrée au tableau */
.meter { display: flex; align-items: center; gap: 10px; min-width: 130px; }
.meter-track { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); }
.meter-fill.warn { background: var(--warn); }
.meter-fill.danger { background: var(--danger); }
.meter span { font-size: .8125rem; color: var(--muted); width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }

/* Tableaux ---------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: baseline; }
th:first-child, td:first-child { padding-left: 2px; }
th:last-child, td:last-child { padding-right: 2px; }
th { font-size: .75rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
td.right, th.right { text-align: right; }
td.amount { text-align: right; font-weight: 500; }
td .sub { display: block; color: var(--muted); font-size: .8125rem; }
tbody tr { transition: background-color .15s var(--ease); }
tbody tr:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
tbody tr.is-editing { background: var(--accent-soft); }
th .sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; }
th .sort:hover { color: var(--text); }
th .sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
th .sort svg { width: 12px; height: 12px; opacity: .35; }
th[aria-sort] .sort { color: var(--text); }
th[aria-sort] .sort svg { opacity: 1; }
th.right .sort { flex-direction: row-reverse; }
tfoot td { font-weight: 600; border-bottom: none; border-top: 1px solid var(--line-strong); }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; align-items: center; vertical-align: middle; }
td:has(> .row-actions) { vertical-align: middle; padding-top: 4px; padding-bottom: 4px; }
tr.inline-row > td { background: var(--strip); padding: 16px 14px; }
tr.inline-row:hover { background: none; }
.inline-row .form-grid { max-width: 640px; }

.empty { padding: 28px 2px 8px; color: var(--muted); max-width: 62ch; }
.empty strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }

/* Statuts */
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; white-space: nowrap; color: var(--muted); }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.ok { color: var(--accent); }
.tag.warn { color: var(--warn); }
.tag.danger { color: var(--danger); }
.tag.info { color: var(--info); }
.act { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.act .swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.act .regime { font-size: .6875rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 4px; line-height: 1.45; }
.view-switch { display: flex; align-items: center; gap: 10px; margin: -12px 0 22px; }
tr.group-row th { padding-top: 22px; font-size: .875rem; color: var(--text); border-bottom: 1px solid var(--line-strong); }
tr.group-row th span { color: var(--muted); font-weight: 400; margin-left: 6px; }
tbody tr.group-row:hover, tbody tr.subtotal:hover { background: none; }
tr.subtotal td { font-weight: 600; border-bottom: none; }
tr.subtotal td.amount { font-weight: 600; }

/* Formulaires ------------------------------------------------------------- */

input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--field); border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 7px 10px; min-height: 36px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; accent-color: var(--accent); cursor: pointer; }
input[type="color"] { padding: 3px; height: 36px; cursor: pointer; }
textarea { resize: vertical; min-height: 64px; }
select {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 13px center, right 9px center; background-size: 4px 4px; background-repeat: no-repeat;
}

.field { display: flex; flex-direction: column; gap: 5px; font-size: .8125rem; font-weight: 500; color: var(--text); }
.field small { color: var(--muted); font-weight: 400; }
.check { display: flex; align-items: center; gap: 9px; font-size: .875rem; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.entry { grid-template-columns: 9.5rem 8rem minmax(0, 1fr) minmax(0, 1fr); }
.form-grid.entry .wide { grid-column: span 2; }
.form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.req { color: var(--danger); text-decoration: none; margin-left: 2px; font-weight: 500; }
.field-error { display: flex; gap: 5px; align-items: baseline; color: var(--danger); font-weight: 400; font-size: .8125rem; }
.field-error::before { content: "!"; display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: var(--danger); color: var(--field); font-size: 10px; font-weight: 700; flex: none; transform: translateY(2px); }
[aria-invalid="true"] { border-color: var(--danger); }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-soft); border-color: var(--danger); }
.form-error { color: var(--danger); font-size: .8125rem; margin-right: auto; }
.form-error:empty { display: none; }

.strip { background: var(--strip); border: 1px solid var(--line); border-radius: 8px; padding: 18px 18px 16px; margin-bottom: 28px; }
.strip > h2 { margin-bottom: 14px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.filters select { width: auto; }
.filters input[type="search"] { width: 260px; max-width: 100%; }

.settings-block { padding: 28px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: 24px 40px; }
.settings-block:first-of-type { padding-top: 0; }
.settings-block .intro p { color: var(--muted); font-size: .8125rem; margin-top: 6px; max-width: 34ch; }

/* Boutons ----------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-weight: 500; line-height: 1.2; white-space: nowrap; text-decoration: none;
  min-height: 34px; padding: 7px 13px; border-radius: 6px; cursor: pointer;
  color: var(--text); background: var(--field); border: 1px solid var(--line-strong);
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover { border-color: var(--faint); color: var(--text); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.btn.danger-text { color: var(--danger); }
.btn.small { min-height: 28px; padding: 4px 10px; font-size: .8125rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 6px;
  border: none; background: none; color: var(--faint); cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Éditeur de facture ------------------------------------------------------ */

.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 36px; align-items: start; }
.lines { margin-top: 22px; }
.lines th, .lines td { padding: 6px 6px; border: none; }
.lines td:first-child, .lines th:first-child { padding-left: 0; }
.lines tbody tr:hover { background: none; }
.lines input { min-height: 34px; padding: 6px 8px; }
.lines td.amount { padding-top: 14px; }
.editor-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line-strong); margin-top: 12px; padding-top: 12px; }
.editor-total strong { font-size: 1.1875rem; font-variant-numeric: tabular-nums; }
.editor-sub { display: flex; justify-content: space-between; gap: 12px; padding-top: 6px; font-size: .8125rem; }
.editor-sub + .editor-total { margin-top: 8px; }
.acomptes { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 12px; margin: 18px 0 0; }
.acomptes legend { font-size: .8125rem; font-weight: 600; padding: 0 4px; }
.acomptes .check { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 6px 0; }
.acomptes .sub { display: block; color: var(--muted); font-size: .8125rem; }
.paid-box { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 12px; }
.paid-box:not(:has(input[name="dejaPaye"]:checked)) .paid-fields { display: none; }
.paid-box:has(input[name="dejaPaye"]:checked) .paid-off { display: none; }
.invoice .inv-ref { margin: -10px 0 22px; }
.preview { position: sticky; top: 24px; }
.preview .caption { color: var(--muted); font-size: .8125rem; margin-bottom: 8px; }
.paper { background: #fff; border: 1px solid var(--line); border-radius: 3px; box-shadow: 0 2px 12px rgba(30, 28, 20, .08); }
.paper .invoice { padding: 36px 38px 40px; font-size: 11.5px; }

/* Facture (aperçu et impression) */
.invoice { color: #1b1b18; background: #fff; font-size: 12.5px; line-height: 1.5; }
.invoice .inv-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 36px; }
.invoice .inv-title { font-size: 2em; font-weight: 650; letter-spacing: -.01em; line-height: 1.1; margin-bottom: 10px; }
.invoice .inv-meta { color: #55574f; }
.invoice .inv-meta b { color: #1b1b18; font-weight: 600; }
.invoice .seller { text-align: right; color: #55574f; }
.invoice .seller b { color: #1b1b18; }
.invoice .buyer { margin: 0 0 30px auto; width: 48%; }
.invoice .lbl { font-size: .85em; color: #77796f; margin-bottom: 4px; }
.invoice table th { color: #55574f; font-size: .85em; border-bottom: 1px solid #1b1b18; padding: 6px 8px; }
.invoice table td { border-bottom: 1px solid #e6e4dd; padding: 8px 8px; color: #1b1b18; }
.invoice table th:first-child, .invoice table td:first-child { padding-left: 0; }
.invoice table th:last-child, .invoice table td:last-child { padding-right: 0; }
.invoice tbody tr:hover { background: none; }
.invoice .inv-total { margin: 14px 0 0 auto; width: 46%; }
.invoice .inv-total div { display: flex; justify-content: space-between; padding: 4px 0; color: #55574f; font-variant-numeric: tabular-nums; }
.invoice .inv-total .grand { border-top: 1px solid #1b1b18; margin-top: 6px; padding-top: 8px; color: #1b1b18; font-weight: 650; font-size: 1.15em; }
.invoice .inv-note { margin-top: 24px; }
.invoice .mentions { margin-top: 40px; font-size: .85em; color: #66685f; line-height: 1.6; }
.invoice .mentions b { color: #1b1b18; font-weight: 600; }
.print-area { display: none; }

/* Retour d'action --------------------------------------------------------- */

.toast {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg);
  padding: 9px 16px; border-radius: 8px; font-weight: 500; z-index: 60;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}
.toast[hidden] { display: none; }
.toast:has(button) { padding-right: 8px; }
.toast button { font: inherit; font-weight: 600; color: var(--bg); background: color-mix(in srgb, var(--bg) 18%, transparent); border: none; border-radius: 5px; padding: 4px 10px; cursor: pointer; }

.dialog-backdrop { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(12, 16, 13, .45); }
.dialog { width: min(420px, 100%); background: var(--field); color: var(--text); border-radius: 10px; padding: 22px 22px 18px; box-shadow: 0 16px 48px rgba(0, 0, 0, .25); }
.dialog h2 { font-size: 1.0625rem; margin-bottom: 8px; }
.dialog p { color: var(--muted); }
.btn.primary.danger-fill { background: var(--danger); border-color: var(--danger); color: var(--field); }
.btn.primary.danger-fill:hover { filter: brightness(1.08); background: var(--danger); border-color: var(--danger); }
.declare-help { margin-top: 32px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--strip); }
.declare-help h2 { margin-bottom: 12px; }
.declare-ways { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px 32px; }
.declare-ways p + * { margin-top: 8px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; color: var(--muted); }
@media (max-width: 760px) { .declare-ways { grid-template-columns: minmax(0, 1fr); } }
body.locked .sidebar { display: none; }
body.locked .app { grid-template-columns: minmax(0, 1fr); }
.login { max-width: 360px; margin: 12vh auto 0; display: grid; gap: 16px; }
.login .btn { justify-self: start; }
.pay-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px 32px; align-items: center; margin-bottom: 28px; padding: 18px 20px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--field); }
.pay-card.empty-pay { display: block; background: var(--strip); border-color: var(--line); }
.pay-main { display: flex; flex-direction: column; gap: 2px; }
.pay-main .t-label { color: var(--muted); font-size: .8125rem; }
.pay-amount { font-size: 1.75rem; font-weight: 650; letter-spacing: -.01em; color: var(--accent); font-variant-numeric: tabular-nums; }
.pay-card.negative .pay-amount { color: var(--danger); }
.pay-day { color: var(--muted); font-size: .875rem; }
.pay-detail { display: grid; gap: 4px; }
.list-line { display: flex; justify-content: space-between; gap: 12px; font-size: .875rem; }
.pay-detail p { margin-top: 4px; }
tr.past td { color: var(--faint); }
@media (max-width: 760px) { .pay-card { grid-template-columns: minmax(0, 1fr); } }
.notice { color: var(--muted); font-size: .8125rem; max-width: 72ch; }
.notice strong { color: var(--text); font-weight: 600; }
.muted { color: var(--muted); }
.sm-only { display: none; }
.small { font-size: .8125rem; }
.mt { margin-top: 16px; }

@media print {
  @page { size: A4; margin: 16mm 14mm; }
  body { background: #fff; }
  .app, .toast { display: none !important; }
  .print-area { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
  .btn:active { transform: none; }
}

/* Pointeur tactile : cibles d'au moins 44 px */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; padding: 8px 12px; }
  .icon-btn { width: 44px; height: 44px; }
  input, select, textarea { min-height: 44px; }
  .nav a { padding: 11px 12px; }
  * { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
}

/* Écrans étroits ---------------------------------------------------------- */

@media (max-width: 1080px) {
  .cols, .cols-even, .editor { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
  .form-grid.entry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 14px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); gap: 12px; display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .wordmark, .year { padding: 0; }
  .space-switch { grid-column: 1 / -1; margin: 0; }
  .nav { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav a { white-space: nowrap; padding: 7px 10px; }
  .save-status { display: none; }
  .main { padding: 22px max(16px, env(safe-area-inset-right, 0px)) 56px max(16px, env(safe-area-inset-left, 0px)); }
  body { font-size: 1rem; }
  .sm-only { display: inline; }
  input, select, textarea { font-size: 1rem; }
  /* Tableaux de saisie empilés en fiches lisibles */
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack tbody tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
  table.stack tbody td { border: none; padding: 0; }
  table.stack tbody td[data-cell="main"] { order: 1; flex: 1 1 55%; min-width: 0; }
  table.stack tbody td[data-cell="amount"] { order: 2; text-align: right; font-weight: 600; }
  table.stack tbody td[data-cell="meta"] { order: 3; color: var(--muted); font-size: .875rem; }
  table.stack tbody td[data-cell="meta"]:empty { display: none; }
  table.stack tbody td[data-cell="actions"] { order: 4; flex-basis: 100%; }
  table.stack tbody td[data-cell="actions"] .row-actions { justify-content: flex-start; margin-left: -8px; }
  table.stack tfoot tr { display: flex; justify-content: space-between; }
  table.stack tfoot td[colspan] { flex: 1; }
  table.stack tfoot td:empty { display: none; }
  table.stack tr.inline-row { display: block; }
  .form-grid, .form-grid.entry { grid-template-columns: minmax(0, 1fr); }
  .form-grid.entry .wide { grid-column: auto; }
  .settings-block { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .filters input[type="search"] { width: 100%; }
  .invoice .buyer, .invoice .inv-total { width: 100%; }
}
