/* ══════════════════════════════════════════════════════════════════════════
   Gestion Budget — feuille unique (style « Modernist », palette citron).
   Base : design_handoff_refonte_gestion_budget/design-system/styles.css.
   Grille visible, filets de 2 px, angles droits, Archivo, un seul accent.
   ══════════════════════════════════════════════════════════════════════ */

/* ─── Tokens : palette citron (retenue) ─────────────────────────────────── */
:root {
  --color-bg: #0f110f;
  --color-surface: #181b18;
  --color-text: #eef0e8;
  --color-accent: #c6f432;
  --color-accent-2: #c6f432;
  --color-divider: color-mix(in srgb, #eef0e8 26%, transparent);

  --color-neutral-100: #161916;
  --color-neutral-200: #202420;
  --color-neutral-300: #2e332e;
  --color-neutral-400: #454b45;
  --color-neutral-500: #666d66;
  --color-neutral-600: #8a918a;
  --color-neutral-700: #a8aea8;
  --color-neutral-800: #c6cbc6;
  --color-neutral-900: #e2e5e2;

  --color-accent-100: #1c2410;
  --color-accent-200: #2a3812;
  --color-accent-300: #3f5416;
  --color-accent-400: #d6f86a;
  --color-accent-500: #c6f432;
  --color-accent-600: #d4fa5a;
  --color-accent-700: #dffb85;
  --color-accent-800: #e8fca6;
  --color-accent-900: #f3fdd2;

  --font-heading: "Archivo", system-ui, sans-serif;
  --font-heading-weight: 800;
  --font-body: "Archivo", system-ui, sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;

  --shadow-lg: 0 12px 32px color-mix(in srgb, #2d2b2b 22%, transparent);

  --sidebar-w: 248px;
  --topbar-h: 64px;

  color-scheme: dark;
}

/* ─── Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--color-bg); color: var(--color-text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55; font-weight: 400;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
h1 { font-size: 42px; }
h2 { font-size: 32px; }
h3 { font-size: 25px; }
h4 { font-size: 20px; }
h5 { font-size: 16px; }
h6 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
a:hover { color: var(--color-accent-600); }
img { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; }
strong, b { font-weight: 800; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }
[hidden] { display: none !important; }

/* Icônes Lucide (SVG injectés par lucide.createIcons) */
.lucide, [data-lucide] { width: 17px; height: 17px; flex: none; stroke-width: 2; }
.icon-16 { width: 16px; height: 16px; }
.icon-20 { width: 20px; height: 20px; }
.icon-22 { width: 22px; height: 22px; }

/* ─── Utilitaires ───────────────────────────────────────────────────────── */
.muted { color: var(--color-neutral-700); }
.accent { color: var(--color-accent); }
.alert-text { color: var(--color-accent-700); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.w-800 { font-weight: 800; }
.w-600 { font-weight: 600; }
.stack { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.gap-28 { gap: 28px; } .gap-32 { gap: 32px; } .gap-36 { gap: 36px; } .gap-40 { gap: 40px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.m-0 { margin: 0; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.hr { height: 2px; border: 0; margin: var(--space-4) 0; background: var(--color-divider); }

/* ─── Boutons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.btn:hover { color: var(--color-text); }
.btn svg { display: block; width: 16px; height: 16px; }
.btn:disabled, .btn.is-disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--color-accent); color: var(--color-bg); }
.btn-primary:hover { background: var(--color-accent-600); color: var(--color-bg); }
.btn-primary:active { background: var(--color-accent-700); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:hover { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-danger { border-color: var(--color-accent); color: var(--color-accent); }
.btn-danger:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); color: var(--color-accent); }
.btn-icon { width: 36px; height: 36px; padding: 0; flex: none; }
.btn-lg { padding: 14px 20px; font-size: 15px; }
.btn-wide { justify-content: flex-start; text-align: left; }
.btn-block { width: 100%; justify-content: flex-start; text-align: left; }
.btn-inverse { background: var(--color-bg); color: var(--color-text); }
.btn-inverse:hover { background: var(--color-neutral-200); color: var(--color-text); }
.back-link { align-self: flex-start; padding-left: 0; }

/* ─── Formulaires ───────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; min-width: 0; }
.field > label, .field-label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input, .form-control, .form-select {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input:hover, .form-control:hover, .form-select:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible, .form-control:focus-visible, .form-select:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
select.input, select.form-control, select.form-select {
  appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
select[multiple].input, select[multiple].form-control { background-image: none; padding-right: 10px; min-height: 120px; }
textarea.input, textarea.form-control { min-height: 90px; resize: vertical; }
input[type="color"].input { padding: 2px; height: 36px; }
.input-lg { font-size: 22px; font-weight: 800; min-height: 48px; }
.field-help { font-size: 12px; color: var(--color-neutral-700); margin-top: 4px; }
.field-error, .errorlist { font-size: 12px; color: var(--color-accent-700); margin: 4px 0 0; padding: 0; list-style: none; }
.field.has-error .input, .field.has-error .form-control { border-color: var(--color-accent); }
.form-errors {
  border-left: 2px solid var(--color-accent); padding: 10px 14px; font-size: 14px;
  background: var(--color-accent-100); color: var(--color-accent-800);
}
.form-errors ul { margin: 0; padding-left: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .span-2, .form-grid-3 .span-all { grid-column: 1 / -1; }
.form-page { max-width: 720px; }
.form-actions {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end;
  border-top: 2px solid var(--color-divider); padding-top: 16px; margin-top: 8px;
}
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input[type="checkbox"], .check input[type="radio"] { accent-color: var(--color-accent); width: 16px; height: 16px; margin: 0; }
.choice-list { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; padding: 0; list-style: none; }
.choice-list label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.choice-list input { accent-color: var(--color-accent); }

/* ─── Contrôle segmenté ─────────────────────────────────────────────────── */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--color-divider); align-self: flex-start; max-width: 100%; }
.seg > a, .seg > button, .seg > label {
  border: 0; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--color-text); text-decoration: none; line-height: 1.3;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.seg > a:hover, .seg > button:hover, .seg > label:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); color: var(--color-text); }
.seg > .is-active, .seg > .is-active:hover, .seg > label:has(input:checked) { background: var(--color-text); color: var(--color-bg); }
.seg > label input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.seg-fill { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-self: stretch; }
.seg-fill > * { justify-content: center; }

/* ─── Tags ──────────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; font-size: 11px; letter-spacing: 0.02em;
  padding: 3px 10px; white-space: nowrap; line-height: 1.4;
}
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); box-shadow: inset 0 0 0 1px var(--color-neutral-300); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }
.tag-accent { background: var(--color-accent); color: var(--color-bg); }
button.tag { font: inherit; font-size: 11px; cursor: pointer; border: 1px solid transparent; }
button.tag.tag-outline { border-color: var(--color-accent); background: transparent; }
button.tag:hover { filter: brightness(1.25); }
button.tag:disabled { opacity: 0.45; cursor: progress; }

/* ─── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 400;
  color: color-mix(in srgb, var(--color-text) 60%, transparent);
  padding: var(--space-2); border-bottom: 2px solid var(--color-divider); white-space: nowrap;
}
.table td { padding: 12px 8px; border-bottom: 1px solid var(--color-divider); vertical-align: middle; }
.table tbody tr:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.table .right, .table th.right { text-align: right; }
.table td:first-child, .table th:first-child { padding-left: 0; }
.table td:last-child, .table th:last-child { padding-right: 0; }
.table .sub { font-size: 12px; color: var(--color-neutral-700); }
.table-lg td { padding-top: 16px; padding-bottom: 16px; }
tr.row-link { cursor: pointer; }
tr.is-paused { opacity: 0.55; }
.table-actions { display: flex; gap: 2px; justify-content: flex-end; }
.table-actions .btn { padding: 6px; }
.table-actions form { display: contents; }

/* ─── Dialogues et panneaux ─────────────────────────────────────────────── */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--space-4);
  background: color-mix(in srgb, #000 60%, transparent);
}
.dialog {
  width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4) 20px 20px; background: var(--color-surface); box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-divider);
}
.dialog-wide { width: min(560px, 100%); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 20px; margin: 0; }
.dialog-close { display: none; }
.dialog-body { font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }
body.has-dialog { overflow: hidden; }

