:root {
  --bg: #efe6d6;
  --ink: #1d1914;
  --muted: #6f655b;
  --paper: #fffdf8;
  --line: #e4d8c6;
  --side: #1c2622;
  --side-text: #f3eadc;
  --copper: #c65324;
  --copper-deep: #8d3714;
  --green: #1d7a4a;
  --red: #9d342c;
  --amber: #9a6412;
  --shadow: 0 12px 40px rgba(60, 40, 20, 0.08);
  --sans: "Avenir Next", "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(198, 83, 36, 0.12), transparent 50%),
    var(--bg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--copper-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.02em; }
h1 { margin: 0; font-size: 2rem; }
h2 { margin: 0 0 0.6rem; font-size: 1.25rem; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--ink);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  cursor: pointer;
}
button:hover { background: var(--copper-deep); }
button.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
button.ghost { background: transparent; }
button.link {
  background: none;
  color: var(--side-text);
  padding: 0;
  border-radius: 0;
}
.button {
  display: inline-flex;
  align-items: center;
  background: var(--ink);
  color: white;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  text-decoration: none;
}
.button:hover { background: var(--copper-deep); text-decoration: none; }

.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
body.nav-closed .shell { grid-template-columns: 3.2rem minmax(0, 1fr); }
.side {
  background: var(--side);
  color: var(--side-text);
  padding: 0.8rem 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.nav-toggle {
  align-self: flex-end;
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.7rem;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--side-text);
  border: 1px solid rgba(255, 253, 248, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-toggle svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }
.nav-toggle:hover { background: rgba(255, 253, 248, 0.1); }
body.nav-closed .side { padding: 0.8rem 0.35rem; align-items: center; }
body.nav-closed .nav-toggle { align-self: center; margin-bottom: 0; }
body.nav-closed .brand,
body.nav-closed .side nav,
body.nav-closed .side-foot { display: none; }
.brand { display: flex; gap: 0.75rem; align-items: center; color: inherit; text-decoration: none; }
.brand strong { display: block; font-family: var(--serif); font-size: 1.25rem; }
.brand small { color: #c8bba8; }
.mark {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid #e7c3a4;
  box-shadow: inset 0 0 0 6px var(--copper);
  flex: none;
}
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px; object-fit: cover; flex: none; background: #fff;
}
table.sheet td.name a { display: flex; align-items: center; gap: 0.45rem; color: inherit; font-weight: 650; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--copper); color: #fff; font-size: 0.75rem;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fiche-top { display: flex; gap: 1rem; align-items: flex-start; }
.portrait {
  width: 96px; height: 96px; border-radius: 16px; object-fit: cover; flex: none; background: #efe6da;
}
.portrait.empty {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 2rem; color: var(--copper-deep);
}
.doc-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.35rem 0; border-bottom: 1px solid var(--line, #eadfce);
}
.doc-row form { margin: 0; }
.side nav { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 1.6rem; }
.side nav a {
  color: var(--side-text);
  text-decoration: none;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
}
.side nav a.active, .side nav a:hover { background: rgba(255, 253, 248, 0.1); text-decoration: none; }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; }
.side-foot a { color: var(--side-text); }

main { padding: 1.4rem 1.6rem 3rem; min-width: 0; }
.gate { max-width: 460px; margin: 8vh auto; padding: 1rem; }
.login h1 { font-size: 3rem; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; color: var(--copper-deep); }
.lede, .muted, .hint { color: var(--muted); }
.page-head, .stats, .split, .filters, .sheet-wrap, .card, .stack, .groups { margin-top: 1rem; }
.page-head { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-top: 0; }
.balance { margin: 0; font-family: var(--serif); font-size: 1.8rem; }
.balance small { display: block; font-family: var(--sans); font-size: 0.8rem; color: var(--muted); }

