:root{
  --bg:#f5f7fb;
  --card:#ffffff;
  --text:#172033;
  --muted:#667085;
  --line:#e4e7ec;
  --brand:#2563eb;
  --brand-dark:#1d4ed8;
  --green:#16a34a;
  --red:#dc2626;
  --amber:#d97706;
  --radius:14px;
}

*{box-sizing:border-box}

html{direction:rtl}

body{
  margin:0;
  min-height:100vh;
  font-family:Tahoma, Arial, sans-serif;
  background:var(--bg);
  color:var(--text);
  font-size:14px;
}

a{
  color:var(--brand);
  text-decoration:none;
}

a:hover{
  text-decoration:underline;
}

header{
  background:#fff;
  border-bottom:1px solid var(--line);
  position:sticky;
  top:0;
  z-index:20;
}

nav{
  max-width:1240px;
  margin:0 auto;
  padding:12px 18px;
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}

nav:before{
  content:"پنل مدیریت دستیار";
  margin-left:auto;
  font-weight:800;
  color:#111827;
}

nav a{
  color:#344054;
  padding:8px 12px;
  border-radius:10px;
  font-weight:600;
}

nav a:hover{
  background:#f2f4f7;
  text-decoration:none;
}

nav a.logout{
  color:var(--red);
  background:#fff1f2;
}

main,.container{
  width:min(1240px,calc(100% - 28px));
  margin:22px auto;
}

h1{
  margin:0 0 18px;
  font-size:24px;
  line-height:1.5;
}

h2,h3{
  margin:0 0 14px;
  line-height:1.5;
}

p{
  color:var(--muted);
  line-height:1.9;
}

.card,.panel,section,form:not(.login-card){
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:18px;
  margin-bottom:16px;
  box-shadow:0 1px 3px rgba(16,24,40,.06);
}

.stats,.grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:14px;
  margin:16px 0;
}

.stat,.stats > *,.grid > *{
  background:#fff;
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:16px;
}

.stat b,.stats b,.grid b{
  display:block;
  font-size:26px;
  margin-top:6px;
  color:#111827;
}

.filters{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:12px 0 18px;
}

.filters a{
  background:#fff;
  border:1px solid var(--line);
  color:#344054;
  padding:8px 12px;
  border-radius:999px;
  font-weight:600;
}

.filters a.on,
.on{
  background:#eff6ff;
  border-color:#bfdbfe;
  color:var(--brand-dark);
}

table{
  width:100%;
  border-collapse:collapse;
  background:#fff;
  border:1px solid var(--line);
  border-radius:var(--radius);
  overflow:hidden;
}

th{
  background:#f9fafb;
  color:#475467;
  font-weight:800;
  text-align:right;
  padding:12px;
  border-bottom:1px solid var(--line);
  white-space:nowrap;
}

td{
  padding:12px;
  border-bottom:1px solid var(--line);
  vertical-align:middle;
}

tr:last-child td{
  border-bottom:0;
}

tr:hover td{
  background:#f9fafb;
}

input,select,textarea{
  width:100%;
  background:#fff;
  color:#111827;
  border:1px solid #d0d5dd;
  border-radius:10px;
  padding:10px 12px;
  outline:none;
  font-family:inherit;
}

input:focus,select:focus,textarea:focus{
  border-color:var(--brand);
  box-shadow:0 0 0 3px rgba(37,99,235,.12);
}

label{
  display:block;
  color:#344054;
  margin:10px 0 6px;
  font-weight:700;
}

button,.btn,input[type=submit]{
  border:0;
  border-radius:10px;
  padding:9px 14px;
  color:#fff;
  background:var(--brand);
  font-family:inherit;
  font-weight:800;
  cursor:pointer;
}

button:hover,.btn:hover,input[type=submit]:hover{
  background:var(--brand-dark);
  text-decoration:none;
}

button.secondary,.btn.secondary{
  background:#f2f4f7;
  color:#344054;
  border:1px solid var(--line);
}

.badge,.pill,.tag{
  display:inline-flex;
  align-items:center;
  padding:5px 9px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
  background:#f2f4f7;
  color:#344054;
}

.badge.good,.true{
  background:#ecfdf3;
  color:#027a48;
}

.badge.bad,.false{
  background:#fef3f2;
  color:#b42318;
}

