/* ================================================================
   admin.css — Bot Midrash Admin Panel
   Light theme · Dark sidebar · RTL · Mobile-first
   ================================================================ */

/* ── Fonts ──────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Variables ──────────────────────────────────────────────────── */
:root {
  /* Brand */
  --green:         #10b981;
  --green-dark:    #059669;
  --green-darker:  #064e3b;
  --green-light:   #d1fae5;
  --green-50:      #ecfdf5;
  --green-glow:    0 0 0 3px rgba(16,185,129,.2);

  /* Sidebar */
  --sidebar-bg:    #0f172a;
  --sidebar-w:     260px;
  --header-h:      60px;

  /* Blue accent */
  --blue:          #3b82f6;
  --blue-dark:     #1d4ed8;
  --blue-light:    #dbeafe;

  /* Status colours */
  --danger:        #ef4444;
  --danger-dark:   #b91c1c;
  --danger-light:  #fee2e2;
  --warning:       #f59e0b;
  --warning-dark:  #b45309;
  --warning-light: #fef3c7;
  --info:          #0ea5e9;
  --info-light:    #e0f2fe;

  /* Surfaces */
  --bg:       #f1f5f9;
  --surface:  #ffffff;
  --surface2: #f8fafc;
  --border:   #e2e8f0;
  --border2:  #cbd5e1;

  /* Text */
  --text:     #0f172a;
  --text2:    #1e293b;
  --muted:    #64748b;
  --muted2:   #94a3b8;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.06);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,.25);

  /* Radii */
  --r-xs:  4px;
  --r-sm:  8px;
  --r:     12px;
  --r-md:  16px;
  --r-lg:  20px;
  --r-xl:  24px;
  --r-f:   9999px;

  /* Transition */
  --ease: cubic-bezier(.4,0,.2,1);
  --t: .15s;

  /* ── Backwards-compat aliases (used in page-level inline <style> blocks) ── */
  --primary:       var(--green);
  --primary-dark:  var(--green-dark);
  --success:       var(--green);
  --success-dark:  var(--green-dark);
  --radius:        var(--r);
  --radius-sm:     var(--r-sm);
  --radius-md:     var(--r-md);
  --radius-lg:     var(--r-lg);
  --radius-xl:     var(--r-xl);
  --radius-full:   var(--r-f);
  --surface-2:     var(--surface2);
  --shadow-xs:     var(--shadow-sm);
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { direction: rtl; font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: .9375rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

a { color: var(--green-dark); text-decoration: none; transition: color var(--t) var(--ease); }
a:hover { color: var(--green-darker); }

/* ── Layout ─────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  flex-direction: row-reverse;
  min-height: 100vh;
}

.admin-content {
  flex: 1;
  min-width: 0;
  margin-right: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 300;
  display: flex;
  flex-direction: column;
  transition: transform .28s var(--ease);
}

.admin-sidebar::-webkit-scrollbar { width: 3px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }

/* glow at top */
.admin-sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 0; bottom: 0;
  background: radial-gradient(ellipse at 60% 0%, rgba(16,185,129,.08) 0%, transparent 55%);
  pointer-events: none;
}

/* header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(16,185,129,.35);
}

.sidebar-logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-logo-text span:first-child { font-size: .9rem; font-weight: 700; color: #fff; }
.sidebar-logo-text span:last-child  { font-size: .65rem; color: rgba(255,255,255,.35); font-weight: 400; }

/* backwards compat: single <span class="sidebar-logo"> */
span.sidebar-logo {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-close {
  display: none;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.5);
  width: 28px; height: 28px;
  border-radius: var(--r-xs);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all var(--t) var(--ease);
}
.sidebar-close:hover { background: rgba(255,255,255,.12); color: #fff; }

/* nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: relative;
  z-index: 1;
}

.sidebar-section-label {
  padding: 12px 10px 5px;
  font-size: .62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.2);
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 7px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.5);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--t) var(--ease);
  text-decoration: none;
  position: relative;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.85);
}

.sidebar-link.active {
  background: rgba(16,185,129,.15);
  color: #6ee7b7;
  font-weight: 600;
  border: 1px solid rgba(16,185,129,.2);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--green);
  border-radius: 0 3px 3px 0;
}

.sidebar-link-super { color: rgba(251,191,36,.6); }
.sidebar-link-super:hover { background: rgba(251,191,36,.08); color: rgba(251,191,36,.9); }

.sidebar-icon { font-size: .9rem; width: 20px; text-align: center; flex-shrink: 0; }

/* footer */
.sidebar-footer {
  padding: 13px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

/* new footer (with avatar div) */
.sidebar-footer-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-footer-info { flex: 1; min-width: 0; }
.sidebar-footer-info span {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-footer-info a {
  font-size: .72rem;
  color: rgba(255,255,255,.3);
  transition: color var(--t) var(--ease);
}
.sidebar-footer-info a:hover { color: #fca5a5; }

/* old footer (span + a) */
.sidebar-footer > span {
  color: rgba(255,255,255,.55);
  font-size: .8rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-footer > a {
  color: rgba(255,255,255,.35);
  font-size: .78rem;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-xs);
  transition: all var(--t) var(--ease);
  white-space: nowrap;
}
.sidebar-footer > a:hover { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.3); color: #fca5a5; }

/* overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 299;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ── Header ─────────────────────────────────────────────────────── */
.admin-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-xs);
}

.sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 16px;
  align-items: center;
  justify-content: center;
  transition: all var(--t) var(--ease);
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--surface2); color: var(--text); }

.admin-header-title {
  font-size: .9375rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.admin-header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: .85rem;
}

.admin-header-user a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--danger-light);
  border: 1px solid #fecaca;
  color: var(--danger-dark);
  padding: 5px 13px;
  border-radius: var(--r-f);
  font-size: .8rem;
  font-weight: 600;
  transition: all var(--t) var(--ease);
}
.admin-header-user a:hover {
  background: #fee2e2;
  border-color: var(--danger);
  color: var(--danger-dark);
  box-shadow: var(--shadow-sm);
}

