/* ==========================================================================
   FELLOWSPLIT — 2 thèmes mobile-first, inspirés d'une compagnie de voyage
   - [data-theme="chronique"] -> Chronique : parchemin, encre, sceaux de cire (clair, défaut)
   - [data-theme="veillee"]   -> Veillée : nuit, or et compagnie de jeu de rôle (sombre)
   - [data-theme="academie"]  -> Académie : école de magie, maisons et directeurs (ivoire & velours prune)
   Choix via le menu Options (⚙), persisté dans localStorage (tribu.theme).
   ========================================================================== */

:root {
  --max-mobile-width: 440px;
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   THÈME 1 : CHRONIQUE (parchemin, carte, sceaux)
   -------------------------------------------------------------------------- */
html[data-theme="chronique"] {
  --font-main: 'Alegreya Sans', system-ui, sans-serif;
  --font-display: 'IM Fell English', Georgia, serif;
  --display-weight: 400;
  --bg-page: #D9C9A6;
  --bg-shell: #F3EAD8;
  --bg-header: #E9DCC0;
  --bg-surface: #EFE3C9;
  --bg-card: #FAF4E6;
  --bg-card-alt: #EFE3C9;
  --text-main: #2A2118;
  --text-secondary: #6B5A45;
  --text-on-header: #2A2118;
  --accent-primary: #9E2B25;
  --accent-secondary: #B5423A;
  --accent-soft: #F1DCC9;
  --on-accent: #F3EAD8;
  --pos-color: #3F5A3A;
  --pos-bg: #DFE6D3;
  --neg-color: #9E2B25;
  --neg-bg: #F3D9D2;
  --border-main: 1px solid #CDBB98;
  --radius-shell: 28px;
  --radius-card: 14px;
  --radius-pill: 9999px;
  --shadow-card: 0 1px 0 rgba(42, 33, 24, 0.06);
  --shadow-btn: inset 0 0 0 3px #B5423A;
  --nav-bg: #F3EAD8;
  --nav-text: #6B5A45;
  --nav-active: #9E2B25;
  --input-bg: #FFFAF0;
  --input-text: #2A2118;
  --input-border: #CDBB98;
}

/* --------------------------------------------------------------------------
   THÈME 2 : VEILLÉE (nuit, or, fiches de personnage)
   -------------------------------------------------------------------------- */
html[data-theme="veillee"] {
  --font-main: 'Manrope', system-ui, sans-serif;
  --font-display: 'Cinzel', Georgia, serif;
  --display-weight: 600;
  --bg-page: #070B0D;
  --bg-shell: #10161A;
  --bg-header: radial-gradient(120% 90% at 85% 0%, #2A2F22 0%, #141B20 55%, #10161A 100%);
  --bg-surface: #182127;
  --bg-card: #182127;
  --bg-card-alt: #1D272E;
  --text-main: #E9E4D6;
  --text-secondary: #9AA3A8;
  --text-on-header: #E9E4D6;
  --accent-primary: #D8B45C;
  --accent-secondary: #E6C77A;
  --accent-soft: rgba(216, 180, 92, 0.16);
  --on-accent: #10161A;
  --pos-color: #7FB48A;
  --pos-bg: rgba(127, 180, 138, 0.16);
  --neg-color: #E0795A;
  --neg-bg: rgba(224, 121, 90, 0.16);
  --border-main: 1px solid #2A353C;
  --radius-shell: 30px;
  --radius-card: 16px;
  --radius-pill: 9999px;
  --shadow-card: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-btn: 0 0 18px rgba(216, 180, 92, 0.35);
  --nav-bg: #0C1114;
  --nav-text: #9AA3A8;
  --nav-active: #D8B45C;
  --input-bg: #10161A;
  --input-text: #E9E4D6;
  --input-border: #2F3B42;
}

/* --------------------------------------------------------------------------
   THÈME 3 : ACADÉMIE (école de magie : ivoire, velours prune, laiton)
   Inspiration générique : aucun nom, blason, couleur de maison ni typo d'une œuvre existante.
   -------------------------------------------------------------------------- */
html[data-theme="academie"] {
  --font-main: 'Source Sans 3', system-ui, sans-serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --display-weight: 700;
  --bg-page: #2B1D33;
  --bg-shell: #F4F1EA;
  --bg-header: #2B1D33;
  --bg-surface: #FFFDF8;
  --bg-card: #FFFDF8;
  --bg-card-alt: #ECE5F0;
  --text-main: #1D2340;
  --text-secondary: #5A5F73;
  --text-on-header: #F4F1EA;
  --accent-primary: #5B2A4D;
  --accent-secondary: #7A3D68;
  --accent-soft: #ECE5F0;
  --on-accent: #F4F1EA;
  --pos-color: #2F6B3A;
  --pos-bg: #E2EFE0;
  --neg-color: #9B2C2C;
  --neg-bg: #F6E1DE;
  --border-main: 1px solid #E3DCCB;
  --radius-shell: 30px;
  --radius-card: 18px;
  --radius-pill: 9999px;
  --shadow-card: 0 1px 2px rgba(29, 35, 64, 0.06);
  --shadow-btn: 0 6px 16px -8px rgba(91, 42, 77, 0.6);
  --nav-bg: #2B1D33;
  --nav-text: #C7BCCF;
  --nav-active: #D4B26A;
  --input-bg: #FFFFFF;
  --input-text: #1D2340;
  --input-border: #D6CDB8;
}

/* ==========================================================================
   BASE & SHELL MOBILE
   ========================================================================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 0 2rem 0;
  font-family: var(--font-main);
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  transition: background var(--transition-fast), color var(--transition-fast);
}

/* Menu Options (choix du design) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

button.btn-options,
button.btn-on-header {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-on-header);
  box-shadow: none;
}

button.btn-options {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
}

.options-dialog {
  width: min(92vw, 380px);
  border: var(--border-main);
  border-radius: var(--radius-card);
  background: var(--bg-shell);
  color: var(--text-main);
  box-shadow: var(--shadow-card);
  padding: 1.1rem;
  font-family: var(--font-main);
}

.options-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.options-dialog form > button {
  width: 100%;
  margin-top: 0.4rem;
}

.theme-choice {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.2rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.theme-swatch {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.theme-swatch[data-swatch="chronique"] { background: linear-gradient(135deg, #F3EAD8 45%, #9E2B25 45% 72%, #2A2118 72%); }
.theme-swatch[data-swatch="veillee"]   { background: linear-gradient(135deg, #10161A 45%, #D8B45C 45% 72%, #7FB48A 72%); }
.theme-swatch[data-swatch="academie"]  { background: linear-gradient(135deg, #2B1D33 45%, #D4B26A 45% 72%, #F4F1EA 72%); }

/* Conteneur Smartphone Centré */
.app-shell {
  max-width: var(--max-mobile-width);
  margin: 1rem auto;
  background: var(--bg-shell);
  border-radius: var(--radius-shell);
  border: var(--border-main);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.26);
  /* clip (et non hidden) : découpe les coins sans créer de conteneur de défilement,
     sinon la barre d'onglets « sticky » ne colle plus au bas de l'écran. */
  overflow: hidden;
  overflow: clip;
  min-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (max-width: 480px) {
  body {
    padding-bottom: 0;
  }
  .app-shell {
    margin: 0;
    max-width: 100%;
    border-radius: 0;
    min-height: 100vh;
    border-left: none;
    border-right: none;
  }
}

/* ==========================================================================
   HEADER DU TÉLÉPHONE (Adaptatif selon le Design)
   ========================================================================== */
.phone-header {
  background: var(--bg-header);
  color: var(--text-on-header);
  padding: 1.35rem 1.25rem 2.1rem 1.25rem;
  position: relative;
  overflow: hidden;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-on-header);
  text-decoration: none;
}

.brand-badge {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent-primary);
  color: #FFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
}

