/* ---------- Polices (embarquées, pour fonctionner hors ligne) ---------- */

@font-face {
  font-family: 'Fraunces';
  src: url('../fonts/fraunces.woff2') format('woff2');
  font-weight: 600 700;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/dm-sans.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'DM Mono';
  src: url('../fonts/dm-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'DM Mono';
  src: url('../fonts/dm-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

/* ---------- Palette (celle de Mes courses, avec le bleu roi du budget) ---------- */

:root {
  --bg: #F4F1EA;
  --surface: #FFFFFF;
  --ink: #1F2A24;
  --ink-soft: #4A564E;
  --muted: #5E6B62;
  --faint: #9AA59D;
  --border: #D9D3C5;
  --divider: #ECE8DE;

  --budget: #2B50C8;
  --budget-dark: #1E3A94;
  --budget-bg: #E6ECFA;
  --accent: var(--budget);

  /* Revenus et soldes positifs, comme le vert de Mes courses */
  --positive: #2F6B4F;
  --positive-dark: #1F4D38;

  /* Budget prévu : faisable avec des efforts, ou bientôt atteint */
  --warning: #B45F06;
  --warning-bg: #FBEBD9;

  --danger: #B3261E;
  --danger-bg: #FBE9E7;
  --danger-ink: #5C1A14;
  --success-bg: #E2EFE6;
  --promo-bg: #F6E6D9;
  --promo-ink: #8A3F1C;

  --serif: 'Fraunces', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;

  /* Marges de sécurité (encoche, barre d'accueil) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color-scheme: light;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

/* Sur iPhone, un champ en dessous de 16 px fait zoomer la page au focus. */
input, select, textarea { font-size: 16px; }

:focus-visible {
  outline: 2.5px solid var(--ink);
  outline-offset: 2px;
  border-radius: 10px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.noscript { padding: 24px; font-family: var(--sans); }

/* ---------- Écrans ---------- */

.screen {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    calc(var(--safe-top) + 8px)
    calc(var(--safe-right) + 20px)
    calc(var(--safe-bottom) + 24px)
    calc(var(--safe-left) + 20px);
  animation: push-in 260ms cubic-bezier(.2, .8, .2, 1);
}

.screen--home {
  padding:
    calc(var(--safe-top) + 24px)
    calc(var(--safe-right) + 28px)
    calc(var(--safe-bottom) + 32px)
    calc(var(--safe-left) + 28px);
  animation-name: fade-in;
}

@keyframes push-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
}

/* ---------- Textes ---------- */

.eyebrow {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.display, .title, .title-small {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-optical-sizing: auto;
  line-height: 1.1;
}
.display { font-size: 40px; }
.title { font-size: 34px; }
.title-small { font-size: 28px; line-height: 1.15; }

.lead { margin: 0; font-size: 16px; line-height: 1.5; color: var(--ink-soft); }

.section-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- En-tête des sections ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  min-height: 44px;
  padding: 0 8px 0 0;
  border: none;
  background: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  touch-action: manipulation;
}
.back-link:active { color: var(--budget-dark); }

.section-body {
  flex-grow: 1;
  min-height: 0;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Cartes ---------- */

.card {
  padding: 16px;
  background: var(--surface);
  border-radius: 18px;
}

.empty-line { margin: 24px 0; text-align: center; color: var(--muted); }

/* ---------- Barres du haut (fiche, formulaire) ---------- */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
}

.text-button {
  min-height: 44px;
  padding: 0 4px;
  border: none;
  background: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  touch-action: manipulation;
}
.text-button--muted { color: var(--ink-soft); }

/* ---------- Champs ---------- */

.field {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
.field::placeholder { color: var(--muted); opacity: 1; }
.field:focus { outline: none; border-color: var(--ink); }
.field[aria-invalid='true'] { border-color: var(--danger); }

select.field {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231F2A24' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
}
.field-label { padding: 0; font-size: 14px; font-weight: 600; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-error { margin: 0; font-size: 14px; line-height: 1.4; color: var(--danger); }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
}
.segmented__option { position: relative; display: flex; }
.segmented__option input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__option span {
  flex-grow: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.segmented__option input:checked + span { background: var(--ink); color: #FFFFFF; }
.segmented__option input:focus-visible + span { outline: 2.5px solid var(--ink); outline-offset: 2px; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form__note { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

/* ---------- Liste : recherche, filtres, lignes ---------- */

.icon-button {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  touch-action: manipulation;
}
.icon-button:active { transform: scale(0.96); }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -20px;
  padding: 4px 20px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  position: relative;
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  touch-action: manipulation;
}
/* Zone tactile de 44 px autour d'une pastille de 36 px */
.chip::after { content: ''; position: absolute; inset: -4px 0; }
.chip[aria-pressed='true'] { border-color: var(--ink); background: var(--ink); color: #FFFFFF; }

.rows { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px 10px 10px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  touch-action: manipulation;
}
.row:active { background: #FBFAF7; }

.row__main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row__title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.row__meta { font-size: 13px; color: var(--muted); }
.row__end { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row__end .row__meta { font-size: 12px; }
.row__price { font-size: 15px; font-weight: 600; }

/* ---------- Fiche ---------- */

.detail-head { display: flex; flex-direction: column; gap: 6px; }
.detail-head__tags { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.badge { padding: 4px 10px; border-radius: 12px; font-size: 13px; font-weight: 600; }

.card { display: flex; flex-direction: column; gap: 10px; }
.card .section-label { margin: 0; }
.card__text { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }


.button {
  flex-grow: 1;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  touch-action: manipulation;
}
.button--outline { border: 1.5px solid var(--border); background: var(--surface); color: var(--ink); }
.button--danger { border: none; background: var(--danger); color: #FFFFFF; }

.confirm {
  padding: 14px;
  border-radius: 14px;
  background: var(--danger-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.confirm p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--danger-ink); }
.confirm__buttons { display: flex; gap: 8px; }
.confirm .button { min-height: 44px; border-radius: 12px; }

/* ---------- Messages ---------- */

.notice {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--success-bg);
  color: var(--positive-dark);
  font-size: 14px;
  line-height: 1.45;
}
.notice.is-busy { background: var(--surface); color: var(--ink-soft); }

.field-row { display: flex; gap: 8px; }
.text-button--start { align-self: flex-start; padding: 0; }

/* ---------- Signalements ---------- */

.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--promo-bg);
  color: var(--promo-ink);
  font-size: 12px;
  font-weight: 600;
}

.review {
  padding: 14px;
  border-radius: 16px;
  background: var(--promo-bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.review__title { margin: 0; font-size: 15px; font-weight: 700; color: var(--promo-ink); }
.review__text { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink); }
.review .button { min-height: 44px; border-radius: 12px; }

.button--accent { border: none; background: var(--accent); color: #FFFFFF; }
.button:disabled { opacity: 0.6; }

/* ---------- Fenêtres (du bas de l'écran) ---------- */

.sheet { position: fixed; inset: 0; z-index: 20; }

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 42, 36, 0.4);
  animation: fade-in 180ms ease;
}

.sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  max-height: calc(100dvh - var(--safe-top) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px calc(var(--safe-right) + 20px) calc(var(--safe-bottom) + 20px) calc(var(--safe-left) + 20px);
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slide-up 240ms cubic-bezier(.2, .8, .2, 1);
}
.sheet__panel--tall { height: calc(100dvh - var(--safe-top) - 24px); }

@keyframes slide-up {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet__panel, .sheet__backdrop { animation: none; }
}

.sheet__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet__title { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.sheet__buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

/* ---------- Intertitres de liste ---------- */

.items__heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.items__heading:first-child { padding-top: 0; }
.items__dot { width: 10px; height: 10px; border-radius: 50%; }
.items__count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--faint);
}

/* ---------- Saisie d'un montant ---------- */

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

.field-with-unit { position: relative; display: flex; }
.field-with-unit .field { padding-right: 72px; font-size: 18px; font-weight: 600; }
.field-with-unit__unit {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  color: var(--muted);
  pointer-events: none;
}

.text-button--danger { align-self: flex-start; padding: 0; color: var(--danger); }

/* ---------- Couleurs et boutons ---------- */



.icon-button--small { width: 40px; height: 40px; border-radius: 12px; }
.icon-button:disabled { opacity: 0.35; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2.5px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.swatch input:checked + span { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }
.swatch input:focus-visible + span { outline: 2.5px solid var(--ink); outline-offset: 2px; }

.button--dashed {
  min-height: 52px;
  border: 1.5px dashed var(--faint);
  background: var(--surface);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

/* ---------- Réglages et sauvegarde ---------- */
.icon-button--round { width: 44px; height: 44px; border-radius: 22px; }

/* ---------- Compte et synchronisation ---------- */

.account-links { display: flex; flex-direction: column; align-items: flex-start; }
.account-status { margin: 0; font-size: 14px; font-weight: 600; color: var(--positive-dark); }

/* ---------- Démarrage impossible (voir index.html) ---------- */

.boot-error { display: flex; flex-direction: column; gap: 14px; padding-top: 48px; }
.boot-error__details {
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Tirer pour actualiser ---------- */

.pull-refresh {
  position: fixed;
  top: calc(var(--safe-top) + 4px);
  left: 50%;
  z-index: 40;
  transform: translate(-50%, -90px);
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--ink);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  transition: transform 180ms ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}
.pull-refresh[data-state='pull'], .pull-refresh[data-state='ready'] { transition: none; }
.pull-refresh__spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
}
.pull-refresh[data-state='busy'] .pull-refresh__spinner { animation: spin 0.8s linear infinite; }
.pull-refresh[data-state='done'] .pull-refresh__spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
/* ---------- Bilan ---------- */

.screen--bilan { padding-bottom: calc(var(--safe-bottom) + 96px); gap: 16px; }

.bilan-head { display: flex; flex-direction: column; gap: 4px; }
.bilan-head__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; }
.bilan-head__actions { display: flex; align-items: center; gap: 8px; }
.bilan-head__actions .icon-button { position: relative; color: var(--ink); text-decoration: none; }

.dot-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--danger);
}

.period-nav { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin: 0 -10px; }
.period-nav__step {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: none;
  border-radius: 22px;
  background: none;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.period-nav__step:active { background: var(--divider); }
.period-nav__current {
  min-width: 0;
  min-height: 52px;
  padding: 0 8px;
  border: none;
  border-radius: 14px;
  background: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  touch-action: manipulation;
}
.period-nav__current .title { font-size: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.period-nav__current svg { flex-shrink: 0; color: var(--accent); }
.period-note { margin: 0; text-align: center; font-size: 14px; color: var(--muted); }
.period-today { align-self: center; min-height: 36px; font-size: 14px; color: var(--accent); }

.course-banner {
  min-height: 52px;
  padding: 10px 12px 10px 14px;
  border-radius: 16px;
  background: var(--budget-bg);
  color: var(--budget-dark);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}
.course-banner span { flex-grow: 1; }

.tip-link {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px dashed var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
  text-decoration: none;
}
.tip-link strong { color: var(--accent); }

.summary-card { gap: 12px; }
.summary-card__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.summary-card__balance {
  padding-top: 12px;
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
}
.summary-card__balance strong { font-family: var(--serif); font-size: 28px; }
.summary-card__note { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__label { font-size: 13px; color: var(--muted); }
.stat__value { font-size: 18px; font-weight: 600; }

.is-positive { color: var(--positive); }
.is-negative { color: var(--danger); }

.category-group { display: flex; flex-direction: column; gap: 8px; }
.category-group .rows { margin: 0; padding: 0; list-style: none; }
.category-line { min-height: 60px; padding-left: 14px; }
.category-line.is-empty .row__title { color: var(--ink-soft); font-weight: 500; }
.category-line.is-empty .row__price { color: var(--faint); }

.dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 50%; background: var(--dot, var(--accent)); }
.dot--big { width: 14px; height: 14px; }

/* Tendance par rapport à la période précédente */
.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 7px;
  border-radius: 8px;
  background: var(--divider);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.trend-badge.is-bad { background: var(--danger-bg); color: var(--danger); }
.trend-badge.is-good { background: var(--success-bg); color: var(--positive); }
.trend-badge.is-new { background: var(--budget-bg); color: var(--budget-dark); }

.fab {
  position: fixed;
  right: max(calc(var(--safe-right) + 20px), calc(50vw - 220px));
  bottom: calc(var(--safe-bottom) + 20px);
  z-index: 5;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 30px;
  background: var(--accent);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(43, 80, 200, 0.35);
  touch-action: manipulation;
}
.fab:active { transform: scale(0.95); }

/* ---------- Budget prévu ---------- */

.gauge { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.gauge__track { position: relative; height: 8px; border-radius: 4px; background: var(--divider); overflow: hidden; }
.gauge--compact .gauge__track { height: 6px; }
.gauge__fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--accent); }
.gauge__fill.is-high { background: var(--warning); }
.gauge__fill.is-over { background: var(--danger); }
.gauge__text { font-size: 13px; color: var(--muted); }
.gauge--compact .gauge__text { font-size: 12px; }

/* Couleur du montant prévu selon son réalisme (habitude des 12 derniers mois) */
.realism { font-weight: 700; }
.realism--ok { color: var(--positive); }
.realism--effort { color: var(--warning); }
.realism--hard { color: var(--danger); }
.realism--none { color: var(--ink); }
.realism-tag { margin-left: 4px; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.realism-tag--ok { background: var(--success-bg); color: var(--positive); }
.realism-tag--effort { background: var(--warning-bg); color: var(--warning); }
.realism-tag--hard { background: var(--danger-bg); color: var(--danger); }
.realism-note { margin: 0; display: flex; align-items: baseline; gap: 6px; font-size: 14px; line-height: 1.45; font-weight: 600; }
.realism-note .dot { align-self: center; }
.realism-note--ok { color: var(--positive); --dot: var(--positive); }
.realism-note--effort { color: var(--warning); --dot: var(--warning); }
.realism-note--hard { color: var(--danger); --dot: var(--danger); }

.budget-card { gap: 8px; }
.link-people { padding-left: 4px; gap: 0; }
.text-button--start svg { vertical-align: -3px; }
.budget-card__head { display: flex; justify-content: space-between; align-items: center; margin: -10px 0 -8px; }
.budget-card__amount { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 15px; color: var(--ink-soft); }
.budget-card__amount strong { font-family: var(--serif); font-size: 24px; }

.budget-alert {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: 12px;
  right: 12px;
  z-index: 15;
  max-width: 456px;
  margin: 0 auto;
  padding: 6px 6px 6px 14px;
  border-radius: 16px;
  background: var(--ink);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: slide-down 240ms cubic-bezier(.2, .8, .2, 1);
}
.budget-alert.is-high { background: var(--warning); }
.budget-alert.is-over { background: var(--danger); }
.budget-alert__text {
  flex-grow: 1;
  min-height: 44px;
  padding: 4px 0;
  border: none;
  background: none;
  color: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
}
.budget-alert__more { font-weight: 400; opacity: 0.85; }
.budget-alert__ok {
  flex-shrink: 0;
  min-width: 52px;
  min-height: 44px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
}
@keyframes slide-down {
  from { transform: translateY(-24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- Choix de la période ---------- */

.year-nav { display: flex; align-items: center; justify-content: center; gap: 24px; font-size: 20px; }
.month-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.month-grid__item {
  min-height: 48px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  touch-action: manipulation;
}
.month-grid__item.is-now { border-color: var(--accent); color: var(--accent); }
.month-grid__item[aria-pressed='true'] { border-color: var(--accent); background: var(--accent); color: #FFFFFF; }

/* ---------- Formulaires du budget ---------- */

.chips--wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 4px 0; }
.chip--category { display: inline-flex; align-items: center; gap: 7px; }
.chip--category .dot { background: var(--dot); }
.chip--category[aria-pressed='true'] .dot { box-shadow: 0 0 0 2px #FFFFFF; }

.repeat-line { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.repeat-line label { display: inline-flex; align-items: center; gap: 6px; }
.repeat-line__select {
  min-height: 40px;
  padding: 0 28px 0 10px;
  border: none;
  border-radius: 10px;
  background: var(--divider) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234A564E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
  color: var(--ink);
  font-size: 16px;
  appearance: none;
  -webkit-appearance: none;
}

.check-line { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.check-line input { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--accent); }
.check-line__hint { font-size: 13px; color: var(--muted); }

.notice--info { background: var(--budget-bg); color: var(--budget-dark); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.notice--warn { background: var(--promo-bg); color: var(--promo-ink); }

.price-editor__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  font-size: 15px;
}
.price-editor__total strong { font-size: 20px; }
.price-editor__label { color: var(--muted); font-size: 13px; }

/* ---------- Détail d'une catégorie ---------- */

.category-title { display: flex; align-items: center; gap: 10px; overflow-wrap: anywhere; }
.detail-total { margin: 4px 0 0; font-family: var(--serif); font-size: 32px; font-weight: 700; line-height: 1.1; }
.entry-group { display: flex; flex-direction: column; gap: 8px; }
.entry-group .rows { margin: 0; padding: 0; list-style: none; }
.section-body > .button { flex-grow: 0; }
.row--button { width: 100%; border: none; text-align: left; font: inherit; }
.entry-row { padding-left: 14px; }
.entry-row__date { width: 48px; flex-shrink: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.entry-row .row__price { display: inline-flex; align-items: center; gap: 4px; }
.entry-row .row__price svg { color: var(--muted); }
.entry-row.is-highlighted { box-shadow: 0 0 0 2.5px var(--accent); animation: highlight 1.6s ease 2; }
@keyframes highlight {
  50% { background: var(--budget-bg); }
}

/* ---------- Courses ---------- */

.course-section { display: flex; flex-direction: column; gap: 8px; }
.course-section .rows { margin: 0; padding: 0; list-style: none; }
.course-section .row { padding-left: 12px; }
.course-section .row > svg { flex-shrink: 0; color: var(--faint); }
.course-section .status-tag { align-self: flex-start; margin-top: 2px; }
.status-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 17px;
  background: var(--budget-bg);
  color: var(--budget-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.status-icon--done { background: var(--success-bg); color: var(--positive); }
.status-icon--warn { background: var(--promo-bg); color: var(--promo-ink); }

.ignored { display: flex; flex-direction: column; gap: 4px; }
.ignored .text-button { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }
.ignored__list { margin: 0; padding: 0; list-style: none; }
.ignored__row {
  width: 100%;
  min-height: 44px;
  padding: 0 4px;
  border: none;
  border-bottom: 1px solid var(--divider);
  background: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--ink-soft);
  text-align: left;
}

/* ---------- Réglages ---------- */

.choice { padding: 14px; border-radius: 14px; background: var(--budget-bg); display: flex; flex-direction: column; gap: 10px; }
.choice__title { margin: 0; font-weight: 600; line-height: 1.45; color: var(--budget-dark); }

.setting-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.setting-row {
  width: 100%;
  min-height: 52px;
  padding: 6px 2px;
  border: none;
  border-bottom: 1px solid var(--divider);
  background: none;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  color: var(--ink);
}
.setting-row > svg { flex-shrink: 0; color: var(--faint); }
.setting-row__main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.setting-row__name { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.setting-row__meta { font-size: 13px; color: var(--muted); }
.app-footer { margin: auto 0 0; padding-top: 32px; text-align: center; font-size: 13px; line-height: 1.5; color: var(--muted); }
.app-footer p { margin: 0; }

/* ---------- Grand écran (Mac, iPad à l'horizontale) ---------- */

@media (hover: hover) {
  .row:hover, .setting-row:hover, .ignored__row:hover { background: #FBFAF7; }
  .button:hover, .chip:hover, .icon-button:hover, .month-grid__item:hover { filter: brightness(0.97); }
  .text-button:hover, .back-link:hover { text-decoration: underline; text-underline-offset: 3px; }
  button, a, label.segmented__option { cursor: pointer; }
}

@media (min-width: 760px) {
  .screen {
    max-width: 760px;
    padding-top: calc(var(--safe-top) + 28px);
    padding-left: calc(var(--safe-left) + 32px);
    padding-right: calc(var(--safe-right) + 32px);
  }
  .title { font-size: 40px; }
  .period-nav__current .title { font-size: 36px; }
  .fab { right: max(32px, calc(50vw - 360px)); }

  /* Fenêtres : au centre de l'écran plutôt qu'en bas. */
  .sheet { display: flex; align-items: center; justify-content: center; }
  .sheet__panel {
    position: relative;
    bottom: auto !important;
    width: min(540px, calc(100vw - 48px));
    max-height: 86vh;
    border-radius: 22px;
    padding-bottom: 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  }
  .sheet__panel--tall { height: auto; min-height: 60vh; }

  /* Catégories du bilan : sur deux colonnes. */
  .category-group .rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
