/* ============================================================
   پنل نیمکس — سیستم دیزاین

   ساختار فایل:
     ۱. توکن‌ها (رنگ/فاصله/شعاع/سایه)
     ۲. پایه (body، ریست)
     ۳. سایدبار و ناوبری (+ نسخه‌ی موبایل: کشویی با همبرگر)
     ۴. دکمه‌ها
     ۵. کارت‌ها، کاشی‌های آمار، پیل‌ها
     ۶. فرم‌ها
     ۷. جدول‌ها و برچسب وضعیت
     ۸. کامپوننت‌های اختصاصی صفحه (پیش‌نمایش دایرکت، نمودار، صندوق پیام،
        انتخاب پست، صفحه‌بندی، لاگین، فرم قانون با پیش‌نمایش ثابت، CRM)
     ۹. کلاس‌های کمکی عمومی (utility)

   هر بخش، ریسپانسیوشو هم کنار خودش داره -- نه تو یه انبوه media query
   جدا در آخر فایل. رنگ‌هایی که بیش از یه‌جا تکرار می‌شدن به توکن تبدیل شدن.
   ============================================================ */

/* ---------- ۱. توکن‌ها ---------- */
:root {
  /* برند */
  --side: #1b2a4e; --side-soft: #24365c; --side-border: rgba(255,255,255,.10);
  --navy: #1b2a4e; --navy-deep: #141f3a; --navy-soft: #24365c;
  --gold: #ddaa42; --gold-hover: #e6ba5c;
  --gold-bg: #fbf3e3; --gold-bg-strong: #f2dfb8; --gold-text: #a57614;

  /* خنثی */
  --bg: #f4f5f8; --card: #ffffff; --surface2: #f1f3f7;
  --stroke: #e3e7ee; --stroke-strong: #d3d9e4;
  --text: #16213d; --muted: #667089; --faint: #98a1b6;
  --slate-bg: #f1f3f7;

  /* وضعیت -- برای پیل‌ها، تگ لاگ، و مراحل CRM */
  --green: #1f8454; --green-bg: #e4f4eb;
  --red: #cf4039; --red-bg: #fceae9;
  --blue: #2f66d0; --blue-bg: #e8eefb;
  --amber: #c45f22; --amber-bg: #fbeee4;

  /* مراحل مشتری (CRM) -- هر مرحله رنگ مخصوص خودش */
  --st-new: #2f66d0; --st-new-bg: #e8eefb;
  --st-price: #a57614; --st-price-bg: #fbf3e3;
  --st-follow: #7152c2; --st-follow-bg: #efeafa;
  --st-nego: #c45f22; --st-nego-bg: #fbeee4;
  --st-won: #1f8454; --st-won-bg: #e4f4eb;
  --st-lost: #7a8398; --st-lost-bg: #eef0f3;

  /* فاصله‌گذاری */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 22px; --space-6: 32px;

  /* شکل -- طراحی جدید مسطح‌تره: بوردر جای سایه‌ی سنگین رو می‌گیره */
  --radius: 14px; --radius-lg: 20px; --radius-full: 999px;
  --shadow: 0 1px 2px rgba(22,33,61,.05);
  --shadow-lg: 0 10px 28px rgba(22,33,61,.12);

  --sidebar-w: 248px;
}

/* ---------- ۲. پایه ---------- */
* { box-sizing: border-box; }

html { overflow-x: clip; }
body { overflow-x: clip; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Vazirmatn', Tahoma, sans-serif; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.container { max-width: 1360px; margin: 0 auto; padding: 30px 24px 90px; animation: rise .45s ease both; }
.container.narrow { max-width: 900px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .container { animation: none; } }

@media (max-width: 640px) {
  .container { padding: 18px 14px 70px; }
}

/* ---------- ۳. سایدبار و ناوبری ---------- */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 auto; position: sticky; top: 0; height: 100vh;
  background: var(--side); color: #fff; display: flex; flex-direction: column;
  padding: 18px 14px; gap: 5px; z-index: 60; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; flex-shrink: 0; }