.phone-title {
  margin: 0 0 0.25rem 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  position: relative;
  z-index: 1;
}

.phone-subtitle {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.82;
  position: relative;
  z-index: 1;
}

/* Jauges & KPIs dans le Header */
.header-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 1.15rem;
  position: relative;
  z-index: 1;
}

.kpi-box {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0.65rem 0.8rem;
}

.kpi-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  display: block;
}

.kpi-val {
  font-size: 1.15rem;
  font-weight: 800;
  margin-top: 0.15rem;
  display: block;
  font-variant-numeric: tabular-nums;
}


/* Disque central Bilan (Spécial Design 3 Inveto Rouge & multi-thème) */
.hero-circle-wrap {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0 0.2rem 0;
  position: relative;
  z-index: 2;
}

.hero-circle {
  width: 156px;
  height: 156px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent-secondary), var(--accent-primary));
  color: var(--on-accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: var(--shadow-btn);
  border: 5px solid rgba(255, 255, 255, 0.16);
  padding: 0.75rem;
}

.hero-circle-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.9;
}

.hero-circle-amount {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0.2rem 0;
  font-variant-numeric: tabular-nums;
}

.hero-circle-sub {
  font-size: 0.68rem;
  opacity: 0.9;
  font-weight: 600;
}

/* ==========================================================================
   CORPS DE L'APPLICATION (Panneau arrondi façon Inveto)
   ========================================================================== */
