:root {
  --bg: #070b14; 
  --surface: rgba(13, 21, 38, 0.55); 
  --card: rgba(18, 29, 52, 0.50); 
  --card-hover: rgba(28, 43, 75, 0.65); 
  --border: rgba(255, 255, 255, 0.10);
  --text-main: #f8fafc; 
  --text-muted: #94a3b8; 
  --cyan: #38bdf8; 
  --teal: #2dd4bf;
  --emerald: #34d399; 
  --amber: #fbbf24; 
  --rose: #f43f5e; 
  --indigo: #818cf8;
  --purple: #a855f7;
  --radius-sm: 8px; 
  --radius-md: 16px; 
  --sidebar-width: 240px;
}

body.light-mode {
  --bg: #f8fafc; 
  --surface: rgba(241, 245, 249, 0.80); 
  --card: rgba(255, 255, 255, 0.75); 
  --card-hover: rgba(226, 232, 240, 0.85); 
  --border: rgba(15, 23, 42, 0.12);
  --text-main: #0f172a; 
  --text-muted: #475569; 
  --cyan: #0284c7; 
  --emerald: #059669;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }

html { 
  background-color: var(--bg); 
  min-height: 100vh; 
  width: 100%;
  overflow-x: clip; 
}

body { 
  background-color: transparent; 
  color: var(--text-main); 
  min-height: 100vh; 
  width: 100%;
  overflow-x: clip; 
  position: relative;
}

/* FOND PHOQUE : iPhone par défaut + Mac >= 850px */
/* FOND OTARIE PLUS VISIBLE ET LUMINEUX */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: -1;
  background-color: var(--bg);
  background-image: 
    linear-gradient(180deg, rgba(6, 11, 22, 0.15) 0%, rgba(6, 11, 22, 0.45) 100%),
    url('fond-iphone.jpg'),
    url('Gemini_Generated_Image_38ws4w38ws4w38ws.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  pointer-events: none;
}

@media (min-width: 850px) {
  body::before {
    background-image: 
      linear-gradient(135deg, rgba(6, 11, 22, 0.15) 0%, rgba(6, 11, 22, 0.42) 100%),
      url('Gemini_Generated_Image_38ws4w38ws4w38ws.jpg');
  }
}

/* =========================================
   HEADER & NAVIGATION MOBILE
   ========================================= */
header { 
  position: fixed; top: 0; left: 0; right: 0; z-index: 9000; 
  background: rgba(9, 13, 22, 0.65); 
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border); 
  padding-top: max(env(safe-area-inset-top), 52px); 
  padding-bottom: 12px; padding-left: 1.1rem; padding-right: 1.1rem;
  display: flex; justify-content: space-between; align-items: center; 
}

.brand-title { font-size: 1.1rem; font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: 0.5rem; }
.theme-toggle { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--text-main); }
.profile-select-ui { appearance: none; -webkit-appearance: none; background-color: transparent; background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.2rem center; background-size: 1.1rem; border: 1px solid transparent; color: var(--text-main); font-weight: 700; border-radius: var(--radius-sm); padding: 0.4rem 1.5rem 0.4rem 0.3rem; outline: none; font-size: 1rem; cursor: pointer; }
.profile-select-ui option { background-color: #090d16; color: var(--text-main); }

.app-container { 
  display: flex; flex-direction: column; width: 100%; 
  padding-top: calc(max(env(safe-area-inset-top), 52px) + 54px); 
  padding-bottom: calc(max(env(safe-area-inset-bottom), 20px) + 82px); 
}
main { flex: 1; padding: 0.9rem; width: 100%; max-width: 720px; margin: 0 auto; }

.view-section { display: none; animation: fadeIn 0.25s ease-out; }
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* CARTES GLASSMORPHISM */
.card { 
  background: rgba(11, 18, 34, 0.42); /* Plus transparent pour laisser apparaître l'otarie */
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12); 
  border-radius: var(--radius-md); 
  padding: 1.1rem; 
  margin-bottom: 1rem; 
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22); 
  width: 100%; min-width: 0; 
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.9rem; font-size: 0.96rem; font-weight: 700; color: var(--text-main); gap: 8px; }

