/* ==========================================================================
   Compte commun — feuille de style unique.
   Thème clair et sombre, mise en page fluide du téléphone au grand écran.
   ========================================================================== */

:root {
  --indigo: #4f46e5;
  --indigo-soft: #eef2ff;
  --sevda: #ec4899;
  --lionel: #0ea5e9;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-soft: #64748b;
  --text-faint: #94a3b8;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 12px 40px -12px rgba(15, 23, 42, .25);
  --topbar-h: 60px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1a2233;
  --border: #1f2937;
  --text: #f1f5f9;
  --text-soft: #94a3b8;
  --text-faint: #64748b;
  --indigo-soft: #1e1b4b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 12px 40px -12px rgba(0, 0, 0, .8);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1a2233;
    --border: #1f2937;
    --text: #f1f5f9;
    --text-soft: #94a3b8;
    --text-faint: #64748b;
    --indigo-soft: #1e1b4b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 12px 40px -12px rgba(0, 0, 0, .8);
  }
}

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
a { color: var(--indigo); }

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

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  min-height: 44px;                       /* confortable au doigt */
  transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4338ca; }
.btn-ghost { background: transparent; color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--red); border-color: transparent; }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--red) 12%, transparent); }
/* Pleine largeur : le libelle peut etre long, il passe a la ligne plutot
   que de deborder du bouton sur un ecran etroit. */
.btn-block { display: flex; width: 100%; white-space: normal; text-wrap: balance; }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 40px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: none; border-radius: 50%;
  background: transparent; color: var(--text-soft); font-size: 17px; cursor: pointer;
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- Champs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > span, .field > legend {
  font-size: 12.5px; font-weight: 600; color: var(--text-soft);
  letter-spacing: .01em; padding: 0;
}
.field > span em { font-weight: 400; font-style: normal; color: var(--text-faint); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], input[type="search"], select {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; transition: border-color .15s ease, box-shadow .15s ease;
  min-height: 44px;                       /* confortable au doigt */
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: none; border-color: var(--indigo);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--indigo) 22%, transparent);
}
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-check { flex-direction: row; align-items: center; gap: 10px; }
.field-check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--indigo); }
.hint { font-size: 12.5px; color: var(--text-faint); margin: 2px 0 0; }
.hint-center { text-align: center; }

.amount-wrap { position: relative; }
.amount-wrap input { font-size: 22px; font-weight: 700; padding-right: 36px; letter-spacing: -.02em; }
.currency {
  position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-weight: 600; pointer-events: none;
}

/* ---------- Alertes ---------- */
.alert {
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px;
  margin-bottom: 18px; border: 1px solid transparent; line-height: 1.5;
}
.alert-ok    { background: color-mix(in srgb, var(--green) 12%, transparent); color: #047857; border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.alert-error { background: color-mix(in srgb, var(--red) 12%, transparent); color: #b91c1c; border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.alert-info  { background: var(--indigo-soft); color: var(--indigo); }
:root[data-theme="dark"] .alert-ok { color: #6ee7b7; }
:root[data-theme="dark"] .alert-error { color: #fca5a5; }

/* ==========================================================================
   Page de connexion
   ========================================================================== */
.auth-body {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1000px 500px at 15% -10%, color-mix(in srgb, var(--indigo) 18%, transparent), transparent 60%),
    radial-gradient(800px 450px at 100% 110%, color-mix(in srgb, var(--sevda) 14%, transparent), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 22px;
  padding: 34px 30px; box-shadow: var(--shadow-lg);
}
/* La page publique ne porte qu'un cadenas : ni titre, ni prénom, ni indice sur
   ce que contient l'application. Le titre du formulaire fait office de h1. */
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-logo { font-size: 38px; line-height: 1; opacity: .85; }
.auth-title { font-size: 17px; margin-bottom: 4px; }
.auth-intro { margin: 0 0 4px; color: var(--text-soft); font-size: 13.5px; line-height: 1.55; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form .btn { margin-top: 4px; }
.auth-links { text-align: center; margin: 2px 0 0; font-size: 13.5px; }
.auth-links a { text-decoration: none; font-weight: 600; }
.auth-links a:hover { text-decoration: underline; }
.auth-sep {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-faint); font-size: 12px; margin: 2px 0;
}
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ==========================================================================
   Barre supérieure
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; height: var(--topbar-h);
  padding: 0 16px; display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); }
.brand-mark { font-size: 21px; }
.brand-text { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }

.tabs { display: flex; gap: 2px; margin-left: auto; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.tab {
  border: none; background: transparent; color: var(--text-soft);
  padding: 8px 15px; border-radius: 9px; font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; transition: background .15s ease, color .15s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--indigo); box-shadow: var(--shadow); }
.tab-long, .tab-short { display: block; overflow: hidden; text-overflow: ellipsis; }
.tab-short { display: none; }

.topbar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.tabs + .topbar-right { margin-left: 0; }
.logout-form { margin: 0; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: border-color .15s ease;
}
.user-chip:hover { border-color: var(--indigo); }
.avatar {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--indigo); color: #fff; font-size: 12px; font-weight: 700;
}

