/* =========================================================
   Insurance Broker CRM — Design Tokens & Styles
   RTL / Arabic. Pure CSS. WordPress-plugin friendly.
   ========================================================= */

:root {
  /* Brand palette */
  --brand-50:  #eef4ff;
  --brand-100: #dbe6ff;
  --brand-200: #b7ccff;
  --brand-400: #6a8dff;
  --brand-500: #4a6cf7;
  --brand-600: #3a56d4;
  --brand-700: #2e44a8;

  --accent-500: #14b8a6; /* teal */
  --accent-600: #0d9488;

  /* Neutrals (light) */
  --bg:        #f5f7fb;
  --bg-alt:    #eef1f8;
  --surface:   #ffffff;
  --surface-2: #f9fbff;
  --border:    #e5e9f2;
  --border-strong: #d6dbe7;
  --text:      #0f172a;
  --text-2:    #475569;
  --muted:     #6b7280;

  /* Contract status colors */
  --active:     #10b981;
  --active-bg:  #dcfce7;
  --incomplete: #f59e0b;
  --incomplete-bg: #fef3c7;
  --cancelled:  #ef4444;
  --cancelled-bg: #fee2e2;

  /* Stage colors */
  --stage-new: #3b82f6;
  --stage-int: #8b5cf6;
  --stage-hes: #f59e0b;
  --stage-no:  #64748b;
  --stage-reg: #10b981;

  /* Effects */
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-xs: 0 1px 2px rgba(15,23,42,.06);
  --shadow-sm: 0 2px 8px rgba(15,23,42,.06);
  --shadow-md: 0 8px 24px rgba(15,23,42,.08);
  --shadow-lg: 0 24px 60px rgba(15,23,42,.16);

  --grad-brand: linear-gradient(135deg, #4a6cf7 0%, #7c5cff 55%, #14b8a6 100%);
  --grad-card:  linear-gradient(180deg, #ffffff 0%, #f7f9ff 100%);

  --font-body: 'Cairo', 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --header-h: 76px;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
h1,h2,h3,h4 { margin: 0; font-weight: 800; letter-spacing: -.01em; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .875rem; }

/* ================= Buttons ================= */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .65rem 1.1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--grad-brand);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px -6px rgba(74,108,247,.55);
}
.btn-primary:hover { box-shadow: 0 12px 28px -6px rgba(74,108,247,.65); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }

.btn-block { width: 100%; justify-content: center; padding: .9rem 1.1rem; }

.btn-danger-ghost {
  background: transparent; color: var(--cancelled);
  border-color: var(--cancelled-bg);
}
.btn-danger-ghost:hover { background: var(--cancelled-bg); }

.btn-whats {
  background: #25d366; color: #fff; border-color: transparent;
  box-shadow: 0 6px 16px -6px rgba(37,211,102,.6);
}
.btn-whats:hover { background: #1ebe5c; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s ease;
}
.icon-btn:hover { background: var(--bg-alt); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ================= Inputs ================= */
.field { display: flex; flex-direction: column; gap: .4rem; }
.field-label {
  font-size: .8rem; font-weight: 600; color: var(--text-2);
}
.input-wrap {
  position: relative;
  display: flex; align-items: center;
}
.input-wrap .input-icon {
  position: absolute; right: .85rem;
  width: 18px; height: 18px; color: var(--muted);
}
.input-wrap input { padding-right: 2.6rem; }

input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="date"], input[type="search"],
.select, textarea {
  width: 100%;
  padding: .75rem .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: .95rem;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
  outline: none;
}
input:focus, .select:focus, textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(74,108,247,.14);
}
textarea { resize: vertical; min-height: 88px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: left .8rem center;
  padding-left: 2.2rem;
}

.check { display: inline-flex; align-items: center; gap: .45rem; color: var(--text-2); font-size: .9rem; cursor: pointer; }
.check input { accent-color: var(--brand-500); width: 16px; height: 16px; }

.chips-check { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-check {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem .9rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: .875rem;
  color: var(--text-2);
  transition: all .15s ease;
}
.chip-check input { accent-color: var(--brand-500); }
.chip-check:has(input:checked) {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-700);
}

.link-muted { color: var(--muted); text-decoration: none; font-size: .875rem; }
.link-muted:hover { color: var(--brand-600); }

