/* ============================================
   DESIGN SYSTEM - مالي Pro
   (ported from the supplied design reference)
   ============================================ */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --ink: #0f172a;
  --ink-secondary: #475569;
  --ink-tertiary: #94a3b8;
  --line: #e2e8f0;
  --line-light: #f1f5f9;
  --primary: #0f8a68;
  --primary-light: #d1fae5;
  --primary-dark: #065f46;
  --accent: #3b82f6;
  --accent-light: #dbeafe;
  --success: #10b981;
  --success-bg: #d1fae5;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --info: #6366f1;
  --info-bg: #e0e7ff;
  --dark-bg: #0f172a;
  --dark-surface: #1e293b;
  --dark-ink: #f8fafc;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 20px rgba(15, 138, 104, 0.15);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --radius-sm: 8px; --radius: 12px; --radius-md: 16px; --radius-lg: 20px;
  --radius-xl: 24px; --radius-full: 9999px;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

[data-theme="dark"] {
  --bg: #0f172a; --surface: #1e293b; --surface-elevated: #334155;
  --ink: #f8fafc; --ink-secondary: #cbd5e1; --ink-tertiary: #94a3b8;
  --line: #334155; --line-light: #1e293b;
  --primary-light: rgba(16, 185, 129, 0.15);
  --accent-light: rgba(59, 130, 246, 0.15);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.6;
  min-height: 100vh; overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-tertiary); border-radius: var(--radius-full); }

.app { max-width: 680px; margin: 0 auto; padding: var(--space-4) var(--space-4) calc(100px + var(--safe-bottom)); position: relative; }

/* Header */
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-5); padding-top: var(--safe-top); }
.brand-group { display: flex; align-items: center; gap: var(--space-3); }
.brand-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-md); display: grid; place-items: center;
  color: white; font-size: 22px; box-shadow: var(--shadow-glow);
  animation: pulse-soft 3s ease-in-out infinite;
}
@keyframes pulse-soft { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.brand-text .brand-name { font-size: 24px; font-weight: 900; letter-spacing: -0.5px; line-height: 1.2; }
.brand-text .brand-tag { font-size: 12px; color: var(--ink-tertiary); font-weight: 500; }
.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-full);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-secondary);
  display: grid; place-items: center; cursor: pointer; font-size: 18px;
  transition: all var(--transition-fast); position: relative;
}
.icon-btn:hover, .icon-btn:active { background: var(--line-light); transform: scale(0.95); }
.icon-btn .badge {
  position: absolute; top: -2px; right: -2px; width: 18px; height: 18px;
  background: var(--danger); color: white; font-size: 10px; font-weight: 800;
  border-radius: var(--radius-full); display: grid; place-items: center;
  border: 2px solid var(--surface); animation: bounce-in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
@keyframes bounce-in { 0% { transform: scale(0); } 100% { transform: scale(1); } }

/* Month Selector */
.month-bar { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); overflow-x: auto; padding-bottom: var(--space-2); scrollbar-width: none; }
.month-bar::-webkit-scrollbar { display: none; }
.month-chip {
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-full);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-secondary);
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  white-space: nowrap; transition: all var(--transition-fast); flex-shrink: 0;
}
.month-chip.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: var(--shadow-glow); }
.month-chip:active { transform: scale(0.95); }

/* Alerts */
.alert-banner {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); margin-bottom: var(--space-3); font-size: 13px; font-weight: 600;
  animation: slide-down 0.4s ease-out; cursor: pointer; transition: transform var(--transition-fast);
}
.alert-banner:active { transform: scale(0.98); }
.alert-banner.warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fcd34d; }
.alert-banner.danger { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-banner.success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-banner.info { background: var(--info-bg); color: #3730a3; border: 1px solid #c7d2fe; }
@keyframes slide-down { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--dark-bg) 0%, #1e3a5f 100%);
  border-radius: var(--radius-xl); padding: var(--space-6); color: white; position: relative;
  overflow: hidden; margin-bottom: var(--space-5); box-shadow: var(--shadow-lg);
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}
.hero::after {
  content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
  top: -100px; left: -100px; animation: float 6s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(30px, 20px); } }
