/* ==========================================================================
   مصروفي - تطبيق إدارة الدخل والمصاريف الشخصية
   تصميم عصري عربي متكامل (RTL) - Mobile First
   ========================================================================== */

/* استيراد خط Cairo من Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
  /* ألوان النظام المالي */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;

  --income: #10b981;
  --income-hover: #059669;
  --income-light: #ecfdf5;
  --income-border: #a7f3d0;

  --expense: #ef4444;
  --expense-hover: #dc2626;
  --expense-light: #fef2f2;
  --expense-border: #fecaca;

  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;

  /* خلفيات وظلال */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  /* النصوص */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-white: #ffffff;

  /* قياسات ونصف قطر */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);

  --font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --transition: all 0.2s ease-in-out;
}

/* ضبط العناصر العامة */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-family);
  direction: rtl;
  text-align: right;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: 84px; /* مساحة للشريط السفلي في الموبايل */
}

body.modal-open {
  overflow: hidden;
}

/* ==========================================================================
   رأس التطبيق (Header)
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.brand-titles h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

/* ==========================================================================
   الحاوية الرئيسية والشاشات (Sections)
   ========================================================================== */
.main-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

.app-section {
  display: none;
  animation: fadeIn 0.25s ease-out forwards;
}

.app-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   بطاقة الرصيد الحالي والمتبقي الكلي (Hero Balance Card)
   ========================================================================== */
.current-balance-hero {
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  color: #ffffff;
}

.current-balance-hero.is-positive {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 65%, #3b82f6 100%);
}