.phone-body {
  flex: 1;
  background: var(--bg-shell);
  margin-top: -1.15rem;
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  padding: 1.25rem 1.1rem 5.5rem 1.1rem;
  position: relative;
  z-index: 2;
}

/* Cartes d'accès rapide (Activities 3 colonnes inspirées de l'image Inveto) */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.35rem;
}

.quick-action-card {
  background: var(--bg-card);
  border: var(--border-main);
  border-radius: 18px;
  padding: 0.85rem 0.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  color: var(--text-main);
  font-family: inherit;
  transition: transform 0.15s ease;
}

.quick-action-card:hover {
  transform: translateY(-2px);
}

.quick-action-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
}

.quick-action-title {
  font-size: 0.73rem;
  font-weight: 700;
}

/* Sections & Cartes */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.15rem 0 0.65rem 0;
}

.section-title {
  font-size: 0.98rem;
  font-weight: 800;
  margin: 0;
}

.ui-card {
  background: var(--bg-card);
  border: var(--border-main);
  border-radius: var(--radius-card);
  padding: 1rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow-card);
}

.ui-card-banner {
  background: var(--bg-card-alt);
  border: var(--border-main);
  border-radius: var(--radius-card);
  padding: 0.95rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: var(--shadow-card);
}

/* Tableaux & listes */
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.84rem;
}

td, th {
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  text-align: left;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.pos {
  color: var(--pos-color);
  font-weight: 800;
}

.neg {
  color: var(--neg-color);
  font-weight: 800;
}

.error {
  color: #E11D48;
  font-weight: 700;
}

.muted {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* Transactions avec pastilles rondes (Style Inveto) */
.tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.tx-item:last-child {
  border-bottom: none;
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.tx-dot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--pos-bg);
  color: var(--pos-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Formulaires & Boutons */
input, select {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--input-text);
  max-width: 100%;
}

input[type="number"] {
  width: 5.2em;
}

button {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.52rem 0.9rem;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent-primary);
  color: var(--on-accent);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

button.btn-ghost {
  background: rgba(148, 163, 184, 0.2);
  color: inherit;
  box-shadow: none;
  padding: 0.32rem 0.6rem;
  font-size: 0.72rem;
}

fieldset {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  margin: 0.6rem 0;
  padding: 0.65rem 0.8rem;
}

legend {
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0 0.35rem;
}

/* Barre de Navigation Inférieure (5 icônes façon Inveto) */
/* Toujours visible : collée au bas de l'écran pendant le défilement. */
.bottom-tab-bar {
  position: -webkit-sticky;
  position: sticky;
  bottom: 0;
  margin-top: auto;
  left: 0;
  right: 0;
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.65rem 0.5rem;
  border-top: var(--border-main);
  z-index: 30;
}

.tab-btn {
  text-decoration: none;
  flex: 1;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--nav-active);
}

.tab-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: transparent;
}

.tab-btn.active .tab-dot {
  background: var(--nav-active);
}

/* ==========================================================================
   ÉCRANS SÉPARÉS : composants
   ========================================================================== */
a { color: var(--accent-primary); }

.phone-header.compact {
  padding-bottom: 1.9rem;
}

.phone-header.compact .phone-title {
  font-size: 1.3rem;
}

.kpi-sub {
  display: block;
  font-size: 0.72rem;
  opacity: 0.8;
  margin-top: 0.2rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.section-title + .muted,
.section-title + p {
  margin-top: 0.3rem;
}

.section-gap {
  margin: 1.2rem 0 0.65rem 0.2rem;
}

.link,
.chevron {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent-primary);
  text-decoration: none;
}

.chevron {
  font-size: 1.3rem;
}

.list-link {
  color: inherit;
  text-decoration: none;
}

/* Boutons */
.btn,
.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

a.btn {
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--accent-primary);
  color: var(--on-accent);
  text-decoration: none;
  box-shadow: var(--shadow-btn);
}

button.btn-block {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  margin-top: 0.4rem;
}

