/* ════════════════════════════════════════════════
   DÉPENSES FAMILIALES — style.css
   Direction : Ardoise & Cuivre
   Polices   : Source Serif 4 (300/400/600) + Karla (400/500/600/700)
════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,wght@0,300;0,400;0,600;1,300&family=Karla:wght@400;500;600;700&display=swap');

/* ── Tokens ──────────────────────────────────── */
:root {
  --bg:      #e2ddd5;
  --slate:   #2a2d35;
  --sheet:   #f5f1eb;
  --rule:    #ccc4b6;
  --copper:  #9c4e20;
  --muted:   #7a7264;
  --pale:    #ece7de;
  --white:   #fdfaf5;
  --error:   #b03030;
  --success: #3a6b42;

  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-sans:  'Karla', system-ui, sans-serif;

  --radius-sm: 5px;
  --radius:    8px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 4px rgba(42,45,53,0.07);
  --shadow:    0 2px 14px rgba(42,45,53,0.10);
  --shadow-lg: 0 8px 32px rgba(42,45,53,0.18);

  --nav-h: 54px;
  --bnav-h: 64px;
}

/* ── Reset ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--slate);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────── */
h1 { font-family: var(--font-serif); font-weight: 300; font-size: 1.55rem; letter-spacing: 0.01em; }
h2 { font-family: var(--font-serif); font-weight: 300; font-size: 1.2rem; letter-spacing: 0.01em; }
h3 { font-family: var(--font-serif); font-weight: 400; font-size: 1rem; }
label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
a { color: var(--copper); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Desktop nav ─────────────────────────────── */
.nav {
  background: var(--slate);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav__brand {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 300;
  color: var(--sheet);
  letter-spacing: 0.04em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
.nav__brand::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--copper);
  display: inline-block;
  flex-shrink: 0;
}

.nav__links {
  display: flex;
  gap: 3px;
  list-style: none;
}
.nav__link {
  padding: 6px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.nav__link:hover { color: var(--sheet); text-decoration: none; }
.nav__link--active {
  background: rgba(245,241,235,0.12);
  color: var(--sheet);
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav__logout {
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  padding: 0;
  transition: color 0.15s;
}
.nav__logout:hover { color: var(--sheet); }

/* ── Mobile header ───────────────────────────── */
.mobile-header {
  display: none;
  background: var(--slate);
  height: 50px;
  padding: 0 20px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.mobile-header__brand {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 300;
  color: var(--sheet);
  display: flex;
  align-items: center;
  gap: 8px;
}
.mobile-header__brand::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--copper);
  display: inline-block;
}
.mobile-header__logout {
  background: none; border: none;
  font-size: 0.75rem; color: var(--muted);
  cursor: pointer; font-family: var(--font-sans);
}

/* ── Bottom nav ──────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bnav-h);
  background: var(--slate);
  z-index: 100;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.bottom-nav__inner { display: flex; height: 100%; }
.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  transition: color 0.15s;
}
.bottom-nav__item svg { width: 20px; height: 20px; }
.bottom-nav__item--active { color: var(--sheet); }

/* ── Page container ──────────────────────────── */
.page {
  padding: 28px 32px;
  max-width: 1280px;
  margin: 0 auto;
}

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card__title { margin-bottom: 20px; }

/* ── Form fields ─────────────────────────────── */
.field { margin-bottom: 12px; }
.field--full { grid-column: span 2; }

.input,
.select {
  width: 100%;
  background: var(--pale);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--slate);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s, background 0.15s;
}
.input:focus,
.select:focus {
  outline: none;
  border-color: var(--copper);
  background: var(--white);
}
.input::placeholder { color: var(--muted); font-weight: 400; }

/* Amount — big centered input on dark bg */
.input--amount {
  background: var(--slate);
  color: var(--sheet);
  font-family: var(--font-serif);
  font-size: 2.75rem;
  font-weight: 300;
  text-align: center;
  padding: 16px 20px;
  border-radius: var(--radius);
  width: 100%;
  border: 2px solid transparent;
  margin-bottom: 18px;
}
.input--amount:focus {
  background: var(--slate);
  border-color: var(--copper);
  outline: none;
}
.input--amount::placeholder { color: rgba(245,241,235,0.3); }

/* Select wrapper (for custom arrow) */
.select-wrap { position: relative; }
.select-wrap::after {
  content: '';
  pointer-events: none;
  position: absolute;
  right: 12px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
}

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.86; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--primary { background: var(--copper); color: #fff; width: 100%; margin-top: 6px; }
.btn--secondary { background: var(--pale); color: var(--slate); }
.btn--danger { background: var(--error); color: #fff; }
.btn--icon {
  background: transparent;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}
.btn--icon:hover { color: var(--copper); opacity: 1; }
.btn--sm { font-size: 0.8125rem; padding: 8px 14px; }

/* ── 2-col form grid ─────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

/* ── Saisie layout ───────────────────────────── */
.saisie-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}

/* ── Tag custom block ────────────────────────── */
.tag-custom {
  background: var(--pale);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 14px;
}
.tag-custom__label {
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.tag-custom__row { display: flex; gap: 8px; }
.tag-custom__row .input { flex: 1; }
.tag-custom__row .btn { flex-shrink: 0; }

/* ── Recent list ─────────────────────────────── */
#recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--rule);
}
.recent-item:last-child { border-bottom: none; }
.recent-item__info { flex: 1; min-width: 0; }
.recent-item__label {
  font-weight: 600; font-size: 0.875rem;
  color: var(--slate); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.recent-item__meta { font-size: 0.6875rem; color: var(--muted); margin-top: 2px; }
.recent-item__amount {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--copper);
  margin: 0 14px;
  white-space: nowrap;
}
.recent-item__actions { display: flex; gap: 2px; flex-shrink: 0; }

/* ── KPI strip ───────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.kpi-card__label {
  font-size: 0.625rem; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.kpi-card__value {
  font-family: var(--font-serif);
  font-size: 1.6rem; font-weight: 300;
  color: var(--slate); line-height: 1.1;
}
.kpi-card--accent .kpi-card__value { color: var(--copper); }

/* ── Filter panel ────────────────────────────── */
.filter-panel {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.filter-panel__grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr auto;
  gap: 10px 14px;
  align-items: end;
}
.filter-panel__actions { display: flex; gap: 6px; }

/* ── Historique table ────────────────────────── */
.data-table {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.data-table table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead tr { background: var(--pale); }
.data-table th {
  font-size: 0.625rem; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); padding: 12px 16px;
  text-align: left; border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 16px;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--pale); }
.data-table .td--amount {
  font-family: var(--font-serif);
  font-size: 1rem; color: var(--copper);
  white-space: nowrap;
}
.data-table .td--actions { width: 80px; }
.data-table .td--actions-inner { display: flex; gap: 2px; }

/* Result count */
.result-count {
  font-size: 0.75rem; color: var(--muted);
  margin-bottom: 10px; padding: 0 2px;
}

/* ── Stats layout ────────────────────────────── */
.stats-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.chart-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}
.chart-card__title {
  font-size: 0.625rem; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 16px;
}
.chart-card canvas { display: block; width: 100% !important; }