.sidebar-brand img { height: 32px; width: 32px; object-fit: contain; flex-shrink: 0; }
.sidebar-brand .name { font-size: 17px; font-weight: 800; line-height: 1.25; }
.sidebar-brand .tagline { font-size: 11px; color: rgba(255,255,255,.6); }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px;
  border-radius: 10px; color: rgba(255,255,255,.74); text-decoration: none;
  font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s ease, color .15s ease;
  position: relative;
}
.sidebar-nav a:hover { background: var(--side-soft); color: #fff; }
.sidebar-nav a.active { background: var(--gold); color: var(--navy); font-weight: 700; }
.sidebar-nav a svg { width: 19px; height: 19px; flex-shrink: 0; opacity: .85; }
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-nav a .label { flex: 1; text-align: right; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav a .count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full);
  background: var(--gold); color: var(--navy); font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-nav a.active .count { background: rgba(27,42,78,.16); color: var(--navy); }

.sidebar-spacer { flex: 1 1 auto; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px;
  border-top: 1px solid var(--side-border); margin-top: 8px; flex-shrink: 0;
}
.sidebar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(221,170,66,.18); color: var(--gold-hover);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who .name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who .role { font-size: 11px; color: rgba(255,255,255,.55); }
.sidebar-user form { flex-shrink: 0; }
.sidebar-user button {
  width: 32px; height: 32px; border-radius: 8px; background: transparent; border: none;
  color: rgba(255,255,255,.7); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.sidebar-user button:hover { background: rgba(207,64,57,.22); color: #ffcbc2; }
.sidebar-user button svg { width: 17px; height: 17px; }

.main-col { flex: 1 1 0; min-width: 0; }

/* نوار بالای موبایل: فقط زیر ۷۶۸px دیده می‌شه */
.mobile-topbar {
  display: none; position: sticky; top: 0; z-index: 40; align-items: center; gap: 12px;
  height: 56px; padding: 0 14px; background: var(--side); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.mobile-topbar .hamburger {
  width: 36px; height: 36px; border-radius: 9px; border: none; background: rgba(255,255,255,.08);
  color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.mobile-topbar .hamburger svg { width: 20px; height: 20px; }
.mobile-topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; }
.mobile-topbar .brand img { height: 24px; width: 24px; }

.nav-overlay { display: none; }

@media (max-width: 767px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed; inset-inline-start: 0; top: 0; height: 100vh; width: min(84vw, 300px);
    transform: translateX(100%); transition: transform .22s ease; box-shadow: -8px 0 30px rgba(0,0,0,.25);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-overlay {
    display: block; position: fixed; inset: 0; background: rgba(10,16,32,.5); z-index: 55;
  }
  body.nav-open { overflow: hidden; }
}

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head--section { margin-top: 30px; margin-bottom: 14px; }
.page-head h1 { font-size: 24px; font-weight: 800; margin: 0 0 3px; letter-spacing: -.01em; }
.page-head .subtitle { color: var(--muted); font-size: 14px; margin: 0; }
@media (max-width: 640px) {
  .page-head h1 { font-size: 19px; }
}

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 13.5px; margin-bottom: 14px; white-space: nowrap; }
.back-link:hover { color: var(--navy); }
.back-link svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ---------- ۴. دکمه‌ها ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: 14px; font-weight: 600; white-space: nowrap;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: all .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-soft); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: var(--gold-hover); }
.btn-ghost { background: var(--card); border-color: var(--stroke-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--navy); }
.btn-on { background: var(--green-bg); color: var(--green); }
.btn-off { background: var(--slate-bg); color: var(--faint); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }

/* دکمه‌ی روشن/خاموش قانون‌ها -- به‌شکل سوییچ، نه آیکون */
.btn-icon.btn-on, .btn-icon.btn-off {
  width: 42px; height: 24px; border-radius: var(--radius-full); position: relative; border: none;
}
.btn-icon.btn-on { background: var(--green); }
.btn-icon.btn-off { background: var(--stroke-strong); }
.btn-icon.btn-on svg, .btn-icon.btn-off svg { display: none; }
.btn-icon.btn-on::after, .btn-icon.btn-off::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: inset-inline-start .15s ease;
}
.btn-icon.btn-on::after { inset-inline-start: 21px; }

