/* ════════════════════════════════════════════════════════════════════
   پرونده‌ی ۳۶۰ درجه‌ی مشتری، تقویم جلسات، قراردادها، تیکت‌ها، مرکز پیامک و تنظیمات CRM
   روی theme-vivid.css و deals.css سوار می‌شود (آخرین stylesheet).
   ════════════════════════════════════════════════════════════════════ */

.pre-wrap { white-space: pre-wrap; }
.chip-sm { padding: 2px 9px; font-size: var(--text-xs); }

/* ── تب‌های پرونده و مرکز پیامک ── */
.crm-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: -1px;
    overflow-x: auto;
    scrollbar-width: none;
    position: relative;
    z-index: 1;
}
.crm-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: var(--r-panel) var(--r-panel) 0 0;
    background: transparent;
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.15s ease, background 0.15s ease;
}
.crm-tab:hover { color: var(--ink); background: var(--hover); }
.crm-tab[aria-selected="true"] {
    border-color: var(--line);
    background: var(--surface);
    color: var(--primary);
    box-shadow: inset 0 3px 0 var(--primary);
}
.crm-tab .count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: var(--r-pill);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: var(--text-xs);
    text-align: center;
}
.crm-tab-panel { border-start-start-radius: 0; min-height: 260px; }
.crm-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-3); }

