/* ── Layout ──────────────────────────────────────────────────────────────── */

.sav-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.sav-form-page {
  max-width: 640px;
}

.sav-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.sav-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.sav-header-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ── Boutons soignés ──────────────────────────────────────────────────────── */

.sav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.sav-btn-primary {
  background: linear-gradient(135deg, #6c63ff, #8b7ffb);
  color: #fff;
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.35);
}
.sav-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(108, 99, 255, 0.45); }

.sav-btn-ghost {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.sav-btn-ghost:hover { background: #e2e8f0; }

/* ── Récap total ──────────────────────────────────────────────────────────── */

.sav-total-recap {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.sav-total-item {
  flex: 1;
  min-width: 140px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sav-total-label { font-size: 0.78rem; color: #64748b; }
.sav-total-value { font-size: 1.3rem; font-weight: 700; color: #0f172a; }

/* ── Carte épargne ────────────────────────────────────────────────────────── */

.sav-plan-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.sav-plan-header { margin-bottom: 0.75rem; }

.sav-plan-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sav-plan-icon { font-size: 1.3rem; }

.sav-plan-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  flex: 1;
}

.sav-plan-balance {
  font-size: 1.1rem;
  font-weight: 700;
  color: #6c63ff;
}

.sav-plan-desc {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0.3rem 0 0.5rem;
}

.sav-plan-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.sav-link-action {
  font-size: 0.85rem;
  color: #6c63ff;
  text-decoration: none;
  font-weight: 500;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.sav-link-danger { color: #dc2626; }

.sav-inline-form { display: inline; }

/* ── Enveloppes ───────────────────────────────────────────────────────────── */

.sav-envelope-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.sav-envelope-card {
  display: block;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sav-envelope-card:hover { border-color: #6c63ff; box-shadow: 0 4px 12px rgba(108, 99, 255, 0.12); }

.sav-envelope-reached { border-color: #86efac; background: #f0fdf4; }

.sav-envelope-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.sav-envelope-name { font-weight: 600; color: #0f172a; }
.sav-envelope-account { font-size: 0.75rem; color: #94a3b8; }

.sav-envelope-balance { font-size: 1.15rem; font-weight: 700; color: #0f172a; margin-bottom: 0.4rem; }
.sav-envelope-target { font-size: 0.85rem; font-weight: 500; color: #94a3b8; }

.sav-envelope-meta {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 0.4rem;
}

.sav-empty-hint { color: #94a3b8; font-size: 0.88rem; }

/* ── Barre de progression ─────────────────────────────────────────────────── */

.sav-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}
.sav-progress-bar-lg { height: 12px; margin: 0.5rem 0; }

.sav-progress-fill {
  height: 100%;
  background: #6c63ff;
  border-radius: inherit;
  transition: width 0.3s;
}
.sav-progress-done { background: #22c55e; }

.sav-color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
  flex-shrink: 0;
}

.sav-account-bar {
  display: flex;
  align-items: stretch;
}

.sav-account-bar-segment {
  height: 100%;
}

.sav-account-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.sav-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #475569;
}
.sav-badge-done { background: #dcfce7; color: #16a34a; }
.sav-badge-warn { background: #ffedd5; color: #c2410c; }

/* ── Page détail enveloppe ────────────────────────────────────────────────── */

.sav-detail-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sav-detail-title { font-size: 1.3rem; font-weight: 700; color: #0f172a; margin: 0; }
.sav-detail-actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.sav-detail-sub { font-size: 0.85rem; color: #64748b; margin-top: 0.3rem; }

.sav-detail-recap {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.sav-detail-balance { font-size: 1.8rem; font-weight: 700; color: #0f172a; }

.sav-detail-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.sav-stat { display: flex; flex-direction: column; gap: 0.15rem; }
.sav-stat-label { font-size: 0.75rem; color: #94a3b8; }
.sav-stat-value { font-size: 1rem; font-weight: 600; color: #0f172a; }

/* ── Blocs d'action (accordéons) ──────────────────────────────────────────── */

.sav-action-block {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 0.75rem;
}

.sav-action-summary {
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: #6c63ff;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.sav-action-summary::-webkit-details-marker { display: none; }

.sav-action-form { padding: 0 1rem 1rem; }

/* ── Historique ───────────────────────────────────────────────────────────── */

.sav-history-title { font-size: 1.05rem; font-weight: 700; color: #0f172a; margin: 1.5rem 0 0.6rem; }

.sav-history-list { display: flex; flex-direction: column; gap: 0.5rem; }

.sav-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
}

.sav-history-main { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.sav-history-date { font-size: 0.75rem; color: #94a3b8; }
.sav-history-label { font-size: 0.9rem; color: #0f172a; overflow-wrap: anywhere; }

.sav-history-right { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.sav-history-amount { font-weight: 700; font-size: 0.95rem; }

.sav-history-expense .sav-history-amount { color: #dc2626; }
.sav-history-contribution .sav-history-amount,
.sav-history-gift .sav-history-amount { color: #16a34a; }

.sav-history-link {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s;
}
.sav-history-link:hover { border-color: #6c63ff; }

/* ── Alerte de retard ─────────────────────────────────────────────────────── */

.sav-behind-alert {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #c2410c;
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* ── Graphique d'évolution ────────────────────────────────────────────────── */

.sav-chart-block {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}

.sav-chart-svg {
  display: block;
  width: 100%;
  height: 80px;
  margin-top: 0.4rem;
}

/* ── Répartition mensuelle ───────────────────────────────────────────────── */

.sav-allocate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.sav-allocate-info { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1 1 160px; }
.sav-allocate-name { font-weight: 600; color: #0f172a; }
.sav-allocate-need { font-size: 0.75rem; color: #94a3b8; }

.sav-allocate-account { max-width: 150px; }
.sav-allocate-input { max-width: 120px; text-align: right; }

.sav-allocate-total-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.75rem 0;
  margin-top: 0.5rem;
  border-top: 2px solid #e2e8f0;
}

/* ── Comptes ──────────────────────────────────────────────────────────────── */

.sav-envelope-over { border-color: #fca5a5; background: #fff1f2; }
.sav-envelope-warn { border-color: #fdba74; background: #fff7ed; }
.sav-progress-over { background: #dc2626; }
.sav-progress-warn { background: #f59e0b; }

.sav-text-danger { color: #dc2626; }
.sav-text-warn { color: #d97706; }

.sav-account-breakdown {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}

/* ── Réglages de répartition ──────────────────────────────────────────────── */

.sav-settings-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.sav-settings-row .sav-allocate-name { flex: 1 1 140px; }
.sav-settings-mode { max-width: 160px; }
.sav-settings-percent { max-width: 90px; text-align: right; }
.sav-settings-percent:disabled { background: #f1f5f9; color: #94a3b8; }

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .sav-envelope-grid { grid-template-columns: 1fr; }
  .sav-detail-stats { gap: 1rem; }
  .sav-allocate-input { max-width: 90px; }
  .sav-allocate-info { flex-basis: 100%; }
  .sav-allocate-account { max-width: 130px; }
}
