/* Мой этап: «парящая» карточка контактов в стиле mainV2 */
.tms {
  --tms-tg: #2AABEE;
  --tms-tg-dark: #1e96d1;
  --tms-link: #229ED9;
  position: relative;
  z-index: 2;
  margin: 6px 0 12px;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px 12px;
  font-family: var(--mv2-font, 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
  color: var(--mv2-text, #1F1F1F);
  background: var(--mv2-card, #fff);
  border: 0.5px solid var(--mv2-border, rgba(31, 31, 31, 0.08));
  border-radius: var(--mv2-r-xl, 14px);
  box-shadow:
    0 10px 28px rgba(31, 31, 31, 0.08),
    0 2px 6px rgba(31, 31, 31, 0.04);
}

/* Свёрнуто: без «двойной рамки»; высота как у полоски «Отбор» */
.tms:not(.tms--open) {
  margin: 0 0 8px;
  max-width: 100%;
  width: 100%;
  padding: 0;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.tms:not(.tms--open).tms--needs-ack .tms__fold-head,
.tms:not(.tms--open).tms--flash .tms__fold-head {
  box-shadow: 0 0 0 3px rgba(183, 224, 0, 0.55);
}

.tms:not(.tms--open).tms--flash .tms__fold-head {
  box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.28);
}

.tms--flash {
  box-shadow:
    0 0 0 3px rgba(42, 171, 238, 0.28),
    0 10px 28px rgba(31, 31, 31, 0.08);
  transition: box-shadow 0.3s ease;
}

.tms--needs-ack {
  box-shadow:
    0 0 0 3px rgba(183, 224, 0, 0.55),
    0 10px 28px rgba(31, 31, 31, 0.08);
}

.tms__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 4px;
}

/* Сворачиваемая секция контактов */
.tms__fold-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 0.5px solid rgba(107, 142, 0, 0.28);
  background: var(--mv2-accent-soft, #F5FBEA);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  float: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

/*
 * Свёрнуто: высота и вид как у полоски «Отбор» (.tos-public__me--compact / --in)
 */
.tms:not(.tms--open) .tms__fold-head {
  padding: 7px 10px;
  gap: 0;
  border-radius: 8px;
  border: 1px solid #9bc49f;
  background: #eef7ef;
}
.tms:not(.tms--open) .tms__fold-head:hover {
  background: #e5f0e5;
  border-color: #9fc49a;
  filter: none;
}
.tms:not(.tms--open) .tms__fold-top {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 10px;
  width: 100%;
}
.tms:not(.tms--open) .tms__badge {
  flex: 0 0 auto;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--mv2-text, #1F1F1F);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
}
.tms:not(.tms--open) .tms__fold-preview {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  color: #5c6554;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tms:not(.tms--open) .tms__fold-toggle {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
  gap: 5px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #3d6b45;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
}
.tms:not(.tms--open) .tms__fold-toggle::after {
  display: none;
}
.tms__fold-chevron {
  display: none;
}
.tms:not(.tms--open) .tms__fold-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid #8fb896;
  background: #e8f3ea;
  color: #1f5a2c;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.tms--open .tms__fold-chevron {
  display: none;
}
@media (max-width: 420px) {
  .tms:not(.tms--open) .tms__fold-toggle-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
}

.tms__fold-head:hover {
  background: #eef6c8;
  border-color: rgba(107, 142, 0, 0.4);
}

.tms--open .tms__fold-head {
  background: transparent;
  border-color: transparent;
  padding: 0 0 8px;
}

.tms--open .tms__fold-head:hover {
  background: transparent;
}

.tms__fold-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px 10px;
  width: auto;
  max-width: 100%;
}

.tms__fold-preview {
  display: block;
  max-width: 100%;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--mv2-text, #1F1F1F);
}

.tms--open .tms__fold-preview {
  display: none;
}

.tms__deadline {
  font-size: 12px;
  color: var(--mv2-secondary, #6F6F6F);
  white-space: nowrap;
}

.tms--open .tms__deadline {
  font-size: 13px;
  color: var(--mv2-text, #1F1F1F);
}

.tms__fold-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  background: #B7E000;
  border: 0.5px solid rgba(107, 142, 0, 0.35);
  color: #1F1F1F;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.tms__fold-toggle::after {
  content: '';
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.tms--open .tms__fold-toggle {
  background: #fff;
  border-color: var(--mv2-border, rgba(31, 31, 31, 0.12));
  color: var(--mv2-secondary, #6F6F6F);
  font-weight: 700;
}

.tms--open .tms__fold-toggle::after {
  margin-top: 1px;
  transform: rotate(-135deg);
}

.tms__fold-body {
  padding-top: 2px;
}

.tms__fold-body[hidden] {
  display: none !important;
}

.tms:not(.tms--open) .tms__badge {
  background: #fff;
}

.tms__badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: var(--mv2-r-pill, 20px);
  background: var(--mv2-accent-soft, #F5FBEA);
  color: var(--mv2-win-text, #4A6600);
  border: 0.5px solid rgba(107, 142, 0, 0.22);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.tms__stage-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin: 0 0 2px;
  font-size: 14px;
  line-height: 1.3;
  color: var(--mv2-text, #1F1F1F);
}

.tms__stage {
  font-weight: 700;
}

.tms__hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--mv2-secondary, #6F6F6F);
}

.tms__cue {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--mv2-secondary, #6F6F6F);
}

.tms__list {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tms__row {
  padding: 12px;
  background: var(--mv2-bg, #F4F5F6);
  border: 0.5px solid var(--mv2-border, rgba(31, 31, 31, 0.08));
  border-radius: var(--mv2-r-md, 10px);
}

.tms__opp {
  min-width: 0;
}

.tms__opp + .tms__opp {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 0.5px solid var(--mv2-border, rgba(31, 31, 31, 0.08));
}

.tms__opp-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  margin-bottom: 8px;
}

.tms__opp-index {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--mv2-secondary, #6F6F6F);
}

.tms__opp-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--mv2-text-name, #2C2C2C);
  text-decoration: none;
}

a.tms__opp-name:hover {
  color: var(--mv2-accent-dark, #6B8E00);
  text-decoration: underline;
}

.tms__opp-meta {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--mv2-secondary, #6F6F6F);
}

.tms__row-deadline {
  margin-left: auto;
  font-size: 12px;
  color: var(--mv2-secondary, #6F6F6F);
}

/* Каналы связи — TG компактный; тел/email скрыты */
.tms__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.tms__ch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  padding: 7px 12px;
  border-radius: var(--mv2-r-md, 10px);
  border: 0.5px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  color: var(--mv2-text, #1F1F1F);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tms__ch i {
  flex: 0 0 auto;
  font-size: 16px;
  line-height: 1;
}

.tms__ch-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tms__ch--tg {
  background: var(--tms-tg);
  color: #fff;
}

.tms__ch--tg:hover {
  background: var(--tms-tg-dark);
  color: #fff;
  text-decoration: none;
}

.tms__private {
  margin-top: 8px;
}

.tms__private-summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  list-style: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--tms-link);
  padding: 2px 0;
  user-select: none;
}

.tms__private-summary::-webkit-details-marker {
  display: none;
}

.tms__private-summary::after {
  content: '▸';
  font-weight: 400;
  color: var(--mv2-muted, #A0A0A0);
  margin-left: 2px;
}

.tms__private[open] .tms__private-summary::after {
  content: '▾';
}

.tms__private-summary i {
  font-size: 14px;
}

.tms__private-body {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tms__ch--phone,
.tms__ch--mail,
.tms__ch--tg-alt {
  background: #fff;
  border-color: rgba(42, 171, 238, 0.35);
  color: var(--tms-link);
}

.tms__ch--phone:hover,
.tms__ch--mail:hover,
.tms__ch--tg-alt:hover {
  background: rgba(42, 171, 238, 0.08);
  border-color: var(--tms-tg);
  color: var(--tms-tg-dark);
  text-decoration: none;
}

.tms__ch--phone i,
.tms__ch--mail i,
.tms__ch--tg-alt i {
  color: var(--tms-tg);
}

.tms__private-hint {
  flex: 1 1 100%;
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--mv2-muted, #A0A0A0);
}

.tms__ch--max,
.tms__ch--msg,
.tms__ch--profile {
  background: #fff;
  border-color: var(--mv2-border, rgba(31, 31, 31, 0.12));
  color: var(--mv2-text, #1F1F1F);
}

.tms__ch--msg:hover,
.tms__ch--profile:hover {
  border-color: var(--mv2-accent-dark, #6B8E00);
  text-decoration: none;
}

.tms__ch--max {
  cursor: default;
}

.tms__links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 8px;
}

.tms__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--mv2-secondary, #6F6F6F);
  text-decoration: none;
}

.tms__link--inline {
  margin: 0;
}

.tms__link i {
  font-size: 14px;
}

.tms__link:hover {
  color: var(--mv2-accent-dark, #6B8E00);
  text-decoration: underline;
}

.tms__more {
  margin: 8px 0 0;
  border-top: 0.5px solid var(--mv2-border, rgba(31, 31, 31, 0.08));
  padding-top: 6px;
}

.tms__more-summary {
  cursor: pointer;
  list-style: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--mv2-accent-dark, #6B8E00);
  padding: 4px 0;
  user-select: none;
}

.tms__more-summary::-webkit-details-marker {
  display: none;
}

.tms__more-summary::before {
  content: '▸ ';
  font-weight: 400;
  color: var(--mv2-muted, #A0A0A0);
}

.tms__more[open] .tms__more-summary::before {
  content: '▾ ';
}

.tms__more-body {
  padding: 8px 0 2px;
}

.tms__more-body p {
  margin: 0 0 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--mv2-secondary, #6F6F6F);
  letter-spacing: 0;
}

.tms__more-ps {
  color: var(--mv2-muted, #A0A0A0) !important;
  font-style: normal;
  font-size: 12px !important;
}

/* Blocking ack modal - в стиле mainV2 (--mv2-*) */
.tms-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(31, 31, 31, 0.55);
  box-sizing: border-box;
}

.tms-modal[hidden] {
  display: none !important;
}

.tms-modal__card {
  position: relative;
  width: 100%;
  max-width: 360px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  margin: 0 auto;
  background: var(--mv2-card, #fff);
  border: 0.5px solid var(--mv2-border, rgba(31, 31, 31, 0.08));
  border-radius: var(--mv2-r-xl, 14px);
  padding: 20px 18px 16px;
  box-shadow: 0 12px 32px rgba(31, 31, 31, 0.18);
  box-sizing: border-box;
  text-align: left;
}

.tms-modal__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--mv2-secondary, #6F6F6F);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.tms-modal__close:hover {
  background: var(--mv2-bg, #F4F5F6);
  color: var(--mv2-text, #1F1F1F);
}

.tms-modal__close:disabled {
  opacity: 0.6;
  cursor: wait;
}

.tms-modal__title {
  margin: 0 28px 8px 0;
  font-family: var(--mv2-font, Inter, sans-serif);
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--mv2-text, #1F1F1F);
  letter-spacing: -0.01em;
}

.tms-modal__tour-name {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--mv2-secondary, #6F6F6F);
}

.tms-modal__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
}

.tms-modal__chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--mv2-r-pill, 20px);
  background: var(--mv2-accent-soft, #F5FBEA);
  color: var(--mv2-win-text, #4A6600);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.tms-modal__chip--date {
  background: var(--mv2-card-alt, #EFEFEF);
  color: var(--mv2-text, #1F1F1F);
}

.tms-modal__ops-label {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--mv2-secondary, #6F6F6F);
}

.tms-modal__ops {
  margin: 0 0 10px;
  padding: 10px 12px;
  list-style: none;
  background: var(--mv2-bg, #F4F5F6);
  border-radius: var(--mv2-r-md, 10px);
  border: 0.5px solid var(--mv2-border, rgba(31, 31, 31, 0.08));
}

.tms-modal__ops li {
  font-size: 14px;
  font-weight: 600;
  color: var(--mv2-text, #1F1F1F);
  line-height: 1.35;
  padding: 4px 0;
}

.tms-modal__ops li + li {
  border-top: 0.5px solid var(--mv2-border, rgba(31, 31, 31, 0.08));
  margin-top: 2px;
  padding-top: 6px;
}

/* KA: время отдельно, обе пары столбиком — 4 фамилии без обрезки */
.tms-modal__ops-item--ka {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.tms-modal__ops-when {
  font-size: 12px;
  font-weight: 600;
  color: var(--mv2-secondary, #6F6F6F);
  line-height: 1.3;
  margin-bottom: 2px;
}

.tms-modal__ops-pair {
  font-size: 14px;
  font-weight: 600;
  color: var(--mv2-text, #1F1F1F);
  line-height: 1.35;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}

.tms-modal__ops-vs {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--mv2-muted, #A0A0A0);
  line-height: 1.2;
  padding: 1px 0;
}

.tms-modal__ops-wait {
  font-size: 14px;
  font-weight: 600;
  color: var(--mv2-text, #1F1F1F);
}

.tms__ka-match {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  margin-top: 2px;
}

.tms__ka-pair {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--mv2-text, #1F1F1F);
  line-height: 1.35;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}

.tms__ka-vs {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--mv2-muted, #A0A0A0);
  line-height: 1.2;
}

.tms-modal__more-count {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--mv2-muted, #A0A0A0);
}

.tms-modal__text {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--mv2-secondary, #6F6F6F);
}

.tms-modal__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.tms-modal .tms-modal__btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  border-radius: 12px;
  padding: 13px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  appearance: none;
  -webkit-appearance: none;
}

/* CTA: цвет Telegram — «напишите / к контактам» */
.tms-modal .tms-modal__btn--contacts {
  border: 0 !important;
  background: var(--tms-tg, #2AABEE) !important;
  color: #fff !important;
  box-shadow: none;
}

.tms-modal .tms-modal__btn--contacts:hover {
  background: var(--tms-tg-dark, #1e96d1) !important;
  color: #fff !important;
}

.tms-modal .tms-modal__btn--contacts:disabled {
  opacity: 0.7;
  cursor: wait;
}

/* Закрыть: тот же холодный ряд, но бледный — не спорит с CTA */
.tms-modal .tms-modal__btn--dismiss {
  border: 0.5px solid rgba(42, 171, 238, 0.22) !important;
  background: #F3F8FB !important;
  color: #5A7380 !important;
  font-weight: 500;
}

.tms-modal .tms-modal__btn--dismiss:hover {
  background: #E8F3F9 !important;
  border-color: rgba(42, 171, 238, 0.35) !important;
  color: #3D5560 !important;
  text-decoration: none;
}

.tms-modal .tms-modal__btn--dismiss:disabled {
  opacity: 0.7;
  cursor: wait;
}

html.tms-ack-lock,
body.tms-ack-lock {
  overflow: hidden !important;
}

@media (max-width: 640px) {
  .tms {
    margin: 4px 0 12px;
    max-width: 100%;
    width: 100%;
    padding: 12px 12px 10px;
    box-shadow:
      0 8px 22px rgba(31, 31, 31, 0.09),
      0 1px 3px rgba(31, 31, 31, 0.04);
  }

  .tms:not(.tms--open) {
    margin: 0 0 8px;
    padding: 0;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }

  .tms__fold-head {
    gap: 6px;
  }

  .tms__fold-toggle {
    margin-top: 0;
  }

  .tms--open .tms__deadline {
    width: auto;
    margin-left: 0;
  }

  .tms__row-deadline {
    margin-left: 0;
    width: 100%;
  }

  .tms__ch-label {
    white-space: nowrap;
  }

  .tms-modal {
    align-items: flex-end;
    padding: 0;
  }

  .tms-modal__card {
    max-width: none;
    width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }
}