.hero-content { position: relative; z-index: 1; }
.hero-label { font-size: 13px; color: rgba(255,255,255,0.7); font-weight: 500; margin-bottom: var(--space-2); }
.hero-amount { font-size: 42px; font-weight: 900; line-height: 1.1; margin-bottom: var(--space-2); text-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.hero-status { display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-full); font-size: 12px; font-weight: 700; background: rgba(255,255,255,0.15); backdrop-filter: blur(8px); }
.hero-status.good { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.hero-status.bad { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.hero-score { position: absolute; top: var(--space-5); left: var(--space-5); z-index: 1; text-align: center; }
.score-ring { width: 70px; height: 70px; border-radius: 50%; background: conic-gradient(var(--primary) calc(var(--score-deg, 0deg)), rgba(255,255,255,0.1) 0); display: grid; place-items: center; position: relative; transition: background 1s ease-out; }
.score-ring::before { content: ''; position: absolute; inset: 6px; background: rgba(255,255,255,0.1); border-radius: 50%; backdrop-filter: blur(4px); }
.score-value { position: relative; font-size: 18px; font-weight: 900; }
.score-label { font-size: 10px; color: rgba(255,255,255,0.6); margin-top: 4px; font-weight: 600; }

/* Metrics */
.metrics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); margin-bottom: var(--space-5); }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); position: relative; overflow: hidden; transition: all var(--transition); cursor: pointer; }
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.metric-card:active { transform: scale(0.98); }
.metric-card::before { content: ''; position: absolute; top: 0; right: 0; width: 60px; height: 60px; border-radius: 0 0 0 60px; opacity: 0.1; }
.metric-card.income::before { background: var(--success); }
.metric-card.expense::before { background: var(--danger); }
.metric-card.saving::before { background: var(--primary); }
.metric-card.fixed::before { background: var(--accent); }
.metric-icon { width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center; font-size: 18px; margin-bottom: var(--space-3); }
.metric-card.income .metric-icon { background: var(--success-bg); }
.metric-card.expense .metric-icon { background: var(--danger-bg); }
.metric-card.saving .metric-icon { background: var(--primary-light); }
.metric-card.fixed .metric-icon { background: var(--accent-light); }
.metric-label { font-size: 12px; color: var(--ink-tertiary); font-weight: 600; margin-bottom: var(--space-1); }
.metric-value { font-size: 22px; font-weight: 900; line-height: 1.2; }
.metric-sub { font-size: 11px; color: var(--ink-tertiary); margin-top: var(--space-1); font-weight: 500; }