/* ─── Toast ─────────────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  background: var(--color-text); color: var(--color-bg); padding: 12px 18px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); pointer-events: auto;
  transition: opacity .25s, transform .25s;
}
.toast.is-error { background: var(--color-accent); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); }

/* ═══ Structure de l'application (desktop) ═══════════════════════════════ */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  border-right: 2px solid var(--color-divider); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand-block { padding: 22px 20px 18px; border-bottom: 2px solid var(--color-divider); text-decoration: none; color: inherit; display: block; }
.brand-block:hover { color: inherit; }
.brand-name { font-family: var(--font-heading); font-weight: 800; font-size: 20px; letter-spacing: -0.02em; line-height: 1.1; }
.brand-sub { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-accent); margin-top: 4px; }
.side-nav { flex: 1; padding: 18px 12px; display: flex; flex-direction: column; gap: 22px; overflow: auto; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-group-title { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-neutral-600); padding: 0 8px 6px; }
.side-link {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 8px;
  font-size: 14px; font-weight: 600; color: var(--color-text); text-decoration: none;
}
.side-link:hover { background: var(--color-neutral-300); color: var(--color-text); }
.side-link.is-active, .side-link.is-active:hover { background: var(--color-text); color: var(--color-bg); }
.side-link .lucide { width: 17px; height: 17px; }
.side-link-label { flex: 1; }
.side-badge { font-size: 11px; font-weight: 800; color: var(--color-accent); }
.side-link.is-active .side-badge { color: var(--color-bg); }
.side-foot { border-top: 2px solid var(--color-divider); padding: 14px 12px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; flex: none; background: var(--color-text); color: var(--color-bg);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; text-decoration: none;
}
.avatar:hover { color: var(--color-bg); }
.side-user { flex: 1; min-width: 0; line-height: 1.3; }
.side-user-name { font-size: 14px; font-weight: 600; color: var(--color-text); text-decoration: none; display: block; }
.side-user-name:hover { color: var(--color-accent); }
.side-user-plan { font-size: 11px; color: var(--color-neutral-700); }
.side-foot form { margin: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: none; border-bottom: 2px solid var(--color-divider);
  display: flex; align-items: center; gap: 12px; padding: 0 32px;
  position: sticky; top: 0; background: var(--color-bg); z-index: 5;
}
.topbar-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bell { position: relative; }
.bell-dot { position: absolute; top: 5px; right: 6px; width: 8px; height: 8px; background: var(--color-accent); }
.content { padding: 36px 40px 72px; width: 100%; max-width: 1400px; }