.current-balance-hero.is-deficit {
  background: linear-gradient(135deg, #991b1b 0%, #dc2626 70%, #ef4444 100%);
}

.balance-hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hero-icon {
  font-size: 2.2rem;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(6px);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.hero-titles {
  display: flex;
  flex-direction: column;
}

.hero-sub {
  font-size: 0.82rem;
  opacity: 0.88;
  font-weight: 500;
}

.hero-amount {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 2px;
  letter-spacing: -0.5px;
}

.btn-balance-edit {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 99px;
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-balance-edit:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.balance-hero-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
  opacity: 0.92;
}

.initial-bal-text strong {
  font-weight: 800;
  margin-right: 4px;
}

.balance-note {
  font-size: 0.72rem;
  opacity: 0.75;
}

/* ==========================================================================
   أزرار الإجراء السريع (Quick Action Buttons)
   ========================================================================== */
.quick-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.btn-quick-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.btn-quick-add:active {
  transform: scale(0.98);
}

.btn-quick-income {
  background-color: var(--income);
  color: var(--text-white);
}

.btn-quick-income:hover {
  background-color: var(--income-hover);
}

.btn-quick-expense {
  background-color: var(--primary);
  color: var(--text-white);
}

.btn-quick-expense:hover {
  background-color: var(--primary-hover);
}

/* ==========================================================================
   بطاقات الملخص المالي (Summary Cards)
   ========================================================================== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.summary-card:hover {
  box-shadow: var(--shadow-md);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card-icon-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.card-income .card-icon-badge {
  background: var(--income-light);
  color: var(--income);
}

.card-expense .card-icon-badge {
  background: var(--expense-light);
  color: var(--expense);
}

.card-net .card-icon-badge {
  background: var(--primary-light);
  color: var(--primary);
}

.card-deficit .card-icon-badge {
  background: var(--expense-light);
  color: var(--expense);
}

.card-count .card-icon-badge {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.card-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  word-break: break-word;
}

.card-income .card-value { color: var(--income); }
.card-expense .card-value { color: var(--expense); }
.card-net .card-value { color: var(--primary); }
.card-deficit .card-value { color: var(--expense); }

/* ==========================================================================
   أشرطة الفلترة والتحكم (Filter Bars)
   ========================================================================== */
.filter-bar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filter-item {
  flex: 1;
  min-width: 140px;
}

.filter-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.custom-date-row {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

/* ==========================================================================
   حقول الإدخال والقوائم (Form Controls)
   ========================================================================== */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-label .required-star {
  color: var(--expense);
}

.form-control {
  width: 100%;
  height: 44px;
  padding: 8px 12px;
  font-family: var(--font-family);
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-control:disabled {
  background-color: var(--bg-subtle);
  cursor: not-allowed;
  opacity: 0.7;
}

textarea.form-control {
  height: auto;
  min-height: 80px;
  resize: vertical;
}

/* أزرار الإجراءات */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 18px;
  font-family: var(--font-family);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary);
  color: var(--text-white);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-income {
  background-color: var(--income);
  color: var(--text-white);
}
.btn-income:hover {
  background-color: var(--income-hover);
}

.btn-danger {
  background-color: var(--expense);
  color: var(--text-white);
}
.btn-danger:hover {
  background-color: var(--expense-hover);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: var(--bg-subtle);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.btn-icon:hover {
  background-color: var(--bg-subtle);
}

/* ==========================================================================
   بطاقات العمليات والمعاملات (Transaction Cards)
   ========================================================================== */
.tx-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-date-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}

.tx-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.tx-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.tx-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.tx-income .tx-card-icon {
  background-color: var(--income-light);
}

.tx-expense .tx-card-icon {
  background-color: var(--expense-light);
}

.tx-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tx-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-card-meta {
  font-size: 0.72rem;
  color: var(--text-subtle);
}

.tx-card-amount {
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
}

.text-income { color: var(--income) !important; }
.text-expense { color: var(--expense) !important; }
.text-danger { color: var(--expense) !important; }
.text-success { color: var(--income) !important; }
.text-muted { color: var(--text-muted) !important; }

/* ==========================================================================
   المخططات والرسوم البيانية (Charts)
   ========================================================================== */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.chart-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Donut Chart */
.donut-chart-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

@media (min-width: 600px) {
  .donut-chart-wrapper {
    flex-direction: row;
    justify-content: space-around;
  }
}

.donut-svg-holder {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 220px;
  height: 220px;
  flex-shrink: 0;
}

.donut-center-text {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.center-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.center-total {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.chart-legend-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.legend-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-label {
  flex: 1;
  color: var(--text-main);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-value {
  font-weight: 700;
  color: var(--text-main);
}

.legend-percent {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 42px;
  text-align: left;
}

/* Bar Chart */
.bar-chart-container {
  width: 100%;
  overflow-x: auto;
  padding: 10px 0;
}

.bar-chart-grid {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 12px;
  min-width: 100%;
  padding-bottom: 20px;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 44px;
}

.bar-value-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  white-space: nowrap;
}

.bar-track {
  width: 100%;
  max-width: 38px;
  background: var(--bg-subtle);
  border-radius: 6px 6px 0 0;
  display: flex;
  align-items: flex-end;
}

.bar-fill {
  width: 100%;
  border-radius: 6px 6px 0 0;
  transition: height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.bar-title-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  white-space: nowrap;
}

/* Line Chart */
.line-chart-wrapper {
  width: 100%;
  overflow-x: auto;
}

.line-svg {
  width: 100%;
  height: 180px;
  display: block;
}

.chart-empty-state {
  text-align: center;
  padding: 30px 15px;
  color: var(--text-muted);
}
.chart-empty-state .empty-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  display: block;
}

/* ==========================================================================
   التحليل التفصيلي للمصروفات (Drill-down)
   ========================================================================== */
.drilldown-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drilldown-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.drilldown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.drilldown-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drilldown-icon {
  font-size: 1.2rem;
}

.drilldown-cat-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.drilldown-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drilldown-amount {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--expense);
}

.drilldown-arrow {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.drilldown-card.expanded .drilldown-arrow {
  transform: rotate(180deg);
}

.drilldown-progress-track {
  width: 100%;
  height: 6px;
  background-color: var(--bg-subtle);
  border-radius: 99px;
  margin-top: 10px;
  overflow: hidden;
}

.drilldown-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f87171, #ef4444);
  border-radius: 99px;
  transition: width 0.6s ease;
}

.drilldown-subs-container {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-color);
  flex-direction: column;
  gap: 8px;
}

.drilldown-card.expanded .drilldown-subs-container {
  display: flex;
}

.drilldown-sub-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.sub-name {
  width: 110px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-bar-wrap {
  flex: 1;
  height: 6px;
  background-color: var(--bg-subtle);
  border-radius: 99px;
  overflow: hidden;
}

.sub-progress-bar {
  height: 100%;
  background-color: #f97316;
  border-radius: 99px;
}

.sub-val {
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
}

/* ==========================================================================
   جداول التقارير (Reports Table)
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: right;
}

.report-table th, .report-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.report-table th {
  background-color: var(--bg-subtle);
  font-weight: 700;
  color: var(--text-muted);
}

.report-table tr:last-child td {
  border-bottom: none;
}

.report-table tr:hover {
  background-color: rgba(241, 245, 249, 0.5);
}

/* ==========================================================================
   إحصائيات إضافية (Stats Metric Grid)
   ========================================================================== */
.stats-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  word-break: break-word;
}

/* ==========================================================================
   شاشة الإعدادات (Settings)
   ========================================================================== */
.settings-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.settings-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.settings-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-item.item-archived {
  opacity: 0.65;
  background: #f1f5f9;
}

.category-card-setting {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}

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

.category-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.subcategories-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.sub-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 0.8rem;
}

.chip-action {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 2px;
  color: var(--text-muted);
}

.no-subs-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ==========================================================================
   شارات وحالات فارغة (Badges & Empty States)
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 99px;
}

