:root{
  --bg: #F5F6F3;
  --surface: #FFFFFF;
  --surface-2: #FBFBF9;
  --ink: #16211D;
  --muted: #5C665F;
  --line: #E2E5DE;
  --teal: #12946F;
  --teal-dark: #0A5C46;
  --teal-light: #6FD3AA;
  --teal-tint: #E9F7F1;
  --amber: #B4791C;
  --amber-tint: #FBF1DF;
  --red: #A63E28;
  --red-tint: #FBEAE4;
  --radius: 10px;
}
*{box-sizing:border-box;}
html,body,#app{min-height:100%;margin:0;padding:0;}
body{
  background:#F6F5EF;
  background-image:url('../assets/site-bg.jpg');
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
  background-attachment:fixed;
  color:var(--ink);
  font-family:'Vazirmatn',sans-serif;
  line-height:1.7;
  -webkit-font-smoothing:antialiased;
}
.mono{font-family:'IBM Plex Mono','Vazirmatn',monospace; direction:ltr; display:inline-block;}
a{color:inherit;}
button{font-family:inherit;cursor:pointer;}
input,select,textarea{font-family:inherit;}
.hidden{display:none !important;}

/* ---------- Top header ---------- */
header.top{
  background:linear-gradient(120deg,var(--teal-dark) 0%, var(--teal) 65%, #1FAE80 100%);
  color:#fff;
  padding:14px 6vw;
  position:relative;
  box-shadow:0 8px 24px -10px rgba(10,60,45,.45);
}
header.top::after{
  content:"";
  position:absolute; inset:0;
  background-image:radial-gradient(circle at 85% 20%, rgba(255,255,255,.10), transparent 45%);
  pointer-events:none;
  z-index:0;
}
.top-inner{
  max-width:1180px;margin:0 auto;position:relative; z-index:1;
  display:flex; align-items:center; justify-content:space-between;
}
.header-actions{display:flex; align-items:center; gap:8px;}
.brand{display:flex; align-items:center; gap:12px; font-weight:800; font-size:17px;}
.brand-logo{
  width:46px; height:46px; border-radius:50%;
  background:#fff;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 3px 10px rgba(0,0,0,.22), inset 0 0 0 1px rgba(255,255,255,.6);
  flex-shrink:0;
}
.brand-logo img{width:36px; height:36px; object-fit:contain;}

.logout-icon-btn{
  background:rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.25);
  border-radius:8px;
  height:38px; padding:0 12px;
  display:flex; align-items:center; justify-content:center; gap:6px;
  color:#fff; font-size:13.5px; font-weight:600;
  font-family:'Vazirmatn',sans-serif;
  transition:background .15s;
}
.logout-icon-btn .logout-ic{width:16px; height:16px; display:inline-flex;}
.logout-icon-btn .logout-ic svg{width:100%; height:100%;}
.logout-icon-btn:hover{background:rgba(220,90,60,.55);}

.notif-wrap{position:relative;}
.notif-btn{
  position:relative;
  background:rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.25);
  border-radius:8px;
  width:42px;height:38px;
  display:flex; align-items:center; justify-content:center;
  color:#fff; cursor:pointer;
  transition:background .15s;
}
.notif-btn svg{width:19px; height:19px;}
.notif-btn:hover{background:rgba(255,255,255,.22);}
.notif-dot{
  position:absolute; top:6px; left:8px; width:9px; height:9px; border-radius:50%;
  background:var(--red); border:2px solid var(--teal-dark); animation:notifPulse 1.6s infinite;
}
@keyframes notifPulse{0%,100%{transform:scale(1);} 50%{transform:scale(1.25);}}
.notif-panel{
  display:none; position:absolute; top:calc(100% + 10px); left:0; z-index:50;
  width:280px; background:var(--surface); border:1px solid var(--line); border-radius:12px;
  box-shadow:0 14px 34px rgba(20,30,25,.18); padding:14px 16px; text-align:right;
  animation:notifSlide .15s ease;
}
@keyframes notifSlide{from{opacity:0; transform:translateY(-6px);} to{opacity:1; transform:translateY(0);}}
.notif-wrap.open .notif-panel{display:block;}
.notif-panel-head{font-size:13.5px; font-weight:800; color:var(--red); margin-bottom:6px;}
.notif-panel-body{font-size:12.5px; color:var(--ink); line-height:1.7;}

.impersonate-bar{
  background:linear-gradient(90deg, #B4791C, #D4941F);
  box-shadow:0 4px 14px -4px rgba(180,121,28,.5);
}
.impersonate-bar-inner{
  max-width:1180px; margin:0 auto; padding:9px 6vw;
  display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap;
}
.impersonate-bar-text{
  display:flex; align-items:center; gap:8px;
  color:#fff; font-size:13px; font-weight:600;
}
.impersonate-bar-text svg{width:17px; height:17px; flex-shrink:0;}
.impersonate-bar-text b{font-weight:800;}
.impersonate-back-btn{
  display:flex; align-items:center; gap:6px;
  background:rgba(255,255,255,.18); border:1px solid rgba(255,255,255,.4);
  color:#fff; font-family:'Vazirmatn',sans-serif; font-weight:700; font-size:12.5px;
  padding:7px 14px; border-radius:8px; cursor:pointer; transition:background .15s;
  white-space:nowrap;
}
.impersonate-back-btn svg{width:15px; height:15px;}
.impersonate-back-btn:hover{background:rgba(255,255,255,.3);}

.home-icon-btn{
  background:rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.25);
  border-radius:8px;
  width:42px;height:38px;
  display:flex; align-items:center; justify-content:center;
  color:#fff;
  transition:background .15s;
}
.home-icon-btn svg{width:19px; height:19px;}
.home-icon-btn:hover{background:rgba(255,255,255,.22);}

.back-icon-btn{
  background:rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.25);
  border-radius:8px;
  width:42px;height:38px;
  display:flex; align-items:center; justify-content:center;
  color:#fff;
  transition:background .15s;
}
.back-icon-btn svg{width:19px; height:19px;}
.back-icon-btn:hover{background:rgba(255,255,255,.22);}

