/* ── Variables & Reset ──────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --c-primary:      #5B8DEF;
  --c-primary-dark: #3A6FD8;
  --c-accent:       #FF6B35;
  --c-accent-dark:  #E55A28;
  --c-bg:           #EEF2FF;
  --c-surface:      #FFFFFF;
  --c-text:         #111827;
  --c-muted:        #6B7280;
  --c-border:       #E5E7EB;
  --c-danger:       #EF4444;

  --radius:    18px;
  --radius-sm: 10px;
  --gap:       16px;

  --shadow:    0 2px 12px rgba(91,141,239,.10);
  --shadow-lg: 0 8px 32px rgba(91,141,239,.18);

  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── Screens ────────────────────────────────────────────────────────────── */

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* ── Welcome ────────────────────────────────────────────────────────────── */

.welcome-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 24px 32px;
  gap: 16px;
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
}

.welcome-logo {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.12));
}

.welcome-title {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--c-primary);
  letter-spacing: -.02em;
}

.welcome-subtitle {
  font-size: 1rem;
  color: var(--c-muted);
  margin-top: -8px;
}

/* ── Card ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  width: 100%;
}

label {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 10px;
}

.input-row {
  display: flex;
  gap: 8px;
}

input[type="text"] {
  flex: 1;
  padding: 13px 16px;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-family: var(--font);
  font-weight: 700;
  color: var(--c-text);
  background: var(--c-bg);
  outline: none;
  transition: border-color .2s;
  text-transform: uppercase;
  letter-spacing: .12em;
  min-width: 0;
}

input[type="text"]::placeholder {
  font-weight: 400;
  letter-spacing: .04em;
  color: var(--c-border);
}

input[type="text"]:focus {
  border-color: var(--c-primary);
  background: #fff;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity .15s, transform .1s, background .15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(.96);
  opacity: .88;
}

.btn:disabled,
.btn-edit-save:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}

.btn-primary:hover { background: var(--c-primary-dark); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-primary);
  border: 2px solid var(--c-primary);
  width: 100%;
}

.btn-secondary:hover { background: var(--c-bg); }

.btn-start {
  background: var(--c-accent);
  color: #fff;
  width: 100%;
  padding: 22px 20px;
  font-size: 1.15rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.btn-start:hover  { background: var(--c-accent-dark); }
.btn-start:active { transform: scale(.97); }

.btn-finish {
  background: var(--c-primary);
  color: #fff;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-sm);
}

.btn-finish:hover { background: var(--c-primary-dark); }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  color: var(--c-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon:hover {
  background: var(--c-border);
  color: var(--c-text);
}

/* ── Divider ────────────────────────────────────────────────────────────── */

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: var(--c-muted);
  font-size: .85rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* ── App Header ─────────────────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  flex-shrink: 0;
}

.session-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--c-bg);
  border: none;
  border-radius: 20px;
  font-size: .95rem;
  font-weight: 800;
  color: var(--c-primary);
  cursor: pointer;
  letter-spacing: .18em;
  font-family: var(--font);
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}

.session-code-btn:hover { background: var(--c-border); }

.header-spacer { flex: 1; }

/* ── Main Content ───────────────────────────────────────────────────────── */

.main-content {
  flex: 1;
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* ── Active Bottle Card ─────────────────────────────────────────────────── */

.bottle-active {
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
}

.timer-started {
  font-size: .85rem;
  color: var(--c-muted);
}

.timer-started strong {
  color: var(--c-text);
}

.timer-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.timer-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.timer-value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--c-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -.02em;
}

/* ── Quantity Selector ──────────────────────────────────────────────────── */

.quantity-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.btn-qty {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2.5px solid var(--c-primary);
  background: var(--c-surface);
  color: var(--c-primary);
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
  font-family: var(--font);
}

.btn-qty:active {
  background: var(--c-primary);
  color: #fff;
  transform: scale(.9);
}

.qty-display {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 90px;
  justify-content: center;
}

.qty-value {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.qty-unit {
  font-size: 1rem;
  color: var(--c-muted);
  font-weight: 600;
}

/* ── Prédictions (ligne sous le récap) ──────────────────────────────────── */

.recap-predict {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  margin-top: 6px;
  border-top: 1px solid var(--c-border);
}

.predict-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.predict-value {
  font-size: .9rem;
  font-weight: 800;
  color: var(--c-text);
  line-height: 1;
  white-space: nowrap;
}

.predict-value[data-sign="pos"] { color: #16A34A; }
.predict-value[data-sign="neg"] { color: var(--c-accent); }

.predict-label {
  font-size: .58rem;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

.predict-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--c-border);
  flex-shrink: 0;
}

/* ── Idle State ─────────────────────────────────────────────────────────── */

.bottle-idle {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.prep-size-hint {
  text-align: center;
  margin-top: 10px;
  font-size: .88rem;
  color: var(--c-muted);
}

.prep-size-hint strong {
  color: var(--c-primary);
  font-weight: 800;
}

/* ── Bottles Section ────────────────────────────────────────────────────── */

.bottles-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 24px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: .7rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 0 2px;
}

.btn-section-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--c-border);
  border-radius: 20px;
  background: var(--c-surface);
  color: var(--c-muted);
  font-size: .72rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-section-action:hover {
  color: var(--c-primary);
  border-color: var(--c-primary);
  background: var(--c-bg);
}