/* BOUCLIER : BLOC PRINCIPAL */
.shield-block { text-align: center; padding: 1.75rem 1rem; position: relative; }
.shield-amount { font-size: clamp(2.4rem, 7vw, 3.2rem); font-weight: 800; color: var(--cyan); margin: 0.4rem 0; letter-spacing: -1.5px; text-shadow: 0 0 25px rgba(56, 189, 248, 0.25); }
.progress-bg { background: rgba(9, 13, 22, 0.55); border-radius: 10px; height: 10px; width: 100%; margin: 14px 0 8px 0; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; width: 0%; transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
.progress-text { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

.metric-grid { display: flex; gap: 0.75rem; margin-bottom: 1rem !important; width: 100%; }
.metric-box { 
  flex: 1; background: var(--card); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem; min-width: 0; 
}
.metric-label { font-size: 0.7rem; text-transform: uppercase; font-weight: 700; color: var(--text-muted); margin-bottom: 0.3rem; }
.metric-value { font-size: 1.25rem; font-weight: 800; color: var(--text-main); }

/* =========================================
   GRILLE MINI-CARTES CATÉGORIES (BOUCLIER)
   ========================================= */
.cat-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  width: 100%;
}
@media (max-width: 350px) {
  .cat-mini-grid { grid-template-columns: 1fr; }
}
.cat-mini-card {
  background: rgba(16, 26, 48, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.55rem;
  transition: transform 0.2s, border-color 0.2s;
  cursor: pointer;
  min-width: 0;
}
.cat-mini-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.35);
}
.cat-mini-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.cat-mini-title { font-size: 0.82rem; font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-mini-icon { color: var(--text-muted); flex-shrink: 0; opacity: 0.85; display: flex; }
.cat-mini-bar-bg { width: 100%; height: 6px; background: rgba(255, 255, 255, 0.07); border-radius: 6px; overflow: hidden; }
.cat-mini-bar-fill { height: 100%; background: linear-gradient(90deg, #5eead4, #38bdf8); border-radius: 6px; transition: width 0.5s ease; }
.cat-mini-bottom { display: flex; justify-content: space-between; align-items: center; font-size: 0.74rem; gap: 4px; }
.cat-mini-sub { color: var(--text-muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-mini-val { color: var(--text-main); font-weight: 800; flex-shrink: 0; }

/* =========================================
   DONUT SOLDE RESTANT & COURBE BOUCLIER
   ========================================= */
.bouclier-charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.bouclier-donut-wrapper {
  position: relative;
  width: 100%;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bouclier-donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  width: 44%;
  max-width: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.bouclier-donut-lbl { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 2px; white-space: nowrap; }
.bouclier-donut-val { font-size: clamp(0.92rem, 2.2vw, 1.22rem); font-weight: 800; color: var(--text-main); letter-spacing: -0.5px; line-height: 1.15; word-break: break-word; }
.bouclier-donut-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; margin-top: 0.5rem; padding-top: 0.5rem; font-size: 0.78rem; }
.b-leg-item { display: flex; align-items: center; gap: 6px; color: var(--text-main); font-weight: 500; }
.b-leg-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.cycle-toggle-group { display: inline-flex; background: rgba(9, 13, 22, 0.6); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.cycle-toggle-btn { background: transparent; border: none; color: var(--text-muted); font-size: 0.74rem; font-weight: 600; padding: 5px 10px; border-radius: 6px; cursor: pointer; transition: 0.2s; }
.cycle-toggle-btn.active { background: rgba(56, 189, 248, 0.18); color: var(--text-main); }

/* =========================================
   ANALYSES : COMPOSANTS
   ========================================= */
.analytics-layout { display: flex; flex-direction: column; gap: 1rem; }
.analytics-top-row { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.micro-fuites-select { appearance: none; -webkit-appearance: none; background-color: rgba(244, 63, 94, 0.15); border: 1px solid rgba(244, 63, 94, 0.35); color: var(--rose); border-radius: 20px; font-size: 0.74rem; font-weight: 700; padding: 0.35rem 0.85rem; outline: none; cursor: pointer; }
.cadence-badge { background: rgba(56, 189, 248, 0.12); border: 1px solid rgba(56, 189, 248, 0.3); color: var(--cyan); font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 12px; white-space: nowrap; }
.cadence-metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem 0.5rem; }
.cadence-lbl { font-size: 0.74rem; color: var(--text-muted); margin-bottom: 3px; }
.cadence-val { font-size: 1.2rem; font-weight: 800; color: var(--text-main); }

.kpi-3-grid { display: grid; grid-template-columns: 1fr; gap: 0.85rem; }
.kpi-mini-card { margin-bottom: 0 !important; display: flex; align-items: center; gap: 0.9rem; padding: 1rem 1.1rem; }
.kpi-icon-box { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cyan-box { background: rgba(56, 189, 248, 0.12); color: var(--cyan); border: 1px solid rgba(56, 189, 248, 0.25); }
.rose-box { background: rgba(244, 63, 94, 0.12); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.25); }
.emerald-box { background: rgba(52, 211, 153, 0.12); color: var(--emerald); border: 1px solid rgba(52, 211, 153, 0.25); }
.kpi-mini-lbl { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 2px; }
.kpi-mini-val { font-size: 1.25rem; font-weight: 800; color: var(--text-main); }

.heatmap-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; margin-top: 0.4rem; }
.heatmap-cell { aspect-ratio: 1; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.07); display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; padding: 2px; }
.heatmap-day-num { font-size: 0.78rem; font-weight: 600; color: var(--text-main); margin-bottom: 10px; }
.heatmap-cell.hm-lvl-0 .heatmap-day-num { margin-bottom: 0; color: var(--text-muted); }
.heatmap-amt-pill { position: absolute; bottom: 3px; background: rgba(9, 13, 22, 0.65); color: #fff; font-size: 0.55rem; font-weight: 700; padding: 1px 4px; border-radius: 6px; max-width: 92%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-lvl-0 { background: rgba(15, 23, 42, 0.55); }
.hm-lvl-1 { background: #5a96ab; }
.hm-lvl-2 { background: #14b89a; }
.hm-lvl-3 { background: #2563eb; box-shadow: 0 0 12px rgba(37, 99, 235, 0.35); }
.heatmap-legend { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 1rem; font-size: 0.72rem; color: var(--text-muted); flex-wrap: wrap; }
.hm-leg-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hm-bar { width: 42px; height: 5px; border-radius: 3px; display: block; }

.tag-search-wrapper { width: 200px; max-width: 100%; }
.tag-search-input { width: 100%; background: rgba(9, 13, 22, 0.5); border: 1px solid var(--border); border-radius: 8px; color: var(--text-main); padding: 0.4rem 0.7rem; font-size: 0.78rem; outline: none; }
.tag-cloud-container { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; padding: 1rem 0.25rem; }
.tag-tile { border-radius: 12px; padding: 0.75rem 1.1rem; display: flex; flex-direction: column; justify-content: center; border: 1px solid rgba(255, 255, 255, 0.15); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }
.tag-tile-name { color: #fff; font-weight: 600; line-height: 1.15; }
.tag-tile-val { color: rgba(255, 255, 255, 0.9); font-weight: 700; margin-top: 3px; }
.sankey-wrapper { height: 290px; }

.goals-global-bar-bg { width: 100%; height: 24px; background: rgba(20, 45, 58, 0.65); border-radius: 12px; overflow: hidden; margin: 0.75rem 0; position: relative; }
.goals-global-bar-fill { height: 100%; background: linear-gradient(90deg, #0284c7, #2dd4bf); border-radius: 12px; display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; font-size: 0.76rem; font-weight: 800; color: #fff; transition: width 0.4s ease; }
.goals-3-grid { display: grid; grid-template-columns: 1fr; gap: 0.9rem; }
.goal-card { margin-bottom: 0 !important; display: flex; flex-direction: column; justify-content: space-between; gap: 0.9rem; }
.goal-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.goal-icon-circle { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.goal-middle { display: flex; align-items: center; gap: 0.9rem; }
.goal-ring-wrap { position: relative; width: 72px; height: 72px; flex-shrink: 0; }
.goal-ring-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 800; color: var(--text-main); }
.goal-pill-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.74rem; font-weight: 700; padding: 5px 12px; border-radius: 14px; width: fit-content; cursor: pointer; }
.transfer-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; padding: 0.35rem 0; color: var(--text-main); border-bottom: 1px solid rgba(255,255,255,0.05); }
.transfer-row:last-child { border-bottom: none; }

.health-ai-grid, .radar-tension-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.ai-insight-item { background: rgba(15, 23, 42, 0.55); border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem 1rem; display: flex; align-items: flex-start; gap: 10px; font-size: 0.82rem; line-height: 1.45; }
.ai-insight-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.95rem; }
.tension-item { display: flex; align-items: flex-start; gap: 10px; font-size: 0.83rem; line-height: 1.45; }

/* =========================================
   SECTION HISTORIQUE (NOUVEAU DESIGN COMPLET)
   ========================================= */
.history-top-tabs {
  background: rgba(13, 21, 38, 0.65);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 1rem;
}
.history-top-tabs .tab-add-btn {
  padding: 0.65rem;
  font-size: 0.86rem;
  border-radius: 9px;
  transition: all 0.2s ease;
}
.history-top-tabs .tab-add-btn.active {
  background: rgba(30, 58, 95, 0.85);
  color: var(--cyan);
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.curr-option { 
  padding: 0.7rem 1rem; font-size: 0.85rem; cursor: pointer; color: var(--text-main); 
  border-bottom: 1px solid rgba(255, 255, 255, 0.05); 
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.curr-option strong { margin-right: 5px; color: var(--cyan); }
.curr-option span { flex: 1; display: flex; align-items: center; 
}
.history-filter-card {
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.history-filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
}
.history-search-box {
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  align-items: center;
}
.history-search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}
.history-search-input {
  padding-left: 36px !important;
  height: 40px;
  background: rgba(7, 11, 20, 0.65) !important;
  border-radius: 10px !important;
  font-size: 0.86rem !important;
}
.history-cat-box {
  grid-column: 1 / -1;
}
.history-cat-select {
  height: 40px;
  background: rgba(7, 11, 20, 0.65) !important;
  border-radius: 10px !important;
  font-size: 0.85rem !important;
  padding: 0 0.75rem !important;
}
.history-date-pill {
  background: rgba(7, 11, 20, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 40px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  cursor: pointer;
  min-width: 0;
}
.history-date-lbl {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.history-date-input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.76rem;
  font-weight: 700;
  outline: none;
  width: 92px;
  min-width: 0;
  padding: 0;
  cursor: pointer;
}
.history-actions-group {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.hist-action-btn {
  height: 40px;
  padding: 0 12px;
  background: rgba(18, 29, 52, 0.75);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}
.hist-action-btn:hover {
  background: var(--card-hover);
  border-color: rgba(56, 189, 248, 0.35);
}
.hist-clear-btn {
  color: var(--rose);
  border-color: rgba(244, 63, 94, 0.25);
  background: rgba(244, 63, 94, 0.08);
  font-weight: bold;
}
.hist-unpointed-check {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 10px;
  background: rgba(7, 11, 20, 0.55);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.hist-unpointed-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--rose);
}

/* CARTE APERÇU DE LA PÉRIODE (SPARKLINE) */
.history-overview-card {
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}
.history-overview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}
.history-overview-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-main);
}
.history-overview-vol {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}
.history-overview-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.history-overview-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.history-overview-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.history-overview-amount {
  font-size: clamp(1.85rem, 5vw, 2.35rem);
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}
.history-overview-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
}
.history-sparkline-wrap {
  width: 100%;
  height: 75px;
  position: relative;
}
.history-overview-avg {
  text-align: right;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
}

/* ÉTAT VIDE ILLUSTRÉ (CADDIE + FACTURE) */
.history-empty-card {
  background: rgba(13, 21, 38, 0.50);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3.5rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}
.history-empty-illust {
  color: rgba(125, 211, 252, 0.75);
  margin-bottom: 1.25rem;
  filter: drop-shadow(0 0 18px rgba(56, 189, 248, 0.2));
}
.history-empty-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}
.history-empty-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}
.history-empty-btn {
  background: #38bdf8;
  color: #06101e;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.75rem 1.6rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.35);
  transition: transform 0.15s, opacity 0.15s;
}
.history-empty-btn:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

/* LISTE DES TRANSACTIONS & CONTRATS (DESIGN CAPTURES 2, 3, 5) */
.hist-list-card {
  background: rgba(13, 21, 38, 0.58);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
}
.hist-list-header {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
}


.hist-row-wrapper {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.hist-row-wrapper:last-child {
  border-bottom: none;
}
.swipe-front { 
  position: relative; 
  z-index: 2; 
  margin-bottom: 0; 
  border: none; 
  background: #090d16 !important; /* Force le fond opaque sur le bloc glissant */
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); 
}
.hist-row-item { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  padding: 0.95rem 0.65rem; 
  gap: 12px; 
  background: transparent; 
}
.hist-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.hist-info-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  flex: 1;
  min-width: 0;
}
.hist-item-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.hist-pills-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.hist-cat-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
}
.hist-row-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.hist-amount-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.hist-amount-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}
.hist-status-line {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem; /* Plus petit pour éviter les chevauchements */
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.hist-status-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 900;
  flex-shrink: 0;
}
.dot-green {
  background: #22c55e;
  color: #052e16;
}
.dot-blue {
  background: #3b82f6;
  color: #ffffff;
}
.dot-clock {
  background: rgba(226, 232, 240, 0.85);
  color: #0f172a;
}
.hist-row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

canvas { width: 100% !important; height: 100% !important; display: block; }
.barchart-container { width: 100%; position: relative; }

/* =========================================
   FORMULAIRES, BOUTONS & MODALES
   ========================================= */
.form-group { margin-bottom: 1rem; width: 100%; min-width: 0; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.4rem; }
.form-input, .form-select { 
  width: 100%; max-width: 100%; min-width: 0;
  background: rgba(9, 13, 22, 0.50); border: 1px solid var(--border); 
  border-radius: var(--radius-sm); color: var(--text-main); 
  padding: 0.75rem 0.65rem; font-size: 0.95rem; outline: none; 
}
.form-select option { background-color: #090d16; color: var(--text-main); }
input[type="date"].form-input { -webkit-appearance: none; appearance: none; min-height: 46px; display: block; }

.form-row-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; width: 100%; align-items: start; }
.form-row-2 > * { min-width: 0; width: 100%; }
@media (max-width: 480px) { #form-variable-section .form-row-2 { grid-template-columns: 1fr; gap: 0; } }

.input-with-btn { display: flex; gap: 6px; width: 100%; align-items: stretch; }
.input-with-btn select, .input-with-btn input { flex: 1; min-width: 0; }
.input-with-btn button { flex: 0 0 44px; background: rgba(255, 255, 255, 0.12); color: var(--text-main); border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: bold; font-size: 1.1rem; cursor: pointer; }

.currency-picker { flex: 0 0 95px; width: 95px; position: relative; }
#formDepMnt { flex: 1; min-width: 0; }

.btn-submit { width: 100%; background: var(--cyan); color: #090d16; border: none; border-radius: var(--radius-sm); font-weight: 700; font-size: 1rem; padding: 0.9rem; cursor: pointer; margin-top: 0.5rem; }
.btn-secondary { background: var(--card); color: var(--text-main); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem; font-weight: 600; cursor: pointer; width: 100%; margin-bottom: 0.5rem; }
.btn-danger { background: rgba(244,63,94,0.15); color: var(--rose); border: 1px solid rgba(244,63,94,0.35); border-radius: var(--radius-sm); padding: 0.75rem; font-weight: 600; cursor: pointer; width: 100%; }
.btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.05rem; padding: 4px; }
.btn-quick-add { background: var(--surface); border: 1px solid var(--border); color: var(--text-main); padding: 0.42rem 0.8rem; border-radius: 20px; font-size: 0.78rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 5px; }
.btn-quick-add span { color: var(--cyan); }

.tabs-add { display: flex; background: var(--card); border-radius: var(--radius-sm); padding: 0.3rem; margin-bottom: 1.2rem; border: 1px solid var(--border); }
.tab-add-btn { flex: 1; text-align: center; padding: 0.6rem; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; color: var(--text-muted); cursor: pointer; background: transparent; border: none; }
.tab-add-btn.active { background: rgba(56, 189, 248, 0.15); color: var(--cyan); }
.add-form-section { display: none; }
.add-form-section.active { display: block; }

.tag-badge { background: rgba(129, 140, 248, 0.2); border: 1px solid rgba(129, 140, 248, 0.4); color: #e0e7ff; padding: 1px 7px; border-radius: 10px; font-size: 0.65rem; font-weight: 600; display: inline-block; }

.nav-container { 
  position: fixed; bottom: 0; left: 0; right: 0; width: 100%;
  background: rgba(9, 13, 22, 0.78); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border); display: flex; justify-content: space-around; align-items: center; 
  z-index: 9000; padding-bottom: max(env(safe-area-inset-bottom), 20px);
  height: calc(65px + max(env(safe-area-inset-bottom), 20px));
}
.nav-btn { flex: 1; min-width: 0; background: none; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-muted); cursor: pointer; font-size: 0.68rem; font-weight: 600; height: 65px; }
.nav-btn svg { width: 20px; height: 20px; stroke-width: 2; }
.nav-btn.active { color: var(--cyan); }
.nav-brand, .nav-desktop-extras { display: none; }

.toast-container { position: fixed; top: calc(1rem + max(env(safe-area-inset-top), 50px)); left: 50%; transform: translateX(-50%); z-index: 100000; display: flex; flex-direction: column; gap: 0.5rem; width: 90%; max-width: 400px; pointer-events: none; }
.toast { background: rgba(18, 24, 38, 0.92); border: 1px solid var(--border); color: var(--text-main); padding: 0.8rem 1rem; border-radius: var(--radius-md); font-size: 0.85rem; display: flex; align-items: center; gap: 0.6rem; }

.month-picker { display: flex; align-items: center; justify-content: space-between; background: rgba(9, 13, 22, 0.45); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem 1rem; margin-bottom: 1rem; }
.month-picker button { background: none; border: none; color: var(--cyan); font-weight: bold; font-size: 1.2rem; cursor: pointer; padding: 0 10px; }

.modal-backdrop { 
  position: fixed; inset: 0; 
  background: rgba(0,0,0,0.85); 
  backdrop-filter: blur(8px); 
  -webkit-backdrop-filter: blur(8px);
  z-index: 99999; 
  display: flex; align-items: center; justify-content: center; 
}
.modal-content { 
  width: 92%; 
  max-width: 400px; 
  max-height: 90vh; 
  overflow-y: auto; 
  padding: 1.5rem; 
  background: #090d16 !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  border-radius: 16px !important;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal-content h3 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 1.2rem;
}
.modal-content .form-input {
  background: #121826 !important;
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 0.85rem;
}
.modal-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  gap: 10px;
}
.modal-actions-right {
  display: flex;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
}
.modal-btn-delete {
  background: rgba(244, 63, 94, 0.1) !important;
  color: var(--rose) !important;
  border: 1px solid rgba(244, 63, 94, 0.25) !important;
  padding: 0.85rem 1rem !important;
  border-radius: 10px !important;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.modal-btn-cancel {
  background: transparent !important;
  color: var(--text-main) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  padding: 0.85rem 1.2rem !important;
  border-radius: 10px !important;
  font-weight: 600;
}
.modal-btn-save {
  background: var(--cyan) !important;
  color: #090d16 !important;
  border: none !important;
  padding: 0.85rem 1.4rem !important;
  border-radius: 10px !important;
  font-weight: 700;
}

#app-lock-screen { display: flex; position: fixed; inset: 0; z-index: 999999; background: rgba(9, 13, 22, 0.95); backdrop-filter: blur(20px); flex-direction: column; align-items: center; justify-content: center; }
#app-lock-screen.hidden { opacity: 0; pointer-events: none; }
.pin-circle-container { display: flex; gap: 15px; margin: 20px 0; }
.pin-circle { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--border); }
.pin-circle.filled { background: var(--cyan); border-color: var(--cyan); }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 20px; }
.numpad button { width: 65px; height: 65px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-main); font-size: 1.5rem; font-weight: bold; cursor: pointer; }

