/* ===========================================================
   Refuge des Tilleuls — système de design
   Repris pixel-perfect du prototype Claude Design.
   =========================================================== */

:root {
  --bg:        #f7f1e8;
  --card:      #fffdf9;
  --border:    #e9dfd2;
  --border2:   #e2d5c2;
  --ink:       #2b2622;
  --muted:     #8a7c6e;
  --muted2:    #6f6355;
  --primary:   #d97750;
  --primary-d: #c9663f;
  --primary-dd:#a8502e;
  --green:     #3f5a4a;
  --green-d:   #344c3e;
  --soft:      #f3ebdf;
  --soft2:     #faf4ea;
  --peach:     #fdf0e8;
  --peach-br:  #f0d9c9;
  --greentint: #e9efe9;
  --yellow:    #f5ecd8;
  --purple:    #efe7f0;
  --red-bg:    #f8e5e2;
  --red:       #a8433a;
  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --body:    'Albert Sans', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); }
body {
  font-family: var(--body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary-d); text-decoration: none; }
a:hover { color: var(--primary-dd); text-decoration: underline; }
::selection { background: var(--peach-br); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; }

/* ---------- Structure ---------- */
.app { display: flex; height: 100vh; min-height: 720px; overflow: hidden; }
.main { flex: 1; overflow-y: auto; padding: 32px 40px; }
.wrap { max-width: 1180px; margin: 0 auto; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 24px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px; background: var(--primary);
  display: grid; place-items: center; color: var(--card);
  font-family: var(--display); font-weight: 700; font-size: 17px;
}
.brand-name { font-family: var(--display); font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand-sub  { font-size: 11px; color: var(--muted); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; border: none;
  font: inherit; font-size: 14px; padding: 10px 12px; border-radius: 10px;
  cursor: pointer; text-align: left; background: transparent;
  color: var(--muted2); font-weight: 500; text-decoration: none;
}
.nav-item:hover { background: var(--soft); text-decoration: none; color: var(--muted2); }
.nav-item.active { background: var(--peach); color: var(--primary-d); font-weight: 700; }
.nav-item.active:hover { color: var(--primary-d); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.capacity { background: var(--soft); border-radius: 14px; padding: 14px; }
.capacity-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.capacity-label { font-size: 12px; font-weight: 600; color: var(--muted2); }
.capacity-val { font-family: var(--display); font-weight: 700; font-size: 14px; }
.capacity-track { height: 6px; border-radius: 3px; background: var(--border2); overflow: hidden; }
.capacity-fill { height: 100%; border-radius: 3px; background: var(--primary); }
.capacity-sub { font-size: 11px; color: var(--muted); margin-top: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.user-ava {
  width: 32px; height: 32px; border-radius: 50%; background: var(--green);
  color: var(--card); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); }
.logout-btn { border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; font: inherit; }
.logout-btn:hover { color: var(--ink); }

/* ---------- En-têtes de page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-eyebrow { font-size: 13px; color: var(--muted); font-weight: 500; }
.page-title { font-size: 30px; font-weight: 700; margin: 4px 0 0; }
.head-actions { display: flex; gap: 10px; }

.back-link {
  display: inline-flex; align-items: center; gap: 8px; border: none; background: transparent;
  color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 6px 8px; margin: -6px 0 14px -8px; border-radius: 8px; cursor: pointer;
}
.back-link:hover { background: var(--soft); color: var(--ink); text-decoration: none; }

/* ---------- Boutons ---------- */
.btn {
  border: 1px solid var(--border); background: var(--card); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; padding: 10px 18px;
  border-radius: 12px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 8px; line-height: 1;
}
.btn:hover { background: var(--soft); text-decoration: none; color: var(--ink); }
.btn-primary { border: none; background: var(--primary); color: var(--card); }
.btn-primary:hover { background: var(--primary-d); color: var(--card); }
.btn-green { border: none; background: var(--green); color: var(--card); }
.btn-green:hover { background: var(--green-d); color: var(--card); }
.btn-sm { font-size: 12.5px; padding: 6px 12px; border-radius: 9px; }
.btn-xs { font-size: 12px; padding: 5px 11px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn-ghost { border: 1px solid var(--border); background: var(--card); font-size: 13px; padding: 9px 14px; border-radius: 10px; }

/* ---------- Cartes ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 22px 24px; }
.card-sm { border-radius: 16px; padding: 18px 20px; }
.card-title { font-family: var(--display); font-size: 18px; font-weight: 700; margin: 0 0 14px; }
.card-title-sm { font-size: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head .card-title { margin: 0; }

.grid { display: grid; gap: 20px; align-items: start; }
.grid-kpi { grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.g-1-360 { grid-template-columns: 1fr 360px; }
.g-1-400 { grid-template-columns: 1fr 400px; }
.g-340-1 { grid-template-columns: 340px 1fr; }
.g-380-1 { grid-template-columns: 380px 1fr; }
.g-400-1 { grid-template-columns: 400px 1fr; }
.g-half  { grid-template-columns: 1fr 1fr; }
.col { display: flex; flex-direction: column; gap: 20px; }

/* ---------- KPI ---------- */
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-value { font-family: var(--display); font-size: 32px; font-weight: 700; margin-top: 6px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-sub.up { color: var(--green); font-weight: 600; }
.kpi-sub.warn { color: var(--primary-d); }
.kpi-value.warn { color: var(--primary-d); }
.kpi-dark { background: var(--green); border-color: var(--green); color: #f4f1ea; }
.kpi-dark .kpi-label, .kpi-dark .kpi-sub { color: #c5d1c8; }

/* ---------- Alerte ---------- */
.alert {
  display: flex; align-items: center; gap: 12px; background: var(--peach);
  border: 1px solid var(--peach-br); border-radius: 14px; padding: 14px 18px; margin-bottom: 24px;
}
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.alert-text { font-size: 14px; }
.alert-link { margin-left: auto; font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  font-size: 12px; font-weight: 600; border-radius: 999px; padding: 5px 12px;
  white-space: nowrap; display: inline-block;
}
.badge-sm { padding: 4px 10px; }
.badge-green  { color: var(--green); background: var(--greentint); }
.badge-peach  { color: var(--primary-d); background: var(--peach); }
.badge-yellow { color: #9a7420; background: var(--yellow); }
.badge-purple { color: #7a5a80; background: var(--purple); }
.badge-grey   { color: var(--muted2); background: var(--soft); }
.badge-red    { color: var(--red); background: var(--red-bg); }

/* ---------- Listes / lignes ---------- */
.row-list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 14px; padding: 12px 10px;
  border-radius: 12px; cursor: pointer; border-bottom: 1px solid var(--soft);
  text-decoration: none; color: inherit;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--soft2); text-decoration: none; color: inherit; }
.row-main { min-width: 0; flex: 1; }
.row-name { font-size: 15px; font-weight: 600; }
.row-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.row-col { font-size: 12.5px; color: var(--muted); }

.filters { display: flex; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--card); color: var(--muted2);
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 12px;
  border-radius: 999px; cursor: pointer; text-decoration: none;
}
.chip:hover { border-color: #d9c9b2; text-decoration: none; color: var(--muted2); }
.chip.active { border-color: var(--primary); background: var(--peach); color: var(--primary-d); }

/* ---------- Tâches / checklist ---------- */
.check-row { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 10px; cursor: pointer; text-decoration: none; color: inherit; }
.check-row:hover { background: var(--soft2); text-decoration: none; color: inherit; }
.check-box {
  width: 20px; height: 20px; border-radius: 7px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--card); border: 1.5px solid #d9c9b2;
}
.check-box.done { background: var(--green); border-color: var(--green); }
.check-label { font-size: 14px; font-weight: 600; }
.check-label.done { color: #a99c8c; text-decoration: line-through; }
.check-sub { font-size: 12px; color: var(--muted); }
.check-time { font-size: 12px; font-weight: 600; color: var(--muted); }

/* ---------- Fiche : champs ---------- */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.field-label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.field-value { font-size: 14px; font-weight: 600; margin-top: 2px; }
.field-full { grid-column: 1 / -1; }
.tabnum { font-variant-numeric: tabular-nums; }

/* ---------- Traits ---------- */
.traits { display: flex; flex-wrap: wrap; gap: 8px; }
.trait { font-size: 12.5px; font-weight: 600; color: var(--green); background: var(--greentint); border-radius: 999px; padding: 5px 12px; }
.note-p { font-size: 13.5px; line-height: 1.55; color: var(--muted2); margin: 14px 0 0; }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; padding-bottom: 16px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 10px; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; background: var(--green); }
.tl-dot.last { background: var(--primary); }
.tl-line { width: 2px; flex: 1; background: #f0e5d4; margin-top: 4px; }
.tl-date { font-size: 12px; color: var(--muted); font-weight: 600; }
.tl-label { font-size: 13.5px; font-weight: 600; margin-top: 2px; }
.tl-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.tl-text { font-size: 13.5px; line-height: 1.5; margin-top: 3px; }

/* ---------- Documents ---------- */
.doc {
  display: flex; align-items: center; gap: 12px; border: 1px solid #f0e5d4;
  border-radius: 12px; padding: 10px 12px; text-decoration: none; color: inherit;
}
.doc:hover { background: var(--soft2); border-color: var(--border2); text-decoration: none; color: inherit; }
.doc-tile { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; flex-shrink: 0; }
.doc-tile.PDF { background: var(--peach); color: var(--primary-d); }
.doc-tile.IMG { background: var(--greentint); color: var(--green); }
.doc-tile.DOC { background: var(--yellow); color: #9a7420; }
.doc-label { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.dashed { border: 1.5px dashed #d9c9b2; border-radius: 12px; padding: 12px; text-align: center; font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ---------- Tableaux (grille) ---------- */
.tbl-head, .tbl-row { display: grid; gap: 8px; align-items: center; }
.tbl-head {
  font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0 8px 8px; border-bottom: 1px solid var(--soft);
}
.tbl-row { font-size: 13.5px; padding: 11px 8px; border-bottom: 1px solid var(--soft); text-decoration: none; color: inherit; }
.tbl-row:hover { background: var(--soft2); text-decoration: none; color: inherit; }
.tbl-row:last-child { border-bottom: none; }
.muted { color: var(--muted2); }
.strong { font-weight: 600; }
.due-warn { color: var(--primary-d); font-weight: 600; font-size: 13px; }
.due-ok { color: var(--muted); font-weight: 600; font-size: 13px; }

/* ---------- Photo ---------- */
.photo-slot {
  width: 100%; height: 260px; border-radius: 12px; overflow: hidden;
  background: var(--soft); display: grid; place-items: center; color: var(--muted);
  font-size: 13px; font-weight: 600;
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Poids (courbe) ---------- */
.weight-big { font-family: var(--display); font-size: 28px; font-weight: 700; }
.weight-cap { font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ---------- Stepper ---------- */
.stepper { display: flex; align-items: flex-start; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 9px; position: relative; min-width: 0; }
.step-conn { position: absolute; top: 17px; left: calc(50% + 22px); width: calc(100% - 44px); height: 2px; background: var(--border); }
.step-conn.on { background: var(--green); }
.step-circle {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13.5px; font-weight: 700; position: relative; z-index: 1;
  background: var(--card); color: var(--muted); border: 1.5px solid #d9c9b2;
}
.step-circle.done { background: var(--green); color: var(--card); border-color: var(--green); }
.step-circle.current { background: var(--primary); color: var(--card); border-color: var(--primary); }
.step-label { font-size: 12.5px; font-weight: 600; text-align: center; color: var(--muted); }
.step-label.done { color: var(--green); }
.step-label.current { color: var(--primary-d); }

/* ---------- Progress ---------- */
.progress { height: 6px; border-radius: 3px; background: var(--border2); overflow: hidden; }
.progress > div { height: 100%; border-radius: 3px; }
.pbar-green { background: var(--green); }
.pbar-primary { background: var(--primary); }

/* ---------- Blocs colorés ---------- */
.panel-green { background: var(--green); border-radius: 18px; padding: 22px 24px; color: #f4f1ea; }
.panel-green .eyebrow { font-size: 11.5px; color: #c5d1c8; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.panel-green .big { font-family: var(--display); font-size: 20px; font-weight: 700; margin-top: 8px; }
.panel-green .sub { font-size: 13px; color: #c5d1c8; margin-top: 4px; }
.eyebrow { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.tile-soft { background: var(--soft2); border-radius: 12px; padding: 12px 14px; }

/* ---------- Interrupteurs ---------- */
.switch { width: 38px; height: 22px; border-radius: 11px; flex-shrink: 0; padding: 2px; transition: background .15s; background: #d9c9b2; border: none; cursor: pointer; }
.switch.on { background: var(--green); }
.switch-knob { width: 18px; height: 18px; border-radius: 50%; background: var(--card); transition: transform .15s; display: block; }
.switch.on .switch-knob { transform: translateX(16px); }

/* ---------- Graphiques ---------- */
.bars { display: flex; align-items: flex-end; gap: 18px; height: 200px; padding: 0 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 44px; border-radius: 8px 8px 4px 4px; background: var(--border2); }
.bar.last { background: var(--primary); }
.bar-val { font-size: 12.5px; font-weight: 700; }
.bar-month { font-size: 12px; color: var(--muted); font-weight: 600; }
.hbar-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.hbar-label { width: 160px; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.hbar-track { flex: 1; height: 10px; background: var(--soft); border-radius: 5px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 5px; }
.hbar-n { width: 26px; text-align: right; font-size: 13px; font-weight: 700; }
.donut { width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.donut-hole { width: 78px; height: 78px; border-radius: 50%; background: var(--card); display: grid; place-items: center; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- Formulaires ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted2); margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; border: 1px solid var(--border2); background: var(--card); border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: 14px; color: var(--ink);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(217,119,80,.15);
}
.form-field textarea { min-height: 84px; resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--green); }

/* ---------- Modales ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(43,38,34,.45); display: none;
  place-items: center; z-index: 50; padding: 24px;
}
.modal-overlay.open { display: grid; }
.modal {
  background: var(--card); border-radius: 20px; padding: 26px 30px 28px; width: 580px;
  max-width: 100%; max-height: calc(100vh - 48px); overflow-y: auto;
  box-shadow: 0 24px 60px rgba(43,38,34,.28);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-family: var(--display); font-size: 21px; font-weight: 700; margin: 0; }
.modal-close {
  border: none; background: var(--soft); color: var(--muted2); width: 30px; height: 30px;
  border-radius: 50%; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.modal-close:hover { background: var(--border); }

/* ---------- Toast (flash) ---------- */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--card); font-size: 14px; font-weight: 600;
  padding: 13px 24px; border-radius: 14px; z-index: 60;
  box-shadow: 0 12px 32px rgba(43,38,34,.35); animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 400px; max-width: 100%; }
.login-logo { width: 52px; height: 52px; border-radius: 15px; background: var(--primary); display: grid; place-items: center; color: var(--card); font-family: var(--display); font-weight: 700; font-size: 22px; margin-bottom: 18px; }
.login-error { background: var(--red-bg); color: var(--red); font-size: 13px; font-weight: 600; padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }

/* ---------- Utilitaires ---------- */
.mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.gap-10 { display: flex; gap: 10px; }
.center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.items-center { align-items: center; }
.gap8 { gap: 8px; }
.rdv-date { width: 44px; text-align: center; background: var(--soft); border-radius: 10px; padding: 6px 0; flex-shrink: 0; }
.rdv-day { font-family: var(--display); font-size: 15px; font-weight: 700; line-height: 1; }
.rdv-month { font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; }

@media (max-width: 1100px) {
  .grid-kpi { grid-template-columns: repeat(2, 1fr); }
  .g-1-360, .g-1-400, .g-340-1, .g-380-1, .g-400-1, .g-half { grid-template-columns: 1fr; }
}