/* ==========================================================================
   Corps de page
   ========================================================================== */
.app {
  max-width: 1080px; margin: 0 auto;
  padding: 22px 16px calc(112px + env(safe-area-inset-bottom));
}
.view { display: none; animation: fade .22s ease; }
.view.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px; overflow: hidden;
}
.card-title {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 14.5px; padding: 16px 18px 0;
}
.card-title .btn { margin-left: auto; }
.card-period { font-weight: 500; font-size: 12.5px; color: var(--text-faint); }
.card-note { margin: 8px 18px 0; font-size: 13px; color: var(--text-soft); line-height: 1.6; }
.card-body { padding: 14px 18px 18px; }

/* ---------- Solde ---------- */
.balance-card {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--indigo) 0%, #7c3aed 55%, #a855f7 100%);
  color: #fff; border-radius: 22px; padding: 30px 26px;
  margin-bottom: 16px; box-shadow: 0 18px 44px -20px color-mix(in srgb, var(--indigo) 85%, transparent);
}
.balance-card::after {
  content: ""; position: absolute; inset: auto -60px -110px auto;
  width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255, 255, 255, .1);
}
.balance-label {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .09em;
  opacity: .82; font-weight: 700; margin: 0 0 8px;
}
.balance-amount {
  font-size: clamp(38px, 9vw, 54px); font-weight: 800; letter-spacing: -.035em;
  line-height: 1.05; margin: 0; font-variant-numeric: tabular-nums;
}
.balance-who { margin: 10px 0 0; font-size: 15px; opacity: .95; position: relative; }
.balance-who strong { font-weight: 700; }
.balance-settled { font-size: 17px; font-weight: 600; margin: 6px 0 0; }
.balance-meta {
  position: relative; margin: 16px 0 0; padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .2);
  display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; opacity: .9;
}

.btn-settle {
  position: relative; margin-top: 18px;
  background: rgba(255, 255, 255, .16); color: #fff;
  border: 1px solid rgba(255, 255, 255, .3);
  padding: 9px 18px; font-size: 13.5px;
}
.btn-settle:hover { background: rgba(255, 255, 255, .26); }

.settle-summary {
  margin: 0; padding: 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 15px; line-height: 1.5;
}
.settle-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.settle-row + .settle-row { border-top: 1px solid var(--border); }

