/* Finary-inspired iOS Minimalist Finance App Styles */
:root {
  --bg-primary: #090C12;
  --bg-secondary: #121722;
  --bg-tertiary: #192030;
  --bg-elevated: rgba(25, 32, 48, 0.85);
  --bg-glass: rgba(18, 23, 34, 0.82);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(245, 158, 11, 0.45);

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  --accent-gold: #F59E0B;
  --accent-gold-soft: rgba(245, 158, 11, 0.14);
  --accent-gold-grad: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);

  --accent-emerald: #10B981;
  --accent-emerald-soft: rgba(16, 185, 129, 0.14);

  --accent-blue: #3B82F6;
  --accent-blue-soft: rgba(59, 130, 246, 0.14);

  --accent-indigo: #6366F1;
  --accent-indigo-soft: rgba(99, 102, 241, 0.14);

  --accent-danger: #F43F5E;
  --accent-danger-soft: rgba(244, 63, 94, 0.14);

  --shadow-card: 0 8px 24px -6px rgba(0, 0, 0, 0.45);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
}

body.theme-light {
  --bg-primary: #F4F6FA;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #EEF2F6;
  --bg-elevated: rgba(255, 255, 255, 0.92);
  --bg-glass: rgba(255, 255, 255, 0.88);
  --border-subtle: rgba(15, 23, 42, 0.09);
  --border-focus: rgba(217, 119, 6, 0.45);

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;

  --accent-gold: #D97706;
  --accent-gold-soft: rgba(217, 119, 6, 0.12);
  --accent-emerald: #059669;
  --accent-emerald-soft: rgba(5, 150, 105, 0.12);
  --accent-danger: #E11D48;
  --accent-danger-soft: rgba(225, 29, 72, 0.12);

  --shadow-card: 0 6px 20px -4px rgba(15, 23, 42, 0.07);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  user-select: text;
  -webkit-user-select: text;
}

.app-content, .modal-sheet, .hero-card, .kpi-card, .section-card, .tx-item, .category-row, .ai-msg, table, td, th {
  user-select: text;
  -webkit-user-select: text;
}

/* Chiffres tabulaires pour alignement financier parfait */
.tabular, .kpi-value, .amount, .pct-badge, table td {
  font-variant-numeric: tabular-nums;
}

/* Barre d'outils PC (masquée automatiquement sur iPhone réel) */
.desktop-toolbar {
  display: none;
}