/* Mobile : en-tête et barre d'onglets (masqués sur desktop) */
.m-header, .tabbar { display: none; }

/* ─── Motifs communs ────────────────────────────────────────────────────── */
.page { display: flex; flex-direction: column; gap: 36px; }
.page-tight { gap: 28px; }
.page-narrow { max-width: 960px; }
.kicker { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-accent); margin-bottom: 8px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-sub { font-size: 13px; color: var(--color-neutral-700); margin-top: 6px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-actions form { margin: 0; }

/* Rangée de KPI */
.kpis { border-top: 2px solid var(--color-text); border-bottom: 2px solid var(--color-divider); overflow: hidden; }
.kpis-inner { display: flex; flex-wrap: wrap; margin: -2px 0 0 -2px; }
.kpi {
  flex: 1 1 200px; padding: 20px 24px 22px; min-width: 0;
  border-left: 2px solid var(--color-divider); border-top: 2px solid var(--color-divider);
  display: flex; flex-direction: column; gap: 6px;
}
.kpi-wide { flex: 2 1 320px; padding-bottom: 16px; gap: 8px; }
.kpi-label { font-size: 12px; color: var(--color-neutral-700); }
.kpi-value {
  font-family: var(--font-heading); font-weight: 800; font-size: clamp(24px, 2.4vw, 32px);
  letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap;
}
.kpi-value-lg { font-size: clamp(26px, 2.6vw, 36px); }
.kpi-note { font-size: 12px; color: var(--color-neutral-700); }
.kpi-note.is-alert { color: var(--color-accent-700); }

/* Bandeau de chiffre unique */
.band { border-top: 2px solid var(--color-text); border-bottom: 2px solid var(--color-divider); padding: 22px 0; display: flex; align-items: baseline; gap: 24px; flex-wrap: wrap; }
.band-value { font-family: var(--font-heading); font-weight: 800; font-size: 48px; letter-spacing: -0.025em; line-height: 1; }

/* En-tête de section */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  border-bottom: 2px solid var(--color-divider); padding-bottom: 10px; margin-bottom: 10px;
}
.section-head h4 { margin: 0; min-width: 0; white-space: nowrap; }
.section-head .btn { white-space: nowrap; flex: none; }
.section-head.flush { margin-bottom: 0; }

