/* Composants : boutons, champs, sélecteur, onglets, étiquettes, listes, cartes, indicateurs, graphiques,
   feuilles, notifications. Un seul style par type de contrôle dans toute l'app. */

/* ---- Boutons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--control-h); padding: 0 var(--s-4); border: 0; border-radius: var(--r-btn);
  background: var(--fill); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: transform var(--dur-1) var(--ease), background var(--dur-2) var(--ease), opacity var(--dur-2);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--fill-2); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { min-height: 34px; padding: 0 var(--s-3); font-size: 14px; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: 0 var(--s-5); font-size: 16px; }
.btn-block { display: flex; width: 100%; }
.btn-round { width: var(--control-h); padding: 0; border-radius: 50%; }
.btn-round.btn-lg { width: 56px; }
.btn .icon { flex: none; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
@media (max-width: 599px) { .actions .btn:not(.btn-round) { flex: 1 1 auto; } }
.action-col { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); font-size: 13px; color: var(--text-2); }

/* ---- Champs ---- */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 var(--s-4); }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 13px; color: var(--text-3); }
.field-error { font-size: 13px; color: var(--red); }
.input {
  width: 100%; min-height: var(--control-h); padding: 0 var(--s-3); border: 1px solid var(--line); border-radius: var(--r-input);
  background: var(--card-2); color: var(--text); font-size: 16px; -webkit-appearance: none; appearance: none;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-3); }
.input[type="date"], .input[type="month"] { min-height: var(--control-h); line-height: 1.2; }
.input-error { border-color: var(--red); }
textarea.input { min-height: 88px; padding: var(--s-3); resize: vertical; }
.input-row { display: flex; align-items: center; gap: var(--s-2); }
.input-row .input { flex: 1; }
.input-suffix { color: var(--text-3); font-size: 15px; }
.stepper { display: inline-flex; align-items: center; gap: var(--s-2); }
.stepper .num { min-width: 2.2ch; text-align: center; font-size: 22px; font-weight: 700; }