/* Progress Cards */
.progress-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-3); margin-bottom: var(--space-5); }
@media (min-width: 480px) { .progress-grid { grid-template-columns: 1fr 1fr; } }
.progress-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); transition: all var(--transition); }
.progress-card:hover { box-shadow: var(--shadow-md); }
.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3); }
.progress-title { font-size: 14px; font-weight: 800; display: flex; align-items: center; gap: var(--space-2); }
.progress-stats { display: flex; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-3); }
.progress-current { font-size: 24px; font-weight: 900; }
.progress-target { font-size: 13px; color: var(--ink-tertiary); font-weight: 600; }
.progress-bar-bg { height: 10px; background: var(--line-light); border-radius: var(--radius-full); overflow: hidden; position: relative; }
.progress-bar-fill { height: 100%; border-radius: var(--radius-full); transition: width 1s cubic-bezier(0.4, 0, 0.2, 1); position: relative; overflow: hidden; }
.progress-bar-fill::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent); animation: shimmer 2s infinite; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.progress-bar-fill.green { background: linear-gradient(90deg, var(--primary), var(--success)); }
.progress-bar-fill.blue { background: linear-gradient(90deg, var(--accent), #8b5cf6); }
.progress-bar-fill.warning { background: linear-gradient(90deg, var(--warning), #f97316); }
.progress-bar-fill.danger { background: linear-gradient(90deg, var(--danger), #dc2626); }
.progress-footer { display: flex; justify-content: space-between; margin-top: var(--space-2); font-size: 11px; color: var(--ink-tertiary); font-weight: 600; }

/* Quick Actions */
.quick-actions { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); margin-bottom: var(--space-5); }
.quick-actions-title { font-size: 14px; font-weight: 800; margin-bottom: var(--space-3); display: flex; align-items: center; gap: var(--space-2); }
.actions-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
.action-btn { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-2); border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-family: inherit; font-size: 11px; font-weight: 700; cursor: pointer; transition: all var(--transition-fast); }
.action-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.action-btn:active { transform: scale(0.95); }
.action-btn .action-icon { width: 44px; height: 44px; border-radius: var(--radius-md); display: grid; place-items: center; font-size: 22px; transition: transform var(--transition-fast); }
.action-btn:hover .action-icon { transform: scale(1.1); }
.action-btn.income .action-icon { background: var(--success-bg); }
.action-btn.expense .action-icon { background: var(--danger-bg); }
.action-btn.child .action-icon { background: #fce7f3; }
.action-btn.save .action-icon { background: #fef3c7; }

/* Children Section */
.children-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); margin-bottom: var(--space-5); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.section-title { font-size: 16px; font-weight: 900; display: flex; align-items: center; gap: var(--space-2); }
.section-total { font-size: 18px; font-weight: 900; color: var(--primary); }
.children-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); }
.child-card { background: var(--line-light); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); text-align: center; transition: all var(--transition-fast); cursor: pointer; }
.child-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.child-avatar { width: 48px; height: 48px; border-radius: var(--radius-full); background: linear-gradient(135deg, var(--primary), var(--accent)); display: grid; place-items: center; margin: 0 auto var(--space-3); color: white; font-size: 22px; font-weight: 800; }
.child-name { font-size: 14px; font-weight: 800; margin-bottom: var(--space-1); }
.child-label { font-size: 11px; color: var(--ink-tertiary); margin-bottom: var(--space-2); }
.child-amount { font-size: 18px; font-weight: 900; color: var(--primary); }

/* Transactions */
.transactions-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); margin-bottom: var(--space-5); }
.tx-list { display: flex; flex-direction: column; gap: var(--space-2); }
.tx-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-md); transition: all var(--transition-fast); cursor: pointer; border: 1px solid transparent; }
.tx-item:hover { background: var(--line-light); border-color: var(--line); }
.tx-item:active { transform: scale(0.99); }
.tx-icon { width: 44px; height: 44px; border-radius: var(--radius); display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.tx-icon.income { background: var(--success-bg); }
.tx-icon.expense { background: var(--danger-bg); }
.tx-icon.saving { background: #fef3c7; }
.tx-icon.child { background: #fce7f3; }
.tx-details { flex: 1; min-width: 0; }
.tx-title { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--ink-tertiary); font-weight: 500; margin-top: 2px; }
.tx-amount { font-size: 15px; font-weight: 900; white-space: nowrap; flex-shrink: 0; }
.tx-amount.income { color: var(--success); }
.tx-amount.expense { color: var(--danger); }
.tx-amount.pending { opacity: .55; }

/* Forms */
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: var(--space-5); margin-bottom: var(--space-5); display: none; animation: slide-up 0.4s ease-out; }
.form-card.open { display: block; }
@keyframes slide-up { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
.form-title { font-size: 18px; font-weight: 900; margin-bottom: var(--space-5); display: flex; align-items: center; gap: var(--space-2); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-3); }
@media (min-width: 480px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 700; color: var(--ink-secondary); }
.field input, .field select, .field textarea { padding: var(--space-3) var(--space-4); border: 1.5px solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); font-family: inherit; font-size: 15px; font-weight: 600; outline: none; transition: all var(--transition-fast); -webkit-appearance: none; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.field textarea { min-height: 80px; resize: vertical; }
.submit-btn { width: 100%; padding: var(--space-4); border: none; border-radius: var(--radius-md); background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; font-family: inherit; font-size: 15px; font-weight: 800; cursor: pointer; transition: all var(--transition-fast); margin-top: var(--space-4); box-shadow: var(--shadow-glow); }
.submit-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(15, 138, 104, 0.3); }
.submit-btn:active { transform: translateY(0); }
.submit-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.submit-btn.secondary { background: var(--line-light); color: var(--ink); box-shadow: none; border: 1px solid var(--line); }
.submit-btn.secondary:hover { background: var(--line); }
.submit-btn.danger { background: linear-gradient(135deg, var(--danger), #dc2626); }

/* Settings */
.settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: var(--space-5); margin-bottom: var(--space-5); display: none; animation: slide-up 0.4s ease-out; }
.settings-card.open { display: block; }
.settings-subtitle { font-size: 15px; font-weight: 900; margin: var(--space-6) 0 var(--space-2); display: flex; align-items: center; gap: var(--space-2); }
.settings-desc { font-size: 12px; color: var(--ink-tertiary); margin-bottom: var(--space-3); }

/* Empty State */
.empty-state { text-align: center; padding: var(--space-8) var(--space-4); color: var(--ink-tertiary); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: var(--space-3); opacity: 0.5; }
.empty-state .empty-title { font-size: 16px; font-weight: 800; color: var(--ink-secondary); margin-bottom: var(--space-2); }
.empty-state .empty-desc { font-size: 13px; }

/* Bottom Nav */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); border-top: 1px solid var(--line); padding: var(--space-2) var(--space-4) calc(var(--space-2) + var(--safe-bottom)); z-index: 100; display: flex; justify-content: space-around; align-items: center; }
[data-theme="dark"] .bottom-nav { background: rgba(30, 41, 59, 0.95); border-top-color: var(--line); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--space-2) var(--space-3); border: none; background: transparent; color: var(--ink-tertiary); font-family: inherit; font-size: 10px; font-weight: 700; cursor: pointer; border-radius: var(--radius-md); transition: all var(--transition-fast); position: relative; flex: 1; max-width: 80px; }
.nav-item .nav-icon { font-size: 22px; transition: transform var(--transition-fast); }
.nav-item.active { color: var(--primary); background: var(--primary-light); }
.nav-item.active .nav-icon { transform: translateY(-2px); }