@media (max-width: 849px) { .desktop-only { display: none !important; } }

/* =========================================
   VUE DESKTOP (MAC / PC >= 850px)
   ========================================= */
/* =========================================
   SECTION AJOUTER : PILULES SVG & 5 SOUS-PAGES
   ========================================= */
.add-pills-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 1.1rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.add-pills-nav::-webkit-scrollbar { display: none; }

.add-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.62rem 1.15rem;
  border-radius: 30px;
  background: rgba(18, 29, 52, 0.65);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.add-pill-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  transition: stroke 0.2s;
}
.add-pill-btn:hover {
  border-color: rgba(56, 189, 248, 0.4);
}
.add-pill-btn.active {
  background: var(--cyan);
  color: #06101e;
  border-color: var(--cyan);
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.35);
}
.add-pill-btn.active svg {
  stroke: #06101e;
}
.add-pill-badge {
  background: var(--rose);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 2px;
}

.add-subpage { display: none; animation: fadeIn 0.22s ease-out; }
.add-subpage.active { display: block; }

.voice-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.voice-pill-btn:hover { border-color: var(--cyan); color: var(--cyan); }

/* SOUS-PAGE SCAN & IA */
.scan-ia-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.15rem;
}
.scan-dropzone-panel {
  background: rgba(11, 18, 34, 0.55);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}