/* ── Impersonation banner ───────────────────────────────────────── */
.impersonation-banner {
  background: var(--warning-light);
  border-bottom: 1px solid #fde68a;
  color: var(--warning-dark);
  padding: 10px 20px;
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.impersonation-banner form { display: inline; margin: 0; }
.impersonation-banner button {
  background: var(--warning-dark);
  color: #fff;
  border: none;
  padding: 4px 14px;
  border-radius: var(--r-f);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  transition: opacity var(--t) var(--ease);
}
.impersonation-banner button:hover { opacity: .85; }

/* ── Main ───────────────────────────────────────────────────────── */
.admin-main {
  flex: 1;
  padding: 26px 26px 52px;
  max-width: 1440px;
  width: 100%;
  animation: fadeIn .22s ease;
}

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

/* ── Card ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* ── Welcome banner ─────────────────────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #064e3b 60%, #065f46 100%);
  border-radius: var(--r-lg);
  padding: 28px 32px;
  margin-bottom: 22px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.welcome-banner::before {
  content: '';
  position: absolute;
  top: -50px; right: -30px;
  width: 220px; height: 220px;
  background: rgba(255,255,255,.04);
  border-radius: 50%;
  pointer-events: none;
}
.welcome-banner::after {
  content: '';
  position: absolute;
  bottom: -70px; left: 10px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,.03);
  border-radius: 50%;
  pointer-events: none;
}

.welcome-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.4px;
  margin-bottom: 5px;
  position: relative;
}

.welcome-subtitle {
  color: rgba(255,255,255,.6);
  font-size: .9rem;
  position: relative;
}

/* ── Stats ──────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: all var(--t) var(--ease);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green), var(--green-dark));
}

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

.stat-card-warn::before  { background: linear-gradient(90deg, var(--warning), #ea580c); }
.stat-card-warn:hover    { border-color: #fcd34d; }
.stat-card-danger::before { background: linear-gradient(90deg, var(--danger), var(--danger-dark)); }
.stat-card-blue::before  { background: linear-gradient(90deg, var(--blue), var(--blue-dark)); }

.stat-value, .stat-card .val {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -1.5px;
  color: var(--text);
  line-height: 1.1;
}

.stat-label, .stat-card .lbl {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-top: 4px;
}

.stat-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--warning-dark);
  background: var(--warning-light);
  padding: 3px 10px;
  border-radius: var(--r-f);
  border: 1px solid #fde68a;
  transition: all var(--t) var(--ease);
}
.stat-action:hover { background: #fde68a; }

/* ── Nav cards ──────────────────────────────────────────────────── */
.nav-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.nav-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 28px 20px 22px;
  display: block;
  text-align: center;
  color: var(--text);
  text-decoration: none;
  transition: all var(--t) var(--ease);
  position: relative;
  overflow: hidden;
}

