/* =========================================================
   GeroImmo — feuille de style unique
   Palette : terre cuite (toits, action) + vert canard (finance)
   ========================================================= */

:root {
  --bg: #f6f2ec;
  --surface: #ffffff;
  --surface-2: #faf7f2;
  --ink: #1d2528;
  --muted: #5f6b6b;
  --line: #e6ddd1;

  --primary: #c4572e;
  --primary-hover: #a9461f;
  --primary-ink: #ffffff;
  --primary-soft: #f7e4d9;

  --accent: #1f6f6b;
  --accent-soft: #d9eeec;

  --success: #1f7a4d;
  --success-soft: #dcf2e5;
  --warning: #9a5a06;
  --warning-soft: #fcefd6;
  --danger: #b42318;
  --danger-soft: #fde7e4;

  --chart-due: #e3d7c8;
  --chart-paid: var(--accent);

  --brand-bg: #1e2a2c;
  --brand-ink: #f6efe6;
  /* Couleurs de l'illustration (identiques en mode sombre) */
  --brand-terracotta: #d4623f;
  --scene-sky: #f6ddae;
  /* Séries du bilan financier : emplacements 1 à 3 de la palette dataviz de référence (validés daltonisme, tous les couples) */
  --series-revenue: #2a78d6;
  --series-expense: #eb6834;
  --series-net: #1baf7a;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(29, 37, 40, 0.05), 0 8px 24px rgba(29, 37, 40, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 248px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121719;
    --surface: #1a2124;
    --surface-2: #1f272a;
    --ink: #ebe8e3;
    --muted: #9ba7a6;
    --line: #2c373a;

    --primary: #e07a4f;
    --primary-hover: #ea8f68;
    --primary-ink: #1a1210;
    --primary-soft: #3a2419;

    --accent: #5db3ac;
    --accent-soft: #173331;

    --success: #5cc48f;
    --success-soft: #16301f;
    --warning: #e6a948;
    --warning-soft: #33280f;
    --danger: #f2796c;
    --danger-soft: #3a1a17;

    --chart-due: #34403f;
    --series-revenue: #3987e5;
    --series-expense: #d95926;
    --series-net: #199e70;

    --brand-bg: #0d1213;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
img { display: block; }
[hidden] { display: none !important; }

a { color: var(--accent); }

.muted { color: var(--muted); }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: 12px; }

/* ---------- Marque ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}
.brand__name {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand__logo { height: 40px; width: auto; flex: none; }
.brand--light .brand__logo { height: 44px; }
/* « Gero » dans la couleur du texte (clair sur fond sombre), « immo » en terracotta */
.brand__name span { color: var(--primary); }
.brand--light { color: var(--brand-ink); }
.brand--light .brand__name span { color: var(--brand-terracotta); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: var(--primary-ink); }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn--small { min-height: 32px; padding: 0 12px; font-size: 0.875rem; }
.btn--block { width: 100%; }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 0.9rem; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[aria-invalid="true"] { border-color: var(--danger); }

.password { position: relative; }
.password input { padding-right: 92px; }
.password__toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.password__toggle:hover { background: var(--surface-2); color: var(--ink); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field--full { grid-column: 1 / -1; }
fieldset.tenant-fields {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}
fieldset.tenant-fields legend { padding: 0 6px; font-weight: 700; }

/* ---------- Alertes, badges ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.92rem; }
.alert--error { background: var(--danger-soft); color: var(--danger); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--neutral { background: var(--accent-soft); color: var(--accent); }

/* ---------- Carte ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.card__header h2 { font-size: 1.05rem; }

/* =========================================================
   Page de connexion
   ========================================================= */
.login { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }

/* Panneau gauche : texte dans un encart sombre, illustration du campement en bas.
   Le fond reprend la couleur du ciel de l'illustration pour un raccord invisible. */
.login__brand {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 40px 40px 0;
  color: var(--brand-ink);
  background: var(--scene-sky);
  overflow: hidden;
}
.login__intro {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 24px;
  max-width: 540px;
  padding: 32px;
  border-radius: 20px;
  background: rgba(31, 42, 68, 0.94);
  box-shadow: 0 20px 40px rgba(31, 42, 68, 0.25);
}
.login__scene {
  display: block;
  width: calc(100% + 80px);
  max-width: none;
  height: auto;
  max-height: 62vh;
  margin: auto -40px 0;
  padding-top: 24px;
  object-fit: cover;
  object-position: center bottom;
}
.login__pitch h1 { font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -0.03em; margin-bottom: 16px; }
.login__pitch p { max-width: 34ch; font-size: 1.08rem; opacity: 0.88; }
.login__features { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 10px; }
.login__features li { display: flex; align-items: center; gap: 10px; }
.login__features li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--brand-terracotta);
  transform: rotate(45deg);
  flex: none;
}
.login__footnote { max-width: 42ch; font-size: 0.88rem; opacity: 0.7; }
.login__quip { font-style: italic; opacity: 0.85; }
.login__quip::before { content: "« "; }
.login__quip::after { content: " »"; }
.flag-fr { display: inline-block; flex: none; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35); }