.scan-viewfinder {
  position: relative;
  border: 1.5px dashed rgba(56, 189, 248, 0.35);
  border-radius: 14px;
  min-height: 270px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(56, 189, 248, 0.06) 0%, transparent 70%);
}
.vf-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--cyan);
  border-style: solid;
  border-width: 0;
  pointer-events: none;
}
.vf-tl { top: 14px; left: 14px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 8px; }
.vf-tr { top: 14px; right: 14px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 8px; }
.vf-bl { bottom: 14px; left: 14px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 8px; }
.vf-br { bottom: 14px; right: 14px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 8px; }

.vf-laser {
  position: absolute;
  left: 8%;
  right: 8%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 12px var(--cyan);
  top: 50%;
  opacity: 0.65;
  animation: laserScan 3s ease-in-out infinite;
}
@keyframes laserScan {
  0%, 100% { top: 18%; }
  50% { top: 82%; }
}

.scan-extracted-panel {
  background: rgba(11, 18, 34, 0.55);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.scan-field-group {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.65rem;
  margin-bottom: 0.85rem;
}
.scan-field-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 3px;
}
.scan-clean-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.2rem;
  font-weight: 700;
  outline: none;
  padding: 2px 0;
}

/* SOUS-PAGE FAVORIS D'AJOUT RAPIDE (IMAGE 4) */
.favs-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}
.fav-card-item {
  background: rgba(15, 25, 45, 0.65);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.9rem;
  transition: all 0.2s ease;
  cursor: pointer;
}
.fav-card-item:hover {
  border-color: var(--cyan);
  background: rgba(22, 38, 68, 0.75);
  transform: translateY(-2px);
}
.fav-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.fav-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fav-card-title { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.fav-card-price { font-size: 1.4rem; font-weight: 800; color: var(--text-main); margin-top: 4px; }
.fav-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.fav-cat-badge {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 14px;
}
.fav-mini-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: var(--cyan);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.fav-create-dashed {
  border: 1.5px dashed rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  transition: 0.2s;
}
.fav-create-dashed:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* SOUS-PAGE PARTAGER */
.split-members-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.split-member-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}
.split-member-chip.selected {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--cyan);
  color: var(--text-main);
}
.split-summary-box {
  background: rgba(9, 13, 22, 0.55);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-top: 0.5rem;
}