.nav-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--green-50), transparent);
  opacity: 0;
  transition: opacity var(--t) var(--ease);
}

.nav-card:hover {
  border-color: var(--green);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--green);
  transform: translateY(-4px);
  color: var(--text);
}
.nav-card:hover::after { opacity: 1; }

.nav-card-icon {
  font-size: 2.2rem;
  margin-bottom: 12px;
  display: block;
  position: relative;
  z-index: 1;
  transition: transform .2s ease;
}
.nav-card:hover .nav-card-icon { transform: scale(1.12); }

.nav-card-label {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 5px;
  position: relative;
  z-index: 1;
}

.nav-card-desc {
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

/* ── Section title ──────────────────────────────────────────────── */
.section-title {
  font-size: .875rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .7px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Toolbar / page title ───────────────────────────────────────── */
.page-title {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--text);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--r-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--t) var(--ease);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
  letter-spacing: -.1px;
}

.btn:active { transform: scale(.97) !important; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(16,185,129,.4);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text2);
  border-color: var(--border2);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--surface2); color: var(--text); box-shadow: var(--shadow-sm); }

.btn-danger {
  background: var(--danger-light);
  color: var(--danger-dark);
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fee2e2; border-color: var(--danger); }

.btn-success {
  background: var(--green-light);
  color: var(--green-darker);
  border-color: #6ee7b7;
}
.btn-success:hover { background: #a7f3d0; }

.btn-warning {
  background: var(--warning-light);
  color: var(--warning-dark);
  border-color: #fcd34d;
}
.btn-warning:hover { background: #fde68a; }

.btn-blue {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,.3);
}
.btn-blue:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(59,130,246,.4); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--green-dark);
  border-color: var(--green);
}
.btn-outline:hover { background: var(--green-50); }

.btn-sm  { padding: 5px 12px; font-size: .8125rem; }
.btn-xs  { padding: 2px 7px; font-size: .75rem; border-radius: var(--r-xs); }
.btn-lg  { padding: 11px 26px; font-size: .9375rem; border-radius: var(--r); }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--r-f);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .2px;
  line-height: 1.5;
  border: 1px solid transparent;
}

.badge-active   { background: var(--green-light); color: var(--green-darker); border-color: #a7f3d0; }
.badge-inactive { background: var(--surface2); color: var(--muted); border-color: var(--border); }
.badge-warn     { background: var(--warning-light); color: var(--warning-dark); border-color: #fde68a; }
.badge-neutral  { background: var(--surface2); color: var(--text2); border-color: var(--border); }
.badge-info     { background: var(--info-light); color: #0369a1; border-color: #bae6fd; }
.badge-primary  { background: var(--blue-light); color: var(--blue-dark); border-color: #bfdbfe; }
.badge-danger   { background: var(--danger-light); color: var(--danger-dark); border-color: #fca5a5; }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--r-sm);
  padding: 12px 16px;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid transparent;
}

.alert-success { background: var(--green-light); border-color: #a7f3d0; color: var(--green-darker); }
.alert-error,
.alert-danger  { background: var(--danger-light); border-color: #fca5a5; color: var(--danger-dark); }
.alert-warning { background: var(--warning-light); border-color: #fde68a; color: var(--warning-dark); }
.alert-info    { background: var(--info-light); border-color: #bae6fd; color: #0369a1; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-wrap, .table-wrapper {
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.admin-table thead tr {
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
}

.admin-table thead th {
  padding: 11px 14px;
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
}

.admin-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t) var(--ease);
}

.admin-table tbody tr:last-child { border-bottom: none; }

.admin-table tbody tr:hover { background: var(--green-50); }

.admin-table tbody td {
  padding: 11px 14px;
  color: var(--text2);
  vertical-align: middle;
  text-align: right;
}

.admin-table td.actions, .actions-group, .action-group {
  white-space: nowrap;
}
.actions-group, .action-group {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}

.empty-state {
  text-align: center;
  padding: 54px 20px;
  color: var(--muted);
  font-size: .9375rem;
}
.empty-state p { margin-bottom: 6px; }

/* ── Filter bar ─────────────────────────────────────────────────── */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  box-shadow: var(--shadow-xs);
}

/* ── Filter bar search input ────────────────────────────────────── */
.filter-bar input[type="search"],
.filter-bar input[type="text"] { flex: 1; min-width: 180px; width: auto; }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-section-title {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 4px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 150px;
  margin-bottom: 12px;
}

.form-label, .form-group label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text2);
  display: block;
  margin-bottom: 4px;
}

.form-control,
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="tel"],
.form-group select,
.filter-bar input[type="search"],
.filter-bar input[type="text"],
.form-group textarea,
input[type="text"].form-control,
input[type="tel"].form-control,
select.form-control {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
  width: 100%;
  font-family: inherit;
  line-height: 1.5;
  direction: rtl;
}

.form-control:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: var(--green-glow);
  background: #fff;
}

.form-control::placeholder { color: var(--muted2); }

.form-group textarea { resize: vertical; min-height: 90px; }

.form-group select, select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2364748b' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-color: var(--surface);
  padding-left: 30px;
  cursor: pointer;
}

