/* =========================================================
   BabakPen OS — Design System
   اطلس فناوران رازبان | Razban
   ========================================================= */

/* ---------- 1. Fonts ---------- */
@font-face {
  font-family: 'Estedad';
  src: url('../fonts/Estedad-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Estedad';
  src: url('../fonts/Estedad-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Estedad';
  src: url('../fonts/Estedad-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- 2. Tokens ---------- */
:root {
  /* Core */
  --navy: #132441;
  --navy-2: #1B3054;
  --gold: #B58B43;
  --gold-soft: #D9C08F;
  --cream: #F5F2EB;
  --white: #FFFFFF;
  --ink: #22314E;
  --muted: #6B7487;
  --line: #E4DFD3;

  /* Pastel category colors */
  --p-blue: #DDE9F8;
  --p-green: #DEECDF;
  --p-pink: #F1DDDC;
  --p-tan: #EEE2CC;

  /* Semantic */
  --ok: #2E7D52;
  --warn: #B58B43;
  --bad: #B4443C;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(19, 36, 65, .07), 0 8px 24px rgba(19, 36, 65, .06);
  --shadow-lift: 0 2px 6px rgba(19, 36, 65, .10), 0 14px 34px rgba(19, 36, 65, .10);

  /* Shell metrics */
  --topbar-h: 62px;
  --sidebar-w: 232px;

  /* Channel dots */
  --ch-telegram: #3A8FD6;
  --ch-whatsapp: #2E9E63;
  --ch-instagram: #C2568C;
  --ch-raychat: #B58B43;
}

/* ---------- 3. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  font-family: 'Estedad', Tahoma, sans-serif;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { overflow-x: hidden; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }

/* ---------- 4. Typography ---------- */
h1, .h1 { font-size: 22px; font-weight: 700; line-height: 1.5; letter-spacing: -.2px; }
h2, .h2 { font-size: 18px; font-weight: 700; line-height: 1.55; }
h3, .h3 { font-size: 15.5px; font-weight: 700; line-height: 1.6; }
.small { font-size: 12.5px; line-height: 1.7; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.medium { font-weight: 500; }
.num { font-variant-numeric: normal; }   /* tnum در استعداد ارقام فارسی را از هم باز می‌کند */

/* thin gold underline for section titles */
.section-title {
  display: inline-block;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--gold);
}

/* ---------- 5. Utilities ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.spacer { flex: 1 1 auto; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.hidden { display: none !important; }
.gold { color: var(--gold); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

/* ---------- 6. App shell ---------- */
.app {
  min-height: 100vh;
  padding-top: var(--topbar-h);
  /* در RTL، inline-start سمت راست است — نوار کناری آنجاست */
  padding-inline-start: var(--sidebar-w);
}

/* Top bar */
.topbar {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  height: var(--topbar-h);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  z-index: 40;
  box-shadow: 0 1px 0 rgba(217, 192, 143, .22);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__brand .logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3px;
  direction: ltr;
  unicode-bidi: isolate;
}
.nib-dot {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  color: var(--gold);
}
.topbar__actions { display: flex; align-items: center; gap: 16px; }
.bell {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: rgba(255, 255, 255, .88);
  transition: background .18s ease;
}
.bell:hover { background: rgba(255, 255, 255, .09); }
.bell__badge {
  position: absolute;
  inset-block-start: 5px;
  inset-inline-end: 5px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border: 1.5px solid var(--navy);
}
.user {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  transition: background .18s ease;
}
.user:hover { background: rgba(255, 255, 255, .08); }
.user__name { font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, .92); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
  font-size: 12.5px;
  flex: none;
}
.avatar--lg {
  width: 62px; height: 62px;
  font-size: 20px;
  background: var(--p-blue);
  color: var(--navy);
}

/* Sidebar (RIGHT side) */
.sidebar {
  position: fixed;
  inset-block-start: var(--topbar-h);
  inset-block-end: 0;
  inset-inline-start: 0;          /* لبهٔ راست در چیدمان راست‌به‌چپ */
  width: var(--sidebar-w);
  background: var(--navy);
  color: rgba(255, 255, 255, .78);
  display: flex;
  flex-direction: column;
  padding: 16px 0 14px;
  z-index: 30;
}
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, .74);
  border-inline-start: 3px solid transparent;
  transition: background .18s ease, color .18s ease;
  position: relative;
}
.nav__item svg { flex: none; opacity: .9; }
.nav__item:hover { background: var(--navy-2); color: #fff; }
.nav__item.is-active {
  background: var(--navy-2);
  color: var(--gold);
  border-inline-start-color: var(--gold);
  font-weight: 700;
}
.nav__item.is-soon { cursor: default; opacity: .62; }
.nav__item.is-soon:hover { background: transparent; color: rgba(255, 255, 255, .74); }
.sidebar__foot {
  margin-top: auto;
  padding: 14px 22px 0;
  border-top: 1px solid rgba(217, 192, 143, .18);
  font-size: 11.5px;
  color: rgba(255, 255, 255, .42);
  text-align: start;          /* هم‌تراز با آیتم‌های منو (لبهٔ راست) */
  unicode-bidi: isolate;
}

/* Tooltip «به‌زودی» */
.tip {
  position: absolute;
  /* منو سمت راست است، پس راهنما باید به سمت داخل صفحه (چپ) باز شود */
  inset-inline-start: calc(100% + 10px);
  inset-block-start: 50%;
  transform: translateY(-50%) translateX(-6px);
  background: var(--gold);
  color: var(--navy);
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.nav__item.is-soon:hover .tip { opacity: 1; transform: translateY(-50%) translateX(0); }

/* Content area */
.content {
  padding: 26px 28px 44px;
  max-width: 1560px;
}
.page-head { margin-bottom: 20px; }
.page-head h1 { margin-bottom: 2px; }

/* page-load micro animation */
.fade-up { animation: fadeUp .25s ease-out both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 7. Cards ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card--pad-sm { padding: 16px 18px; }
.card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.card__head h2, .card__head h3 { margin: 0; }
.icon-sq {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  flex: none;
  color: var(--navy);
  background: var(--p-blue);
}
.icon-sq--blue { background: var(--p-blue); }
.icon-sq--green { background: var(--p-green); }
.icon-sq--pink { background: var(--p-pink); }
.icon-sq--tan { background: var(--p-tan); }
.icon-sq--gold { background: rgba(181, 139, 67, .16); color: var(--gold); }

.card--clickable { transition: transform .18s ease, box-shadow .18s ease; }
.card--clickable:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.card--gold { border: 1.5px solid var(--gold-soft); }

/* ---------- 8. Chips & badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--p-blue);
  color: var(--navy);
  white-space: nowrap;
}
.chip--ok { background: rgba(46, 125, 82, .13); color: var(--ok); }
.chip--warn { background: rgba(181, 139, 67, .16); color: #8A6A31; }
.chip--bad { background: rgba(180, 68, 60, .13); color: var(--bad); }
.chip--neutral { background: #EFEDE7; color: var(--muted); }
.chip--blue { background: var(--p-blue); color: #2A4C7A; }
.chip--green { background: var(--p-green); color: #2C6440; }
.chip--pink { background: var(--p-pink); color: #94443F; }
.chip--tan { background: var(--p-tan); color: #7A5F2B; }
.chip--gold-outline {
  background: rgba(181, 139, 67, .07);
  color: #8A6A31;
  border: 1px solid var(--gold-soft);
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot--telegram { background: var(--ch-telegram); }
.dot--whatsapp { background: var(--ch-whatsapp); }
.dot--instagram { background: var(--ch-instagram); }
.dot--raychat { background: var(--ch-raychat); }

/* ---------- 9. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  background: var(--navy);
  color: #fff;
  border: 1px solid var(--navy);
  transition: background .18s ease, box-shadow .18s ease, transform .12s ease;
}
.btn:hover { background: var(--navy-2); border-color: var(--navy-2); }
.btn:active { transform: translateY(1px); }
.btn--secondary {
  background: var(--white);
  color: var(--navy);
  border: 1px solid var(--line);
}
.btn--secondary:hover { background: #FBFAF7; border-color: var(--gold-soft); }
.btn--sm { padding: 5px 12px; font-size: 12.5px; border-radius: 7px; }
.btn--block { width: 100%; }
.btn--gold {
  background: rgba(181, 139, 67, .1);
  color: #8A6A31;
  border: 1px solid var(--gold-soft);
}
.btn--gold:hover { background: rgba(181, 139, 67, .18); }

.linkish { color: var(--navy); font-weight: 500; }
.linkish:hover { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--gold); }

/* ---------- 10. Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.input::placeholder { color: #A6ADBB; }
.input:focus {
  outline: none;
  border-color: var(--gold-soft);
  box-shadow: 0 0 0 3px rgba(181, 139, 67, .16);
}
textarea.input { resize: vertical; min-height: 88px; line-height: 1.8; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check__box {
  width: 17px; height: 17px;
  border-radius: 5px;
  border: 1.5px solid var(--gold-soft);
  display: grid; place-items: center;
  flex: none;
  transition: background .16s ease, border-color .16s ease;
}
.check__box::after {
  content: '';
  width: 9px; height: 5px;
  /* physical sides on purpose — logical props would mirror the tick in RTL */
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(.4);
  opacity: 0;
  transition: opacity .16s ease, transform .16s ease;
}
.check input:checked + .check__box { background: var(--gold); border-color: var(--gold); }
.check input:checked + .check__box::after { opacity: 1; transform: rotate(-45deg) scale(1); }

/* ---------- 11. KPI tiles ---------- */
.kpi {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.kpi__label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.kpi__value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--navy);
}
/* واحد روی خط خودش می‌نشیند تا در عرض کم وسط عبارت نشکند */
.kpi__unit { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); line-height: 1.5; }
.kpi__sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi__trend { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; }
.kpi__trend--up { color: var(--ok); }
.kpi__trend--down { color: var(--bad); }
.kpi--alert .kpi__value { color: var(--bad); }

/* ---------- 12. Tables ---------- */
.table th, .table td {
  padding: 11px 12px;
  text-align: start;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.table th { font-weight: 700; color: var(--muted); font-size: 12.5px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FBFAF7; }

/* ---------- 13. Toast ---------- */
.toast-wrap {
  position: fixed;
  inset-block-end: 26px;
  inset-inline-start: 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 90;
}
.toast {
  background: var(--navy);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  font-size: 13.5px;
  font-weight: 500;
  border-inline-start: 3px solid var(--gold);
  animation: toastIn .22s ease-out both;
}
.toast.is-out { animation: toastOut .22s ease-in both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ---------- 14. Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(19, 36, 65, .42);
  display: grid;
  place-items: center;
  z-index: 80;
  animation: fadeIn .16s ease-out both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(460px, 92vw);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 24px;
  animation: fadeUp .22s ease-out both;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal__close { color: var(--muted); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.modal__close:hover { background: var(--cream); color: var(--ink); }
.modal__foot { display: flex; gap: 10px; justify-content: flex-start; margin-top: 18px; }

/* ---------- 15. Login page ---------- */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login__brand {
  grid-column: 1; grid-row: 1; /* dir=rtl → first column renders on the RIGHT */
  background: var(--navy);
  color: #fff;
  padding: 60px 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.login__pattern {
  position: absolute;
  inset: 0;
  opacity: .05;
  pointer-events: none;
}
.login__brand-inner { position: relative; z-index: 1; max-width: 420px; }
.login__title { font-size: 34px; font-weight: 700; letter-spacing: .5px; direction: ltr; unicode-bidi: isolate; text-align: start; margin: 26px 0 8px; }
.login__subtitle { font-size: 17px; font-weight: 500; color: var(--gold); margin-bottom: 30px; }
.login__bullets { display: flex; flex-direction: column; gap: 13px; }
.login__bullets li { display: flex; align-items: center; gap: 10px; color: rgba(255, 255, 255, .7); font-size: 14px; }
.login__bullets .nibmark { color: var(--gold-soft); flex: none; }

.login__form {
  grid-column: 2; grid-row: 1; /* dir=rtl → second column renders on the LEFT */
  background: var(--cream);
  display: grid;
  place-items: center;
  padding: 40px;
}
.login__card {
  width: min(380px, 100%);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 30px;
}
.login__card h2 { margin-bottom: 22px; }
.login__foot { text-align: center; margin-top: 16px; font-size: 11.5px; color: var(--muted); }

/* ---------- 16. Customer 360 ---------- */
.cust-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.profile { position: sticky; top: calc(var(--topbar-h) + 20px); }
.profile__id { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; }
.profile__name { font-size: 17px; font-weight: 700; margin-top: 10px; }
.profile__phone {
  direction: ltr;
  unicode-bidi: isolate;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
  border-bottom: 1px dashed var(--gold-soft);
}
.profile__phone:hover { color: var(--gold); }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

.stat-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
}
.stat-row__label { font-size: 12.5px; color: var(--muted); }
.stat-row__value { font-weight: 700; font-size: 14.5px; color: var(--navy); }

.rfm { display: flex; gap: 10px; }
.rfm__item { flex: 1; text-align: center; }
.rfm__bar { display: flex; gap: 3px; justify-content: center; margin-bottom: 5px; }
.rfm__seg { width: 100%; height: 6px; border-radius: 3px; background: var(--line); }
.rfm__seg.is-on { background: var(--gold); }
.rfm__label { font-size: 11.5px; color: var(--muted); }

.next-action { background: rgba(181, 139, 67, .05); }
.next-action__text { font-size: 13.5px; line-height: 1.85; }

/* search */
.search-wrap { position: relative; width: 330px; }
.search-drop {
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  max-height: 300px;
  overflow-y: auto;
  z-index: 25;
  padding: 5px;
}
.search-drop__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.search-drop__item:hover { background: var(--cream); }
.search-drop__empty { padding: 12px; text-align: center; color: var(--muted); font-size: 13px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .18s ease, border-color .18s ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--navy); font-weight: 700; border-bottom-color: var(--gold); }
.tab__count { font-size: 11.5px; color: var(--muted); margin-inline-start: 4px; }

/* timeline */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.tl-item {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  border-inline-start: 4px solid var(--p-blue);
  transition: box-shadow .18s ease;
}
.tl-item:hover { box-shadow: var(--shadow-lift); }
.tl-item--order { border-inline-start-color: #9BBEE8; }
.tl-item--call { border-inline-start-color: #86BE9A; }
.tl-item--chat { border-inline-start-color: #D08FAF; }
.tl-item--repair { border-inline-start-color: #D3B478; }
.tl-item--note { border-inline-start-color: var(--gold); }
.tl-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tl-head__title { font-weight: 700; font-size: 14.5px; }
.tl-head__date { font-size: 12px; color: var(--muted); margin-inline-start: auto; white-space: nowrap; }
.tl-body { font-size: 13.5px; }

.ai-box {
  background: rgba(19, 36, 65, .045);
  border: 1px solid rgba(19, 36, 65, .08);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  margin-top: 12px;
}
.ai-box__title {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; color: var(--navy);
  margin-bottom: 7px;
}
.ai-box__title svg { color: var(--gold); }
.ai-box__summary { font-size: 13px; line-height: 1.9; color: var(--ink); }
.ai-action {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 11px; padding: 9px 12px;
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius-sm);
  background: rgba(181, 139, 67, .06);
  font-size: 12.5px;
}
.ai-action__label { font-weight: 700; color: #8A6A31; }

.transcript-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 10px;
  font-size: 12.5px; font-weight: 500; color: var(--navy);
}
.transcript-toggle:hover { color: var(--gold); }
.transcript-toggle svg { transition: transform .2s ease; }
.transcript-toggle.is-open svg { transform: rotate(180deg); }
.transcript {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--cream);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 8px;
}
.transcript__turn { font-size: 12.8px; line-height: 1.85; }
.transcript__who { font-weight: 700; color: var(--navy); }
.transcript__turn--agent .transcript__who { color: var(--gold); }

/* ---------- 17. Dashboard ---------- */
.spark-wrap { position: relative; }
.spark { width: 100%; height: 196px; display: block; overflow: visible; }
.spark__axis { font-family: 'Estedad', Tahoma, sans-serif; font-size: 11.5px; fill: var(--muted); }
.spark__base { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.spark__dot { cursor: pointer; transition: r .12s ease; }
.spark-tip {
  position: absolute;
  transform: translate(50%, -100%);
  background: var(--navy);
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .14s ease;
  z-index: 5;
}
.spark-tip.is-on { opacity: 1; }

.report {
  background: var(--white);
  border: 1.5px solid var(--gold-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.report__head {
  background: var(--navy);
  color: #fff;
  padding: 11px 18px;
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; font-weight: 700;
}
.report__head svg { color: var(--gold); }
.report__time { margin-inline-start: auto; font-weight: 500; color: rgba(255,255,255,.65); font-size: 12px; }
.report__body { padding: 18px 20px; font-size: 13.5px; line-height: 2.05; white-space: pre-line; }
.report__sign {
  margin-top: 12px; padding-top: 11px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px; font-weight: 700; color: var(--gold);
  display: flex; align-items: center; gap: 6px;
}

.risk-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.risk-row:last-child { border-bottom: 0; }
.risk-row__name { font-weight: 500; font-size: 13.5px; }
.risk-row__meta { font-size: 11.5px; color: var(--muted); }

.split-bar {
  display: flex;
  height: 30px;
  border-radius: 8px;
  overflow: hidden;
  margin: 6px 0 16px;
}
.split-bar__seg { display: grid; place-items: center; font-size: 12.5px; font-weight: 700; }
.split-bar__seg--online { background: var(--p-blue); color: #2A4C7A; }
.split-bar__seg--instore { background: var(--p-tan); color: #7A5F2B; }
.legend { display: flex; gap: 18px; font-size: 12.5px; }
.legend__item { display: flex; align-items: center; gap: 7px; }
.legend__swatch { width: 11px; height: 11px; border-radius: 3px; }

.prod-row { padding: 8px 0; }
.prod-row__top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 5px; }
.prod-row__track { height: 7px; background: var(--cream); border-radius: 4px; overflow: hidden; }
.prod-row__fill { height: 100%; background: var(--gold); border-radius: 4px; }

/* ---------- 18. Queue ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-chip {
  padding: 6px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: all .18s ease;
}
.filter-chip:hover { border-color: var(--gold-soft); color: var(--ink); }
.filter-chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  border-inline-start: 4px solid var(--line);
  transition: opacity .3s ease, box-shadow .18s ease, transform .18s ease;
}
.task:hover { box-shadow: var(--shadow-lift); }
.task--urgent { border-inline-start-color: var(--bad); }
.task--today { border-inline-start-color: var(--gold); }
.task--week { border-inline-start-color: #C9CEDA; }
.task.is-done { opacity: .48; }
.task.is-done .task__title { text-decoration: line-through; }
.task__body { flex: 1; min-width: 0; }
.task__title { font-weight: 700; font-size: 14.5px; margin-bottom: 4px; }
.task__detail { font-size: 13px; color: var(--muted); line-height: 1.8; margin-bottom: 9px; }
.task__meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 12px; }
.task__check {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid; place-items: center;
  flex: none;
  margin-top: 2px;
  color: transparent;
  transition: all .2s ease;
}
.task__check:hover { border-color: var(--gold); }
.task.is-done .task__check { background: var(--ok); border-color: var(--ok); color: #fff; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state__title { font-size: 17px; font-weight: 700; color: var(--ink); margin-top: 10px; }

/* ---------- 19. Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D9D4C8; border-radius: 6px; border: 3px solid var(--cream); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-soft); }

/* ---------- 20. Responsive guards (projector safety) ---------- */
@media (max-width: 1400px) {
  .content { padding: 22px 20px 40px; }
  .grid-5 { gap: 12px; }
  .kpi { padding: 15px 16px; }
  .kpi__value { font-size: 27px; }
  .cust-layout { grid-template-columns: 296px minmax(0, 1fr); }
}
@media (max-width: 1180px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* =========================================================
   Phase 5 — components
   ========================================================= */

/* ---------- 21. Social inbox ---------- */
.inbox {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 300px;
  gap: 16px;
  height: calc(100vh - var(--topbar-h) - 52px);
}
.inbox__col {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.inbox__head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.inbox__scroll { overflow-y: auto; flex: 1; min-height: 0; }

/* channel filter tabs */
.chan-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 12px; }
.chan-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--white);
  font-size: 12px; font-weight: 500; color: var(--muted);
  transition: all .16s ease;
}
.chan-tab:hover { border-color: var(--gold-soft); color: var(--ink); }
.chan-tab.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.chan-tab.is-active .dot { box-shadow: 0 0 0 2px rgba(255,255,255,.35); }

/* status segmented control */
.seg { display: flex; background: var(--cream); border-radius: var(--radius-sm); padding: 3px; margin-top: 10px; }
.seg__btn {
  flex: 1; padding: 5px 8px; border-radius: 7px;
  font-size: 12px; font-weight: 500; color: var(--muted);
  transition: all .16s ease;
}
.seg__btn.is-active { background: var(--white); color: var(--navy); font-weight: 700; box-shadow: var(--shadow); }

/* thread rows */
.thread {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-inline-start: 3px solid transparent;
  transition: background .14s ease;
}
.thread:hover { background: #FBFAF7; }
.thread.is-active { background: var(--cream); border-inline-start-color: var(--gold); }
.thread__body { flex: 1; min-width: 0; }
.thread__top { display: flex; align-items: center; gap: 6px; }
.thread__name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread.is-unread .thread__name { font-weight: 700; }
.thread__time { margin-inline-start: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.thread__last {
  font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.thread.is-unread .thread__last { color: var(--ink); }
.thread__marks { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.thread__unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--navy); flex: none; }
.avatar--chan { background: var(--p-blue); color: var(--navy); }
.avatar--telegram { background: #DCEDFA; color: #1F5F8B; }
.avatar--whatsapp { background: var(--p-green); color: #22693F; }
.avatar--instagram { background: var(--p-pink); color: #8E3358; }
.avatar--raychat { background: var(--p-tan); color: #7A5F2B; }

/* conversation pane */
.conv__head {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
  flex-wrap: wrap;                 /* در عرض کم به‌جای بیرون‌زدن، سطر دوم می‌سازد */
}
.conv__who { min-width: 0; flex: 1 1 120px; }
.conv__who > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv__msgs {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 18px 20px;
  background: var(--cream);
  display: flex; flex-direction: column; gap: 10px;
}
.daysep { text-align: center; margin: 6px 0; }
.daysep span {
  background: var(--white); border: 1px solid var(--line);
  padding: 3px 12px; border-radius: 999px;
  font-size: 11.5px; color: var(--muted);
}
.bubble {
  max-width: 74%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.85;
  position: relative;
  box-shadow: 0 1px 2px rgba(19,36,65,.05);
}
.bubble__time { display: block; font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.bubble--customer {
  align-self: flex-start;              /* dir=rtl → سمت راست */
  background: var(--white);
  border: 1px solid var(--line);
  border-start-start-radius: 4px;
}
.bubble--agent {
  align-self: flex-end;                /* dir=rtl → سمت چپ */
  background: #E8EDF6;
  border: 1px solid #D5DEEC;
  border-start-end-radius: 4px;
}
.bubble--ai { align-self: flex-end; background: #F3EEE3; border: 1px solid var(--gold-soft); border-start-end-radius: 4px; }
.bubble__ai-mark { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: #8A6A31; margin-bottom: 4px; }
.bubble__ai-note { display: block; font-size: 10.5px; color: var(--muted); margin-top: 4px; font-style: normal; }
.bubble__attach {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; margin: -2px 0 4px;
  background: var(--cream); border: 1px dashed var(--line); border-radius: 9px;
  font-size: 12.5px; color: var(--muted);
}

/* composer */
.composer { flex: none; border-top: 1px solid var(--line); padding: 12px 16px; background: var(--white); }
.composer__row { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.composer textarea { min-height: 62px; }
.composer__tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute;
  inset-block-end: calc(100% + 6px);
  inset-inline-start: 0;
  min-width: 230px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  padding: 5px;
  z-index: 30;
}
.dropdown__item { display: block; width: 100%; text-align: start; padding: 8px 10px; border-radius: 7px; font-size: 12.5px; }
.dropdown__item:hover { background: var(--cream); }

/* context pane */
.ctx-card { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ctx-card:last-child { border-bottom: 0; }
.ctx-card__title { font-size: 12.5px; font-weight: 700; color: var(--navy); margin-bottom: 9px; display: flex; align-items: center; gap: 6px; }
.ctx-card__title svg { color: var(--gold); }
.match-note {
  display: flex; align-items: flex-start; gap: 7px;
  background: rgba(181,139,67,.08); border: 1px solid var(--gold-soft);
  border-radius: var(--radius-sm); padding: 8px 10px;
  font-size: 11.5px; color: #8A6A31; margin-bottom: 10px;
}

/* sidebar unread badge */
.nav__badge {
  margin-inline-start: auto;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px;
  background: var(--gold); color: var(--navy);
  font-size: 11px; font-weight: 700; line-height: 19px; text-align: center;
}

/* ---------- 22. AI Q&A ---------- */
.ask__chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.ask__chip {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--gold-soft); background: rgba(181,139,67,.06);
  font-size: 12.5px; color: #8A6A31; text-align: start;
}
.ask__chip:hover { background: rgba(181,139,67,.15); }
.ask__log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; max-height: 320px; overflow-y: auto; }
.ask__q { align-self: flex-start; background: var(--navy); color: #fff; padding: 8px 13px; border-radius: 12px; font-size: 13px; max-width: 85%; }
.ask__a { align-self: flex-end; background: var(--cream); border: 1px solid var(--line); padding: 11px 14px; border-radius: 12px; font-size: 13px; line-height: 1.9; max-width: 92%; }
.ask__foot { font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 4px; }
.shimmer { display: inline-block; width: 130px; height: 11px; border-radius: 6px;
  background: linear-gradient(90deg, #EDE9E0 25%, #F7F4EE 50%, #EDE9E0 75%);
  background-size: 200% 100%; animation: sh 1.1s linear infinite; }
@keyframes sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- 23. Audio player ---------- */
.player { display: flex; align-items: center; gap: 12px; padding: 11px 13px;
  background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; }
.player__btn { width: 36px; height: 36px; border-radius: 50%; background: var(--navy); color: #fff;
  display: grid; place-items: center; flex: none; }
.player__btn:hover { background: var(--navy-2); }
.player__btn[disabled] { opacity: .45; cursor: not-allowed; }
.wave { display: flex; align-items: center; gap: 2px; height: 30px; flex: 1; min-width: 0; }
.wave__bar { flex: 1; background: var(--gold-soft); border-radius: 1px; transition: background .15s ease; }
.wave__bar.is-played { background: var(--gold); }
.player__time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.player__speed { font-size: 11.5px; font-weight: 700; color: var(--navy); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 8px; background: var(--white); }
.transcript__turn.is-live { background: rgba(181,139,67,.16); border-radius: 6px; padding: 2px 6px; margin: -2px -6px; }

/* ---------- 24. Repairs kanban ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.board__col { background: rgba(255,255,255,.55); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-height: 320px; }
.board__col.is-over { border-color: var(--gold); background: rgba(181,139,67,.07); }
.board__head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.board__count { margin-inline-start: auto; font-size: 12px; color: var(--muted); }
.rcard { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 13px 14px; margin-bottom: 10px; cursor: grab; }
.rcard:active { cursor: grabbing; }
.rcard.is-dragging { opacity: .45; }
.rcard__title { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.rcard__title svg { color: var(--gold); flex: none; }
.rcard__meta { font-size: 11.5px; color: var(--muted); line-height: 1.9; }

/* ---------- 25. Settings ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.subnav { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.subnav__item { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; color: var(--muted); position: relative; }
.subnav__item.is-active { background: var(--cream); color: var(--navy); font-weight: 700; }
.subnav__item.is-soon { opacity: .6; cursor: default; }
.subnav__item.is-soon .tip { inset-inline-end: auto; inset-inline-start: calc(100% + 8px); }
.subnav__item.is-soon:hover .tip { opacity: 1; transform: translateY(-50%); }
.radio-row { display: flex; gap: 11px; align-items: flex-start; padding: 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer; transition: border-color .16s ease, background .16s ease; }
.radio-row + .radio-row { margin-top: 9px; }
.radio-row:hover { border-color: var(--gold-soft); }
.radio-row.is-on { border-color: var(--gold); background: rgba(181,139,67,.05); }
.radio-dot { width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--gold-soft);
  flex: none; margin-top: 3px; display: grid; place-items: center; }
.radio-row.is-on .radio-dot { border-color: var(--gold); }
.radio-row.is-on .radio-dot::after { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.slider { width: 100%; accent-color: var(--gold); margin: 10px 0 6px; }
.meter { height: 9px; background: var(--cream); border-radius: 5px; overflow: hidden; }
.meter__fill { height: 100%; background: var(--gold); border-radius: 5px; transition: width .3s ease; }
.toggle-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: 0; }
.switch { width: 40px; height: 23px; border-radius: 999px; background: var(--ok); flex: none; position: relative; transition: background .2s ease; }
.switch::after { content: ''; position: absolute; inset-block-start: 3px; inset-inline-end: 3px;
  width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: inset-inline-end .2s ease; }
.switch.is-off { background: #C9CEDA; }
.switch.is-off::after { inset-inline-end: 20px; }
.lock { color: var(--muted); flex: none; }

/* ---------- 26. Customers list ---------- */
.table--sortable th { cursor: pointer; user-select: none; white-space: nowrap; }
.table--sortable th:hover { color: var(--navy); }
.table__sort { font-size: 9px; color: var(--gold); margin-inline-start: 3px; }
.minibar { width: 60px; height: 6px; background: var(--cream); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; }
.minibar__fill { height: 100%; border-radius: 3px; }
.row-link { cursor: pointer; }

/* ---------- 27. Notifications dropdown ---------- */
.notif {
  position: absolute;
  inset-block-start: calc(100% + 8px);
  /* زنگ اعلان نزدیک لبهٔ چپ است؛ منو باید به سمت داخل صفحه باز شود، نه بیرون */
  inset-inline-end: 0;
  width: 360px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  z-index: 60;
  overflow: hidden;
  animation: fadeUp .18s ease-out both;
  color: var(--ink);
}
.notif__head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 15px; border-bottom: 1px solid var(--line); }
.notif__list { max-height: 380px; overflow-y: auto; }
.notif__item { display: flex; gap: 11px; padding: 12px 15px; border-bottom: 1px solid var(--line);
  cursor: pointer; text-align: start; width: 100%; }
.notif__item:last-child { border-bottom: 0; }
.notif__item:hover { background: #FBFAF7; }
.notif__item.is-read { opacity: .55; }
.notif__title { font-size: 13px; font-weight: 700; }
.notif__detail { font-size: 12px; color: var(--muted); line-height: 1.75; }
.notif__time { font-size: 11px; color: var(--muted); margin-top: 3px; display: block; }

/* ---------- 28. Phone frame preview ---------- */
.phone-frame {
  width: 390px; height: 780px;
  background: var(--navy);
  border-radius: 44px;
  padding: 12px;
  box-shadow: 0 20px 60px rgba(19,36,65,.35);
  position: relative;
}
.phone-frame::before {
  content: ''; position: absolute; inset-block-start: 20px; inset-inline: 0;
  width: 120px; height: 22px; margin: 0 auto;
  background: var(--navy); border-radius: 0 0 14px 14px; z-index: 2;
}
.phone-frame iframe { width: 100%; height: 100%; border: 0; border-radius: 33px; background: var(--cream); }
.modal--phone { width: auto; background: transparent; box-shadow: none; padding: 0; }
.modal--phone .modal__head { color: #fff; margin-bottom: 12px; }
.modal--phone .modal__close { color: #fff; }
.modal--phone .modal__close:hover { background: rgba(255,255,255,.15); }

/* ---------- 29. Mobile Customer 360 (فروشنده حضوری) ---------- */
/* is-mobile از ?mobile=1 می‌آید تا در قاب گوشی هم همین چیدمان دیده شود */
@media (max-width: 480px) {
  .app { padding-inline-start: 0; }
  .sidebar { display: none; }
  .sidebar.is-open { display: flex; width: 232px; box-shadow: 0 0 40px rgba(19,36,65,.4); z-index: 50; }
  .content { padding: 16px 14px 90px; }
  .cust-layout { grid-template-columns: minmax(0, 1fr); }
  .profile { position: static; }
  .search-wrap { width: 100%; }
  .page-head.row-between { flex-direction: column; align-items: stretch; gap: 12px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; }
  .grid-2, .grid-3, .grid-5 { grid-template-columns: minmax(0, 1fr); }
}
body.is-mobile .app { padding-inline-start: 0; }
body.is-mobile .sidebar { display: none; }
body.is-mobile .sidebar.is-open { display: flex; width: 232px; box-shadow: 0 0 40px rgba(19,36,65,.4); z-index: 50; }
body.is-mobile .content { padding: 16px 14px 90px; }
body.is-mobile .cust-layout { grid-template-columns: minmax(0, 1fr); }
body.is-mobile .profile { position: static; }
body.is-mobile .search-wrap { width: 100%; }
body.is-mobile .page-head.row-between { flex-direction: column; align-items: stretch; gap: 12px; }
body.is-mobile .tabs { overflow-x: auto; flex-wrap: nowrap; }
body.is-mobile .tab { white-space: nowrap; }
body.is-mobile .topbar { padding: 0 14px; }
/* انیمیشن ورود transform دارد و برای فرزندِ position:fixed «بلوک دربرگیرنده» می‌سازد؛
   در موبایل خاموش می‌شود تا نوار «اقدام بعدی» واقعاً به پایین صفحه بچسبد. */
body.is-mobile .content { animation: none; }
body.is-mobile .user__name { display: none; }

/* پروفایل در موبایل: هدر افقی به‌جای ستون */
body.is-mobile .profile__id { flex-direction: row; text-align: start; gap: 12px; align-items: center; }
body.is-mobile .profile__id .avatar--lg { width: 48px; height: 48px; font-size: 16px; }
body.is-mobile .profile__name { margin-top: 0; font-size: 15.5px; }
body.is-mobile .profile .card { padding: 16px; }

/* دو آمار خرید کنار هم */
body.is-mobile .stat-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
body.is-mobile .stat-duo .stat-row { padding: 10px; background: var(--cream); border-radius: var(--radius-sm); }

/* «اقدام بعدی» به‌صورت نوار چسبیده به پایین */
body.is-mobile .next-action { position: fixed; inset-inline: 0; inset-block-end: 0;
  border-radius: var(--radius) var(--radius) 0 0; z-index: 45; margin: 0;
  box-shadow: 0 -6px 24px rgba(19,36,65,.15); max-height: 42vh; overflow-y: auto; }

/* دکمهٔ همبرگر — فقط در موبایل */
.hamburger { display: none; width: 36px; height: 36px; border-radius: 8px;
  color: rgba(255,255,255,.9); place-items: center; }
body.is-mobile .hamburger, .hamburger.is-mobile-visible { display: grid; }
@media (max-width: 480px) { .hamburger { display: grid; } }

/* =========================================================
   Phase 6 — crafted pass (overrides above on purpose)
   ========================================================= */

/* ---------- 30. Paper grain: reads as stationery, kills "template" ---------- */
body {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* ---------- 31. Type hierarchy with real contrast ---------- */
h1, .h1 { font-size: 24px; font-weight: 700; letter-spacing: -.25px; }
.card__head h2, .card__head h3 { font-size: 15px; font-weight: 700; letter-spacing: 0; }
.small { font-size: 12.5px; }

/* gold rule belongs to the page title only, not every heading */
.card__head .section-title { border-bottom: 0; padding-bottom: 0; }
.section-title { border-bottom-width: 2px; max-width: max-content; }

/* asymmetric rhythm: more air above a title than below it */
.page-head { margin-bottom: 28px; }
.card__head { margin-bottom: 14px; }

/* ---------- 32. Surfaces: shadow OR hairline, never both ---------- */
.card, .kpi { box-shadow: none; border: 1px solid var(--line); }
.card--raised, .report, .modal, .notif, .toast, .search-drop, .dropdown__menu {
  box-shadow: var(--shadow);
}
.card--clickable:hover, .kpi:hover { box-shadow: var(--shadow); border-color: var(--gold-soft); }
.tl-item { box-shadow: none; }
.tl-item:hover { box-shadow: var(--shadow); }

/* ---------- 33. Density — ops tools are tighter than landing pages ---------- */
.tl-item { padding: 13px 16px; }
.tl-head { margin-bottom: 7px; }
.timeline { gap: 12px; }
.table th, .table td { padding: 8px 12px; height: 44px; }
.inbox__col .card { padding: 16px; }

/* ---------- 34. The star call earns a hairline gold frame ---------- */
.tl-item--star { border: 1px solid var(--gold-soft); border-inline-start-width: 4px; padding: 17px 20px; }
.tl-item--star .ai-box { background: rgba(19, 36, 65, .05); }

/* profile column gets a quiet cream band instead of another white card */
.profile__band { background: var(--cream); border-radius: var(--radius-sm); padding: 12px 14px; margin: 14px 0; }

/* ---------- 35. Dashboard: 4 tiles + one wide strip, not 5 equal boxes ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi--wide {
  grid-column: 1 / -1;          /* نوار «امروز» تمام‌عرض بالای چهار کاشی */
  display: grid;
  grid-template-columns: auto 1px auto 1fr auto;
  align-items: center;
  gap: 18px;
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.kpi--wide .kpi__label { color: rgba(255,255,255,.65); }
.kpi--wide .kpi__value { color: #fff; }
.kpi--wide .kpi__unit { color: rgba(255,255,255,.6); }
.kpi--wide .kpi__rule { background: rgba(217,192,143,.3); height: 100%; min-height: 46px; }
.kpi--wide .kpi__split { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: rgba(255,255,255,.8); }
.kpi--wide .kpi__glance { display: flex; gap: 22px; }
.kpi--wide .kpi__glance div { text-align: start; }
.kpi--wide .kpi__glance .n { font-size: 19px; font-weight: 700; color: var(--gold-soft); line-height: 1.3; }
.kpi--wide .kpi__glance .l { font-size: 11.5px; color: rgba(255,255,255,.6); }
.kpi--wide:hover { box-shadow: none; border-color: var(--navy); }

/* morning report spans both rows on the right */
.dash-mid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* ---------- 36. Avatars: 1px inner ring in the darker tone ---------- */
.avatar { box-shadow: inset 0 0 0 1px rgba(19, 36, 65, .12); }
.avatar--telegram { box-shadow: inset 0 0 0 1px rgba(31, 95, 139, .3); }
.avatar--whatsapp { box-shadow: inset 0 0 0 1px rgba(34, 105, 63, .3); }
.avatar--instagram { box-shadow: inset 0 0 0 1px rgba(142, 51, 88, .3); }
.avatar--raychat { box-shadow: inset 0 0 0 1px rgba(122, 95, 43, .3); }

/* ---------- 37. Motion: one entrance, quick hovers, one slow pulse ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation-duration: .22s; }
.btn, .filter-chip, .chan-tab, .tab, .thread, .linkish { transition-duration: .12s; }
.thread__unread-dot { animation: pulseDot 2s ease-in-out infinite; }
@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- 38. Focus visible on everything interactive ---------- */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-radius: 6px;
}
.topbar a:focus-visible, .sidebar a:focus-visible, .topbar button:focus-visible {
  outline-color: var(--gold-soft);
}

/* ---------- 39. Footer mark ---------- */
.sidebar__foot { font-size: 11px; opacity: .55; letter-spacing: .02em; color: #fff; }

/* ---------- 40. Print: customer file on paper ---------- */
@media print {
  .topbar, .sidebar, .search-wrap, .tabs, .toast-wrap, .modal-backdrop,
  #btnPhonePreview, .transcript-toggle, .ai-action button { display: none !important; }
  .app { padding: 0; }
  .content { padding: 0; max-width: none; }
  .cust-layout { grid-template-columns: minmax(0, 1fr); }
  .profile { position: static; }
  body { background: #fff; }
  .card, .tl-item, .kpi { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .transcript { display: block !important; }
  a[href]::after { content: ''; }
}

/* identity block: left-aligned (centered text inside cards is a template tell),
   but stacked — a 320px column is too narrow for avatar + name + phone on one line. */
.profile__id--row { flex-direction: column; align-items: flex-start; text-align: start; gap: 2px; }
.profile__id--row .avatar--lg { width: 52px; height: 52px; font-size: 17px; margin-bottom: 8px; }
.profile__id--row .profile__name { margin-top: 0; }
.profile__id--row .profile__phone { direction: ltr; unicode-bidi: isolate; }

/* ---------- 41. Branch selector & chips (Phase 7) ---------- */
.branch-select {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(217, 192, 143, .35);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
  max-width: 150px;
}
.branch-select:hover { background: rgba(255, 255, 255, .14); }
.branch-select option { color: var(--ink); background: #fff; }
.chip--branch { font-size: 11px; opacity: .9; }

/* ---------- 42. Prediction card ---------- */
.pred__window { font-size: 18px; font-weight: 700; color: var(--navy); line-height: 1.5; }
.pred__window--late { color: var(--bad); }
.pred__basis { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.8; }
.pred__label { font-size: 12.5px; font-weight: 500; margin: 11px 0 6px; }
.pred__reason { font-size: 12px; color: var(--muted); margin-top: 9px; line-height: 1.8; }
.due-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.due-row:last-child { border-bottom: 0; }
.due-row__win { font-size: 12px; color: var(--muted); }
.due-row__win--late { color: var(--bad); font-weight: 500; }

/* ---------- 43. Roles & access ---------- */
.role-chip { font-size: 11.5px; }
.matrix th:first-child, .matrix td:first-child { font-weight: 500; }
.matrix td { text-align: center; }
.matrix th { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: start; }
.role-menu { position: absolute; z-index: 70; background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lift); padding: 5px; min-width: 150px; }
.role-menu button { display: block; width: 100%; text-align: start; padding: 7px 10px;
  border-radius: 6px; font-size: 12.5px; }
.role-menu button:hover { background: var(--cream); }

/* ---------- 44. Workflow: referral, approval, history (Phase 8) ---------- */
.tab__badge {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  margin-inline-start: 6px;
  border-radius: 999px;
  background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 700;
}
.task--opportunity { border-inline-start-color: var(--ok); }
.task--approve { border-inline-start-color: var(--gold); }
.task__from {
  font-size: 12px; color: #8A6A31;
  background: rgba(181, 139, 67, .07);
  border-inline-start: 2px solid var(--gold-soft);
  padding: 5px 9px; border-radius: 6px;
  margin-bottom: 7px;
}
.task__actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.approve__reason { font-size: 13.5px; color: var(--ink); margin-bottom: 8px; }
.task.is-approved { border-inline-start-color: var(--ok); background: rgba(46, 125, 82, .05); }
.task.is-rejected { opacity: .5; }

.hist { margin-top: 11px; padding: 10px 12px; background: var(--cream); border-radius: var(--radius-sm); }
.hist__row { display: flex; align-items: baseline; gap: 8px; font-size: 12px; padding: 3px 0; }
.hist__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold-soft); flex: none; }
.hist__at { color: var(--muted); white-space: nowrap; }
.hist__who { font-weight: 700; color: var(--navy); white-space: nowrap; }
.hist__what { color: var(--ink); }

/* ---------- 45. Positive strip & goal tile ---------- */
.goodstrip {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  background: rgba(46, 125, 82, .07);
  border: 1px solid rgba(46, 125, 82, .22);
  border-radius: var(--radius);
  padding: 11px 18px;
  margin-bottom: 16px;
}
.goodstrip__title { font-size: 12.5px; font-weight: 700; color: var(--ok); white-space: nowrap; }
.goodstrip__item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink); }
.goodstrip__item svg { color: var(--ok); flex: none; }

.goal__bar { height: 8px; background: var(--cream); border-radius: 5px; overflow: hidden; margin: 8px 0 5px; }
.goal__fill { height: 100%; background: var(--ok); border-radius: 5px; }

/* ---------- 46. Automation rules table ---------- */
.rule-note { font-size: 12px; color: var(--muted); margin-top: 12px; }
.builder { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.builder select { width: auto; min-width: 165px; }
.builder__word { font-size: 13px; color: var(--muted); }
.sysbar {
  display: flex; align-items: center; gap: 8px;
  margin-top: 20px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 12px; color: var(--muted);
}
.sysbar svg { color: var(--ok); flex: none; }
.locked-list { display: flex; flex-direction: column; }
.locked-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.locked-row:last-child { border-bottom: 0; }
.locked-row svg { color: var(--muted); flex: none; }
.locked-row .spacer { flex: 1; }
.strengths {
  display: flex; align-items: flex-start; gap: 7px;
  margin-top: 10px; padding: 8px 10px;
  background: rgba(46, 125, 82, .07);
  border: 1px solid rgba(46, 125, 82, .2);
  border-radius: var(--radius-sm);
  font-size: 12px; color: #2C6440; line-height: 1.75;
}
.strengths svg { color: var(--ok); flex: none; margin-top: 3px; }
