/* ============================================
   الثيمات (Themes)
   ============================================ */
:root,
[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #151f35;
  --surface-2: #1c2942;
  --surface-3: #243358;
  --border: #263156;
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.15);
  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.15);
  --danger: #ef4444;
  --warning: #f59e0b;
  --purple: #8b5cf6;
  --teal: #14b8a6;
  --text: #e8eefc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --header-bg: #151f35;
  --nav-bg: #151f35;
  --shadow-color: rgba(0, 0, 0, 0.4);
}

[data-theme="purple"] {
  --bg: #120a24;
  --surface: #1e1338;
  --surface-2: #2a1b4d;
  --surface-3: #3a2663;
  --border: #3d2668;
  --primary: #a855f7;
  --primary-glow: rgba(168, 85, 247, 0.2);
  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.15);
  --danger: #ef4444;
  --warning: #f59e0b;
  --purple: #a855f7;
  --teal: #14b8a6;
  --text: #f2ebff;
  --text-muted: #b4a5d6;
  --text-dim: #7d6ea8;
  --header-bg: #1e1338;
  --nav-bg: #1e1338;
  --shadow-color: rgba(80, 0, 120, 0.4);
}

[data-theme="emerald"] {
  --bg: #051914;
  --surface: #0a2820;
  --surface-2: #103a2f;
  --surface-3: #164a3c;
  --border: #1a5244;
  --primary: #10b981;
  --primary-glow: rgba(16, 185, 129, 0.2);
  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.15);
  --danger: #ef4444;
  --warning: #f59e0b;
  --purple: #8b5cf6;
  --teal: #14b8a6;
  --text: #e0f7ef;
  --text-muted: #8eb8ab;
  --text-dim: #5a8a7d;
  --header-bg: #0a2820;
  --nav-bg: #0a2820;
  --shadow-color: rgba(0, 60, 40, 0.4);
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #e2e8f0;
  --border: #d1dae6;
  --primary: #2563eb;
  --primary-glow: rgba(37, 99, 235, 0.12);
  --success: #16a34a;
  --success-glow: rgba(22, 163, 74, 0.12);
  --danger: #dc2626;
  --warning: #d97706;
  --purple: #7c3aed;
  --teal: #0d9488;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --header-bg: #ffffff;
  --nav-bg: #ffffff;
  --shadow-color: rgba(15, 23, 42, 0.1);
}

/* ============================================
   الأساسيات
   ============================================ */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 90px;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.3s, color 0.3s;
}

/* ============================================
   Header
   ============================================ */
header {
  background: var(--header-bg);
  padding: 16px 16px 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  transition: background-color 0.3s;
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
header .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 400;
}
#btnSettings {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
#btnSettings:active {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(0.95);
}

/* ============================================
   Content
   ============================================ */
main {
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
}
.tab-content {
  animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.hidden { display: none !important; }

/* ============================================
   Stats
   ============================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat {
  background: var(--surface);
  padding: 12px 8px;
  border-radius: 14px;
  text-align: center;
  border: 1px solid var(--border);
  transition: transform 0.2s, background-color 0.3s;
}
.stat .num {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.stat .lbl {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

/* ============================================
   Inputs
   ============================================ */
input, select, button, textarea {
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s;
  font-size: 15px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.field input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.field input.valid { border-color: var(--success); }

.hint {
  font-size: 11.5px;
  margin-top: 5px;
  min-height: 14px;
  line-height: 1.5;
  font-weight: 500;
}
.hint.warn { color: var(--warning); }
.hint.error { color: var(--danger); }
.hint.ok { color: var(--success); }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

/* ============================================
   Radio Group
   ============================================ */
.radio-group { display: flex; gap: 8px; }
.radio-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  font-weight: 600;
}
.radio-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  margin: 0;
  cursor: pointer;
}
.radio-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-glow);
}

/* ============================================
   Buttons
   ============================================ */