.form-group .hint, .form-help {
  font-size: .78rem;
  color: var(--muted2);
  margin-top: -2px;
}

/* ── Stats day-filter buttons (standalone, not using .btn) ─────── */
.day-filter { display: flex; gap: .4rem; margin-bottom: 1.25rem; flex-wrap: wrap; }

.day-btn {
  padding: .35rem .9rem;
  border: 1.5px solid var(--border2);
  border-radius: var(--r-f);
  background: var(--surface);
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t) var(--ease);
  box-shadow: var(--shadow-xs);
}
.day-btn:hover:not(.active) { border-color: var(--green); color: var(--green-dark); background: var(--green-50); }
.day-btn.active { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,.3); }

/* ── Modals ─────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .22s cubic-bezier(.34, 1.56, .64, 1);
}

.modal-lg { max-width: 760px; }
.modal-xl { max-width: 940px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}

.modal-title { font-size: 1rem; font-weight: 700; color: var(--text); }

/* modal-title used directly inside .modal (without .modal-header wrapper) */
.modal > .modal-title,
.modal > h2,
.modal > h3 {
  display: block;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t) var(--ease);
}
.modal-close:hover { background: var(--danger-light); border-color: #fca5a5; color: var(--danger-dark); }

.modal-body { padding: 22px; background: var(--surface2); }

.modal-footer, .modal-actions {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--surface2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* ── Modal form content padding ────────────────────────── */
/* Ensures form fields inside modals have proper padding when not using .modal-body */
.modal > form { padding: 22px; }
.modal > form > .modal-actions,
.modal > form > div.modal-actions {
  margin: 0 -22px -22px;
  padding: 14px 22px;
}

/* Single-column form rows inside standard modals */
.modal .form-row {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.modal .form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Profile avatar in edit modal */
.person-avatar-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
}
.person-avatar-initials {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.modal-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-avatar-info { display: flex; flex-direction: column; gap: 3px; }
.modal-avatar-info .person-name { font-size: 1.0625rem; font-weight: 700; color: var(--text); }
.modal-avatar-info .person-phone { font-size: .8125rem; color: var(--muted); }

/* ── Tabs ───────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 9px 18px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--t) var(--ease);
  white-space: nowrap;
  text-decoration: none;
  background: none;
  cursor: pointer;
  border-top: none;
  border-right: none;
  border-left: none;
  font-family: inherit;
}

.tab-link:hover { color: var(--text); }

.tab-link.active {
  color: var(--green-dark);
  border-bottom-color: var(--green);
}

.tab-count {
  background: var(--surface2);
  color: var(--muted);
  padding: 1px 7px;
  border-radius: var(--r-f);
  font-size: .68rem;
  font-weight: 700;
}
.tab-link.active .tab-count { background: var(--green-light); color: var(--green-darker); }

/* ── Pagination ─────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 14px; }

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: .8125rem;
  font-weight: 600;
  color: var(--muted);
  border: 1.5px solid var(--border);
  background: var(--surface);
  transition: all var(--t) var(--ease);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}

.page-link:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.page-link.active { background: var(--green); color: #fff; border-color: var(--green); box-shadow: 0 2px 8px rgba(16,185,129,.35); }
.page-link:disabled,
.page-link.disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }

/* ── Plugins ────────────────────────────────────────────────────── */
.plugin-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  margin-bottom: 7px;
  transition: all var(--t) var(--ease);
  cursor: pointer;
}
.plugin-item:hover { border-color: var(--green); background: var(--green-50); }
.plugin-item input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--green); cursor: pointer; }
.plugin-name { font-weight: 600; font-size: .875rem; color: var(--text); }
.plugin-item label { font-weight: 500; font-size: .875rem; cursor: pointer; flex: 1; margin: 0; }
.plugin-item .plugin-desc { font-size: .75rem; color: var(--muted); }

