:root {
  --bg: #F6F8FB;
  --surface: #FFFFFF;
  --surface-soft: #F8FAFD;
  --border: #EFF1F4;
  --border-strong: #E2E8F0;
  --text: #0F172A;
  --text-strong: #1F1F1F;
  --muted: #64748B;
  --blue: #1A73E8;
  --g-blue: #4285F4;
  --g-red: #EA4335;
  --g-red-dark: #C5221F;
  --g-amber: #FBBC05;
  --g-amber-dark: #B06000;
  --g-green: #34A853;
  --g-green-dark: #137333;
  --g-purple: #9B72CB;
  --g-cyan: #00ACC1;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
}

/* ── Top App Bar ──────────────────────────────────────────────────────────── */
.pb-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  padding: max(10px, env(safe-area-inset-top, 10px)) 14px 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pb-topbar:has(+ .pb-main > .pb-subtabs:first-child) {
  border-bottom: none;
  padding-bottom: 8px;
}

.pb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.pb-topbar-right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pb-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #475569;
  background: #FFFFFF;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 9px;
  cursor: pointer;
}
.pb-sync-pill.syncing {
  color: var(--blue);
  border-color: rgba(26, 115, 232, 0.35);
  background: #EFF6FF;
}
.pb-sync-pill.offline {
  color: var(--g-amber-dark);
  background: #FEF7E0;
  border-color: #FDE68A;
}

.pb-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: #FFFFFF;
  border: 1px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  cursor: pointer;
}
.pb-icon-btn:active { transform: scale(0.95); }

/* ── Main Container ───────────────────────────────────────────────────────── */
.pb-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 13px 16px 13px;
}

/* ── Segmented Subtabs (Style PayPal) ─────────────────────────────────────── */
.pb-subtabs {
  display: flex;
  gap: 4px;
  background: #E9EEF5;
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.pb-subtabs::-webkit-scrollbar { display: none; }

.pb-subtab-btn {
  flex: 1 0 auto;
  border: none;
  background: transparent;
  color: #475569;
  font-family: var(--font);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.pb-subtab-btn.active {
  background: #FFFFFF;
  color: var(--text);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

/* Sous-onglets principaux fusionnés dans le header */
.pb-main > .pb-subtabs:first-child {
  margin: -12px -13px 14px -13px;
  padding: 2px 13px 10px 13px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 0;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}
.pb-main > .pb-subtabs:first-child .pb-subtab-btn.active {
  background: #F1F5F9;
  box-shadow: none;
}

.pb-pill-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--g-red);
  color: #FFFFFF;
  font-size: 0.62rem;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
}

/* ── Cards & Spectral Hero ────────────────────────────────────────────────── */
.pb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.025);
}