/* ── تایم‌لاین ── */
.timeline { margin: 0; padding: 0; list-style: none; position: relative; }
.timeline::before {
    content: "";
    position: absolute;
    inset-block: 6px;
    inset-inline-start: 15px;
    width: 2px;
    background: var(--line);
}
.timeline-day { position: relative; margin: var(--s-4) 0 var(--s-2); padding-inline-start: 40px; }
.timeline-day:first-child { margin-top: 0; }
.timeline-day span {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--r-pill);
    background: var(--surface-sunken);
    color: var(--ink-2);
    font-size: var(--text-xs);
    font-weight: 700;
}
.timeline-item { position: relative; display: flex; gap: var(--s-3); padding: 6px 0; }
.timeline-dot {
    position: relative;
    z-index: 1;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--tone-soft, var(--surface-sunken));
    color: var(--tone, var(--muted));
    box-shadow: 0 0 0 3px var(--surface);
    font-size: 0.9rem;
}
.timeline-body {
    flex: 1;
    min-width: 0;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    background: var(--surface);
}
.timeline-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); font-size: var(--text-sm); }
.timeline-title a, .timeline-title strong { font-weight: 700; color: var(--ink); }
.timeline-title a:hover { color: var(--primary); }
.timeline-title small { flex-shrink: 0; color: var(--faint); font-size: var(--text-xs); font-variant-numeric: normal; }
.timeline-body p { margin: 2px 0 0; color: var(--ink-2); font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ── مخاطبان ── */
.crm-form { margin-bottom: var(--s-4); padding: var(--s-4); border: 1px dashed var(--primary-line); border-radius: var(--r-panel); background: var(--primary-soft); }
.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-3); }
.contact-card { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
.contact-card.is-primary { border-color: var(--primary-line); box-shadow: inset 3px 0 0 var(--primary); }
.contact-card-head { display: flex; align-items: center; gap: var(--s-2); }
.contact-card-head > div { flex: 1; min-width: 0; }
.contact-card-head strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-card-head small { color: var(--muted); font-size: var(--text-xs); }
.contact-ways { margin: 0; padding: 0; list-style: none; font-size: var(--text-sm); }
.contact-ways li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.contact-ways i { color: var(--faint); }
.contact-notes { margin: 0; color: var(--muted); font-size: var(--text-xs); white-space: pre-wrap; }
.contact-actions { display: flex; gap: 4px; margin-top: auto; }

/* ── جلسات ── */
.meeting-list { display: grid; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
.meeting-row {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3);
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    border-inline-start: 3px solid var(--t-violet);
}
.meeting-row.status-done { border-inline-start-color: var(--t-emerald); }
.meeting-row.status-canceled { border-inline-start-color: var(--line-strong); opacity: 0.7; }
.meeting-date { display: flex; flex-direction: column; min-width: 86px; font-size: var(--text-sm); }
.meeting-date small { color: var(--muted); font-size: var(--text-xs); }
.meeting-main { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; font-size: var(--text-sm); }
.meeting-main small { color: var(--muted); font-size: var(--text-xs); }
.meeting-outcome { margin: 4px 0 0; padding: 4px 8px; border-radius: var(--r-control); background: var(--t-emerald-soft); color: var(--ink-2); font-size: var(--text-xs); }
.meeting-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.meeting-actions .form-control { width: 160px; }
.attendee-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.attendee-pick .chip { display: inline-flex; align-items: center; gap: 6px; }

/* ── تقویم ماهانه ── */
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.cal-nav { display: flex; align-items: center; gap: var(--s-2); }
.cal-nav strong { min-width: 120px; text-align: center; font-size: var(--text-lg); }
.cal-user { width: auto; min-width: 180px; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-4); align-items: start; }
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    background: var(--line);
    gap: 1px;
    overflow: hidden;
}
.cal-head { padding: 8px 4px; background: var(--surface-sunken); color: var(--muted); font-size: var(--text-xs); font-weight: 700; text-align: center; }
.cal-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 104px;
    padding: 6px;
    background: var(--surface);
    cursor: pointer;
    transition: background 0.12s ease;
}
.cal-cell:hover { background: var(--primary-soft); }
.cal-cell:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-cell.is-blank { background: var(--surface-sunken); cursor: default; }
.cal-cell.is-holiday .cal-day { color: var(--danger); }
.cal-cell.is-today .cal-day { background: var(--primary); color: #fff; }
.cal-cell.is-selected { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-day { align-self: flex-start; min-width: 24px; height: 24px; padding: 0 6px; border-radius: var(--r-pill); font-size: var(--text-sm); font-weight: 700; line-height: 24px; text-align: center; }
.cal-event {
    display: block;
    width: 100%;
    padding: 2px 6px;
    border: 0;
    border-radius: 4px;
    background: var(--t-violet-soft);
    color: color-mix(in srgb, var(--t-violet) 80%, #000);
    font-size: 0.6875rem;
    text-align: start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-event.kind-online { background: var(--t-sky-soft); color: color-mix(in srgb, var(--t-sky) 75%, #000); }
.cal-event.kind-phone { background: var(--t-teal-soft); color: color-mix(in srgb, var(--t-teal) 75%, #000); }
.cal-event.status-done { background: var(--t-emerald-soft); color: color-mix(in srgb, var(--t-emerald) 75%, #000); }
.cal-event.status-canceled { background: var(--surface-sunken); color: var(--faint); text-decoration: line-through; }
.cal-more { color: var(--muted); font-size: 0.6875rem; }
.cal-agenda { position: sticky; top: var(--s-4); }

/* ── فایل‌ها ── */
.file-list { display: grid; gap: 6px; margin: var(--s-3) 0 0; padding: 0; list-style: none; }
.file-list li { display: flex; align-items: center; gap: var(--s-3); padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-control); }
.file-list li > div { flex: 1; min-width: 0; }
.file-list a { display: block; overflow: hidden; color: var(--ink); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-list a:hover { color: var(--primary); }
.file-list small { color: var(--muted); font-size: var(--text-xs); }
.file-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-control); background: var(--t-blue-soft); color: var(--t-blue); font-size: 1.1rem; }

/* ── تیکت ── */
.prio { display: inline-block; padding: 1px 8px; border-radius: var(--r-pill); background: var(--surface-sunken); color: var(--ink-2); font-size: var(--text-xs); font-weight: 600; }
.prio-high { background: var(--t-orange-soft); color: color-mix(in srgb, var(--t-orange) 80%, #000); }
.prio-urgent { background: var(--danger-soft); color: var(--danger); }
.prio-low { color: var(--muted); }
.ticket-thread { display: grid; gap: var(--s-2); margin: 0 0 var(--s-3); padding: 0; list-style: none; }
.ticket-msg { padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); font-size: var(--text-sm); }
.ticket-msg.is-internal { border-color: color-mix(in srgb, var(--t-amber) 40%, #fff); background: var(--t-amber-soft); }
.ticket-msg.is-customer { border-color: color-mix(in srgb, var(--t-teal, #0f8b7e) 35%, #fff); background: color-mix(in srgb, var(--t-teal, #0f8b7e) 8%, var(--surface)); }
.ticket-msg.is-system { border: 0; padding: 2px var(--s-2); background: transparent; color: var(--muted); font-size: var(--text-xs); }
.ticket-msg-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-bottom: 4px; }
.ticket-msg-head small { margin-inline-start: auto; }
.ticket-reply { padding-top: var(--s-3); border-top: 1px solid var(--line); }
.stage-pick-btn {
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--ink-2);
    font-size: var(--text-sm);
}
.stage-pick-btn:hover:not(:disabled) { border-color: var(--primary-line); }
.stage-pick-btn[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.stars { display: flex; gap: 4px; }
.star { padding: 0; border: 0; background: none; color: var(--line-strong); font-size: 1.4rem; line-height: 1; transition: transform 0.1s ease; }
.star:hover { transform: scale(1.12); }
.star.on { color: var(--t-amber); }

/* ── قرارداد ── */
.renew-panel { border-color: color-mix(in srgb, var(--t-emerald) 35%, #fff); background: var(--t-emerald-soft); }

/* ── پیامک ── */
.sms-tokens { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.sms-audience { padding: 10px 12px; border-radius: var(--r-control); background: var(--primary-soft); color: var(--primary); font-size: var(--text-sm); }
.sms-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-3); }
.sms-template { padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
.sms-template.is-off { background: var(--surface-sunken); opacity: 0.75; }
.sms-template-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.sms-log td { vertical-align: top; }
.sms-panel-empty { display: flex; gap: var(--s-4); align-items: flex-start; }
.sms-panel-icon { flex: 0 0 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: var(--t-violet-soft); color: var(--t-violet); font-size: 1.5rem; }
.sms-credit { margin-bottom: 4px; }
.sms-credit strong { font-size: var(--text-2xl); }

/* ── تنظیمات: اطلاعات پایه، فیلد سفارشی، API ── */
.lookup-cats { display: flex; flex-direction: column; gap: 2px; padding: var(--s-2); }
.lookup-cat { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 0; border-radius: var(--r-control); background: transparent; color: var(--ink-2); font-size: var(--text-sm); text-align: start; }
.lookup-cat:hover { background: var(--hover); }
.lookup-cat[aria-selected="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.lookup-list { display: grid; gap: 6px; margin: 0 0 var(--s-3); padding: 0; list-style: none; }
.lookup-list li { display: flex; align-items: center; gap: 6px; }
.lookup-no { min-width: 22px; color: var(--faint); font-size: var(--text-xs); text-align: center; }
.lookup-add { max-width: 420px; }
.cf-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.cf-list li { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-control); }
.cf-list li.is-off { background: var(--surface-sunken); opacity: 0.7; }
.cf-main { flex: 1; min-width: 0; }
.cf-main small { display: block; color: var(--muted); font-size: var(--text-xs); }
.cf-form .form-label { font-size: var(--text-sm); }
.api-keys { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.api-keys li { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-control); }
.api-keys li > div { flex: 1; min-width: 0; }
.api-keys li.is-off { background: var(--surface-sunken); opacity: 0.7; }
.api-docs pre { padding: 10px 12px; border-radius: var(--r-control); background: #1e2422; color: #e6f3ec; font-size: var(--text-xs); white-space: pre-wrap; word-break: break-all; }
.api-docs code { font-size: 0.75rem; }
.api-secret input { font-family: ui-monospace, Consolas, monospace; }

/* ── امتیاز به خود در یادداشت روزانه (۱ تا ۱۰) ── */
.self-score { display: flex; flex-direction: column; gap: 6px; margin-top: var(--s-3); }
.self-score-label { font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.self-score-scale { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.self-score-btn {
    --tone: var(--t-blue);
    height: 32px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: var(--text-sm);
    font-weight: 700;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ease-out);
}
.self-score-btn.low, .self-score-badge.low { --tone: #e5484d; }
.self-score-btn.mid, .self-score-badge.mid { --tone: var(--t-amber); }
.self-score-btn.good, .self-score-badge.good { --tone: var(--t-sky); }
.self-score-btn.top, .self-score-badge.top { --tone: var(--t-emerald); }
.self-score-btn:hover { border-color: var(--tone); color: var(--tone); transform: translateY(-1px); }
.self-score-btn[aria-checked="true"] { border-color: var(--tone); background: var(--tone); color: #fff; box-shadow: 0 6px 14px -8px var(--tone); }
.self-score-hint { color: var(--muted); font-size: var(--text-xs); }
.self-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: var(--r-pill);
    background: color-mix(in srgb, var(--tone) 12%, #fff);
    color: color-mix(in srgb, var(--tone) 80%, #000);
    font-size: var(--text-xs);
    font-weight: 700;
    white-space: nowrap;
}
.self-score-badge small { font-weight: 500; opacity: 0.8; }

@media (max-width: 1199.98px) {
    .cal-layout { grid-template-columns: 1fr; }
    .cal-agenda { position: static; }
}
@media (max-width: 767.98px) {
    .cal-cell { min-height: 64px; padding: 3px; }
    .cal-event { padding: 1px 3px; font-size: 0.625rem; }
    .cal-event .num { display: none; }
    .meeting-row { flex-wrap: wrap; }
    .meeting-actions { width: 100%; }
}

/* پلن قیمت ۱۴۰۵: مصرف اشتراک، فرم وب، پورتال مشتری و خودکارسازی */
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-3); }
.usage-item { display: flex; flex-direction: column; gap: 4px; padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-panel); }
.usage-item .usage-label { color: var(--muted); font-size: var(--text-sm); }
.usage-item strong { font-size: 1.15rem; }
.usage-item strong small { font-size: .75rem; color: var(--muted); font-weight: 400; }
.usage-item .progress { height: 6px; }
.usage-compact { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); margin-bottom: var(--s-3);
    border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); font-size: var(--text-sm); }
.usage-compact.is-low { border-color: color-mix(in srgb, var(--t-amber) 45%, #fff); background: var(--t-amber-soft); }
.usage-compact.is-out { border-color: color-mix(in srgb, #d63c3c 45%, #fff); background: #fdecec; }
.webform-card.is-off { opacity: .7; }
.webform-card details summary { cursor: pointer; color: var(--muted); }
.portal-links { border-top: 1px dashed var(--line); padding-top: var(--s-3); }
.automation-runs li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.automation-runs li:last-child { border-bottom: 0; }
.issue-seats { max-width: 160px; }

/* ── پیوست تسک و گزارش روزانه (WorkFilePicker / WorkFileLinks) ── */
.work-file-picker { margin-top: 4px; }
.work-file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
.work-file-chips li { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 4px 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2, transparent); font-size: .8rem; }
.work-file-chips .name { overflow: hidden; max-width: 220px; text-overflow: ellipsis; white-space: nowrap; }
.work-file-chips small { color: var(--muted, #6b7280); }
.work-file-links { margin-top: 4px; }
.work-file-links ul { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 2px 0 0; padding: 0; list-style: none; }
.work-file-links li { display: inline-flex; align-items: baseline; gap: 4px; font-size: .82rem; }
.work-file-links a { color: var(--primary); font-weight: 600; text-decoration: none; }
.work-file-links a:hover { text-decoration: underline; }
.work-file-links small { color: var(--muted, #6b7280); }
.management-areas { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-control); }
.management-area-group + .management-area-group { margin-top: 8px; }