/* CORRECTION FOND MENU DEVISES */
#currencyMenu {
  background: #0f172a !important; 
  border: 1px solid var(--border);
}

/* =========================================
   SECTION PARAMÈTRES (DESIGN ONGLET & UI)
   ========================================= */
.set-subpage { display: none; animation: fadeIn 0.22s ease-out; }
.set-subpage.active { display: block; }

/* Gestionnaire de catégories (Sleek) */
.cat-m-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  transition: background 0.2s;
}
.cat-m-row:hover { background: rgba(15, 23, 42, 0.8); }
.cat-m-root {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.2);
}
.cat-m-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cat-m-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-main);
}
.cat-m-root .cat-m-icon { background: rgba(56, 189, 248, 0.15); color: var(--cyan); }
.cat-m-info { display: flex; flex-direction: column; gap: 2px; }
.cat-m-title { font-size: 0.95rem; font-weight: 600; color: var(--text-main); }
.cat-m-sub { font-size: 0.72rem; color: var(--text-muted); }
.cat-m-actions { display: flex; gap: 4px; align-items: center; }

/* Boutons Données & Sauvegardes */
.set-data-btn {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 1.1rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.set-data-btn:hover { border-color: var(--cyan); background: rgba(15, 23, 42, 0.8); transform: translateY(-1px); }
.set-data-icon { font-size: 1.6rem; opacity: 0.8; }
.set-data-text { display: flex; flex-direction: column; gap: 3px; }
.set-data-title { font-size: 0.95rem; font-weight: 700; color: var(--text-main); }
.set-data-sub { font-size: 0.8rem; color: var(--text-muted); }

/* Zone de danger */
.set-danger-zone {
  border-color: rgba(244, 63, 94, 0.3) !important;
  background: rgba(244, 63, 94, 0.02) !important;
}

/* DESIGN DES CATÉGORIES (SWIPE & APPARENCE PRO) */
.cat-row-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.05);
}
.cat-m-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--card);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s, box-shadow 0.2s;
  z-index: 2;
  position: relative;
}
.cat-m-root { background: rgba(18, 29, 52, 0.8); }
.cat-m-left { display: flex; align-items: center; gap: 12px; pointer-events: none; }
.cat-m-icon { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center; color: var(--text-main); }
.cat-m-root .cat-m-icon { background: rgba(56, 189, 248, 0.15); color: var(--cyan); }
.cat-m-info { display: flex; flex-direction: column; gap: 2px; }
.cat-m-title { font-size: 0.95rem; font-weight: 600; color: var(--text-main); }
.cat-m-sub { font-size: 0.72rem; color: var(--text-muted); }
.cat-m-actions { display: flex; gap: 6px; align-items: center; }