.bottles-empty {
  text-align: center;
  color: var(--c-muted);
  padding: 28px 16px;
  font-size: .9rem;
}

.bottles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
}

/* ── Bottle Item ────────────────────────────────────────────────────────── */

.bottle-item {
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  padding: 14px 12px 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.bottle-item-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}

.bottle-item-info {
  flex: 1;
  min-width: 0;
}

.bottle-item-time {
  font-size: .95rem;
  font-weight: 700;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottle-item-meta {
  font-size: .78rem;
  color: var(--c-muted);
  margin-top: 2px;
}

.bottle-item-qty {
  font-size: .95rem;
  font-weight: 800;
  color: var(--c-primary);
  flex-shrink: 0;
  white-space: nowrap;
}

.bottle-item-qty.pending {
  color: var(--c-muted);
  font-weight: 500;
  font-size: .82rem;
}

.bottle-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.bottle-edited {
  font-size: .7rem;
  color: var(--c-muted);
  opacity: .7;
  font-style: italic;
}

.btn-delete,
.btn-edit {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.btn-delete:hover {
  color: var(--c-danger);
  background: #FEF2F2;
}

.btn-edit:hover {
  color: var(--c-primary);
  background: var(--c-bg);
}

/* ── Boutons événements ─────────────────────────────────────────────────── */

.event-section {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--c-border);
}

.btn-event {
  font-size: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--c-border);
  background: var(--c-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform .12s, background .12s;
  -webkit-tap-highlight-color: transparent;
}

.btn-event:active {
  transform: scale(.88);
  background: var(--c-border);
}

/* ── Badges événements (liste + standalone) ─────────────────────────────── */

.bottle-events {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 3px;
}

.event-badge {
  font-size: .9rem;
  padding: 1px 3px;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
}

.event-badge:hover {
  background: var(--c-bg);
}

/* ── Événements standalone du jour ──────────────────────────────────────── */

.standalone-events-row {
  padding: 0 16px 10px;
}

.events-details { width: 100%; }

.events-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.events-summary::-webkit-details-marker,
.events-summary::marker { display: none; }

.events-summary-emojis {
  font-size: .95rem;
  letter-spacing: 1px;
}

.events-summary-count {
  font-size: .75rem;
  color: var(--c-muted);
}

.events-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 2px;
}

.event-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px 3px 6px;
  border: 1px solid var(--c-border);
  border-radius: 20px;
  background: var(--c-surface);
  cursor: pointer;
  font-size: .85rem;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}

.event-chip:active { background: var(--c-border); }

.event-chip-time {
  font-size: .72rem;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Événements dans la timeline ────────────────────────────────────────── */

.event-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 14px;
  list-style: none;
  border-left: 2px solid var(--c-border);
  margin: 0 0 0 8px;
}

.event-item-emoji {
  font-size: .95rem;
  flex-shrink: 0;
  line-height: 1;
}

.event-item-label {
  flex: 1;
  font-size: .82rem;
  font-weight: 500;
  color: var(--c-text);
}

.event-item-time {
  font-size: .75rem;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.event-item-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  transition: color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.event-item-del:hover {
  color: var(--c-danger);
  background: #FEF2F2;
}

/* ── Séparateurs de jour ────────────────────────────────────────────────── */

.day-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
  font-size: .7rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  list-style: none;
}

.day-separator::before,
.day-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

.day-sep-label {
  white-space: nowrap;
}

.day-sep-total {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  opacity: .75;
  white-space: nowrap;
}

.day-sep-total::before {
  content: '— ';
}

/* ── Boutons événements (taille réduite, formulaire d'édition) ──────────── */

.btn-event-sm {
  font-size: 1.15rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--c-border);
  background: var(--c-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform .12s, background .12s;
  -webkit-tap-highlight-color: transparent;
}

.btn-event-sm:active  { transform: scale(.88); background: var(--c-border); }
.btn-event-sm:disabled { opacity: .4; cursor: not-allowed; }

/* ── Section événements du formulaire d'édition ─────────────────────────── */

.edit-form-row--events {
  align-items: flex-start;
}

.edit-events-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.edit-events-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.event-badge--edit {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
}

.event-badge-time {
  font-size: .65rem;
  color: var(--c-muted);
}

.edit-events-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Formulaire d'édition inline ────────────────────────────────────────── */

.edit-form {
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 2px;
}

.edit-form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.edit-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0;
  width: 70px;
  flex-shrink: 0;
}

.edit-input {
  flex: 1;
  padding: 8px 10px;
  border: 1.5px solid var(--c-border);
  border-radius: 8px;
  font-size: .9rem;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
  min-width: 0;
  transition: border-color .2s;
}

