/* =====================================================================
   ARS-X 2.4 — CRM в классическом виде, карточка компании, кабинет заказчика,
   тарифы и обмен с 1С. Подключается после arsx23.css.
   ===================================================================== */

/* без отраслевого модуля «Строительство» объекты в CRM не показываются */
html.no-industry [data-industry] { display: none !important; }

/* ------------------------------------------------ вкладки CRM (как в Битрикс24) */
.crm-tabs { display: flex; align-items: flex-end; gap: 2px; margin: -6px 0 14px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.crm-tabs::-webkit-scrollbar { display: none; }
.crm-tab { position: relative; display: inline-flex; align-items: center; gap: 5px; padding: 10px 14px 11px; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; border-radius: 8px 8px 0 0; }
.crm-tab:hover { color: var(--text); background: var(--surface-2); }
.crm-tab.active { color: var(--text); }
.crm-tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--brand); }
.crm-tab .chev { width: 13px; height: 13px; }
.crm-tab.open { color: var(--text); background: var(--surface-2); }
.crm-more { position: relative; }
.crm-more-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; min-width: 300px; padding: 6px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); animation: arsxPop .12s ease-out; }
.crm-more-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 13.5px; text-align: left; }
.crm-more-menu button .ico { width: 16px; height: 16px; color: var(--muted); }
.crm-more-menu button:hover { background: var(--surface-2); }
.crm-tabs-slot { display: block; }

.crm-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.search-input.wide { flex: 1 1 340px; max-width: 560px; }
.crm-total { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.crm-table td { vertical-align: middle; }
.crm-table table { min-width: 720px; }
.crm-table { overflow-x: auto; }
.cell-person { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.cell-person > span:not(.badge):not(.mini-avatar):not(.company-mark) { display: grid; min-width: 0; }
.cell-person b { font-weight: 620; }
.cell-person small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.cell-person .badge { margin-left: 4px; }
.company-mark { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--brand); font-weight: 700; font-size: 12px; }
.company-mark .ico { width: 16px; height: 16px; }
.company-mark.big { width: 46px; height: 46px; flex-basis: 46px; border-radius: 12px; font-size: 16px; }
.crm-table .mini-avatar { width: 32px; height: 32px; font-size: 12px; flex: 0 0 32px; }

/* формы React-окон */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .field-label small { font-weight: 500; color: var(--muted); }
.check-line { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--text-2); }
.check-line input { width: 16px; height: 16px; min-height: 0; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* --------------------------------------------------------- карточка компании */
.company-head { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.company-title { font-size: 24px; font-weight: 720; letter-spacing: -0.02em; line-height: 1.2; }
.company-stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.company-stats div { display: grid; }
.company-stats b { font-size: 17px; font-weight: 720; font-variant-numeric: tabular-nums; }
.company-stats span { font-size: 12px; color: var(--muted); }
.company-stats .warn b { color: var(--warning); }
.contact-card.clickable { cursor: pointer; border-radius: 10px; transition: background-color .12s; }
.contact-card.clickable:hover { background: var(--surface-2); }
.contact-name b .badge { margin-left: 6px; font-size: 10.5px; }
.deal-row { display: grid !important; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.deal-row > span:not(.badge) { min-width: 0; overflow: hidden; }
.kv a { color: var(--brand); }

/* кабинет заказчика в карточке */
.portal-panel .card-head { margin-bottom: 6px; }
.portal-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.portal-actions .link-button { font-size: 12.5px; }
.portal-issued { display: grid; gap: 14px; }
.portal-code { display: grid; gap: 2px; padding: 14px; border-radius: 12px; background: var(--accent-softer); border: 1px dashed var(--accent-line); text-align: center; }
.portal-code span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.portal-code b { font-size: 30px; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.portal-code small { font-size: 12px; color: var(--muted); }
.link-edit { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr) 28px; gap: 6px; margin-top: 6px; align-items: center; }
.link-edit input { min-height: 34px; padding: 5px 9px; font-size: 13px; }

/* ------------------------------------------------------------ тариф и оплата */
.plan-current { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 18px; }
.plan-current .plan-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.plan-current h2 { margin: 2px 0 6px; font-size: 24px; }
.plan-current p { margin: 8px 0 0; color: var(--text-2); }
.plan-current.st-expired { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.plan-current.st-trial { border-color: color-mix(in srgb, var(--warning) 35%, var(--line)); }
.plan-usage { min-width: 220px; display: grid; gap: 4px; }
.plan-usage span { font-size: 12.5px; color: var(--muted); }
.plan-usage b { font-size: 20px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 14px; }
.plan-card { display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.plan-card.current { border-color: var(--accent-line); background: linear-gradient(180deg, var(--accent-softer), var(--surface) 55%); }
.plan-card h3 { margin: 0; font-size: 17px; }
.plan-price { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; }
.plan-price small { font-size: 14px; color: var(--muted); font-weight: 500; }
.plan-card p { margin: 0; color: var(--text-2); font-size: 13.5px; }
.plan-card .btn, .plan-card .badge { margin-top: auto; align-self: flex-start; }

/* ------------------------------------------------------------------- 1С */
.onec-tab { display: grid; gap: 14px; }
.onec-tab .billing-settings { max-width: none; }
.onec-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.onec-actions .card { display: grid; gap: 8px; align-content: start; }
.onec-actions .card .btn { justify-self: start; }
.form-row.cols-2 .span-2 { grid-column: 1 / -1; }

/* задачи в узких колонках карточек: срок под названием, без наложения */
.deal-side .task-list.compact .task-row { grid-template-columns: auto minmax(0, 1fr); row-gap: 2px; }
.deal-side .task-list.compact .task-due { grid-column: 2; padding-top: 0; white-space: normal; }
.plan-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