.banner { margin: 0 0 0.55rem; padding: 0.4rem 0.75rem; border-radius: 10px; background: #e7f6ee; font-size: 0.88rem; }
.banner.err { background: #fde8e4; }
.banner.warn { background: #fff1d6; }
.banner a { font-weight: 600; }

details.fold {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.15rem 1.1rem;
  box-shadow: var(--shadow);
  margin-top: 1rem;
}
details.fold summary { cursor: pointer; list-style: none; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary h2 { display: inline; }
details.fold summary::before { content: "▸  "; color: var(--copper); }
details.fold[open] summary::before { content: "▾  "; }
details.fold[open] { padding-bottom: 1rem; }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; }
.stat {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.9rem 1rem;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.stat:hover { text-decoration: none; border-color: #d7b495; }
.stat span, .stat small { color: var(--muted); display: block; }
.stat strong { display: block; font-family: var(--serif); font-size: 1.55rem; margin: 0.25rem 0; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 0.8rem; }
.groups { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.section-title { margin: 1.5rem 0 0; }
.week { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; margin-top: 0.8rem; }
.day-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 0.9rem 1rem;
  min-width: 0;
}
.day-card header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
}
.day-card header h2 { margin: 0; }
.day-count { margin: 0; white-space: nowrap; }
.day-count strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.day-count span { color: var(--muted); font-size: 0.78rem; }
.slot-group { margin-top: 0.75rem; }
.slot-group h3 {
  display: flex;
  justify-content: space-between;
  margin: 0 0 0.35rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--copper-deep);
}
.slot-names { display: flex; flex-wrap: wrap; gap: 0.28rem; }
.who {
  display: inline-block;
  background: #f6efe4;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.78rem;
}
.who:hover { text-decoration: none; background: #efe2d0; }
.who.actif { background: #e5f5ec; }
.who.nouveau { background: #fde7da; }
.who.inscription { background: #fff1d2; }
.who.expire { background: transparent; color: var(--muted); border: 1px dashed var(--line); }

.bars, .people, .ledger, .roster { list-style: none; margin: 0; padding: 0; }
.bars li, .ledger li, .roster li, .people li {
  display: grid;
  grid-template-columns: 4.2rem 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.28rem 0;
}
.people li, .ledger li { grid-template-columns: 1fr auto; }
.roster li { grid-template-columns: 1.4fr 1fr auto; border-top: 1px solid var(--line); padding: 0.45rem 0; }
.track { height: 8px; background: #f0e6d6; border-radius: 99px; overflow: hidden; }
.track span { display: block; height: 100%; background: var(--copper); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sim { color: var(--amber); }
input.cell { width: 7rem; text-align: right; padding: 0.3rem 0.45rem; }
button.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.in { color: var(--green); }
.out { color: var(--red); }
.ledger small, .roster span { color: var(--muted); }

.filters, .inline, .row-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; }
.filters input, .filters select, .form input, .form select, .form textarea, .row-form input, .row-form select {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
}
.form label, .filters label { display: grid; gap: 0.25rem; font-size: 0.82rem; color: var(--muted); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.8rem; }
.wide { grid-column: 1 / -1; }
.months { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.5rem; }
.months input { width: 100%; }
.actions { display: flex; gap: 1rem; align-items: center; }
.check { display: flex; gap: 0.4rem; align-items: center; color: var(--ink); }
.narrow { max-width: 420px; }
fieldset { border: 1px solid var(--line); border-radius: 14px; }
.chips { display: flex; gap: 0.4rem; margin: 0.8rem 0; }
.chips a { padding: 0.3rem 0.7rem; border-radius: 999px; background: white; color: var(--ink); text-decoration: none; border: 1px solid var(--line); }
.chips a.active { background: var(--ink); color: white; }
.stack { display: grid; gap: 0.6rem; }
.cheque.late { border-color: #e3b2a8; }
.row-form input[name="label"], .row-form input[name="payer_name"], .row-form input[name="person_name"] { min-width: 14rem; }
.num-input { width: 6.5rem; text-align: right; }

.sheet-wrap { overflow: auto; max-height: calc(100vh - 210px); border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.sim-sheet { max-height: none; margin: 0.6rem 0 0.8rem; box-shadow: none; }
table.sheet, table.data { border-collapse: separate; border-spacing: 0; width: 100%; }
table.sheet th, table.sheet td, table.data th, table.data td { padding: 0.35rem 0.45rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.sheet th, table.data th {
  position: sticky; top: 0; background: #fbf6ee; z-index: 2;
  font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); text-align: left;
}
table.sheet td.name, table.sheet th.name { position: sticky; left: 0; z-index: 1; background: var(--paper); min-width: 180px; }
table.sheet thead th.name { z-index: 3; background: #fbf6ee; }
table.sheet tfoot th { position: sticky; bottom: 0; background: #f6efe4; z-index: 2; }
table.sheet tr[data-status="expire"] { color: #8d8378; }
table.sheet tr[data-status="inscription"] td.name { box-shadow: inset 3px 0 0 var(--amber); }
input.cell {
  width: 4.6rem;
  border: 1px solid transparent;
  background: transparent;
  text-align: right;
  padding: 0.25rem 0.35rem;
  border-radius: 8px;
}
input.cell:hover, input.cell:focus { background: white; border-color: #e7c3a4; outline: none; }
input.cell.ok { background: #e7f6ee; }
input.cell.bad { background: #fde8e4; }
.note { max-width: 14rem; color: var(--muted); font-size: 0.85rem; }
.name form { margin-top: 0.2rem; }
.name form input { width: 100%; font-size: 0.78rem; }

.pill { display: inline-block; border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.75rem; background: #f3eadc; }
.pill.actif { background: #e5f5ec; color: var(--green); }
.pill.expire { background: #f3eee8; color: #7d746a; }
.pill.nouveau { background: #fde7da; color: var(--copper-deep); }
.pill.inscription { background: #fff1d2; color: var(--amber); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}
.icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.primary { background: var(--ink); color: white; border-color: var(--ink); }
.icon.danger { color: var(--red); border-color: #f0d0cb; background: white; }
.icon:hover { background: #f6efe4; }
.icon.primary:hover { background: var(--copper-deep); color: white; }
.icon.danger:hover { background: #fde8e4; }

.toolbar, .filter-board { margin-top: 0.75rem; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: end;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.6rem 0.7rem;
}
.toolbar label, .filter-board label { display: grid; gap: 0.15rem; font-size: 0.72rem; color: var(--muted); }
.toolbar input, .toolbar select, .filter-board input, .filter-board select {
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 0.45rem;
}
.toolbar .check { height: 2rem; align-self: end; }
.filter-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.75rem 0.85rem 0.85rem;
}
.filter-board h3 {
  margin: 0 0 0.45rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--copper-deep);
}
.filter-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.55rem; }

.ledger {
  margin-top: 0.75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: auto;
}
.ledger.fit { overflow: visible; }
.picker { position: relative; min-width: 0; }
.picker-label { display: block; font-size: 0.72rem; color: var(--muted); }
.picker-chosen { display: flex; flex-direction: column; gap: 0.2rem; }
.picker-menu {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: 100%;
  max-height: 11rem;
  overflow: auto;
  margin: 0.15rem 0 0;
  padding: 0.2rem 0;
  list-style: none;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.picker-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 0;
  border-radius: 0;
  padding: 0.28rem 0.5rem;
}
.picker-menu button:hover { background: #f6efe4; }
.chip {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  background: #f3eadc;
  border-radius: 8px;
  padding: 0.12rem 0.3rem;
  font-size: 0.75rem;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line .chip-amount, .toolbar .chip-amount { width: 4rem; height: 1.5rem; padding: 0 0.3rem; }
button.chip-x, button.chip-x:hover { background: none; color: inherit; border: 0; padding: 0 0.15rem; line-height: 1; border-radius: 0; }
.line.cols-bank:focus-within, .toolbar:focus-within { position: relative; z-index: 6; }
.line {
  display: grid;
  gap: 0.35rem;
  align-items: center;
  min-width: 760px;
  padding: 0.28rem 0.55rem;
}
.line.cols-bank { min-width: 0; }
.line.head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbf6ee;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.line:not(.head) { border-top: 1px solid var(--line); }
.line.late { background: #fff4f1; }
.line.future { background: #f3f6fb; }
.line input, .line select {
  width: 100%;
  min-width: 0;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 0.45rem;
}
.line .check { white-space: nowrap; font-size: 0.82rem; color: var(--ink); height: 2rem; }
.cols-cash { grid-template-columns: 9.2rem minmax(8rem, 1.15fr) minmax(8rem, 1.35fr) 7.6rem 6.4rem 2rem 2rem; }
.cols-cheque { grid-template-columns: 6.5rem minmax(10rem, 1.4fr) 9.2rem minmax(7rem, 1fr) 7.4rem 2rem 2rem; }
.cols-bank {
  grid-template-columns:
    8.3rem
    minmax(0, 1.45fr)
    minmax(0, 0.75fr)
    minmax(5.6rem, 0.7fr)
    5.4rem
    4.6rem
    minmax(6.2rem, 0.85fr)
    minmax(8.6rem, max-content)
    4.15rem;
}
.row-actions { display: flex; gap: 0.25rem; justify-content: flex-end; }
.line .num { font-size: 0.86rem; }
.cols-sonarges { grid-template-columns: minmax(9rem, 1.2fr) 6.4rem minmax(9rem, 1.3fr) 6.2rem 7rem 2rem auto; }
.cols-user { grid-template-columns: 8rem minmax(8rem, 1fr) 11rem 6rem minmax(9rem, 1fr) 2rem; min-width: 760px; }
.fiche-link { font-size: 0.82rem; white-space: nowrap; }

.charts { display: grid; grid-template-columns: 1.35fr 0.9fr; gap: 0.75rem; margin-top: 0.75rem; }
.chart-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.75rem 0.9rem 0.9rem;
  min-width: 0;
}
.chart-card h2 { margin-bottom: 0.15rem; }
.chart-card p { margin: 0 0 0.45rem; }
.plot { position: relative; height: 260px; }
.plot.tall { height: 300px; }
.chart-card.wide { grid-column: 1 / -1; }
.synthesis {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
ul.moves { list-style: none; margin: 0; padding: 0; }
ul.moves li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-top: 1px solid var(--line); }
ul.moves small { color: var(--muted); }
.synthesis th, .synthesis td { padding: 0.38rem 0; border-bottom: 1px solid var(--line); text-align: left; }
.synthesis td { text-align: right; font-weight: 600; }
.stats.six { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: relative; height: auto; }
  .side nav { flex-direction: row; overflow: auto; margin-top: 0.8rem; }
  .stats, .stats.six, .split, .groups, .week, .grid-form, .filter-board, .charts { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: auto; }
  .side-foot { margin-top: 0.8rem; }
}