/* ---------- ۵. کارت‌ها، کاشی‌های آمار، پیل‌ها ---------- */
.card, .tile, .rule-card { transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 22px; }
.tile { background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tile:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.tile .num { font-size: 26px; font-weight: 800; display: block; line-height: 1.25; }
.tile .label { font-size: 12.5px; color: var(--muted); display: block; }
.tile.gold .num { color: var(--gold-text); }
.tile.green .num { color: var(--green); }
@media (max-width: 640px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 9px; }
  .tile { padding: 13px 14px; }
  .tile .num { font-size: 21px; }
}
@media (min-width: 1200px) {
  .tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
  .tile { padding: 20px 22px; }
  .tile .num { font-size: 30px; }
  .tile .label { font-size: 13px; }
}

.card { background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 16px; font-weight: 700; }
.section-title { font-size: 16px; font-weight: 700; margin: 0 0 16px; color: var(--text); }
@media (max-width: 640px) {
  .card { padding: 16px 14px; }
}
@media (min-width: 1200px) {
  .card { padding: 28px; }
}

.rule-card {
  background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 15px 18px; margin-bottom: 10px; box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
}
.rule-card:hover { box-shadow: var(--shadow-lg); border-color: var(--stroke-strong); }
.rule-card.is-off { opacity: .62; }
.rule-info { display: flex; align-items: center; gap: 13px; min-width: 0; flex: 1; }
.rule-body { min-width: 0; flex: 1; }
.thumb { width: 50px; height: 50px; border-radius: 9px; object-fit: cover; border: 1px solid var(--stroke); flex-shrink: 0; background: var(--slate-bg); }
.thumb.all { display: flex; align-items: center; justify-content: center; color: var(--gold-text); background: var(--gold-bg); font-size: 19px; font-weight: 700; }
.pill { display: inline-block; background: var(--green-bg); color: var(--green); font-size: 12.5px; font-weight: 700; padding: 2px 10px; border-radius: var(--radius-full); margin-bottom: 4px; }
.pill.pill-muted { background: var(--slate-bg); color: var(--muted); }
.rule-card.is-off .pill { background: var(--slate-bg); color: var(--faint); }
.line-1 { color: var(--muted); font-size: 13.5px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-2 { color: var(--faint); font-size: 12.5px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
@media (max-width: 640px) {
  .rule-card { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 12px; }
  .rule-actions { justify-content: flex-end; }
}

.search-box { position: relative; margin-bottom: 16px; }
.search-box svg { position: absolute; top: 50%; right: 13px; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.search-box input { width: 100%; background: var(--card); border: 1px solid var(--stroke); border-radius: 10px; padding: 11px 40px 11px 14px; font-family: inherit; font-size: 14px; color: var(--text); }
.search-box input:focus { outline: none; border-color: var(--navy); }

.empty { text-align: center; padding: 54px 24px; background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.empty .badge { width: 48px; height: 48px; border-radius: 12px; background: var(--gold-bg); color: var(--gold-text); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.empty .badge svg { width: 22px; height: 22px; }
.empty h2 { font-size: 17px; margin: 0 0 6px; }
.empty p { color: var(--muted); font-size: 14px; margin: 0 auto 18px; max-width: 340px; }

/* ---------- ۶. فرم‌ها ---------- */
.field { text-align: right; margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field textarea, .field select, .login-card input {
  width: 100%; background: #fafbfd; border: 1px solid var(--stroke-strong); border-radius: 9px;
  padding: 10px 12px; color: var(--text); font-family: inherit; font-size: 14px; transition: border-color .15s ease;
}
.field input:focus, .field textarea:focus, .field select:focus, .login-card input:focus { outline: none; border-color: var(--navy); background: #fff; }
.field textarea { resize: vertical; min-height: 90px; line-height: 1.8; }
.field-hint { color: var(--faint); font-size: 12px; margin: 6px 2px 0; }
.error-box { background: var(--red-bg); color: var(--red); border-radius: 9px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.error-box.success { background: var(--green-bg); color: var(--green); }

.section-label { font-size: 13.5px; font-weight: 700; margin: 22px 0 10px; }
.section-label:first-of-type { margin-top: 0; }

.form-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 900px) {
  .form-layout { grid-template-columns: .85fr 1.15fr; gap: 20px; }
}

.all-option { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 2px solid var(--stroke); border-radius: 10px; cursor: pointer; margin-bottom: 14px; transition: all .15s ease; }
.all-option input { accent-color: var(--gold); width: 16px; height: 16px; flex-shrink: 0; }
.all-option:has(input:checked) { border-color: var(--gold); background: var(--gold-bg); }

.or-divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12.5px; margin: 18px 0; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--stroke); }

.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 9px; }
.post-cell { position: relative; cursor: pointer; }
.post-cell input { position: absolute; opacity: 0; width: 0; height: 0; }
.post-cell .thumb-box { aspect-ratio: 1; border-radius: 9px; overflow: hidden; border: 2px solid var(--stroke); transition: all .15s ease; }
.post-cell:hover .thumb-box { border-color: var(--stroke-strong); transform: scale(1.03); }
.post-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-cell input:checked + .thumb-box { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(221,170,66,.28); }
.post-cell .check { position: absolute; top: 5px; left: 5px; width: 19px; height: 19px; border-radius: 50%; background: var(--gold); display: none; align-items: center; justify-content: center; }
.post-cell input:checked ~ .check { display: flex; }
.post-cell .check svg { width: 11px; height: 11px; color: var(--navy); }
@media (min-width: 900px) {
  .post-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}
@media (max-width: 640px) {
  .post-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 7px; }
}

.pagination { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.page-btn { min-width: 32px; height: 32px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--stroke-strong); background: var(--card); color: var(--muted); font-family: inherit; font-size: 13px; cursor: pointer; }
.page-btn:hover { border-color: var(--navy); color: var(--text); }
.page-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.sort-links { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; justify-content: center; }
.sort-links a { font-size: 13px; padding: 7px 13px; border-radius: 8px; text-decoration: none; color: var(--muted); border: 1px solid var(--stroke); background: var(--card); white-space: nowrap; }
.sort-links a:hover { border-color: var(--navy); color: var(--text); }
.sort-links a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- ۷. جدول‌ها و برچسب وضعیت ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* لیست مشتریان (CRM) -- زیر ۶۰۰px به‌جای جدول فشرده، کارت نشون بده */
.crm-cards { display: none; }
@media (max-width: 599px) {
  .table-card { display: none; }
  .crm-cards { display: flex; flex-direction: column; gap: 10px; }
}
.crm-card {
  display: block; background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.crm-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.crm-card-meta { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.log-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 620px; }
.log-table th { text-align: right; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 9px 10px; border-bottom: 1px solid var(--stroke); white-space: nowrap; }
.log-table td { padding: 11px 10px; border-bottom: 1px solid var(--stroke); }
.log-table tr:last-child td { border-bottom: none; }
.log-table tbody tr { transition: background .12s ease; }
.log-table tbody tr:hover { background: var(--surface2); }
.log-table .muted-cell { color: var(--muted); }
.log-table .nowrap { white-space: nowrap; }
.tag-ok { color: var(--green); font-weight: 600; }
.tag-fail { color: var(--red); font-weight: 600; }
.tag-skip { color: var(--faint); }

/* برچسب مرحله‌ی مشتری تو CRM -- همون منطق .pill، با رنگ‌های وضعیتی بیشتر.
   عمداً اسمش .badge نیست: با .empty .badge (دایره‌ی آیکون حالت خالی) تداخل می‌کرد. */
.stage-badge { display: inline-block; font-size: 12.5px; font-weight: 700; padding: 3px 11px; border-radius: var(--radius-full); white-space: nowrap; }
.stage-badge--new_lead { background: var(--st-new-bg); color: var(--st-new); }
.stage-badge--price_inquiry { background: var(--st-price-bg); color: var(--st-price); }
.stage-badge--followed_up { background: var(--st-follow-bg); color: var(--st-follow); }
.stage-badge--negotiating { background: var(--st-nego-bg); color: var(--st-nego); }
.stage-badge--converted { background: var(--st-won-bg); color: var(--st-won); }
.stage-badge--lost { background: var(--st-lost-bg); color: var(--st-lost); }

/* یادداشت‌ها و تاریخچه‌ی مراحل (CRM) */
.note-list { display: flex; flex-direction: column; }
.note-item { padding: 12px 0; border-bottom: 1px solid var(--stroke); font-size: 13.5px; }
.note-item:last-child { border-bottom: none; padding-bottom: 0; }
.note-item:first-child { padding-top: 0; }
.note-item p { margin: 0 0 4px; white-space: pre-wrap; }

/* ---------- ۸. کامپوننت‌های اختصاصی صفحه ---------- */

/* پیش‌نمایش دایرکت (فرم قانون‌ها) */
.dm-preview { background: #fafbfd; border: 1px solid var(--stroke); border-radius: 12px; padding: 16px; }
.dm-preview .head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.dm-preview .head svg { width: 15px; height: 15px; }
.bubble { background: var(--navy); color: #fff; border-radius: 16px 16px 4px 16px; padding: 11px 15px; font-size: 13.5px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; max-width: 100%; }
.bubble.placeholder { background: var(--slate-bg); color: var(--faint); }
.char-count { font-size: 11.5px; color: var(--faint); margin-top: 8px; text-align: left; }

/* فرم قانون با پیش‌نمایش ثابت -- کارت اول تو دسکتاپ می‌چسبه بالا */
@media (min-width: 900px) {
  .form-layout > .card:first-child { position: sticky; top: 20px; }
}

/* نمودار فالوئر جدید (آمار) */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 140px; padding-top: 8px; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.chart .bar { width: 100%; background: var(--navy); border-radius: 5px 5px 0 0; min-height: 3px; transition: background .15s ease; }
.chart .bar-wrap:hover .bar { background: var(--gold); }
.chart .bar-val { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.chart-dates { display: flex; gap: 5px; margin-top: 6px; }
.chart-dates span { flex: 1; text-align: center; font-size: 10.5px; color: var(--faint); }

/* ردیف آمار پروفایل بالای صفحه‌ی آمار */
.profile-strip { display: flex; align-items: center; gap: 16px; background: var(--navy); color: #fff; border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px; flex-wrap: wrap; }
.profile-strip .handle { font-size: 17px; font-weight: 800; }
.profile-strip .divider { width: 1px; height: 30px; background: rgba(255,255,255,.18); }
.profile-strip .item { display: flex; flex-direction: column; }
.profile-strip .item b { font-size: 19px; font-weight: 800; color: var(--gold); line-height: 1.3; }
.profile-strip .item span { font-size: 12px; color: #a8b4cc; }

/* آمار تک‌تک پست‌ها (آمار) */
.post-stat { display: flex; gap: 14px; align-items: flex-start; padding: 16px 0; border-bottom: 1px solid var(--stroke); }
.post-stat:first-child { padding-top: 0; }
.post-stat:last-child { border-bottom: none; padding-bottom: 0; }
.post-stat a { display: block; flex-shrink: 0; }
.post-stat .thumb { width: 62px; height: 62px; transition: border-color .15s ease; }
.post-stat a:hover .thumb { border-color: var(--gold); }
.post-stat-body { flex: 1; min-width: 0; }
.post-stat-caption { font-size: 13.5px; margin: 0 0 9px; font-weight: 600; }
.metric-row { display: flex; flex-wrap: wrap; gap: 7px; }
.metric { background: var(--surface2); border: 1px solid var(--stroke); border-radius: 8px; padding: 5px 11px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.metric b { color: var(--text); font-weight: 700; }
.metric.hl { background: var(--gold-bg); border-color: var(--gold-bg-strong); }
.metric.hl b { color: var(--gold-text); }
@media (min-width: 1200px) {
  .post-stat .thumb { width: 74px; height: 74px; }
  .post-stat-caption { font-size: 14.5px; }
  .metric { font-size: 13px; }
}
@media (max-width: 640px) {
  .post-stat .thumb { width: 50px; height: 50px; }
}

/* صندوق پیام‌ها -- تو موبایل بین لیست مکالمه‌ها و پنجره‌ی چت سوییچ می‌کنه */
.inbox-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .inbox-layout { grid-template-columns: 1fr 1.6fr; } }

.conv-list { display: flex; flex-direction: column; gap: 4px; max-height: 640px; overflow-y: auto; }
.conv-item { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--text); border: 1px solid transparent; }
.conv-item:hover { background: var(--surface2); }
.conv-item.active { background: var(--gold-bg); border-color: var(--gold-bg-strong); }
.conv-item .uname { font-weight: 700; font-size: 13.5px; }
.conv-item .time { font-size: 11.5px; color: var(--faint); }

.thread { display: flex; flex-direction: column; gap: 10px; max-height: 640px; overflow-y: auto; padding: 4px; }
.msg-row { display: flex; }
.msg-row.out { justify-content: flex-start; }
.msg-row.in { justify-content: flex-end; }
.msg-bubble { max-width: 70%; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.msg-row.out .msg-bubble { background: var(--navy); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg-row.in .msg-bubble { background: var(--slate-bg); color: var(--text); border-radius: 16px 16px 16px 4px; }
.msg-time { font-size: 10.5px; color: var(--faint); margin-top: 4px; text-align: center; }

.reply-box { display: flex; gap: 8px; align-items: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--stroke); }
.reply-box textarea { flex: 1; background: #fafbfd; border: 1px solid var(--stroke-strong); border-radius: 10px; padding: 9px 12px; font-family: inherit; font-size: 13.5px; resize: none; }
.reply-box textarea:focus { outline: none; border-color: var(--navy); }
.reply-box .btn { flex-shrink: 0; }

.thread-back { display: none; }
@media (max-width: 899px) {
  /* موبایل: وقتی مکالمه‌ای انتخاب شده، فقط پنجره‌ی چت رو نشون بده؛ وگرنه فقط لیست */
  .inbox-layout.has-thread .conv-card { display: none; }
  .inbox-layout:not(.has-thread) .thread-card { display: none; }
  .thread-back { display: inline-flex; }
}

/* ورود */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--navy); }
.login-card { background: var(--card); border-radius: var(--radius-lg); padding: 30px 32px 32px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-card img.login-logo { width: 128px; height: 128px; object-fit: contain; margin: -14px auto -8px; display: block; }
.login-card h1 { font-size: 19px; margin: 0 0 5px; }
.login-card p.subtitle { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.login-card .field { text-align: right; }
.password-field { position: relative; }
.password-field input { padding-left: 40px; }
.password-toggle {
  position: absolute; top: 50%; left: 8px; transform: translateY(-50%); width: 28px; height: 28px;
  border: none; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.password-toggle svg { width: 17px; height: 17px; }

/* ---------- CRM: کارت انتخاب مرحله به‌شکل دکمه‌های کنار هم ---------- */
.stage-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.stage-picker form { margin: 0; }
.stage-picker button {
  font-family: inherit; font-size: 13px; font-weight: 700; padding: 8px 14px; border-radius: var(--radius-full);
  border: 1.5px solid var(--stroke); background: var(--card); color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: all .15s ease;
}
.stage-picker button:hover { border-color: var(--stroke-strong); color: var(--text); }
.stage-picker button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stage-picker button.is-current { cursor: default; }
.stage-picker button.is-current--new_lead { background: var(--st-new-bg); border-color: var(--st-new-bg); color: var(--st-new); }
.stage-picker button.is-current--price_inquiry { background: var(--st-price-bg); border-color: var(--st-price-bg); color: var(--st-price); }
.stage-picker button.is-current--followed_up { background: var(--st-follow-bg); border-color: var(--st-follow-bg); color: var(--st-follow); }
.stage-picker button.is-current--negotiating { background: var(--st-nego-bg); border-color: var(--st-nego-bg); color: var(--st-nego); }
.stage-picker button.is-current--converted { background: var(--st-won-bg); border-color: var(--st-won-bg); color: var(--st-won); }
.stage-picker button.is-current--lost { background: var(--st-lost-bg); border-color: var(--st-lost-bg); color: var(--st-lost); }

/* ---------- ۹. کلاس‌های کمکی ---------- */
.card--flush { margin: 0; }
.card--flush-col { margin: 0; display: flex; flex-direction: column; }
.card--narrow { max-width: 640px; }
.hidden { display: none; }
.mt-lg { margin-top: var(--space-5); }
.mb-lg { margin-bottom: var(--space-4); }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.empty-note { color: var(--muted); text-align: center; padding: 30px 0; }
.row-link { color: var(--text); text-decoration: none; font-weight: 600; }
.row-link:hover { color: var(--navy); text-decoration: underline; }