.pb-card-click {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.pb-card-click:active {
  transform: scale(0.985);
}

.pb-hero-spectral {
  background: linear-gradient(#FFFFFF, #FFFFFF) padding-box,
              linear-gradient(135deg, #4285F4 0%, #EA4335 30%, #FBBC05 55%, #34A853 75%, #9B72CB 100%) border-box;
  border: 1.5px solid transparent;
  border-radius: 22px;
  padding: 16px 16px 13px 16px;
  margin-bottom: 12px;
  box-shadow: 0 6px 24px -4px rgba(66, 133, 244, 0.12), 0 0 16px rgba(155, 114, 207, 0.08);
}

.pb-hero-spectral-cool {
  background: linear-gradient(#FFFFFF, #FFFFFF) padding-box,
              linear-gradient(135deg, #4285F4 0%, #9B72CB 50%, #34A853 100%) border-box;
  border: 1.5px solid transparent;
  border-radius: 22px;
  padding: 15px 15px 13px 15px;
  margin-bottom: 12px;
  box-shadow: 0 6px 24px -4px rgba(66, 133, 244, 0.12), 0 0 16px rgba(155, 114, 207, 0.08);
}

.pb-section-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 13px 2px 7px 2px;
}
.pb-section-title {
  font-size: 0.74rem;
  font-weight: 800;
  color: #1E293B;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.pb-section-sub {
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--muted);
}

.pb-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pb-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.pb-soft-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 10px;
}
.pb-kpi-lbl {
  font-size: 0.60rem;
  font-weight: 700;
  color: #5F6368;
  text-transform: uppercase;
  letter-spacing: 0.25px;
}
.pb-kpi-val {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--text);
  margin-top: 2px;
}
.pb-kpi-sub {
  font-size: 0.61rem;
  color: var(--muted);
  margin-top: 1px;
}

.pb-progress-track {
  width: 100%;
  height: 7px;
  background: #EFF1F4;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}
.pb-progress-fill { height: 100%; border-radius: 999px; }

.pb-chart-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 11px 11px 9px 11px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}
.pb-chart-wrap {
  position: relative;
  width: 100%;
  height: 215px;
}
.pb-chart-wrap.sm { height: 185px; }
.pb-chart-wrap.lg { height: 240px; }

/* ── Badges & Pills ───────────────────────────────────────────────────────── */
.pb-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
  white-space: nowrap;
}
.pb-badge-green { background: #E6F4EA; color: #137333; }
.pb-badge-red { background: #FCE8E6; color: #C5221F; }
.pb-badge-blue { background: #E8F0FE; color: #1967D2; }
.pb-badge-amber { background: #FEF7E0; color: #B06000; }
.pb-badge-cyan { background: #E4F7FB; color: #007B83; }
.pb-badge-purple { background: rgba(155, 114, 203, 0.14); color: #7C3AED; }
.pb-badge-slate { background: #F1F5F9; color: #475569; }

.pb-chevron {
  color: #94A3B8;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
}

/* ── Forms & Buttons ──────────────────────────────────────────────────────── */
.pb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 0.80rem;
  font-weight: 700;
  padding: 9px 13px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
  color: var(--text);
  cursor: pointer;
  min-height: 38px;
  transition: transform 0.1s, opacity 0.15s;
}
.pb-btn:active { transform: scale(0.97); }
.pb-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.pb-btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #FFFFFF;
}
.pb-btn-success {
  background: #137333;
  border-color: #137333;
  color: #FFFFFF;
}
.pb-btn-danger {
  background: #FCE8E6;
  border-color: #FAD2CF;
  color: #C5221F;
}
.pb-btn-block { width: 100%; }
.pb-btn-sm { min-height: 32px; padding: 5px 10px; font-size: 0.74rem; border-radius: 10px; }

.pb-input, .pb-select {
  width: 100%;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: #F8FAFC;
  border: 1px solid #CBD5E1;
  border-radius: 11px;
  padding: 8px 10px;
  outline: none;
}
.pb-input:focus, .pb-select:focus {
  border-color: var(--blue);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.14);
}
.pb-field-label {
  display: block;
  font-size: 0.67rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* ── Period Pills ─────────────────────────────────────────────────────────── */
.pb-period-row {
  display: inline-flex;
  gap: 5px;
  background: #EEF2F6;
  padding: 3px;
  border-radius: 999px;
}
.pb-period-btn {
  border: none;
  background: transparent;
  color: #475569;
  font-family: var(--font);
  font-size: 0.70rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.pb-period-btn.active {
  background: #FFFFFF;
  color: var(--blue);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ── Micro-pilules temporelles intégrées sous le graphique (style Finary) ─── */
.pb-gf-pills {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
  background: transparent;
  padding: 2px 2px 0 2px;
  margin: -2px 0 10px 0;
  gap: 2px;
}
.pb-gf-pill {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 2px 8px;
  min-height: 24px;
  height: 24px;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748B;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.pb-gf-pill:hover {
  background: rgba(15, 23, 42, 0.04);
  color: #0F172A;
}
.pb-gf-pill.active {
  background: rgba(15, 23, 42, 0.07);
  color: #0F172A;
  font-weight: 700;
}

/* ── Bottom Liquid Glass Tab Bar ──────────────────────────────────────────── */
.pb-bottom-nav {
  position: fixed;
  left: 22px;
  right: 22px;
  bottom: max(12px, env(safe-area-inset-bottom, 12px));
  z-index: 60;
  max-width: 380px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.56);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  border-radius: 999px;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
}

.pb-nav-item {
  position: relative;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: var(--font);
  font-size: 0.62rem;
  font-weight: 600;
  color: #64748B;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}
.pb-nav-item.active {
  background: rgba(15, 23, 42, 0.07);
  color: #0F172A;
  font-weight: 700;
}

.pb-nav-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 17px);
  background: var(--g-red);
  color: #FFFFFF;
  font-size: 0.54rem;
  font-weight: 800;
  min-width: 14px;
  height: 14px;
  padding: 0 3.5px;
  border-radius: 999px;
  border: 1.5px solid #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Gemini Thinking Banner ───────────────────────────────────────────────── */
.gemini-thinking-card {
  border-radius: 16px;
  padding: 1.5px;
  background: linear-gradient(90deg, #4285F4, #9B72CB, #D96570, #F29900, #4285F4);
  background-size: 300% 100%;
  animation: gemShift 2.2s linear infinite;
  margin-bottom: 10px;
}
@keyframes gemShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}
.gemini-thinking-inner {
  background: #FFFFFF;
  border-radius: 14.5px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.gemini-pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4285F4;
  box-shadow: 0 0 0 0 rgba(66, 133, 244, 0.6);
  animation: gemPulse 1.4s infinite;
  flex-shrink: 0;
}
@keyframes gemPulse {
  0% { box-shadow: 0 0 0 0 rgba(66, 133, 244, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(66, 133, 244, 0); }
  100% { box-shadow: 0 0 0 0 rgba(66, 133, 244, 0); }
}

/* ── Bottom Sheet Modal ───────────────────────────────────────────────────── */
.pb-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.pb-modal-backdrop.hidden { display: none; }

.pb-modal-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: #F8FAFC;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 35px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sheetUp 0.18s ease-out;
}
@keyframes sheetUp {
  from { transform: translateY(28px); opacity: 0.7; }
  to { transform: translateY(0); opacity: 1; }
}

.pb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
}
.pb-modal-title {
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--text);
}
.pb-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: #F1F5F9;
  color: #475569;
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
}
.pb-modal-body {
  padding: 14px 14px calc(22px + env(safe-area-inset-bottom, 10px)) 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.pb-toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  background: #0F172A;
  color: #FFFFFF;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 9px 15px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  max-width: 90vw;
  text-align: center;
}
.pb-toast.hidden { display: none; }

/* ── Bank tiles & logos ───────────────────────────────────────────────────── */
.pb-bank-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}
.pb-bank-tile {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.pb-bank-tile.add {
  border-style: dashed;
  border-color: #93C5FD;
  background: #F8FAFF;
  justify-content: center;
  color: var(--blue);
  font-weight: 700;
  font-size: 0.76rem;
}
.pb-logo-img {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  object-fit: contain;
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 1px;
  flex-shrink: 0;
}
.pb-logo-fallback {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: #E8F0FE;
  color: #0B57D0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* ── Skeleton Loader (First Launch before cache) ──────────────────────────── */
.pb-skel {
  background: linear-gradient(90deg, #EEF2F6 25%, #E2E8F0 50%, #EEF2F6 75%);
  background-size: 200% 100%;
  animation: skelAnim 1.2s infinite;
  border-radius: 16px;
}
@keyframes skelAnim {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
