:root {
  --bg: #14102a;
  --bg-elev: #1f1844;
  --bg-card: #2a1f56;
  --bg-card-2: #34286a;
  --fg: #f5f0ff;
  --fg-dim: #b4abd4;
  --fg-mute: #8a82a8;

  --accent: #ff7eb5;        /* rose */
  --accent-2: #a78bfa;      /* violet */
  --accent-3: #5fc3ff;      /* bleu */
  --accent-warm: #ffd166;   /* or — pour les gains */
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;

  --gradient-warm: linear-gradient(135deg, #ff7eb5 0%, #a78bfa 100%);
  --gradient-cool: linear-gradient(135deg, #5fc3ff 0%, #a78bfa 100%);
  --gradient-gold: linear-gradient(135deg, #ffd166 0%, #ff9f6a 100%);

  --radius: 20px;
  --radius-sm: 12px;
  --radius-lg: 28px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 40px rgba(167, 139, 250, 0.25);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Fredoka", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
  background: #14102a;
  color: var(--fg);
  min-height: 100dvh;
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow-x: hidden;
}

/* ───────── BACKGROUND : orbes flottantes ───────── */

.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  will-change: transform;
}
.orb-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #ff7eb5, transparent 70%);
  top: -180px; left: -180px;
  animation: float-1 22s ease-in-out infinite;
}
.orb-2 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, #a78bfa, transparent 70%);
  bottom: -200px; right: -180px;
  animation: float-2 28s ease-in-out infinite;
}
.orb-3 {
  width: 380px; height: 380px;
  background: radial-gradient(circle, #5fc3ff, transparent 70%);
  top: 40%; left: 50%;
  opacity: 0.25;
  animation: float-3 25s ease-in-out infinite;
}
@keyframes float-1 {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(60px, 80px); }
}
@keyframes float-2 {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(-80px, -60px); }
}
@keyframes float-3 {
  0%, 100% { transform: translate(-50%, -50%); }
  50%      { transform: translate(-30%, -70%); }
}

/* ───────── CANVAS PARTICLES ───────── */

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* ───────── TYPOGRAPHIE ───────── */

h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

/* ───────── BUTTONS ───────── */

button {
  font: inherit;
  font-weight: 500;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 14px 22px;
  background: var(--bg-card);
  color: var(--fg);
  transition: transform 120ms var(--bounce), background 160ms var(--ease), box-shadow 160ms var(--ease);
  position: relative;
  overflow: hidden;
}
button:hover { background: var(--bg-card-2); }
button:active { transform: scale(0.95); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--gradient-warm);
  color: white;
  font-weight: 600;
  box-shadow: var(--shadow), 0 0 24px rgba(255, 126, 181, 0.35);
}
.btn-primary:hover { background: var(--gradient-warm); filter: brightness(1.08); }
.btn-good {
  background: linear-gradient(135deg, #4ade80, #16a34a);
  color: #052e1a;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(74, 222, 128, 0.35);
}
.btn-bad {
  background: linear-gradient(135deg, #f87171, #dc2626);
  color: #2a0808;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(248, 113, 113, 0.35);
}
.btn-ghost {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--fg); }

/* ───────── INPUTS ───────── */

input, select {
  font: inherit;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  background: rgba(20, 16, 42, 0.6);
  color: var(--fg);
  width: 100%;
  transition: border 160ms var(--ease), background 160ms var(--ease);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-2);
  background: rgba(20, 16, 42, 0.9);
  box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.18);
}
input::placeholder { color: var(--fg-mute); }

/* ───────── LAYOUT ───────── */

main#app {
  padding: 18px 16px 80px;
  max-width: 980px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ───────── LOGIN ───────── */