.login__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 16px;
}
.login__form { width: 100%; max-width: 400px; display: grid; gap: 18px; padding: 32px; }
.login__form h2 { font-size: 1.5rem; }
.login__legal { font-size: 0.82rem; }
.login__legal a { font-weight: 700; }
.login__form .form-grid { grid-template-columns: 1fr 1fr; }
.login__form .pw-show { align-items: flex-start; }
.login__form .pw-show input { margin-top: 4px; }
/* Piège à robots du formulaire d'inscription */
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login__brand { min-height: 0; padding: 16px 16px 0; }
  .login__intro { gap: 16px; padding: 20px; border-radius: 16px; }
  .login__scene { width: calc(100% + 32px); max-height: 200px; margin: 0 -16px; padding-top: 12px; }
  .login__pitch h1 { font-size: 1.9rem; }
  .login__features, .login__footnote { display: none; }
  .login__form { padding: 24px 20px; }
}

/* =========================================================
   Application (tableau de bord)
   ========================================================= */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.nav { display: grid; gap: 4px; }
.nav__link {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.nav__link:hover { background: var(--surface-2); color: var(--ink); }
.nav__link.is-active { background: var(--primary-soft); color: var(--primary); }
.sidebar__foot { margin-top: auto; font-size: 0.8rem; color: var(--muted); }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.4); }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__menu { display: none; }
.topbar__heading { flex: 1; min-width: 0; }
.topbar__heading h1 { font-size: 1.35rem; }
.topbar__heading p { font-size: 0.88rem; }
.topbar__user { display: flex; align-items: center; gap: 12px; }
/* Menu du compte : s'ouvre en cliquant sur son nom */
.user-menu { position: relative; }
.user-menu__btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.user-menu__btn:hover, .user-menu__btn[aria-expanded="true"] { background: var(--surface-2); }
.user-menu__chevron { flex: none; width: 7px; height: 7px; margin-left: 2px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-2px); }
.user-menu__btn[aria-expanded="true"] .user-menu__chevron { transform: rotate(-135deg) translate(-2px, -2px); }
.user-menu__panel { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; display: grid; min-width: 190px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); }
.user-menu__item { padding: 10px 12px; border-radius: 6px; color: var(--ink); font-weight: 600; text-decoration: none; }
.user-menu__item:hover { background: var(--surface-2); }
.user-menu__logout { display: none; width: 100%; border: 0; background: transparent; font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.user-menu__item[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.topbar__identity { display: flex; flex-direction: column; line-height: 1.25; }
.topbar__identity span { font-size: 0.8rem; }
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

/* minmax(0, 1fr) : les tableaux défilent dans leur cadre au lieu d'élargir toute la page */
.content { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 28px 32px 48px; max-width: 1400px; }
.section-title { font-size: 1.05rem; margin-bottom: 14px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi__label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.kpi__value { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi__hint { color: var(--muted); font-size: 0.82rem; }
.kpi--alert .kpi__value { color: var(--danger); }
.meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.meter__fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 0.6s ease; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; }

/* Graphique */
.legend { display: flex; gap: 16px; font-size: 0.82rem; color: var(--muted); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__item::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.legend__item--due::before { background: var(--chart-due); }
.legend__item--paid::before { background: var(--chart-paid); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar--due { fill: var(--chart-due); }
.chart .bar--paid { fill: var(--chart-paid); }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }

/* Impayés */
.unpaid-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 360px; overflow-y: auto; }
.unpaid-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.unpaid-item__title { font-weight: 700; }
.unpaid-item__meta { font-size: 0.82rem; color: var(--muted); }
.unpaid-item__amount { font-weight: 800; color: var(--danger); text-align: right; font-variant-numeric: tabular-nums; }
.unpaid-item__actions { grid-column: 2; justify-self: end; }
.empty { padding: 24px 12px; text-align: center; color: var(--muted); }

/* Tableau */
/* position: relative : les libellés .visually-hidden (absolus) restent dans le cadre qui défile */
.table-wrap { position: relative; overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-title { font-weight: 700; }
.cell-sub { font-size: 0.82rem; color: var(--muted); }

/* SCI */
.sci-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.sci-card { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); display: grid; gap: 4px; }
.sci-card__name { font-weight: 800; }
.sci-card__stats { display: flex; justify-content: space-between; margin-top: 8px; font-size: 0.88rem; }

/* Dialogue */
.dialog {
  width: min(640px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
}
.dialog::backdrop { background: rgba(18, 23, 25, 0.55); }
.dialog__form { display: grid; gap: 18px; padding: 24px; }
.dialog__header, .dialog__footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog__footer { justify-content: flex-end; }

/* Notification */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* Squelette de chargement */
.content[aria-busy="true"] .kpi__value { color: transparent; background: var(--surface-2); border-radius: 6px; }

/* =========================================================
   Locataires (liste et formulaire)
   ========================================================= */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Menus parents dépliables (Patrimoine, Gestion) et leurs sous-menus */
.nav__section { margin-top: 6px; }
.nav__parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.94rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.nav__parent::-webkit-details-marker { display: none; }
.nav__parent::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s;
}
.nav__section:not([open]) > .nav__parent::after { transform: rotate(-45deg); }
.nav__parent:hover { background: var(--surface-2); }
.nav__sub {
  display: grid;
  gap: 2px;
  margin: 2px 0 4px 18px;
  padding-left: 10px;
  border-left: 2px solid var(--line);
}
/* Styles inversés : menus (Tableau de bord, Patrimoine, Gestion) discrets, sous-menus mis en avant */
.nav > .nav__link { font-size: 0.94rem; }
.nav__sub .nav__link { padding: 8px 12px; color: var(--ink); font-weight: 700; }
.nav__sub .nav__link.is-active { color: var(--primary); }

.alert--warning { background: var(--warning-soft); color: var(--warning); }
.alert--info { background: var(--accent-soft); color: var(--ink); border-left: 3px solid var(--accent); }
.alert--info a { font-weight: 700; }
.alert--warning a { color: inherit; font-weight: 700; }

.breadcrumb { font-size: 0.82rem; color: var(--muted); }
.breadcrumb a { color: inherit; }

.content--narrow { max-width: 880px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar__search { width: 260px; min-height: 40px; padding: 8px 12px; }
.toolbar__filter { width: auto; min-height: 40px; padding: 8px 12px; }
.card__header h2 .badge { margin-left: 6px; vertical-align: middle; }

a.badge { text-decoration: none; }
a.badge:hover { filter: brightness(0.95); }
.table tr.is-new td { background: var(--accent-soft); }

.tenant-form { display: grid; gap: 20px; }
.form-section { display: grid; gap: 16px; }
.form-section__title { font-size: 1rem; }
.form-hint { font-size: 0.85rem; color: var(--muted); }
.req { color: var(--danger); }
.field--spacer { visibility: hidden; }
select[aria-invalid="true"] { border-color: var(--danger); }

.choice { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; border: 0; }
.choice legend { width: 100%; margin-bottom: 6px; padding: 0; font-weight: 600; font-size: 0.9rem; }
.choice__option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
}
.choice__option input { width: auto; min-height: 0; accent-color: var(--primary); }
.choice__option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.choice__option:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }

.dropzone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 28px 16px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--success); background: var(--success-soft); }
.dropzone.has-error { border-style: solid; border-color: var(--danger); background: var(--danger-soft); }
.dropzone:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.dropzone__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone__title { font-weight: 700; word-break: break-all; }
.dropzone__hint { font-size: 0.85rem; color: var(--muted); }