/* ---------- Totaux par personne ---------- */
.person-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.person-row + .person-row { border-top: 1px solid var(--border); }
.person-avatar {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.person-avatar.is-sevda { background: var(--sevda); }
.person-avatar.is-lionel { background: var(--lionel); }
.person-info { flex: 1; min-width: 0; }
.person-name { font-weight: 600; font-size: 14px; }
.person-sub { font-size: 12.5px; color: var(--text-faint); }
.person-amount { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.person-bar { height: 5px; border-radius: 3px; background: var(--border); margin-top: 6px; overflow: hidden; }
.person-bar > i { display: block; height: 100%; border-radius: 3px; }

.person-transfer {
  display: block; font-size: 11.5px; font-weight: 500; color: var(--text-faint);
}

/* ---------- Catégories ---------- */
.cat-row { display: flex; align-items: center; gap: 11px; padding: 8px 0; }
.cat-icon { font-size: 17px; width: 24px; text-align: center; flex-shrink: 0; }
.cat-info { flex: 1; min-width: 0; }
.cat-name { font-size: 13.5px; font-weight: 600; display: flex; justify-content: space-between; gap: 10px; }
.cat-name b { font-variant-numeric: tabular-nums; font-weight: 700; }
.cat-bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 5px; overflow: hidden; }
.cat-bar > i { display: block; height: 100%; border-radius: 3px; transition: width .5s ease; }
.cat-count { font-size: 11.5px; color: var(--text-faint); }

/* ---------- Graphique mensuel ---------- */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 190px; overflow-x: auto; padding-bottom: 4px; }
.chart-col {
  flex: 1 0 34px; display: flex; flex-direction: column; align-items: center;
  gap: 6px; height: 100%; justify-content: flex-end;
}
.chart-stack {
  width: 100%; max-width: 30px; display: flex; flex-direction: column-reverse;
  border-radius: 6px 6px 0 0; overflow: hidden; background: var(--surface-2);
  transition: opacity .15s ease;
}
.chart-col:hover .chart-stack { opacity: .82; }
.chart-seg { transition: height .5s ease; min-height: 0; }
.chart-seg.is-sevda { background: var(--sevda); }
.chart-seg.is-lionel { background: var(--lionel); }
.chart-label { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; }
.chart-value { font-size: 10.5px; font-weight: 700; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text-soft); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-sevda { background: var(--sevda); }
.dot-lionel { background: var(--lionel); }