.hamburger-btn{
  background:rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.25);
  border-radius:8px;
  width:42px;height:38px;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
  transition:background .15s;
}
.hamburger-btn:hover{background:rgba(255,255,255,.22);}
.hamburger-btn span{display:block; width:19px; height:2px; background:#fff; border-radius:2px;}

/* ---------- Drawer ---------- */
.drawer-overlay{
  position:fixed; inset:0; background:rgba(10,20,16,.35);
  z-index:40; animation:fadeIn .15s ease;
}
@keyframes fadeIn{from{opacity:0} to{opacity:1}}
.drawer{
  position:fixed; top:0; bottom:0; right:0; width:300px; max-width:85vw;
  background:var(--surface); z-index:50; box-shadow:-8px 0 30px rgba(10,20,16,.18);
  display:flex; flex-direction:column;
  animation:slideIn .18s ease;
}
@keyframes slideIn{from{transform:translateX(100%)} to{transform:translateX(0)}}
.drawer-head{padding:20px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between;}
.drawer-head strong{font-size:15px;}
.drawer-close{width:30px;height:30px;border-radius:8px;border:1px solid var(--line); background:var(--surface-2); color:var(--muted); font-size:16px; line-height:1;}
.drawer-user{padding:16px 20px; border-bottom:1px solid var(--line); display:flex; gap:12px; align-items:center;}
.drawer-user img, .avatar-fallback{
  width:42px;height:42px;border-radius:50%; object-fit:cover; background:var(--teal-tint);
  display:flex; align-items:center; justify-content:center; color:var(--teal-dark); font-weight:700;
}
.drawer-user .name{font-weight:700; font-size:14px;}
.drawer-user .role{font-size:12px; color:var(--muted);}
.drawer-nav{padding:10px; display:flex; flex-direction:column; gap:4px; flex:1;}
.drawer-nav button.link{
  display:flex; align-items:center; gap:12px;
  padding:12px 14px; border-radius:8px; color:var(--ink);
  font-size:14.5px; font-weight:500; background:none; border:none; text-align:right; width:100%;
}
.drawer-nav button.link:hover{background:var(--teal-tint); color:var(--teal-dark);}
.drawer-nav button.link.active{background:var(--teal-tint); color:var(--teal-dark); font-weight:700;}
.link-ic{width:22px; height:22px; display:inline-flex; align-items:center; justify-content:center; flex-shrink:0; color:var(--teal-dark);}
.link-ic img{width:100%; height:100%; object-fit:contain;}
.link-ic.ic-line svg{width:19px; height:19px;}
.drawer-foot{padding:14px 20px; border-top:1px solid var(--line);}
.drawer-foot button{width:100%; padding:10px; border-radius:8px; border:1px solid var(--line); background:var(--surface-2); color:var(--red); font-weight:600; font-size:13.5px;}

/* ---------- Layout ---------- */
.page{max-width:820px; margin:28px auto 60px; padding:0 6vw;}
.page.wide{max-width:1180px;}
/* پنل ادمین به‌خاطر جدول چندستونی، کمی پهن‌تر از بقیه‌ی صفحات نیاز دارد تا بدون اسکرول افقی جا شود */
.page.wide.admin-page{max-width:1475px;}
.page.profile-wide{max-width:1600px;}

.profile-grid{display:grid; grid-template-columns:1fr 1fr; gap:0 24px; align-items:start;}
@media (max-width:760px){ .profile-grid{grid-template-columns:1fr;} }

.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:22px 24px;
  box-shadow:0 1px 2px rgba(20,30,25,.03);
  margin-bottom:16px;
}
.card h2{font-size:16px; font-weight:700; margin:0 0 4px;}
.card .desc{color:var(--muted); font-size:13px; margin:0 0 16px;}

.home-grid{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:18px;
  perspective:1200px;
}
@media (max-width:720px){
  .home-grid{grid-template-columns:repeat(2, 1fr);}
}
@media (max-width:420px){
  .home-grid{grid-template-columns:1fr;}
}
.home-card{
  display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center;
  gap:10px;
  background:rgba(255,255,255,.82);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
  border:1px solid rgba(255,255,255,.7);
  border-radius:18px;
  padding:30px 16px 24px;
  box-shadow:0 10px 25px -8px rgba(20,40,30,.08), 0 6px 10px -6px rgba(20,40,30,.05);
  cursor:pointer;
  transition:box-shadow .25s ease, border-color .25s ease;
  transform-style:preserve-3d;
  font-family:'Vazirmatn',sans-serif;
  position:relative;
  overflow:hidden;
}
.home-card::before{
  content:'';
  position:absolute; top:0; left:0; right:0; height:3px;
  background:linear-gradient(90deg, transparent, var(--card-accent, var(--teal)), transparent);
  opacity:0; transition:opacity .25s ease;
}
.home-card:hover{
  border-color:rgba(18,148,111,.28);
  box-shadow:0 20px 34px -10px rgba(18,148,111,.20), 0 10px 14px -8px rgba(20,40,30,.08);
}
.home-card:hover::before{opacity:1;}
.home-card:active{transform:scale(.98) !important;}
.home-card-icon{
  width:64px; height:64px;
  display:flex; align-items:center; justify-content:center;
  transform:translateZ(24px);
  transition:transform .25s ease;
}
.home-card:hover .home-card-icon{transform:translateZ(36px) scale(1.07);}
.home-card-icon img{width:100%; height:100%; object-fit:contain; filter:drop-shadow(0 3px 6px rgba(20,40,30,.12));}
.home-card-icon svg{width:100%; height:100%; filter:drop-shadow(0 3px 6px rgba(20,40,30,.12));}
.home-card-title{font-size:14.5px; font-weight:700; color:var(--ink); transform:translateZ(16px); transition:color .25s ease;}
.home-card:hover .home-card-title{color:var(--card-accent, var(--teal-dark));}
.home-card-sub{font-size:11.5px; color:var(--muted); margin-top:-6px; transform:translateZ(12px);}
.home-card.locked{opacity:.55;}
.home-card.locked:hover{border-color:rgba(255,255,255,.7); box-shadow:0 10px 25px -8px rgba(20,40,30,.08), 0 6px 10px -6px rgba(20,40,30,.05); transform:none !important;}