.form-actions { display: flex; justify-content: flex-end; gap: 12px; }

/* ---------- Parcours de démarrage ---------- */
.onboarding { border-color: var(--primary); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.step {
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: start;
  gap: 8px 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.step > .btn { grid-column: 1 / -1; justify-self: start; }
.step__marker {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
  color: var(--muted);
  font-weight: 800;
}
.step__body { display: grid; gap: 2px; }
.step__title { font-weight: 700; }
.step__text { font-size: 0.85rem; color: var(--muted); }
.step--done .step__marker { background: var(--success); border-color: var(--success); color: #fff; }
.step--done .step__title { color: var(--success); }
.step--current { border-color: var(--primary); background: var(--primary-soft); }
.step--current .step__marker { border-color: var(--primary); color: var(--primary); }
.step--todo { opacity: 0.65; }

.cell-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Bilan financier ---------- */
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 16px 20px; }

.swatch { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: baseline; flex: none; }
.swatch--revenue { background: var(--series-revenue); }
.swatch--expense { background: var(--series-expense); }
.swatch--net { background: var(--series-net); }
.legend__item--revenue::before { background: var(--series-revenue); }
.legend__item--expense::before { background: var(--series-expense); }
.kpi__value.is-negative, td.is-negative { color: var(--danger); }

.chart--interactive { position: relative; }
.chart .bar--revenue { fill: var(--series-revenue); }
.chart .bar--expense { fill: var(--series-expense); }
.chart .line--net { fill: none; stroke: var(--series-net); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area--net { fill: var(--series-net); opacity: 0.12; }
/* Anneau de la couleur du fond autour des points, pour les détacher de la ligne */
.chart .marker--net { fill: var(--series-net); stroke: var(--surface); stroke-width: 2; }
.chart .axis-base { stroke: var(--muted); stroke-width: 1; opacity: 0.6; }
.chart .axis-label--future { opacity: 0.45; }
.chart .direct-label { fill: var(--ink); font-size: 12px; font-weight: 700; font-family: var(--font); }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hover-band { fill: var(--surface-2); }
.chart .hit-zone { fill: transparent; cursor: crosshair; outline: none; }
.chart .hit-zone:focus-visible { stroke: var(--primary); stroke-width: 2; }

/* Panneau de graphique toujours clair (même en mode sombre) : fond clair, barres colorées,
   encres et grilles de la palette de référence pour fond clair */
.chart-panel {
  --series-revenue: #2a78d6;
  --series-expense: #eb6834;
  --series-net: #1baf7a;
  --chart-surface: #fcfcfb;
  --chart-ink: #0b0b0b;
  --chart-ink-2: #52514e;
  --chart-muted: #898781;
  --chart-grid: #e1e0d9;
  --chart-baseline: #c3c2b7;
  color-scheme: light;
  padding: 12px 12px 4px;
  border: 1px solid rgba(11, 11, 11, 0.10);
  border-radius: var(--radius-sm);
  background: var(--chart-surface);
  color: var(--chart-ink);
}
.chart-panel .axis-label { fill: var(--chart-ink-2); }
.chart-panel .grid-line { stroke: var(--chart-grid); }
.chart-panel .axis-base { stroke: var(--chart-baseline); opacity: 1; }
.chart-panel .hover-band { fill: #efeee9; }
.chart-panel .direct-label { fill: var(--chart-ink); }
.chart-panel .crosshair { stroke: var(--chart-muted); }
.chart-panel .marker--net { stroke: var(--chart-surface); }
.chart-panel .empty { color: var(--chart-ink-2); }
.chart-panel .chart-tooltip { border-color: var(--chart-grid); background: #ffffff; color: var(--chart-ink); }
.chart-panel .chart-tooltip__label { color: var(--chart-ink-2); }

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  pointer-events: none;
}
.chart-tooltip__title { margin-bottom: 6px; font-weight: 700; }
.chart-tooltip__row { display: flex; align-items: center; gap: 4px; }
.chart-tooltip__label { flex: 1; color: var(--muted); }
.chart-tooltip__row strong { font-variant-numeric: tabular-nums; }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hbars__row { display: grid; grid-template-columns: minmax(110px, 36%) 1fr auto; align-items: center; gap: 10px; }
.hbars__label { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars__track { height: 14px; }
.hbars__fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--series-expense); }
.hbars__row:hover .hbars__fill { filter: brightness(0.9); }
.hbars__value { font-size: 0.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Archives ---------- */
.archive-list { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
.archive { display: grid; gap: 6px; }
.archive__expiry { color: var(--danger); font-size: 0.9rem; }
.archive__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.archive__receipts { margin-top: 6px; font-size: 0.9rem; }
.archive__receipts > summary { cursor: pointer; font-weight: 600; }
.archive__receipt-list { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.archive__receipt-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }

/* ---------- Mon compte : suppression ---------- */
.account-effects { margin: 0 0 12px; padding-left: 20px; }
.account-effects:empty { display: none; }

/* ---------- Petit « i » avec infobulle, au survol et au clavier ---------- */
.info-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: 2px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.7rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  cursor: help;
}
.info-tip:hover, .info-tip:focus-visible { border-color: var(--primary); color: var(--primary); outline: none; }
.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 5;
  display: none;
  width: max-content;
  max-width: 200px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 0.8rem;
  font-style: normal;
  font-weight: 500;
  white-space: normal;
}
.info-tip--end::after { left: auto; right: 0; }
.info-tip:hover::after, .info-tip:focus::after { display: block; }

/* ---------- Révision des loyers ---------- */
.revision-fields { min-width: 0; margin: 4px 0 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.revision-fields legend { padding: 0 6px; font-weight: 600; }
.index-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 12px 0; }
.index-form .field { flex: 1 1 120px; }

/* ---------- Alertes de révision ---------- */
.revision-alerts { display: grid; gap: 10px; margin: 0 0 8px; padding: 0; list-style: none; }
.revision-alert { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.revision-alert:last-child { border-bottom: 0; }
.revision-alert__body { flex: 1 1 220px; min-width: 0; }

.revision-history { font-size: 0.9rem; }
.revision-history > summary { cursor: pointer; font-weight: 600; }
.revision-history ul { margin: 8px 0 0; padding-left: 20px; }

/* ---------- Sauvegardes ---------- */
.backup-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 14px; margin: 0 0 16px; }
.backup-facts dt { color: var(--muted); font-size: 0.85rem; }
.backup-facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.backup-detail { overflow-wrap: anywhere; }

/* ---------- Onglets de l'administration ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; box-shadow: inset 0 -1px 0 var(--line); }
.tabs__tab {
  flex: none;
  padding: 10px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tabs__tab:hover { color: var(--ink); }
.tabs__tab[aria-selected="true"] { border-bottom-color: var(--primary); color: var(--ink); }
.tab-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.grid-even { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 24px; }
.chart-hint { margin: 0; font-size: 0.85rem; }
.hbars--accounts .hbars__fill { background: #2a78d6; }
.kpis--thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.table-view > summary { cursor: pointer; font-weight: 700; }
.table-view[open] > summary { margin-bottom: 12px; }
.table tr.is-future td { color: var(--muted); }

/* ---------- Cartes SCI (bouton Modifier) et locations d'un locataire ---------- */
.sci-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sci-card__identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sci-card__logo { display: block; max-width: 72px; max-height: 36px; width: auto; height: auto; object-fit: contain; flex: none; }
.logo-field { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.logo-field__controls { display: grid; gap: 8px; justify-items: start; flex: 1; min-width: 200px; }
.logo-field__controls input[type="file"] { min-height: 0; padding: 6px; }
/* Fond blanc : aperçu fidèle au rendu sur la quittance, même en mode sombre */
.logo-preview { display: grid; place-items: center; width: 160px; height: 80px; padding: 8px; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: #ffffff; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview__empty { font-size: 0.85rem; color: #6b7576; }
.sci-list--page { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.sci-card.is-new { border-color: var(--accent); background: var(--accent-soft); }
.sci-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.sci-stat { display: grid; gap: 2px; }
.sci-stat__value { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.sci-stat__label { font-size: 0.78rem; color: var(--muted); }
.sci-card__links { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; font-size: 0.88rem; }
.sci-card__links a { font-weight: 600; }
.lease-ref + .lease-ref { margin-top: 6px; }
.current-doc { font-size: 0.9rem; }
.current-doc a { font-weight: 600; word-break: break-all; }
.lease-ref__label { font-weight: 700; color: var(--ink); text-decoration: none; }
.lease-ref__label:hover { text-decoration: underline; }
.lease-ref__create { display: block; margin-top: 4px; font-size: 0.85rem; font-weight: 600; }

/* ---------- Mon compte ---------- */
#profile-form, #password-form { display: grid; gap: 14px; }
.pw-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; color: var(--muted); }
.pw-rules li::before { content: "○ "; }
.pw-rules li.is-ok { color: var(--success); }
.pw-rules li.is-ok::before { content: "✓ "; }
.pw-show { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.pw-show input { width: auto; min-height: 0; }
.account-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.account-meta dt { font-size: 0.8rem; color: var(--muted); }
.account-meta dd { margin: 0; font-weight: 600; }
@media (max-width: 520px) { .account-meta { grid-template-columns: 1fr; } }

/* ---------- Encaissement (solde ou partiel) ---------- */
.pay-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.pay-figures div { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.pay-figures dt { font-size: 0.8rem; color: var(--muted); }
.pay-figures dd { margin: 0; font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.pay-figures__remaining { border-color: var(--primary) !important; background: var(--primary-soft); }
.pay-figures__remaining dd { color: var(--primary); }
.pay-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.88rem; }
.pay-history li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 6px; background: var(--surface-2); }
.pay-after { font-weight: 600; }
.pay-after.is-error { color: var(--danger); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
@media (max-width: 520px) { .pay-figures { grid-template-columns: 1fr; } }

/* ---------- Administration ---------- */
.btn--danger { color: var(--danger); }
.btn--danger-solid { background: var(--danger); color: #fff; }
.btn--danger-solid:hover:not(:disabled) { background: var(--danger); filter: brightness(0.92); }
#end-effects { display: grid; gap: 4px; font-size: 0.9rem; }
.cell-sub.is-pending { color: var(--warning); font-weight: 600; }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.table tr.is-inactive td { opacity: 0.6; }
.table tr.is-inactive .cell-actions { opacity: 1; }
.inline-form { display: flex; gap: 10px; margin-bottom: 12px; }
.inline-form input { flex: 1; min-width: 0; }
.type-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; }
.type-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.type-row__name { font-weight: 600; }
.secret { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.secret__value { flex: 1; padding: 0; background: none; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.05em; word-break: break-all; user-select: all; }

/* ---------- Bouton-icône (quittance) ---------- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.icon-btn svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.icon-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- Dépenses ---------- */
#expense-form { display: grid; gap: 16px; }
.form-grid--expense { grid-template-columns: 2fr 2fr 1fr 1fr; }
.table tr.is-editing td { background: var(--primary-soft); }
.table tr.is-editing td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.table tfoot th, .table tfoot td { padding: 12px; border-top: 2px solid var(--line); border-bottom: 0; }
.table__total-label { text-align: right; text-transform: none; letter-spacing: 0; font-size: 0.92rem; color: var(--ink); }
.table__total { font-weight: 800; font-size: 1.05rem; }
code { padding: 1px 6px; border-radius: 4px; background: rgba(0, 0, 0, 0.06); font-size: 0.9em; }

/* ---------- Récapitulatif de location ---------- */
.lease-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  border-color: var(--accent);
  background: var(--accent-soft);
}
.lease-summary__label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--accent); }
.lease-summary__value { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.lease-summary__detail { color: var(--ink); max-width: 46ch; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid--expense { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.is-open { transform: none; }
  .shell { margin-left: 0; }
  .topbar { padding: 12px 16px; }
  .topbar__menu { display: inline-flex; }
  .topbar__identity { display: none; }
  .content { padding: 20px 16px 40px; }
  .form-grid, .form-grid--expense, .filters { grid-template-columns: 1fr; }
  .hbars__row { grid-template-columns: 1fr auto; }
  .hbars__track { grid-column: 1 / -1; grid-row: 2; }
  .field--spacer { display: none; }
  .toolbar, .toolbar__search, .toolbar__filter { width: 100%; }
}

@media (max-width: 520px) {
  .topbar__heading p { display: none; }
  .topbar { gap: 8px; }
  .topbar__heading h1 { overflow: hidden; font-size: 1.1rem; text-overflow: ellipsis; white-space: nowrap; }
  /* Peu de place : la déconnexion passe dans le menu du compte */
  #logout-btn { display: none; }
  .user-menu__logout { display: block; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: 1fr; }
  .kpi__value { font-size: 1.35rem; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
}

/* ---------- 404 ---------- */
.notfound-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.notfound { display: grid; justify-items: center; gap: 14px; text-align: center; max-width: 420px; padding: 40px 32px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