/* ---------- Repères chiffrés ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-tile {
  padding: 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.stat-label {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint);
}
.stat-value {
  font-size: clamp(19px, 3.6vw, 25px); font-weight: 800; letter-spacing: -.02em;
  margin-top: 4px; font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: 12px; color: var(--text-faint); }
.stats-toggle { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.stats-toggle span { font-size: 13px; color: var(--text-soft); font-weight: 500; }
.cat-name em.tag { font-style: normal; margin-left: 6px; }

/* ---------- Liste de dépenses ---------- */
.expense-list { list-style: none; margin: 0; padding: 0; }
.expense-list-full { padding: 0 6px; }
.expense-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background .13s ease;
}
.expense-item:hover { background: var(--surface-2); }
.expense-item + .expense-item { border-top: 1px solid var(--border); border-radius: var(--radius-sm); }
.exp-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  font-size: 18px; flex-shrink: 0;
}
.exp-main { flex: 1; min-width: 0; }
.exp-label {
  font-weight: 600; font-size: 14px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.exp-meta {
  font-size: 12px; color: var(--text-faint);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.exp-payer { font-weight: 600; }
.exp-payer.is-sevda { color: var(--sevda); }
.exp-payer.is-lionel { color: var(--lionel); }
.exp-arrow { color: var(--text-faint); margin: 0 -2px; }
.exp-right { text-align: right; flex-shrink: 0; }
.exp-amount { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.exp-impact { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; background: var(--surface-2); color: var(--text-soft);
}
.tag-auto { background: var(--indigo-soft); color: var(--indigo); }
/* Budget : enveloppe nommee a la main, distincte de la categorie. */
.tag-budget {
  background: color-mix(in srgb, var(--indigo) 14%, transparent);
  color: var(--indigo); font-weight: 700;
}
.tag-budget::before { content: "🏷️ "; }
.tag-est { background: color-mix(in srgb, var(--amber) 16%, transparent); color: #b45309; }
:root[data-theme="dark"] .tag-est { color: #fcd34d; }

.day-sep {
  padding: 14px 12px 5px; font-size: 12px; font-weight: 700;
  color: var(--text-faint); text-transform: capitalize;
  display: flex; justify-content: space-between; gap: 12px;
}
.day-sep b { color: var(--text-soft); font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-faint); }
.empty-icon { font-size: 34px; display: block; margin-bottom: 8px; }

/* ---------- Filtres ---------- */
.filters {
  display: flex; gap: 9px; flex-wrap: wrap; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.field-inline { flex: 0 0 auto; }
.field-grow { flex: 1 1 190px; }
.field-inline input, .field-inline select { min-height: 40px; padding: 8px 12px; font-size: 13.5px; }
.field-inline select { padding-right: 32px; }
.filters-summary {
  padding: 10px 18px; font-size: 13px; color: var(--text-soft);
  border-bottom: 1px solid var(--border); display: none;
}
.filters-summary.is-visible { display: block; }
.filters-summary b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Récurrences ---------- */
.rec-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 0; cursor: pointer;
  border-radius: var(--radius-sm);
}
.rec-row + .rec-row { border-top: 1px solid var(--border); }
.rec-row:hover { background: var(--surface-2); }
.rec-row.is-off { opacity: .5; }
.rec-info { flex: 1; min-width: 0; }
.rec-label { font-weight: 600; font-size: 14px; }
.rec-meta { font-size: 12.5px; color: var(--text-faint); }
.rec-amount { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Barre de saisie ---------- */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  pointer-events: none;
}
.composer-inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; gap: 11px; justify-content: center; align-items: center;
  pointer-events: auto;
}
.composer-add { box-shadow: var(--shadow-lg); padding: 14px 26px; border-radius: 999px; }
.composer-add .plus { font-size: 17px; line-height: 1; }

.mic-btn {
  position: relative; width: 54px; height: 54px; flex-shrink: 0;
  border: none; border-radius: 50%; cursor: pointer;
  background: linear-gradient(135deg, var(--sevda), #f43f5e);
  color: #fff; box-shadow: var(--shadow-lg);
  display: grid; place-items: center;
  transition: transform .15s ease;
}
.mic-btn:hover { transform: scale(1.06); }
.mic-btn:active { transform: scale(.94); }
.mic-btn[hidden] { display: none; }
.mic-icon { font-size: 22px; line-height: 1; }
.mic-pulse {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--sevda); opacity: 0;
}
.mic-btn.is-recording .mic-pulse { animation: pulse 1.4s ease-out infinite; }
@keyframes pulse {
  0%   { transform: scale(1);   opacity: .75; }
  100% { transform: scale(1.75); opacity: 0; }
}

/* ---------- Fenêtres modales ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px); animation: fade .18s ease;
}
.modal-panel {
  position: relative; width: 100%; max-width: 460px;
  max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg);
  animation: rise .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 12px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16.5px; flex: 1; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 15px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 9px; align-items: center;
  padding: 14px 18px; border-top: 1px solid var(--border);
}

/* ---------- Mon compte ---------- */
.account-id { display: flex; align-items: center; gap: 14px; }
.avatar-lg { width: 46px; height: 46px; font-size: 18px; }
.account-name { font-weight: 700; font-size: 16px; }
.account-mail { font-size: 13px; color: var(--text-faint); }
.account-section {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-soft);
  margin: 4px 0 2px; padding-top: 16px; border-top: 1px solid var(--border);
}
#password-form { display: flex; flex-direction: column; gap: 13px; }
#password-form .btn { margin-top: 4px; }
#password-remove { font-size: 12.5px; padding: 9px 12px; }

/* ---------- Répartition ---------- */
.share-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.share-choice { position: relative; }
.share-choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.share-choice span {
  display: block; text-align: center; padding: 10px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; color: var(--text-soft); cursor: pointer;
  transition: all .14s ease;
}
.share-choice input:checked + span {
  border-color: var(--indigo); background: var(--indigo-soft); color: var(--indigo);
}
.share-choice input:focus-visible + span {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--indigo) 22%, transparent);
}
.share-custom { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.share-custom input[type="range"] { flex: 1; accent-color: var(--indigo); min-height: 40px; }
.share-custom output { font-weight: 700; font-size: 13px; min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.share-explain {
  margin: 9px 0 0; font-size: 12.5px; color: var(--text-soft);
  background: var(--surface-2); padding: 9px 11px; border-radius: var(--radius-sm); line-height: 1.5;
}

/* ---------- Dictée ---------- */
.modal-voice { max-width: 480px; }
.voice-stage { padding: 30px 22px 26px; text-align: center; }
.voice-orb {
  width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 38px; cursor: pointer;
  background: linear-gradient(135deg, var(--sevda), #f43f5e); color: #fff;
  box-shadow: 0 14px 34px -14px var(--sevda);
  transition: transform .2s ease;
}
.voice-orb:hover { transform: scale(1.05); }
.voice-orb.is-recording { animation: breathe 1.5s ease-in-out infinite; }
.voice-orb.is-thinking {
  background: linear-gradient(135deg, var(--indigo), #7c3aed);
  animation: breathe 1s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.09); } }
.voice-status { font-weight: 600; font-size: 15px; margin: 0 0 6px; }
.voice-transcript {
  margin: 10px 0 0; font-size: 14.5px; color: var(--text); min-height: 22px;
  font-style: italic; line-height: 1.5;
}
.voice-transcript:not(:empty)::before { content: "« "; }
.voice-transcript:not(:empty)::after { content: " »"; }
.voice-hint { margin: 18px 0 0; font-size: 12px; color: var(--text-faint); line-height: 1.8; }
.voice-results { padding: 0 18px 6px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; }
.voice-comment { font-size: 13px; color: var(--text-soft); text-align: center; margin: 0 0 4px; }
.voice-card {
  display: flex; align-items: center; gap: 11px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.voice-card.is-unsure { border-color: var(--amber); }
.voice-card-main { flex: 1; min-width: 0; }
.voice-card-label { font-weight: 600; font-size: 14px; }
.voice-card-meta { font-size: 12px; color: var(--text-faint); }
.voice-card-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.voice-card .icon-btn { width: 32px; height: 32px; font-size: 14px; }

/* ---------- Réponse de l'assistant ---------- */
.voice-answer { padding: 4px 0 8px; }
.voice-question {
  margin: 0 0 12px; font-size: 13px; font-style: italic; color: var(--text-faint);
  text-align: center;
}
.voice-question::before { content: "« "; }
.voice-question::after  { content: " »"; }
.voice-answer-text {
  margin: 0; padding: 16px 18px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 15.5px; line-height: 1.6;
}

/* ---------- Notifications ---------- */
.toasts {
  position: fixed; z-index: 90; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: calc(100% - 32px); max-width: 420px;
}
.toast {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg);
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toast-in .25s cubic-bezier(.2, .9, .3, 1);
  pointer-events: auto;
}
.toast.is-error { background: var(--red); color: #fff; }
.toast.is-ok { background: var(--green); color: #fff; }
.toast button {
  margin-left: auto; background: rgba(255, 255, 255, .2); border: none; color: inherit;
  padding: 5px 11px; border-radius: 7px; font: inherit; font-weight: 600; font-size: 12.5px; cursor: pointer;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Chargement ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm);
  display: block;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-balance { height: 104px; border-radius: 18px; opacity: .35; }
.skeleton-rows { height: 96px; }
.skeleton-chart { height: 180px; width: 100%; }

/* ==========================================================================
   Adaptation aux petits écrans
   ========================================================================== */
@media (max-width: 780px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stat-tiles { grid-template-columns: 1fr; gap: 8px; }
  .stat-tile { display: flex; align-items: baseline; gap: 10px; padding: 12px 14px; }
  .stat-tile .stat-value { margin: 0; margin-left: auto; }
  .stat-tile .stat-sub { flex-basis: 100%; text-align: right; }
  /* Les quatre onglets ne tiennent pas sur la meme ligne que la marque et les
     boutons : a 375px ils recevaient 50px chacun et « Historique » en reclame 63,
     donc le libelle etait tronque. Ils prennent leur propre ligne, pleine largeur. */
  .topbar-inner { height: auto; flex-wrap: wrap; gap: 10px; row-gap: 7px; padding: 7px 12px; }
  .brand { order: 1; }
  .topbar-right { order: 2; margin-left: auto; }
  .tabs { order: 3; flex-basis: 100%; margin-left: 0; min-width: 0; padding: 3px; }
  .tabs + .topbar-right { margin-left: auto; }
  .app { padding-top: 14px; }              /* la barre occupe une ligne de plus */
  .tab {
    flex: 1 1 0; min-width: 0; padding: 9px 6px; font-size: 13px;
    min-height: 44px;                     /* cible tactile confortable */
    text-align: center; display: grid; place-items: center;
  }
  .user-name { display: none; }
  .user-chip { padding: 5px; }
  .tab-long { display: none; }
  .tab-short { display: block; }
  .balance-card { padding: 24px 20px; }
  .field-row { grid-template-columns: 1fr; }
  .filters { padding: 12px; gap: 8px; }
  .field-grow { flex-basis: 100%; }
  .card-body { padding: 12px 14px 16px; }
  .card-title { padding: 14px 14px 0; }
  .card-note { margin: 8px 14px 0; }
  .modal { padding: 0; place-items: end stretch; }
  .modal-panel {
    max-width: none; border-radius: 20px 20px 0 0;
    max-height: 92dvh; animation: sheet .26s cubic-bezier(.2, .9, .3, 1);
  }
  @keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }
  .composer-add { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
