/* ============================================================
   BudgetFlow – Global Stylesheet
   ============================================================ */

/* ── Theme tokens ─────────────────────────────────────────── */
/* Each theme overrides --primary, --primary-dark, --primary-light,
   --primary-rgb, --sidebar-bg, --sidebar-accent               */

/* Default: Blue */
:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --primary-rgb:    37,99,235;
  --sidebar-bg:     #1e293b;
  --sidebar-accent: rgba(37,99,235,.35);
}

/* Green */
[data-theme="green"] {
  --primary:        #059669;
  --primary-dark:   #047857;
  --primary-light:  #d1fae5;
  --primary-rgb:    5,150,105;
  --sidebar-bg:     #064e3b;
  --sidebar-accent: rgba(5,150,105,.4);
}

/* Purple */
[data-theme="purple"] {
  --primary:        #7c3aed;
  --primary-dark:   #6d28d9;
  --primary-light:  #ede9fe;
  --primary-rgb:    124,58,237;
  --sidebar-bg:     #2e1065;
  --sidebar-accent: rgba(124,58,237,.4);
}

/* Rose */
[data-theme="rose"] {
  --primary:        #e11d48;
  --primary-dark:   #be123c;
  --primary-light:  #ffe4e6;
  --primary-rgb:    225,29,72;
  --sidebar-bg:     #4c0519;
  --sidebar-accent: rgba(225,29,72,.4);
}

/* Orange */
[data-theme="orange"] {
  --primary:        #ea580c;
  --primary-dark:   #c2410c;
  --primary-light:  #ffedd5;
  --primary-rgb:    234,88,12;
  --sidebar-bg:     #431407;
  --sidebar-accent: rgba(234,88,12,.4);
}

/* Teal */
[data-theme="teal"] {
  --primary:        #0891b2;
  --primary-dark:   #0e7490;
  --primary-light:  #cffafe;
  --primary-rgb:    8,145,178;
  --sidebar-bg:     #083344;
  --sidebar-accent: rgba(8,145,178,.4);
}

/* Light (white / minimal) */
[data-theme="light"] {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --primary-rgb:    37,99,235;
  --sidebar-bg:     #ffffff;
  --sidebar-accent: rgba(37,99,235,.1);
}

/* Indigo */
[data-theme="indigo"] {
  --primary:        #4f46e5;
  --primary-dark:   #4338ca;
  --primary-light:  #e0e7ff;
  --primary-rgb:    79,70,229;
  --sidebar-bg:     #1e1b4b;
  --sidebar-accent: rgba(79,70,229,.4);
}

/* Amber / Gold */
[data-theme="amber"] {
  --primary:        #d97706;
  --primary-dark:   #b45309;
  --primary-light:  #fef3c7;
  --primary-rgb:    217,119,6;
  --sidebar-bg:     #1c1207;
  --sidebar-accent: rgba(217,119,6,.4);
}

/* Pink / Fuchsia */
[data-theme="pink"] {
  --primary:        #db2777;
  --primary-dark:   #be185d;
  --primary-light:  #fce7f3;
  --primary-rgb:    219,39,119;
  --sidebar-bg:     #500724;
  --sidebar-accent: rgba(219,39,119,.4);
}

/* Slate / Graphite */
[data-theme="slate"] {
  --primary:        #475569;
  --primary-dark:   #334155;
  --primary-light:  #f1f5f9;
  --primary-rgb:    71,85,105;
  --sidebar-bg:     #0f172a;
  --sidebar-accent: rgba(71,85,105,.4);
}

/* Midnight / Deep Navy */
[data-theme="midnight"] {
  --primary:        #3b82f6;
  --primary-dark:   #2563eb;
  --primary-light:  #dbeafe;
  --primary-rgb:    59,130,246;
  --sidebar-bg:     #020617;
  --sidebar-accent: rgba(59,130,246,.4);
}

/* Forest / Deep Green */
[data-theme="forest"] {
  --primary:        #16a34a;
  --primary-dark:   #15803d;
  --primary-light:  #dcfce7;
  --primary-rgb:    22,163,74;
  --sidebar-bg:     #052e16;
  --sidebar-accent: rgba(22,163,74,.4);
}

/* Light theme: sidebar is white so text must be dark */
[data-theme="light"] .app-sidebar {
  border-right: 1px solid #e2e8f0;
}
[data-theme="light"] .sidebar-nav-link {
  color: #334155 !important;
}
[data-theme="light"] .sidebar-nav-link:hover {
  background: rgba(var(--primary-rgb),0.08) !important;
  color: var(--primary) !important;
}
[data-theme="light"] .sidebar-nav-link.active {
  color: var(--primary) !important;
}
[data-theme="light"] .sidebar-divider { border-color: #e2e8f0; }
[data-theme="light"] .sidebar-plan-badge,
[data-theme="light"] .badge-free { color: #64748b; background: #f1f5f9; }
[data-theme="light"] .sidebar-logout { color: rgba(239,68,68,.7) !important; }
[data-theme="light"] .brand-name,
[data-theme="light"] .sidebar-user-name { color: #1e293b !important; }
[data-theme="light"] .sidebar-upgrade { background: rgba(var(--primary-rgb),0.06); }

:root {
  --success:    #10b981;
  --danger:     #ef4444;
  --warning:    #f59e0b;
  --info:       #06b6d4;
  --purple:     #7c3aed;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-500:   #64748b;
  --gray-700:   #334155;
  --gray-900:   #0f172a;

  --sidebar-w:  260px;
  --radius:     12px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow:     0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* ── Base ────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.9375rem;
  color: var(--gray-700);
  background: var(--gray-100);
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  text-decoration: none;
}
.sidebar-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--success));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--gray-900);
}

.sidebar-user {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.sidebar-user-name  { font-weight: 600; font-size: 0.875rem; color: var(--gray-900); }
.sidebar-user-plan  { font-size: 0.75rem; }

.sidebar-nav { padding: 0.75rem 1rem; flex: 1; }

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 0.75rem 0.5rem 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
  margin-bottom: 2px;
}
.sidebar-link:hover { background: var(--gray-100); color: var(--primary); }
.sidebar-link.active { background: #eff6ff; color: var(--primary); font-weight: 600; }
.sidebar-link .sidebar-icon { width: 18px; text-align: center; }
.sidebar-link .lock-icon { margin-left: auto; font-size: 0.7rem; color: var(--gray-500); }
.sidebar-link .badge-count {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  border-radius: 20px;
  padding: 0 6px;
  font-size: 0.7rem;
  min-width: 18px;
  text-align: center;
}

.sidebar-upgrade {
  margin: 1rem;
  padding: 1rem;
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  text-align: center;
}
.sidebar-upgrade h6 { font-size: 0.8rem; font-weight: 700; color: var(--gray-900); margin-bottom: 0.5rem; }
.sidebar-upgrade p  { font-size: 0.75rem; color: var(--gray-500); margin-bottom: 0.75rem; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
}

/* ── Main layout ─────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ─────────────────────────────────────────────── */
.top-bar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1030;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.card-header { border-radius: var(--radius) var(--radius) 0 0 !important; }

/* KPI cards */
.kpi-card { transition: transform 0.15s; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow) !important; }