/* Grilles de page */
.split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 48px; }
.split-even { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; }
.split-3-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 48px; }
.split-releve { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); gap: 48px; }
.split-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 48px; }
.flex-cols { display: flex; flex-wrap: wrap; gap: 48px; align-items: flex-start; }
.col-main { flex: 3 1 560px; min-width: 0; }
.col-side { flex: 1 1 280px; min-width: 0; }

/* Lignes de liste */
.list-row { padding: 12px 0; border-bottom: 1px solid var(--color-divider); }
a.list-row, button.list-row {
  display: flex; width: 100%; justify-content: space-between; gap: 12px; align-items: center;
  background: transparent; border: 0; border-bottom: 1px solid var(--color-divider);
  cursor: pointer; text-align: left; color: inherit; text-decoration: none; font: inherit;
}
a.list-row:hover, button.list-row:hover { background: var(--color-neutral-200); color: inherit; }
.row-title { font-size: 14px; font-weight: 600; }
.row-sub { font-size: 12px; color: var(--color-neutral-700); }
.tx-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.empty { font-size: 14px; color: var(--color-neutral-700); padding: 20px 0; margin: 0; }

/* Barres de progression */
.progress { height: 6px; background: var(--color-neutral-300); }
.progress > span { display: block; height: 100%; background: var(--color-text); max-width: 100%; }
.progress.is-over > span { background: var(--color-accent); }
.progress-4 { height: 4px; } .progress-8 { height: 8px; } .progress-14 { height: 14px; }

/* Montants */
.amount-in { font-weight: 800; }
.amount-out { font-weight: 400; }
.big-number { font-family: var(--font-heading); font-weight: 800; letter-spacing: -0.03em; line-height: 1; }

/* Histogrammes */
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--color-neutral-700); flex-wrap: wrap; justify-content: flex-end; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; display: inline-block; }
.swatch-in { background: var(--color-text); } .swatch-out { background: var(--color-neutral-400); }
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 16px; height: 240px; align-items: end; border-bottom: 2px solid var(--color-text); }
.bars-300 { height: 300px; gap: 20px; }
.bar-pair { height: 100%; display: flex; align-items: flex-end; gap: 4px; }
.bar-pair > span { flex: 1; min-height: 1px; }
.bar-in { background: var(--color-text); }
.bar-out { background: var(--color-neutral-400); }
.bar-out.is-over { background: var(--color-accent); }
.bars-labels { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 16px; padding-top: 8px; font-size: 12px; line-height: 1.35; }
.bars-300 + .bars-labels { gap: 20px; }
.bars-labels > * { display: flex; flex-direction: column; min-width: 0; }
.spark { flex: 1; min-height: 64px; display: flex; align-items: flex-end; gap: 4px; }
.spark > span { flex: 1; background: var(--color-text); min-height: 2px; }

/* Grille de cartes à filets */
.ruled-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); border-top: 2px solid var(--color-divider); border-left: 2px solid var(--color-divider); }
.ruled-grid > * { padding: 22px 24px 24px; border-right: 2px solid var(--color-divider); border-bottom: 2px solid var(--color-divider); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ruled-cols { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); border-top: 2px solid var(--color-text); border-bottom: 2px solid var(--color-divider); }
.ruled-cols > * { padding: 24px; border-right: 2px solid var(--color-divider); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ruled-cols > *:last-child { border-right: 0; }
.card-link { color: inherit; text-decoration: none; }
.card-link:hover { background: var(--color-neutral-200); color: inherit; }
.is-selected { outline: 2px solid var(--color-text); outline-offset: -2px; }

/* Bloc de confirmation (suppression) */
.confirm-box { border-top: 2px solid var(--color-text); padding-top: 20px; max-width: 640px; display: flex; flex-direction: column; gap: 16px; }
.detail-list { display: grid; grid-template-columns: 180px minmax(0, 1fr); border-top: 1px solid var(--color-divider); margin: 0; }
.detail-list dt, .detail-list dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--color-divider); font-size: 14px; }
.detail-list dt { color: var(--color-neutral-700); }
.callout { border-left: 2px solid var(--color-accent); padding: 10px 14px; font-size: 14px; background: var(--color-neutral-100); }