/* État lors du glisser-déposer (Appui long) */
.cat-dragging {
  opacity: 0.9;
  transform: scale(1.02);
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  z-index: 999;
  border-color: var(--cyan);
}

/* CARTES DE DÉPENSES AÉRÉES ET ARRONDIES (HISTORIQUE) */
.hist-row-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.05rem;
  margin-bottom: 0.75rem;
  gap: 12px;
  background: rgba(16, 25, 46, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}
.hist-row-card:last-child {
  margin-bottom: 0;
}

/* =========================================
   CORRECTIFS MAC & IPHONE (SELECTS, MÉMOS, HEATMAP, BILAN)
   ========================================= */

/* 1. Harmonisation des listes déroulantes (<select>) sur Mac et iPhone */
select.form-select, .history-cat-select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-color: rgba(11, 18, 34, 0.85) !important;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important;
  background-size: 1rem !important;
  padding-right: 2.3rem !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  color: var(--text-main) !important;
  font-weight: 600 !important;
  cursor: pointer;
  box-shadow: none !important;
}
select.form-select:focus, .history-cat-select:focus {
  border-color: var(--cyan) !important;
}

/* 2. Harmonisation du badge de catégorie et du mémo dans Historique */
.hist-cat-pill {
  font-size: 0.7rem !important;
  font-weight: 700 !important;
  padding: 3px 10px !important;
  border-radius: 8px !important;
  letter-spacing: 0.1px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.hist-sub-meta {
  font-size: 0.73rem !important;
  color: var(--text-muted) !important;
  font-weight: 500 !important;
  letter-spacing: 0;
}

/* 3. Jours de la semaine au-dessus de la Heatmap */
.heatmap-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* 4. Grille du Bilan Complet (Wrapped) */
.bilan-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 1.25rem;
}
@media (min-width: 650px) {
  .bilan-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
.bilan-kpi-box {
  background: rgba(16, 25, 46, 0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  text-align: left;
}
.bilan-kpi-lbl { font-size: 0.73rem; color: var(--text-muted); text-transform: uppercase; font-weight: 700; margin-bottom: 4px; }
.bilan-kpi-val { font-size: 1.3rem; font-weight: 800; color: var(--text-main); }

/* =========================================
   ANIMATION D'OUVERTURE OTARIA (SPLASH SCREEN)
   ========================================= */
#otaria-splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999999;
  background: radial-gradient(circle at center, #0f1b33 0%, #060a12 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.6s;
}
#otaria-splash-screen.splash-hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-logo-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.2rem;
}
.splash-svg {
  z-index: 2;
  filter: drop-shadow(0 0 18px rgba(56, 189, 248, 0.6));
  animation: splashFloat 2s ease-in-out infinite;
}
.splash-ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(56, 189, 248, 0.5);
  animation: splashWave 2s cubic-bezier(0.1, 0.8, 0.3, 1) infinite;
}
.splash-ripple.delay-1 {
  animation-delay: 0.7s;
}
.splash-title {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 2.2rem;
  font-weight: 200; /* Trait ultra-fin et élégant */
  letter-spacing: 14px;
  margin-right: -14px; /* Compense l'espacement à droite pour un centrage parfait */
  color: #f8fafc;
  text-shadow: 0 0 28px rgba(56, 189, 248, 0.45);
  animation: splashTextIn 0.9s ease-out forwards;
}
.splash-subtitle {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 0.76rem;
  font-weight: 300;
  color: #38bdf8;
  letter-spacing: 4.5px;
  margin-right: -4.5px;
  text-transform: uppercase;
  margin-top: 10px;
  opacity: 0.9;
}
@keyframes splashWave {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.65); opacity: 0; }
}
@keyframes splashFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.05); }
}
@keyframes splashTextIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   CORRECTION LISTE DES DÉPENSES SUR IPHONE (ZÉRO CHEVAUCHEMENT)
   ========================================= */