.badge.warn{
  background:#fffaeb;
  color:#b54708;
}

.error,.alert{
  padding:11px 12px;
  border-radius:10px;
  background:#fef3f2;
  color:#b42318;
  border:1px solid #fecdca;
  margin:12px 0;
}

pre,code{
  direction:ltr;
  text-align:left;
  background:#111827;
  color:#e5e7eb;
  border-radius:10px;
}

pre{
  padding:14px;
  overflow:auto;
}

/* Login stays modern/dark */
body.login-screen{
  background:
    radial-gradient(circle at 20% 15%, rgba(124,58,237,.35), transparent 32%),
    radial-gradient(circle at 80% 10%, rgba(6,182,212,.24), transparent 30%),
    linear-gradient(135deg,#0b1020,#111936);
  color:#eef3ff;
}

.login-page{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
}

.login-card{
  width:min(430px,100%);
  padding:30px;
  border-radius:24px;
  background:rgba(255,255,255,.09);
  border:1px solid rgba(255,255,255,.14);
  box-shadow:0 24px 70px rgba(0,0,0,.35);
  backdrop-filter:blur(22px);
}

.login-card h1{
  font-size:28px;
  margin-bottom:10px;
}

.login-card p{
  color:#a9b6d3;
}

.login-card label{
  color:#dbeafe;
}

.login-card input{
  background:rgba(255,255,255,.09);
  color:#fff;
  border:1px solid rgba(255,255,255,.16);
}

.login-card button{
  width:100%;
  margin-top:16px;
  padding:14px 16px;
  background:linear-gradient(135deg,#7c3aed,#06b6d4);
}

@media(max-width:760px){
  nav:before{
    width:100%;
    margin:0 0 6px;
  }

  nav a{
    flex:1 1 auto;
    text-align:center;
  }

  main,.container{
    width:calc(100% - 18px);
    margin:14px auto;
  }

  table{
    display:block;
    overflow-x:auto;
    white-space:nowrap;
  }
}

/* Clear status badges */
.status-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:76px;
  padding:5px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
  line-height:1.4;
  border:1px solid transparent;
  white-space:nowrap;
}

.status-badge.is-on{
  color:#027a48;
  background:#ecfdf3;
  border-color:#abefc6;
}

.status-badge.is-off{
  color:#b42318;
  background:#fef3f2;
  border-color:#fecdca;
}

.status-badge.is-warn{
  color:#b54708;
  background:#fffaeb;
  border-color:#fedf89;
}

tr.row-human-required td{
  background:#fff7ed !important;
}

tr.row-followup-needed td{
  background:#fffbeb !important;
}

/* Dashboard simple chart */
.dashboard-chart-card{
  background:#fff;
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:18px;
  margin:16px 0;
  box-shadow:0 1px 3px rgba(16,24,40,.06);
}

.dashboard-chart-card h2{
  margin:0 0 6px;
  font-size:18px;
}

.dashboard-chart-card p{
  margin:0 0 16px;
  color:var(--muted);
}

.simple-chart{
  display:grid;
  gap:12px;
}

.simple-chart-row{
  display:grid;
  grid-template-columns:150px 1fr 64px;
  gap:10px;
  align-items:center;
}

.simple-chart-label{
  color:#344054;
  font-weight:700;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.simple-chart-track{
  height:12px;
  background:#eef2f7;
  border-radius:999px;
  overflow:hidden;
}

.simple-chart-fill{
  height:100%;
  width:0%;
  background:linear-gradient(90deg,#2563eb,#06b6d4);
  border-radius:999px;
  transition:width .5s ease;
}

.simple-chart-value{
  direction:ltr;
  text-align:left;
  color:#111827;
  font-weight:900;
}

@media(max-width:760px){
  .simple-chart-row{
    grid-template-columns:1fr;
    gap:6px;
  }

  .simple-chart-value{
    text-align:right;
  }
}

/* Fix old dot indicators: dot g / dot r / dot y */
.dot{
  display:inline-flex !important;
  align-items:center;
  justify-content:center;
  min-width:78px;
  height:auto;
  padding:5px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
  line-height:1.4;
  border:1px solid transparent;
  vertical-align:middle;
}

.dot.g{
  background:#ecfdf3 !important;
  color:#027a48 !important;
  border-color:#abefc6 !important;
}

.dot.g::after{
  content:"فعال";
}

.dot.r{
  background:#fef3f2 !important;
  color:#b42318 !important;
  border-color:#fecdca !important;
}

.dot.r::after{
  content:"غیرفعال";
}

.dot.y{
  background:#fffaeb !important;
  color:#b54708 !important;
  border-color:#fedf89 !important;
}

.dot.y::after{
  content:"نیازمند بررسی";
}

/* If dot is inside human/followup columns, make red/green still readable */
td .dot{
  margin:0 auto;
}

/* Dashboard stat cards: separate number from label */
.stats{
  grid-template-columns:repeat(auto-fit,minmax(210px,1fr));
}

.stats > *,
.dashboard-stat-card{
  position:relative;
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height:118px;
  justify-content:space-between;
  overflow:hidden;
}

.stats > *::before{
  content:"";
  position:absolute;
  top:0;
  right:0;
  width:5px;
  height:100%;
  background:#2563eb;
  opacity:.85;
}

.stat-number-box{
  direction:ltr;
  align-self:flex-start;
  min-width:92px;
  padding:9px 13px;
  border-radius:14px;
  background:#eff6ff;
  color:#1d4ed8;
  border:1px solid #bfdbfe;
  font-size:24px;
  font-weight:900;
  line-height:1.2;
  text-align:center;
  letter-spacing:-.4px;
}

.stat-label-text{
  display:block;
  color:#475467;
  font-size:14px;
  font-weight:800;
  line-height:1.7;
  padding-right:4px;
}

.stat-number-box.is-danger{
  background:#fef3f2;
  color:#b42318;
  border-color:#fecdca;
}

.stat-number-box.is-warning{
  background:#fffaeb;
  color:#b54708;
  border-color:#fedf89;
}

.stat-number-box.is-money{
  background:#ecfdf3;
  color:#027a48;
  border-color:#abefc6;
}

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

  .stat-number-box{
    min-width:74px;
    font-size:20px;
    padding:8px 10px;
  }

  .stat-label-text{
    font-size:13px;
  }
}

/* Dashboard top cards exact fix: .grid .card .num */
.grid > .card:has(.num){
  display:flex !important;
  flex-direction:column !important;
  align-items:flex-start !important;
  justify-content:space-between !important;
  gap:12px !important;
  min-height:118px !important;
  padding:18px !important;
  border-radius:16px !important;
  background:#fff !important;
  border:1px solid #e4e7ec !important;
  box-shadow:0 1px 3px rgba(16,24,40,.06) !important;
}

.grid > .card:has(.num)::before{
  content:"" !important;
  position:absolute !important;
  top:0 !important;
  right:0 !important;
  width:5px !important;
  height:100% !important;
  background:#2563eb !important;
  border-radius:0 16px 16px 0 !important;
}

.grid > .card:has(.num){
  position:relative !important;
  overflow:hidden !important;
}

.grid > .card:has(.num) .num{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  direction:ltr !important;
  min-width:92px !important;
  padding:9px 14px !important;
  border-radius:14px !important;
  background:#eff6ff !important;
  color:#1d4ed8 !important;
  border:1px solid #bfdbfe !important;
  font-size:24px !important;
  font-weight:900 !important;
  line-height:1.2 !important;
  letter-spacing:-.3px !important;
  box-shadow:0 1px 2px rgba(16,24,40,.04) !important;
}

.grid > .card:has(.num) span:not(.num){
  display:block !important;
  color:#475467 !important;
  font-size:14px !important;
  font-weight:800 !important;
  line-height:1.7 !important;
}

.grid > .card.warn:has(.num)::before{
  background:#f59e0b !important;
}

.grid > .card.warn:has(.num) .num{
  background:#fffaeb !important;
  color:#b54708 !important;
  border-color:#fedf89 !important;
}

.grid > .card.err:has(.num)::before{
  background:#ef4444 !important;
}

.grid > .card.err:has(.num) .num{
  background:#fef3f2 !important;
  color:#b42318 !important;
  border-color:#fecdca !important;
}

@media(max-width:760px){
  .grid > .card:has(.num){
    min-height:100px !important;
    padding:14px !important;
  }

  .grid > .card:has(.num) .num{
    min-width:74px !important;
    font-size:20px !important;
    padding:8px 11px !important;
  }
}
