:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;

  /* هوية بصرية جديدة - هيدر غامق واحترافي */
  --navy: #0f172a;
  --navy-light: #1e293b;
  --navy-border: rgba(255, 255, 255, 0.08);
  --navy-text: #e2e8f0;
  --navy-muted: #94a3b8;
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --icon-blue-bg: #dbeafe;
  --icon-blue-fg: #2563eb;
  --icon-green-bg: #dcfce7;
  --icon-green-fg: #16a34a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
  background: linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%);
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.login-logo-badge {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin: 0 auto 16px;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; text-align: right; }
.form-group label { display: block; font-size: 14px; margin-bottom: 6px; color: var(--muted); }
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: #fafafa;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.error-box {
  background: var(--red-bg);
  color: var(--red);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.btn svg { flex-shrink: 0; width: 16px; height: 16px; }
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-block { width: 100%; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-deposit { background: var(--green); color: #fff; flex: 1; }
.btn-withdraw { background: var(--red); color: #fff; flex: 1; }

.actions-row .btn {
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.actions-row .btn-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.actions-row .btn-icon svg { width: 13px; height: 13px; }

/* ---------- Topbar (تصميم غامق احترافي) ---------- */
.topbar {
  background: var(--navy);
  border-bottom: 1px solid var(--navy-border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.logo-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

.company-name { font-weight: 700; font-size: 15px; color: #fff; }
.user-name { font-size: 12px; color: var(--navy-muted); }

.topbar-actions .btn-outline {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--navy-border);
  color: var(--navy-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar-actions .btn-outline:hover {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}
.topbar-actions .btn-outline svg { width: 15px; height: 15px; }

/* ---------- Admin panel extras ---------- */
.form-card { margin-bottom: 16px; }
.form-card h2 { margin: 0 0 6px; font-size: 16px; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 16px; overflow-wrap: break-word; word-break: break-word; max-width: 100%; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.inline-form .form-group { flex: 1 1 160px; margin-bottom: 0; }
.inline-form .form-group-grow { flex: 2 1 220px; }
.inline-form .form-group-narrow { flex: 0 1 140px; }
.inline-form .btn { height: 42px; flex: 0 0 auto; }

.msg-box {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.msg-box.success { background: var(--green-bg); color: var(--green); }
.msg-box.error { background: var(--red-bg); color: var(--red); }

.actions-cell { display: flex; gap: 8px; flex-wrap: wrap; }

select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: #fafafa;
}

/* ---------- Section headers with icon badges ---------- */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.section-header h2 { margin: 0; }

.icon-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--icon-blue-bg);
  color: var(--icon-blue-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-circle svg { width: 17px; height: 17px; }

/* ---------- Role / status badges ---------- */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-role-admin { background: var(--icon-blue-bg); color: var(--icon-blue-fg); }
.badge-role-user { background: #ede9fe; color: #7c3aed; }
.badge-status-active { background: var(--green-bg); color: var(--green); }
.badge-status-inactive { background: var(--red-bg); color: var(--red); }

/* ---------- Pill action buttons (جدول المستخدمين) ---------- */
.btn-small {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.btn-small svg { width: 13px; height: 13px; }

.btn-edit {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
}
.btn-edit:hover { border-color: var(--primary); color: var(--primary); }

.btn-delete {
  border: none;
  background: var(--red-bg);
  color: var(--red);
  border-radius: 999px;
}
.btn-delete:hover { opacity: 0.85; }

.btn-activate {
  border: none;
  background: var(--green-bg);
  color: var(--green);
  border-radius: 999px;
}
.btn-activate:hover { opacity: 0.85; }

.btn-deposit-small {
  border: 1px solid var(--green);
  background: #fff;
  color: var(--green);
  border-radius: 8px;
}
.btn-deposit-small:hover { background: var(--green-bg); }

.btn-withdraw-small {
  border: 1px solid var(--red);
  background: #fff;
  color: var(--red);
  border-radius: 8px;
}
.btn-withdraw-small:hover { background: var(--red-bg); }

.btn-history {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 8px;
}
.btn-history:hover { border-color: var(--primary); color: var(--primary); }

.modal-wide { max-width: 640px; }

.invoice-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 700;
  padding: 14px 4px;
  margin-top: 8px;
  border-top: 2px solid var(--border);
  color: var(--primary);
}

/* زرار حذف عملية - أيقونة بس داخل مربع أحمر فاتح */
.btn-icon-danger {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--red-bg);
  color: var(--red);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-icon-danger:hover { background: var(--red); color: #fff; }
.btn-icon-danger svg { width: 15px; height: 15px; }

/* ---------- Layout ---------- */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
}

.summary-grid .card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.card-value { font-size: 26px; font-weight: 700; }

.balance-card .card-value { color: var(--primary); }

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-icon svg { width: 22px; height: 22px; }
.card-icon-blue { background: var(--icon-blue-bg); color: var(--icon-blue-fg); }
.card-icon-green { background: var(--icon-green-bg); color: var(--icon-green-fg); }

.actions-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.actions-row .btn { font-size: 16px; padding: 14px; }

/* ---------- Quick nav cards (أقسام الشركة) ---------- */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 10px;
}
.nav-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.nav-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
}
.nav-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.08); }
.nav-card-label { font-size: 13px; font-weight: 600; }
.nav-card .icon-circle { width: 44px; height: 44px; }
.nav-card .icon-circle svg { width: 20px; height: 20px; }

.nav-icon-amber { background: #fef3c7; color: #d97706; }
.nav-icon-blue { background: var(--icon-blue-bg); color: var(--icon-blue-fg); }
.nav-icon-violet { background: #ede9fe; color: #7c3aed; }
.nav-icon-green { background: var(--icon-green-bg); color: var(--icon-green-fg); }

@media (max-width: 560px) {
  .nav-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Table ---------- */
.table-card { padding: 0; overflow: hidden; }

/* ---------- قوائم الموظفين/العملاء (صفوف قابلة للضغط) ---------- */
.entity-list { display: flex; flex-direction: column; }
.entity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}
.entity-row:last-child { border-bottom: none; }
.entity-row:hover { background: #fafafa; }
.entity-row-inactive { opacity: 0.55; }
.entity-name { font-weight: 600; font-size: 15px; }
.entity-balance { font-weight: 700; font-size: 15px; }

/* ---------- صفحة البروفايل الشخصي ---------- */
.profile-header {
  text-align: center;
  padding: 24px 16px 8px;
}
.profile-header h1 { margin: 0 0 6px; font-size: 20px; }
.profile-balance-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.profile-balance-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.profile-meta { font-size: 13px; color: var(--muted); margin-top: 6px; }
.profile-actions-secondary {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.table-header h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.last-update { font-size: 12px; color: var(--muted); }

.copy-btn {
  border: none;
  background: #f1f5f9;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.copy-btn:hover { background: var(--icon-blue-bg); color: var(--icon-blue-fg); }
.copy-btn svg { width: 14px; height: 14px; }
.copy-btn.copied { background: var(--green-bg); color: var(--green); }

.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
thead th {
  text-align: right;
  padding: 10px 14px;
  background: #f9fafb;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }

.empty-state { text-align: center; color: var(--muted); padding: 30px !important; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-deposit { background: var(--green-bg); color: var(--green); }
.badge-withdraw { background: var(--red-bg); color: var(--red); }

.text-green { color: var(--green); font-weight: 600; }
.text-red { color: var(--red); font-weight: 600; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
}
.modal h2 { margin: 0 0 18px; font-size: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.modal-actions .btn { flex: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .summary-grid { grid-template-columns: 1fr; }
  .card-value { font-size: 22px; }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
  }
  .topbar-left { flex: 1 1 100%; }
  .topbar-actions { flex: 1 1 100%; justify-content: flex-end; }
  .topbar-actions .btn-outline { padding: 8px 12px; font-size: 13px; }
  .logo-badge { width: 36px; height: 36px; font-size: 17px; }
}