.edit-input:focus {
  border-color: var(--c-primary);
}

.edit-qty-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-edit-qty {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--c-primary);
  background: var(--c-surface);
  color: var(--c-primary);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
  font-family: var(--font);
  flex-shrink: 0;
}

.btn-edit-qty:active {
  background: var(--c-primary);
  color: #fff;
  transform: scale(.9);
}

.edit-qty-display {
  display: flex;
  align-items: baseline;
  gap: 3px;
  min-width: 60px;
  justify-content: center;
}

.edit-qty-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.edit-qty-unit {
  font-size: .82rem;
  color: var(--c-muted);
  font-weight: 600;
}

.edit-error {
  font-size: .82rem;
  color: var(--c-danger);
  font-weight: 500;
  margin: 0;
}

.edit-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 2px;
}

.btn-edit-cancel {
  background: var(--c-surface);
  color: var(--c-muted);
  border: 1.5px solid var(--c-border);
  padding: 8px 16px;
  font-size: .85rem;
}

.btn-edit-save {
  padding: 8px 16px;
  font-size: .85rem;
}

/* ── Pied de liste (scroll infini) ──────────────────────────────────────── */

.bottles-footer {
  text-align: center;
  padding: 16px 0 8px;
}

.foot-end {
  font-size: .78rem;
  color: var(--c-border);
  font-weight: 500;
}

.foot-loading {
  font-size: .78rem;
  color: var(--c-muted);
}

.btn-load-more {
  background: none;
  border: 1.5px solid var(--c-border);
  border-radius: 20px;
  padding: 8px 20px;
  font-size: .82rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--c-primary);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-load-more:hover {
  background: var(--c-bg);
  border-color: var(--c-primary);
}

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--c-text);
  color: #fff;
  padding: 11px 22px;
  border-radius: 24px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity .25s, transform .25s;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ── Utilities ──────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

.error-msg {
  margin-top: 10px;
  font-size: .85rem;
  color: var(--c-danger);
  font-weight: 500;
}

/* ── Récap journalier ───────────────────────────────────────────────────── */

.daily-recap {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.recap-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.recap-stats {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.recap-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.recap-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--c-text);
  line-height: 1;
  white-space: nowrap;
}

.recap-label {
  font-size: .6rem;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

.recap-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--c-border);
  flex-shrink: 0;
}

.btn-stats {
  flex-shrink: 0;
  border: none;
  background: var(--c-bg);
  border-radius: var(--radius-sm);
  padding: 9px;
  cursor: pointer;
  color: var(--c-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-stats:hover { background: var(--c-border); }

/* ── Modale ─────────────────────────────────────────────────────────────── */

@keyframes fadeOverlay {
  from { background: rgba(0,0,0,0); }
  to   { background: rgba(0,0,0,.48); }
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.48);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeOverlay .2s ease;
}

.modal {
  background: var(--c-surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp .25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  position: sticky;
  top: 0;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  z-index: 1;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Sections stats ─────────────────────────────────────────────────────── */

.stats-section + .stats-section {
  border-top: 1px solid var(--c-border);
  padding-top: 16px;
  margin-top: 4px;
}

.stats-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.stats-section-title {
  font-size: .8rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Sélecteur référence journalière ────────────────────────────────────── */

.daily-ref-selector {
  display: flex;
  gap: 4px;
}

.btn-ref {
  padding: 3px 9px;
  font-size: .72rem;
  font-weight: 500;
  border: 1px solid var(--c-border);
  border-radius: 20px;
  background: transparent;
  color: var(--c-muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  line-height: 1.4;
}

.btn-ref.active {
  background: var(--c-primary, #5B8DEF);
  border-color: var(--c-primary, #5B8DEF);
  color: #fff;
}

/* ── Légende du graphique journalier ────────────────────────────────────── */

.chart-daily-legend {
  display: flex;
  gap: 14px;
  font-size: .75rem;
  color: var(--c-muted);
  margin-top: 6px;
  padding: 0 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-today { background: #5B8DEF; }
.legend-ref   { background: #FB923C; opacity: .65; }

.chart-empty {
  font-size: .82rem;
  color: var(--c-muted);
  text-align: center;
  padding: 20px 0;
}

/* ── Graphique ──────────────────────────────────────────────────────────── */

.chart-container {
  background: var(--c-bg);
  border-radius: var(--radius-sm);
  padding: 12px 8px 4px;
  overflow: hidden;
}

/* ── Résumé stats ───────────────────────────────────────────────────────── */

.stats-dl {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stats-dl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--c-border);
}

.stats-dl-row:last-child { border-bottom: none; }

.stats-dl-row dt {
  font-size: .85rem;
  color: var(--c-muted);
  font-weight: 500;
}

.stats-dl-row dd {
  font-size: .9rem;
  font-weight: 700;
  color: var(--c-text);
  text-align: right;
}

.stats-sub {
  font-size: .78rem;
  color: var(--c-muted);
  font-weight: 400;
}
