* { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- גופנים מקומיים (variable — כל המשקלים בקובץ אחד, ללא CDN) ---- */
@font-face {
  font-family: "Assistant";
  src: url("/fonts/Assistant.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Rubik";
  src: url("/fonts/Rubik.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --purple: #5a4b9c;
  --purple-dark: #43377d;
  --blue: #5aa7e0;
  --bg: #f2f1f6;
  --danger: #d64545;
  --green: #2e9e5b;
  --ink: #2a2440;
  --font-body: "Assistant", "Segoe UI", "Heebo", Arial, sans-serif;
  --font-display: "Rubik", "Assistant", "Segoe UI", Arial, sans-serif;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- פריסת פאנל ניהול: סרגל צד בימין ---- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(185deg, #3d3370 0%, #3a3f75 55%, #405d8c 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .logo-box { text-align: center; margin-bottom: 26px; }
.sidebar .logo-box img { width: 130px; max-width: 90%; }
.sidebar .logo-box .fallback { font-size: 22px; font-weight: 800; letter-spacing: 2px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  color: #e8e6f5; text-decoration: none;
  padding: 11px 14px; border-radius: 10px;
  font-size: 15px; font-weight: 600;
  transition: background .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.1); }
.sidebar nav a.on { background: rgba(255,255,255,.18); color: #fff; }
.sidebar nav a .ic { width: 22px; height: 22px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.sidebar nav a .ic svg { width: 19px; height: 19px; display: block; }
/* תג מונה בקשות ממתינות */
.sidebar nav a .nav-badge {
  margin-inline-start: auto; background: #e08a2e; color: #fff;
  min-width: 21px; height: 21px; padding: 0 6px; border-radius: 999px;
  font-size: 12px; font-weight: 800; line-height: 21px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.sidebar .logout { display: flex; align-items: center; gap: 10px; }
.sidebar .logout .ic { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.sidebar .logout .ic svg { width: 18px; height: 18px; }
.sidebar .user-chip {
  margin: 0 4px 8px; padding: 10px 14px;
  background: rgba(255,255,255,.12); border-radius: 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar .user-chip .uname { color: #fff; font-weight: 700; font-size: 14px; }
.sidebar .user-chip .urole { color: #cfc9e8; font-size: 12px; }
.sidebar .logout {
  color: #cfc9e8; text-decoration: none; font-size: 14px;
  padding: 10px 14px; border-radius: 10px;
}
.sidebar .logout:hover { background: rgba(255,255,255,.1); color: #fff; }

.main { flex: 1; padding: 26px 28px; min-width: 0; }
.main h1.page-title { font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -.01em; margin-bottom: 18px; color: var(--purple-dark); }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px; }
  .sidebar .logo-box { margin: 0 0 0 10px; }
  .sidebar .logo-box img { width: 80px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav a { padding: 8px 10px; font-size: 13.5px; }
  .main { padding: 16px 12px; }
}

/* ---- דשבורד: אריחי מדדים ---- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(60, 50, 110, .08);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
/* פס צבע עליון דק לפי הקטגוריה */
.stat-card::before {
  content: ""; position: absolute; top: 0; right: 0; left: 0; height: 3px;
  background: var(--accent, #5a4b9c); opacity: .55;
  transition: opacity .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(60, 50, 110, .14); }
.stat-card:hover::before { opacity: 1; }
.stat-card.sel { border-color: var(--accent, var(--purple)); }
.stat-card.sel::before { opacity: 1; }
/* המספר עצמו נושא את צבע הקטגוריה — חיווי אחד ברור במקום נקודה + פס */
.stat-card .num {
  font-family: var(--font-display); font-size: 36px; font-weight: 700;
  color: var(--accent, var(--ink)); line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.stat-card .lbl { font-size: 13.5px; font-weight: 600; color: #6d648f; }
.stat-card .sub { font-size: 12px; color: #8b83a8; }

.card-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(60, 50, 110, .08);
  padding: 24px;
  margin-bottom: 20px;
}

/* ---- מצב ריק ---- */
.empty-state { text-align: center; padding: 44px 20px 40px; }
.empty-state .es-icon {
  width: 58px; height: 58px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px; background: #f1eff8; color: var(--purple);
}
.empty-state .es-icon svg { width: 30px; height: 30px; }
.empty-state h3 { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--purple-dark); margin-bottom: 6px; }
.empty-state p { color: #8b83a8; font-size: 14px; margin: 0 auto 18px; max-width: 400px; line-height: 1.6; }
.empty-state .es-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

h1 { font-family: var(--font-display); font-weight: 700; font-size: 20px; margin-bottom: 16px; color: var(--purple-dark); }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 18px 0 10px; color: var(--purple-dark); }

.toolbar { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.toolbar form.search { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.toolbar input[type=search] {
  flex: 1; padding: 10px 14px; border: 1px solid #d5d2e2; border-radius: 10px; font-size: 15px;
}

/* ---- בקרת מקטעים (segmented) לבחירת סוג דוח ---- */
.segmented {
  display: inline-flex; background: #eceaf4; border-radius: 11px; padding: 3px; gap: 2px;
}
.segmented a {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  color: #6d648f; text-decoration: none; transition: background .15s, color .15s, box-shadow .15s;
}
.segmented a:hover { color: var(--purple-dark); }
.segmented a.on {
  background: #fff; color: var(--purple-dark);
  box-shadow: 0 1px 4px rgba(60, 50, 110, .16);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; text-decoration: none;
  padding: 10px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  background: var(--purple); color: #fff; transition: background .15s;
  font-family: inherit;
}
.btn:hover { background: var(--purple-dark); }
.btn.secondary { background: #e8e6f2; color: var(--purple-dark); }
.btn.secondary:hover { background: #dcd9ec; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b23434; }
.btn.small { padding: 7px 10px; font-size: 13px; border-radius: 8px; }

/* ---- פוקוס מקלדת גלוי (נגישות) ---- */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn:focus-visible,
.stat-card:focus-visible,
.segmented a:focus-visible,
.menu > a:focus-visible,
.menu > button:focus-visible,
.menu > form > button:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
/* על רקע כהה בסרגל הצד — קו לבן */
.sidebar a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* שורת פעולות: שני כפתורים ראשיים + תפריט "עוד" */
.actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.actions > .btn { white-space: nowrap; padding: 7px 14px; font-size: 13px; }

/* תפריט נפתח לפעולות משניות */
.menu-wrap { position: relative; }
.menu-toggle { padding: 7px 12px; font-size: 13px; }
.menu {
  display: none;
  position: absolute; top: calc(100% + 4px); inset-inline-start: 0;
  background: #fff; border: 1px solid #e0dcee; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(40, 30, 80, .16);
  min-width: 190px; padding: 6px; z-index: 30;
}
.menu-wrap.open .menu { display: block; }
.menu > a, .menu > form > button, .menu > button {
  display: block; width: 100%; text-align: start;
  background: none; border: none; cursor: pointer;
  padding: 9px 12px; border-radius: 7px; font-size: 13.5px;
  font-family: inherit; color: #2a2440; text-decoration: none;
}
.menu > a:hover, .menu > form > button:hover:not(:disabled), .menu > button:hover {
  background: #f1eff8;
}
.menu > form { margin: 0; }
.menu > form > button.danger, .menu > button.danger { color: var(--danger); }
.menu > form > button.danger:hover { background: #fdeaea; }
.menu > form > button:disabled { color: #bbb4cc; cursor: not-allowed; }
.menu-sep { height: 1px; background: #ece9f4; margin: 5px 4px; }

/* עמודת הפעולות דביקה — נשארת גלויה גם בגלילה אופקית */
td.actions-cell, th.actions-cell {
  position: sticky; left: 0; background: #fff; z-index: 2;
  box-shadow: 4px 0 8px -4px rgba(60, 50, 110, .15);
}
/* התא הדביק יוצר הקשר ערימה משלו, ולכן תפריט פתוח בתוכו נדרס ע"י תאים
   של שורות אחרות. הגבהת התא עצמה בזמן פתיחה מרימה איתו את כל התפריט. */
td.actions-cell.menu-open { z-index: 40; }
tr:hover td.actions-cell { background: #faf9fd; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid #ece9f4; font-size: 14px; vertical-align: middle; }
th { color: #6d648f; font-weight: 600; font-size: 13px; }
tr:hover td { background: #faf9fd; }

.avatar { width: 44px; height: 56px; object-fit: cover; border-radius: 8px; display: block; }

.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.badge.ok { background: #e2f5e9; color: var(--green); }
.badge.expired { background: #fdeaea; color: var(--danger); }
.badge.inactive { background: #eeecf5; color: #7a7295; }
.badge.soon { background: #fbecd7; color: #b56a12; margin-top: 4px; }

/* שורה של מנוי שמסתיים בקרוב — פס דגש כתום בקצה הימני (תחילת השורה ב-RTL) */
tr.row-soon td { background: #fdf7ee; }
tr.row-soon:hover td { background: #fbf1e0; }
tr.row-soon td:first-child { box-shadow: inset -3px 0 0 #e08a2e; }
tr.row-soon td.actions-cell { background: #fdf7ee; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 14px; font-weight: 600; color: #554c78; }
.field input, .field select {
  padding: 11px 14px; border: 1px solid #d5d2e2; border-radius: 10px; font-size: 15px; background: #fff;
  font-family: inherit;
}
.field input:focus { outline: 2px solid var(--blue); border-color: transparent; }
/* שדות תאריך: סדר המקטעים תמיד יום/חודש/שנה משמאל לימין,
   אחרת ה-RTL של העמוד הופך אותם ומציג שנה/חודש/יום */
.field input[type="date"] { direction: ltr; text-align: right; }
.hint { font-size: 12.5px; color: #8b83a8; }

.error-msg {
  background: #fdeaea; color: var(--danger); padding: 12px 16px; border-radius: 10px;
  margin-bottom: 16px; font-weight: 600; font-size: 14px;
}
.ok-msg {
  background: #e2f5e9; color: var(--green); padding: 12px 16px; border-radius: 10px;
  margin-bottom: 16px; font-weight: 600; font-size: 14px;
}

.login-wrap {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
  background: linear-gradient(150deg, #3a2f70 0%, #4b3f8f 45%, #4a86c8 100%);
  position: relative; overflow: hidden;
}
/* צורות רקע עדינות בסגנון הכרטיס */
.login-wrap::before, .login-wrap::after {
  content: ""; position: absolute; border-radius: 50%; opacity: .18; pointer-events: none;
}
.login-wrap::before { width: 420px; height: 420px; background: #7ec3ea; top: -140px; right: -120px; }
.login-wrap::after { width: 360px; height: 360px; background: #8478c6; bottom: -130px; left: -110px; }
.login-box { width: 380px; max-width: 92vw; position: relative; z-index: 1; padding: 34px 30px; }
.login-box .logo { text-align: center; margin-bottom: 24px; }
.login-box .logo img { width: 168px; max-width: 70%; filter: brightness(0) saturate(100%) invert(23%) sepia(23%) saturate(2216%) hue-rotate(219deg) brightness(94%) contrast(92%); }
.login-box .logo .title { font-size: 26px; font-weight: 800; color: var(--purple-dark); letter-spacing: 2px; }
.login-box .logo .sub { color: #7a7295; font-size: 14px; margin-top: 10px; }

.copy-flash { position: fixed; bottom: 24px; right: 50%; transform: translateX(50%);
  background: var(--purple-dark); color: #fff; padding: 10px 22px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
.copy-flash.show { opacity: 1; }

.photo-preview { width: 90px; height: 115px; object-fit: cover; border-radius: 10px; border: 1px solid #d5d2e2; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }

/* הודעת הקשר בטופס אישור בקשה */
.approve-note {
  background: #eef4fb; border: 1px solid #d5e3f2; color: #3c5a7d;
  padding: 12px 15px; border-radius: 11px; margin-bottom: 18px;
  font-size: 14px; line-height: 1.65;
}

/* ---- כרטיס קוד ההרשמה העצמית ---- */
.join-qr { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.join-qr-code {
  background: #fff; padding: 10px; border-radius: 14px; flex-shrink: 0;
  border: 1px solid #e6e3f0; box-shadow: 0 2px 10px rgba(60, 50, 110, .08);
}
.join-qr-code img { width: 148px; height: 148px; display: block; }
.join-qr-text { flex: 1; min-width: 260px; }
.join-url {
  background: #f5f4fa; border: 1px solid #e6e3f0; border-radius: 9px;
  padding: 9px 12px; font-size: 13.5px; color: #554c78; word-break: break-all;
  font-variant-numeric: tabular-nums;
}
.btn.secondary.danger-text { color: var(--danger); }
.btn.secondary.danger-text:hover { background: #fdeaea; }

.alert-box {
  background: #fdf3e3; border: 1px solid #f0d5a8; color: #8a5310;
  border-radius: 10px; padding: 13px 16px; font-size: 14px; line-height: 1.65;
}

/* שורת בחירה עם תיבת סימון / כפתור רדיו */
.check-row {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 14px; border: 1px solid #e0dcee; border-radius: 11px;
  cursor: pointer; font-size: 14.5px; color: #2a2440; line-height: 1.5;
  transition: border-color .15s, background .15s;
}
.check-row + .check-row { margin-top: 10px; }
.check-row:hover { border-color: var(--purple); background: #faf9fd; }
.check-row input { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; accent-color: var(--purple); }
.check-row input:disabled { cursor: not-allowed; }
.check-row:has(input:disabled) { opacity: .6; cursor: not-allowed; background: #f7f6fa; }
.check-row .hint { margin-top: 3px; }

.steps { list-style: none; display: grid; gap: 10px; margin: 12px 0; }
.steps li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: #554c78; }
.steps .num {
  background: var(--purple); color: #fff; width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
