/* ================================================================
   Mon budget - feuille de style
   Une seule couleur d'accent, des cartes, beaucoup d'espace.
   ================================================================ */

:root {
  /* La couleur principale (accent) et la couleur "attention" (danger) */
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --income: #16a34a;
  --income-soft: #f0fdf4;

  /* Les couleurs neutres du fond et du texte */
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1a1c29;
  --ink-soft: #5b6072;
  --ink-faint: #9aa0b0;
  --border: #e7e9f2;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 22, 40, 0.04), 0 8px 24px rgba(20, 22, 40, 0.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Le bandeau du haut ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-block;
  flex-shrink: 0;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.hello {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- La zone centrale ---------- */
.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* ---------- Les 3 cartes de resume ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-label {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
}

.stat-value {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* La carte du solde est mise en avant avec l'accent */
.stat-balance {
  background: var(--accent);
  border-color: var(--accent);
}
.stat-balance .stat-label { color: rgba(255, 255, 255, 0.8); }
.stat-balance .stat-value { color: #ffffff; }
/* Si le solde est negatif, on passe la carte en rouge */
.stat-balance.is-negative {
  background: var(--danger);
  border-color: var(--danger);
}

.stat-income { color: var(--income); }
.stat-expense { color: var(--danger); }

/* ---------- La grille en deux colonnes ---------- */
.columns {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

.right-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Les panneaux (formulaire, graphique, liste) ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- Le formulaire ---------- */
.field {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label,
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Le bouton Revenu / Depense */
.kind-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.kind-btn {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.kind-btn:hover { border-color: var(--ink-faint); }

/* Quand "Revenu" est choisi il devient vert */
#kind-income.is-active {
  background: var(--income-soft);
  border-color: var(--income);
  color: var(--income);
}
/* Quand "Depense" est choisi il devient rouge */
#kind-expense.is-active {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.form-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.submit-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.submit-btn:hover { filter: brightness(1.05); }
.submit-btn:active { filter: brightness(0.95); }
.submit-btn:disabled { opacity: 0.6; cursor: default; }

/* ---------- Le graphique en barres ---------- */
.breakdown {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
}

.bar-cat { font-weight: 500; color: var(--ink); }
.bar-amount {
  font-weight: 600;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* La piste grise dans laquelle glisse la barre coloree */
.bar-track {
  width: 100%;
  height: 12px;
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
  min-width: 4px;
}

.breakdown-empty { margin: 0; }

/* ---------- La liste des mouvements ---------- */
.movement-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.movement {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.movement:last-child { border-bottom: none; }

/* La petite pastille coloree a gauche de chaque ligne */
.movement-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.movement-dot.income { background: var(--income); }
.movement-dot.expense { background: var(--danger); }

.movement-main { flex: 1; min-width: 0; }

.movement-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movement-meta {
  font-size: 12.5px;
  color: var(--ink-faint);
}

.movement-amount {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.movement-amount.income { color: var(--income); }
.movement-amount.expense { color: var(--danger); }

.delete-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink-faint);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.delete-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

/* ---------- L'etat vide ---------- */
.empty-state {
  text-align: center;
  padding: 32px 16px;
}
.empty-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
}

.muted { color: var(--ink-soft); font-size: 14px; }

/* ---------- Sur petit ecran, on empile tout ---------- */
@media (max-width: 760px) {
  .stats { grid-template-columns: 1fr; }
  .columns { grid-template-columns: 1fr; }
}
