:root{
  --navy:#0A1438;
  --navy-2:#131E4A;
  --navy-3:#1B2A5E;
  --black:#111111;
  --gold:#D4AF37;
  --gold-dim:#a5872c;
  --white:#FFFFFF;
  --bg:#F5F6FA;
  --muted:#6b7280;
  --border:#e5e7eb;
  --danger:#c0392b;
  --success:#1e8e5a;
  --warn:#b8860b;
  --radius:10px;
}
*{box-sizing:border-box; margin:0; padding:0;}
body{
  font-family:'Vazirmatn', sans-serif;
  background:var(--bg);
  color:var(--black);
  min-height:100vh;
  direction:rtl;
}
::selection{background:var(--gold); color:var(--navy);}

/* ---------- LOGIN ---------- */
#login-screen{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  background:
    radial-gradient(circle at 20% 20%, rgba(212,175,55,0.08), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(212,175,55,0.06), transparent 40%),
    var(--navy);
  padding:20px;
}
.login-card{
  background:var(--navy-2);
  border:1px solid rgba(212,175,55,0.25);
  border-radius:16px;
  padding:44px 40px;
  width:100%;
  max-width:380px;
  text-align:center;
  box-shadow:0 20px 60px rgba(0,0,0,0.4);
}
.brand-mark{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:56px; height:56px;
  border-radius:14px;
  background:linear-gradient(135deg, var(--gold), #b8912e);
  color:var(--navy);
  font-weight:800;
  font-size:22px;
  margin-bottom:18px;
}
.login-card h1{color:var(--white); font-size:22px; font-weight:700; margin-bottom:6px;}
.login-card p.sub{color:#9aa3c0; font-size:13px; margin-bottom:28px;}
.field{text-align:right; margin-bottom:16px;}
.field label{display:block; font-size:12.5px; color:#c9cfe6; margin-bottom:6px; font-weight:500;}
.field input{
  width:100%; padding:12px 14px; border-radius:9px;
  border:1px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.05); color:var(--black);
  font-family:inherit; font-size:14px; outline:none; transition:border-color .15s;
}
.field input::placeholder{color:#6b7396;}
.field input:focus{border-color:var(--gold);}
.btn-gold{
  width:100%; padding:13px; border-radius:9px; border:none;
  background:var(--gold); color:var(--navy); font-family:inherit;
  font-weight:700; font-size:14.5px; cursor:pointer;
  transition:filter .15s, transform .05s; margin-top:6px;
}
.btn-gold:hover{filter:brightness(1.08);}
.btn-gold:active{transform:scale(0.98);}
.btn-gold:disabled{opacity:.6; cursor:not-allowed;}
.login-portal-note{
  display:flex; align-items:center; gap:8px; justify-content:center;
  font-size:11.5px; color:#8b92b8; margin-bottom:22px;
  padding:9px 12px; background:rgba(255,255,255,0.04); border-radius:8px;
}
.login-alt-link{margin-top:16px; font-size:12px;}
.login-alt-link a{color:var(--gold); text-decoration:none;}
.login-alt-link a:hover{text-decoration:underline;}
.login-error{
  display:none; text-align:right; background:rgba(192,57,43,0.12); border:1px solid rgba(192,57,43,0.4);
  color:#ff9d90; font-size:12.5px; padding:10px 12px; border-radius:8px; margin-bottom:16px; font-weight:600;
}
.login-error.show{display:block;}

/* ---------- APP SHELLS ---------- */
.shell{display:flex; min-height:100vh;}

.sidebar{
  width:250px; color:var(--white);
  display:flex; flex-direction:column; flex-shrink:0; padding:24px 18px;
}
.sidebar.theme-employee{background:var(--navy);}
.sidebar.theme-admin{background:var(--black);}

.sidebar .brand{
  display:flex; align-items:center; gap:10px;
  padding:0 6px 24px; margin-bottom:8px;
  border-bottom:1px solid rgba(255,255,255,0.08);
}
.sidebar .brand .mark{
  width:34px;height:34px; border-radius:9px;
  background:var(--gold); color:var(--navy);
  display:flex;align-items:center;justify-content:center; font-weight:800; font-size:14px;
}
.sidebar .brand .name{font-weight:700; font-size:16px;}
.sidebar .brand .tag{font-size:10.5px; color:#8b92b8;}
.portal-tag{
  display:inline-block; margin-top:6px; padding:3px 9px;
  background:rgba(212,175,55,0.15); color:var(--gold);
  border-radius:20px; font-size:10px; font-weight:700;
}

.nav-group{margin-top:18px;}
.nav-label{font-size:10.5px; color:#6b7396; font-weight:600; letter-spacing:.03em; padding:0 10px; margin-bottom:8px;}
.nav-item{
  display:flex; align-items:center; gap:10px; padding:11px 12px; border-radius:9px;
  color:#c3c8e0; font-size:13.5px; font-weight:500; cursor:pointer; margin-bottom:3px;
  transition:.12s; border:1px solid transparent;
}
.nav-item:hover{background:rgba(255,255,255,0.06); color:var(--white);}
.nav-item.active{background:rgba(212,175,55,0.13); color:var(--gold); border-color:rgba(212,175,55,0.3);}
.nav-item .dot{width:6px;height:6px;border-radius:50%;background:currentColor; opacity:0.7;}

.sidebar-footer{margin-top:auto; padding-top:16px; border-top:1px solid rgba(255,255,255,0.08);}
.user-chip{display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:9px;}
.user-chip .avatar{
  width:32px;height:32px; border-radius:50%; background:rgba(255,255,255,0.08);
  border:1px solid rgba(212,175,55,0.4); color:var(--gold);
  display:flex;align-items:center;justify-content:center; font-size:12px; font-weight:700;
}
.user-chip .info .n{font-size:13px; font-weight:600; color:var(--white);}
.user-chip .info .r{font-size:11px; color:#8b92b8;}
.logout-btn{
  width:100%; margin-top:10px; padding:9px; background:transparent;
  border:1px solid rgba(255,255,255,0.1); color:#c3c8e0; border-radius:8px;
  font-family:inherit; font-size:12.5px; cursor:pointer;
}
.logout-btn:hover{border-color:var(--gold); color:var(--gold);}

.main{flex:1; padding:28px 32px; overflow-x:hidden;}
.topbar{display:flex; align-items:center; justify-content:space-between; margin-bottom:24px; flex-wrap:wrap; gap:10px;}
.topbar h2{font-size:20px; font-weight:700;}
.topbar p{font-size:12.5px; color:var(--muted); margin-top:3px;}
.today-badge{background:var(--navy); color:var(--gold); font-size:12px; font-weight:600; padding:8px 14px; border-radius:20px;}

.view{display:none;}
.view.active{display:block;}

.stats-row{display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:24px;}
.stat-card{background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:16px 18px; position:relative; overflow:hidden;}
.stat-card .val{font-size:26px; font-weight:800; color:var(--navy);}
.stat-card .lbl{font-size:12px; color:var(--muted); margin-top:4px;}
.stat-card::before{content:''; position:absolute; top:0; right:0; width:4px; height:100%; background:var(--gold);}
.stat-card.admin-accent::before{background:var(--black);}

.panel{background:var(--white); border:1px solid var(--border); border-radius:var(--radius); padding:22px; margin-bottom:20px;}
.panel-title{font-size:15px; font-weight:700; margin-bottom:4px;}
.panel-sub{font-size:12px; color:var(--muted); margin-bottom:18px;}

.add-form{display:flex; gap:12px; align-items:flex-end; flex-wrap:wrap;}
.form-field{flex:1; min-width:200px;}
.form-field-wide{flex-basis:100%; min-width:200px;}
.form-field label{display:block; font-size:12.5px; font-weight:600; margin-bottom:6px; color:#374151;}
.form-field input, .form-field select{
  width:100%; padding:11px 13px; border-radius:8px; border:1.5px solid var(--border);
  font-family:inherit; font-size:14px; outline:none; transition:border-color .15s; background:var(--white);
}
.form-field input:focus, .form-field select:focus{border-color:var(--navy);}
.form-field input.err{border-color:var(--danger); background:#fdf2f1;}
.btn-primary{
  padding:11.5px 22px; background:var(--navy); color:var(--white); border:none; border-radius:8px;
  font-family:inherit; font-weight:600; font-size:13.5px; cursor:pointer; white-space:nowrap; transition:filter .15s;
}
.btn-primary:hover{filter:brightness(1.2);}
.btn-primary:disabled{opacity:.6; cursor:not-allowed;}
.err-msg{color:var(--danger); font-size:12px; margin-top:8px; display:none; font-weight:600;}
.err-msg.show{display:block;}
.ok-msg{color:var(--success); font-size:12px; margin-top:8px; display:none; font-weight:600;}
.ok-msg.show{display:block;}

.table-wrap{overflow-x:auto;}
table{width:100%; border-collapse:collapse; font-size:13px;}
thead th{text-align:right; padding:10px 12px; color:var(--muted); font-weight:600; font-size:11.5px; border-bottom:1.5px solid var(--border); white-space:nowrap;}
tbody td{padding:12px; border-bottom:1px solid var(--border); white-space:nowrap;}
tbody tr:hover{background:#fafafa;}
.page-name{font-weight:600;}
.phone{direction:ltr; text-align:right; font-family:inherit; color:#374151;}

/* ---------- PHONE CELL + DESCRIPTION BUTTON ---------- */
.phone-cell{display:inline-flex; align-items:center; gap:8px; direction:rtl;}
.desc-btn{
  position:relative; width:26px; height:26px; flex-shrink:0; border-radius:7px;
  border:1px solid var(--border); background:var(--white); cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center; font-size:12px;
  color:#6b7280; padding:0; transition:.12s;
}
.desc-btn:hover{border-color:var(--navy); background:#f5f6fa; color:var(--navy);}
.desc-btn.has-desc{border-color:rgba(30,142,90,0.5); background:#f0faf5; color:var(--success);}
.desc-btn .desc-ic{line-height:1; pointer-events:none;}
.desc-tick{
  position:absolute; top:-6px; left:-6px; width:14px; height:14px; border-radius:50%;
  background:var(--success); color:var(--white); font-size:9px; font-weight:800;
  display:flex; align-items:center; justify-content:center; border:2px solid var(--white);
  pointer-events:none;
}
.modal-phone{direction:ltr; unicode-bidi:embed; color:var(--navy); font-weight:800;}

.badge{display:inline-flex; align-items:center; gap:5px; padding:5px 10px; border-radius:20px; font-size:11px; font-weight:600;}
.badge .d{width:6px;height:6px;border-radius:50%;}
.badge-pending{background:#eef0f7; color:#4b5563;} .badge-pending .d{background:#9ca3af;}
.badge-called{background:#e8f3ee; color:var(--success);} .badge-called .d{background:var(--success);}
.badge-noanswer{background:#fdf4e3; color:var(--warn);} .badge-noanswer .d{background:var(--warn);}
.badge-notwanted{background:#fdedec; color:var(--danger);} .badge-notwanted .d{background:var(--danger);}
.badge-hassite{background:#eee9fb; color:#6d3fc9;} .badge-hassite .d{background:#6d3fc9;}
.badge-followup{background:#e6effa; color:#1a63b8;} .badge-followup .d{background:#1a63b8;}
.badge-telegram{background:#e5f4fc; color:#0088cc;} .badge-telegram .d{background:#0088cc;}
.badge-whatsapp{background:#e5f9ec; color:#1da851;} .badge-whatsapp .d{background:#1da851;}
.badge-instagram{background:#fbe7f2; color:#c13584;} .badge-instagram .d{background:#c13584;}
.badge-size-small{background:#eef0f7; color:#4b5563;} .badge-size-small .d{background:#9ca3af;}
.badge-size-medium{background:#fdf4e3; color:var(--warn);} .badge-size-medium .d{background:var(--warn);}
.badge-size-large{background:#fdedec; color:var(--danger);} .badge-size-large .d{background:var(--danger);}
.badge-size-none{background:#eef0f7; color:#9ca3af;}
.badge-category{background:#eaf1fb; color:#1a63b8;}

.status-select{padding:6px 10px; border-radius:7px; border:1.5px solid var(--border); font-family:inherit; font-size:12px; background:var(--white); cursor:pointer;}
.row-actions{display:flex; gap:6px;}
.icon-btn{
  width:30px; height:30px; border-radius:7px; border:1px solid var(--border); background:var(--white);
  cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:14px; transition:.12s;
}
.icon-btn:hover{border-color:var(--navy); background:#f5f6fa;}
.icon-btn.danger:hover{border-color:var(--danger); background:#fdf2f1;}

.owner-chip{display:inline-flex; align-items:center; gap:6px; font-size:12px; font-weight:600; color:var(--navy);}
.owner-chip .av{
  width:20px; height:20px; border-radius:50%; background:var(--navy); color:var(--gold);
  display:flex; align-items:center; justify-content:center; font-size:9px; font-weight:800;
}

.filters-row{display:flex; gap:10px; flex-wrap:wrap; margin-bottom:18px;}
.filters-row input[type=text]{flex:2; min-width:220px; padding:10px 14px; border-radius:8px; border:1.5px solid var(--border); font-family:inherit; font-size:13.5px;}
.filters-row select{padding:10px 12px; border-radius:8px; border:1.5px solid var(--border); font-family:inherit; font-size:13px; background:var(--white); min-width:150px;}
.filters-row input:focus, .filters-row select:focus{outline:none; border-color:var(--navy);}

.scope-note{
  display:flex; align-items:center; gap:8px; font-size:12px; color:var(--navy);
  background:#eef1fb; border:1px solid #d8deef; padding:9px 13px; border-radius:8px; margin-bottom:16px;
}

.empty-state{text-align:center; padding:50px 20px; color:var(--muted);}
.empty-state .ic{font-size:34px; margin-bottom:10px; opacity:.5;}
.empty-state p{font-size:13.5px;}

.toast{
  position:fixed; bottom:20px; left:20px; z-index:200; background:var(--navy); color:var(--white);
  padding:12px 18px; border-radius:9px; font-size:13px; font-weight:600; box-shadow:0 10px 30px rgba(0,0,0,.25);
  display:none;
}
.toast.show{display:block;}
.toast.err{background:var(--danger);}

.modal-overlay{display:none; position:fixed; inset:0; background:rgba(10,20,56,0.55); align-items:center; justify-content:center; z-index:100; padding:20px;}
.modal-overlay.show{display:flex;}
.modal{background:var(--white); border-radius:14px; padding:26px; width:100%; max-width:400px;}
.modal h3{font-size:16px; font-weight:700; margin-bottom:18px;}
.modal .field{text-align:right; margin-bottom:16px;}
.modal .field label{display:block; font-size:12.5px; font-weight:600; margin-bottom:6px; color:#374151;}
.modal .field input, .modal .field select{width:100%; padding:11px 13px; border-radius:8px; border:1.5px solid var(--border); font-family:inherit; font-size:14px; background:var(--white);}
.modal-actions{display:flex; gap:10px; margin-top:20px;}
.modal-actions button{flex:1;}
.btn-ghost{padding:11px; border-radius:8px; border:1.5px solid var(--border); background:var(--white); color:#374151; font-family:inherit; font-weight:600; font-size:13.5px; cursor:pointer;}

.mobile-menu-btn{
  display:none; width:38px;height:38px; border-radius:8px; border:1px solid var(--border);
  background:var(--white); align-items:center; justify-content:center; cursor:pointer; margin-left:10px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px){
  .sidebar{position:fixed; right:-260px; top:0; bottom:0; z-index:50; transition:.2s; width:250px; max-width:80vw;}
  .sidebar.open{right:0; box-shadow:0 0 40px rgba(0,0,0,.35);}
  .main{padding:18px;}
  .stats-row{grid-template-columns:repeat(2,1fr);}
  .mobile-menu-btn{display:flex !important;}
}

@media (max-width: 640px){
  body{overflow-x:hidden;}
  .login-card{padding:32px 22px;}
  .main{padding:14px;}
  .topbar{margin-bottom:16px;}
  .topbar h2{font-size:17px;}
  .topbar p{font-size:11.5px;}
  .today-badge{font-size:11px; padding:6px 11px;}

  .stats-row{grid-template-columns:repeat(2,1fr); gap:10px; margin-bottom:16px;}
  .stat-card{padding:12px 14px;}
  .stat-card .val{font-size:21px;}
  .stat-card .lbl{font-size:11px;}

  .panel{padding:16px;}
  .panel-title{font-size:14px;}

  .add-form{flex-direction:column; align-items:stretch; gap:10px;}
  .form-field{min-width:0;}
  .add-form .btn-primary{width:100%;}

  .filters-row{flex-direction:column; align-items:stretch;}
  .filters-row input[type=text], .filters-row select{width:100%; min-width:0; flex:none;}

  .modal{padding:20px; max-width:100%;}

  /* جداول در موبایل به‌صورت کارت نمایش داده می‌شوند تا اسکرول افقی لازم نباشد */
  .table-wrap{overflow-x:visible;}
  table, thead, tbody, th, td, tr{display:block;}
  thead{position:absolute; top:-9999px; left:-9999px;}
  table tr{
    background:var(--white); border:1px solid var(--border); border-radius:10px;
    padding:10px 12px; margin-bottom:10px;
  }
  table tbody tr:hover{background:var(--white);}
  table td{
    display:flex; align-items:center; justify-content:space-between; gap:12px;
    border-bottom:1px dashed var(--border); padding:9px 2px; white-space:normal; text-align:left;
  }
  table td:last-child{border-bottom:none;}
  table td[data-label]::before{
    content:attr(data-label); font-size:11px; font-weight:700; color:var(--muted);
    flex-shrink:0;
  }
  table td.page-name{justify-content:space-between;}
  table .status-select{max-width:170px;}
  table .row-actions{justify-content:flex-end;}
  table td[colspan]{display:block; text-align:center;}
  table td[colspan]::before{content:none;}
}