@media (max-width: 600px) {
  .hist-list-card {
    padding: 0.9rem 0.75rem !important;
  }
  .hist-row-card {
    padding: 0.85rem 0.75rem !important;
    gap: 8px !important;
    align-items: flex-start !important;
  }
  .hist-icon-box {
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
    margin-top: 2px;
  }
  .hist-row-left {
    gap: 9px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden;
  }
  .hist-info-col {
    gap: 4px !important;
    width: 100%;
    min-width: 0 !important;
  }
  .hist-item-title {
    font-size: 0.9rem !important;
  }
  .hist-pills-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 3px !important;
  }
  .hist-cat-pill {
    font-size: 0.65rem !important;
    padding: 2px 8px !important;
    max-width: 145px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hist-sub-meta {
    font-size: 0.68rem !important;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 155px;
  }
  .hist-row-right {
    gap: 4px !important;
    flex-shrink: 0 !important;
    align-items: center !important;
  }
  .hist-amount-val {
    font-size: 0.96rem !important;
  }
  .hist-status-line {
    font-size: 0.64rem !important;
    gap: 3px !important;
  }
  .hist-status-dot {
    width: 13px !important;
    height: 13px !important;
    font-size: 0.52rem !important;
  }
}


/* =========================================
   MENUS DÉROULANTS PERSONNALISÉS OTARIA (MAC & PC)
   ========================================= */
.otaria-select-portal {
  position: fixed;
  z-index: 9999999;
  background: rgba(11, 18, 34, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  animation: fadeIn 0.15s ease-out;
}
.otaria-select-option {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s, color 0.15s;
}
.otaria-select-option:hover {
  background: rgba(56, 189, 248, 0.15);
  color: var(--cyan);
}
.otaria-select-option.selected {
  background: rgba(56, 189, 248, 0.22);
  color: var(--cyan);
  font-weight: 700;
}

/* CORRECTIF D'AFFICHAGE DU QR CODE */
#qrcode-container {
  background: #ffffff !important;
  padding: 16px !important;
  border-radius: 14px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}
#qrcode-container canvas {
  width: 200px !important;
  height: 200px !important;
}
#qrcode-container img {
  width: 200px !important;
  height: 200px !important;
  display: block !important;
  margin: 0 auto !important;
}

@media (min-width: 850px) {
  header { display: none; }
  .nav-container { 
    position: fixed; top: 0; left: 0; bottom: 0; 
    width: var(--sidebar-width); height: 100vh;
    flex-direction: column; justify-content: flex-start; align-items: stretch; 
    padding: 2rem 1rem; border-top: none; border-right: 1px solid var(--border); 
    background: rgba(9, 13, 22, 0.55); 
    backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
    z-index: 1000;
  }
  .app-container { 
    margin-left: var(--sidebar-width); 
    width: calc(100% - var(--sidebar-width)); 
    padding-top: 0; padding-bottom: 0; 
  }
  main { max-width: 1350px; padding: 2rem 2.5rem; margin: 0; }
  .card { padding: 1.25rem; margin-bottom: 1.15rem; }
  
  .nav-brand { display: flex; align-items: center; gap: 0.4rem; font-size: 1.15rem; font-weight: bold; color: var(--text-main); margin-bottom: 2.5rem; padding-left: 0.5rem; width: 100%; }
  .nav-btn { flex: none; flex-direction: row; padding: 0.9rem 1rem; justify-content: flex-start; gap: 0.9rem; border-radius: 12px; font-size: 0.92rem; height: auto; margin-bottom: 4px; }
  .nav-btn:hover { background: var(--card-hover); }
  .nav-btn.active { background: rgba(56, 189, 248, 0.14); color: var(--cyan); border: 1px solid rgba(56, 189, 248, 0.25); }
  
  .nav-desktop-extras { display: flex; flex-direction: row; align-items: center; gap: 12px; width: 100%; padding: 0.75rem 1rem; margin-top: auto; border: 1px solid var(--border); border-radius: 12px; background: rgba(9, 13, 22, 0.35); }
  .nav-theme-desktop { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; font-weight: 600; }
  
  .dashboard-grid, .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
  .full-col { grid-column: 1 / -1; }

  .cat-mini-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem; }
  .cat-mini-card { padding: 1rem 1.1rem; }
  .cat-mini-title { font-size: 0.92rem; }
  .cat-mini-bottom { font-size: 0.82rem; }

  .bouclier-charts-grid { grid-template-columns: 1fr 1.15fr; }
  .analytics-top-row { grid-template-columns: 1.45fr 1fr; }
  .kpi-3-grid { grid-template-columns: repeat(3, 1fr); }
  .goals-3-grid { grid-template-columns: repeat(3, 1fr); }
  .health-ai-grid { grid-template-columns: 1fr 1.15fr; }
  .radar-tension-grid { grid-template-columns: 1.25fr 1fr; }

  .heatmap-grid { gap: 8px; }
  .heatmap-day-num { font-size: 0.9rem; margin-bottom: 14px; }
  .heatmap-amt-pill { font-size: 0.68rem; padding: 2px 8px; bottom: 6px; }
  .sankey-wrapper { height: 340px; }

  /* Alignement 1 ligne sur Mac pour la barre de filtres Historique */
  .history-filter-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .history-search-box { flex: 1.4; min-width: 180px; }
  .history-cat-box { flex: 1; min-width: 170px; }
  .history-date-pill { flex: 0 0 auto; }
  .history-actions-group { flex: 0 0 auto; }

  /* Alignement horizontal pour l'Aperçu de la Période sur Mac */
  .history-overview-body {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2.5rem;
  }
  .history-overview-left { flex: 0 0 220px; }
  .history-sparkline-wrap { height: 82px; }
  .scan-ia-grid { grid-template-columns: 1.35fr 1fr; }
  .favs-cards-grid { grid-template-columns: repeat(2, 1fr); }
}

/* =========================================
   NOUVELLES OPTIONS : SYNC LIVE, ONBOARDING, IOS BANNER, CSV & EXPORT PDF
   ========================================= */