.login {
  display: flex;
  flex-direction: column;
  gap: 32px;
  align-items: center;
  min-height: 90dvh;
  justify-content: center;
  animation: fade-up 500ms var(--ease);
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 2.2rem;
  font-weight: 700;
  text-align: center;
}
.brand-pig {
  display: inline-block;
  font-size: 2.6rem;
  animation: breathe 3.2s ease-in-out infinite;
  filter: drop-shadow(0 6px 12px rgba(255, 126, 181, 0.3));
}
@keyframes breathe {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.08) rotate(-3deg); }
}
.brand-text {
  background: var(--gradient-warm);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login .users {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.user-card {
  width: 130px;
  height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 3px solid transparent;
  transition: border 200ms var(--ease), transform 200ms var(--bounce), box-shadow 200ms var(--ease);
}
.user-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.user-card.selected {
  border-color: var(--accent);
  transform: translateY(-6px);
  box-shadow: var(--shadow), 0 0 30px rgba(255, 126, 181, 0.4);
}
.user-card .emoji {
  font-size: 3.5rem;
  line-height: 1;
  transition: transform 300ms var(--bounce);
}
.user-card.selected .emoji { transform: scale(1.15); }
.user-card .name { font-size: 1.05rem; font-weight: 600; }

.pinpad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 12px;
  justify-content: center;
}
.pinpad button {
  height: 72px;
  font-size: 1.6rem;
  font-weight: 600;
  background: rgba(42, 31, 86, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.pinpad button:hover { background: rgba(52, 40, 106, 0.8); }
.pin-display {
  display: flex;
  gap: 14px;
  justify-content: center;
  height: 32px;
}
.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  transition: background 200ms var(--ease), transform 200ms var(--bounce);
}
.pin-dot.filled {
  background: var(--accent);
  transform: scale(1.2);
  box-shadow: 0 0 12px var(--accent);
}

/* ───────── TOPBAR ───────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 18px;
  flex-wrap: wrap;
  animation: fade-up 400ms var(--ease);
}
.topbar .me {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.05rem;
}
.topbar .me .emoji {
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}
.topbar .spacer { flex: 1; }
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(31, 24, 68, 0.6);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
}
.tabs button {
  padding: 8px 14px;
  border-radius: 10px;
  background: transparent;
  color: var(--fg-dim);
  font-weight: 500;
  font-size: 0.95rem;
}
.tabs button:hover { color: var(--fg); background: rgba(255, 255, 255, 0.04); }
.tabs button.active {
  background: var(--bg-card);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

/* ───────── BALANCE / GOALS ───────── */

.balance-card {
  position: relative;
  background: linear-gradient(135deg, rgba(255, 126, 181, 0.18), rgba(167, 139, 250, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 28px 22px 24px;
  text-align: center;
  margin-bottom: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-glow);
  animation: fade-up 500ms var(--ease);
}
.balance-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.06) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: shimmer 5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes shimmer {
  0%      { transform: translateX(-100%); }
  60%     { transform: translateX(100%); }
  100%    { transform: translateX(100%); }
}
.balance-card .label {
  color: var(--fg-dim);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 3px;
  font-weight: 500;
  margin-bottom: 4px;
}
.balance-card .amount {
  font-size: clamp(3rem, 13vw, 5.4rem);
  font-weight: 700;
  line-height: 1.05;
  background: var(--gradient-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 12px rgba(255, 209, 102, 0.25));
  letter-spacing: -0.02em;
}
.balance-card .pending {
  margin-top: 8px;
  color: var(--warn);
  font-weight: 600;
  font-size: 0.95rem;
}

/* ───────── GOALS ───────── */

.goals { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.goal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
}
.goal:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.goal-head { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.goal-head .emoji { font-size: 1.4rem; }
.goal-head .target { margin-left: auto; color: var(--fg-dim); font-weight: 400; font-size: 0.9rem; }
.goal-bar {
  height: 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}
.goal-bar > span {
  display: block;
  height: 100%;
  background: var(--gradient-warm);
  border-radius: 99px;
  transition: width 800ms var(--ease);
  position: relative;
  overflow: hidden;
}
.goal-bar > span::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: bar-shimmer 2.5s ease-in-out infinite;
}
@keyframes bar-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.goal-bar.done > span { background: linear-gradient(90deg, #4ade80, #22d3ee); }
.goal.achieved {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.1), rgba(34, 211, 238, 0.1));
  border-color: rgba(74, 222, 128, 0.3);
}

/* ───────── SECTION TITLES ───────── */

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 22px 4px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title .pill {
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(255, 126, 181, 0.4);
}

/* ───────── TASK CARDS ───────── */

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.task-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 200ms var(--bounce), box-shadow 200ms var(--ease), border 200ms var(--ease);
  position: relative;
  overflow: hidden;
}
.task-card:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--shadow);
  border-color: rgba(255, 126, 181, 0.3);
}
.task-card:active { transform: translateY(-1px) scale(0.99); }
.task-card .row1 { display: flex; align-items: center; gap: 10px; }
.task-card .emoji {
  font-size: 1.9rem;
  line-height: 1;
  transition: transform 300ms var(--bounce);
}
.task-card:hover .emoji { transform: scale(1.15) rotate(-5deg); }
.task-card .name { flex: 1; font-weight: 600; line-height: 1.2; font-size: 1rem; }
.task-card .price {
  font-weight: 700;
  background: var(--gradient-gold);
  color: #2d1a00;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(255, 209, 102, 0.3);
}
.task-card .meta { color: var(--fg-dim); font-size: 0.78rem; font-weight: 500; }
/* Carte parent en mode édition rapide (depuis la vue Ardoise) */
.task-card-edit:hover {
  border-color: rgba(167, 139, 250, 0.4);
}
.task-card-edit .cta-hint {
  color: var(--accent-2);
}