button.btn-danger {
  color: var(--neg-color);
}

/* Bannières d'alerte */
.ui-card-banner.alert {
  border-left: 4px solid var(--accent-primary);
}

/* Cartes d'accès rapide en lien */
a.quick-action-card {
  text-decoration: none;
  text-align: center;
}

/* Champs de formulaire */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 0;
}

.field input,
.field select {
  width: 100%;
}

.field .muted {
  font-weight: 400;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.participant-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.participant-row label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
}

/* Identité */
.identity-group {
  margin: 0.8rem 0;
}

.identity-household {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

button.chip {
  background: var(--accent-soft);
  color: var(--text-main);
  box-shadow: none;
}

button.chip.active {
  background: var(--accent-primary);
  color: var(--on-accent);
}

/* Foyers */
.households-cards-grid {
  display: grid;
  gap: 0.85rem;
}

.household-card {
  background: var(--bg-card);
  border: var(--border-main);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1rem;
}

.household-card.mine,
.balance-card.mine {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.household-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.household-name {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
}

.household-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.member {
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.member-info {
  font-size: 0.74rem;
  opacity: 0.75;
  margin-top: 0.15rem;
}

.member-more {
  margin-top: 0.35rem;
  font-size: 0.78rem;
}

.member-more summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-primary);
}

.member-more form {
  margin-top: 0.5rem;
}

.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.6rem;
}

.cat-weight {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.76rem;
}

.cat-weight input {
  width: 4.2em;
  padding: 0.35rem 0.45rem;
}

.member-name {
  font-weight: 700;
}

.member-edit {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.member-edit select {
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
}

.chef-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  background: var(--accent-primary);
  color: var(--on-accent);
  vertical-align: middle;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.inline-form input {
  min-width: 0;
}

.transfer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  margin-top: 0.7rem;
  color: var(--text-secondary);
}

.household-card.mine .transfer {
  color: inherit;
}

.validated-note,
.household-lock {
  font-size: 0.78rem;
  margin: 0.7rem 0 0 0;
  opacity: 0.85;
}

.badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.ok {
  background: var(--pos-bg);
  color: var(--pos-color);
}

.badge.wait {
  background: #FEF3C7;
  color: #92400E;
}

.add-household summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 0.9rem;
}

.add-household[open] summary {
  margin-bottom: 0.4rem;
}

/* Bilan */
.settlement {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  font-size: 0.88rem;
}

.settlement:last-child {
  border-bottom: none;
}

.settlement.mine strong {
  color: var(--accent-primary);
}

.settlement .arrow {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.stat-grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.stat-grid .num {
  text-align: left;
  font-size: 0.88rem;
}

.stat-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

/* Transactions : ligne cliquable */
.tx-item .num {
  white-space: nowrap;
}

/* Formulaire de dépense : répartition */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: block;
  text-align: center;
  padding: 0.55rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--on-accent);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent-secondary);
}

.part-hint {
  font-size: 0.72rem;
}

.participant-row label {
  align-items: flex-start;
}

.parts-total {
  margin: 0.2rem 0 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
}


/* Lien secondaire (export CSV) */
a.btn.btn-secondary {
  background: transparent;
  color: var(--accent-primary);
  border: 1px solid currentColor;
  box-shadow: none;
}

/* Comptes : fenêtre de connexion */
#auth-dialog .stack { gap: 0.6rem; }
button.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #FFFFFF;
  color: #1F2937;
  border: 1px solid #D1D5DB;
  box-shadow: none;
}
.g-logo {
  font-weight: 800;
  color: #4285F4;
}
.auth-sep {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  opacity: 0.7;
}
.auth-sep::before,
.auth-sep::after {
  content: '';
  flex: 1;
  border-top: 1px solid rgba(148, 163, 184, 0.4);
}
.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem;
}
button.link {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  color: var(--accent-primary);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
}
.auth-msg.error { color: var(--neg-color); }
.account-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* PWA : zones sûres (encoche, barre d'accueil) en mode application installée */
.phone-header {
  padding-top: calc(1.35rem + env(safe-area-inset-top, 0px));
  padding-left: calc(1.25rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1.25rem + env(safe-area-inset-right, 0px));
}
.bottom-tab-bar {
  padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
}
@media (display-mode: standalone) {
  .app-shell {
    margin: 0 auto;
    min-height: 100dvh;
  }
}

/* Invitation à installer l'app */
.install-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.install-card img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex: none;
}
.install-card .install-text { flex: 1; }
.install-card .install-close {
  background: none;
  border: none;
  box-shadow: none;
  color: inherit;
  opacity: 0.6;
  padding: 0.2rem;
  font-size: 1rem;
}

