/* Mon carnet d'épargne — feuille de style partagée */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,600;1,9..144,500&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #eef0e4;
  --surface: #fbf9f2;
  --ink: #1f2d27;
  --muted: #7a7567;
  --accent: #2f6f4f;
  --gold: #8f6228;
  --alert: #b5453a;
  --border: #e3ded0;
  --border-soft: #ece7d8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.font-display { font-family: 'Fraunces', serif; }
.mono { font-family: 'IBM Plex Mono', monospace; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.gold { color: var(--gold); }
.alert { color: var(--alert); }

a { color: inherit; text-decoration: none; }

.app-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 16px 96px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 4px;
}

h1.page-title {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  margin: 0;
}

.page-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 6px 0 0;
}

.flash {
  margin-bottom: 20px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
}
.flash.error { background: #f7e3e0; color: var(--alert); }
.flash.success { background: #e9f0e7; color: var(--accent); }

/* Stats grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px;
}
.stat-card .label { font-size: 11px; color: var(--muted); margin: 0 0 2px; }
.stat-card .value { font-family: 'IBM Plex Mono', monospace; font-size: 14px; margin: 0; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 8px 24px -16px rgba(40,40,20,0.25);
}
.card-link {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.card h2 {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  margin: 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.card-head .small { font-size: 12px; color: var(--muted); }

/* Bars */
.bar {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: var(--border-soft);
  margin-bottom: 8px;
}
.bar.over { box-shadow: 0 0 0 2px var(--alert); }
.bar .seg { height: 100%; }
.bar .seg.stripe {
  background-image: repeating-linear-gradient(135deg, #ddd7c5 0 4px, #e9e4d6 4px 8px);
}
.bar-caption {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}
.bar-caption .warn { color: var(--alert); display: flex; align-items: center; gap: 4px; }

/* Rows (expenses, incomes, recurring, pockets) */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border-soft);
}
.row:first-child { border-top: none; }
.row-icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.row-main { flex: 1; min-width: 0; }
.row-main .name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-main .meta { font-size: 12px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; }
.row-amount { font-family: 'IBM Plex Mono', monospace; font-size: 14px; flex-shrink: 0; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; flex-shrink: 0; }

.empty-state { font-size: 13px; color: var(--muted); font-style: italic; padding: 8px 0; }

/* Progress mini-bar (pocket goal) */
.mini-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
  margin-top: 4px;
}
.mini-bar .fill { height: 100%; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  color: var(--ink);
}
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-soft { background: #eee9dc; color: var(--ink); }
.btn-outline { border: 1px dashed var(--accent); color: var(--accent); }
.btn-outline-gold { border: 1px dashed var(--gold); color: var(--gold); }
.btn-outline-muted { border: 1px dashed var(--border); color: var(--ink); }
.btn-danger { background: #eee9dc; color: var(--alert); }
.btn-icon { padding: 6px; border-radius: 8px; color: var(--muted); border: none; background: none; cursor: pointer; }
.btn-icon:hover { background: var(--border-soft); }
.btn-sm { font-size: 12px; padding: 6px 10px; }
.btn-row { display: flex; gap: 8px; }

/* Point toggle (rond de pointage) */
.point-toggle {
  width: 20px; height: 20px;
  border-radius: 999px;
  border: 1px solid #c9c2ac;
  background: transparent;
  flex-shrink: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 11px;
  padding: 0;
}
.point-toggle.pointed { background: var(--accent); border-color: var(--accent); }

/* Active/Inactive pill for recurring */
.pill-toggle {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.pill-toggle.active { background: var(--gold); color: #fff; border-color: var(--gold); }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3e6cf;
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Forms */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
}
.field input, .field select {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  background: #fff;
}
.field input.mono, .field select.mono { font-family: 'IBM Plex Mono', monospace; }

details.add-form summary {
  cursor: pointer;
  list-style: none;
  margin-top: 4px;
}
details.add-form summary::-webkit-details-marker { display: none; }
details.add-form .form-body { margin-top: 14px; }

.icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
.icon-opt {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
.icon-opt input { display: none; }
.icon-opt:has(input:checked) { background: #eef3ea; border-color: var(--accent); }

.color-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.color-opt {
  width: 28px; height: 28px;
  border-radius: 999px;
  cursor: pointer;
  display: block;
  border: 2px solid transparent;
}
.color-opt input { display: none; }
.color-opt:has(input:checked) { border-color: var(--ink); }

/* Bottom navigation */
.nav-bottom {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.nav-bottom .inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
}
.nav-item .ic { font-size: 18px; }
.nav-item.active { color: var(--accent); }

/* Login screen */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 8px 24px -16px rgba(40,40,20,0.25);
  text-align: center;
}
.login-card .emoji { font-size: 36px; margin-bottom: 8px; }

.hidden { display: none; }

@media (min-width: 480px) {
  .app-shell { padding-top: 48px; }
}