/* ================= LOGIN ================= */
.login-screen {
  position: relative;
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 1.5rem;
  overflow: hidden;
  background: radial-gradient(1200px 700px at 100% -10%, #dfe8ff 0%, transparent 60%),
              radial-gradient(1000px 600px at 0% 110%, #d7fff2 0%, transparent 60%),
              #f5f7fb;
}
.login-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.blob-a { width: 380px; height: 380px; background: #a5b8ff; top: -80px; right: -80px; }
.blob-b { width: 340px; height: 340px; background: #a7f3d0; bottom: -80px; left: -60px; }
.blob-c { width: 260px; height: 260px; background: #f0abfc; top: 40%; left: 30%; opacity: .35; }

.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.75rem; }
.brand-mark {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 10px 24px -8px rgba(74,108,247,.6);
}
.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; }
.brand-mark svg { width: 24px; height: 24px; }
.brand-title { font-size: 1.15rem; }
.brand-sub { color: var(--muted); font-size: .8rem; }

.login-title { font-size: 1.6rem; margin-bottom: .35rem; }
.login-desc { color: var(--text-2); margin-bottom: 1.5rem; font-size: .95rem; }

.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-row { display: flex; justify-content: space-between; align-items: center; margin-top: -.25rem; }
.login-foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 1.5rem; }

/* ================= APP SHELL ================= */
.app {
  min-height: 100dvh;
  background: var(--bg);
}

/* Top app bar */
.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem clamp(1rem, 2.5vw, 2rem);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.appbar-brand { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.appbar-brand-text strong { display: block; font-size: .95rem; line-height: 1.15; }
.appbar-brand-text span { color: var(--muted); font-size: .72rem; }
.appbar-nav { display: flex; gap: .35rem; }
.nav-pill {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem 1rem; border-radius: 999px;
  border: 0; background: transparent; cursor: pointer;
  color: var(--text-2); font-weight: 700; font-size: .9rem; font-family: inherit;
  transition: all .15s ease;
}
.nav-pill svg { width: 18px; height: 18px; }
.nav-pill:hover { background: var(--bg-alt); color: var(--text); }
.nav-pill.active { background: var(--brand-50); color: var(--brand-700); box-shadow: inset 0 0 0 1px var(--brand-200); }
.appbar-actions { display: flex; align-items: center; gap: .6rem; margin-inline-start: auto; }
.appbar .user-chip { padding-inline-start: .6rem; border-inline-start: 1px solid var(--border); }
.page-head { margin-bottom: 1.5rem; }
.page-head h2 { font-size: 1.6rem; }
.page-head p { color: var(--muted); font-size: .9rem; margin-top: .15rem; }

/* Sidebar (desktop) */
.sidebar {
  position: sticky; top: 0;
  height: 100dvh;
  padding: 1.25rem 1rem;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 1rem;
}
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: .5rem; }
.sidebar-brand-text strong { display: block; font-size: .95rem; }
.sidebar-brand-text span { color: var(--muted); font-size: .75rem; }

.sidebar-nav { display: flex; flex-direction: column; gap: .25rem; margin-top: .5rem; }
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .75rem .9rem;
  border-radius: 12px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-2);
  font-weight: 600; font-size: .92rem;
  text-align: right;
  transition: all .15s ease;
}
.nav-item svg { width: 20px; height: 20px; }
.nav-item:hover { background: var(--bg-alt); color: var(--text); }
.nav-item.active {
  background: var(--brand-50);
  color: var(--brand-700);
  box-shadow: inset 3px 0 0 var(--brand-500);
}