/* Remboursements : ligne principale, actions, état payé */
.settle-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.settlement .badge { align-self: flex-start; }
.settlement.paid .settle-main { opacity: 0.6; }
.settle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
/* Bouton Wero : couleurs de la marque (jaune Wero, texte foncé) */
a.btn.btn-wero {
  background: #FFE600;
  color: #1D1D1B;
  margin-bottom: 0;
}

/* Fin du voyage */
.closing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  font-size: 0.88rem;
}
.closing-card .btn-block,
.closing-card .btn-ghost { margin-top: 0.6rem; }
.wero-card summary { cursor: pointer; }
.wero-card form { margin-top: 0.5rem; }

/* Logo Fellowsplit : l'anneau partagé (icône) */
.brand-badge {
  background: url('/icons/icon.svg') center / cover no-repeat;
}

/* ==========================================================================
   TYPO D'APPARAT & HABILLAGE DES DEUX THÈMES
   ========================================================================== */
.phone-title,
.section-title,
.household-name,
.hero-circle-amount,
.options-dialog h2 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
}

.brand-logo {
  font-family: var(--font-display);
}

/* Option goûter du semi-homme */
.gouter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.gouter-toggle input {
  margin: 0;
  padding: 0;
  width: auto;
  accent-color: var(--accent-primary);
}