/* Toast */
.toast-container { position: fixed; top: var(--space-4); left: var(--space-4); right: var(--space-4); z-index: 200; display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); display: flex; align-items: center; gap: var(--space-3); box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 700; animation: toast-in 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; pointer-events: auto; max-width: 100%; }
.toast.toast-out { animation: toast-out 0.3s ease-in forwards; }
.toast.success { border-color: var(--success); background: var(--success-bg); color: #065f46; }
.toast.error { border-color: var(--danger); background: var(--danger-bg); color: #991b1b; }
.toast.warning { border-color: var(--warning); background: var(--warning-bg); color: #92400e; }
.toast.info { border-color: var(--accent); background: var(--accent-light); color: #1e40af; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-20px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-10px) scale(0.95); } }

/* Loading */
.loading-overlay { position: fixed; inset: 0; background: rgba(248, 250, 252, 0.95); backdrop-filter: blur(8px); z-index: 300; display: none; place-items: center; flex-direction: column; gap: var(--space-4); }
.loading-overlay.active { display: grid; }
[data-theme="dark"] .loading-overlay { background: rgba(15, 23, 42, 0.95); }
.loader { width: 48px; height: 48px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; font-weight: 700; color: var(--ink-secondary); }

/* Pull to refresh */
.ptr-indicator { position: fixed; top: 8px; left: 50%; transform: translateX(-50%) scale(0); z-index: 250; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-md); display: grid; place-items: center; transition: transform .2s ease; }
.ptr-indicator.show { transform: translateX(-50%) scale(1); }
.ptr-indicator .loader { width: 20px; height: 20px; border-width: 2px; }

/* Offline pill */
.offline-pill { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 210; background: var(--warning); color: #241a00; font-weight: 800; font-size: 12px; padding: 7px 14px; border-radius: var(--radius-full); box-shadow: var(--shadow-md); }

/* Notifications Panel */
.notifications-panel { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); z-index: 150; display: none; opacity: 0; transition: opacity var(--transition); }
.notifications-panel.open { display: block; opacity: 1; }
.notifications-sheet { position: absolute; bottom: 0; left: 0; right: 0; background: var(--surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 70vh; overflow-y: auto; transform: translateY(100%); transition: transform var(--transition-slow); padding: var(--space-5); padding-bottom: calc(var(--space-5) + var(--safe-bottom)); }
.notifications-panel.open .notifications-sheet { transform: translateY(0); }
.notifications-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-5); }
.notifications-title { font-size: 18px; font-weight: 900; }
.notification-item { display: flex; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-md); margin-bottom: var(--space-2); transition: background var(--transition-fast); }
.notification-item:hover { background: var(--line-light); }
.notification-item.unread { background: var(--primary-light); }
.notification-dot { width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.notification-content { flex: 1; }
.notification-text { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.notification-time { font-size: 11px; color: var(--ink-tertiary); }

/* Auth screen */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6); }
.auth-card { max-width: 380px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: var(--space-6); box-shadow: var(--shadow-lg); text-align: center; }

/* PIN lock */
.pinlock { position: fixed; inset: 0; background: var(--dark-bg); color: #fff; display: grid; place-items: center; z-index: 400; gap: var(--space-2); }
.pinlock .dots { display: flex; gap: 14px; margin: var(--space-5) 0; }
.pinlock .dot { width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.25); transition: background .15s; }
.pinlock .dot.filled { background: var(--warning); }
.pinlock .keypad { display: grid; grid-template-columns: repeat(3,70px); gap: 14px; }
.pinlock .keypad button { width: 70px; height: 70px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06); color: #fff; font-size: 22px; font-weight: 800; }

/* Chart (added extra) */
.chart-wrap { width: 100%; height: 220px; }

/* ============================================================
   قسم الإحصائيات الشهرية — بطاقات بأيقونات وشارات مميزة
   ============================================================ */
.stats-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); margin-bottom: var(--space-5); }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); margin-top: var(--space-4); }
@media (min-width: 480px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
.stat-badge {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--line-light); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: var(--space-3); transition: all var(--transition-fast);
}
.stat-badge:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.stat-badge-icon {
  width: 42px; height: 42px; border-radius: var(--radius-full); flex-shrink: 0;
  display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
}
.stat-badge-icon.gold { background: linear-gradient(135deg, #f59e0b, #f97316); }
.stat-badge-icon.purple { background: linear-gradient(135deg, #8b5cf6, #6366f1); }
.stat-badge-icon.pink { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.stat-badge-icon.blue { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.stat-badge-content { min-width: 0; flex: 1; }
.stat-badge-label { font-size: 11px; color: var(--ink-tertiary); font-weight: 600; margin-bottom: 2px; }
.stat-badge-value { font-size: 15px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-badge-sub { font-size: 10px; color: var(--ink-tertiary); margin-top: 1px; }

/* ============================================================
   قسم التقارير — رسوم بيانية + مقارنة بالشهر السابق
   ============================================================ */
.reports-compare { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin-bottom: var(--space-5); }
.compare-badge { background: var(--line-light); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-3); text-align: center; }
.compare-badge .compare-label { font-size: 11px; color: var(--ink-tertiary); font-weight: 600; margin-bottom: 4px; }
.compare-badge .compare-value { font-size: 16px; font-weight: 900; display: flex; align-items: center; justify-content: center; gap: 4px; }
.compare-badge .compare-value.up { color: var(--danger); }
.compare-badge .compare-value.down { color: var(--success); }
.compare-badge .compare-value.up.good { color: var(--success); }
.compare-badge .compare-value.down.bad { color: var(--danger); }

.report-chart-card { background: var(--line-light); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); margin-bottom: var(--space-4); }
.report-chart-title { font-size: 13px; font-weight: 800; margin-bottom: var(--space-3); }

.top-categories-list { display: flex; flex-direction: column; gap: var(--space-3); }
.top-cat-row { display: flex; align-items: center; gap: var(--space-3); }
.top-cat-rank { width: 24px; height: 24px; border-radius: var(--radius-full); background: var(--primary); color: #fff; font-size: 11px; font-weight: 900; display: grid; place-items: center; flex-shrink: 0; }
.top-cat-info { flex: 1; min-width: 0; }
.top-cat-header { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.top-cat-bar-bg { height: 6px; background: var(--line); border-radius: var(--radius-full); overflow: hidden; }
.top-cat-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: var(--radius-full); }

/* ============================================================
   سجل العمليات الكامل — بحث، فلترة، تعديل وحذف
   ============================================================ */
.entries-filter-bar { margin-bottom: var(--space-4); }
.entries-filter-bar input[type="text"] { width: 100%; padding: var(--space-3) var(--space-4); border: 1.5px solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); font-family: inherit; font-size: 14px; margin-bottom: var(--space-3); }
.entries-filter-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.entries-filter-row input[type="date"] { flex: 1; min-width: 120px; padding: var(--space-2) var(--space-3); border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-family: inherit; font-size: 12px; }

.tx-item .tx-actions { display: flex; gap: 4px; flex-shrink: 0; }
.tx-item .tx-action-btn { width: 30px; height: 30px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; font-size: 13px; cursor: pointer; transition: all var(--transition-fast); }
.tx-item .tx-action-btn:hover { background: var(--line-light); transform: scale(1.05); }
.tx-item .tx-action-btn.delete:hover { background: var(--danger-bg); border-color: var(--danger); }

.entries-pagination { display: flex; justify-content: center; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }
.entries-pagination button { padding: var(--space-2) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-family: inherit; font-weight: 700; font-size: 13px; cursor: pointer; }
.entries-pagination button:disabled { opacity: .4; cursor: not-allowed; }
.entries-pagination .page-info { font-size: 12px; color: var(--ink-tertiary); font-weight: 700; }

/* Animations */
.fade-in { animation: fade-in 0.5s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.stagger-1 { animation-delay: 0.05s; } .stagger-2 { animation-delay: 0.1s; } .stagger-3 { animation-delay: 0.15s; } .stagger-4 { animation-delay: 0.2s; }

/* Responsive */
@media (max-width: 400px) {
  .hero-amount { font-size: 32px; }
  .metric-value { font-size: 18px; }
  .actions-grid { grid-template-columns: repeat(2, 1fr); }
  .children-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 768px) {
  .app { max-width: 800px; }
  .metrics-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Utilities */
.hidden { display: none !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }
.sub { color: var(--ink-tertiary); font-size: 12px; }
.tx-item.inactive { opacity: .5; }

/* ============================================================
   صندوق شرح حساب الميزانية الأسبوعية التلقائي
   ============================================================ */
.auto-budget-box { background: var(--line-light); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); margin-bottom: var(--space-2); text-align: center; }
.auto-budget-formula { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-tertiary); font-weight: 700; margin-bottom: var(--space-3); }
.auto-budget-formula .auto-budget-op { color: var(--primary); font-weight: 900; }
.auto-budget-result { font-size: 26px; font-weight: 900; color: var(--primary); }
.auto-budget-result .sub { font-size: 12px; font-weight: 700; margin-inline-start: 4px; }

/* ============================================================
   الحسابات (بنك/بطاقة/نقد) والتحويلات
   ============================================================ */
.accounts-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); margin-bottom: var(--space-5); }
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.account-card { background: var(--line-light); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); position: relative; transition: all var(--transition-fast); }
.account-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.account-icon { width: 40px; height: 40px; border-radius: var(--radius); display: grid; place-items: center; font-size: 20px; margin-bottom: var(--space-2); background: var(--primary-light); }
.account-name { font-size: 13px; font-weight: 800; margin-bottom: 4px; }
.account-type { font-size: 10px; color: var(--ink-tertiary); font-weight: 600; margin-bottom: var(--space-2); }
.account-balance { font-size: 17px; font-weight: 900; }
.account-balance.negative { color: var(--danger); }
.account-delete-btn { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--surface); color: var(--ink-tertiary); font-size: 11px; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity var(--transition-fast); }
.account-card:hover .account-delete-btn { opacity: 1; }
.accounts-actions { display: flex; gap: var(--space-2); }
.accounts-actions .submit-btn { margin-top: 0; }

/* ============================================================
   رابط "عرض الكل وتعديل" الواضح + تبويبات نوع العملية داخل السجل
   ============================================================ */
.edit-entry-link {
  border: 1px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.edit-entry-link:hover { background: var(--primary); color: #fff; }

.entries-type-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: var(--space-4);
}
.entries-type-tab {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--line-light);
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.entries-type-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
