/* [telephony] Телефония: экран подключения, журнал звонков, карточка «Звонит…», меню «Позвонить»
   и запись о звонке в ленте. Только то, чего нет в app.css и crm.css; цвета и шрифты —
   переменные кабинета. Сначала компьютер, ниже — планшет и телефон. */

.tel-ic { display: inline-block; vertical-align: -.16em; flex: none; }
.tel-fine { font-size: 12.5px; color: var(--ink-faint); line-height: 1.5; }
.tel-p { font-size: 14px; color: var(--ink-dim); line-height: 1.55; margin: 0 0 12px; max-width: 760px; }
.tel-lead { margin: -14px 0 18px; max-width: 760px; font-size: 14px; line-height: 1.55; color: var(--ink-dim); }

/* ---------- экран подключения ---------- */
.tel-sec { padding: 18px 20px; margin-bottom: 14px; }
.tel-sec h3 { font-family: var(--disp); font-size: 17px; font-weight: 600; margin: 0 0 10px; display: flex;
  align-items: center; gap: 10px; flex-wrap: wrap; }
.tel-sec__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tel-acts { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.tel-sec > .tel-acts { margin-top: 14px; }
.tel-state { font-family: var(--body); font-size: 12px; font-weight: 700; border-radius: 99px; padding: 2px 10px;
  background: var(--surface-sunken); color: var(--ink-dim); border: 1px solid var(--line); white-space: nowrap; }
.tel-state.ok { background: #ECFAF1; color: #17713F; border-color: #BFE8D0; }
.tel-state.wait { background: #FFF6E5; color: #7A4B00; border-color: #F3D9A4; }
.tel-note { border-radius: 10px; padding: 10px 14px; font-size: 13.5px; line-height: 1.5; margin: 0 0 12px;
  background: var(--surface-sunken); color: var(--ink-dim); border: 1px solid var(--line); }
.tel-note.warn { background: #FFF6E5; color: #7A4B00; border-color: #F3D9A4; }
.tel-note.ok { background: #ECFAF1; color: #17603A; border-color: #BFE8D0; }
#tel-set > .tel-note { margin-bottom: 14px; }
.tel-hint { border: 1px dashed var(--line-bright); border-radius: 12px; padding: 16px 16px; color: var(--ink-dim);
  font-size: 13.5px; line-height: 1.5; }
.tel-list-plain { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; line-height: 1.5;
  color: var(--ink-dim); max-width: 780px; }
.tel-list-plain b { color: var(--ink); }

.tel-provs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; margin-bottom: 14px; }
.tel-prov { border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column;
  gap: 8px; background: var(--bg-raise); }
.tel-prov b { font-size: 15.5px; }
.tel-prov p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-dim); flex: 1; }
.tel-prov .btn-amber { align-self: flex-start; margin-top: 4px; }

.tel-copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; margin-bottom: 12px; }
.tel-copy > span { grid-column: 1 / -1; font-size: 12px; color: var(--ink-dim); }
.tel-copy code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-sunken); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 12px; overflow-wrap: anywhere; user-select: all; min-width: 0; }
#tel-rotate { min-height: 34px; }
.tel-steps { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.tel-steps summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--accent); min-height: 30px; }
.tel-steps ol { margin: 10px 0 0; padding-left: 22px; display: grid; gap: 9px; font-size: 14px; line-height: 1.55;
  color: var(--ink-dim); max-width: 820px; }
.tel-steps li b { color: var(--ink); }

.tel-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px 14px;
  align-items: start; margin-bottom: 4px; }
.tel-fields[hidden], .tel-f[hidden] { display: none; }
.tel-f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tel-f.full { grid-column: 1 / -1; }
.tel-f > span { font-size: 12px; color: var(--ink-dim); }
.tel-f > span i { font-style: normal; color: var(--ink-faint); }
.tel-f input, .tel-f select, .tel-f textarea { width: 100%; background: var(--surface-sunken); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; font-family: var(--body); font-size: 14px; color: var(--ink); outline: none; min-height: 40px; }
.tel-f textarea { font-family: var(--mono); font-size: 13px; resize: vertical; line-height: 1.45; }
.tel-f input:focus, .tel-f select:focus, .tel-f textarea:focus { border-color: var(--accent); background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(10,77,166,.12); }
.tel-f small { font-size: 12px; color: var(--ink-faint); line-height: 1.45; }
.tel-check { display: flex; align-items: center; gap: 9px; font-size: 14px; padding: 6px 0 10px; cursor: pointer; min-height: 34px; }
.tel-check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }

.tel-ext { display: grid; gap: 8px; margin-bottom: 4px; }
.tel-ext__head, .tel-ext__row { display: grid; grid-template-columns: 130px minmax(0, 1fr) minmax(0, 1.2fr) 40px; gap: 8px; align-items: center; }
.tel-ext__head { font-size: 12px; color: var(--ink-dim); }
.tel-ext__row .crm-input, .tel-ext__row .crm-select { width: 100%; min-width: 0; }

.tel-journal { display: grid; }
.tel-jrow { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.tel-jrow:last-child { border-bottom: none; }
.tel-jrow time { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.tel-jrow div { min-width: 0; display: flex; flex-direction: column; }
.tel-jrow div span { color: var(--ink-dim); overflow-wrap: anywhere; }
.tel-jrow i { font-style: normal; font-size: 12px; font-weight: 700; color: var(--green); white-space: nowrap; }
.tel-jrow.duplicate i, .tel-jrow.ignored i { color: var(--ink-faint); }
.tel-jrow.rejected i, .tel-jrow.error i { color: var(--red); }

/* ---------- журнал звонков ---------- */
.tel-switch { display: inline-flex; gap: 2px; background: var(--bg-card); border: 1px solid var(--line-bright);
  border-radius: 10px; padding: 3px; margin: 0 0 14px; }
.tel-switch a { font-size: 13px; font-weight: 700; color: var(--ink-dim); padding: 7px 14px; border-radius: 7px; white-space: nowrap; }
.tel-switch a:hover { color: var(--ink); }
.tel-switch a.on { background: var(--navy); color: #fff; }

.tel-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tel-tools #tel-q { flex: 1; min-width: 180px; max-width: 320px; }
.tel-pills { display: flex; gap: 2px; background: var(--bg-card); border: 1px solid var(--line-bright); border-radius: 10px;
  padding: 3px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tel-pills::-webkit-scrollbar { display: none; }
.tel-pills button { border: none; background: none; font-size: 13px; font-weight: 700; color: var(--ink-dim);
  padding: 7px 12px; border-radius: 7px; white-space: nowrap; min-height: 32px; }
.tel-pills button.on { background: var(--navy); color: #fff; }
.tel-own { display: inline-flex; gap: 8px; align-items: center; }
.tel-own[hidden], .tel-tools select[hidden] { display: none; }

.tel-sums { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.tel-sum { background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; min-width: 0; }
.tel-sum span { display: block; font-size: 12px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tel-sum b { font-family: var(--mono); font-size: 18px; font-weight: 600; white-space: nowrap; }
.tel-sum.is-bad b { color: var(--red); }

.tel-list { padding: 4px 18px; }
.tel-load { padding: 40px 16px; text-align: center; color: var(--ink-faint); font-size: 13.5px; }
.tel-more { text-align: center; padding: 12px 0 14px; }
.tel-row { display: grid; grid-template-columns: 34px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1.1fr) 104px;
  gap: 4px 14px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.tel-list.has-acts .tel-row { grid-template-columns: 34px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1.1fr) 104px 214px; }
.tel-list:not(.has-acts) .tel-row__acts { display: none; }
.tel-row:last-of-type { border-bottom: none; }
.tel-row__ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--client-soft); color: var(--accent); }
.tel-row.is-bad .tel-row__ic { background: #FEF1F0; color: var(--red); }
.tel-row.is-dim .tel-row__ic { background: var(--surface-sunken); color: var(--ink-faint); }
.tel-row.is-live .tel-row__ic { background: #ECFAF1; color: var(--green); }
.tel-row__main { min-width: 0; }
.tel-row__who { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.tel-row__who a { color: inherit; }
.tel-row__who a:hover { color: var(--accent); }
.tel-row__sub { font-size: 12.5px; color: var(--ink-dim); display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 1px; }
.tel-row__sub a { color: var(--accent); font-weight: 600; overflow-wrap: anywhere; }
.tel-num { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.tel-tag { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 700; color: #17713F; background: #ECFAF1;
  border-radius: 99px; padding: 1px 8px; vertical-align: 1px; white-space: nowrap; }
.tel-row__res { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.35; }
.tel-row__res b { font-weight: 600; }
.tel-row__res span { color: var(--ink-dim); font-family: var(--mono); font-size: 12px; }
.tel-row.is-bad .tel-row__res b { color: var(--red); }
.tel-row__staff { font-size: 13px; color: var(--ink-dim); min-width: 0; overflow-wrap: anywhere; display: flex; flex-direction: column; }
.tel-row__when { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
.tel-row__acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.tel-btn { padding: 6px 10px; font-size: 12.5px; white-space: nowrap; }
.tel-row__rec { grid-column: 2 / -1; }
.tel-row__rec:empty { display: none; }
.tel-audio { display: block; width: min(100%, 420px); height: 40px; margin-top: 6px; }

/* ---------- запись о звонке в ленте сделки и клиента ---------- */
.crm-ev.tel-ev .tel-ev__ic { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px;
  margin-right: 7px; vertical-align: -5px; background: var(--client-soft); color: var(--accent); }
.tel-ev__acts { margin-left: 32px; }
.crm-ev.tel-ev.is-missed .tel-ev__ic { background: #FEF1F0; color: var(--red); }
.crm-ev.tel-ev.is-missed .txt { color: var(--red); font-weight: 600; }
.crm-ev.tel-ev.is-failed .tel-ev__ic { background: var(--surface-sunken); color: var(--ink-faint); }
.tel-ev__acts { margin-top: 6px; }
.tel-play { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-bright); background: var(--bg-card);
  color: var(--accent); font-size: 12.5px; font-weight: 700; border-radius: 99px; padding: 5px 12px; min-height: 32px; }
.tel-play:hover { border-color: var(--accent); }
.tel-play[hidden] { display: none; }

/* ---------- меню «Позвонить» у номера телефона ---------- */
.tel-menu { position: fixed; z-index: 97; width: min(300px, calc(100vw - 16px)); background: var(--bg-card);
  border: 1px solid var(--line-bright); border-radius: 13px; box-shadow: 0 14px 36px rgba(16,24,40,.2); padding: 6px; }
.tel-menu__num { font-family: var(--mono); font-size: 12.5px; color: var(--ink-faint); padding: 6px 10px 4px; }
.tel-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: none; background: none;
  border-radius: 9px; padding: 9px 10px; color: var(--ink); font-size: 14px; min-height: 44px; }
.tel-menu button:hover, .tel-menu button:focus-visible { background: var(--surface-sunken); outline: none; }
.tel-menu button span { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.tel-menu button b { font-weight: 600; }
.tel-menu button i { font-style: normal; font-size: 12px; color: var(--ink-faint); }
.tel-menu__go .tel-ic { color: var(--green); }

/* ---------- карточка «Звонит…» ---------- */
.tel-pop { position: fixed; right: 18px; bottom: 18px; z-index: 94; display: grid; gap: 10px; width: min(360px, calc(100vw - 24px));
  pointer-events: none; }
.tel-card { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; background: var(--bg-card);
  border: 1px solid var(--line-bright); border-left: 4px solid var(--green); border-radius: 14px; padding: 13px 12px 13px 14px;
  box-shadow: 0 16px 40px rgba(16,24,40,.22); animation: tel-in .22s both; }
.tel-card.is-talk { border-left-color: var(--accent); }
@keyframes tel-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.tel-card__ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: #ECFAF1; color: var(--green); animation: tel-ring 1.4s ease-in-out infinite; }
.tel-card.is-talk .tel-card__ic { background: var(--client-soft); color: var(--accent); animation: none; }
@keyframes tel-ring { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-12deg); } 20% { transform: rotate(12deg); }
  30% { transform: rotate(-8deg); } 40% { transform: rotate(8deg); } 50% { transform: rotate(0); } }
.tel-card__body { flex: 1; min-width: 0; }
.tel-card__head { font-size: 12px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }
.tel-card__who { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; line-height: 1.3; margin-top: 1px; }
.tel-card__sub { font-size: 12.5px; color: var(--ink-dim); overflow-wrap: anywhere; margin-top: 2px; }
.tel-card__go { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; font-size: 13.5px; font-weight: 700;
  color: var(--accent); min-height: 32px; }
.tel-card__x { border: none; background: none; color: var(--ink-faint); width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; flex: none; margin: -6px -4px 0 0; }
.tel-card__x:hover { background: var(--surface-sunken); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .tel-card, .tel-card__ic { animation: none; } }

/* ---------- планшет ---------- */
@media (max-width: 1100px) {
  .tel-sums { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tel-row, .tel-list.has-acts .tel-row { grid-template-columns: 34px minmax(0, 1.5fr) minmax(0, 1fr) 96px; }
  .tel-list.has-acts .tel-row { grid-template-columns: 34px minmax(0, 1.5fr) minmax(0, 1fr) 96px 214px; }
  .tel-row__staff { grid-column: 2 / 4; grid-row: 2; flex-direction: row; gap: 10px; font-size: 12.5px; }
}

/* ---------- телефон ---------- */
@media (max-width: 640px) {
  .tel-lead { margin-top: -6px; }
  .tel-sec { padding: 15px 14px; }
  .tel-sec__head { flex-direction: column; align-items: stretch; }
  .tel-acts .crm-btn, .tel-acts .btn-amber { min-height: 40px; }
  .tel-copy { grid-template-columns: minmax(0, 1fr); }
  .tel-copy .crm-btn { justify-self: start; min-height: 40px; }
  .tel-ext__head { display: none; }
  .tel-ext__row { grid-template-columns: 92px minmax(0, 1fr) 44px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .tel-ext__row [data-x="user_id"] { grid-column: 1 / 3; grid-row: 2; }
  .tel-ext__row [data-del] { grid-row: 1 / 3; align-self: start; min-height: 40px; }
  .tel-jrow { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; }
  .tel-jrow time { grid-column: 1 / -1; }

  .tel-switch { display: flex; }
  .tel-switch a { flex: 1; text-align: center; padding: 9px 8px; }
  .tel-tools { gap: 8px; }
  .tel-tools #tel-q { max-width: none; flex-basis: 100%; order: 5; }
  .tel-tools .crm-select { flex: 1; min-width: 0; }
  .tel-pills { flex-basis: 100%; }
  .tel-pills button { flex: 1; min-height: 38px; padding: 7px 8px; }
  .tel-own { flex-basis: 100%; }
  .tel-own .crm-input { flex: 1; min-width: 0; }
  .tel-sums { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tel-sum { padding: 9px 12px; }
  .tel-sum b { font-size: 16px; }
  .tel-list { padding: 2px 12px; }
  .tel-row, .tel-list.has-acts .tel-row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 3px 10px; align-items: start; }
  .tel-row__main { grid-column: 2; }
  .tel-row__when { grid-column: 3; grid-row: 1; text-align: right; padding-top: 2px; }
  .tel-row__res { grid-column: 2 / -1; grid-row: 2; flex-direction: row; gap: 8px; align-items: baseline; }
  .tel-row__staff { grid-column: 2 / -1; grid-row: 3; }
  .tel-row__acts { grid-column: 2 / -1; grid-row: 4; justify-content: flex-start; margin-top: 4px; }
  .tel-row__acts .tel-btn { min-height: 38px; padding: 8px 12px; }
  .tel-row__rec { grid-column: 1 / -1; }
  .tel-play { min-height: 36px; }

  /* карточка звонка — над нижней панелью разделов */
  .tel-pop { right: 12px; left: 12px; width: auto; bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
}
