/* =====================================================================
 * سامانه مدیریت تماس و پیگیری فروش — سازه پوشش ماموت
 * طراحی راست‌چین، صنعتی و موبایل‌محور
 * =================================================================== */

:root {
  --navy-900: #0b1220;
  --navy-800: #111c30;
  --navy-700: #1a2942;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f1f5f9;
  --card: #ffffff;
  --primary: #1d4ed8;
  --primary-600: #1e40af;
  --primary-soft: #eff6ff;
  --ok: #15803d;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #0369a1;
  --info-soft: #f0f9ff;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 24px 60px -24px rgba(15, 23, 42, .35);
  --sidebar-w: 268px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Vazirmatn', 'IRANSansX', 'IRANSans', 'Segoe UI', Tahoma, 'Noto Naskh Arabic', sans-serif;
  font-size: 15px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.5; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .5rem; }
ul, ol { margin: 0; padding-inline-start: 1.2rem; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }

.mono { font-family: 'Consolas', 'Courier New', monospace; direction: ltr; unicode-bidi: embed; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.truncate { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- بارگذاری */
.boot-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem; color: var(--muted);
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%; display: inline-block;
  border: 2.5px solid var(--line-2); border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}
.spinner--lg { width: 34px; height: 34px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading {
  display: flex; align-items: center; gap: .6rem; justify-content: center;
  padding: 3rem 1rem; color: var(--muted);
}

/* ---------------------------------------------------------------- ورود */
.login {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 460px) 1fr;
}
.login__panel {
  background: var(--card); padding: clamp(1.5rem, 4vw, 3rem);
  display: flex; flex-direction: column; justify-content: center; gap: 1.5rem;
}
.login__side {
  background: linear-gradient(150deg, var(--navy-900), var(--navy-700) 65%, #1e3a8a);
  color: #e2e8f0; padding: clamp(1.5rem, 5vw, 4rem);
  display: flex; flex-direction: column; justify-content: center; gap: 1.5rem;
}
.login__side h2 { font-size: clamp(1.3rem, 3vw, 2rem); color: #fff; line-height: 1.6; }
.login__side ul { display: grid; gap: .8rem; padding-inline-start: 1.1rem; }
.login__side li { color: #cbd5e1; }
.login__error { color: var(--danger); min-height: 1.4rem; font-size: .9rem; }
.login__hint { font-size: .82rem; color: var(--muted); }
.login__hint code { background: var(--bg); padding: .1rem .4rem; border-radius: 5px; }

/* ---------------------------------------------------------------- برند */
.brand { display: flex; align-items: center; gap: .75rem; }
.brand__mark {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff; font-weight: 800; font-size: 1.3rem;
  display: grid; place-items: center;
}
.brand strong { display: block; font-size: .95rem; }
.brand span { display: block; font-size: .78rem; color: var(--muted); }
.brand--lg .brand__mark { width: 54px; height: 54px; font-size: 1.7rem; }
.brand--lg strong { font-size: 1.1rem; }

/* ---------------------------------------------------------------- پوسته */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
  color: #cbd5e1; padding: 1.1rem .9rem; display: flex; flex-direction: column; gap: 1.1rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand span { color: #94a3b8; }
.sidebar .brand strong { color: #fff; }
.nav { display: grid; gap: .18rem; }
.nav__item {
  display: flex; align-items: center; gap: .65rem; width: 100%;
  background: transparent; border: 0; color: #cbd5e1;
  padding: .62rem .7rem; border-radius: var(--radius-sm);
  text-align: start; font-size: .92rem; transition: background .15s, color .15s;
}
.nav__item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav__item.is-active { background: var(--primary); color: #fff; font-weight: 600; }
.nav__icon { width: 20px; text-align: center; opacity: .9; }
.nav__badge { margin-inline-start: auto; font-size: .72rem; display: none; }
.nav__badge.is-on {
  display: inline-block; background: #dc2626; color: #fff;
  border-radius: 999px; padding: 0 .42rem; min-width: 1.3rem; text-align: center;
}
.sidebar__foot { margin-top: auto; display: grid; gap: .35rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.1); }
.who strong { display: block; color: #fff; font-size: .9rem; }
.who span { display: block; color: #94a3b8; font-size: .78rem; }
.sidebar__foot .link { color: #93c5fd; text-align: start; padding: .1rem 0; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem clamp(.8rem, 2vw, 1.6rem);
}
.topbar__title { font-weight: 700; font-size: .95rem; }
.topbar__right { margin-inline-start: auto; display: flex; align-items: center; gap: .5rem; }

.icon-btn {
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  width: 38px; height: 38px; display: grid; place-items: center; position: relative;
  font-size: 1.05rem;
}
.icon-btn:hover { background: var(--bg); }
.notif-dot {
  position: absolute; top: 2px; inset-inline-start: 2px; display: none;
  background: #dc2626; color: #fff; font-size: .66rem; border-radius: 999px;
  min-width: 1.15rem; height: 1.15rem; line-height: 1.15rem; text-align: center; padding: 0 .2rem;
}
.notif-dot.is-on { display: block; }

.offline-flag {
  display: none; background: var(--warn-soft); color: var(--warn);
  border: 1px solid #fcd34d; border-radius: 999px; padding: .1rem .6rem; font-size: .78rem;
}
.offline-flag.is-on { display: inline-block; }

.view { padding: clamp(.9rem, 2vw, 1.6rem); max-width: 1500px; width: 100%; }

/* ---------------------------------------------------------------- سرصفحه */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem;
}
.page-head__date { color: var(--muted); font-size: .84rem; }
.page-head p { margin: .15rem 0 0; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- دکمه */
.btn {
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .5rem 1rem; font-weight: 600; font-size: .9rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--card); color: var(--ink); text-decoration: none;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -8px var(--primary); }
.btn--primary:hover:not(:disabled) { background: var(--primary-600); }
.btn--ghost { background: var(--card); border-color: var(--line-2); color: var(--ink-2); }
.btn--ghost:hover { background: var(--bg); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--lg { padding: .68rem 1.3rem; font-size: .96rem; }
.btn--sm { padding: .32rem .7rem; font-size: .82rem; }
.btn--block { width: 100%; }
.link {
  background: none; border: 0; color: var(--primary);
  font-size: .86rem; font-weight: 600; padding: 0;
}
.link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- کارت */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; margin-bottom: .8rem;
}
.card__head--sub { margin-top: 1.2rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.card--locked { border-color: #fecaca; background: linear-gradient(180deg, var(--danger-soft), #fff 40%); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; align-items: start; }

/* ---------------------------------------------------------------- KPI */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem; margin-bottom: 1.1rem;
}
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem .95rem; box-shadow: var(--shadow);
  border-top: 3px solid var(--line-2);
}
.kpi--ok { border-top-color: var(--ok); }
.kpi--warn { border-top-color: #f59e0b; }
.kpi--danger { border-top-color: var(--danger); }
.kpi--info { border-top-color: var(--info); }
.kpi__label { font-size: .82rem; color: var(--muted); }
.kpi__value { font-size: 1.85rem; font-weight: 800; line-height: 1.3; }
.kpi__hint { font-size: .78rem; color: var(--muted); }

/* ---------------------------------------------------------------- هشدار */
.alert-stack { display: grid; gap: .5rem; margin-bottom: 1.1rem; }
.alert {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  width: 100%; text-align: start; border-radius: var(--radius-sm);
  padding: .6rem .9rem; font-size: .9rem; font-weight: 600; border: 1px solid;
}
.alert--danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.alert--warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.alert--info { background: var(--info-soft); border-color: #bae6fd; color: var(--info); }
.alert__arrow { opacity: .6; }

/* ---------------------------------------------------------------- فهرست سرنخ */
.lead-list { display: grid; gap: .5rem; }
.lead-list--compact .lead-row { padding: .55rem .7rem; }
.lead-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .9rem;
  width: 100%; text-align: start; background: var(--card);
  border: 1px solid var(--line); border-inline-start: 3px solid var(--line-2);
  border-radius: var(--radius-sm); padding: .7rem .85rem; transition: box-shadow .15s, border-color .15s;
}
.lead-row:hover { box-shadow: var(--shadow); border-color: var(--line-2); }
.lead-row--danger { border-inline-start-color: var(--danger); }
.lead-row--warn { border-inline-start-color: #f59e0b; }
.lead-row__title { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.lead-row__sub { color: var(--ink-2); font-size: .86rem; }
.lead-row__tags { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .35rem; }
.lead-row__side { text-align: end; flex: none; }
.lead-row__owner { font-size: .84rem; font-weight: 600; }
.lead-row__next { font-size: .78rem; color: var(--muted); }
.result-count { color: var(--muted); font-size: .84rem; margin-bottom: .5rem; }

/* ---------------------------------------------------------------- نشان */
.badge {
  display: inline-block; font-size: .74rem; font-weight: 600; border-radius: 999px;
  padding: .1rem .55rem; background: color-mix(in srgb, var(--badge, #64748b) 12%, #fff);
  color: var(--badge, #475569); border: 1px solid color-mix(in srgb, var(--badge, #64748b) 30%, #fff);
}
.badge--ok { --badge: #15803d; }
.badge--warn { --badge: #b45309; }
.badge--danger { --badge: #b91c1c; }
.badge--info { --badge: #0369a1; }
.pill {
  display: inline-block; font-size: .74rem; font-weight: 600; border-radius: 6px;
  padding: .08rem .5rem; color: #fff; background: var(--pill, #64748b);
}
.tag {
  display: inline-block; font-size: .68rem; background: var(--bg);
  border: 1px solid var(--line); border-radius: 5px; padding: 0 .35rem;
  margin-inline-start: .3rem; color: var(--muted);
}
.tag--repeat { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.code { font-size: .74rem; color: var(--muted); font-family: monospace; direction: ltr; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }

/* ---------------------------------------------------------------- ابزار و فیلتر */
.toolbar, .section-bar {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .9rem;
}
.section-bar { justify-content: space-between; }
.toolbar .input { max-width: 320px; }
.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .5rem; margin-bottom: .6rem;
}
.filters .input:first-child { grid-column: 1 / -1; }
.quick-filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; }
.chip {
  background: var(--card); border: 1px solid var(--line-2); border-radius: 999px;
  padding: .22rem .8rem; font-size: .82rem; color: var(--ink-2);
}
.chip:hover { background: var(--bg); }
.chip--on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.chip--clear { color: var(--muted); }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .4rem; }

/* ---------------------------------------------------------------- فرم */
.form { display: grid; gap: .8rem; }
.form-note {
  background: var(--info-soft); border: 1px solid #bae6fd; color: var(--info);
  border-radius: var(--radius-sm); padding: .5rem .75rem; font-size: .84rem;
}
.field { display: grid; gap: .3rem; }
.field > label { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.field--required > label::after { content: ' *'; color: var(--danger); }
.field--inline { padding: .2rem 0; }
.grid-2-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; }

.input {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: .5rem .7rem; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.input:disabled { background: var(--bg); color: var(--muted); }
textarea.input { resize: vertical; min-height: 60px; }
input[type=color].input { padding: .15rem; height: 38px; }
.input--inline { width: auto; min-width: 170px; }
.input--phone { direction: ltr; text-align: end; font-family: monospace; font-size: 1.05rem; letter-spacing: .5px; }
.date-row { display: grid; grid-template-columns: 1fr 110px; gap: .4rem; }
.input--time { direction: ltr; text-align: center; }

.switch { display: flex; align-items: center; gap: .5rem; font-size: .88rem; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--primary); }

.form-actions {
  display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap;
  margin-top: .4rem; padding-top: .6rem; border-top: 1px solid var(--line);
}
.form-actions--sticky {
  position: sticky; bottom: -1px; background: var(--card);
  padding-bottom: .3rem; margin-bottom: -.3rem; z-index: 5;
}

/* انتخاب دسته */
.cat-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .45rem; }
.cat-option input { position: absolute; opacity: 0; pointer-events: none; }
.cat-option span {
  display: block; text-align: center; padding: .6rem .5rem; border-radius: var(--radius-sm);
  border: 2px solid var(--line); background: var(--card); font-size: .88rem;
  font-weight: 600; color: var(--ink-2); cursor: pointer; transition: all .15s;
}
.cat-option input:checked + span {
  border-color: var(--pill); background: color-mix(in srgb, var(--pill) 10%, #fff); color: var(--pill);
}

/* تشخیص تکراری */
.dup { border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .86rem; margin-top: .4rem; }
.dup--new { background: var(--ok-soft); border: 1px solid #a7f3d0; color: var(--ok); }
.dup--found { background: var(--warn-soft); border: 1px solid #fde68a; color: #78350f; }
.dup__title { font-weight: 700; margin-bottom: .2rem; }
.dup__leads { display: grid; gap: .25rem; margin-top: .5rem; padding-top: .5rem; border-top: 1px dashed #fcd34d; }
.dup__lead { display: flex; align-items: center; gap: .4rem; cursor: pointer; }

.custom-block {
  border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
  padding: .7rem .8rem; background: #fafbfd;
}
.custom-block__title { font-size: .82rem; font-weight: 700; color: var(--muted); margin-bottom: .5rem; }

/* ---------------------------------------------------------------- جدول */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  text-align: start; font-weight: 700; color: var(--muted); font-size: .8rem;
  padding: .6rem .7rem; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table--sm { font-size: .84rem; }
.row-click { cursor: pointer; }
.row-off { opacity: .55; }

/* ---------------------------------------------------------------- Kanban */
.kanban {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr);
  gap: .7rem; overflow-x: auto; padding-bottom: .6rem; align-items: start;
}
.kb-col { background: #eef2f7; border-radius: var(--radius); padding: .5rem; min-height: 180px; }
.kb-col.is-over { background: var(--primary-soft); outline: 2px dashed var(--primary); }
.kb-col__head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .84rem; font-weight: 700; padding: .2rem .35rem .5rem;
  border-bottom: 2px solid var(--col, #64748b); color: var(--col, #334155); margin-bottom: .5rem;
}
.kb-col__body { display: grid; gap: .4rem; }
.kb-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .55rem .65rem; cursor: grab; box-shadow: var(--shadow);
}
.kb-card.is-dragging { opacity: .4; }
.kb-card--overdue { border-inline-start: 3px solid var(--danger); }
.kb-card__title { font-weight: 700; font-size: .88rem; }
.kb-card__sub { font-size: .78rem; color: var(--muted); margin-bottom: .3rem; }
.kb-card__meta { display: flex; gap: .25rem; flex-wrap: wrap; }
.kb-card__foot {
  display: flex; justify-content: space-between; font-size: .74rem;
  color: var(--muted); margin-top: .35rem;
}
.kb-empty { text-align: center; color: var(--muted); font-size: .8rem; padding: .8rem 0; }

/* ---------------------------------------------------------------- جزئیات */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.page-head--detail h1 { margin-top: .2rem; }
.detail-tags { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; margin-top: .35rem; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .7rem; }
.kv-grid > div, .kv-list > div { display: grid; gap: .1rem; }
.kv-grid span, .kv-list span { font-size: .78rem; color: var(--muted); }
.kv-list { display: grid; gap: .55rem; }
.stage-actions {
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
  margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line);
}
.stage-actions label { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.phones { display: flex; gap: .35rem; flex-wrap: wrap; margin: .6rem 0; }
.phone-chip {
  background: var(--primary-soft); border: 1px solid #bfdbfe; color: var(--primary);
  border-radius: 999px; padding: .12rem .7rem; font-size: .85rem;
  font-family: monospace; direction: ltr; text-decoration: none;
}
.hist { display: grid; gap: .4rem; list-style: none; padding: 0; font-size: .84rem; }
.hist li { display: grid; gap: .05rem; padding-inline-start: .8rem; border-inline-start: 2px solid var(--line); }
.hist em { font-style: normal; color: var(--muted); font-size: .76rem; }

/* تایم‌لاین */
.timeline { display: grid; gap: .1rem; }
.tl-item { display: grid; grid-template-columns: 20px 1fr; gap: .5rem; }
.tl-dot { position: relative; }
.tl-dot::before {
  content: ''; position: absolute; top: .5rem; inset-inline-start: 6px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--primary); z-index: 1;
}
.tl-dot::after {
  content: ''; position: absolute; top: 1.1rem; bottom: -.4rem;
  inset-inline-start: 10px; width: 1px; background: var(--line);
}
.tl-item:last-child .tl-dot::after { display: none; }
.tl-body { padding-bottom: .9rem; }
.tl-head { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.tl-result { font-size: .86rem; color: var(--ink-2); }
.tl-note { font-size: .86rem; background: var(--bg); border-radius: 8px; padding: .35rem .6rem; margin: .25rem 0; }
.tl-next { font-size: .8rem; color: var(--info); }
.tl-actor { font-size: .76rem; color: var(--muted); }

/* ---------------------------------------------------------------- آمار */
.cat-stats { display: grid; gap: .7rem; }
.cat-stat { cursor: pointer; }
.cat-stat__top { display: flex; align-items: center; gap: .4rem; font-size: .88rem; }
.cat-stat__title { flex: 1; }
.cat-stat__meta { font-size: .76rem; color: var(--muted); }
.bar { height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; margin: .25rem 0; }
.bar span { display: block; height: 100%; border-radius: 999px; }
.stage-chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.stage-chip {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .3rem .7rem; font-size: .82rem; display: flex; gap: .4rem; align-items: center;
}
.stage-chip strong { color: var(--primary); }
.stage-chip:hover { background: var(--primary-soft); border-color: #bfdbfe; }

.funnel { display: grid; gap: .5rem; }
.funnel__row { display: grid; grid-template-columns: 170px 1fr 50px 50px; gap: .6rem; align-items: center; font-size: .86rem; }
.funnel__label { color: var(--ink-2); }
.funnel__bar { height: 22px; background: var(--bg); border-radius: 7px; overflow: hidden; }
.funnel__bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #3b82f6); }
.funnel__row em { font-style: normal; color: var(--muted); font-size: .78rem; }

.spark { display: flex; align-items: flex-end; gap: 2px; height: 110px; padding: .4rem 0; }
.spark__col { flex: 1; min-width: 3px; display: flex; align-items: flex-end; height: 100%; }
.spark__col span { display: block; width: 100%; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; }

.hbars { display: grid; gap: .45rem; }
.hbar { display: grid; grid-template-columns: 110px 1fr 34px; gap: .5rem; align-items: center; font-size: .82rem; }
.hbar__label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar__track { height: 14px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.hbar__track span { display: block; height: 100%; background: #64748b; border-radius: 5px; }

/* ---------------------------------------------------------------- تقویم */
.cal-day { margin-bottom: 1rem; }
.cal-day header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .4rem; }
.cal-day header span { font-size: .8rem; color: var(--muted); }
.cal-day--past header h3 { color: var(--danger); }
.cal-day--today header h3 { color: var(--primary); }

/* ---------------------------------------------------------------- تب */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: .5rem .8rem; font-size: .88rem; font-weight: 600; color: var(--muted);
}
.tab:hover { color: var(--ink); }
.tab--on { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------------------------------------------------------------- چک‌لیست فاز */
.progress { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-bottom: .9rem; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--ok), #22c55e); }
.checklist { list-style: none; padding: 0; display: grid; gap: .45rem; }
.checklist li { padding: .35rem .5rem; border-radius: 8px; background: #fafbfd; border: 1px solid var(--line); }
.approved-box {
  background: var(--ok-soft); border: 1px solid #a7f3d0; border-radius: var(--radius-sm);
  padding: .7rem .9rem; margin-top: 1rem; color: var(--ok); display: grid; gap: .3rem; justify-items: start;
}
/* ---------------------------------------------------------------- پیامک */
.notice {
  border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: .84rem;
  border: 1px solid var(--line); background: var(--bg); margin: .3rem 0;
}
.notice--warn { background: var(--warn-soft); border-color: #fde68a; color: #78350f; }
.notice strong { display: block; margin-bottom: .3rem; }
.notice p { margin: .3rem 0; }
.notice pre {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .7rem; margin: .4rem 0; white-space: pre-wrap;
  font-family: inherit; font-size: .84rem; line-height: 1.9;
}
.notice code { background: #fff; padding: .05rem .3rem; border-radius: 4px; }

.sms-meter { font-size: .78rem; margin-top: .2rem; }
.placeholders { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.notify-stats { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.sms-preview {
  background: #0b1220; color: #e2e8f0; border-radius: 14px;
  padding: .8rem 1rem; margin-top: .8rem; max-width: 380px;
}
.sms-preview__body { white-space: pre-wrap; font-size: .9rem; line-height: 1.9; margin-bottom: .4rem; }
.sms-preview .muted { color: #94a3b8; }

.demo-users { background: var(--bg); border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: .86rem; }
.demo-users code { background: #fff; padding: .05rem .35rem; border-radius: 4px; font-family: monospace; }

/* ---------------------------------------------------------------- خالی و خطا */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty__mark {
  width: 52px; height: 52px; margin: 0 auto .7rem; border-radius: 50%;
  background: var(--bg); display: grid; place-items: center; font-size: 1.4rem; color: var(--line-2);
}
.empty h3 { color: var(--ink); margin-bottom: .3rem; }
.empty--error .empty__mark { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------- مودال */
.modal-root { display: none; }
.modal-root.is-open { display: block; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: 92vh; display: flex; flex-direction: column;
}
.modal--wide { width: min(880px, 100%); }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--line);
}
.modal__body { padding: 1rem 1.1rem; overflow-y: auto; }
.confirm-text { font-size: .95rem; }

.notif-list { display: grid; gap: .4rem; max-height: 55vh; overflow-y: auto; }
.notif {
  text-align: start; width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .55rem .75rem;
}
.notif--unread { background: var(--primary-soft); border-color: #bfdbfe; }
.notif__title { font-weight: 700; font-size: .88rem; }
.notif__body { font-size: .82rem; color: var(--ink-2); }
.notif__time { font-size: .74rem; color: var(--muted); }

/* ---------------------------------------------------------------- توست */
.toast {
  position: fixed; bottom: 1.2rem; inset-inline-start: 50%; transform: translateX(50%) translateY(150%);
  background: var(--navy-900); color: #fff; padding: .65rem 1.1rem; border-radius: 999px;
  font-size: .88rem; z-index: 200; box-shadow: var(--shadow-lg);
  transition: transform .25s ease; max-width: 92vw; text-align: center;
}
.toast.is-open { transform: translateX(50%) translateY(0); }
.toast--success { background: #15803d; }
.toast--error { background: #b91c1c; }
.toast--warn { background: #b45309; }

/* ---------------------------------------------------------------- FAB و ناوبری موبایل */
.fab {
  position: fixed; bottom: calc(64px + env(safe-area-inset-bottom, 0px) + .7rem);
  inset-inline-end: 1rem; width: 58px; height: 58px; border-radius: 50%;
  background: var(--primary); color: #fff; border: 0; font-size: 1.7rem; line-height: 1;
  box-shadow: 0 12px 28px -8px rgba(29, 78, 216, .6); z-index: 60;
}
.bottom-nav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 55;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav button {
  flex: 1; background: none; border: 0; padding: .45rem .2rem;
  display: grid; gap: .05rem; justify-items: center; color: var(--muted); font-size: 1.05rem;
}
.bottom-nav em { font-style: normal; font-size: .68rem; }
.bottom-nav button.is-active { color: var(--primary); font-weight: 700; }

.only-mobile { display: none; }
.only-desktop { display: inline-flex; }

/* ---------------------------------------------------------------- واکنش‌گرا */
@media (max-width: 1000px) {
  .detail-grid { grid-template-columns: 1fr; }
  .funnel__row { grid-template-columns: 120px 1fr 44px 42px; }
}

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login__side { order: -1; padding: 1.5rem; }
  .login__side ul { display: none; }

  .shell { grid-template-columns: 1fr; }
  /* کشوی کناری موبایل: در حالت بسته نه دیده می‌شود، نه با لمس یا کیبورد
     قابل دسترسی است — حتی اگر مرورگر transform را اعمال نکند. */
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: 82vw; max-width: 300px;
    z-index: 90; transform: translateX(100%); visibility: hidden;
    /* visibility عمداً انیمیشن ندارد: باز و بسته بودن کشو نباید به اجرای
       صحیح انیمیشن در مرورگر وابسته باشد. */
    transition: transform .22s ease;
  }
  body.menu-open .sidebar { transform: translateX(0); visibility: visible; box-shadow: var(--shadow-lg); }
  body.menu-open::after {
    content: ''; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 80;
  }
  .view { padding: .8rem .8rem calc(78px + env(safe-area-inset-bottom, 0px)); }
  .only-mobile { display: inline-flex; }
  .only-desktop { display: none; }
  .bottom-nav { display: flex; }
  .kpi__value { font-size: 1.5rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .page-head { margin-bottom: .8rem; }
  .page-head .btn--lg { width: 100%; }
  .lead-row { flex-direction: column; gap: .35rem; }
  .lead-row__side { text-align: start; display: flex; gap: .6rem; }
  .modal { width: 100%; max-height: 96vh; border-radius: 18px 18px 0 0; align-self: flex-end; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .input:first-child { grid-column: 1 / -1; }
  .funnel__row { grid-template-columns: 100px 1fr 40px; }
  .funnel__row em { display: none; }
  .table { font-size: .82rem; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .cat-picker { grid-template-columns: 1fr 1fr; }
  .grid-2-form { grid-template-columns: 1fr; }
  .date-row { grid-template-columns: 1fr 96px; }
}

/* ---------------------------------------------------------------- چاپ / PDF */
@media print {
  .sidebar, .topbar, .bottom-nav, .fab, .head-actions, .quick-filters,
  .filters, .toolbar, .modal-root, .toast { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body { background: #fff; font-size: 12px; }
  .card { box-shadow: none; border-color: #cbd5e1; break-inside: avoid; }
  .view { padding: 0; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  a[href]::after { content: ''; }
}