/* ---- Sélecteur (popover) ---- */
.select { position: relative; display: inline-block; max-width: 100%; }
.select-block { display: block; }
.select-trigger {
  display: inline-flex; align-items: center; gap: var(--s-2); width: 100%; min-height: var(--control-h); padding: 0 var(--s-3) 0 var(--s-4);
  border: 1px solid var(--line); border-radius: var(--r-input); background: var(--card-2); color: var(--text); font-size: 15px; font-weight: 500;
  cursor: pointer; text-align: left; transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.select-trigger:hover { background: var(--fill-2); }
.select-trigger[aria-expanded="true"] { border-color: var(--accent); }
.select-trigger .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-trigger .placeholder { color: var(--text-3); }
.select-trigger .chev { color: var(--text-3); transition: transform var(--dur-2) var(--ease); }
.select-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }
.select-sm .select-trigger { min-height: 36px; font-size: 14px; padding: 0 var(--s-2) 0 var(--s-3); border-radius: 10px; }
.popover {
  position: fixed; z-index: 60; min-width: 180px; max-height: 320px; overflow: auto; overscroll-behavior: contain;
  padding: 6px; margin: 0; list-style: none; background: var(--card); border-radius: 14px; box-shadow: var(--shadow-pop);
  animation: popIn var(--dur-2) var(--ease-spring); transform-origin: top left;
}
.popover.from-bottom { transform-origin: bottom left; animation-name: popInUp; }
.popover li {
  display: flex; align-items: center; gap: var(--s-2); min-height: 40px; padding: 0 var(--s-3); border-radius: 9px;
  font-size: 15px; cursor: pointer; color: var(--text); transition: background var(--dur-1) var(--ease);
}
.popover li:hover, .popover li.active { background: var(--fill); }
.popover li[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.popover li .label { flex: 1; }
.popover li .hint { font-size: 13px; color: var(--text-3); }
.popover .group { padding: var(--s-2) var(--s-3) 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
@keyframes popIn { from { opacity: 0; transform: translateY(-6px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes popInUp { from { opacity: 0; transform: translateY(6px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ---- Onglets (segmented control) ---- */
.seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; border-radius: var(--r-pill); background: var(--fill); isolation: isolate; }
.seg-block { width: 100%; }
.seg-ind { position: absolute; top: 3px; bottom: 3px; left: 3px; border-radius: var(--r-pill); background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform var(--dur-3) var(--ease-spring); z-index: 0; }
.seg button { position: relative; z-index: 1; min-height: 34px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text-2); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: color var(--dur-2) var(--ease); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button[aria-selected="true"] { color: var(--text); }
.seg-sm button { min-height: 28px; font-size: 13px; padding: 0 var(--s-2); }

/* ---- Étiquettes ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; background: var(--slate-soft); color: var(--slate); }
.pill-upper { text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; }
.pill-blue { background: var(--blue-soft); color: var(--blue); } .pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--amber-soft); color: var(--amber); } .pill-red { background: var(--red-soft); color: var(--red); }
.pill-purple { background: var(--purple-soft); color: var(--purple); } .pill-orange { background: var(--orange-soft); color: var(--orange); }
.pill-teal { background: var(--teal-soft); color: var(--teal); } .pill-pink { background: var(--pink-soft); color: var(--pink); }
.pill-slate { background: var(--slate-soft); color: var(--slate); } .pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill .dot { background: currentColor; }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; }
.delta-up { background: var(--green-soft); color: var(--green); } .delta-down { background: var(--red-soft); color: var(--red); } .delta-flat { background: var(--slate-soft); color: var(--slate); }

/* ---- Cartes, sections, listes ---- */
.card { background: var(--card); border-radius: var(--r-card); padding: var(--s-4); margin: 0 0 var(--s-4); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin: 0 0 var(--s-3); }
.card-head .title-3 { margin: 0; }
.card-link { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; font-weight: 500; color: var(--text-2); }
.card-link:hover { color: var(--accent); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin: var(--s-5) 0 var(--s-2); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); }
@media (min-width: 700px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.list { list-style: none; margin: 0 0 var(--s-4); padding: 0; background: var(--card); border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow); }
.list.in-card { box-shadow: none; background: transparent; border-radius: 0; margin: 0; }
.row { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: var(--s-2) var(--s-4); color: var(--text); text-align: left; width: 100%; border: 0; background: transparent; font: inherit; cursor: default; transition: background var(--dur-1) var(--ease); }
.list li + li .row { border-top: 1px solid var(--line); }
.list.in-card .row { padding-left: 0; padding-right: 0; }
.row.is-clickable { cursor: pointer; } .row.is-clickable:hover { background: var(--fill); } .row.is-clickable:active { background: var(--fill-2); }
.row-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--slate-soft); color: var(--slate); font-size: 18px; }
.row-icon.blue { background: var(--blue-soft); color: var(--blue); } .row-icon.green { background: var(--green-soft); color: var(--green); } .row-icon.amber { background: var(--amber-soft); color: var(--amber); } .row-icon.red { background: var(--red-soft); color: var(--red); } .row-icon.purple { background: var(--purple-soft); color: var(--purple); } .row-icon.orange { background: var(--orange-soft); color: var(--orange); } .row-icon.teal { background: var(--teal-soft); color: var(--teal); } .row-icon.pink { background: var(--pink-soft); color: var(--pink); } .row-icon.accent { background: var(--accent-soft); color: var(--accent); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { display: block; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { display: block; font-size: 13px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.row-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.row-value.pos { color: var(--green); } .row-value.neg { color: var(--red); }
.row-chev { color: var(--text-3); flex: none; }

/* ---- Indicateurs ---- */
.money .dec { font-size: 0.6em; font-weight: 600; opacity: 0.8; }
.money .cur { font-size: 0.6em; font-weight: 600; margin-left: 0.15em; opacity: 0.8; }
.stat { background: var(--card); border-radius: var(--r-card); padding: var(--s-4); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat-sub { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hero { position: relative; overflow: hidden; background: var(--hero); color: #fff; border-radius: var(--r-card); padding: var(--s-6) var(--s-5); margin: 0 0 var(--s-4); text-align: center; box-shadow: var(--shadow); }
.hero .eyebrow { color: rgba(255,255,255,0.75); }
.hero .display { margin: var(--s-2) 0 var(--s-1); }
.hero .secondary { color: rgba(255,255,255,0.78); }
/* Dans le héros, les chiffres se distinguent par la couleur (demande de Dylan) : centimes et € en menthe, montant clé en ambre, variation en vert clair */
.hero .money .dec, .hero .money .cur { color: #A7F3D0; opacity: 1; }
.hero .secondary strong { color: #FDE68A; font-weight: 700; }
.hero .delta { background: rgba(255,255,255,0.16); }
.hero .delta-up { color: #A7F3D0; } .hero .delta-down { color: #FECACA; } .hero .delta-flat { color: #fff; }
.progress { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width var(--dur-3) var(--ease); }
.progress-row { display: flex; align-items: center; gap: var(--s-2); }
.progress-row .progress { flex: 1; }
.progress-row .caption { margin: 0; white-space: nowrap; }

/* ---- Graphiques ---- */
.chart { position: relative; }
.chart-area { position: relative; }
.chart.has-callout { padding-top: 4px; }
/* La bulle se place à GAUCHE du dernier point, centrée verticalement : jamais sur l'en-tête de la carte ni hors du cadre */
.chart-callout { transform: translate(calc(-100% - 12px), -50%); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-target { fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-dasharray: 4 5; vector-effect: non-scaling-stroke; opacity: 0.8; }
.chart-dot { fill: var(--card); stroke-width: 3; vector-effect: non-scaling-stroke; }
.chart-labels { display: flex; justify-content: space-between; margin-top: var(--s-2); font-size: 12px; color: var(--text-3); }
.chart-callout { position: absolute; padding: 3px 9px; border-radius: 8px; background: var(--green); color: #052E1C; font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.chart-callout::after { content: ""; position: absolute; right: -4px; top: 50%; width: 10px; height: 10px; background: inherit; transform: translateY(-50%) rotate(45deg); border-radius: 2px; }
.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: var(--ring-w, 8); }
.ring .track { stroke: var(--fill-2); }
.ring .arc { stroke: var(--ring-color, var(--accent)); stroke-linecap: round; transition: stroke-dasharray var(--dur-3) var(--ease); }
.ring-content { position: relative; text-align: center; line-height: 1.1; }
.ring-value { font-size: 15px; font-weight: 700; }
.ring-label { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ---- Feuille (sheet) ---- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 80; background: var(--overlay); animation: fadeIn var(--dur-2) var(--ease); }
.sheet { position: fixed; z-index: 81; left: 0; right: 0; bottom: 0; max-height: calc(100dvh - 40px); display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-pop);
  padding-bottom: env(safe-area-inset-bottom); animation: slideUp var(--dur-3) var(--ease); }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--fill-2); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4) var(--s-2); }
.sheet-head .title-2 { font-size: 20px; }
.sheet-body { padding: var(--s-2) var(--s-4) var(--s-4); overflow: auto; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: var(--s-2); padding: var(--s-3) var(--s-4) var(--s-4); border-top: 1px solid var(--line); }
.sheet-foot .btn { flex: 1; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(560px, calc(100vw - 48px)); max-height: calc(100dvh - 80px);
    transform: translate(-50%, -50%); border-radius: var(--r-sheet); animation: popCenter var(--dur-3) var(--ease-spring); padding-bottom: 0; }
  .sheet-handle { display: none; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes popCenter { from { transform: translate(-50%, -48%) scale(0.96); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
body.sheet-open { overflow: hidden; }

/* ---- Notifications (toast) ---- */
.toaster { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--s-4) + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: var(--s-2); width: min(92vw, 420px); pointer-events: none; }
@media (min-width: 900px) { .toaster { bottom: var(--s-6); } }
.toast { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: 14px; background: var(--card-2); color: var(--text); box-shadow: var(--shadow-pop); font-size: 15px; pointer-events: auto; animation: toastIn var(--dur-3) var(--ease-spring); }
.toast .icon { flex: none; color: var(--accent); }
.toast-error .icon { color: var(--red); }
.toast-text { flex: 1; }
.toast .btn { min-height: 32px; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Bandeaux, messages, état vide ---- */
.banner { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-btn); margin: 0 0 var(--s-4); font-size: 15px; }
.banner-error { background: var(--red); color: #fff; }
.banner-info { background: var(--accent-soft); color: var(--accent); }
.notice { margin: var(--s-3) 0 0; padding: var(--s-2) var(--s-3); border-radius: 10px; font-size: 15px; }
.notice-ok { background: var(--accent-soft); color: var(--accent); }
.notice-err { background: var(--red-soft); color: var(--red); }
.empty { text-align: center; padding: var(--s-10) var(--s-4); background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); }
.empty-icon { width: 56px; height: 56px; margin: 0 auto var(--s-4); border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty .secondary { max-width: 440px; margin: var(--s-2) auto 0; }
.empty .actions, .empty .btn { justify-content: center; margin-top: var(--s-5); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); margin: var(--s-3) 0; }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stats div { padding: var(--s-3); border-radius: var(--r-btn); background: var(--card-2); }
.stats dt { font-size: 13px; color: var(--text-2); }
.stats dd { margin: 2px 0 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s-2); }
.swatch { border-radius: 12px; padding: var(--s-3); font-size: 12px; font-weight: 600; min-height: 64px; display: flex; align-items: flex-end; }
.demo-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin: var(--s-2) 0; }