.task-card .description {
  color: var(--fg-mute);
  font-size: 0.78rem;
  line-height: 1.35;
  font-style: italic;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid rgba(255, 209, 102, 0.4);
  border-radius: 6px;
  text-align: left;
}
.task-card .actions { display: flex; gap: 6px; margin-top: auto; }
.task-card .actions button { flex: 1; padding: 10px; font-size: 0.9rem; }
.task-card .cta-hint {
  color: var(--fg-mute);
  font-size: 0.82rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ───────── PENDING / VALIDATIONS ───────── */

.pending-list { display: flex; flex-direction: column; gap: 10px; }
.pending-row {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid rgba(255, 255, 255, 0.05);
  animation: slide-in 300ms var(--ease);
}
@keyframes slide-in {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.pending-row .who { font-size: 1.7rem; line-height: 1; }
.pending-row .what { flex: 1; min-width: 140px; }
.pending-row .what b { display: block; font-size: 1.05rem; }
.pending-row .what small { color: var(--fg-dim); font-size: 0.82rem; }
.pending-row .price {
  font-weight: 700;
  background: var(--gradient-gold);
  color: #2d1a00;
  padding: 5px 12px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(255, 209, 102, 0.3);
}
.pending-row .actions { display: flex; gap: 6px; }
.pending-row .actions button { padding: 12px 16px; font-size: 1.1rem; min-width: 50px; }

/* ───────── HISTORY ───────── */

.history { display: flex; flex-direction: column; gap: 6px; }
.history-row {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(31, 24, 68, 0.5);
  border-radius: 12px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 200ms var(--ease);
}
.history-row:hover { background: rgba(42, 31, 86, 0.7); }
.history-row .icon { font-size: 1.3rem; width: 32px; text-align: center; }
.history-row .label { flex: 1; }
.history-row .label > div:first-child { font-weight: 500; }
.history-row .label small { display: block; color: var(--fg-mute); font-size: 0.74rem; margin-top: 2px; }
.history-row .amt { font-weight: 700; font-size: 1rem; }
.history-row .amt.pos { color: var(--good); }
.history-row .amt.neg { color: var(--bad); }

/* ───────── MODALS / FORMS ───────── */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 7, 24, 0.6);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 16px;
  animation: backdrop-in 200ms var(--ease);
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal {
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow), 0 0 60px rgba(167, 139, 250, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: modal-in 280ms var(--bounce);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h2 { margin: 0; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal .actions.actions-split { justify-content: space-between; align-items: center; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { color: var(--fg-dim); font-size: 0.85rem; font-weight: 500; }
.field-row { display: flex; gap: 8px; }
.field-row > * { flex: 1; }

/* ───────── TOASTS ───────── */

.toasts {
  position: fixed; bottom: 20px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  max-width: 90vw;
  font-weight: 500;
  animation: toast-in 320ms var(--bounce);
  backdrop-filter: blur(8px);
}
.toast.good { border-color: var(--good); box-shadow: var(--shadow), 0 0 20px rgba(74, 222, 128, 0.3); }
.toast.bad { border-color: var(--bad); box-shadow: var(--shadow), 0 0 20px rgba(248, 113, 113, 0.3); }
@keyframes toast-in {
  from { transform: translateY(30px) scale(0.9); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ───────── EMPTY STATE ───────── */

.empty {
  color: var(--fg-dim);
  text-align: center;
  padding: 32px 16px;
  font-style: italic;
  font-size: 0.95rem;
}
.empty .emoji { font-size: 2.4rem; display: block; margin-bottom: 10px; opacity: 0.7; }

/* ───────── PARENT PANEL ───────── */

.panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.panel h3 { margin: 0 0 12px; }

/* ───────── REPORT ───────── */

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding: 6px;
}
.report-tile {
  background: rgba(31, 24, 68, 0.6);
  padding: 16px;
  border-radius: var(--radius-sm);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: transform 200ms var(--ease);
}
.report-tile:hover { transform: translateY(-2px); }
.report-tile .v { font-size: 1.5rem; font-weight: 700; }
.report-tile .l { color: var(--fg-dim); font-size: 0.8rem; margin-top: 2px; }
.report-tile.tile-accent {
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.15), rgba(255, 126, 181, 0.10));
  border-color: rgba(255, 209, 102, 0.35);
}
.report-tile.tile-accent .v {
  background: var(--gradient-gold);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ───────── PRESENCE BANNER (garde alternée) ───────── */

.presence-banner {
  text-align: center;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 14px;
  border: 1px solid transparent;
  animation: fade-up 400ms var(--ease);
}
.presence-banner.present {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.15), rgba(74, 222, 128, 0.05));
  border-color: rgba(74, 222, 128, 0.3);
  color: #a7f3d0;
}
.presence-banner.away {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.12), rgba(167, 139, 250, 0.04));
  border-color: rgba(167, 139, 250, 0.25);
  color: var(--fg-dim);
}

/* ───────── ANIMATION GLOBALE ───────── */

.fade-in { animation: fade-up 400ms var(--ease); }

@media (max-width: 480px) {
  .topbar .tabs { width: 100%; order: 3; }
  .topbar .me { font-size: 0.95rem; }
  .balance-card .amount { font-size: clamp(2.6rem, 16vw, 4rem); }
}

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