:root {
  --ink: #1b2a30;
  --muted: #5f6f75;
  --brand: #1f4e5f;
  --line: #dde3e5;
  --bg: #ffffff;
  --danger: #a12a2a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; padding-bottom: env(safe-area-inset-bottom); }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--brand); text-decoration: none; }
.page { max-width: 720px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; margin: 8px 0; }
.muted { color: var(--muted); margin-top: 0; }
.empty { margin-top: 32px; color: var(--muted); }
.login { max-width: 360px; margin: 15vh auto 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
input { font: inherit; font-size: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
button { font: inherit; cursor: pointer; }
.primary { margin-top: 12px; padding: 12px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 600; }
.link { background: none; border: 0; color: var(--muted); padding: 0; }
.error { color: var(--danger); }
.notice { color: var(--brand); }
.danger { color: var(--danger); }
.button { display: block; text-align: center; text-decoration: none; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 0 16px 16px; margin: 16px 0; }
h2 { font-size: 1.15rem; }
.rows { list-style: none; padding: 0; }
.row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row p { margin: 4px 0 0; }
.row.inactive strong { color: var(--muted); }
.actions { display: flex; gap: 16px; align-items: center; }
a.link { text-decoration: none; }
select { font: inherit; font-size: 16px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.inline select { padding: 6px; }
.changes { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .title { color: var(--ink); text-decoration: none; }
.total { padding-top: 8px; }
.figures { display: grid; grid-template-columns: minmax(8em, auto) 1fr; gap: 6px 16px; margin: 0; }
.figures dt { color: var(--muted); }
.figures dd { margin: 0; font-variant-numeric: tabular-nums; }
label.check { display: flex; gap: 8px; align-items: center; }
/* The "+" button: bottom right, where a right thumb rests, above the iPhone home bar. */
.page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 10; }
.fab summary {
  list-style: none; width: 56px; height: 56px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; background: var(--brand); color: #fff;
  font-size: 2rem; line-height: 1; box-shadow: 0 2px 8px rgb(0 0 0 / 0.25);
}
.fab summary::-webkit-details-marker { display: none; }
.fab[open] summary { transform: rotate(45deg); }
.fab-menu {
  position: absolute; right: 0; bottom: 68px; min-width: 180px; display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.15);
}
.fab-menu a { padding: 14px 16px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.fab-menu a:last-child { border-bottom: 0; }
/* Tableau de bord: one hero figure, stat tiles, a meter (brand fill on a lighter step of the same hue). */
.hero { font-size: 3.5rem; font-weight: 600; line-height: 1; margin: 8px 0 4px; }
.lead { font-size: 1.15rem; margin: 0 0 12px; }
.meter { height: 8px; border-radius: 4px; background: #d5e2e6; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-top: 16px; }
.tile { display: flex; flex-direction: column; gap: 4px; }
.tile-label { color: var(--muted); }
.tile-value { font-size: 1.6rem; font-weight: 600; white-space: nowrap; }
.tile-note { color: var(--muted); font-size: 0.9rem; }
.row.bail { flex-direction: column; gap: 2px; }
.row.bail p { margin: 0; }
.releve { display: grid; gap: 16px; margin-top: 16px; }
.releve .pdf { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
.lignes { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.lignes th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px; }
.lignes td { padding: 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lignes input { width: 100%; padding: 6px; font-size: 16px; }
.lignes input[type="checkbox"] { width: auto; }
/* Budget: a wide grid for a computer, scrolled sideways on a phone with the Catégorie column kept in view. */
.defile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ecarts, .grille { border-collapse: collapse; font-size: 0.9rem; min-width: 100%; }
.ecarts th, .ecarts td, .grille th, .grille td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.ecarts td:first-child, .ecarts tbody th, .ecarts tfoot th, .grille tbody th { text-align: left; }
.ecarts thead th, .grille thead th { color: var(--muted); font-weight: 500; }
.ecarts .groupe { text-align: left; padding-top: 16px; }
.ecarts tfoot th, .ecarts tfoot td { font-weight: 600; }
.grille tbody th { position: sticky; left: 0; background: var(--bg); font-weight: 500; min-width: 12em; }
.grille input { width: 7.5em; padding: 6px; text-align: right; font-variant-numeric: tabular-nums; }
.grille input.invalide { border-color: var(--danger); }
@media (min-width: 1100px) {
  .page:has(.grille) { max-width: 1400px; }
  .page:has(.releve) { max-width: 1400px; }
  .releve { grid-template-columns: 1fr 1.2fr; }
  .releve .pdf { height: calc(100vh - 220px); position: sticky; top: 16px; }
}
@media (max-width: 700px) {
  .lignes thead { display: none; }
  .lignes tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .lignes td { border: 0; }
  .lignes td:nth-child(3) { grid-column: 1 / -1; }
}