@media (min-width: 600px) {
  body.iphone-preview-mode {
    background: radial-gradient(circle at 50% 15%, #182032 0%, #06080C 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 32px;
  }

  .desktop-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 980px;
    margin: 14px auto;
    padding: 10px 18px;
    background: rgba(18, 23, 34, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 16px;
    color: #F8FAFC;
    z-index: 1000;
  }

  .desktop-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .desktop-toolbar-brand {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .desktop-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* Simulateur iPhone 16 Pro sur PC */
  body.iphone-preview-mode .app-shell {
    width: 412px;
    height: 868px;
    background: var(--bg-primary);
    border-radius: 50px;
    border: 10px solid #222938;
    box-shadow:
      0 0 0 2px #0F131C,
      0 30px 70px -10px rgba(0, 0, 0, 0.75),
      inset 0 0 12px rgba(255, 255, 255, 0.04);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* Dynamic Island */
  body.iphone-preview-mode .app-shell::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 112px;
    height: 28px;
    background: #000000;
    border-radius: 20px;
    z-index: 200;
    box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.15);
  }

  body.iphone-preview-mode .app-header {
    padding-top: 46px;
  }

  /* Mode plein écran sur PC */
  body:not(.iphone-preview-mode) .app-shell {
    max-width: 980px;
    margin: 0 auto;
    min-height: calc(100vh - 80px);
    padding-bottom: 100px;
  }

  body:not(.iphone-preview-mode) .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body:not(.iphone-preview-mode) .two-col-desktop {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
}

/* Structure principale sur iPhone */
.app-shell {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
}

.app-header {
  padding: calc(env(safe-area-inset-top, 12px) + 10px) 18px 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-gold-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #090C12;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-selector-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.month-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 6px 28px 6px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

.month-select:focus {
  border-color: var(--accent-gold);
}

.month-selector-arrow {
  position: absolute;
  right: 10px;
  pointer-events: none;
  font-size: 10px;
  color: var(--accent-gold);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

/* Zone de contenu scrollable */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 105px;
  -webkit-overflow-scrolling: touch;
}

/* Masquer la scrollbar sur mode aperçu iPhone */
body.iphone-preview-mode .app-content::-webkit-scrollbar {
  width: 4px;
}
body.iphone-preview-mode .app-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* Hero Card façon Finary */
.hero-card {
  background: radial-gradient(120% 130% at 95% 0%, rgba(245, 158, 11, 0.18) 0%, rgba(18, 23, 34, 0.96) 55%), var(--bg-secondary);
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

body.theme-light .hero-card {
  background: radial-gradient(120% 130% at 95% 0%, rgba(245, 158, 11, 0.16) 0%, rgba(255, 255, 255, 0.98) 60%), #FFFFFF;
  border: 1px solid rgba(217, 119, 6, 0.32);
  box-shadow: 0 10px 26px -6px rgba(217, 119, 6, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
}

body.theme-light .progress-target-marker {
  background: rgba(15, 23, 42, 0.65);
}

body.theme-light .category-row:hover {
  background: #E2E8F0;
}

body.theme-light .modal-handle {
  background: rgba(15, 23, 42, 0.2);
}

.hero-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.hero-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.status-pill.ok {
  background: var(--accent-emerald-soft);
  color: var(--accent-emerald);
}

.status-pill.warn {
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
}

.status-pill.danger {
  background: var(--accent-danger-soft);
  color: var(--accent-danger);
}

.hero-main-amount {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 4px;
}

.hero-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-cashflow-bar {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.hero-mini-stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hero-mini-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.hero-mini-val {
  font-size: 15px;
  font-weight: 700;
  margin-top: 1px;
}

/* Grille de KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
  width: 100%;
  max-width: 100%;
}

.kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 6px;
  min-width: 0;
}

.kpi-value {
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
  width: 100%;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Cartes de section génériques */
.section-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}

.section-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 7px;
}

.section-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Règle 50 / 30 / 20 */
.rule-503020-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.rule-503020-item:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.rule-503020-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.rule-503020-name {
  font-weight: 650;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rule-503020-amounts {
  text-align: right;
  font-size: 13.5px;
  font-weight: 700;
}

.rule-503020-target {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-target-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.7);
  z-index: 2;
}

.rule-503020-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* Donut Chart + Légende interactive */
.donut-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.donut-svg-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-center-info {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  padding: 24px;
}

.donut-center-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 600;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.donut-center-val {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.donut-center-pct {
  font-size: 11px;
  color: var(--accent-gold);
  font-weight: 600;
}

/* Liste des catégories */
.category-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.category-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.category-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cat-icon-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.cat-name-wrap {
  min-width: 0;
}

.cat-name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cat-type-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 600;
}

.cat-type-tag.Besoin {
  background: var(--accent-indigo-soft);
  color: #818CF8;
}

.cat-type-tag.Envie {
  background: var(--accent-gold-soft);
  color: var(--accent-gold);
}

.cat-type-tag.Revenu {
  background: var(--accent-emerald-soft);
  color: var(--accent-emerald);
}

.cat-type-tag.Épargne {
  background: rgba(245, 158, 11, 0.2);
  color: #FBBF24;
}

.category-row-right {
  text-align: right;
  flex-shrink: 0;
}

.cat-amount {
  font-size: 14px;
  font-weight: 700;
}

.cat-share {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Graphiques SVG / Courbes */
.chart-box {
  width: 100%;
  overflow: hidden;
  padding-top: 4px;
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Liste d'opérations */
.tx-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.tx-item:active {
  transform: scale(0.99);
}

.tx-item:hover {
  border-color: rgba(245, 158, 11, 0.35);
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1;
}

.tx-details {
  min-width: 0;
  flex: 1;
}

.tx-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.tx-right {
  text-align: right;
  flex-shrink: 0;
}

.tx-amount {
  font-size: 14.5px;
  font-weight: 700;
}

.tx-amount.positive {
  color: var(--accent-emerald);
}

.tx-amount.negative {
  color: var(--text-primary);
}

/* Filtres / Chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.chip {
  padding: 6px 13px;
  border-radius: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip.active {
  background: var(--accent-gold-soft);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Barre de recherche */
.search-bar {
  position: relative;
  margin-bottom: 12px;
}

.search-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 14px 11px 38px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-gold);
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent-gold-grad);
  color: #090C12;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-danger {
  background: var(--accent-danger-soft);
  color: var(--accent-danger);
  border-color: rgba(244, 63, 94, 0.3);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 9px;
}

.btn-block {
  width: 100%;
}

/* Zone de dépôt fichier (Import) */
.dropzone {
  border: 2px dashed rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.04);
  border-radius: var(--radius-lg);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 14px;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.1);
}

.dropzone-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.dropzone-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.dropzone-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Barre de navigation inférieure style iOS */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding: 6px 4px calc(env(safe-area-inset-bottom, 10px) + 4px);
  z-index: 100;
}

@media (min-width: 600px) {
  body.iphone-preview-mode .bottom-nav {
    position: absolute;
    padding-bottom: 18px;
  }
  body:not(.iphone-preview-mode) .bottom-nav {
    max-width: 980px;
    margin: 0 auto;
    border-radius: 20px 20px 0 0;
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
  }
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 2px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s ease, transform 0.12s ease;
}

.nav-item:active {
  transform: scale(0.92);
}

.nav-item.active {
  color: var(--accent-gold);
}

.nav-icon {
  font-size: 19px;
  line-height: 1;
}

.nav-label {
  font-size: 9.8px;
  font-weight: 600;
}

/* Modale iOS Bottom Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(env(safe-area-inset-bottom, 16px) + 16px);
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-backdrop.open .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 99px;
  margin: 0 auto 14px;
}

.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 11px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-gold);
}

/* Toast notification */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1E293B;
  color: #F8FAFC;
  border: 1px solid var(--accent-gold);
  padding: 10px 16px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.25s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   INTÉGRATION GEMINI IA (AUTO-CLASSEMENT & COACH FINANCIER)
   ============================================================================ */
.ai-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(99, 102, 241, 0.18) 100%);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.15);
}

.ai-header-btn:active {
  transform: scale(0.94);
}

.ai-coach-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14) 0%, rgba(245, 158, 11, 0.12) 100%), var(--bg-secondary);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-coach-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-coach-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-coach-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-ai {
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 55%, #F59E0B 100%);
  color: #FFFFFF;
  border: none;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.ai-chat-box {
  max-height: 360px;
  min-height: 180px;
  overflow-y: auto;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.ai-msg {
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  max-width: 92%;
  word-wrap: break-word;
}

.ai-msg-user {
  align-self: flex-end;
  background: var(--accent-gold-grad);
  color: #090C12;
  font-weight: 600;
  border-bottom-right-radius: 4px;
}

.ai-msg-bot {
  align-self: flex-start;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.ai-msg-bot strong {
  color: var(--accent-gold);
}

.ai-classify-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
