@font-face { font-family: Peyda; font-weight: 400; font-display: swap; src: url(../fonts/PeydaFaNum-Regular.ttf) format("truetype"); }
@font-face { font-family: Peyda; font-weight: 500; font-display: swap; src: url(../fonts/Peyda-Medium.ttf) format("truetype"); }
@font-face { font-family: Peyda; font-weight: 600; font-display: swap; src: url(../fonts/Peyda-SemiBold.ttf) format("truetype"); }
@font-face { font-family: Peyda; font-weight: 700; font-display: swap; src: url(../fonts/PeydaFaNum-Bold.ttf) format("truetype"); }
:root {
    --navy: #1c2a5e;
    --navy-soft: #2a3a75;
    --primary: #2f62e8;
    --primary-dark: #244fc4;
    --bg: #f3f5fa;
    --grid: #e8ecf4;
    --card: #ffffff;
    --line: #e7ebf2;
    --head: #e8f0fb;
    --text: #1b2440;
    --muted: #7c869d;
    --ok: #12a074;
    --warn: #d98a12;
    --bad: #d64545;
    --info: #2f62e8;
    --radius: 16px;
    --shadow: 0 2px 10px rgba(28, 42, 94, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 14px; }
body {
    margin: 0;
    font-family: Peyda, Tahoma, sans-serif;
    color: var(--text);
    background-color: var(--bg);
    background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 92px 92px;
    line-height: 1.75;
    word-spacing: .12em;
    -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
bdi, .mono { font-family: Consolas, 'Courier New', monospace; font-size: .92em; }
.muted { color: var(--muted); }
.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.icon { width: 20px; height: 20px; flex: none; }

/* ---------- چیدمان ---------- */
.shell { display: flex; gap: 22px; padding: 12px; min-height: 100vh; align-items: flex-start; }
.sidebar {
    position: sticky; top: 12px; flex: none; width: 212px; height: calc(100vh - 24px);
    display: flex; flex-direction: column; padding: 18px 14px;
    background: var(--navy); color: #fff; border-radius: 22px;
}
.main { flex: 1; min-width: 0; }

.side-user { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; }
.side-user strong { display: block; font-size: 13px; font-weight: 600; }
.side-user small { color: #b9c3e6; font-size: 12px; direction: ltr; display: block; text-align: right; }
.avatar {
    display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
    background: #dfe6f7; color: var(--navy);
}
.avatar.sm { width: 28px; height: 28px; background: var(--navy); color: #fff; }
.avatar.sm .icon { width: 16px; height: 16px; }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; font-weight: 700; background: var(--head); color: var(--primary); }

.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.side-nav::-webkit-scrollbar { display: none; }
.side-nav a, .side-nav .soon, .side-logout {
    display: flex; align-items: center; gap: 10px; flex: none; padding: 9px 14px; border-radius: 12px;
    color: #e6eaf8; font-weight: 500; font-size: 13.5px; transition: background .15s;
}
.side-nav a:hover, .side-logout:hover { background: var(--navy-soft); }
.side-nav a.active { background: #fff; color: var(--navy); font-weight: 600; }
.side-nav .soon { color: #8b97c4; cursor: default; }
.side-nav .soon em { margin-inline-start: auto; font-style: normal; font-size: 10.5px; padding: 1px 7px; border-radius: 20px; background: var(--navy-soft); color: #b9c3e6; }
.side-foot { padding-top: 12px; }
.brand { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 0 4px; font-weight: 700; font-size: 16px; }
.brand b { width: 22px; height: 22px; border-radius: 6px 6px 6px 0; background: #fff; box-shadow: inset -7px -7px 0 var(--primary); }
.brand.dark { color: var(--navy); justify-content: flex-start; padding: 0 0 18px; }
.brand.dark b { background: var(--navy); }

.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 22px; margin-bottom: 18px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.topbar-title { display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px; background: none; color: var(--navy); cursor: pointer; }
.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border: 1px solid var(--line); border-radius: 10px; font-weight: 500; font-size: 13px; }

/* ---------- اجزا ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 20px 22px; }
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 22px;
    border: 1.5px solid transparent; border-radius: 10px; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--head); }
.btn-block { width: 100%; padding: 12px; }
.link { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--primary); font-weight: 500; font-size: 13px; cursor: pointer; }
.link .icon { width: 16px; height: 16px; }
.link:hover { text-decoration: underline; }

input[type=text], input[type=password], input[type=search], input[type=url], select, textarea {
    width: 100%; padding: 9px 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 98, 232, .12); }
input[type=color] { width: 100%; height: 40px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); }
label > input, label > select { margin-top: 5px; color: var(--text); font-weight: 400; font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; }

.alert { padding: 12px 18px; margin-bottom: 16px; border-radius: 12px; font-weight: 500; background: #fff; border: 1px solid var(--line); }
.alert-success { background: #e9f8f2; border-color: #bfe8d9; color: #0c7a58; }
.alert-error { background: #fdeeee; border-color: #f5c8c8; color: #b23333; }
.alert-key { background: #fff8e6; border-color: #f1dca0; }
.alert-key code { display: block; margin-top: 8px; padding: 10px 14px; background: #fff; border: 1px dashed #d9bf6a; border-radius: 8px; font-size: 14px; cursor: pointer; word-break: break-all; }
.alert-key code.copied { border-color: var(--ok); color: var(--ok); }

/* ---------- داشبورد ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi { display: flex; align-items: center; gap: 14px; padding: 18px 20px; }
.kpi-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--head); color: var(--primary); }
.kpi small { display: block; color: var(--muted); font-size: 12.5px; }
.kpi strong { display: block; font-size: 21px; font-weight: 700; line-height: 1.5; }
.kpi em { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; align-items: start; }
.top-gap { margin-top: 18px; }

.bars { display: flex; flex-direction: column; gap: 13px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 190px; align-items: center; gap: 12px; font-size: 13px; }
.bar-label { font-weight: 500; }
.bar-track { height: 10px; border-radius: 10px; background: #eef1f7; overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 10px; min-width: 3px; }
.bar-value { font-weight: 600; white-space: nowrap; }
.bar-value small { font-weight: 400; color: var(--muted); }

.cols { display: flex; align-items: flex-end; gap: 8px; height: 200px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.col i { width: 100%; max-width: 26px; border-radius: 6px 6px 2px 2px; background: var(--primary); opacity: .85; }
.col:last-child i { opacity: 1; background: var(--navy); }
.col b { font-size: 11px; font-weight: 500; color: var(--muted); }
.col small { font-size: 11px; color: var(--muted); }

/* ---------- نوار ابزار، تب و جدول ---------- */
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin: 4px 0 0; }
.toolbar + .card { border-start-start-radius: 0; }
.tabs { display: flex; border-bottom: 2px solid #dfe5f0; margin-inline-start: 14px; }
.tabs button {
    display: flex; align-items: center; gap: 6px; padding: 10px 18px; margin-bottom: -2px; border: 0; border-bottom: 2px solid transparent;
    background: none; color: var(--muted); font-weight: 600; cursor: pointer;
}
.tabs button .icon { width: 18px; height: 18px; }
.tabs button.active { color: var(--navy); border-bottom-color: var(--primary); }
.tabs button.active .icon { color: var(--primary); }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; }
.filters select, .filters input[type=search] { width: auto; min-width: 150px; border-color: transparent; box-shadow: var(--shadow); }
.search { position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; inset-inline-start: 10px; width: 17px; height: 17px; color: var(--muted); }
.search input { padding-inline-start: 34px; min-width: 220px; margin: 0; }
.check { display: flex; align-items: center; gap: 6px; color: var(--text); }
.count-note { padding: 0 6px 16px; font-weight: 600; color: var(--navy); }

.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 16px; background: var(--head); font-size: 13px; font-weight: 700; text-align: right; white-space: nowrap; }
th:first-child { border-start-start-radius: var(--radius); }
th:last-child { border-start-end-radius: var(--radius); }
.toolbar + .table-card th:first-child { border-start-start-radius: 0; }
td { padding: 15px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfe; }
td.empty, p.empty { padding: 44px 16px; text-align: center; color: var(--muted); }
td.actions { white-space: nowrap; }
td.actions form { display: inline-block; margin-inline-end: 12px; }

.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-weight: 500; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-ok i { color: var(--ok); } .status-warn i { color: var(--warn); } .status-bad i { color: var(--bad); }
.status-info i { color: var(--info); } .status-muted i { color: #a7afc0; }
.status-muted { color: var(--muted); }

.site-tag {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; margin: 1px 0; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap;
    background: color-mix(in srgb, var(--c) 11%, #fff); color: color-mix(in srgb, var(--c) 78%, #000);
}
.site-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

.pager { display: flex; justify-content: center; gap: 6px; margin: 18px 0; }
.pager a, .pager span { min-width: 34px; padding: 5px 8px; text-align: center; border-radius: 9px; background: #fff; box-shadow: var(--shadow); font-weight: 500; }
.pager span { background: none; box-shadow: none; }
.pager a.active { background: var(--primary); color: #fff; }

/* ---------- پرونده‌ی مشتری ---------- */
.grid-profile { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.grid-profile > div > .card { margin-bottom: 16px; }
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.profile-head h2 { margin: 0; font-size: 17px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 18px; }
.facts div { padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.facts dt { font-size: 11.5px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-size: 13px; }
.identities { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.identity { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-inline-start: 4px solid var(--c); border-radius: 12px; font-size: 12.5px; color: var(--muted); }
.identity strong { color: var(--text); font-size: 13.5px; }
.note-form { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: start; margin-bottom: 18px; }
.note { padding: 12px 0; border-top: 1px solid var(--line); }
.note header { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.note header strong { color: var(--primary); }

/* ---------- راهنمای وب‌سرویس ---------- */
.docs p { margin-bottom: 12px; }
.docs pre, details pre { margin: 0 0 12px; padding: 14px 16px; border-radius: 12px; background: #141d42; color: #dbe4ff; overflow-x: auto; text-align: left; font-size: 12.5px; line-height: 1.6; }
.docs pre code, details pre code { font-family: Consolas, 'Courier New', monospace; }
table.mini { margin-bottom: 12px; }
table.mini td { padding: 7px 0; font-size: 12.5px; }
table.mini td:first-child { direction: ltr; text-align: left; padding-inline-start: 12px; word-break: break-all; }
details summary { cursor: pointer; color: var(--primary); font-size: 12.5px; }
details pre { margin-top: 8px; max-width: 420px; white-space: pre-wrap; word-break: break-all; }

/* ---------- ورود ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 32px; background: #fff; border-radius: 22px; box-shadow: 0 12px 40px rgba(28, 42, 94, .12); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 20px; }
.login-card .brand.dark { padding-bottom: 6px; }

/* ---------- واکنش‌گرا ---------- */
@media (max-width: 1200px) {
    .kpis { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-profile { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .shell { padding: 10px; }
    .sidebar { position: fixed; inset-block: 10px; inset-inline-start: 10px; z-index: 20; height: auto; transform: translateX(120%); transition: transform .2s; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
    .sidebar.open { transform: none; }
    .menu-btn { display: grid; }
    .user-chip { display: none; }
    .bar-row { grid-template-columns: 90px 1fr; }
    .bar-value { grid-column: 1 / -1; }
    .note-form, .row-2 { grid-template-columns: 1fr; }
    .tabs { margin-inline-start: 0; }
}


/* ---------- تب‌های لینکی و نشان‌ها ---------- */
.tabs a { display: flex; align-items: center; gap: 6px; padding: 10px 16px; margin-bottom: -2px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tabs a.active { color: var(--navy); border-bottom-color: var(--primary); }
.pill { min-width: 22px; padding: 0 7px; border-radius: 20px; background: #e6eaf3; color: var(--navy); font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.8; }
.pill-bad { background: #fde3e3; color: var(--bad); }
.pill-warn { background: #fdf0d8; color: #a86a08; }
.late { color: var(--bad); font-weight: 600; }
.link.danger { color: var(--bad); }
.small { font-size: 12px; }
.footnote { margin: 14px 6px; font-size: 12.5px; color: var(--muted); }
td.wrap { min-width: 260px; max-width: 420px; line-height: 1.8; }
.type-tag { padding: 2px 10px; border-radius: 8px; font-size: 12px; font-weight: 500; background: var(--head); color: var(--primary); white-space: nowrap; }
.type-meeting { background: #efe8fd; color: #6a3fd0; }
.type-message { background: #e3f6ef; color: #0c7a58; }
.type-task { background: #eef1f7; color: #56607a; }
.inline-form { display: inline-flex; align-items: center; gap: 8px; }
.inline-form select, .inline-form input { width: auto; padding: 5px 10px; font-size: 13px; }
.inline-form input[type=password] { width: 120px; }
input[type=time] { width: 100%; padding: 8px 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.topbar-actions form { display: contents; }

/* ---------- قیف فروش ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.kanban-col { flex: 1 0 184px; max-width: 300px; background: #e9edf6; border-radius: var(--radius); border-top: 4px solid var(--c); }
.kanban-col.drag-over { background: #dbe5fa; outline: 2px dashed var(--primary); }
.kanban-col header { padding: 12px 14px 8px; }
.kanban-col header strong { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.kanban-col header strong span { min-width: 24px; padding: 0 7px; border-radius: 20px; background: #fff; font-size: 12px; text-align: center; }
.kanban-col header small { color: var(--muted); font-size: 11.5px; }
.kanban-cards { display: flex; flex-direction: column; gap: 10px; min-height: 90px; padding: 6px 10px 12px; }
.deal { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); cursor: grab; font-size: 12.5px; color: var(--muted); }
.deal:hover { box-shadow: 0 4px 16px rgba(28, 42, 94, .14); }
.deal.dragging { opacity: .45; }
.deal strong { color: var(--text); font-size: 13.5px; line-height: 1.6; }
.deal b { color: var(--navy); font-size: 13.5px; }
.deal footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 11.5px; }
.deal em { font-style: normal; font-size: 11.5px; color: var(--bad); }

/* ---------- پنجره‌ی فرم ---------- */
.dialog { width: min(560px, calc(100vw - 32px)); padding: 24px 26px; border: 0; border-radius: 20px; box-shadow: 0 20px 60px rgba(28, 42, 94, .3); color: var(--text); overflow: visible; }
.dialog::backdrop { background: rgba(20, 29, 66, .45); }
.dialog h2 { font-size: 16px; }
.dialog .form-actions { align-items: center; }
.dialog .form-actions .link { margin-inline-start: auto; }
.lookup { position: relative; display: block; margin-top: 5px; }
.lookup input[type=text] { color: var(--text); font-weight: 400; font-size: 14px; }
.lookup-list { position: absolute; z-index: 5; inset-inline: 0; top: calc(100% + 4px); display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(28, 42, 94, .16); overflow: hidden; }
.lookup-list button { padding: 9px 14px; border: 0; background: none; text-align: right; color: var(--text); cursor: pointer; }
.lookup-list button:hover { background: var(--head); }

/* ---------- رفتار کاربران ---------- */
a.kpi { transition: transform .12s; }
a.kpi:hover { transform: translateY(-2px); }
.kpi-active { outline: 2px solid var(--primary); }
.kpi-icon.tone-ok { background: #e3f6ef; color: var(--ok); }
.kpi-icon.tone-warn { background: #fdf0d8; color: var(--warn); }
.kpi-icon.tone-bad { background: #fde3e3; color: var(--bad); }
.kpi-icon.tone-muted { background: #eef1f7; color: #7c869d; }
.score-cell { white-space: nowrap; }
.score { display: inline-block; width: 84px; height: 8px; margin-inline-end: 8px; border-radius: 8px; background: #eef1f7; overflow: hidden; vertical-align: middle; }
.score i { display: block; height: 100%; border-radius: 8px; }
.score-ok i { background: var(--ok); }
.score-warn i { background: var(--warn); }
.score-bad i { background: var(--bad); }
.behavior-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.behavior-summary { font-size: 13px; line-height: 1.9; margin-bottom: 10px; }
blockquote { margin: 0 0 8px; padding: 8px 12px; border-inline-start: 3px solid var(--bad); background: #fdf5f5; border-radius: 8px; font-size: 12.5px; }
blockquote small { display: block; color: var(--muted); }
.service-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

.chat { border-bottom: 1px solid var(--line); padding: 10px 0; }
.chat:last-of-type { border-bottom: 0; }
.chat summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; color: var(--text); font-size: 13px; }
.chat summary .muted { margin-inline-start: auto; font-size: 12px; }
.chat-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 4px 6px; }
.bubble { max-width: 76%; padding: 9px 14px; border-radius: 14px; font-size: 13px; line-height: 1.8; }
.bubble small { display: block; font-size: 11px; opacity: .65; }
.bubble-customer { align-self: flex-start; background: #eef1f7; border-start-start-radius: 4px; }
.bubble-agent, .bubble-bot { align-self: flex-end; background: var(--primary); color: #fff; border-start-end-radius: 4px; }

/* ---------- کاریزها، شمارنده‌ها، تنظیمات ---------- */
.segmented { display: inline-flex; padding: 3px; margin-bottom: 12px; background: #e3e8f2; border-radius: 11px; }
.segmented a { padding: 6px 20px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--muted); }
.segmented a.active { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.counters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.counter { padding: 12px 16px; background: #fff; border-radius: 14px; box-shadow: var(--shadow); border-inline-start: 4px solid #c8cfdf; }
.counter b { display: block; font-size: 17px; font-weight: 700; }
.counter span { font-size: 12px; color: var(--muted); }
.counter.tone-warn { border-color: var(--warn); } .counter.tone-warn b { color: #b87408; }
.counter.tone-bad { border-color: var(--bad); } .counter.tone-bad b { color: var(--bad); }
.counter.tone-ok { border-color: var(--ok); } .counter.tone-ok b { color: var(--ok); }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
textarea { resize: vertical; }
label > textarea { margin-top: 5px; color: var(--text); font-weight: 400; font-size: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { margin: 0; }
.card-head select { width: auto; }

.grid-settings { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.menu-list { display: flex; flex-direction: column; gap: 4px; }
.menu-list a { padding: 9px 14px; border-radius: 10px; font-weight: 500; color: var(--text); }
.menu-list a:hover { background: var(--bg); }
.menu-list a.active { background: var(--head); color: var(--primary); font-weight: 600; }
.inline-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.inline-row label { flex: 1; min-width: 200px; }
td input[type=text], td select { padding: 6px 10px; font-size: 13px; min-width: 110px; }
input.tiny { width: 64px; min-width: 0; text-align: center; }
input.swatch { width: 44px; height: 32px; padding: 2px; }
tr.row-new td { background: #fafbfe; }
input[type=file] { width: 100%; margin-top: 5px; font-size: 12.5px; color: var(--text); }
input[type=file]::file-selector-button { margin-inline-end: 10px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font: inherit; cursor: pointer; }

/* ---------- پرونده‌ی مشتری: تماس سریع، پیوست، مشکل باز ---------- */
.quick-contact { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 16px; }
.quick-contact a, .quick-contact button { padding: 4px 12px; border: 1px solid var(--line); border-radius: 20px; background: #fff; font-size: 12px; font-weight: 500; color: var(--primary); cursor: pointer; }
.quick-contact a:hover, .quick-contact button:hover { background: var(--head); }
.note-form .file-pick { grid-column: 1 / -1; }
.attachment { display: inline-flex; flex-direction: column; gap: 4px; margin: 8px 0 0 8px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; font-size: 11.5px; color: var(--primary); vertical-align: top; }
.attachment img { display: block; max-width: 180px; max-height: 140px; border-radius: 6px; object-fit: cover; }
.alert-case { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fdeeee; border-color: #f5c8c8; }
.alert-case strong { color: #b23333; }
.alert-case p { font-weight: 400; margin: 2px 0; }
.alert-case small { color: var(--muted); font-weight: 400; }
.nav-badge { margin-inline-start: auto; min-width: 22px; padding: 0 6px; border-radius: 20px; background: var(--bad); color: #fff; font-style: normal; font-size: 11px; font-weight: 600; text-align: center; line-height: 1.7; }
.side-nav a.active .nav-badge { background: var(--bad); }
td .pill { display: inline-block; margin-inline-start: 6px; }

@media (max-width: 1200px) {
    .grid-settings { grid-template-columns: 1fr; }
    .counters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
    .row-3 { grid-template-columns: 1fr; }
}

#fields form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
#fields form button { grid-column: 1 / -1; }

/* ---------- جستجوی سراسری و افزودن سریع ---------- */
.topbar-search { position: relative; flex: 1; max-width: 420px; display: flex; align-items: center; }
.topbar-search > .icon { position: absolute; inset-inline-start: 12px; width: 17px; height: 17px; color: var(--muted); }
.topbar-search input { padding-inline-start: 38px; background: var(--bg); border-color: transparent; }
.topbar-search .lookup-list a, .topbar-search .lookup-list span { display: flex; align-items: center; gap: 10px; padding: 9px 14px; font-size: 13px; }
.topbar-search .lookup-list a:hover { background: var(--head); }
.topbar-search .lookup-list small { flex: none; padding: 1px 8px; border-radius: 20px; background: var(--head); color: var(--primary); font-size: 11px; }
.topbar-search .lookup-list span { color: var(--muted); }
.quick-add { position: relative; }
.quick-add summary { list-style: none; border: 1px solid var(--line); }
.quick-add summary::-webkit-details-marker { display: none; }
.quick-add > div { position: absolute; z-index: 10; inset-inline-end: 0; top: calc(100% + 6px); min-width: 170px; display: flex; flex-direction: column; padding: 6px; background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(28, 42, 94, .18); }
.quick-add a { padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.quick-add a:hover { background: var(--head); color: var(--primary); }

/* ---------- تاریخچه‌ی یکجا ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 78px 1fr auto; gap: 14px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tl-item:last-child { border-bottom: 0; }
.tl-kind { padding: 2px 0; border-radius: 8px; text-align: center; font-size: 11.5px; font-weight: 600; background: #eef1f7; color: #56607a; }
.tl-info .tl-kind { background: var(--head); color: var(--primary); }
.tl-ok .tl-kind { background: #e3f6ef; color: #0c7a58; }
.tl-warn .tl-kind { background: #fdf0d8; color: #a86a08; }
.tl-bad .tl-kind { background: #fde3e3; color: var(--bad); }
.tl-item strong { font-size: 13.5px; font-weight: 600; }
.tl-item p { font-size: 12.5px; color: var(--muted); }
.tl-item time { font-size: 12px; color: var(--muted); white-space: nowrap; }
@media (max-width: 860px) {
    .tl-item { grid-template-columns: 70px 1fr; }
    .tl-item time { grid-column: 2; }
}
/* ---------- اولویت سوم: محصولات، پیامک، فرم عمومی، چاپ ---------- */
.tabs-wrap { flex-wrap: wrap; }
.item-rows { display: flex; flex-direction: column; gap: 8px; }
.item-rows-title { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.item-rows > div { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; margin-top: 8px; }
td textarea { width: 100%; min-width: 280px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.quick-contact button[type=submit] { font: inherit; font-size: 12px; font-weight: 500; }
.team-row { align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.team-row strong { flex: 1; }
.public-card { max-width: 440px; }
.public-card p { line-height: 1.9; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.nps { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; direction: ltr; }
.nps input { position: absolute; opacity: 0; }
.nps span { display: block; padding: 8px 0; border: 1px solid var(--line); border-radius: 8px; text-align: center; font-weight: 600; cursor: pointer; }
.nps input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.nps input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.nps-hint { display: flex; justify-content: space-between; direction: ltr; font-size: 12px; color: var(--muted); margin-top: -8px; }
.cols-pair .pair { display: flex; align-items: flex-end; justify-content: center; gap: 3px; width: 100%; height: 100%; }
.cols-pair .pair i { width: 42%; max-width: 16px; opacity: .85; }
.cols-pair .pair i.won, .legend i.won { background: var(--ok); opacity: 1; }
.cols-pair .col:last-child i:not(.won) { background: var(--primary); }
.legend { margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; margin-inline: 10px 4px; border-radius: 3px; background: var(--primary); vertical-align: middle; }

@media print {
    body { background: #fff; }
    .sidebar, .topbar, .toolbar, .pager, .footnote { display: none !important; }
    .shell { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    .grid-2, .kpis { gap: 8px; }
}
/* ================= گوشی و تبلت ================= */
.cell { display: contents; }
.backdrop { display: none; }
.dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }

@media (max-width: 860px) {
    html { font-size: 14px; }
    .shell { display: block; padding: 8px; }
    .sidebar { width: min(270px, 82vw); inset-block: 8px; inset-inline-start: 8px; }
    .sidebar.open + .backdrop { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(20, 29, 66, .45); }

    /* نوار بالا: عنوان، بعد دکمه‌ها، بعد جستجو در ردیف کامل */
    .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 12px; margin-bottom: 12px; }
    .topbar-title { flex: 1; min-width: 0; }
    .topbar h1 { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
    .topbar-actions > .icon-btn:not(.menu-btn), .topbar-actions > span.icon-btn { display: none; }
    .topbar-actions .btn { padding: 8px 14px; font-size: 13px; }
    .topbar-search { display: flex; order: 3; flex: 1 0 100%; max-width: none; }
    .quick-add summary { width: 36px; height: 36px; }

    /* ورودی‌ها ۱۶ پیکسل تا مرورگر گوشی صفحه را بزرگ نکند */
    input[type=text], input[type=password], input[type=search], input[type=url], input[type=time], select, textarea { font-size: 16px; }
    label > input, label > select, label > textarea, .lookup input[type=text] { font-size: 16px; }

    /* نوار ابزار: تب‌ها افقی اسکرول می‌شوند و فیلترها تمام‌عرض */
    .toolbar { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 10px; margin-bottom: 10px; }
    .toolbar > * { min-width: 0; }
    .grid-profile > *, .grid-2 > *, .grid-settings > *, .kpis > *, .counters > * { min-width: 0; }
    .tabs, .tabs.tabs-wrap { flex-wrap: nowrap; overflow-x: auto; margin-inline-start: 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs a, .tabs button { flex: none; padding: 9px 13px; white-space: nowrap; }
    .segmented { align-self: flex-start; margin-bottom: 0; }
    .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-bottom: 0; }
    .filters select, .filters input[type=search], .filters .btn { width: 100%; min-width: 0; }
    .filters .search, .filters .check { grid-column: 1 / -1; }
    .filters .search input { min-width: 0; width: 100%; }
    .count-note { padding: 0 4px; font-size: 13px; }
    .toolbar + .card { border-start-start-radius: var(--radius); }

    /* کارت‌های آماری دو ستونه و فشرده */
    .kpis { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
    .kpi { padding: 12px; gap: 10px; align-items: flex-start; }
    .kpi-icon { width: 34px; height: 34px; border-radius: 10px; }
    .kpi-icon .icon { width: 17px; height: 17px; }
    .kpi strong { font-size: 16px; }
    .kpi small { font-size: 11.5px; }
    .kpi em { font-size: 10.5px; line-height: 1.5; }
    .counters { gap: 8px; margin-bottom: 12px; }
    .counter { padding: 10px 12px; }
    .counter b { font-size: 15px; }
    .grid-2, .grid-profile, .grid-settings { gap: 12px; margin-bottom: 12px; }
    .card.pad { padding: 16px 14px; }
    .cols { height: 150px; gap: 4px; }
    .col b { font-size: 9.5px; }
    .col small { font-size: 9.5px; }

    /* جدول => کارت: هر ردیف یک کارت دو ستونه، عنوان ستون بالای مقدار */
    .table-card { overflow: visible; background: none; box-shadow: none; border-radius: 0; }
    .table-card table, .table-card tbody { display: block; width: 100%; }
    .table-card thead { display: none; }
    .table-card tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin-bottom: 10px; padding: 8px 14px; background: #fff; border-radius: 14px; box-shadow: var(--shadow); }
    .table-card tbody tr:hover { background: #fff; }
    .table-card td { display: flex; flex-direction: column; gap: 1px; min-width: 0; max-width: none; padding: 7px 0; border-bottom: 0; font-size: 13.5px; white-space: normal; }
    .table-card td::before { content: attr(data-label); color: var(--muted); font-size: 11.5px; line-height: 1.6; }
    .table-card td[data-label=""]::before, .table-card td:not([data-label])::before, .table-card td[data-label="عملیات"]::before { display: none; }
    .table-card td[data-label="ردیف"] { display: none; }
    .table-card td .cell { display: block; min-width: 0; overflow-wrap: anywhere; }
    .table-card td.empty { grid-column: 1 / -1; padding: 24px 8px; text-align: center; }
    /* خانه‌های پهن: متن بلند، فرم و عملیات تمام‌عرض */
    .table-card td.wrap, .table-card td.actions, .table-card td[data-label="عملیات"],
    .table-card td:has(.cell > input), .table-card td:has(.cell > select), .table-card td:has(.cell > textarea), .table-card td:has(.cell > form), .table-card td:has(details) { grid-column: 1 / -1; }
    .table-card td:has(.cell > input.tiny), .table-card td:has(.cell > input.swatch) { grid-column: auto; }
    .table-card td.actions, .table-card td[data-label="عملیات"] { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
    .table-card td.actions .cell, .table-card td[data-label="عملیات"] .cell, .table-card td .cell:has(> form) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
    .table-card td.actions form { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
    .table-card td .link { padding: 4px 0; font-size: 13.5px; }
    .table-card td .cell > input[type=text], .table-card td .cell > select, .table-card td .cell > textarea { width: 100%; min-width: 0; }
    .table-card td textarea { min-width: 0; }
    .table-card td details pre { max-width: 100%; }
    input.tiny, input.swatch { width: 100%; }
    .inline-form { flex-wrap: wrap; }
    table.mini, table.mini tbody, table.mini tr, table.mini td { display: block; }
    table.mini td { padding: 3px 0; }
    /* قیف فروش: ستون‌ها با کشیدن افقی */
    .kanban { gap: 10px; scroll-snap-type: x mandatory; padding-bottom: 10px; margin-inline: -8px; padding-inline: 8px; }
    .kanban-col { flex: 0 0 82vw; max-width: 340px; scroll-snap-align: center; }

    /* پرونده‌ی مشتری */
    .profile-head { margin-bottom: 14px; }
    .avatar.lg { width: 52px; height: 52px; font-size: 22px; }
    .profile .row-2, .dialog .row-2, .dialog .row-3 { grid-template-columns: 1fr 1fr; }
    .identities { grid-template-columns: 1fr; }
    .alert-case { flex-direction: column; align-items: stretch; }
    .alert-case .btn { width: 100%; }
    .note-form { grid-template-columns: 1fr; }
    .bubble { max-width: 90%; }
    .chat summary .muted { margin-inline-start: 0; flex-basis: 100%; }
    .attachment img { max-width: 100%; }
    .behavior-head { flex-wrap: wrap; gap: 8px; }

    /* فرم‌ها و پنجره‌ها */
    .dialog { width: calc(100vw - 16px); max-width: none; padding: 18px 16px; border-radius: 18px; }
    .dialog .form-actions { flex-wrap: wrap; }
    .dialog .form-actions .btn { flex: 1; }
    .form-actions .btn { padding: 10px 16px; }
    .item-rows > div { grid-template-columns: 1fr 76px; }
    .inline-row { flex-direction: column; align-items: stretch; }
    .inline-row label { min-width: 0; }
    .check-grid { grid-template-columns: 1fr 1fr; }
    .menu-list { flex-direction: row; flex-wrap: wrap; }
    .docs pre { font-size: 11.5px; }
    .pager { flex-wrap: wrap; }
    .alert { padding: 10px 14px; overflow-wrap: anywhere; }
    .login-card { padding: 24px 20px; }
    .nps span { padding: 8px 0; font-size: 13px; }
}

@media (max-width: 340px) {
    .filters { grid-template-columns: 1fr; }
    .table-card tbody tr { grid-template-columns: 1fr; }
    .check-grid { grid-template-columns: 1fr; }
    .topbar-actions .btn { padding: 7px 11px; font-size: 12.5px; }
}