/* Wallet cards */
.wallet-card { border-left-width: 4px !important; border-left-style: solid !important; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { border-radius: 8px; font-weight: 500; transition: all 0.15s; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: transparent;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(var(--primary-rgb),0.35); border-color: transparent; }

/* ── Forms ───────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: 8px;
  border-color: var(--gray-200);
  font-size: 0.9rem;
  padding: 0.55rem 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.1);
}

/* ── Tables ──────────────────────────────────────────────── */
.table th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  border-bottom-width: 1px;
  padding: 0.75rem 1rem;
}
.table td { padding: 0.875rem 1rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: rgba(var(--primary-rgb),0.025); }

/* ── Progress bars ───────────────────────────────────────── */
.progress { background: var(--gray-200); border-radius: 20px; }
.progress-bar { border-radius: 20px; transition: width 0.6s ease; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { font-weight: 500; letter-spacing: 0.02em; }
.bg-purple { background-color: var(--purple) !important; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  border: none;
  box-shadow: var(--shadow-sm);
}

/* ── Modals ──────────────────────────────────────────────── */
.modal-content {
  border-radius: 16px;
  border: none;
}
.modal-backdrop.show { opacity: 0.4; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination .page-link {
  border-radius: 6px !important;
  font-size: 0.85rem;
  color: var(--primary);
  border-color: var(--gray-200);
}
.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}

/* ── Dropdown ────────────────────────────────────────────── */
.dropdown-menu {
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
}
.dropdown-item { padding: 0.5rem 1rem; border-radius: 6px; }
.dropdown-item:hover { background: var(--gray-100); }

/* ── Dark mode — global Bootstrap overrides ──────────────── */
body.dark-mode {
    background: #0f172a;
    color: #cbd5e1;
}

/* Layout */
body.dark-mode .main-wrapper,
body.dark-mode .page-content        { background: #0f172a; }

/* Bootstrap cards */
body.dark-mode .card                { background: #1e293b; border-color: #334155; color: #cbd5e1; }
body.dark-mode .card-header         { background: #1a2436; border-color: #334155; color: #f1f5f9; }
body.dark-mode .card-footer         { background: #1a2436; border-color: #334155; }

/* Bootstrap tables */
body.dark-mode .table               { color: #cbd5e1; --bs-table-color: #cbd5e1; --bs-table-bg: transparent; --bs-table-border-color: #293548; }
body.dark-mode .table th,
body.dark-mode .table thead th      { background: #1a2436 !important; color: #64748b !important; border-color: #334155 !important; }
body.dark-mode .table td            { background-color: transparent !important; border-color: #293548 !important; color: #cbd5e1 !important; }
body.dark-mode .table tbody tr      { background-color: transparent !important; }
body.dark-mode .table-light,
body.dark-mode .table-light > * > tr > th,
body.dark-mode .table-light > * > tr > td { --bs-table-bg: #1a2436; background-color: #1a2436 !important; color: #64748b !important; border-color: #334155 !important; }
body.dark-mode .table-hover tbody tr:hover,
body.dark-mode .table-hover tbody tr:hover td { background-color: #243044 !important; }
body.dark-mode .table-striped tbody tr:nth-of-type(odd) td { background: rgba(255,255,255,.02) !important; }

/* Backgrounds utilitaires */
body.dark-mode .bg-white            { background: #1e293b !important; }
body.dark-mode .bg-light            { background: #1a2436 !important; }
body.dark-mode .bg-body             { background: #0f172a !important; }

/* Borders */
body.dark-mode .border              { border-color: #334155 !important; }
body.dark-mode .border-top          { border-top-color: #334155 !important; }
body.dark-mode .border-bottom       { border-bottom-color: #334155 !important; }
body.dark-mode .border-start        { border-left-color: #334155 !important; }
body.dark-mode .border-end          { border-right-color: #334155 !important; }

/* Text */
body.dark-mode .text-dark           { color: #f1f5f9 !important; }
body.dark-mode .text-muted          { color: #64748b !important; }
body.dark-mode .text-body           { color: #cbd5e1 !important; }

/* Forms */
body.dark-mode .form-control,
body.dark-mode .form-select         { background: #273348; border-color: #334155; color: #e2e8f0; }
body.dark-mode .form-control::placeholder { color: #64748b; }
body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus   { background: #1e293b; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
body.dark-mode .form-label          { color: #94a3b8; }
body.dark-mode .input-group-text    { background: #273348; border-color: #334155; color: #94a3b8; }

/* Buttons */
body.dark-mode .btn-light           { background: #273348; border-color: #334155; color: #e2e8f0; }
body.dark-mode .btn-light:hover     { background: #334155; }
body.dark-mode .btn-outline-secondary { border-color: #475569; color: #94a3b8; }
body.dark-mode .btn-outline-secondary:hover { background: #334155; color: #e2e8f0; border-color: #64748b; }
body.dark-mode .btn-close           { filter: invert(1) brightness(.8); }

/* Modals */
body.dark-mode .modal-content       { background: #1e293b; color: #e2e8f0; border-color: #334155; }
body.dark-mode .modal-header        { border-color: #334155; }
body.dark-mode .modal-footer        { border-color: #334155; }

/* Dropdowns */
body.dark-mode .dropdown-menu       { background: #1e293b; border-color: #334155; }
body.dark-mode .dropdown-item       { color: #cbd5e1; }
body.dark-mode .dropdown-item:hover { background: #273348; color: #f1f5f9; }
body.dark-mode .dropdown-divider    { border-color: #334155; }

/* Badges */
body.dark-mode .badge.bg-light      { background: #334155 !important; color: #94a3b8 !important; }
body.dark-mode .badge.text-bg-light { background: #334155 !important; color: #94a3b8 !important; }

/* Nav tabs */
body.dark-mode .nav-tabs            { border-color: #334155; }
body.dark-mode .nav-tabs .nav-link  { color: #94a3b8; }
body.dark-mode .nav-tabs .nav-link.active { background: #1e293b; border-color: #334155 #334155 #1e293b; color: #f1f5f9; }

/* List groups */
body.dark-mode .list-group-item     { background: #1e293b; border-color: #334155; color: #cbd5e1; }

/* Pagination */
body.dark-mode .page-link           { background: #1e293b; border-color: #334155; color: #94a3b8; }
body.dark-mode .page-item.active .page-link { background: #6366f1; border-color: #6366f1; }

/* Alerts */
body.dark-mode .alert-warning       { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: #fcd34d; }
body.dark-mode .alert-danger        { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.3); color: #fca5a5; }
body.dark-mode .alert-success       { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.3); color: #6ee7b7; }
body.dark-mode .alert-info          { background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.3); color: #93c5fd; }

/* Sidebar legacy */
body.dark-mode .sidebar,
body.dark-mode .top-bar             { background: #1e293b; border-color: #334155; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .top-bar .hamburger-btn { display: flex !important; }
}

/* ── Mobile global improvements ─────────────────────────── */
@media (max-width: 767.98px) {
  /* Touch targets — minimum 44px for all interactive controls */
  .form-control,
  .form-select,
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* Reduce card inner padding on small screens */
  .card-body { padding: 1rem; }

  /* Page content horizontal padding reduction */
  .container-fluid { padding-left: .875rem; padding-right: .875rem; }

  /* Topbar: hide language selector (accessible from sidebar) */
  .topbar-lang-hide { display: none !important; }

  /* Tables: visual scroll hint */
  .table-responsive::after {
    content: '';
    display: block;
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,.8));
    pointer-events: none;
  }
  .table-responsive { position: relative; }

  /* Page title smaller on mobile */
  .topbar-title { font-size: .875rem !important; }

  /* Reduce gap in flex layouts */
  .d-flex.gap-3 { gap: .75rem !important; }
  .d-flex.gap-4 { gap: 1rem !important; }
}

/* ── App-wide mobile bottom nav ──────────────────────────── */
.app-mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  z-index: 1055;
  align-items: stretch;
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
@media (max-width: 767.98px) { .app-mobile-nav { display: flex; } }
.app-mobile-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  text-decoration: none;
  font-size: .58rem;
  font-weight: 600;
  gap: 3px;
  position: relative;
  transition: color .15s;
}
.app-mobile-nav a i { font-size: 1.05rem; }
.app-mobile-nav a.active { color: var(--primary); }
.app-mobile-nav a:hover  { color: var(--primary); }
.app-mobile-nav a.active::before {
  content: '';
  position: absolute;
  top: 0; left: 15%; right: 15%;
  height: 2px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}
/* Center "+" button */
.app-mobile-nav .nav-add-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff !important;
  margin: auto;
  box-shadow: 0 3px 12px rgba(var(--primary-rgb),.4);
  font-size: 1.25rem !important;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
}
.app-mobile-nav .nav-add-btn:hover { transform: scale(1.1); }
body.dark-mode .app-mobile-nav {
  background: #1e293b;
  border-color: #334155;
}
body.dark-mode .app-mobile-nav a { color: #64748b; }
body.dark-mode .app-mobile-nav a.active,
body.dark-mode .app-mobile-nav a:hover { color: #818cf8; }
body.dark-mode .app-mobile-nav a.active::before { background: #818cf8; }

/* ── Page-level mobile bottom nav — mobile uniquement, style admin ── */
.page-mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: #0f172a;
    border-top: 1px solid rgba(255,255,255,.07);
    z-index: 1055;
    align-items: stretch;
}
@media (max-width: 767.98px) {
    .page-mobile-nav { display: flex; }
    body { padding-bottom: 68px; }
}
.page-mobile-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.38);
    text-decoration: none;
    font-size: .6rem;
    font-weight: 600;
    gap: 3px;
    position: relative;
    transition: color .15s;
}
.page-mobile-nav a i { font-size: 1.1rem; }
.page-mobile-nav a.active,
.page-mobile-nav a:hover { color: #818cf8; }
.page-mobile-nav a.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: #818cf8;
    border-radius: 0 0 3px 3px;
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.35s ease both; }

@keyframes countUp {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* ── Font Awesome — protection anti-écrasement RTL ──────── */
i.fas, i.far, i.fa, i.fa-solid, i.fa-regular, i.fa-classic,
i[class*="fa-"] {
    font-family: "Font Awesome 6 Free" !important;
    font-style: normal !important;
    letter-spacing: normal !important;
}
i.fab, i.fa-brands {
    font-family: "Font Awesome 6 Brands" !important;
    font-style: normal !important;
    letter-spacing: normal !important;
}

/* ── Print styles ────────────────────────────────────────── */
@media print {
  .sidebar, .top-bar, .btn, .modal, nav { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ── Utility helpers ─────────────────────────────────────── */
.text-purple  { color: var(--purple) !important; }
.bg-gradient-primary { background: linear-gradient(135deg, var(--primary), var(--success)); }
.cursor-pointer { cursor: pointer; }
.hover-shadow:hover { box-shadow: var(--shadow) !important; transition: box-shadow 0.2s; }
.border-primary-soft { border: 1.5px solid rgba(var(--primary-rgb),0.3); }

/* ============================================================
   App Sidebar (dark theme) — matches sidebar.php HTML structure
   ============================================================ */
.app-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* ── Overlay (mobile) ─────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1039;
  cursor: pointer;
}
.sidebar-overlay.show { display: block; }
body.sidebar-is-open  { overflow: hidden; }

/* ── Plan badges ──────────────────────────────────────────── */
.sidebar-plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-free    { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.65); }
.badge-premium { background: rgba(245,158,11,0.25);  color: #fbbf24; }
.badge-family  { background: rgba(124,58,237,0.25);  color: #a78bfa; }
.badge-pro     { background: rgba(14,165,233,0.25);  color: #38bdf8; }

/* ── Sidebar nav links ────────────────────────────────────── */
.sidebar-nav-link {
  color: rgba(255,255,255,0.65) !important;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav-link:hover {
  background: rgba(255,255,255,0.07) !important;
  color: #fff !important;
}
.sidebar-nav-link.active {
  background: var(--sidebar-accent) !important;
  color: #fff !important;
  font-weight: 600;
}
.sidebar-nav-link.locked { opacity: 0.55; }
.sidebar-ai-link { background: rgba(99,102,241,.15) !important; }
.sidebar-ai-link:hover { background: rgba(99,102,241,.28) !important; }
.sidebar-ai-link .nav-icon { color: #a5b4fc !important; }
.sidebar-ai-link .nav-label { color: #c4b5fd !important; font-weight: 600; }
.sidebar-gm-link { background: rgba(245,158,11,.12) !important; }
.sidebar-gm-link:hover { background: rgba(245,158,11,.22) !important; }
.sidebar-gm-link .nav-icon { color: #fcd34d !important; }
.sidebar-gm-link .nav-label { color: #fde68a !important; font-weight: 600; }
.sidebar-logout { color: rgba(239,68,68,0.75) !important; }
.sidebar-logout:hover {
  background: rgba(239,68,68,0.12) !important;
  color: #ef4444 !important;
}

/* ── Sidebar upgrade banner ───────────────────────────────── */
.sidebar-upgrade {
  background: linear-gradient(135deg, rgba(37,99,235,0.25), rgba(16,185,129,0.15)) !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
}

/* ── Main content area ────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gray-100);
  transition: margin-left 0.3s ease;
}

/* ── Desktop sidebar collapse ─────────────────────────────── */
@media (min-width: 992px) {
  body.sidebar-collapsed .app-sidebar  { transform: translateX(-100%); }
  body.sidebar-collapsed .main-content { margin-left: 0; }
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.topbar-title { font-size: 1rem; color: var(--gray-900); }

/* ── Flash container ──────────────────────────────────────── */
.flash-container .alert { margin-bottom: 0; }

/* ── Page content ─────────────────────────────────────────── */
.page-content { flex: 1; }

/* ── Mobile responsive ────────────────────────────────────── */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  .main-content {
    margin-left: 0;
  }
}

/* ── Dark mode additions ──────────────────────────────────── */
body.dark-mode .topbar              { background: #1e293b; border-color: #334155; }
body.dark-mode .topbar-title        { color: #f1f5f9; }
body.dark-mode .topbar .btn-outline-secondary { color: #94a3b8; border-color: #334155; }
body.dark-mode .topbar .btn-outline-secondary:hover { background: #334155; color: #e2e8f0; }
body.dark-mode .main-content        { background: #0f172a; }
body.dark-mode .page-content .text-dark { color: #f1f5f9 !important; }

/* ============================================================
   MODERN GRID SYSTEM — BudgetFlow SaaS
   ============================================================ */

/* ── CSS Grid utilities ────────────────────────────────────── */
.bf-grid          { display: grid; gap: 1.25rem; }
.bf-grid-1        { grid-template-columns: 1fr; }
.bf-grid-2        { grid-template-columns: repeat(2, 1fr); }
.bf-grid-3        { grid-template-columns: repeat(3, 1fr); }
.bf-grid-4        { grid-template-columns: repeat(4, 1fr); }
.bf-grid-auto     { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.bf-grid-auto-sm  { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.bf-grid-auto-lg  { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

/* KPI bar — 4 equal columns, wraps at 2 on tablet */
.bf-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

/* Content + sidebar split */
.bf-layout-main-aside {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
  align-items: start;
}
.bf-layout-aside-main {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* ── Responsive grid breakpoints ────────────────────────────── */
@media (max-width: 1199.98px) {
  .bf-grid-4      { grid-template-columns: repeat(2, 1fr); }
  .bf-kpi-grid    { grid-template-columns: repeat(2, 1fr); }
  .bf-layout-main-aside,
  .bf-layout-aside-main { grid-template-columns: 1fr; }
}
@media (max-width: 767.98px) {
  .bf-grid-2,
  .bf-grid-3,
  .bf-grid-4      { grid-template-columns: 1fr; }
  .bf-kpi-grid    { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .bf-grid        { gap: .875rem; }
}
@media (max-width: 479px) {
  .bf-kpi-grid    { grid-template-columns: 1fr; }
}

/* ── Page header (standard across all pages) ────────────────── */
.bf-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.bf-page-header-left   { display: flex; flex-direction: column; gap: .2rem; }
.bf-page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.02em;
  line-height: 1.2;
}
.bf-page-subtitle {
  font-size: .825rem;
  color: var(--gray-500);
  line-height: 1.4;
}
.bf-page-actions {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-wrap: wrap;
}
@media (max-width: 575.98px) {
  .bf-page-title   { font-size: 1.1rem; }
  .bf-page-actions { width: 100%; justify-content: flex-start; }
}

/* ── Modern stat card (replaces legacy .kpi-card) ───────────── */
.bf-stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  padding: 1.25rem 1.375rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.bf-stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.bf-stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 14px 14px 0 0;
}
.bf-stat-card.accent-green::before   { background: linear-gradient(90deg,#10b981,#34d399); }
.bf-stat-card.accent-red::before     { background: linear-gradient(90deg,#ef4444,#f87171); }
.bf-stat-card.accent-blue::before    { background: linear-gradient(90deg,#2563eb,#60a5fa); }
.bf-stat-card.accent-purple::before  { background: linear-gradient(90deg,#7c3aed,#a78bfa); }
.bf-stat-card.accent-amber::before   { background: linear-gradient(90deg,#f59e0b,#fbbf24); }
.bf-stat-card.accent-teal::before    { background: linear-gradient(90deg,#0891b2,#22d3ee); }

.bf-stat-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gray-500);
  margin-bottom: .35rem;
}
.bf-stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.1;
  letter-spacing: -.03em;
}
.bf-stat-meta {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: .4rem;
  font-size: .78rem;
  color: var(--gray-500);
}
.bf-stat-meta .up   { color: #10b981; font-weight: 600; }
.bf-stat-meta .down { color: #ef4444; font-weight: 600; }
.bf-stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Dark mode stat cards */
body.dark-mode .bf-stat-card {
  background: #1e293b;
  border-color: #334155;
}
body.dark-mode .bf-stat-value { color: #f1f5f9; }
body.dark-mode .bf-stat-label { color: #64748b; }

/* ── Section card (standard content container) ──────────────── */
.bf-section {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.bf-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.375rem;
  border-bottom: 1px solid var(--gray-100);
}
.bf-section-title {
  font-size: .925rem;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.bf-section-title .icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
}
.bf-section-body    { padding: 1.25rem 1.375rem; }
.bf-section-footer  {
  padding: .875rem 1.375rem;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  font-size: .825rem;
}

body.dark-mode .bf-section         { background: #1e293b; border-color: #334155; }
body.dark-mode .bf-section-header  { border-color: #334155; }
body.dark-mode .bf-section-title   { color: #f1f5f9; }
body.dark-mode .bf-section-footer  { background: #1a2436; border-color: #334155; }

/* ── Empty state component ──────────────────────────────────── */
.bf-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  gap: 1rem;
}
.bf-empty-icon {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  color: var(--gray-500);
}
.bf-empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-700);
  margin: 0;
}
.bf-empty-text {
  font-size: .875rem;
  color: var(--gray-500);
  margin: 0;
  max-width: 320px;
  line-height: 1.6;
}
body.dark-mode .bf-empty-icon  { background: #273348; color: #64748b; }
body.dark-mode .bf-empty-title { color: #e2e8f0; }
body.dark-mode .bf-empty-text  { color: #64748b; }

/* ── Skeleton loader ────────────────────────────────────────── */
@keyframes bf-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.bf-skeleton {
  background: linear-gradient(90deg,
    var(--gray-200) 25%,
    var(--gray-100) 37%,
    var(--gray-200) 63%);
  background-size: 400px 100%;
  animation: bf-shimmer 1.4s ease infinite;
  border-radius: 6px;
}
body.dark-mode .bf-skeleton {
  background: linear-gradient(90deg,
    #273348 25%,
    #1e293b 37%,
    #273348 63%);
  background-size: 400px 100%;
}

/* ── Tag/pill chips (tx-tag-pill, general) ──────────────────── */
.bf-tag {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.bf-tag-primary { background: rgba(var(--primary-rgb),.12); color: var(--primary); }
.bf-tag-success { background: rgba(16,185,129,.12); color: #059669; }
.bf-tag-danger  { background: rgba(239,68,68,.12); color: #dc2626; }
.bf-tag-warning { background: rgba(245,158,11,.12); color: #d97706; }
.bf-tag-muted   { background: var(--gray-100); color: var(--gray-500); }
body.dark-mode .bf-tag-muted { background: #273348; color: #94a3b8; }

/* ── Progress bar (improved) ────────────────────────────────── */
.bf-progress {
  height: 8px;
  background: var(--gray-200);
  border-radius: 20px;
  overflow: hidden;
}
.bf-progress-bar {
  height: 100%;
  border-radius: 20px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.bf-progress.thin  { height: 5px; }
.bf-progress.thick { height: 12px; }
body.dark-mode .bf-progress { background: #334155; }

/* ── List rows (transactions, items) ────────────────────────── */
.bf-list-row {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .8rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  transition: background .12s;
}
.bf-list-row:last-child { border-bottom: none; }
.bf-list-row:hover { background: var(--gray-50); }
body.dark-mode .bf-list-row { border-color: #293548; }
body.dark-mode .bf-list-row:hover { background: #243044; }

/* ── Avatar icon (category, wallet, etc.) ───────────────────── */
.bf-avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
}
.bf-avatar-sm { width: 32px; height: 32px; border-radius: 8px; font-size: .75rem; }
.bf-avatar-lg { width: 48px; height: 48px; border-radius: 12px; font-size: 1.1rem; }

/* ── Status dots ────────────────────────────────────────────── */
.bf-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bf-dot-success { background: #10b981; }
.bf-dot-danger  { background: #ef4444; }
.bf-dot-warning { background: #f59e0b; }
.bf-dot-muted   { background: #94a3b8; }
.bf-dot-blue    { background: #2563eb; }

/* ── Inline action buttons ──────────────────────────────────── */
.bf-action-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem;
  color: var(--gray-500);
  cursor: pointer;
  transition: all .15s;
}
.bf-action-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.bf-action-btn.danger:hover { background: #fef2f2; color: #ef4444; border-color: #fecaca; }
body.dark-mode .bf-action-btn {
  background: #273348; border-color: #334155; color: #94a3b8;
}
body.dark-mode .bf-action-btn:hover { background: #334155; color: #e2e8f0; }

/* ── Divider with label ─────────────────────────────────────── */
.bf-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0;
  color: var(--gray-500);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.bf-divider::before,
.bf-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}
body.dark-mode .bf-divider::before,
body.dark-mode .bf-divider::after { background: #334155; }

/* ── Topbar filter bar (toolbar below topbar) ───────────────── */
.bf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: .7rem 1.125rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
body.dark-mode .bf-toolbar { background: #1e293b; border-color: #334155; }

/* ── Month navigator ────────────────────────────────────────── */
.bf-month-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.bf-month-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  color: var(--gray-500);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.bf-month-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.bf-month-label {
  font-weight: 700;
  font-size: .9rem;
  color: var(--gray-900);
  min-width: 140px;
  text-align: center;
}
body.dark-mode .bf-month-btn  { background: #273348; border-color: #334155; color: #94a3b8; }
body.dark-mode .bf-month-label { color: #f1f5f9; }


/* ── Toast notifications (in-page) ─────────────────────────── */
.bf-toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.bf-toast {
  min-width: 240px;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: .85rem 1.125rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  pointer-events: all;
  animation: bf-toast-in .25s ease;
}
@keyframes bf-toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
.bf-toast.success { border-left: 4px solid #10b981; }
.bf-toast.error   { border-left: 4px solid #ef4444; }
.bf-toast.warning { border-left: 4px solid #f59e0b; }
.bf-toast.info    { border-left: 4px solid #2563eb; }
body.dark-mode .bf-toast { background: #1e293b; border-color: #334155; color: #e2e8f0; }

/* ── Responsive helpers ─────────────────────────────────────── */
.bf-hide-mobile { }
.bf-show-mobile { display: none !important; }
@media (max-width: 767.98px) {
  .bf-hide-mobile { display: none !important; }
  .bf-show-mobile { display: block !important; }
}

/* ── Page content padding fix (accounts for mobile nav) ─────── */
@media (max-width: 767.98px) {
  .page-content { padding-bottom: 1rem; }
}

/* ── Improved form label ────────────────────────────────────── */
.bf-label {
  font-size: .825rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .4rem;
}
.bf-label-opt { font-weight: 400; color: var(--gray-500); font-size: .75rem; }
body.dark-mode .bf-label { color: #94a3b8; }

/* ── Card hover glow (premium feel) ────────────────────────── */
.bf-hover-glow:hover {
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.15), var(--shadow-lg) !important;
}

/* ── Gradient text ──────────────────────────────────────────── */
.bf-text-gradient {
  background: linear-gradient(135deg, var(--primary), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Number input spinner fix ───────────────────────────────── */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: .5;
}

/* ── Focus ring — accessible ────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
  outline: none;
}

/* ── Table improvements ─────────────────────────────────────── */
.bf-table { width: 100%; border-collapse: collapse; }
.bf-table th {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  white-space: nowrap;
}
.bf-table td {
  padding: .8rem 1rem;
  font-size: .875rem;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.bf-table tbody tr:last-child td { border-bottom: none; }
.bf-table tbody tr:hover td { background: rgba(var(--primary-rgb),.025); }
body.dark-mode .bf-table th { background: #1a2436; color: #64748b; border-color: #334155; }
body.dark-mode .bf-table td { color: #cbd5e1; border-color: #293548; }
body.dark-mode .bf-table tbody tr:hover td { background: #243044; }

/* ── Scroll area (overflow-x on mobile) ─────────────────────── */
.bf-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Section gap ────────────────────────────────────────────── */
.bf-gap-sm { gap: .75rem !important; }
.bf-gap-md { gap: 1.25rem !important; }
.bf-gap-lg { gap: 2rem !important; }

/* ── Inline stat inline with icon ───────────────────────────── */
.bf-inline-stat {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .825rem;
  font-weight: 600;
  color: var(--gray-700);
}
.bf-inline-stat.up   { color: #10b981; }
.bf-inline-stat.down { color: #ef4444; }
.bf-inline-stat.neutral { color: var(--gray-500); }
body.dark-mode .bf-inline-stat { color: #94a3b8; }

/* ── Premium feature badge ──────────────────────────────────── */
.bf-premium-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .15rem .5rem;
  border-radius: 6px;
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: linear-gradient(135deg,#f59e0b,#d97706);
  color: #fff;
}

/* ── Smooth page transitions ────────────────────────────────── */
.page-content {
  animation: bf-page-in .25s ease;
}
@keyframes bf-page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Print: hide UI chrome ──────────────────────────────────── */
@media print {
  .app-sidebar, .topbar, .app-mobile-nav,
  .bf-toolbar, .page-fab,
  .btn-primary, .btn-outline-primary,
  .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .bf-stat-card, .bf-section { box-shadow: none !important; border: 1px solid #ddd !important; }
  body { background: #fff !important; }
  .bf-amount { filter: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   B1 DESIGN SYSTEM — global (extracted from budgets.php)
═══════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ───────────────────────────────────── */
:root {
    --b1-bg:        #f1f5f9;
    --b1-card:      #ffffff;
    --b1-card-2:    #f8fafc;
    --b1-border:    rgba(15,23,42,.08);
    --b1-border-2:  rgba(15,23,42,.05);
    --b1-text:      #0f172a;
    --b1-text2:     #64748b;
    --b1-text3:     #94a3b8;
    --b1-blue:      #2563eb;
    --b1-blue-bg:   #eff6ff;
    --b1-violet:    #7c3aed;
    --b1-violet-bg: #f5f3ff;
    --b1-green:     #10b981;
    --b1-green-bg:  #ecfdf5;
    --b1-red:       #ef4444;
    --b1-red-bg:    #fef2f2;
    --b1-amber:     #f59e0b;
    --b1-amber-bg:  #fffbeb;
    --b1-r:         14px;
    --b1-r-sm:      9px;
    --b1-r-xs:      6px;
    --b1-sh:        0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --b1-sh-md:     0 4px 24px rgba(0,0,0,.07), 0 2px 8px rgba(0,0,0,.04);
    --b1-sh-lg:     0 12px 40px rgba(0,0,0,.1),  0 4px 16px rgba(0,0,0,.06);
    --b1-font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --b1-transition: all .18s cubic-bezier(.4,0,.2,1);
}

body.dark-mode {
    --b1-bg:        #0a0f1e;
    --b1-card:      #111827;
    --b1-card-2:    #0f172a;
    --b1-border:    rgba(255,255,255,.07);
    --b1-border-2:  rgba(255,255,255,.04);
    --b1-text:      #f1f5f9;
    --b1-text2:     #94a3b8;
    --b1-text3:     #475569;
    --b1-blue-bg:   rgba(37,99,235,.12);
    --b1-violet-bg: rgba(124,58,237,.12);
    --b1-green-bg:  rgba(16,185,129,.12);
    --b1-red-bg:    rgba(239,68,68,.12);
    --b1-amber-bg:  rgba(245,158,11,.12);
    --b1-sh:        0 1px 3px rgba(0,0,0,.3),  0 1px 2px rgba(0,0,0,.2);
    --b1-sh-md:     0 4px 24px rgba(0,0,0,.3),  0 2px 8px rgba(0,0,0,.2);
    --b1-sh-lg:     0 12px 40px rgba(0,0,0,.4),  0 4px 16px rgba(0,0,0,.25);
}

/* ── Base ─────────────────────────────────────────────────────── */
.b1-wrap * { font-family: var(--b1-font); box-sizing: border-box; }

.b1-wrap {
    background: var(--b1-bg);
    min-height: calc(100vh - 60px);
    padding: 1.75rem 1.5rem 5rem;
    transition: background .2s;
}

/* ── Page Header ─────────────────────────────────────────────── */
.b1-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}
.b1-breadcrumb {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .72rem;
    font-weight: 500;
    color: var(--b1-text3);
    margin-bottom: .35rem;
    letter-spacing: .02em;
}
.b1-breadcrumb a { color: var(--b1-text3); text-decoration: none; transition: color .15s; }
.b1-breadcrumb a:hover { color: var(--b1-blue); }
.b1-breadcrumb .sep { opacity: .4; }
.b1-page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--b1-text);
    letter-spacing: -.03em;
    line-height: 1.2;
    margin: 0 0 .2rem;
}
.b1-page-sub {
    font-size: .8rem;
    color: var(--b1-text2);
    font-weight: 400;
}
.b1-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.b1-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--b1-r-sm);
    font-size: .82rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--b1-transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}
.b1-btn-primary {
    background: var(--b1-blue);
    color: #fff;
    border-color: var(--b1-blue);
    box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
.b1-btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
    transform: translateY(-1px);
    color: #fff;
}
.b1-btn-ghost {
    background: var(--b1-card);
    color: var(--b1-text2);
    border-color: var(--b1-border);
    box-shadow: var(--b1-sh);
}
.b1-btn-ghost:hover {
    background: var(--b1-card-2);
    border-color: rgba(37,99,235,.3);
    color: var(--b1-blue);
}
.b1-btn-danger-ghost {
    background: transparent;
    color: var(--b1-red);
    border-color: transparent;
}
.b1-btn-danger-ghost:hover {
    background: var(--b1-red-bg);
    border-color: rgba(239,68,68,.2);
}
.b1-btn-icon {
    padding: .45rem .6rem;
    border-radius: var(--b1-r-xs);
}

/* ── Month Nav ───────────────────────────────────────────────── */
.b1-month-nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    background: var(--b1-card);
    border: 1px solid var(--b1-border);
    border-radius: var(--b1-r-sm);
    padding: .25rem .3rem;
    box-shadow: var(--b1-sh);
}
.b1-month-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--b1-r-xs);
    color: var(--b1-text2);
    text-decoration: none;
    font-size: .78rem;
    transition: var(--b1-transition);
}
.b1-month-nav a:hover {
    background: var(--b1-blue-bg);
    color: var(--b1-blue);
}
.b1-month-nav span {
    font-size: .82rem;
    font-weight: 700;
    color: var(--b1-text);
    padding: 0 .6rem;
    min-width: 120px;
    text-align: center;
}

/* ── Score Ring Pill ─────────────────────────────────────────── */
.b1-adh-pill {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    background: var(--b1-card);
    border: 1px solid var(--b1-border);
    border-radius: 20px;
    padding: .3rem .8rem .3rem .35rem;
    font-size: .75rem;
    font-weight: 700;
    box-shadow: var(--b1-sh);
}

/* ── Flash Alerts ────────────────────────────────────────────── */
.b1-flash {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1.1rem;
    border-radius: var(--b1-r-sm);
    font-size: .84rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
    animation: b1FadeIn .3s ease;
}
.b1-flash-success { background: var(--b1-green-bg); color: #065f46; border-color: rgba(16,185,129,.25); }
.b1-flash-danger  { background: var(--b1-red-bg);   color: #991b1b; border-color: rgba(239,68,68,.25); }
.b1-flash-info    { background: var(--b1-blue-bg);   color: #1e40af; border-color: rgba(37,99,235,.25); }
.b1-flash-warning { background: var(--b1-amber-bg);  color: #92400e; border-color: rgba(245,158,11,.25); }
.b1-flash-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: .5;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    transition: opacity .15s;
}
.b1-flash-close:hover { opacity: 1; }

/* ── Daily Rhythm Band ───────────────────────────────────────── */
.b1-band {
    background: var(--b1-card);
    border: 1px solid var(--b1-border);
    border-radius: var(--b1-r);
    padding: 1rem 1.4rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--b1-sh);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}
.b1-band::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #a78bfa);
    border-radius: var(--b1-r) var(--b1-r) 0 0;
}
.b1-band-label {
    font-size: .75rem;
    font-weight: 700;
    color: var(--b1-text2);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: .35rem;
}
.b1-band-track {
    flex: 1;
    min-width: 120px;
    height: 7px;
    border-radius: 4px;
    background: var(--b1-border);
    overflow: hidden;
}
.b1-band-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    transition: width .6s ease;
}
.b1-band-stat {
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--b1-text2);
}
.b1-band-vs { color: var(--b1-text3); font-size: .72rem; }

/* ── KPI Cards Grid ──────────────────────────────────────────── */
.b1-kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 1400px) { .b1-kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .b1-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .b1-kpi-grid { grid-template-columns: 1fr; } }

.b1-kpi-card {
    background: var(--b1-card);
    border: 1px solid var(--b1-border);
    border-radius: var(--b1-r);
    padding: 1.2rem 1.25rem 1.1rem;
    box-shadow: var(--b1-sh);
    transition: var(--b1-transition);
    position: relative;
    overflow: hidden;
}
.b1-kpi-card:hover {
    box-shadow: var(--b1-sh-md);
    transform: translateY(-2px);
    border-color: rgba(37,99,235,.15);
}
.b1-kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--kpi-accent, #2563eb);
    border-radius: var(--b1-r) var(--b1-r) 0 0;
    opacity: 0;
    transition: opacity .2s;
}
.b1-kpi-card:hover::after { opacity: 1; }

.b1-kpi-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: .8rem;
}
.b1-kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
}
.b1-kpi-label {
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--b1-text3);
    margin-bottom: .3rem;
}
.b1-kpi-value {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--b1-text);
    letter-spacing: -.03em;
    line-height: 1.1;
}
.b1-kpi-delta {
    font-size: .7rem;
    font-weight: 600;
    margin-top: .3rem;
    display: flex;
    align-items: center;
    gap: .2rem;
}

/* Global usage card */
.b1-global-card {
    background: var(--b1-card);
    border: 1px solid var(--b1-border);
    border-radius: var(--b1-r);
    padding: 1.2rem 1.4rem;
    box-shadow: var(--b1-sh);
    margin-bottom: 1.5rem;
    transition: var(--b1-transition);
}
.b1-global-card:hover { box-shadow: var(--b1-sh-md); }
.b1-global-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .75rem;
}
.b1-global-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--b1-text2);
    display: flex;
    align-items: center;
    gap: .4rem;
}
.b1-global-pct {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -.02em;
}
.b1-global-bar-track {
    height: 10px;
    border-radius: 6px;
    background: var(--b1-border);
    overflow: hidden;
    margin-bottom: .6rem;
}
.b1-global-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width .6s ease;
}
.b1-global-sub {
    font-size: .72rem;
    color: var(--b1-text3);
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}

/* ── Analytics Section ───────────────────────────────────────── */
.b1-analytics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 1280px) { .b1-analytics { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .b1-analytics { grid-template-columns: 1fr; } }

.b1-card {
    background: var(--b1-card);
    border: 1px solid var(--b1-border);
    border-radius: var(--b1-r);
    box-shadow: var(--b1-sh);
    position: relative;
    overflow: hidden;
    transition: var(--b1-transition);
}
.b1-card:hover { box-shadow: var(--b1-sh-md); }
.b1-card-head {
    padding: 1.1rem 1.25rem .75rem;
    border-bottom: 1px solid var(--b1-border-2);
}
.b1-card-title {
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--b1-text3);
    display: flex;
    align-items: center;
    gap: .4rem;
}
.b1-card-body { padding: 1.1rem 1.25rem; }

/* Lock overlay */
.b1-lock {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border-radius: var(--b1-r);
    gap: .5rem;
}
body.dark-mode .b1-lock { background: rgba(10,15,30,.92); }
.b1-lock-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--b1-card-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--b1-text3);
    border: 1px solid var(--b1-border);
}
.b1-lock-text { font-size: .78rem; font-weight: 600; color: var(--b1-text2); text-align: center; }
.b1-lock-btn {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: .35rem .9rem;
    font-size: .75rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--b1-transition);
}
.b1-lock-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(124,58,237,.35); color: #fff; }

/* Projection stats */
.b1-proj-big {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: 1;
    margin-bottom: .3rem;
}
.b1-proj-caption { font-size: .75rem; color: var(--b1-text2); margin-bottom: 1rem; }
.b1-proj-track {
    height: 6px;
    border-radius: 4px;
    background: var(--b1-border);
    overflow: hidden;
    margin-bottom: .6rem;
}
.b1-proj-fill { height: 100%; border-radius: 4px; background: var(--b1-blue); }
.b1-proj-meta {
    display: flex;
    justify-content: space-between;
    font-size: .7rem;
    color: var(--b1-text3);
    margin-bottom: .9rem;
}
.b1-proj-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.b1-proj-stat {
    background: var(--b1-card-2);
    border: 1px solid var(--b1-border-2);
    border-radius: var(--b1-r-sm);
    padding: .6rem .7rem;
    text-align: center;
}
.b1-proj-stat-label { font-size: .67rem; color: var(--b1-text3); margin-bottom: .15rem; }
.b1-proj-stat-value { font-size: .9rem; font-weight: 700; color: var(--b1-text); }

/* Tendances */
.b1-trend-row {
    padding: .6rem 0;
    border-bottom: 1px solid var(--b1-border-2);
}
.b1-trend-row:last-child { border-bottom: none; }
.b1-trend-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .3rem;
}
.b1-trend-name {
    font-size: .78rem;
    font-weight: 600;
    color: var(--b1-text);
    display: flex;
    align-items: center;
    gap: .35rem;
}
.b1-trend-amounts { font-size: .72rem; color: var(--b1-text3); }
.b1-trend-mini-track {
    height: 5px;
    border-radius: 3px;
    background: var(--b1-border);
    overflow: hidden;
    margin-bottom: .2rem;
}
.b1-trend-mini-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }
.b1-trend-avg { font-size: .65rem; color: var(--b1-text3); }

/* Conseils */
.b1-conseil {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .65rem .75rem;
    border-radius: var(--b1-r-sm);
    margin-bottom: .5rem;
    border-left: 3px solid transparent;
    font-size: .79rem;
}
.b1-conseil:last-child { margin-bottom: 0; }
.b1-conseil.danger  { background: var(--b1-red-bg);   border-left-color: var(--b1-red);   }
.b1-conseil.warning { background: var(--b1-amber-bg); border-left-color: var(--b1-amber); }
.b1-conseil.info    { background: var(--b1-blue-bg);  border-left-color: var(--b1-blue);  }
.b1-conseil.success { background: var(--b1-green-bg); border-left-color: var(--b1-green); }
.b1-conseil-icon { margin-top: .15rem; flex-shrink: 0; font-size: .85rem; }
.b1-conseil-text { color: var(--b1-text); line-height: 1.45; }

/* Donut legend */
.b1-donut-legend { display: flex; flex-direction: column; gap: .3rem; max-height: 130px; overflow-y: auto; margin-top: .5rem; }
.b1-donut-leg-row { display: flex; align-items: center; gap: .5rem; font-size: .72rem; }
.b1-donut-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.b1-donut-name { flex: 1; color: var(--b1-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b1-donut-pct { font-weight: 700; color: var(--b1-text2); }

/* ── Budget Table Section ────────────────────────────────────── */
.b1-table-card {
    background: var(--b1-card);
    border: 1px solid var(--b1-border);
    border-radius: var(--b1-r);
    box-shadow: var(--b1-sh);
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.b1-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem .9rem;
    border-bottom: 1px solid var(--b1-border-2);
    flex-wrap: wrap;
    gap: .75rem;
}
.b1-table-meta {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.b1-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.b1-table-title { font-size: .92rem; font-weight: 700; color: var(--b1-text); }
.b1-table-count { font-size: .75rem; color: var(--b1-text3); background: var(--b1-card-2); padding: .2rem .6rem; border-radius: 20px; border: 1px solid var(--b1-border); font-weight: 600; }

.b1-tbl { width: 100%; border-collapse: collapse; }
.b1-tbl thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--b1-card-2);
}
.b1-tbl thead tr { border-bottom: 1px solid var(--b1-border); }
.b1-tbl thead th {
    padding: .7rem 1rem;
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--b1-text3);
    white-space: nowrap;
    text-align: left;
}
.b1-tbl thead th:first-child { padding-left: 1.5rem; }
.b1-tbl thead th:last-child  { padding-right: 1.5rem; text-align: right; }
.b1-tbl thead th.right { text-align: right; }
.b1-tbl thead th.center { text-align: center; }

.b1-tbl tbody tr {
    border-bottom: 1px solid var(--b1-border-2);
    transition: background .12s;
}
.b1-tbl tbody tr:last-child { border-bottom: none; }
.b1-tbl tbody tr:hover { background: var(--b1-card-2); }

.b1-tbl tbody td {
    padding: .9rem 1rem;
    font-size: .84rem;
    color: var(--b1-text);
    vertical-align: middle;
}
.b1-tbl tbody td:first-child { padding-left: 1.5rem; }
.b1-tbl tbody td:last-child  { padding-right: 1.5rem; }
.b1-tbl tbody td.right  { text-align: right; }
.b1-tbl tbody td.center { text-align: center; }

.b1-tbl tfoot tr { border-top: 2px solid var(--b1-border); }
.b1-tbl tfoot td {
    padding: .85rem 1rem;
    font-size: .84rem;
    font-weight: 700;
    color: var(--b1-text);
    background: var(--b1-card-2);
}
.b1-tbl tfoot td:first-child { padding-left: 1.5rem; }

/* Category cell */
.b1-cat-cell { display: flex; align-items: center; gap: .75rem; }
.b1-cat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: .85rem;
}

/* Progress bar */
.b1-prog-wrap { display: flex; align-items: center; gap: .5rem; min-width: 130px; }
.b1-prog-track {
    flex: 1;
    height: 7px;
    border-radius: 4px;
    background: var(--b1-border);
    overflow: hidden;
}
.b1-prog-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.b1-prog-pct { font-size: .72rem; font-weight: 700; color: var(--b1-text3); min-width: 34px; text-align: right; }

/* Status badges */
.b1-badge {
    display: inline-flex;
    align-items: center;
    gap: .28rem;
    padding: .22rem .65rem;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}
.b1-badge-ok     { background: var(--b1-green-bg); color: #059669; border-color: rgba(16,185,129,.25); }
.b1-badge-warn   { background: var(--b1-amber-bg); color: #d97706; border-color: rgba(245,158,11,.25); }
.b1-badge-danger { background: var(--b1-red-bg);   color: #dc2626; border-color: rgba(239,68,68,.25); }

/* Depletion mini badge */
.b1-dep-badge {
    display: inline-block;
    font-size: .62rem;
    font-weight: 700;
    padding: .1rem .38rem;
    border-radius: 10px;
    margin-top: .2rem;
}
.b1-dep-ok     { background: rgba(16,185,129,.1);  color: #16a34a; }
.b1-dep-warn   { background: rgba(245,158,11,.1);  color: #d97706; }
.b1-dep-danger { background: rgba(239,68,68,.1);   color: #ef4444; }

/* Action buttons */
.b1-actions-cell { display: flex; align-items: center; justify-content: flex-end; gap: .3rem; }
.b1-act-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--b1-border);
    background: var(--b1-card);
    color: var(--b1-text2);
    font-size: .8rem;
    cursor: pointer;
    transition: var(--b1-transition);
    text-decoration: none;
}
.b1-act-btn:hover     { background: var(--b1-blue-bg); border-color: rgba(37,99,235,.25); color: var(--b1-blue); }
.b1-act-btn.del:hover { background: var(--b1-red-bg);  border-color: rgba(239,68,68,.25);  color: var(--b1-red);  }

/* ── Empty State ─────────────────────────────────────────────── */
.b1-empty {
    background: var(--b1-card);
    border: 1px solid var(--b1-border);
    border-radius: var(--b1-r);
    box-shadow: var(--b1-sh);
    text-align: center;
    padding: 3.5rem 2rem;
    margin-bottom: 1.5rem;
}
.b1-empty-emoji { font-size: 3rem; margin-bottom: .75rem; }
.b1-empty-title { font-size: 1rem; font-weight: 700; color: var(--b1-text); margin-bottom: .35rem; }
.b1-empty-text  { font-size: .84rem; color: var(--b1-text2); max-width: 380px; margin: 0 auto 1.5rem; }

/* ── Free Categories Section ─────────────────────────────────── */
.b1-free-section {
    background: var(--b1-card);
    border: 1px solid var(--b1-border);
    border-radius: var(--b1-r);
    box-shadow: var(--b1-sh);
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.b1-free-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.4rem .85rem;
    border-bottom: 1px solid var(--b1-border-2);
}
.b1-free-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--b1-text);
    display: flex;
    align-items: center;
    gap: .55rem;
}
.b1-free-count-pill {
    background: var(--b1-blue-bg);
    color: var(--b1-blue);
    font-size: .65rem;
    font-weight: 700;
    padding: .15rem .5rem;
    border-radius: 20px;
    border: 1px solid rgba(37,99,235,.15);
}
.b1-free-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; padding: 1.1rem 1.4rem; }
@media (max-width: 1024px) { .b1-free-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .b1-free-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .b1-free-grid { grid-template-columns: 1fr; } }

.b1-free-card {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .85rem;
    border-radius: var(--b1-r-sm);
    background: var(--b1-card-2);
    border: 1px solid var(--b1-border);
    transition: var(--b1-transition);
    cursor: pointer;
}
.b1-free-card:hover {
    background: var(--b1-blue-bg);
    border-color: rgba(37,99,235,.25);
    transform: translateY(-1px);
    box-shadow: var(--b1-sh);
}
.b1-free-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: .8rem;
}
.b1-free-name { flex: 1; font-size: .8rem; font-weight: 600; color: var(--b1-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b1-free-add  { font-size: .72rem; color: var(--b1-blue); opacity: .7; flex-shrink: 0; }

/* ── Modals (enhanced) ───────────────────────────────────────── */
.b1-modal .modal-content {
    border: 1px solid var(--b1-border);
    border-radius: var(--b1-r);
    box-shadow: var(--b1-sh-lg);
    background: var(--b1-card);
    overflow: hidden;
}
body.dark-mode .b1-modal .modal-content { background: #111827; }
.b1-modal .modal-header {
    padding: 1.25rem 1.5rem .75rem;
    border-bottom: 1px solid var(--b1-border-2);
}
.b1-modal .modal-title { font-size: 1rem; font-weight: 700; color: var(--b1-text); }
.b1-modal .modal-body  { padding: 1.25rem 1.5rem; }
.b1-modal .modal-footer { padding: .75rem 1.5rem 1.25rem; border-top: 1px solid var(--b1-border-2); }
.b1-modal .form-label { font-size: .8rem; font-weight: 600; color: var(--b1-text2); margin-bottom: .4rem; }
.b1-modal .form-control,
.b1-modal .form-select {
    border-radius: var(--b1-r-sm);
    border: 1px solid var(--b1-border);
    background: var(--b1-card-2);
    color: var(--b1-text);
    font-size: .875rem;
    padding: .55rem .85rem;
    transition: var(--b1-transition);
    box-shadow: none;
}
.b1-modal .form-control:focus,
.b1-modal .form-select:focus {
    border-color: var(--b1-blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
    background: var(--b1-card);
    outline: none;
}
body.dark-mode .b1-modal .form-control,
body.dark-mode .b1-modal .form-select { background: #0f172a; }
.b1-modal .form-check-input:checked { background-color: var(--b1-blue); border-color: var(--b1-blue); }

/* ── Wallet Select ───────────────────────────────────────────── */
.b1-wallet-select {
    border-radius: var(--b1-r-sm);
    border: 1px solid var(--b1-border);
    background: var(--b1-card);
    color: var(--b1-text);
    font-size: .82rem;
    font-weight: 500;
    padding: .42rem .7rem;
    cursor: pointer;
    box-shadow: var(--b1-sh);
    transition: var(--b1-transition);
}
.b1-wallet-select:focus { outline: none; border-color: var(--b1-blue); }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes b1FadeIn  { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes b1SlideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.b1-kpi-card      { animation: b1FadeIn .3s ease both; }
.b1-analytics > * { animation: b1SlideUp .35s ease both; }
.b1-analytics > *:nth-child(1) { animation-delay: .05s; }
.b1-analytics > *:nth-child(2) { animation-delay: .1s; }
.b1-analytics > *:nth-child(3) { animation-delay: .15s; }
.b1-analytics > *:nth-child(4) { animation-delay: .2s; }

/* ── Mobile overrides ────────────────────────────────────────── */
.b1-mobile-nav-active { color: var(--b1-blue) !important; }

@media (max-width: 768px) {
    .b1-wrap { padding: 1.25rem 1rem 5rem; }
    .b1-page-title { font-size: 1.25rem; }
    .b1-tbl thead th, .b1-tbl tbody td { padding: .75rem .65rem; font-size: .78rem; }
    .b1-tbl thead th:first-child, .b1-tbl tbody td:first-child { padding-left: 1rem; }
}

/* ── Table density ──────────────────────────────────────────────────────────── */
.bf-density-compact .table > :not(caption) > * > * { padding: .25rem .5rem !important; font-size: .78rem !important; }
.bf-density-compact .card-body { padding: .75rem !important; }
.bf-density-compact .b1-wrap { padding-top: .75rem !important; }
.bf-density-spacious .table > :not(caption) > * > * { padding: .9rem 1rem !important; font-size: .88rem !important; }
.bf-density-spacious .card-body { padding: 1.75rem !important; }