.home-card-badge{
  position:absolute; top:10px; left:10px; z-index:2;
  min-width:22px; height:22px; padding:0 6px;
  border-radius:11px;
  background:linear-gradient(135deg, var(--red) 0%, #C24A2F 100%);
  color:#fff; font-size:11px; font-weight:800; font-family:'Vazirmatn',sans-serif;
  direction:ltr;
  align-items:center; justify-content:center;
  box-shadow:0 3px 8px rgba(166,62,40,.35), 0 0 0 2px #fff;
  transform:translateZ(30px);
  animation:homeCardBadgePulse 2s ease-in-out infinite;
}
@keyframes homeCardBadgePulse{
  0%, 100%{ box-shadow:0 3px 8px rgba(166,62,40,.35), 0 0 0 2px #fff; }
  50%{ box-shadow:0 3px 10px rgba(166,62,40,.5), 0 0 0 2px #fff, 0 0 0 5px rgba(166,62,40,.15); }
}
.home-card.locked:hover .home-card-icon{transform:translateZ(24px);}
.home-card.locked:hover .home-card-title{color:var(--ink);}

.theme-tpn{ --icon-bg:#eef2ff; --icon-color:#6366f1; --card-accent:#6366f1; }
.theme-admin{ --icon-bg:#f0fdf4; --icon-color:#16a34a; --card-accent:#16a34a; }
.theme-patients{ --icon-bg:#f0fdfa; --icon-color:#0d9488; --card-accent:#0d9488; }
.theme-profile{ --icon-bg:#faf5ff; --icon-color:#9333ea; --card-accent:#9333ea; }
.theme-drugfood{ --icon-bg:#fff7ed; --icon-color:#ea580c; --card-accent:#ea580c; }
.theme-ppn{ --icon-bg:#ecfeff; --icon-color:#0891b2; --card-accent:#0891b2; }
.theme-anthro{ --icon-bg:#fdf2f8; --icon-color:#db2777; --card-accent:#db2777; }
.theme-siteupdate{ --icon-bg:#eff6ff; --icon-color:#2563eb; --card-accent:#2563eb; }
.theme-references{ --icon-bg:#fffbeb; --icon-color:#B4791C; --card-accent:#B4791C; }
.theme-referrals{ --icon-bg:#fff1f2; --icon-color:#e11d48; --card-accent:#e11d48; }
.theme-chat{ --icon-bg:#f7fee7; --icon-color:#65a30d; --card-accent:#65a30d; }
.theme-points{ --icon-bg:#fefce8; --icon-color:#ca8a04; --card-accent:#ca8a04; }
.theme-aipatterns{ --icon-bg:#faf5ff; --icon-color:#7c3aed; --card-accent:#7c3aed; }

.field{display:flex; flex-direction:column; gap:6px; font-size:13px; color:var(--muted); font-weight:500; margin-bottom:14px;}
.field .unit{color:#8b948d; font-weight:400;}
.field .required-unit{color:#C2410C !important; font-weight:700;}
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=file], select, textarea{
  font-family:'Vazirmatn',sans-serif;
  font-size:14.5px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:7px;
  background:var(--surface-2);
  color:var(--ink);
  outline:none;
  transition:border-color .15s, box-shadow .15s;
  width:100%;
}
input:focus, select:focus, textarea:focus{border-color:var(--teal); box-shadow:0 0 0 3px var(--teal-tint);}

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:11px 18px; border-radius:8px; border:none; font-weight:700; font-size:14.5px;
  cursor:pointer; transition:filter .15s, transform .1s; white-space:nowrap; flex-shrink:0;
}
.btn:active{transform:translateY(1px);}
.btn-primary{background:var(--teal); color:#fff;}
.btn-primary:hover{filter:brightness(1.08);}
.btn-primary:disabled{background:#B7C4BF; cursor:not-allowed;}
.btn-outline{background:var(--surface); border:1px solid var(--line); color:var(--ink);}
.btn-outline:hover{border-color:var(--teal); color:var(--teal-dark);}
.btn-block{width:100%;}
.btn-danger{background:var(--red-tint); color:var(--red);}
.btn-sm{padding:7px 12px; font-size:13px;}

.note{background:var(--teal-tint); color:var(--teal-dark); border-radius:8px; padding:10px 14px; font-size:13px; margin-top:6px;}

.ref-doctor-option{
  background:var(--surface); border:1.5px solid var(--line); border-radius:10px;
  padding:10px 12px; cursor:pointer; transition:border-color .15s, background .15s;
}
.ref-doctor-option:hover{border-color:var(--teal);}
.ref-doctor-option.selected{border-color:var(--teal); background:var(--teal-tint);}
.ref-doctor-check{
  flex-shrink:0; width:20px; height:20px; border-radius:50%; border:1.5px solid var(--line);
  color:transparent; font-size:13px; font-weight:800; display:flex; align-items:center; justify-content:center;
  transition:all .15s;
}
.ref-doctor-option.selected .ref-doctor-check{background:var(--teal); border-color:var(--teal); color:#fff;}
.ref-doctor-suggested{
  display:inline-block; font-size:10.5px; font-weight:700; color:var(--teal-dark);
  background:var(--teal-tint); padding:1px 8px; border-radius:20px; margin-inline-start:4px;
}
.note.warn{background:var(--amber-tint); color:#7A5314;}
.note.bad{background:var(--red-tint); color:var(--red);}

.badge{display:inline-flex; align-items:center; gap:6px; font-size:12.5px; font-weight:700; padding:4px 10px; border-radius:20px;}
.badge.pending{background:var(--amber-tint); color:#7A5314;}
.badge.approved{background:var(--teal-tint); color:var(--teal-dark);}
.badge.rejected{background:var(--red-tint); color:var(--red);}
.badge.incomplete{background:#EDEEEA; color:var(--muted);}

.divider{height:1px; background:var(--line); margin:18px 0;}

.tabs{display:flex; gap:8px; margin-bottom:18px; border-bottom:1px solid var(--line);}
.tabs button{background:none; border:none; padding:10px 4px; font-size:14px; font-weight:600; color:var(--muted); border-bottom:2px solid transparent; margin-inline-end:18px;}
.tabs button.active{color:var(--teal-dark); border-color:var(--teal);}

table.admin-table{width:100%; border-collapse:collapse; font-size:13.5px; table-layout:fixed;}
table.admin-table th{text-align:right; color:var(--muted); font-weight:700; padding:12px 14px; border-bottom:2px solid var(--line); font-size:12px; letter-spacing:.2px; vertical-align:middle; line-height:1.4; background:var(--surface-2);}
table.admin-table td{padding:16px 14px; border-bottom:1px solid var(--line); vertical-align:top; line-height:1.6;}
table.admin-table tbody tr:nth-child(even){background:rgba(18,148,111,.025);}
table.admin-table tbody tr:hover{background:var(--teal-tint);}
table.admin-table td, table.admin-table th{overflow:hidden;}
table.admin-table td:not(:last-child), table.admin-table th:not(:last-child){border-inline-start:1px solid var(--line);}

/* عرض ثابت هر ستون تا ردیف‌ها هم‌راستا بمانند و با محتوای متغیر جابه‌جا نشوند */
table.admin-table col.col-name{width:14%;}
table.admin-table col.col-contact{width:15%;}
table.admin-table col.col-specialty{width:12%;}
table.admin-table col.col-code{width:9%;}
table.admin-table col.col-card{width:9%;}
table.admin-table col.col-reply{width:9%;}
table.admin-table col.col-status{width:12%;}
table.admin-table col.col-actions{width:20%;}

table.admin-table td.admin-cell-name{font-weight:700; color:var(--ink); white-space:normal; overflow-wrap:anywhere; word-break:break-word;}

.admin-contact-stack{display:flex; flex-direction:column; gap:5px;}
.admin-contact-line{
  font-size:11.5px; direction:ltr; text-align:right; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis; display:block; color:var(--muted);
}
.admin-contact-line:first-child{color:var(--ink);}

.admin-specialty-tag{
  display:block; width:100%; box-sizing:border-box; font-size:12px; font-weight:600; color:var(--teal-dark);
  background:var(--teal-tint); padding:5px 10px; border-radius:8px;
  white-space:normal; word-break:break-word; overflow-wrap:break-word;
  line-height:1.45; text-align:center;
}

.admin-code-chip{
  display:inline-block; font-size:12.5px; font-weight:700; color:var(--ink);
  background:var(--surface-2); border:1px solid var(--line); padding:3px 9px; border-radius:6px;
  white-space:nowrap;
}

.admin-reply-preview{
  display:block; font-size:11.5px; color:var(--ink); white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis;
}

/* ---------- پنل ادمین: الگوی شخصی پزشکان (AI Insights) ---------- */
.ai-row-specialty{font-size:11px; font-weight:400; color:var(--muted); margin-top:2px;}
.ai-record-count{
  display:inline-block; font-family:'IBM Plex Mono','Vazirmatn',monospace; font-weight:700;
  font-size:13px; color:#7c3aed; background:#faf5ff; padding:3px 10px; border-radius:20px;
}
.ai-toggle-switch{display:flex; align-items:center; gap:8px; cursor:pointer; user-select:none;}
.ai-toggle-switch input{position:absolute; opacity:0; width:0; height:0;}
.ai-toggle-track{
  position:relative; width:38px; height:22px; border-radius:20px; background:var(--line);
  transition:background .2s; flex-shrink:0;
}
.ai-toggle-thumb{
  position:absolute; top:2px; right:2px; width:18px; height:18px; border-radius:50%;
  background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.25); transition:transform .2s;
}
.ai-toggle-switch input:checked + .ai-toggle-track{background:#7c3aed;}
.ai-toggle-switch input:checked + .ai-toggle-track .ai-toggle-thumb{transform:translateX(-16px);}
.ai-toggle-label{font-size:12px; font-weight:700; color:var(--muted); min-width:38px;}
.ai-toggle-switch input:checked ~ .ai-toggle-label{color:#7c3aed;}
.ai-scope-select{
  width:100%; font-size:12px; padding:6px 8px; border-radius:8px; border:1px solid var(--line);
  background:var(--surface); color:var(--ink); font-family:'Vazirmatn',sans-serif;
}
.ai-scope-select:disabled{opacity:.5; cursor:not-allowed;}
table.ai-patterns-table td{vertical-align:middle;}

.ai-bulk-actions{
  margin-top:16px; background:linear-gradient(160deg,#faf5ff 0%,var(--surface-2) 70%);
  border:1.5px solid #ddd6fe; border-radius:12px; padding:14px 16px;
}
.ai-bulk-actions-label{font-weight:800; font-size:13px; color:#5b21b6; margin-bottom:10px;}
.ai-bulk-actions-row{display:flex; flex-wrap:wrap; gap:20px;}
.ai-bulk-group{display:flex; align-items:center; gap:8px; flex-wrap:wrap;}
.ai-bulk-group-label{font-size:11.5px; color:var(--muted); font-weight:700; margin-inline-end:2px;}
.ai-bulk-btn{border-color:#ddd6fe; color:#6d28d9;}
.ai-bulk-btn:hover{background:#f3e8ff; border-color:#c4b5fd;}
.ai-bulk-btn.danger{color:var(--red); border-color:#fecaca;}
.ai-bulk-btn.danger:hover{background:#fef2f2; border-color:#fca5a5;}
.ai-bulk-btn.active{
  background:linear-gradient(155deg,#bbf7d0,#86efac); border-color:#16a34a; color:#14532d;
  font-weight:800; box-shadow:0 3px 10px -4px rgba(22,163,74,.4);
}
.ai-bulk-btn.active:hover{background:linear-gradient(155deg,#bbf7d0,#86efac); border-color:#16a34a;}
@media (max-width:640px){ .ai-bulk-actions-row{flex-direction:column; align-items:flex-start; gap:12px;} }

table.admin-table td.admin-actions{
  display:flex; flex-direction:column; align-items:stretch; gap:6px;
}
table.admin-table td.admin-actions .btn{width:100%; white-space:nowrap;}

.center-screen{min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px;}
.auth-card{width:100%; max-width:400px; background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:32px 28px; box-shadow:0 10px 40px rgba(20,30,25,.06);}
.auth-logo{display:flex; align-items:center; justify-content:center; margin-bottom:14px;}
.auth-logo img{width:88px; height:88px; object-fit:contain; filter:drop-shadow(0 6px 16px rgba(10,60,45,.18));}
.auth-tagline{text-align:center; font-weight:800; font-size:19px; color:var(--teal-dark); margin-bottom:6px;}
.auth-sub{color:var(--muted); font-size:13.5px; margin-bottom:22px; text-align:center;}
.auth-switch{display:flex; background:var(--surface-2); border:1px solid var(--line); border-radius:9px; padding:3px; margin-bottom:18px;}
.link-btn{
  display:block; width:100%; text-align:center;
  background:none; border:none; color:var(--teal-dark);
  font-family:'Vazirmatn',sans-serif; font-size:13px; font-weight:600;
  cursor:pointer; padding:4px;
}
.link-btn:hover{text-decoration:underline;}
.auth-switch button{flex:1; background:none; border:none; padding:8px; border-radius:7px; font-size:13px; font-weight:600; color:var(--muted);}
.auth-switch button.active{
  background:linear-gradient(150deg, var(--teal-light), var(--teal) 65%);
  color:#fff; font-weight:700;
  box-shadow:0 3px 10px -2px rgba(18,148,111,.45);
}
.google-btn-wrap{display:flex; justify-content:center; margin-bottom:14px; min-height:40px;}
.auth-divider{display:flex; align-items:center; gap:10px; color:var(--muted); font-size:12px; margin:14px 0;}
.auth-divider::before, .auth-divider::after{content:""; flex:1; height:1px; background:var(--line);}

.avatar-upload{display:flex; align-items:center; gap:16px; margin-bottom:18px;}
.avatar-upload .preview{width:74px;height:74px;border-radius:50%; object-fit:cover; background:var(--teal-tint); display:flex; align-items:center; justify-content:center; color:var(--teal-dark); font-weight:700; font-size:22px;}
.avatar-upload .preview.license-preview{width:96px; height:74px; border-radius:10px;}

.spinner{width:16px;height:16px;border-radius:50%;border:2px solid rgba(255,255,255,.4);border-top-color:#fff;animation:spin .7s linear infinite; display:inline-block;}
.spinner.dark{border-color:var(--line); border-top-color:var(--teal);}
@keyframes spin{to{transform:rotate(360deg)}}

.errmsg{color:var(--red); font-size:13px; margin-top:8px;}

.captcha-box{background:var(--surface-2); border:1px solid var(--line); border-radius:11px; padding:12px 14px; margin-top:14px;}
.captcha-row{display:flex; align-items:center; gap:10px;}
.captcha-question{
  flex:1; text-align:center; background:var(--surface); border:1px solid var(--line); border-radius:8px;
  padding:9px 12px; font-size:16px; font-weight:700; color:var(--ink); letter-spacing:.5px;
}
.captcha-refresh{
  flex-shrink:0; width:38px; height:38px; border-radius:8px; border:1px solid var(--line);
  background:var(--surface); color:var(--teal-dark); font-size:18px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; transition:all .15s;
}
.captcha-refresh:hover{background:var(--teal-tint); border-color:var(--teal); transform:rotate(45deg);}
.captcha-answer{margin-top:10px;}

/* ---------- محاسبه اندازه‌گیری‌ها (Anthro) ---------- */
.anthro-hero{
  display:flex; align-items:center; gap:14px; margin-bottom:6px;
}
.anthro-hero .ic{
  width:52px; height:52px; border-radius:14px; flex-shrink:0;
  background:linear-gradient(135deg, var(--teal), var(--teal-dark));
  display:flex; align-items:center; justify-content:center; font-size:26px;
  box-shadow:0 6px 16px rgba(10,90,60,.25);
}
.anthro-hero h2{margin:0; font-size:17px;}
.anthro-hero p{margin:2px 0 0; color:var(--muted); font-size:13px;}

.field-head{display:flex; justify-content:space-between; align-items:flex-end; min-height:2.4em; gap:8px;}
.label-text-plain{color:var(--muted); font-weight:500; font-size:13px;}
.jalali-date-row{display:flex; gap:6px;}
.jalali-date-row select{flex:1; min-width:0;}
.smart-toggle{
  font-family:'Vazirmatn',sans-serif; font-size:11.5px; font-weight:700;
  border-radius:20px; padding:4px 11px; cursor:pointer; white-space:nowrap;
  border:1px solid var(--teal); background:#fff; color:var(--teal);
  transition:all .15s;
}
.smart-toggle:hover{background:var(--teal-tint);}

.bmi-box{
  margin-top:18px; border:1px solid var(--line); border-radius:14px; padding:20px 22px;
  background:var(--surface-2); text-align:center; transition:background .2s, border-color .2s;
}
.bmi-box .bmi-val{font-family:'IBM Plex Mono','Vazirmatn',monospace; font-size:40px; font-weight:800; color:var(--ink); line-height:1;}
.bmi-box .bmi-cat{margin-top:8px; font-size:14.5px; font-weight:700; display:inline-block; padding:4px 14px; border-radius:20px;}
.bmi-box .bmi-note{margin-top:10px; font-size:12px; color:var(--muted);}
.bmi-gauge{position:relative; height:10px; border-radius:6px; margin:18px 4px 2px; direction:ltr;
  background:linear-gradient(90deg, #A9C6DE 0 11.7%, #7FC8A0 11.7% 33.3%, #F4C463 33.3% 50%, #E8935E 50% 66.7%, #D9704F 66.7% 83.3%, #C2544A 83.3% 100%);
}
.bmi-gauge .marker{
  position:absolute; top:-5px; width:2px; height:20px; background:var(--ink); border-radius:2px;
  transform:translateX(-50%); transition:left .25s ease;
}
.bmi-gauge-labels{position:relative; height:16px; font-size:10.5px; color:var(--muted); margin:0 2px 8px;}
.bmi-gauge-labels span{position:absolute; top:0; white-space:nowrap;}

.bmi-cat.under{background:#E7F0F7; color:#2E6B96;}
.bmi-cat.normal{background:var(--teal-tint); color:var(--teal-dark);}
.bmi-cat.over{background:var(--amber-tint); color:#7A5314;}
.bmi-cat.ob1{background:#FBE7E1; color:#A2502E;}
.bmi-cat.ob2{background:#FBDCCB; color:#A2472B;}
.bmi-cat.ob3{background:var(--red-tint); color:var(--red);}

/* ---------- محاسبه‌گر تخمینی قد/وزن — مودال ---------- */
.est-modal-overlay{
  position:fixed; inset:0; background:rgba(15,25,20,.55);
  display:none; align-items:center; justify-content:center;
  z-index:1000; padding:16px; backdrop-filter:blur(2px);
}
.est-modal-overlay.open{display:flex;}
.est-modal{
  background:var(--surface); border-radius:16px; width:100%; max-width:440px;
  max-height:90vh; overflow-y:auto; box-shadow:0 20px 60px rgba(10,20,15,.28);
  animation:estPop .18s ease;
}
@keyframes estPop{from{opacity:0; transform:scale(.94) translateY(8px);} to{opacity:1; transform:scale(1) translateY(0);}}
.est-modal-head{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:18px 20px 14px; border-bottom:1px solid var(--line);
  background:linear-gradient(135deg, var(--teal-tint), #fff);
  border-radius:16px 16px 0 0; position:sticky; top:0;
}
.est-modal-head h3{margin:0; font-size:15.5px; font-weight:800; color:var(--teal-dark); display:flex; align-items:center; gap:8px;}
.est-modal-close{
  width:30px; height:30px; border-radius:50%; border:none; background:var(--surface-2);
  color:var(--muted); font-size:15px; cursor:pointer; display:flex; align-items:center; justify-content:center;
  transition:all .15s; flex-shrink:0;
}
.est-modal-close:hover{background:var(--red-tint); color:var(--red);}
.est-modal-body{padding:18px 20px;}
.est-method-row{display:flex; gap:8px; flex-wrap:wrap; margin-bottom:16px;}
.est-method-chip{
  flex:1; min-width:100px; text-align:center; font-size:12.5px; font-weight:700;
  border:1.5px solid var(--line); background:var(--surface-2); color:var(--muted);
  border-radius:10px; padding:10px 8px; cursor:pointer; transition:all .15s;
}
.est-method-chip:hover{border-color:var(--teal);}
.est-method-chip.active{border-color:var(--teal); background:var(--teal-tint); color:var(--teal-dark);}
.est-field{margin-bottom:14px;}
.est-field label{display:block; font-size:13px; color:var(--muted); font-weight:600; margin-bottom:6px;}
.est-context{
  display:flex; gap:8px; align-items:center; background:var(--surface-2); border:1px dashed var(--line);
  border-radius:9px; padding:10px 12px; font-size:12px; color:var(--muted); margin-bottom:16px;
}
.est-context b{color:var(--ink);}
.est-result{
  margin-top:14px; background:var(--teal-tint); border:1px solid var(--teal); border-radius:10px;
  padding:14px 16px; text-align:center; display:none;
}
.est-result.show{display:block;}
.est-result .val{font-size:26px; font-weight:800; color:var(--teal-dark); font-family:'IBM Plex Mono','Vazirmatn',monospace;}
.est-result .lbl{font-size:12px; color:var(--muted); margin-top:2px;}
.est-warn{
  background:var(--amber-tint); color:#7A5314; border-radius:9px; padding:10px 12px; font-size:12.5px; margin-top:10px;
}
.est-modal-foot{display:flex; gap:10px; padding:6px 20px 20px;}
.est-modal-foot .btn{flex:1; margin:0;}
.est-modal-foot .btn-outline{background:var(--surface-2);}
.confirm-modal-box{max-width:400px;}

/* ---------- تداخلات غذا و دارو ---------- */
.df-search-wrap{display:flex; gap:10px; margin-top:20px; position:relative;}
.df-search-wrap input{flex:1;}
.df-suggestions{
  position:relative; margin-top:8px; border-radius:12px; overflow:hidden;
  max-height:0; opacity:0; transition:max-height .18s ease, opacity .18s ease;
}
.df-suggestions.open{max-height:340px; opacity:1; border:1px solid var(--line); box-shadow:0 10px 24px -14px rgba(20,60,45,.25);}
.df-suggestion-item{
  display:flex; justify-content:space-between; align-items:center; gap:10px;
  padding:11px 16px; cursor:pointer; background:var(--surface); border-top:1px solid var(--line);
  transition:background .12s;
}
.df-suggestion-item:first-child{border-top:none;}
.df-suggestion-item:hover{background:var(--teal-tint);}
.df-sg-name{font-weight:700; font-size:14px; color:var(--ink);}
.df-sg-cat{font-size:11.5px; color:var(--muted);}
.df-ambiguous-box{
  margin-top:18px; background:var(--amber-tint); border:1px solid var(--amber);
  border-radius:12px; padding:16px 18px;
}
.df-amb-title{font-weight:700; font-size:14px; color:#7A5314; margin-bottom:12px;}
.df-amb-chips{display:flex; flex-wrap:wrap; gap:10px;}
.df-amb-chip{
  display:flex; flex-direction:column; align-items:flex-start; gap:2px;
  background:#fff; border:1.5px solid var(--amber); border-radius:10px; padding:9px 14px;
  cursor:pointer; font-family:'Vazirmatn',sans-serif; font-weight:700; font-size:13.5px; color:#7A5314;
  transition:all .15s;
}
.df-amb-chip span{font-size:11px; font-weight:500; color:#9c7a3f;}
.df-amb-chip:hover{background:var(--amber); color:#fff;}
.df-amb-chip:hover span{color:#fff;}

.df-result-card{margin-top:16px;}
.df-result-head{border-bottom:1px solid var(--line); padding-bottom:16px; margin-bottom:18px;}
.df-result-name{font-size:19px; font-weight:800; color:var(--teal-dark); direction:ltr; text-align:right; font-family:'IBM Plex Mono','Vazirmatn',monospace;}
.df-result-fa{font-size:14px; color:var(--ink); margin-top:4px; font-weight:600;}
.df-result-category{display:inline-block; margin-top:8px; background:var(--teal-tint); color:var(--teal-dark); font-size:12px; font-weight:700; padding:4px 12px; border-radius:20px;}

.df-sections{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.df-sec-use{grid-column:1 / -1;}
@media (max-width:640px){ .df-sections{grid-template-columns:1fr;} }
.df-section{
  background:var(--surface-2); border:1px solid var(--line); border-radius:12px;
  padding:14px 16px; box-shadow:0 1px 2px rgba(20,30,25,.04);
}
.df-sec-head{display:flex; align-items:center; gap:8px; font-weight:700; font-size:13.5px; margin-bottom:8px; color:var(--ink);}
.df-sec-ic{font-size:15px;}
.df-section ul{margin:0; padding-inline-start:18px; display:flex; flex-direction:column; gap:6px;}
.df-section li{font-size:13px; color:var(--muted); line-height:1.75;}
.df-sec-body{font-size:13.5px; color:var(--ink); line-height:1.8;}
.df-sec-use{background:linear-gradient(180deg, var(--teal-tint), var(--surface-2));}
.df-sec-side .df-sec-head{color:#8a5a12;}
.df-sec-side{border-inline-start:3px solid var(--amber);}
.df-sec-food{border-inline-start:3px solid var(--teal);}
.df-sec-drug .df-sec-head{color:var(--red);}
.df-sec-drug{border-inline-start:3px solid var(--red);}
.df-sec-supp{border-inline-start:3px solid #2e7d5e;}


/* ══════════════════════════════════════════════════════
   بیماران
   ══════════════════════════════════════════════════════ */
.patients-head-row{display:flex; align-items:flex-start; justify-content:space-between; gap:16px; flex-wrap:wrap;}
.patients-head-row h2{display:flex; align-items:center; gap:8px;}
.patients-head-row h2 svg{width:22px; height:22px; color:var(--teal-dark);}

.patient-card{
  display:flex; align-items:center; gap:14px;
  background:var(--surface-2); border:1px solid var(--line); border-radius:12px;
  padding:14px 16px; margin-bottom:10px;
  transition:border-color .15s, box-shadow .15s;
}
.patient-card:hover{border-color:var(--teal); box-shadow:0 4px 14px rgba(20,30,25,.07);}
.patient-card-avatar{
  width:42px; height:42px; border-radius:50%; flex-shrink:0;
  background:linear-gradient(135deg, var(--teal-light), var(--teal));
  color:#fff; font-weight:800; font-size:17px;
  display:flex; align-items:center; justify-content:center;
}
.patient-card-info{flex:1; min-width:0;}
.patient-card-name{font-weight:700; font-size:14.5px; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.patient-card-nid{font-size:12px; color:var(--muted); direction:ltr; text-align:right; margin-top:2px;}
.patient-card-meta{display:flex; flex-direction:column; align-items:flex-end; gap:4px; font-size:11.5px; color:var(--muted); flex-shrink:0;}
.patient-card-count{font-weight:600;}
.visit-type-badge{display:inline-block; padding:2px 10px; border-radius:20px; font-size:11px; font-weight:800;}
.visit-type-badge.tpn{background:#eef2ff; color:#4338CA;}
.visit-type-badge.ppn{background:#ecfeff; color:#0E7490;}
.patient-card-actions{display:flex; flex-direction:column; gap:6px; flex-shrink:0;}
.patient-card-actions .btn{white-space:nowrap; padding:7px 14px; font-size:12px;}
.patient-card-delete{
  flex-shrink:0; width:28px; height:28px; border-radius:50%; border:none;
  background:transparent; color:var(--muted); cursor:pointer; font-size:14px; line-height:1;
  transition:background .15s, color .15s;
}
.patient-card-delete:hover{background:var(--red-tint); color:var(--red);}

.visit-item{border:1px solid var(--line); border-radius:10px; padding:12px 14px; margin-bottom:10px;}
.visit-item-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:6px;}
.visit-item-date{font-size:11.5px; color:var(--muted); direction:ltr;}
.visit-item-summary{font-size:12.5px; color:var(--ink); margin-bottom:8px;}
.visit-rx-text{
  font-family:'Vazirmatn',sans-serif; font-size:12.5px; line-height:1.9;
  background:var(--surface-2); border-radius:8px; padding:12px; margin-top:8px; color:var(--ink);
  border:1px solid var(--line); direction:ltr; text-align:left;
}
.visit-rx-text .rx-line{white-space:pre-wrap;}
.visit-rx-text .rx-line.rx-fa{direction:rtl; text-align:right; unicode-bidi:plaintext;}
.visit-rx-text .rx-line.rx-en{direction:ltr; text-align:left; unicode-bidi:plaintext; font-family:'IBM Plex Mono','Vazirmatn',monospace;}
.visit-rx-text .idx{color:var(--teal-dark); font-weight:600;}

.visit-item-actions{display:flex; gap:8px; margin-top:4px;}
.visit-details-list{
  margin-top:10px; padding:10px 12px; background:var(--surface-2); border:1px solid var(--line); border-radius:9px;
  display:grid; grid-template-columns:1fr 1fr; gap:6px 16px;
}
@media (max-width:520px){ .visit-details-list{grid-template-columns:1fr;} }
.visit-detail-row{display:flex; align-items:center; justify-content:space-between; gap:10px; font-size:12.5px; padding:3px 0; border-bottom:1px dashed var(--line);}
.visit-detail-label{color:var(--muted); font-weight:600;}
.visit-detail-value{color:var(--ink); font-weight:700; direction:ltr;}

.backup-item{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  background:var(--surface-2); border:1px solid var(--line); border-radius:10px;
  padding:12px 14px; margin-bottom:8px;
}
.backup-item-date{font-size:13px; font-weight:700; color:var(--ink); direction:ltr; text-align:right;}
.backup-item-note{font-size:11.5px; color:var(--muted); margin-top:2px;}

/* ══════════════════════════════════════════════════════
   طراحی اختصاصی موبایل — کل سایت (نه صرفاً کوچک‌شدن دسکتاپ)
   ══════════════════════════════════════════════════════ */
.admin-table-scroll{overflow-x:auto; -webkit-overflow-scrolling:touch; margin:12px -4px 0; padding:0 4px; border:1px solid var(--line); border-radius:12px;}
.admin-table-scroll table.admin-table{min-width:1100px;}

@media (max-width:640px){
  .top{padding:12px 4vw;}
  .brand{font-size:15px; gap:8px;}
  .brand-logo{width:38px; height:38px;}
  .brand-logo img{width:28px; height:28px;}
  .header-actions{gap:6px;}
  .hamburger-btn, .home-icon-btn, .back-icon-btn, .notif-btn{width:36px; height:34px;}
  .logout-icon-btn{height:34px; padding:0 9px; font-size:12px;}
  .logout-icon-btn span:not(.logout-ic){display:none;}

  .page{padding:0 4vw; margin:16px auto 40px;}
  .page.wide, .page.profile-wide, .page.wide.admin-page{max-width:100%;}
  .card{padding:16px 14px; border-radius:14px;}
  .card h2{font-size:15px;}
  .field{margin-bottom:11px;}
  input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=file], select, textarea{
    font-size:14px; padding:9px 10px;
  }
  .btn, .btn-primary, .btn-outline{font-size:13px; padding:10px 14px;}
  .btn-block{padding:12px;}

  .home-card{padding:22px 10px;}
  .home-card-icon{width:50px; height:50px;}
  .home-card-title{font-size:13px;}

  .patient-card{padding:11px 12px; gap:10px;}
  .patient-card-avatar{width:36px; height:36px; font-size:14px;}
  .patient-card-meta{align-items:flex-start;}

  .impersonate-bar-inner{padding:8px 4vw; gap:8px;}
  .impersonate-bar-text{font-size:12px;}
  .impersonate-back-btn{font-size:11.5px; padding:6px 10px;}

  .notif-panel{width:min(85vw, 280px);}
}

/* ══════════════════════════════════════════════════════
   منابع علمی — صفحه‌ی مرکزی
   ══════════════════════════════════════════════════════ */
.refs-hub-head{text-align:center; margin-bottom:28px;}
.refs-hub-head h1{font-size:22px; margin:0 0 6px; color:var(--ink);}
.refs-hub-head p{color:var(--muted); font-size:13.5px; margin:0;}

.refs-hub-grid{
  display:grid; grid-template-columns:repeat(3, 1fr); gap:18px;
}
@media (max-width:720px){ .refs-hub-grid{grid-template-columns:1fr;} }

.refs-tool-card{
  display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center;
  gap:10px; background:rgba(255,255,255,.85); backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
  border:1px solid rgba(255,255,255,.7); border-radius:18px; padding:34px 18px;
  box-shadow:0 10px 25px -8px rgba(20,40,30,.08), 0 6px 10px -6px rgba(20,40,30,.05);
  cursor:pointer; transition:box-shadow .2s ease, border-color .2s ease, transform .15s ease;
  position:relative; overflow:hidden;
}
.refs-tool-card::before{
  content:''; position:absolute; top:0; left:0; right:0; height:3px;
  background:linear-gradient(90deg, transparent, var(--tool-color, var(--teal)), transparent);
  opacity:0; transition:opacity .2s ease;
}
.refs-tool-card:hover{
  border-color:color-mix(in srgb, var(--tool-color, var(--teal)) 35%, transparent);
  box-shadow:0 20px 34px -10px rgba(20,40,30,.16), 0 10px 14px -8px rgba(20,40,30,.08);
  transform:translateY(-2px);
}
.refs-tool-card:hover::before{opacity:1;}
.refs-tool-card:active{transform:translateY(0) scale(.98);}
.refs-tool-icon{font-size:40px; line-height:1;}
.refs-tool-title{font-size:15.5px; font-weight:800; color:var(--ink);}
.refs-tool-card:hover .refs-tool-title{color:var(--tool-color, var(--teal-dark));}
.refs-tool-sub{font-size:11.5px; color:var(--muted); margin-top:-6px;}

.refs-detail-head{margin-bottom:26px;}
.refs-detail-head h1{font-size:20px; margin:0 0 8px; color:var(--ink);}
.refs-detail-head p{color:var(--muted); font-size:13px; line-height:1.8; margin:0;}

.refs-category{margin-bottom:22px;}
.refs-category-head{
  display:flex; align-items:center; gap:8px;
  font-size:14.5px; font-weight:800; color:var(--teal-dark);
  margin-bottom:10px; padding-bottom:8px; border-bottom:2px solid var(--teal-tint);
}
.refs-category-icon{font-size:17px;}

.ref-list{display:flex; flex-direction:column; gap:10px;}
.ref-item{
  border:1px solid var(--line); border-inline-start:3px solid var(--teal);
  border-radius:10px; background:var(--surface-2); padding:12px 14px;
}
.ref-rule{font-size:13px; font-weight:600; color:var(--ink); margin-bottom:4px; line-height:1.7;}
.ref-source{font-size:11.5px; color:var(--muted); line-height:1.7;}

@media (max-width:560px){
  .refs-hub-head h1{font-size:19px;}
  .refs-tool-card{padding:26px 14px;}
  .refs-tool-icon{font-size:34px;}
}

/* ══════════════════════════════════════════════════════
   ارجاع به پزشک دیگر
   ══════════════════════════════════════════════════════ */
.patient-card-avatar img, .leaderboard-avatar img, .chat-msg-avatar img {
  width:100%; height:100%; border-radius:50%; object-fit:cover;
}
.ref-status-badge{display:inline-block; padding:3px 10px; border-radius:20px; font-size:11px; font-weight:700; white-space:nowrap;}
.ref-status-sent{background:var(--amber-tint); color:var(--amber);}
.ref-status-read{background:#eef2ff; color:#4338CA;}
.ref-status-answered{background:var(--teal-tint); color:var(--teal-dark);}

/* ---------- دگمه‌های «ارجاعات دریافتی / ارسالی» ---------- */
.ref-tab-toggle{display:flex; gap:12px; margin-top:16px; max-width:620px;}
.ref-tab-btn{
  flex:1; display:flex; flex-direction:column; align-items:center; gap:8px;
  padding:14px 16px; border-radius:14px; border:1.5px solid var(--line); background:var(--surface);
  cursor:pointer; transition:border-color .18s, background .18s, box-shadow .18s, transform .12s;
  box-shadow:0 1px 3px rgba(20,30,25,.04);
}
.ref-tab-btn:hover{border-color:var(--teal); transform:translateY(-1px);}
.ref-tab-btn.active{
  border-color:var(--teal-dark);
  background:linear-gradient(155deg, var(--teal-light) 0%, var(--teal) 60%, var(--teal-dark) 100%);
  box-shadow:0 10px 24px -8px rgba(18,148,111,.45), inset 0 1px 0 rgba(255,255,255,.2);
}
.ref-tab-btn.active:hover{transform:none;}
.ref-tab-label{font-weight:800; font-size:14px; color:var(--ink); display:flex; align-items:center; gap:6px; white-space:nowrap;}
.ref-tab-btn.active .ref-tab-label{color:#fff;}
.ref-tab-counts{display:flex; gap:6px; flex-wrap:wrap; justify-content:center; min-height:20px;}
.ref-tab-count{font-size:10.5px; font-weight:700; padding:2.5px 9px; border-radius:20px; white-space:nowrap;}
.ref-tab-count.unread{background:var(--amber-tint); color:var(--amber);}
.ref-tab-count.read{background:#eef2ff; color:#4338CA;}
.ref-tab-count.answered{background:var(--teal-tint); color:var(--teal-dark);}
.ref-tab-btn.active .ref-tab-count.unread{background:rgba(255,255,255,.28); color:#fff;}
.ref-tab-btn.active .ref-tab-count.read{background:rgba(255,255,255,.2); color:#fff;}
.ref-tab-btn.active .ref-tab-count.answered{background:rgba(255,255,255,.32); color:#fff;}
@media (max-width:560px){ .ref-tab-toggle{gap:8px;} .ref-tab-label{font-size:12.5px;} .ref-tab-btn{padding:11px 8px;} }

.ref-visit-check{
  display:flex; align-items:center; gap:10px; padding:10px 12px; border:1px solid var(--line);
  border-radius:9px; margin-bottom:8px; cursor:pointer; font-size:12.5px;
}
.ref-visit-check:hover{border-color:var(--teal);}
.ref-visit-check input{width:16px; height:16px; flex-shrink:0;}
.ref-visit-summary{color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}

.est-modal-actions{display:flex; gap:10px; justify-content:flex-end;}
.est-modal-actions .btn{flex:1;}

.refd-section{margin-top:22px; padding-top:18px; border-top:1px solid var(--line);}
.refd-section h3{font-size:14.5px; margin:0 0 12px; color:var(--ink);}

.refd-message{
  background:var(--surface-2); border:1px solid var(--line); border-radius:12px;
  padding:12px 14px; margin-bottom:10px;
}
.refd-message.mine{background:var(--teal-tint); border-color:#D8EEE4;}
.refd-message-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; gap:10px;}
.refd-message-head b{font-size:13px; color:var(--ink);}
.refd-message-date{font-size:11px; color:var(--muted); white-space:nowrap;}
.refd-message-text{font-size:13px; color:var(--ink); line-height:1.8;}
.refd-role-tag{font-size:10px; font-weight:700; padding:2px 8px; border-radius:20px; white-space:nowrap;}
.refd-role-tag.referrer{background:var(--amber-tint); color:var(--amber);}
.refd-role-tag.responder{background:var(--teal-tint); color:var(--teal-dark);}

.refd-proposed-visit{
  margin-top:10px; padding:10px 12px; background:var(--surface); border:1px dashed var(--teal); border-radius:10px;
}
.refd-pv-head{display:flex; align-items:center; gap:10px; margin-bottom:6px;}

.refd-compose{margin-top:14px;}
.refd-compose textarea{
  width:100%; border:1px solid var(--line); border-radius:10px; padding:10px 12px;
  font-family:inherit; font-size:13px; resize:vertical;
}

/* ══════════════════════════════════════════════════════
   چت همگانی
   ══════════════════════════════════════════════════════ */
.chat-card{display:flex; flex-direction:column;}
.chat-messages-list{
  max-height:55vh; overflow-y:auto; padding:6px 4px; display:flex; flex-direction:column; gap:12px;
  border:1px solid var(--line); border-radius:12px; background:var(--surface-2);
}
.chat-message{display:flex; gap:8px; padding:3px 12px; align-items:flex-end;}
.chat-message.mine{flex-direction:row-reverse; text-align:right;}
.chat-msg-avatar{
  width:32px; height:32px; border-radius:50%; flex-shrink:0;
  background:linear-gradient(135deg, var(--teal-light), var(--teal));
  color:#fff; font-weight:800; font-size:13px;
  display:flex; align-items:center; justify-content:center;
}
.chat-msg-body{
  max-width:70%; min-width:0;
  background:var(--surface); border:1px solid var(--line); border-radius:16px;
  padding:8px 12px; box-shadow:0 1px 2px rgba(20,30,25,.04);
}
.chat-message.mine .chat-msg-body{background:var(--teal-tint); border-color:#D8EEE4;}
.chat-msg-head{display:flex; align-items:center; justify-content:space-between; gap:14px; margin-bottom:2px;}
.chat-msg-name{font-weight:700; font-size:12px; color:var(--teal-dark); white-space:nowrap;}
.chat-msg-date{font-size:10px; color:var(--muted); white-space:nowrap;}
.chat-msg-text{font-size:13.5px; color:var(--ink); line-height:1.7; white-space:pre-wrap; word-break:break-word;}
.chat-msg-image{max-width:240px; max-height:240px; border-radius:10px; margin-top:6px; display:block; object-fit:cover;}
.chat-msg-actions{display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-top:6px;}
@media (max-width:640px){ .chat-msg-body{max-width:84%;} }
.chat-action-btn{
  background:none; border:1px solid var(--line); border-radius:20px; padding:3px 10px;
  font-size:11px; color:var(--muted); cursor:pointer; transition:all .15s;
}
.chat-action-btn:hover{border-color:var(--teal); color:var(--teal-dark);}
.chat-rating-display{font-size:11px; color:var(--amber); font-weight:700;}
.chat-rating-count{color:var(--muted); font-weight:400;}
.chat-rater-row{display:flex; gap:6px; margin-top:8px;}
.chat-rate-num{
  width:28px; height:28px; border-radius:50%; border:1px solid var(--line); background:var(--surface);
  cursor:pointer; font-weight:700; font-size:12px; color:var(--ink); transition:all .15s;
}
.chat-rate-num:hover{background:var(--teal); color:#fff; border-color:var(--teal);}

.chat-reply-ref{
  border-inline-start:3px solid var(--teal); background:var(--surface-2); border-radius:6px;
  padding:5px 10px; margin-bottom:6px; font-size:11.5px;
}
.chat-reply-ref-name{font-weight:700; color:var(--teal-dark); margin-inline-end:6px;}
.chat-reply-ref-text{color:var(--muted);}

.chat-edit-box textarea{width:100%; border:1px solid var(--line); border-radius:8px; padding:8px 10px; font-family:inherit; font-size:13px;}

.chat-composer{margin-top:14px; border-top:1px solid var(--line); padding-top:14px;}
.chat-reply-banner{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:var(--teal-tint); border-radius:8px; padding:6px 12px; font-size:12px; margin-bottom:8px;
}
.chat-reply-banner button{background:none; border:none; cursor:pointer; color:var(--muted); font-size:14px;}
.chat-image-preview-chip{
  display:inline-flex; align-items:center; gap:8px; background:var(--surface-2); border:1px solid var(--line);
  border-radius:8px; padding:6px 12px; font-size:12px; margin-bottom:8px;
}
.chat-image-preview-chip button{background:none; border:none; cursor:pointer; color:var(--red); font-size:13px;}
.chat-composer-row{display:flex; gap:10px; align-items:flex-end;}
.chat-composer-row textarea{
  flex:1; border:1px solid var(--line); border-radius:10px; padding:10px 12px;
  font-family:inherit; font-size:13px; resize:vertical;
}
.chat-composer-actions{display:flex; align-items:center; gap:8px;}
.chat-image-btn{
  width:40px; height:40px; border-radius:10px; border:1px solid var(--line); background:var(--surface-2);
  display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:17px; flex-shrink:0;
}
.chat-image-btn:hover{border-color:var(--teal);}

/* ══════════════════════════════════════════════════════
   امتیاز و رتبه
   ══════════════════════════════════════════════════════ */
.points-breakdown-grid{display:grid; grid-template-columns:repeat(5, 1fr); gap:14px; margin-top:16px;}
@media (max-width:900px){ .points-breakdown-grid{grid-template-columns:1fr 1fr 1fr;} }
@media (max-width:520px){ .points-breakdown-grid{grid-template-columns:1fr 1fr;} }
.points-stat{
  background:var(--surface-2); border:1px solid var(--line); border-radius:12px;
  padding:18px 10px; text-align:center;
}
.points-stat-value{font-size:22px; font-weight:800; color:var(--teal-dark); font-family:'IBM Plex Mono','Vazirmatn',monospace;}
.points-stat-label{font-size:11.5px; color:var(--muted); margin-top:4px;}
.points-stat-total{background:linear-gradient(135deg, var(--teal-tint), #fff); border-color:var(--teal);}
.points-stat-total .points-stat-value{color:var(--teal); font-size:26px;}
.points-stat-rank{background:linear-gradient(135deg, var(--amber-tint), #fff); border-color:var(--amber);}
.points-stat-rank .points-stat-value{color:var(--amber); font-size:26px;}

.leaderboard-row{
  display:flex; align-items:center; gap:14px; padding:10px 12px; border-radius:10px;
  border-bottom:1px solid var(--line);
}
.leaderboard-row.me{background:var(--teal-tint); border-radius:10px;}
.leaderboard-rank{width:28px; text-align:center; font-weight:800; color:var(--muted); font-family:'IBM Plex Mono','Vazirmatn',monospace;}
.leaderboard-row:nth-child(1) .leaderboard-rank{color:#CA8A04; font-size:16px;}
.leaderboard-row:nth-child(2) .leaderboard-rank{color:#94A3B8; font-size:15px;}
.leaderboard-row:nth-child(3) .leaderboard-rank{color:#B45309; font-size:15px;}
.leaderboard-avatar{
  width:36px; height:36px; border-radius:50%; flex-shrink:0;
  background:linear-gradient(135deg, var(--teal-light), var(--teal));
  color:#fff; font-weight:800; font-size:14px;
  display:flex; align-items:center; justify-content:center;
}
.leaderboard-name{flex:1; font-weight:600; font-size:13.5px; color:var(--ink);}
.leaderboard-points{font-weight:800; color:var(--teal-dark); font-size:13px; font-family:'IBM Plex Mono','Vazirmatn',monospace;}

@media (max-width:560px){
  .chat-messages-list{max-height:65vh;}
  .chat-composer-row{flex-direction:column; align-items:stretch;}
  .points-breakdown-grid{grid-template-columns:1fr 1fr;}
}
