/* Style global — simple, propre, responsive */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7686;
  --accent: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --border: #e3e8ef;
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
nav .brand { font-weight: 700; text-decoration: none; color: var(--text); }
nav .links { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav .links a {
  text-decoration: none; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; font-weight: 500;
}
nav .links a:hover { background: var(--bg); }
nav .links a.active { background: var(--accent); color: #fff; }
nav .logout button { background: none; border: 1px solid var(--border); }

main { max-width: 860px; margin: 0 auto; padding: 24px 16px 60px; }

h1 { font-size: 1.6rem; margin-bottom: 16px; }
h2 { font-size: 1.1rem; margin: 24px 0 10px; }
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card {
  display: block; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; text-decoration: none; color: var(--text);
  transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.card.selected { border-color: var(--accent); }
.card p { color: var(--muted); font-size: .9rem; margin-top: 4px; }

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 18px; font-size: .85rem; color: var(--muted); min-width: 120px;
}
.stat strong { font-size: 1.2rem; color: var(--text); }
.stat.green strong { color: var(--green); }
.stat.red strong { color: var(--red); }

form.add-form {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px;
}
input, select, button {
  font: inherit; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
button {
  background: var(--accent); color: #fff; border: none; cursor: pointer; font-weight: 500;
}
button:hover { opacity: .9; }
button.danger { background: var(--red); }
button.small { padding: 4px 10px; font-size: .85rem; }
.small-input { width: 110px; padding: 4px 8px; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }

table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
.right { text-align: right; }
.muted { color: var(--muted); font-size: .9rem; }
.red-text { color: var(--red); font-weight: 500; }
.green-text { color: var(--green); font-weight: 500; }

details { margin: 12px 0; }
summary { cursor: pointer; color: var(--accent); font-weight: 500; margin-bottom: 8px; }

/* Évolution du solde (barres) */
.evo-chart {
  display: flex; align-items: flex-end; gap: 6px; height: 140px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 12px 8px; margin: 12px 0;
}
.evo-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.evo-bar { width: 100%; max-width: 28px; border-radius: 4px 4px 0 0; min-height: 4px; }
.evo-bar.green { background: var(--green); }
.evo-bar.red { background: var(--red); }
.evo-label { font-size: .7rem; color: var(--muted); white-space: nowrap; }

/* Dépenses par catégorie (barres + budget) */
.cat-bars { display: flex; flex-direction: column; gap: 14px; margin: 12px 0 20px; }
.cat-row-head { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; margin-bottom: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.cat-bar-track { position: relative; height: 10px; background: var(--bg); border-radius: 6px; }
.cat-bar-fill { height: 100%; border-radius: 6px; }
.cat-bar-budget { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--text); border-radius: 1px; }

/* Ligne d'actions repliable dans un tableau (modifier/supprimer) */
.row-actions summary { font-weight: 700; margin: 0; }
.row-actions form.add-form { margin-top: 8px; justify-content: flex-end; }

/* Gestion des catégories : une mini-ligne de formulaire par catégorie */
.cat-manage { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.cat-manage form.add-form { padding: 8px 12px; }

/* Page de connexion */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; width: 100%; max-width: 360px; text-align: center;
}
.login-box h1 { margin-bottom: 20px; }
.login-box form { display: flex; flex-direction: column; gap: 10px; }
.error { color: var(--red); margin-bottom: 12px; }

@media (max-width: 600px) {
  form.add-form input, form.add-form select, form.add-form button { width: 100%; }
}