.badge-income { background: var(--income-light); color: var(--income); }
.badge-expense { background: var(--expense-light); color: var(--expense); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-neutral { background: var(--bg-subtle); color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 40px 16px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  margin: 16px 0;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  display: block;
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.empty-state-compact {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ==========================================================================
   النوافذ المنبثقة (Modals)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  padding: 0;
}

@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
    padding: 20px;
  }
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: #ffffff;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-float);
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

@media (min-width: 600px) {
  .modal-dialog {
    border-radius: var(--radius-lg);
    transform: scale(0.95);
  }
}

.modal-overlay.active .modal-dialog {
  transform: translateY(0);
}

@media (min-width: 600px) {
  .modal-overlay.active .modal-dialog {
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 20px;
}

.modal-actions-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

/* تفاصيل العملية داخل المودال */
.tx-detail-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.tx-detail-amount {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 16px;
}

.tx-detail-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-subtle);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  padding-bottom: 6px;
}

.detail-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-desc-block {
  flex-direction: column;
  gap: 4px;
}

.detail-val-desc {
  background: #ffffff;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

/* ==========================================================================
   التنبيهات العائمة (Toast Notifications)
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}

.toast {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  border-right: 4px solid var(--income);
}
.toast-success .toast-icon {
  color: var(--income);
  font-weight: 800;
}

.toast-error {
  border-right: 4px solid var(--expense);
}
.toast-error .toast-icon {
  color: var(--expense);
  font-weight: 800;
}

/* ==========================================================================
   شريط التنقل السفلي للموبايل (Mobile Bottom Bar)
   ========================================================================== */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 64px;
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  color: var(--text-muted);
  text-decoration: none;
  border: none;
  background: none;
  font-family: var(--font-family);
  cursor: pointer;
  transition: var(--transition);
  padding: 4px 0;
}

.bottom-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 2px;
}

.bottom-nav-label {
  font-size: 0.72rem;
  font-weight: 600;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: translateY(-2px);
}

/* القائمة الجانبية للشاشات الكبيرة */
.desktop-sidebar {
  display: none;
}

/* ==========================================================================
   التجاوب للشاشات الكبيرة (Desktop & Tablet)
   ========================================================================== */
@media (min-width: 1024px) {
  body {
    padding-bottom: 0;
    padding-right: 250px; /* مساحة القائمة الجانبية */
  }

  .mobile-bottom-nav {
    display: none;
  }

  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 250px;
    background: #ffffff;
    border-left: 1px solid var(--border-color);
    z-index: 50;
    padding: 24px 16px;
    box-shadow: var(--shadow-sm);
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
  }

  .sidebar-brand h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
  }

  .sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
  }

  .sidebar-menu-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    text-align: right;
    transition: var(--transition);
    width: 100%;
  }

  .sidebar-menu-btn:hover {
    background-color: var(--bg-subtle);
    color: var(--text-main);
  }

  .sidebar-menu-btn.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
  }

  .sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
  }

  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .stats-metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .charts-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }
}