/* 1. Indicateur d'état de synchronisation en direct */
.sync-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sync-status-pill.desktop {
  width: 100%;
  justify-content: center;
  padding: 8px 12px;
  font-size: 0.76rem;
}
.sync-status-pill:hover {
  border-color: var(--cyan);
  color: var(--text-main);
}
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}
.sync-dot.synced {
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}
.sync-dot.syncing {
  background: var(--cyan);
  animation: syncPulse 0.8s infinite alternate;
}
.sync-dot.offline {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}
@keyframes syncPulse {
  from { transform: scale(0.8); opacity: 0.5; }
  to { transform: scale(1.25); opacity: 1; }
}

/* 2. Guide de prise en main (Onboarding) */
.onboarding-card {
  background: linear-gradient(135deg, rgba(14, 28, 54, 0.88), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.onboarding-steps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 0.9rem;
}
@media (min-width: 700px) {
  .onboarding-steps-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
.onboarding-step-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.85rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.onboarding-step-box:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.08);
}
.onboarding-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.2);
  color: var(--cyan);
  font-weight: 800;
  font-size: 0.78rem;
}

/* 3. Infobulle d'installation iOS */
.ios-install-prompt {
  position: fixed;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 430px;
  z-index: 99990;
  background: rgba(11, 19, 36, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65);
  animation: fadeIn 0.35s ease-out;
}
.ios-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ios-install-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* 4. Lignes de rapprochement bancaire CSV */
.csv-rec-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0.7rem 0.85rem;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-wrap: wrap;
}
.csv-rec-row.duplicate {
  opacity: 0.55;
  border-style: dashed;
}

/* 5. Mise en page d'impression officielle pour l'Export PDF du Bilan */
@media print {
  body * {
    visibility: hidden !important;
  }
  #wrapped-modal, #wrapped-modal * {
    visibility: visible !important;
  }
  #wrapped-modal {
    position: absolute !important;
    inset: 0 !important;
    background: #070b14 !important;
    display: block !important;
    padding: 0 !important;
  }
  #wrappedModalBody {
    max-width: 100% !important;
    width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
    border: none !important;
  }
  .no-print-btn {
    display: none !important;
  }
}

@media (max-width: 849px) {
  .nav-desktop-extras {
    display: none !important;
  }
}
@media (min-width: 850px) {
  .nav-desktop-extras {
    display: flex !important;
    flex-direction: column;
    gap: 8px;
  }
}

/* =========================================
   CORRECTIFS FINAUX : HISTORIQUE & MODALES
   ========================================= */

/* Barre de filtres de l'historique sur la même ligne */
.history-filter-card {
  padding: 0.9rem !important;
}
.history-filter-bar {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  width: 100% !important;
  padding-bottom: 4px;
}
.history-search-box {
  flex: 1.5;
  min-width: 130px;
}
.history-cat-box {
  flex: 1.2;
  min-width: 120px;
}
.history-date-pill {
  flex: 1;
  min-width: 110px;
}
.history-actions-group {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.history-actions-group .hist-action-btn {
  padding: 6px 8px !important;
  font-size: 0.78rem !important;
  border-radius: 6px !important;
}

/* Gestion définitive de l'en-tête selon l'appareil */
@media (min-width: 850px) {
  /* Sur Mac / Desktop : Masqué car la sidebar gère la navigation */
  header {
    display: none !important;
  }
}

@media (max-width: 849px) {
  /* Sur iPhone / Mobile : Affiché avec une marge sécurisée anti-encoche */
  header {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
    padding-top: calc(env(safe-area-inset-top, 20px) + 8px) !important;
    padding-bottom: 10px !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
    background: #090d16 !important;
    border-bottom: 1px solid var(--border);
  }
}

/* Espacement optimal du contenu principal sur iPhone pour éviter que la première carte soit trop basse */
@media (max-width: 849px) {
  .app-container {
    padding-top: 0px !important;
  }
  main {
    padding-top: 8px !important;
  }
  #view-dashboard .dashboard-grid {
    padding-top: 4px !important;
  }
}

/* Empêche le chevauchement du texte des montants lors du changement de profil */
.shield-amount, .metric-value, .bilan-kpi-val {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  width: 100% !important;
  display: block !important;
}

/* =========================================================
   VISITE GUIDÉE INTERACTIVE (SPOTLIGHT ONBOARDING)
   ========================================================= */
#otaria-spotlight-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999999;
  pointer-events: auto;
  overflow: hidden;
}

#otaria-spotlight-hole {
  position: fixed;
  border-radius: 16px;
  /* Crée l'obscurité tout autour de la zone éclairée */
  box-shadow: 0 0 0 9999px rgba(4, 8, 18, 0.84), 0 0 28px 4px rgba(56, 189, 248, 0.55);
  border: 2px solid var(--cyan);
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  z-index: 9999998;
}

.spotlight-tooltip {
  position: fixed;
  z-index: 9999999;
  width: calc(100vw - 32px);
  max-width: 350px;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(9, 14, 26, 0.98));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 18px;
  padding: 1.15rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 25px rgba(56, 189, 248, 0.15);
  transition: top 0.4s cubic-bezier(0.22, 1, 0.36, 1), left 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
}

.spotlight-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.spotlight-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.spotlight-skip-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
}
.spotlight-skip-btn:hover {
  color: var(--text-main);
}

.spotlight-title {
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.spotlight-desc {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
  margin-bottom: 1rem;
}

.spotlight-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.spotlight-dots {
  display: flex;
  gap: 5px;
}

.spotlight-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: all 0.25s ease;
}
.spotlight-dot.active {
  width: 18px;
  border-radius: 999px;
  background: var(--cyan);
}

.spotlight-btn-sec {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.spotlight-btn-pri {
  background: linear-gradient(135deg, var(--cyan), #0284c7);
  border: none;
  color: #040812;
  padding: 0.45rem 0.95rem;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}