/* Splits */
.split-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
.split-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.split-card__title {
  font-size: 0.625rem; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 12px;
}
.split-item {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--rule);
  font-size: 0.875rem;
}
.split-item:last-child { border-bottom: none; }
.split-item__name { font-weight: 600; }
.split-item__pct {
  font-family: var(--font-serif);
  font-size: 1.05rem; color: var(--copper);
}

/* ── Edit modal / bottom sheet ───────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(42,45,53,0.52);
  z-index: 300;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.is-open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 28px 32px 36px;
  width: 100%;
  max-width: 580px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
.modal__close {
  background: none; border: none;
  font-size: 1.5rem; line-height: 1;
  color: var(--muted); cursor: pointer;
  padding: 0 4px;
}
.modal__close:hover { color: var(--slate); }
.modal__footer { display: flex; gap: 10px; margin-top: 16px; }
.modal__footer .btn { flex: 1; }

/* ── Toasts ──────────────────────────────────── */
#toast-container {
  position: fixed;
  top: calc(var(--nav-h) + 16px);
  right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--slate);
  color: var(--sheet);
  padding: 11px 18px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  pointer-events: auto;
  animation: toastIn 0.22s ease;
  transition: opacity 0.25s;
}
.toast::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--copper);
  flex-shrink: 0;
}
.toast--success::before { background: #5aab60; }
.toast--error::before   { background: var(--error); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}

/* ── Login ───────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--slate);
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px 44px;
  width: 100%;
  max-width: 390px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  font-family: var(--font-serif);
  font-size: 1.5rem; font-weight: 300;
  color: var(--slate); margin-bottom: 4px;
  display: flex; align-items: center; gap: 10px;
}
.login-brand::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%; background: var(--copper);
  display: inline-block; flex-shrink: 0;
}
.login-subtitle {
  font-size: 0.8125rem; color: var(--muted);
  margin-bottom: 28px;
}
.login-error {
  display: none;
  font-size: 0.8125rem; color: var(--error);
  background: #fdf0ef;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.login-error.is-visible { display: block; }

/* Section header util */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
}
.section-header h2 { color: var(--slate); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 640px) {
  .nav { display: none; }
  .mobile-header { display: flex; }
  .bottom-nav { display: block; }

  .page { padding: 16px 16px calc(var(--bnav-h) + 20px); }

  .saisie-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .field--full { grid-column: span 1; }

  .kpi-row { grid-template-columns: 1fr 1fr; }

  .filter-panel__grid { grid-template-columns: 1fr 1fr; }

  .stats-layout { grid-template-columns: 1fr; }
  .split-row { grid-template-columns: 1fr; }

  .data-table { overflow-x: auto; }
  .data-table table { min-width: 600px; }

  #toast-container {
    top: auto;
    bottom: calc(var(--bnav-h) + 12px);
    right: 12px; left: 12px;
  }

  .modal { padding: 22px 20px 30px; }
}

@media (min-width: 641px) {
  .mobile-header { display: none; }
}