/* --- Chronique : carte au trésor dans l'en-tête, sceaux de cire --- */
html[data-theme="chronique"] .phone-title {
  font-size: 1.9rem;
  letter-spacing: 0;
}
html[data-theme="chronique"] .section-title {
  font-size: 1.25rem;
}
html[data-theme="chronique"] .household-name {
  font-size: 1.3rem;
}
html[data-theme="chronique"] .phone-header {
  border-bottom: 1px solid #CDBB98;
}
html[data-theme="chronique"] .phone-header::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.55;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='160' viewBox='0 0 360 160'%3E%3Cpath d='M-10 130 C 60 40, 120 150, 190 80 S 300 20, 380 60' fill='none' stroke='%23B9A37B' stroke-width='2' stroke-dasharray='2 7' stroke-linecap='round'/%3E%3Ccircle cx='190' cy='80' r='4' fill='%239E2B25' fill-opacity='.5'/%3E%3C/svg%3E") right top / 360px 160px no-repeat;
}
html[data-theme="chronique"] .phone-body {
  border-top: 1px solid #CDBB98;
}
html[data-theme="chronique"] .brand-logo {
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 400;
}
html[data-theme="chronique"] .hero-circle {
  border: none;
  box-shadow: inset 0 0 0 6px #B5423A, 0 6px 14px -6px rgba(42, 33, 24, 0.5);
}
html[data-theme="chronique"] .hero-circle-amount {
  font-size: 1.6rem;
}
html[data-theme="chronique"] .chef-tag {
  background: transparent;
  color: var(--accent-primary);
  border: 1px solid currentColor;
}
html[data-theme="chronique"] .tab-btn.active {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* --- Veillée : ciel étoilé, accents or, cartes de personnage --- */
html[data-theme="veillee"] .phone-header::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.7;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, #E9E4D6 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 12%, #E9E4D6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 62% 30%, #D8B45C 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 14%, #E9E4D6 50%, transparent 51%),
    radial-gradient(1px 1px at 90% 40%, #E9E4D6 50%, transparent 51%),
    radial-gradient(1px 1px at 48% 46%, #9AA3A8 50%, transparent 51%);
}
html[data-theme="veillee"] .brand-logo {
  color: var(--accent-primary);
  letter-spacing: 0.18em;
}
html[data-theme="veillee"] .phone-title {
  letter-spacing: 0.01em;
}
html[data-theme="veillee"] .section-title {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
html[data-theme="veillee"] .kpi-box {
  background: rgba(24, 33, 39, 0.75);
  border: 1px solid #2A353C;
}
html[data-theme="veillee"] .household-card.mine,
html[data-theme="veillee"] .balance-card.mine {
  outline: 1px solid var(--accent-primary);
}
html[data-theme="veillee"] .badge.wait {
  background: rgba(216, 180, 92, 0.16);
  color: #D8B45C;
}
html[data-theme="veillee"] .tab-btn.active .tab-dot {
  box-shadow: 0 0 8px var(--nav-active);
}
html[data-theme="veillee"] td,
html[data-theme="veillee"] th,
html[data-theme="veillee"] .member,
html[data-theme="veillee"] .tx-item {
  border-color: #222C33;
}

/* Ligne de membre : les réglages (part, profil, goûter) passent à la ligne plutôt que d'élargir la carte */
.households-cards-grid {
  grid-template-columns: minmax(0, 1fr);
}
.member-row {
  flex-wrap: wrap;
}
.member-edit {
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}

/* --- Académie : constellations dans l'en-tête, laiton, fanions de maison --- */
html[data-theme="academie"] .phone-header::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.6;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='130' viewBox='0 0 220 130'%3E%3Cpath d='M20 82 70 46 118 68 168 24 204 52' fill='none' stroke='%23D4B26A' stroke-width='.8'/%3E%3Cg fill='%23D4B26A'%3E%3Ccircle cx='20' cy='82' r='2'/%3E%3Ccircle cx='70' cy='46' r='2.6'/%3E%3Ccircle cx='118' cy='68' r='2'/%3E%3Ccircle cx='168' cy='24' r='3.2'/%3E%3Ccircle cx='204' cy='52' r='2'/%3E%3Ccircle cx='140' cy='108' r='1.2'/%3E%3Ccircle cx='46' cy='18' r='1.2'/%3E%3C/g%3E%3C/svg%3E") right top / 220px 130px no-repeat;
}
html[data-theme="academie"] .brand-logo {
  color: #D4B26A;
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 1.15rem;
}
html[data-theme="academie"] .phone-title {
  font-size: 1.9rem;
  letter-spacing: 0;
}
html[data-theme="academie"] .section-title {
  font-size: 1.3rem;
}
html[data-theme="academie"] .household-name {
  font-size: 1.35rem;
}
html[data-theme="academie"] .phone-subtitle {
  color: #D9CFE0;
  opacity: 1;
}
html[data-theme="academie"] .kpi-box {
  background: rgba(244, 241, 234, 0.08);
  border: 1px solid rgba(212, 178, 106, 0.25);
}
html[data-theme="academie"] .kpi-label {
  color: #D4B26A;
  opacity: 1;
}
html[data-theme="academie"] .hero-circle {
  background: radial-gradient(circle at 35% 30%, #E8CF8F, #C9A24F 60%, #A8823A);
  color: #2B1D33;
  border: none;
  box-shadow: 0 0 0 6px #F4F1EA, 0 0 0 7px #D4B26A, 0 12px 24px -10px rgba(43, 29, 51, 0.6);
}
html[data-theme="academie"] .chef-tag {
  background: transparent;
  color: #7A5C22;
  border: 1px solid currentColor;
}
html[data-theme="academie"] .ui-card-banner.alert {
  border-left-color: #7A5C22;
}

/* Fanion de maison (couleur choisie par la maison, tous thèmes) */
.house-flag {
  display: inline-block;
  width: 0.8em;
  height: 1.1em;
  margin-right: 0.4em;
  vertical-align: -0.12em;
  background: var(--text-secondary);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 76%, 0 100%);
}
.house-flag[data-color=""] { display: none; }
.house-flag[data-color="prune"]   { background: #5B2A4D; }
.house-flag[data-color="canard"]  { background: #1F5C63; }
.house-flag[data-color="ocre"]    { background: #8A5A1C; }
.house-flag[data-color="ardoise"] { background: #3C4A6B; }
.house-flag[data-color="mousse"]  { background: #4D5F2E; }
.house-flag[data-color="rouille"] { background: #8F3B1F; }
html[data-theme="veillee"] .house-flag { box-shadow: 0 0 0 1px rgba(233, 228, 214, 0.35); }

.house-colors {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.7rem;
}
.house-colors .muted { margin-right: 0.3rem; }
.house-color {
  position: relative;
  display: inline-flex;
  padding: 0.3rem;
  border-radius: 8px;
  cursor: pointer;
}
.house-color input {
  position: absolute;
  opacity: 0;
}
.house-color .house-flag {
  width: 16px;
  height: 22px;
  margin: 0;
}
.house-color input:checked + .house-flag {
  outline: 2px solid var(--text-main);
  outline-offset: 2px;
}
.house-color input:focus-visible + .house-flag {
  outline: 2px dashed var(--accent-primary);
  outline-offset: 2px;
}