.sidebar-foot {
  margin-top: auto;
  padding: .75rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem; justify-content: space-between;
}
.user-chip { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.user-chip strong { display: block; font-size: .85rem; }
.user-chip span { color: var(--muted); font-size: .75rem; }

/* Main */
.main { min-width: 0; max-width: 1200px; margin: 0 auto; padding: 1.5rem clamp(1rem, 2.5vw, 2rem) 6rem; }

.topbar {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}
.topbar-title h2 { font-size: 1.6rem; }
.topbar-title p { color: var(--muted); font-size: .9rem; margin-top: .15rem; }
.topbar-actions { display: flex; gap: .6rem; align-items: center; }

.search-mini {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem .8rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; min-width: 260px;
}
.search-mini svg { width: 18px; height: 18px; color: var(--muted); }
.search-mini input { border: 0; padding: 0; background: transparent; box-shadow: none !important; }

/* ================= Stats ================= */
.stats-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  position: relative;
  flex: 1 1 185px;
  max-width: 230px;
  padding: 1.4rem 1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-strip { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; color: #fff; margin-bottom: .35rem;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-icon svg { width: 22px; height: 22px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 900; letter-spacing: -.02em; line-height: 1.1; }
.stat-card .stat-label { color: var(--text); font-size: .88rem; font-weight: 700; }
.stat-card .trend { font-size: .72rem; color: var(--muted); }

.icon-bg-1 { background: linear-gradient(135deg,#4a6cf7,#7c5cff); }
.icon-bg-2 { background: linear-gradient(135deg,#10b981,#059669); }
.icon-bg-3 { background: linear-gradient(135deg,#8b5cf6,#6d28d9); }
.icon-bg-4 { background: linear-gradient(135deg,#f59e0b,#d97706); }
.icon-bg-5 { background: linear-gradient(135deg,#14b8a6,#0d9488); }
.icon-bg-6 { background: linear-gradient(135deg,#f97316,#c2410c); }
.icon-bg-7 { background: linear-gradient(135deg,#ef4444,#b91c1c); }

/* ================= Section headers ================= */
.section-head {
  display: flex; align-items: end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
}
.section-head h3 { font-size: 1.15rem; }
.section-head p { margin-top: .15rem; }

/* ================= Filters ================= */
.filters-bar {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.search-wrap {
  position: relative;
}
.search-wrap svg {
  position: absolute; right: .9rem; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted);
}
.search-wrap input { padding-right: 2.6rem; }
.filter-group { display: flex; gap: .5rem; flex-wrap: wrap; }
.filter-group .select { min-width: 160px; }

/* ================= Client Cards ================= */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.client-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow-xs);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  display: flex; flex-direction: column; gap: .9rem;
  overflow: hidden;
}
.client-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.client-card .status-strip {
  position: absolute; top: 0; inset-inline-end: 0;
  height: 4px; width: 100%;
}
.client-card.status-active .status-strip { background: linear-gradient(90deg, transparent, var(--active)); }
.client-card.status-incomplete .status-strip { background: linear-gradient(90deg, transparent, var(--incomplete)); }
.client-card.status-cancelled .status-strip { background: linear-gradient(90deg, transparent, var(--cancelled)); }

.client-head {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: .75rem; align-items: center;
}
.avatar {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 1rem;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.avatar.sm { width: 36px; height: 36px; border-radius: 10px; font-size: .82rem; }
.gradient-1 { background: linear-gradient(135deg,#4a6cf7,#7c5cff); }
.gradient-2 { background: linear-gradient(135deg,#10b981,#059669); }
.gradient-3 { background: linear-gradient(135deg,#f59e0b,#ea580c); }
.gradient-4 { background: linear-gradient(135deg,#ec4899,#be185d); }
.gradient-5 { background: linear-gradient(135deg,#14b8a6,#0e7490); }
.gradient-6 { background: linear-gradient(135deg,#8b5cf6,#6d28d9); }

.client-info { min-width: 0; }
.client-info .name { font-weight: 800; font-size: 1rem; }
.client-info .company { color: var(--muted); font-size: .82rem; margin-top: .1rem; display: flex; align-items: center; gap: .35rem; }
.client-info .company svg { width: 14px; height: 14px; }

.client-badges { display: flex; gap: .4rem; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .6rem;
  border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  background: var(--bg-alt); color: var(--text-2);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.stage-new { background: #dbeafe; color: #1d4ed8; }
.stage-interested { background: #ede9fe; color: #6d28d9; }
.stage-hesitant { background: #fef3c7; color: #b45309; }
.stage-not_interested { background: #e2e8f0; color: #475569; }
.stage-registered { background: #d1fae5; color: #047857; }

.status-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  font-size: .75rem; font-weight: 700;
}
.status-badge.active { background: var(--active-bg); color: #047857; }
.status-badge.incomplete { background: var(--incomplete-bg); color: #b45309; }
.status-badge.cancelled { background: var(--cancelled-bg); color: #b91c1c; }

.client-meta {
  display: flex; align-items: center; gap: 1rem;
  padding: .65rem .8rem;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px dashed var(--border);
  font-size: .82rem; color: var(--text-2);
  flex-wrap: wrap;
}
.client-meta .meta-item { display: flex; align-items: center; gap: .35rem; }
.client-meta svg { width: 14px; height: 14px; }

.client-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.client-actions .btn { padding: .5rem .85rem; font-size: .82rem; }
.client-actions .btn svg { width: 15px; height: 15px; }
.client-actions .spacer { flex: 1; }

/* ================= Empty ================= */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: .5rem; opacity: .5; }
.empty-state h4 { color: var(--text); margin-bottom: .35rem; }

/* ================= Modals ================= */
.modal {
  position: fixed; inset: 0;
  z-index: 60;
  display: grid; place-items: center;
  padding: 1rem;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(6px);
}
.modal-sheet, .viewer-sheet {
  position: relative;
  width: 100%; max-width: 720px;
  max-height: 90dvh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: slideUp .22s cubic-bezier(.2,.9,.3,1);
}
.modal-sheet.wide { max-width: 860px; }
.viewer-sheet { max-width: 1000px; max-height: 94dvh; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1.15rem; }
.modal-body { padding: 1.25rem; overflow: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.modal-foot .foot-right { display: flex; gap: .5rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 1rem;
}
.field-full { grid-column: 1 / -1; }

/* Client detail */
.detail-head { display: flex; align-items: center; gap: .8rem; min-width: 0; }
.detail-head .name { font-weight: 800; font-size: 1.1rem; }
.detail-head .sub { color: var(--muted); font-size: .82rem; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.detail-item {
  padding: .75rem .9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.detail-item .k { color: var(--muted); font-size: .75rem; font-weight: 600; margin-bottom: .2rem; }
.detail-item .v { font-weight: 700; font-size: .92rem; word-break: break-word; }

.detail-section-title {
  font-size: .9rem; font-weight: 800;
  margin: 1.25rem 0 .6rem;
  display: flex; align-items: center; gap: .5rem;
}
.detail-section-title svg { width: 16px; height: 16px; color: var(--brand-500); }

.crosssell { display: flex; gap: .5rem; flex-wrap: wrap; }
.crosssell .chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .4rem .8rem;
  border-radius: 999px;
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: .82rem; font-weight: 700;
}
.crosssell .chip.off { background: var(--bg-alt); color: var(--muted); }

.notes-box {
  padding: .9rem 1rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  color: #78350f;
  font-size: .9rem;
  line-height: 1.7;
}

.detail-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Uploader */
.uploader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  text-align: center;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.uploader:hover, .uploader.drag { border-color: var(--brand-500); background: var(--brand-50); }

/* قسم المستندات داخل نموذج الإضافة/التعديل */
#form-docs { border-top: 1px dashed var(--border-strong); padding-top: 1.1rem; margin-top: .35rem; }
#form-docs.flash .uploader { animation: lmDocsFlash 1.5s ease; }
@keyframes lmDocsFlash {
  0%, 100% { box-shadow: none; }
  30% { box-shadow: 0 0 0 5px rgba(74,108,247,.28); border-color: var(--brand-500); background: var(--brand-50); }
}
.uploader svg { width: 34px; height: 34px; color: var(--brand-500); margin-bottom: .5rem; }
.uploader strong { font-size: .95rem; font-weight: 800; }
.uploader span { color: var(--muted); font-size: .82rem; }
.uploader-btns { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-top: .7rem; }
.btn-sm { padding: .5rem .9rem; font-size: .84rem; }

.files-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .85rem; }
.file-row {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: .75rem;
  align-items: center;
  padding: .7rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.file-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: #fee2e2; color: #b91c1c;
}
.file-icon.img { background: #dbeafe; color: #1d4ed8; }
.file-icon svg { width: 18px; height: 18px; }
.file-meta { min-width: 0; }
.file-meta .fn { font-weight: 700; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta .fm { color: var(--muted); font-size: .75rem; }
.file-actions { display: flex; gap: .3rem; }

/* Viewer */
.viewer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.viewer-title { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.viewer-title svg { width: 18px; height: 18px; color: var(--brand-500); }
.viewer-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-actions { display: flex; gap: .5rem; }
.viewer-body {
  background: #0f172a; color: #fff;
  min-height: 60dvh; max-height: 78dvh;
  overflow: auto; padding: 0;
  display: grid; place-items: center;
}
.pdf-mock {
  width: min(700px, 100%); background: #fff; color: #0f172a;
  padding: 3rem 2.5rem; margin: 1.25rem; border-radius: 8px;
  box-shadow: 0 30px 60px rgba(0,0,0,.4);
  font-size: .9rem; line-height: 1.9;
  min-height: 60dvh;
}
.pdf-mock h4 { color: var(--brand-600); margin-bottom: 1rem; font-size: 1.25rem; }
.pdf-mock p { margin: .6rem 0; color: var(--text-2); }
.pdf-mock .line { height: 8px; background: #eef1f8; border-radius: 4px; margin: .5rem 0; }
.pdf-mock .line.w-3\/4 { width: 75%; }
.pdf-mock .line.w-1\/2 { width: 50%; }

/* ================= Toasts ================= */
.toasts {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex; flex-direction: column; gap: .5rem;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: .6rem;
  padding: .75rem 1rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: .88rem; font-weight: 600;
  min-width: 240px;
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast.success { border-inline-start: 4px solid var(--active); }
.toast.error   { border-inline-start: 4px solid var(--cancelled); }
.toast .toast-icon {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex-shrink: 0;
}
.toast.success .toast-icon { background: var(--active); }
.toast.error .toast-icon { background: var(--cancelled); }
.toast svg { width: 16px; height: 16px; }

/* ================= Bottom nav (mobile) ================= */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; inset-inline: 0;
  padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 40;
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
  align-items: center;
  gap: .35rem;
}
.bottom-nav .bn-item span { font-size: .68rem; }
.bn-item {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-size: .72rem; font-weight: 600;
  padding: .35rem;
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item.active { color: var(--brand-600); }
.bn-fab {
  width: 56px; height: 56px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--grad-brand); color: #fff;
  box-shadow: 0 12px 24px -6px rgba(74,108,247,.6);
  display: grid; place-items: center;
  transform: translateY(-14px);
}
.bn-fab svg { width: 24px; height: 24px; }

/* ================= Responsive ================= */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .appbar-nav { display: none; }
  .appbar .search-mini { display: none; }
  .appbar-actions .user-chip { display: none; }
  .appbar-brand-text span { display: none; }
  .bottom-nav { display: grid; }
  .main { padding-bottom: 7rem; }
  .topbar { grid-template-columns: 1fr; }
  .topbar-actions .search-mini { display: none; }
  .topbar-actions { justify-content: flex-end; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .filters-bar { grid-template-columns: 1fr; }
  .filter-group { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-group .select { min-width: 0; }
  .modal-foot { flex-direction: column-reverse; align-items: stretch; }
  .modal-foot .foot-right { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .stats-grid { gap: .6rem; }
  .stat-card { flex: 1 1 calc(50% - .3rem); max-width: none; padding: 1rem .5rem .85rem; }
  .stat-card .stat-icon { width: 40px; height: 40px; margin-bottom: .2rem; }
  .stat-card .stat-icon svg { width: 20px; height: 20px; }
  .stat-card .stat-value { font-size: 1.6rem; }
  .stat-card .stat-label { font-size: .8rem; }
  .stat-card .trend { font-size: .68rem; }
}
@media (max-width: 480px) {
  .topbar-title h2 { font-size: 1.3rem; }
  .clients-grid { grid-template-columns: 1fr; }
  .login-card { padding: 1.5rem; }
}


/* شارات النواقص على البطاقة */
.missing-row { display:flex; flex-wrap:wrap; gap:.35rem; margin-top:.55rem; }
.missing-badge { font-size:.72rem; font-weight:700; color:#b91c1c; background:#fee2e2; border:1px solid #fecaca; padding:.16rem .55rem; border-radius:999px; line-height:1.6; }


/* شارة تحويل العمولة */
.comm-row { margin-top:.45rem; }
.comm-badge { display:inline-block; font-size:.74rem; font-weight:700; padding:.18rem .6rem; border-radius:999px; }
.comm-badge.pending { color:#b91c1c; background:#fee2e2; border:1px solid #fecaca; }
.comm-badge.done { color:#047857; background:#d1fae5; border:1px solid #a7f3d0; }


/* فلتر الشهر في الرئيسية */
.dash-filter { margin-bottom:1rem; display:flex; justify-content:flex-start; }
.dash-filter .select { max-width:240px; }


/* المربعات الإحصائية القابلة للضغط */
.stat-card.clickable { cursor:pointer; transition:transform .12s ease, box-shadow .12s ease; }
.stat-card.clickable:hover { transform:translateY(-2px); box-shadow:0 8px 22px rgba(0,0,0,.10); }
.stat-card.clickable:active { transform:translateY(0); }


/* بطاقات إنتاج الوسطاء */
.agent-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:.75rem; margin-bottom:1.25rem; }
.agent-card { position:relative; background:#ecfdf5; border:1px solid #a7f3d0; border-radius:16px; padding:1rem .75rem; text-align:center; cursor:pointer; transition:transform .12s ease, box-shadow .12s ease; }
.agent-card:hover { transform:translateY(-2px); box-shadow:0 8px 22px rgba(16,185,129,.18); }
.agent-icon { display:inline-flex; width:34px; height:34px; align-items:center; justify-content:center; color:#059669; }
.agent-icon svg { width:22px; height:22px; }
.agent-value { font-size:1.6rem; font-weight:800; color:#047857; line-height:1.2; }
.agent-label { font-size:.8rem; font-weight:700; color:#065f46; }
@media (max-width:520px){ .agent-grid { gap:.5rem; } .agent-value{ font-size:1.25rem; } .agent-label{ font-size:.72rem; } }

/* حقل التاريخ المجزّأ (يوم/شهر/سنة) */
.date-parts { display:flex; gap:.5rem; }
.date-parts .select { flex:1; min-width:0; }
.date-parts #ins-month { flex:1.6; }
.date-preview { font-size:.8rem; font-weight:700; margin-top:.3rem; min-height:1.1em; }
.date-preview-ok { color:#047857; }
.date-preview-err { color:#b91c1c; }

/* كشف حساب الوسطاء */
#agent-stats { display:block; background:#ecfdf5; border:1px solid #a7f3d0; border-radius:16px; padding:1rem; margin-bottom:1.25rem; }
.agent-acc-head { display:flex; align-items:center; gap:.5rem; font-weight:800; color:#065f46; margin-bottom:.75rem; flex-wrap:wrap; }
.agent-acc-head svg { width:20px; height:20px; color:#059669; }
.agent-acc-head small { font-weight:600; color:#059669; font-size:.72rem; margin-inline-start:auto; }
.agent-table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
.agent-table { width:100%; border-collapse:collapse; min-width:430px; }
.agent-table th, .agent-table td { padding:.45rem .5rem; text-align:center; white-space:nowrap; }
.agent-table thead th { font-size:.72rem; font-weight:700; color:#059669; border-bottom:1px solid #a7f3d0; }
.agent-table tbody th { font-size:.85rem; font-weight:800; color:#065f46; text-align:right; }
.agent-table tbody tr + tr { border-top:1px dashed #d1fae5; }
.agent-num { background:#fff; border:1px solid #a7f3d0; border-radius:10px; min-width:44px; padding:.3rem .6rem; font-size:1rem; font-weight:800; color:#047857; cursor:pointer; transition:transform .12s ease, box-shadow .12s ease; }
.agent-num:hover { transform:translateY(-1px); box-shadow:0 4px 12px rgba(16,185,129,.25); }
.agent-num.num-ok { color:#047857; border-color:#6ee7b7; background:#f0fdf9; }
.agent-num.num-warn { color:#b45309; border-color:#fcd34d; background:#fffbeb; }
@media (max-width:520px){ #agent-stats { padding:.75rem; } .agent-table { min-width:400px; } }

/* شارات التأمينات على البطاقة (موجود = أخضر / ناقص = أحمر) */
.ins-row { display:flex; flex-wrap:wrap; gap:.35rem; margin-top:.55rem; }
.ins-have, .ins-miss { display:inline-flex; align-items:center; gap:.25rem; font-size:.72rem; font-weight:700; padding:.16rem .55rem; border-radius:999px; line-height:1.6; }
.ins-have svg { width:13px; height:13px; }
.ins-have { color:#047857; background:#d1fae5; border:1px solid #a7f3d0; }
.ins-miss { color:#b91c1c; background:#fee2e2; border:1px solid #fecaca; }
/* التأمين الصحي تحت الاسم (بدل شركة التأمين) */
.client-info .company .ins-have, .client-info .company .ins-miss { margin-top:.15rem; }

/* التأمينات المسجّلة (خضراء) تحت الاسم مباشرة */
.client-info .ins-row-top { margin-top:.3rem; }

/* ===== الإعدادات (لوحة تحكم الحساب) ===== */
.settings-wrap { display:grid; gap:1rem; max-width:640px; }
.settings-card { background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:1.1rem 1.2rem; box-shadow:var(--shadow-sm); }
.settings-card-head { font-weight:800; color:var(--text); margin-bottom:.6rem; font-size:1rem; }
.settings-row { display:flex; justify-content:space-between; gap:1rem; padding:.4rem 0; border-bottom:1px dashed var(--border); }
.settings-row:last-child { border-bottom:0; }
.settings-row .s-k { color:var(--muted); font-size:.85rem; font-weight:600; }
.settings-row .s-v { font-weight:700; color:var(--text); word-break:break-all; }
#set-enroll { width:100%; }

/* ===== سلة المحذوفات + سجل النشاط ===== */
.btn-sm { padding:.4rem .7rem; font-size:.8rem; border-radius:10px; }
.trash-list { display:flex; flex-direction:column; gap:.5rem; }
.trash-row { display:flex; align-items:center; justify-content:space-between; gap:.6rem; padding:.6rem .7rem; background:var(--surface-2); border:1px solid var(--border); border-radius:12px; flex-wrap:wrap; }
.trash-info { display:flex; flex-direction:column; min-width:0; }
.trash-info .muted { font-size:.75rem; }
.trash-acts { display:flex; gap:.4rem; flex-shrink:0; }
.audit-table { display:flex; flex-direction:column; gap:.3rem; max-height:340px; overflow-y:auto; }
.audit-row { display:grid; grid-template-columns:auto 1fr auto; gap:.4rem .6rem; align-items:center; padding:.45rem .6rem; border-bottom:1px dashed var(--border); font-size:.82rem; }
.audit-row .audit-time { grid-column:2 / 4; font-size:.72rem; }
.audit-act { font-weight:800; font-size:.72rem; padding:.12rem .5rem; border-radius:999px; white-space:nowrap; background:var(--bg-alt); color:var(--text-2); }
.audit-create { background:#d1fae5; color:#047857; }
.audit-update { background:#dbeafe; color:#1d4ed8; }
.audit-trash { background:#fef3c7; color:#b45309; }
.audit-restore { background:#e0e7ff; color:#4338ca; }
.audit-purge { background:#fee2e2; color:#b91c1c; }
.audit-name { font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.audit-meta { font-size:.72rem; color:var(--muted); white-space:nowrap; }

/* ===== الموافقة + سياسة الخصوصية (GDPR) ===== */
.consent-box { background:#f0fdf9; border:1px solid #a7f3d0; border-radius:12px; padding:.7rem .8rem; display:flex; flex-direction:column; gap:.4rem; }
.consent-check { display:flex; align-items:flex-start; gap:.55rem; cursor:pointer; font-size:.85rem; font-weight:600; color:#065f46; line-height:1.5; }
.consent-check input { margin-top:.2rem; width:18px; height:18px; accent-color:#059669; flex-shrink:0; }
.link-privacy { align-self:flex-start; background:none; border:0; color:var(--brand-600); font-weight:700; font-size:.8rem; cursor:pointer; text-decoration:underline; padding:0; }
.privacy-text { white-space:pre-wrap; line-height:1.9; color:var(--text-2); font-size:.92rem; }
.consent-status { border-radius:10px; padding:.5rem .7rem; font-size:.82rem; font-weight:700; margin-bottom:.2rem; }
.consent-status.ok { background:#d1fae5; color:#047857; }
.consent-status.no { background:#fef3c7; color:#b45309; }
#set-privacy { width:100%; font-size:.88rem; line-height:1.7; }
