:root {
  --bg: #EDE6D6;
  --card: #FBF8F0;
  --ink: #1E2A38;
  --ink-soft: #4C5A68;
  --line: #D9CFB6;
  --lemon: #E8B93E;
  --olive: #6E7B3D;
  --clay: #B3552A;
  --clay-dark: #8F421F;
  --white: #FFFDF8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(30,42,56,0.05) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---------- Écran de connexion ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 40px -24px rgba(30,42,56,0.4);
}
.login-card h1 {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  margin: 4px 0 10px;
}
.login-sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 20px;
  line-height: 1.5;
}
.login-card label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  gap: 5px;
  margin-bottom: 14px;
}
.login-card input {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
}
.login-error {
  color: var(--clay-dark);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 6px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Header ---------- */
.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}
.eyebrow {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--clay);
  margin-bottom: 4px;
}
h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 32px;
  margin: 0;
  letter-spacing: -0.01em;
}
.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 100px;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-ghost:hover { background: var(--ink); color: var(--white); }

/* ---------- Plate gauge (signature element) ---------- */
.plate-section {
  display: flex;
  gap: 24px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.plate-gauge {
  position: relative;
  width: 180px;
  height: 180px;
  flex-shrink: 0;
}
.plate-gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-track {
  fill: none;
  stroke: var(--line);
  stroke-width: 12;
}
.gauge-fill {
  fill: none;
  stroke: var(--clay);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 540;
  stroke-dashoffset: 540;
  transition: stroke-dashoffset .6s ease, stroke .3s ease;
}
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.gauge-total {
  font-family: 'Fraunces', serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}
.gauge-label {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.gauge-target {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--clay);
  margin-top: 6px;
}

.plate-meta { flex: 1; min-width: 220px; }
.meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}
.meta-row.strong { color: var(--ink); font-weight: 600; border-bottom: none; padding-top: 10px; }
.meta-row span:last-child { font-size: 13px; }

.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 16px 0 10px;
}
.date-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  min-width: 100px;
  text-align: center;
  text-transform: capitalize;
}
.btn-icon {
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--line); }

.btn-clay {
  width: 100%;
  background: var(--clay);
  color: var(--white);
  border: none;
  padding: 12px;
  border-radius: 100px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease;
}
.btn-clay:hover { background: var(--clay-dark); }
.btn-clay.full { margin-top: 6px; }

/* ---------- Suivi du poids ---------- */
.poids-section {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 30px -18px rgba(30,42,56,0.35);
  margin-bottom: 20px;
}
.poids-body { padding: 6px 20px 20px; }

.poids-chart-wrap {
  width: 100%;
  height: 110px;
  margin: 10px 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.poids-chart-wrap svg { width: 100%; height: 100%; }
.poids-chart-empty {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  margin: 0;
  padding: 0 10px;
}

.poids-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.poids-stat {
  flex: 1;
  min-width: 68px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}
.poids-stat.highlight { background: #F3E7D8; border-color: var(--clay); }
.poids-stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.poids-stat-value { font-size: 15px; font-weight: 600; }

.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.progress-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 100px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--lemon), var(--olive));
  border-radius: 100px;
  width: 0%;
  transition: width .5s ease;
}
.progress-bar-pct {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--ink-soft);
  min-width: 38px;
  text-align: right;
}

.poids-message {
  font-family: 'Fraunces', serif;
  font-size: 15px;
  text-align: center;
  color: var(--olive);
  margin: 0 0 14px;
  line-height: 1.4;
}

.poids-form {
  display: flex;
  gap: 8px;
}
.poids-form input {
  flex: 1;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.poids-form button { width: auto; padding: 10px 18px; }

/* ---------- Ticket (menu list) ---------- */
.ticket {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 30px -18px rgba(30,42,56,0.35);
}
.ticket-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px dashed var(--line);
}

.repas-bloc { border-bottom: 1px dashed var(--line); }
.repas-bloc:last-child { border-bottom: none; }

.repas-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 20px 6px;
}
.repas-nom {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 19px;
}
.repas-kcal {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--ink-soft);
}

.repas-items { padding: 0 20px 6px; }
.item-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  font-size: 14px;
}
.item-nom { color: var(--ink); }
.item-kcal {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  margin-left: 12px;
}
.item-fill {
  flex: 1;
  border-bottom: 1px dotted var(--line);
  margin: 0 6px;
  transform: translateY(-3px);
}

.repas-foot {
  padding: 10px 20px 18px;
}
.btn-stamp {
  border: 1.5px solid var(--olive);
  color: var(--olive);
  background: none;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transform: rotate(-2deg);
  transition: all .15s ease;
}
.btn-stamp.mange {
  background: var(--olive);
  color: var(--white);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30,42,56,0.45);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-head h2 {
  font-family: 'Fraunces', serif;
  margin: 0;
  font-size: 22px;
}
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-body label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  gap: 5px;
}
.modal-body input, .modal-body select {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
}

@media (max-width: 480px) {
  h1 { font-size: 26px; }
  .plate-section { flex-direction: column; }
  .plate-gauge { margin: 0 auto; }
}