button {
  padding: 13px 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.15s;
  font-family: inherit;
}
button:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  font-size: 15px;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-primary:active { filter: brightness(0.9); }
.btn-wa { background: #25D366; color: white; }
.btn-danger {
  background: var(--danger);
  color: white;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.btn-renew { background: #0891b2; color: white; padding: 8px 12px; font-size: 13px; }
.btn-att { background: var(--purple); color: white; padding: 8px 12px; font-size: 13px; }
.btn-pay {
  background: var(--success);
  color: white;
  padding: 8px 12px;
  font-size: 13px;
  box-shadow: 0 2px 8px var(--success-glow);
}
.btn-share { background: #0ea5e9; color: white; width: 100%; font-size: 14px; }
.btn-copy { background: #0d9488; color: white; width: 100%; font-size: 14px; }
.btn-download { background: #6366f1; color: white; width: 100%; font-size: 14px; }
.btn-restore { background: var(--warning); color: #1a1a1a; width: 100%; font-size: 14px; font-weight: 700; }
.btn-paste { background: var(--purple); color: white; width: 100%; font-size: 14px; }
.btn-icon-pick {
  background: var(--surface-2);
  color: var(--text);
  padding: 0 16px;
  border-radius: 10px;
  font-size: 18px;
  border: 1.5px solid var(--border);
}

/* ============================================
   Search & Sort
   ============================================ */
.search-wrap { position: relative; margin-bottom: 10px; }
.search-wrap::before {
  content: '🔍';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  opacity: 0.6;
}
.search-bar {
  width: 100%;
  padding: 13px 44px 13px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  transition: all 0.15s;
}
.search-bar:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.search-bar::placeholder { color: var(--text-dim); }

.sort-select {
  padding: 11px 14px;
  background: var(--surface);
  border-radius: 10px;
  border: 1.5px solid var(--border);
  width: 100%;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 14px;
  font-weight: 500;
}
.sort-select:focus { outline: none; border-color: var(--primary); }

/* ============================================
   Member Card
   ============================================ */
.member-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-right: 3px solid var(--primary);
  transition: all 0.2s;
  position: relative;
}
.member-card.quarterly { border-right-color: var(--purple); }
.member-card.yearly { border-right-color: var(--teal); }
.member-card.expired { border-right-color: var(--danger); opacity: 0.72; }
.member-card.present { border-right-color: var(--success); }
.member-card.has-debt {
  border-right-color: var(--warning);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.2);
}
.member-card:hover { transform: translateY(-1px); }

.member-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.member-title { flex: 1; min-width: 0; }
.member-name {
  font-weight: 700;
  font-size: 15.5px;
  margin-bottom: 6px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge.active { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.badge.exp { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.badge.monthly { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge.quarterly { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; }
.badge.yearly { background: rgba(20, 184, 166, 0.15); color: #5eead4; }
.badge.debt { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.badge.paid { background: rgba(34, 197, 94, 0.15); color: #86efac; }

[data-theme="light"] .badge.active { background: #dcfce7; color: #15803d; }
[data-theme="light"] .badge.exp { background: #fee2e2; color: #b91c1c; }
[data-theme="light"] .badge.monthly { background: #dbeafe; color: #1d4ed8; }
[data-theme="light"] .badge.quarterly { background: #ede9fe; color: #6d28d9; }
[data-theme="light"] .badge.yearly { background: #ccfbf1; color: #0f766e; }
[data-theme="light"] .badge.debt { background: #fef3c7; color: #b45309; }
[data-theme="light"] .badge.paid { background: #dcfce7; color: #15803d; }

.quick-check {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.quick-check:active { transform: scale(0.9); }
.quick-check.done {
  background: var(--success);
  border-color: var(--success);
  color: white;
  box-shadow: 0 2px 10px var(--success-glow);
}

.member-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.9;
  margin-bottom: 4px;
}
.member-meta a { color: #60a5fa; text-decoration: none; }
[data-theme="light"] .member-meta a { color: #2563eb; }

.end-marker {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  margin-right: 4px;
  white-space: nowrap;
}
.end-marker.expired { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.end-marker.soon { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.end-marker.ok { background: rgba(34, 197, 94, 0.15); color: #86efac; }

[data-theme="light"] .end-marker.expired { background: #fee2e2; color: #b91c1c; }
[data-theme="light"] .end-marker.soon { background: #fef3c7; color: #b45309; }
[data-theme="light"] .end-marker.ok { background: #dcfce7; color: #15803d; }

/* شريط تقدم الدفع */
.payment-progress {
  margin-top: 8px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  border: 1px solid var(--border);
}
.payment-progress-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: 600;
}
.payment-progress-row .paid { color: var(--success); }
.payment-progress-row .remaining { color: var(--warning); }
.payment-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.payment-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #4ade80);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.member-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ============================================
   Empty
   ============================================ */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
}
.empty .emoji {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ============================================
   Section Title
   ============================================ */
.section-title {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 20px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.section-note {
  font-size: 10.5px;
  text-transform: none;
  color: var(--text-dim);
  font-weight: 500;
}

/* ============================================
   Check Row
   ============================================ */
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  background: var(--surface);
  padding: 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s;
}
.check-row:hover { border-color: var(--primary); }
.check-row input {
  width: 20px;
  height: 20px;
  accent-color: #25D366;
  cursor: pointer;
  flex-shrink: 0;
}
.check-row span { font-size: 14px; font-weight: 500; }

/* ============================================
   Bottom Nav
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
  padding: 6px 6px 8px;
  backdrop-filter: blur(20px);
  transition: background-color 0.3s;
}
.nav-item {
  flex: 1;
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}
.nav-item .nav-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform 0.2s;
}
.nav-item .nav-label { font-size: 11px; font-weight: 600; }
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon { transform: scale(1.1); }
.nav-item:active { transform: scale(0.95); }

/* ============================================
   Toast
   ============================================ */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--success);
  color: white;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s ease-out;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px var(--shadow-color);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================
   Rich Toast
   ============================================ */
.rich-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: linear-gradient(135deg, #166534, #14532d);
  color: white;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 400;
  opacity: 0;
  transition: all 0.35s ease-out;
  max-width: 92%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  text-align: center;
  border: 1px solid rgba(34, 197, 94, 0.3);
  line-height: 1.6;
}
.rich-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.rich-toast .rich-amount {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: #86efac;
  margin: 4px 0 6px;
}
.rich-toast .rich-action {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 8px;
  margin-top: 8px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
}
.rich-toast .rich-action:active {
  background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   Modals
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s;
}
[data-theme="light"] .modal-overlay {
  background: rgba(15, 23, 42, 0.5);
}
.modal-box {
  background: var(--surface);
  border-radius: 18px;
  padding: 22px;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-box h2 {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 700;
  flex-shrink: 0;
}
.modal-body {
  overflow-y: auto;
  flex: 1;
  margin-bottom: 12px;
  scrollbar-width: thin;
}

/* ============================================
   Pick Item
   ============================================ */
.pick-item {
  background: var(--bg);
  padding: 13px 14px;
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  transition: all 0.15s;
}
.pick-item:active {
  background: var(--surface-2);
  border-color: var(--primary);
  transform: scale(0.98);
}
.pick-name { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.pick-meta { font-size: 12px; color: var(--text-muted); }

/* ============================================
   Attendance Row
   ============================================ */
.att-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 14px;
  border: 1px solid var(--border);
}
.att-row .date { font-weight: 600; }
.att-row .time {
  color: var(--text-muted);
  font-size: 12.5px;
  background: var(--surface-2);
  padding: 3px 10px;
  border-radius: 6px;
}

/* ============================================
   Date Bar
   ============================================ */
.date-bar {
  background: var(--surface);
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.date-bar label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.date-bar input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.date-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================
   Cash Page
   ============================================ */
.cash-header {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: stretch;
}
.btn-employees {
  background: var(--purple);
  color: white;
  padding: 12px 16px;
  font-size: 20px;
  border-radius: 10px;
  flex-shrink: 0;
}

.cash-balance-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.balance-item { display: flex; align-items: center; gap: 10px; }
.balance-icon { font-size: 24px; }
.balance-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 600;
}
.balance-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-top: 2px;
}

.daily-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.summary-card {
  background: var(--surface);
  padding: 12px 8px;
  border-radius: 14px;
  text-align: center;
  border: 1px solid var(--border);
}
.in-card { border-top: 3px solid var(--success); }
.out-card { border-top: 3px solid var(--danger); }
.net-card { border-top: 3px solid var(--primary); }
.summary-icon { font-size: 18px; margin-bottom: 2px; }
.summary-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.summary-value {
  font-size: 18px;
  font-weight: 800;
  margin-top: 4px;
}
.in-card .summary-value { color: var(--success); }
.out-card .summary-value { color: var(--danger); }
.net-card .summary-value { color: var(--primary); }
.summary-sub {
  font-size: 9.5px;
  color: var(--text-dim);
  margin-top: 3px;
}

.cash-actions-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.cash-actions-row button {
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}
.cash-actions-row span:first-child { font-size: 20px; }

.btn-add-expense {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-add-advance {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.btn-add-salary {
  background: rgba(20, 184, 166, 0.15);
  color: #5eead4;
  border: 1px solid rgba(20, 184, 166, 0.3);
}
.btn-add-income {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

[data-theme="light"] .btn-add-expense { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
[data-theme="light"] .btn-add-advance { background: #fef3c7; color: #b45309; border-color: #fde68a; }
[data-theme="light"] .btn-add-salary { background: #ccfbf1; color: #0f766e; border-color: #99f6e4; }
[data-theme="light"] .btn-add-income { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }

.cash-section-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 800;
  margin: 16px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cash-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.cash-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.cash-icon { font-size: 20px; }
.cash-name { flex: 1; font-weight: 700; font-size: 14px; }
.cash-total { font-weight: 800; font-size: 16px; }
.cash-total.success { color: var(--success); }
.cash-total.danger { color: var(--danger); }
.cash-breakdown { font-size: 13px; }
.cash-breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  color: var(--text-muted);
}
.cash-breakdown-row + .cash-breakdown-row { border-top: 1px dashed var(--border); }
.cash-breakdown-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 8px;
  font-size: 12px;
}

.cash-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 14px;
  font-weight: 700;
}
.total-value { font-size: 17px; font-weight: 800; }
.total-value.success { color: var(--success); }
.total-value.danger { color: var(--danger); }

.net-summary {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.net-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 14px;
}
.net-row + .net-row { border-top: 1px solid var(--border); }
.net-row.big {
  padding-top: 14px;
  font-size: 16px;
  font-weight: 800;
}
.net-amount {
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
}
.net-amount.success { color: var(--success); }

/* ============================================
   Transaction Item
   ============================================ */
.tx-item {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-right: 3px solid var(--success);
}
.tx-item.out { border-right-color: var(--danger); }
.tx-icon { font-size: 22px; flex-shrink: 0; }
.tx-info { flex: 1; min-width: 0; }
.tx-desc {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-meta { font-size: 11px; color: var(--text-muted); }
.tx-amount { font-size: 14px; font-weight: 800; flex-shrink: 0; }
.tx-amount.in { color: var(--success); }
.tx-amount.out { color: var(--danger); }
.tx-del {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
}
.tx-del:active {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* ============================================
   Employee Card
   ============================================ */
.emp-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.emp-card:active {
  background: var(--surface-2);
  border-color: var(--primary);
}
.emp-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}
.emp-name { font-weight: 700; font-size: 15px; }
.emp-role {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 6px;
}
.emp-meta { font-size: 12px; color: var(--text-muted); line-height: 1.7; }
.emp-actions { display: flex; gap: 6px; margin-top: 8px; }
.emp-actions button {
  flex: 1;
  padding: 8px;
  font-size: 12px;
  border-radius: 8px;
}

/* ============================================
   Income Preview
   ============================================ */
.income-preview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), rgba(34, 197, 94, 0.05));
  border: 1.5px solid rgba(34, 197, 94, 0.35);
  border-radius: 10px;
  margin-bottom: 14px;
  animation: previewPop 0.3s ease-out;
}
@keyframes previewPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.income-preview-icon { font-size: 26px; flex-shrink: 0; }
.income-preview-body { flex: 1; min-width: 0; }
.income-preview-title {
  font-size: 11.5px;
  color: var(--success);
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.income-preview-detail {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}
.income-preview-detail b {
  color: var(--success);
  font-size: 15px;
  font-weight: 800;
}
.income-preview-remaining {
  font-size: 11.5px;
  color: var(--warning);
  margin-top: 6px;
  font-weight: 600;
  padding-top: 6px;
  border-top: 1px dashed rgba(245, 158, 11, 0.3);
}
[data-theme="light"] .income-preview {
  background: linear-gradient(135deg, #dcfce7, #f0fdf4);
  border-color: #86efac;
}

/* ============================================
   Payment Modal / Summary
   ============================================ */
.pay-summary {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.pay-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.pay-summary-row + .pay-summary-row { border-top: 1px dashed var(--border); }
.pay-summary-row .label { color: var(--text-muted); }
.pay-summary-row .val { font-weight: 700; }
.pay-summary-row .val.paid { color: var(--success); }
.pay-summary-row .val.remaining { color: var(--warning); font-size: 15px; }

/* ============================================
   Payments History
   ============================================ */
.pay-hist-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.pay-hist-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--success-glow);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.pay-hist-info { flex: 1; min-width: 0; }
.pay-hist-amount {
  font-size: 14px;
  font-weight: 800;
  color: var(--success);
  margin-bottom: 2px;
}
.pay-hist-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.pay-hist-del {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
}
.pay-hist-del:active { color: var(--danger); }

/* ============================================
   Theme Grid
   ============================================ */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
.theme-option {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.theme-option:active { transform: scale(0.97); }
.theme-option.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.theme-preview {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}
.theme-preview::before {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  left: 8px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
}
.theme-preview::after {
  content: '';
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 24px;
  height: 6px;
  border-radius: 3px;
}
.theme-preview-dark {
  background: linear-gradient(135deg, #0b1220, #151f35);
}
.theme-preview-dark::after { background: #3b82f6; }
.theme-preview-purple {
  background: linear-gradient(135deg, #120a24, #2a1b4d);
}
.theme-preview-purple::after { background: #a855f7; }
.theme-preview-emerald {
  background: linear-gradient(135deg, #051914, #164a3c);
}
.theme-preview-emerald::after { background: #10b981; }
.theme-preview-light {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
}
.theme-preview-light::before { background: rgba(0, 0, 0, 0.1); }
.theme-preview-light::after { background: #2563eb; }
.theme-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

/* ============================================
   Backup
   ============================================ */
.backup-info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.backup-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.backup-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
#backupTextarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
  direction: ltr;
  text-align: left;
}
#backupTextarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================
   Responsive — Tablet & Desktop (Landscape)
   ============================================ */
@media (min-width: 768px) {
  main {
    max-width: 900px;
    padding: 24px;
  }

  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
  .stat { padding: 18px 12px; }
  .stat .num { font-size: 28px; }

  .cash-balance-bar {
    grid-template-columns: 1fr 1fr;
    padding: 18px;
  }
  .balance-value { font-size: 20px; }

  .daily-summary {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
  .summary-value { font-size: 22px; }

  .cash-actions-row {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
  .cash-actions-row button { padding: 18px 12px; }

  /* تصميم الشبكة للكروت */
  #membersList,
  #attList,
  #transactionsList {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .member-card,
  .tx-item {
    margin-bottom: 0;
  }

  /* القائمة الجانبية */
  header { padding: 20px 24px 16px; }
  header h1 { font-size: 20px; }
  header .sub { font-size: 13px; }

  .bottom-nav {
    max-width: 640px;
    margin: 0 auto;
    border-radius: 16px 16px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    padding: 8px 12px;
  }

  .modal-box { max-width: 520px; }
}

@media (min-width: 1024px) {
  main {
    max-width: 1100px;
    padding: 32px;
  }

  .stats-row {
    gap: 16px;
  }

  #membersList,
  #attList,
  #transactionsList {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .cash-actions-row button {
    flex-direction: row;
    gap: 10px;
    padding: 14px 20px;
    font-size: 14px;
  }

  /* تصميم عمودين للفورم */
  #tab-add {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
  }
  #tab-add > .section-title {
    grid-column: 1 / -1;
  }
  #tab-add > .btn-primary,
  #tab-add > div:last-child {
    grid-column: 1 / -1;
  }

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

  .modal-box { max-width: 600px; }
}

/* ============================================
   Landscape Mobile (أفقي على الموبايل)
   ============================================ */
@media (orientation: landscape) and (max-height: 500px) {
  body {
    padding-bottom: 0;
    padding-left: 80px;
  }

  header {
    position: fixed;
    top: 0;
    right: 0;
    left: 80px;
    padding: 10px 16px;
  }
  header h1 { font-size: 14px; }
  header .sub { font-size: 11px; }

  main {
    padding: 12px;
    max-width: 100%;
    margin-top: 56px;
  }

  /* شريط تنقل جانبي */
  .bottom-nav {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: 80px;
    flex-direction: column;
    padding: 12px 6px;
    border-top: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
  }
  .nav-item {
    padding: 12px 6px;
    margin-bottom: 6px;
  }
  .nav-item .nav-icon { font-size: 26px; }
  .nav-item .nav-label { font-size: 10px; }

  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
  }
  .stat { padding: 8px 6px; }
  .stat .num { font-size: 18px; }

  .cash-header { flex-wrap: nowrap; }
  .cash-balance-bar { padding: 10px; margin-bottom: 8px; }
  .balance-icon { font-size: 20px; }
  .balance-value { font-size: 14px; }

  .daily-summary { gap: 6px; margin-bottom: 8px; }
  .summary-card { padding: 8px 6px; }
  .summary-value { font-size: 15px; }

  .cash-actions-row { gap: 4px; margin-bottom: 10px; }
  .cash-actions-row button {
    flex-direction: row;
    padding: 8px 6px;
    font-size: 11px;
    gap: 4px;
  }
  .cash-actions-row span:first-child { font-size: 16px; }

  .toast { bottom: 20px; }
  .rich-toast { bottom: 30px; }
}

/* ============================================
   تحسينات اللمس للسطح المكتبي
   ============================================ */
@media (hover: hover) and (pointer: fine) {
  button:hover { filter: brightness(1.1); }
  .member-card:hover { border-color: var(--surface-3); }
  .pick-item:hover { background: var(--surface-2); border-color: var(--primary); }
  .emp-card:hover { background: var(--surface-2); border-color: var(--primary); }
  .theme-option:hover { border-color: var(--primary); }
}

/* ============================================
   Animations
   ============================================ */
@keyframes pulseSuccess {
  0%, 100% { box-shadow: 0 2px 10px var(--success-glow); }
  50% { box-shadow: 0 2px 20px rgba(34, 197, 94, 0.4); }
}

.payment-progress-fill.complete {
  animation: pulseSuccess 2s infinite;
}

/* ============================================
   تفاصيل بنود الخزنة (جديد)
   ============================================ */
.cash-category-block {
  border-bottom: 1px dashed var(--border);
  padding-bottom: 10px;
  margin-bottom: 10px;
}
.cash-category-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}
.cash-category-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.cash-category-head .cat-amount {
  font-weight: 800;
  color: var(--success);
}
.cash-category-head .cat-amount.out {
  color: var(--danger);
}
.cash-detail-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  margin-top: 6px;
  font-size: 12px;
}
.cash-detail-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.cash-detail-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cash-detail-amount {
  color: var(--success);
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}
.cash-detail-amount.out {
  color: var(--danger);
}
.cash-detail-meta {
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.6;
}
.cash-detail-notes {
  color: var(--text-muted);
  font-size: 11.5px;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed var(--border);
  line-height: 1.6;
}