/* ── Chart ──────────────────────────────────────────────────────── */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.chart-wrap h3 { font-size: .875rem; font-weight: 700; color: var(--text); margin-bottom: 14px; }

/* ── Login page ─────────────────────────────────────────────────── */
body.login-page {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 100vh !important;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .28s ease;
}

.login-logo {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin: 0 auto 18px;
  box-shadow: 0 8px 24px rgba(16,185,129,.35);
}

.login-title {
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -.4px;
}

.login-subtitle {
  font-size: .875rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
  line-height: 1.65;
}

.login-back {
  display: block;
  text-align: center;
  margin-top: 14px;
  font-size: .82rem;
  color: var(--muted2);
  transition: color var(--t) var(--ease);
}
.login-back:hover { color: var(--muted); }

/* ── Utilities ──────────────────────────────────────────────────── */
.text-muted   { color: var(--muted) !important; }
.text-danger  { color: var(--danger) !important; }
.text-success { color: var(--green-dark) !important; }
.text-warning { color: var(--warning-dark) !important; }
.text-center  { text-align: center !important; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 14px; }
.mb-4 { margin-bottom: 20px; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.flex-wrap    { flex-wrap: wrap; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }

/* ── Responsive — tablet / mobile ───────────────────────────────── */
@media (max-width: 1024px) {
  .admin-content {
    margin-right: 0;
    width: 100%;
    max-width: 100%;
  }

  .admin-sidebar {
    right: calc(-1 * var(--sidebar-w));
    transform: none;
    box-shadow: none;
    transition: right .28s var(--ease);
  }
  .admin-sidebar.open {
    right: 0;
    transform: none;
    box-shadow: var(--shadow-xl);
  }

  .sidebar-toggle { display: flex; }
  .sidebar-close  { display: flex; }

  .admin-main   { padding: 18px 16px 42px; }
  .admin-header { padding: 0 16px; }

  /* table → cards */
  .admin-table thead { display: none; }
  .admin-table tbody tr {
    display: flex;
    flex-direction: column;
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    gap: 4px;
  }
  .admin-table tbody td {
    padding: 2px 0;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    border: none;
  }
  .admin-table tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--muted);
    white-space: nowrap;
    min-width: 85px;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-cards-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .admin-main  { padding: 14px 12px 36px; }
  .welcome-banner { padding: 22px 20px; }
  .welcome-title { font-size: 1.25rem; }
  .nav-card { padding: 20px 12px 16px; }
  .nav-card-icon { font-size: 1.8rem; }
  .filter-bar { padding: 11px 13px; }
  .modal { border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .toolbar .btn { font-size: .8rem; padding: 7px 11px; }
  .tab-link { padding: 9px 12px; font-size: .82rem; }
  .login-card { padding: 30px 22px; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .nav-cards-grid { grid-template-columns: 1fr; }
}

/* ── Toast notifications (showToast helper in admin.js) ─────────────────────── */
.bm-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: var(--sidebar-bg);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--r-md);
  font-size: .9rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  max-width: 90vw;
  text-align: center;
  pointer-events: none;
}
.bm-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.bm-toast-success { background: var(--success, #2e7d32); }
.bm-toast-error   { background: var(--danger); }
.bm-toast-info    { background: var(--primary); }

/* ── Help Modal ─────────────────────────────────────────────────── */
.help-modal {
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 90%;
  background: var(--surface);
  color: var(--text);
}
.help-modal::backdrop {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
}
.help-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.help-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--green-darker);
}
.help-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
}
.help-modal-close:hover { color: var(--danger-dark); }
.help-modal-body {
  padding: 20px;
  line-height: 1.6;
}
.help-modal-body h4 { margin-top: 0; margin-bottom: 10px; color: var(--green-dark); }
.help-modal-body ul { margin-inline-start: 20px; margin-top: 10px; }
.help-modal-body li { margin-bottom: 8px; font-size: .95rem; }