/* Barre d'outils entre filets (filtres de liste) */
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border-top: 2px solid var(--color-text); border-bottom: 2px solid var(--color-divider); padding: 14px 0; margin: 0; }
.toolbar-search { max-width: 280px; }
.toolbar-select { width: auto; }
.toolbar-totals { margin-left: auto; display: flex; gap: 24px; font-size: 13px; flex-wrap: wrap; }
@media (max-width: 767px) {
  .toolbar { gap: 10px; }
  .toolbar .seg { width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .toolbar .seg > * { justify-content: center; padding-inline: 6px; min-height: 40px; }
  .toolbar-search { max-width: none; flex: 1 1 160px; }
  .toolbar-totals { margin-left: 0; gap: 16px; width: 100%; }
}

/* Pagination */
.pagination { display: flex; gap: 8px; align-items: center; font-size: 13px; }

/* ═══ Pages publiques ═════════════════════════════════════════════════════ */
.public-nav { display: flex; align-items: center; gap: 16px; padding: 18px 48px; border-bottom: 2px solid var(--color-divider); }
.public-nav .brand-name { margin-right: auto; color: var(--color-text); text-decoration: none; }
.public-nav > a:not(.btn):not(.brand-name) { color: inherit; text-decoration: none; font-size: 14px; }
.public-nav > a:not(.btn):not(.brand-name):hover { color: var(--color-accent); }
.hero { padding: 72px 48px 64px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px; border-bottom: 2px solid var(--color-divider); }
.hero .kicker { grid-column: 1 / span 12; margin: 0; }
.hero h1 { grid-column: 1 / span 9; font-size: 104px; line-height: 0.95; letter-spacing: -0.045em; margin: 0; text-wrap: balance; }
.hero-body { grid-column: 1 / span 5; display: flex; flex-direction: column; gap: 24px; margin-top: 24px; }
.hero-body p { font-size: 19px; line-height: 1.5; margin: 0; text-wrap: pretty; }
.hero-cta { min-width: 220px; justify-content: flex-start; }
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 2px solid var(--color-divider); }
.figures > div { padding: 28px 32px; border-left: 2px solid var(--color-divider); }
.figures > div:first-child { padding-left: 48px; border-left: 0; }
.figure-value { font-family: var(--font-heading); font-weight: 800; font-size: 44px; letter-spacing: -0.03em; }
.public-section { padding: 72px 48px; border-bottom: 2px solid var(--color-divider); }
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 2px solid var(--color-text); }
.features > div { padding: 24px 24px 32px; border-left: 2px solid var(--color-divider); }
.features > div:nth-child(3n+1) { padding-left: 0; border-left: 0; }
.features > div:nth-child(3n) { padding-right: 0; }
.features > div:nth-child(-n+3) { border-bottom: 2px solid var(--color-divider); }
.feature-num { font-size: 12px; font-weight: 800; color: var(--color-accent); }
.features h4 { margin: 12px 0 8px; }
.features p { font-size: 14px; margin: 0; }
.pricing { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 48px; }
.pricing-plans { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 2px solid var(--color-text); }
.pricing-plans > div { padding: 20px 16px 0 0; display: flex; flex-direction: column; gap: 6px; }
.cta-band { background: var(--color-accent); color: var(--color-bg); padding: 88px 48px 72px; display: flex; flex-direction: column; gap: 32px; }
.cta-band h2 { font-size: 88px; line-height: 0.95; letter-spacing: -0.045em; margin: 0; max-width: 1100px; }
.cta-band .btn { align-self: flex-start; min-width: 240px; justify-content: flex-start; }
.public-footer { padding: 24px 48px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--color-neutral-700); }

