:root {
  --bg: #F6F5F1;
  --ink: #1C1B19;
  --muted: #5F5D57;
  --faint: #77746D;
  --line: #E4E1D9;
  --line-soft: #EFECE5;
  --input: #CFCBC1;
  --chip: #F0EDE6;
  --track: #ECE9E1;
  --card: #FFFFFF;
  --accent: #2F6B4F;
  --accent-dark: #1F4A36;
  --warn: #B04C14;
  --font-body: Inter, system-ui, sans-serif;
  --font-head: 'Bricolage Grotesque', system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1, h2 { font-family: var(--font-head); margin: 0; }
h1 { font-size: 36px; font-weight: 700; letter-spacing: -0.5px; margin-top: 4px; }
h2 { font-size: 20px; }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }

/* Barre latérale */
.sidebar { flex: 1 1 220px; background: var(--ink); color: var(--bg); padding: 28px 16px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 20px; }
.brand-sub { font-size: 13px; color: #BDBAB2; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: #DCD9D1; text-decoration: none; }
.nav a:hover { background: #2A2926; color: #FFFFFF; }
.nav a[aria-current="page"] { background: #33322E; color: #FFFFFF; font-weight: 600; }
.mates { margin-top: auto; padding: 0 8px; display: flex; flex-direction: column; gap: 10px; }
.mates-label { font-size: 13px; color: #BDBAB2; }
.row { display: flex; gap: 6px; }

/* Contenu */
.main { flex: 999 1 560px; min-width: 0; padding: 36px clamp(16px, 4vw, 48px); display: flex; flex-direction: column; gap: 28px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.eyebrow { font-size: 14px; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 20px; align-items: start; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; align-items: start; }
.stat { gap: 6px; padding: 20px; }
.stat-value { font-family: var(--font-head); font-size: 32px; font-weight: 700; }
.small { font-size: 14px; color: var(--muted); }
.tiny { font-size: 13px; color: var(--muted); }
.pos { color: var(--accent); }
.neg { color: var(--warn); }
.progress { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .2s; }

.avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.avatar.sm { width: 34px; height: 34px; }

.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 500; }
.strong { font-weight: 600; }

.check { display: flex; align-items: center; gap: 12px; min-height: 44px; border-top: 1px solid var(--line-soft); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.check .label { flex: 1; }
.check input:checked ~ .label .text { color: var(--faint); text-decoration: line-through; font-weight: 400; }

.debt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 12px; background: var(--bg); }

.date { width: 52px; flex: none; text-align: center; border-radius: 10px; background: var(--bg); padding: 6px 0; }
.date-m { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.date-d { font-family: var(--font-head); font-size: 22px; font-weight: 700; }

/* Boutons et champs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--input); background: #FFFFFF; color: var(--ink); text-decoration: none; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--bg); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); color: #FFFFFF; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.btn-dark:hover { background: #33322E; color: #FFFFFF; }
.btn-icon { width: 44px; padding: 0; }
.self-start { align-self: flex-start; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, legend { font-size: 14px; font-weight: 500; }
.input { min-height: 44px; padding: 0 14px; border: 1px solid var(--input); border-radius: 12px; background: #FFFFFF; min-width: 0; width: 100%; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
fieldset { border: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
legend { padding: 0; margin-bottom: 8px; }
.inline-add { display: flex; gap: 8px; margin-top: 4px; }
.inline-add .input { flex: 1; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--input); background: #FFFFFF; color: var(--muted); cursor: pointer; }
.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; font-weight: 500; }
.pill.soft { border: none; background: var(--chip); color: var(--ink); font-size: 14px; }
.pill.soft[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.tag { padding: 4px 10px; border-radius: 999px; background: var(--chip); font-size: 13px; }

/* Soldes */
.balance { display: grid; grid-template-columns: 64px 1fr 84px; align-items: center; gap: 12px; }
.bar { height: 12px; border-radius: 6px; background: var(--track); position: relative; overflow: hidden; }
.bar .fill { position: absolute; top: 0; bottom: 0; border-radius: 6px; }
.bar .zero { position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: #9C998F; }
.right { text-align: right; }
.settle { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.divider { border-top: 1px solid var(--line-soft); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }

/* Tableau */
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 560px; border-collapse: collapse; }
th { padding: 10px 8px; font-weight: 500; text-align: left; color: var(--muted); font-size: 13px; }
td { padding: 12px 8px; border-top: 1px solid var(--line-soft); }

/* Tâches */
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-label { min-width: 170px; text-align: center; font-weight: 600; }
.progress-card { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 16px; padding: 20px 22px; }
.progress-card .grow { flex: 1 1 240px; display: flex; flex-direction: column; gap: 6px; }
.person { padding: 18px; gap: 6px; }
.person-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.person-head h2 { font-size: 19px; }
.rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; line-height: 1.5; }
.spaced { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }

.notice { background: #FFF6E5; border: 1px solid #EBD3A6; color: #5C4410; border-radius: 12px; padding: 10px 14px; font-size: 14px; }