/* Connexion / inscription */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-aside { background: var(--color-accent); color: var(--color-bg); padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-aside a { color: inherit; text-decoration: none; }
.auth-aside h2 { font-size: 72px; line-height: 0.95; letter-spacing: -0.045em; margin: 0; }
.auth-main { padding: 40px 48px; display: flex; flex-direction: column; justify-content: center; }
.auth-form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.auth-form h2 { margin: 8px 0 0; }
.auth-submit { justify-content: flex-start; padding: 12px 16px; font-size: 15px; }

/* ═══ Responsive ══════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .hero h1 { font-size: 72px; grid-column: 1 / -1; }
  .hero-body { grid-column: 1 / span 8; }
  .cta-band h2 { font-size: 64px; }
  .pricing { grid-template-columns: 1fr; }
  .split, .split-even, .split-3-2, .split-releve { grid-template-columns: minmax(0, 1fr); }
  .ruled-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ruled-cols > * { border-bottom: 2px solid var(--color-divider); }
  .ruled-cols > *:nth-child(2n) { border-right: 0; }
}

@media (max-width: 767px) {
  body { font-size: 15px; }
  h1 { font-size: 30px; letter-spacing: -0.025em; }

  /* Structure mobile : en-tête + onglets en bas */
  .app { display: block; }
  .sidebar, .topbar { display: none; }
  .m-header {
    display: flex; position: sticky; top: 0; z-index: 5; background: var(--color-bg);
    padding: 14px 20px 14px; align-items: flex-end; justify-content: space-between; gap: 12px;
    border-bottom: 2px solid var(--color-divider);
  }
  .m-header-text { min-width: 0; }
  .m-back { font-size: 13px; font-weight: 600; color: var(--color-accent); text-decoration: none; display: block; margin-bottom: 4px; min-height: 24px; }
  .m-kicker { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-accent); }
  .m-title { margin: 2px 0 0; font-size: 30px; letter-spacing: -0.025em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-add { width: 44px; height: 44px; }
  .m-add svg { width: 20px; height: 20px; }
  .m-tools { display: flex; gap: 8px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    border-top: 2px solid var(--color-text); background: var(--color-bg); padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0 8px; min-height: 56px;
    color: var(--color-neutral-600); text-decoration: none; border-top: 3px solid transparent; margin-top: -2px;
    font-size: 11px; font-weight: 600;
  }
  .tab svg { width: 22px; height: 22px; }
  .tab.is-active { color: var(--color-text); border-top-color: var(--color-accent); }
  .tab:hover { color: var(--color-text); }
  .content { padding: 20px 20px 104px; }

  /* La page reprend le titre dans l'en-tête mobile */
  .page { gap: 28px; }
  .page-head { align-items: stretch; flex-direction: column; gap: 16px; }
  .page-head > div:first-child { display: none; }
  .page-head.keep-title > div:first-child { display: block; }
  .page-actions { width: 100%; }
  /* en-tête de page vide sur mobile (titre repris par .m-header, actions masquées) */
  .page-head:not(.keep-title):not(:has(.page-actions > :not(.hide-mobile))) { display: none; }
  .page-actions .btn { flex: 1 1 auto; min-height: 44px; justify-content: flex-start; }

  .kpi { flex-basis: 50%; padding: 14px 12px 16px; }
  .kpi-value { font-size: 22px; }
  .band-value { font-size: 36px; }
  .btn { min-height: 40px; }
  .btn-icon { min-height: 0; }
  .input, .form-control, .form-select { min-height: 44px; font-size: 16px; }
  .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .detail-list { grid-template-columns: minmax(0, 1fr); }
  .detail-list dt { border-bottom: 0; padding-bottom: 0; }

  .ruled-cols { grid-template-columns: minmax(0, 1fr); border-top-width: 2px; }
  .ruled-cols > * { border-right: 0; padding: 18px 0; }
  .ruled-grid { grid-template-columns: minmax(0, 1fr); border-left: 0; }
  .ruled-grid > * { border-right: 0; padding: 16px 0; }
  .bars { height: 180px; gap: 8px; }
  .bars-labels { gap: 8px; font-size: 11px; }
  .hide-mobile { display: none !important; }

  /* Tables → lignes empilées */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr { display: block; width: 100%; }
  /* ligne 1 : libellé | montant — ligne 2 : méta · méta — ligne 3 : actions */
  .table-stack tr { display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; gap: 2px 0; padding: 12px 0; border-bottom: 1px solid var(--color-divider); min-height: 44px; }
  .table-stack td { display: block; padding: 0 !important; border: 0; min-width: 0; }
  .table-stack td.cell-main { grid-column: 1 / 3; grid-row: 1; padding-right: 12px !important; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  .table-stack td.cell-amount { grid-column: 3; grid-row: 1; text-align: right; font-size: 14px; }
  .table-stack td.cell-meta { grid-row: 2; font-size: 12px; color: var(--color-neutral-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .table-stack td.cell-meta { grid-column: 1; }
  .table-stack td.cell-meta ~ td.cell-meta { grid-column: 2 / 4; }
  .table-stack td.cell-meta ~ td.cell-meta::before { content: " · "; white-space: pre; }
  .table-stack td.cell-hide { display: none; }
  .table-stack td.cell-actions { grid-column: 1 / -1; grid-row: 3; }
  /* Solde après l'opération : sous le montant */
  .table-stack td.cell-balance { grid-column: 3; grid-row: 2; font-size: 12px; text-align: right; padding-left: 12px !important; }
  .table-stack td.cell-meta ~ td.cell-meta:has(~ td.cell-balance) { grid-column: 2; }
  .table-stack td.cell-meta ~ td.cell-meta:has(.tag) { padding-left: 10px !important; }
  .table-stack td.cell-meta ~ td.cell-meta:has(.tag)::before { content: none; }
  .table-stack td.cell-actions .table-actions { justify-content: flex-start; }

  /* Modales → panneau bas */
  .dialog-backdrop { place-items: end stretch; padding: 0; }
  .dialog, .dialog-wide {
    width: 100%; max-height: 92vh; border: 0; border-top: 4px solid var(--color-accent);
    background: var(--color-bg); padding: 20px 20px calc(28px + env(safe-area-inset-bottom, 0)); gap: 14px;
  }
  .dialog-title { font-size: 22px; }
  .dialog-close { display: inline-flex; min-height: 44px; }
  .dialog .input-lg { font-size: 26px; min-height: 56px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { min-height: 48px; justify-content: flex-start; font-size: 15px; }
  .toast-stack { bottom: 96px; left: 20px; right: 20px; transform: none; width: auto; max-width: none; }

  /* Pages publiques */
  .public-nav { padding: 14px 20px; flex-wrap: wrap; }
  .public-nav > a:not(.btn):not(.brand-name) { display: none; }
  .hero { padding: 40px 20px; grid-template-columns: minmax(0, 1fr); }
  .hero h1 { font-size: 52px; }
  .hero-body { grid-column: 1; margin-top: 0; }
  .hero-body p { font-size: 17px; }
  .hero-body .row .btn { flex: 1 1 auto; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures > div, .figures > div:first-child { padding: 20px; border-left: 0; border-bottom: 2px solid var(--color-divider); }
  .figures > div:nth-child(2n) { border-left: 2px solid var(--color-divider); }
  .figure-value { font-size: 32px; }
  .public-section { padding: 48px 20px; }
  .features { grid-template-columns: minmax(0, 1fr); }
  .features > div, .features > div:nth-child(3n+1) { padding: 20px 0; border-left: 0; border-bottom: 2px solid var(--color-divider); }
  .pricing-plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cta-band { padding: 56px 20px; }
  .cta-band h2 { font-size: 44px; }
  .public-footer { padding: 20px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { padding: 24px 20px 28px; gap: 24px; }
  .auth-aside h2 { font-size: 44px; }
  .auth-main { padding: 28px 20px 40px; justify-content: flex-start; }
}

/* ─── Masquage des montants (texte remplacé par app.js) ─────────────────── */
html.masque .amt { letter-spacing: 0.05em; }
html.masque .amt:not([data-amt]) { visibility: hidden; }   /* évite le flash avant remplacement */
@media (max-width: 767px) { .page .back-link { display: none; } .page .back-link + .page-head { margin-top: 0 !important; } }

/* ─── Rapports ──────────────────────────────────────────────────────────── */
.cat-row { display: grid; grid-template-columns: 40px 180px minmax(0, 1fr) 120px 60px; gap: 16px; align-items: center; font-size: 14px; }
.trends { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 2px solid var(--color-divider); }
.trends > div { padding: 8px 24px 24px; border-left: 2px solid var(--color-divider); min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.trends > div:first-child { padding-left: 0; border-left: 0; }
.trends > div:last-child { padding-right: 0; }
.trend-value { font-size: 40px; }
@media (max-width: 767px) {
  .cat-row { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 10px; }
  .cat-row .progress { grid-column: 2 / 4; grid-row: 2; }
  .cat-row > span:last-child { display: none; }
  .trends { grid-template-columns: minmax(0, 1fr); }
  .trends > div { padding: 16px 0; border-left: 0; border-top: 2px solid var(--color-divider); }
  .trend-value { font-size: 32px; }
}

/* ─── Impression / export PDF : fond clair, sans navigation ─────────────── */
@media print {
  :root {
    --color-bg: #ffffff; --color-surface: #ffffff; --color-text: #111311;
    --color-divider: color-mix(in srgb, #111311 30%, transparent);
    --color-accent: #4d6b00; --color-accent-700: #4d6b00;
    --color-neutral-300: #e2e5e2; --color-neutral-400: #a8aea8; --color-neutral-700: #555b55; --color-neutral-800: #333833;
  }
  body { background: #fff; }
  .sidebar, .topbar, .m-header, .tabbar, .page-actions, .toolbar .seg, .toast-stack, .dialog-backdrop, [data-print], .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .page-head > div:first-child { display: block !important; }
  .page-head { display: flex !important; }
  a { color: inherit; text-decoration: none; }
  .bar-in, .bar-out, .progress > span, .progress { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ─── Menu « Plus » ─────────────────────────────────────────────────────── */
.menu-row { display: flex; align-items: center; gap: 14px; padding: 16px 0; min-height: 56px; border-bottom: 1px solid var(--color-divider); color: var(--color-text); text-decoration: none; }
.menu-row:hover { background: var(--color-neutral-200); color: var(--color-text); }
.menu-row > span:nth-of-type(1) { flex: 1; font-size: 15px; font-weight: 600; }
.menu-note { font-size: 12px; color: var(--color-neutral-700); }

/* ─── Notifications ─────────────────────────────────────────────────────── */
.notif { display: grid; grid-template-columns: 10px 110px minmax(0, 1fr) auto; gap: 16px; align-items: start; padding: 18px 0; border-bottom: 1px solid var(--color-divider); cursor: pointer; }
.notif:hover { background: var(--color-neutral-200); }
.notif-dot { width: 8px; height: 8px; margin-top: 7px; background: transparent; }
.notif.is-unread .notif-dot { background: var(--color-accent); }
.notif-type { justify-self: start; }
.notif-title { font-size: 15px; font-weight: 400; }
.notif.is-unread .notif-title { font-weight: 800; }
.notif-message { font-size: 14px; color: var(--color-neutral-800); margin-top: 2px; }
.notif-side { display: flex; align-items: center; gap: 4px; }
.notif-side .btn-icon { width: 28px; height: 28px; opacity: 0; }
.notif:hover .notif-side .btn-icon, .notif-side .btn-icon:focus-visible { opacity: 1; }
@media (max-width: 767px) {
  .notif { grid-template-columns: 10px minmax(0, 1fr) auto; gap: 4px 12px; padding: 16px 0; }
  .notif-type { grid-column: 2; background: none; box-shadow: none; padding: 0; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-neutral-700); }
  .notif-body { grid-column: 2 / 4; }
  .notif-side { grid-column: 3; grid-row: 1; }
  .notif-side .btn-icon { opacity: 1; }
}

/* ─── Abonnement ────────────────────────────────────────────────────────── */
.plans { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 2px solid var(--color-divider); border-bottom: 2px solid var(--color-divider); }
.plan { padding: 24px; border-right: 2px solid var(--color-divider); border-top: 4px solid transparent; margin-top: -2px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.plan:last-child { border-right: 0; }
.plan.is-popular { border-top-color: var(--color-accent); }
.plan-badge { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-accent); white-space: nowrap; }
.plan-features { border-top: 1px solid var(--color-divider); }
.plan-features > div { padding: 8px 0; border-bottom: 1px solid var(--color-divider); font-size: 13px; }
@media (max-width: 1100px) { .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); } .plan:nth-child(2n) { border-right: 0; } .plan { border-bottom: 2px solid var(--color-divider); } }
@media (max-width: 767px) { .plans { grid-template-columns: minmax(0, 1fr); } .plan { border-right: 0; padding: 20px 0; } }
