/* Referral composition. Foundations and primitives come only from @grafx/tm-design-system v1. */
.tm-referral-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 64px; }
.tm-referral-hero { position: relative; display: grid; max-width: 900px; gap: 12px; overflow: hidden; padding: 28px 0 48px; }
.tm-referral-hero::after { position: absolute; z-index: -1; top: -90px; right: 0; width: 360px; height: 260px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--tm-purple) 16%, transparent), transparent 68%); content: ""; }
.tm-referral-hero .tmc-brand { margin-bottom: 30px; }
.tm-referral-hero h1 { max-width: 14ch; margin-bottom: 4px; }
.tm-referral-hero > p:last-child { max-width: 62ch; color: var(--tm-muted); }
.tm-referral-layout { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(21rem,.6fr); gap: 18px; align-items: start; }
.tm-referral-layout--personal { grid-template-columns: repeat(12,minmax(0,1fr)); }
.tm-referral-layout--personal > * { grid-column: span 4; }
.tm-referral-layout--personal > .tm-span-2 { grid-column: span 8; }
.tm-referral-layout > .tm-full-width { grid-column: 1 / -1; }
.tm-field-row { display: flex; gap: 8px; align-items: end; }
.tm-field-row .tmc-field { flex: 1; }
.tm-live:empty { display: none; }
[data-referral-entry-form] { margin-block-end: var(--tm-space-4); }
.tm-referral-continuation { display: grid; gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--tm-line); }
.tm-referral-continuation[hidden] { display: none; }
.tm-referral-continuation h3, .tm-referral-continuation p { margin: 0; }
.tm-referral-continuation .tmc-button { justify-self: start; }
.tm-legal-acceptance { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.tm-legal-acceptance input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; }
.tm-legal-acceptance label { min-width: 0; overflow-wrap: anywhere; }
.tm-referral-continuation [data-legal-version][hidden] { display: none; }
.tm-live[data-state="error"] { color: var(--tm-red, #a51d2d); }
.tm-live[data-state="success"] { color: var(--tm-success, #0f766e); }
.tmc-button[aria-disabled="true"] { cursor: not-allowed; opacity: .55; }
/* Окно прижато к верху: когда вместо поля почты появляется поле кода, ничего выше не сдвигается. */
.tm-email-otp { width: min(520px, calc(100% - 24px)); margin-block: min(12vh, 96px) auto; }
.tm-email-otp > div { display: grid; gap: var(--tm-space-4); padding: var(--tm-space-6); }
/* UI-POLISH В-1: поля форм входят в сетку окна, поэтому сообщение встаёт сразу
   под видимым полем: поле → сообщение → срок кода → кнопки. */
.tm-email-otp form { display: contents; padding: 0; }
.tm-email-otp [data-email-title], .tm-email-otp [data-email-intro] { margin: 0; }
.tm-email-otp [data-email-intro] { color: var(--tm-muted); }
.tm-email-otp form[hidden] { display: none; }
.tm-email-otp .tmc-field { order: 1; }
.tm-email-otp__status { order: 2; min-height: 2.9em; margin: calc(var(--tm-space-2) - var(--tm-space-4)) 0 0; color: var(--tm-muted); font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.tm-email-otp__status[data-state="success"] { color: var(--tm-ink); }
.tm-email-otp__status[data-state="error"] { color: var(--tm-red-strong); font-weight: 600; }
.tm-email-otp [data-email-expiry] { order: 3; margin: calc(var(--tm-space-2) - var(--tm-space-4)) 0 0; }
.tm-email-otp [data-email-expiry]:empty { display: none; }
.tm-email-otp :is([data-email-request], [data-email-verify]) { order: 4; }
.tm-email-otp [data-email-resend] { order: 5; }
.tm-email-otp__more { display: flex; order: 6; gap: var(--tm-space-3); }
.tm-email-otp__more > .tmc-button { flex: 1 1 0; padding-inline: var(--tm-space-3); white-space: nowrap; }
/* Ссылки на документы — цель 44 px, без «·» между ними. */
.tm-referral-footer { display: flex; flex-wrap: wrap; gap: 0 var(--tm-space-6); width: min(1180px, calc(100% - 32px)); margin: 0 auto var(--tm-space-6); }
.tm-referral-footer a { display: inline-flex; min-height: 44px; align-items: center; }
.tm-email-otp__more > [hidden] { display: none; }
.tm-email-otp .tmc-field[data-state="error"] input { box-shadow: 0 0 0 1px var(--tm-red); }
.tm-code-state { display: flex; align-items: center; gap: 8px; color: #0f766e; font-weight: 650; }
.tm-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tm-code { overflow-wrap: anywhere; color: var(--tm-ink); font: 720 clamp(28px,5vw,52px)/1.1 Inter,sans-serif; letter-spacing: .035em; }
.tm-muted { color: var(--tm-muted); }
.tm-stats { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin: 0; }
.tm-stats div { padding: 14px; border-radius: 12px; background: var(--tm-panel-soft); }
.tm-stats dt { min-height: 2.8em; color: var(--tm-muted); font-size: 12px; }
.tm-stats dd { margin: 4px 0 0; color: var(--tm-ink); font-size: clamp(24px,4vw,36px); font-weight: 720; font-variant-numeric: tabular-nums; }
.tm-history, .tm-economic-history { margin: 0; padding: 0; list-style: none; }
.tm-history li { display: flex; gap: 16px; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--tm-line); }
.tm-history time { color: var(--tm-muted); text-align: right; }
.tm-economic-history { display: grid; gap: 16px; }
.tm-economic-history li { display: grid; gap: 8px; padding: 16px 0; border-bottom: 1px solid rgba(255,255,255,.16); }
.tm-economic-history dl { display: grid; gap: 5px; margin: 0; }
.tm-economic-history dl div { display: grid; grid-template-columns: minmax(8rem,.7fr) minmax(0,1.3fr); gap: 12px; }
.tm-economic-history dt { color: #aaa1b8; }
.tm-economic-history dd { margin: 0; overflow-wrap: anywhere; }
/* UI-POLISH В-4: у кода — главная «Поделиться» и «Копировать код»; остальное — в «Ещё». */
.tm-code-actions { align-items: flex-start; }
.tm-code-more { position: relative; }
.tm-code-more > summary { list-style: none; }
.tm-code-more > summary::-webkit-details-marker { display: none; }
.tm-code-more > summary::after { width: 8px; height: 8px; margin-left: 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; content: ""; transform: translateY(-2px) rotate(45deg); }
.tm-code-more[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.tm-code-more__list { position: absolute; z-index: 5; top: calc(100% + var(--tm-space-2)); left: 0; display: grid; min-width: 17rem; gap: var(--tm-space-1); padding: var(--tm-space-2); border-radius: var(--tm-space-4); background: var(--tm-panel); box-shadow: var(--tm-shadow-control); }
.tm-code-more__list > .tmc-button { justify-content: flex-start; --tmc-button-shadow: 0 0 0 0 transparent; }
.tm-share-preview { overflow-wrap: anywhere; padding: 12px; border: 1px solid var(--tm-line); border-radius: 10px; background: var(--tm-panel-soft); }
.tm-link-button { padding: 0; border: 0; background: transparent; color: var(--tm-accent-strong); cursor: pointer; font-weight: 630; }
/* К30 / X41: пришедший из продукта видит вход по почте первым, регистрацию по приглашению — рядом. */
[data-entry-mode="return"] .tm-referral-layout { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
[data-entry-invitation-note][hidden] { display: none; }
@media (max-width: 800px) {
  .tm-referral-layout, .tm-referral-layout--personal, [data-entry-mode="return"] .tm-referral-layout { grid-template-columns: 1fr; }
  .tm-referral-layout--personal > *, .tm-referral-layout--personal > .tm-span-2 { grid-column: auto; }
}
@media (max-width: 540px) {
  .tm-referral-shell { width: calc(100% - 24px); padding-top: 12px; }
  .tm-referral-hero .tmc-brand { margin-bottom: 16px; }
  .tm-field-row, .tm-history li { align-items: stretch; flex-direction: column; }
  .tm-history time { text-align: left; }
  .tm-stats, .tm-economic-history dl div { grid-template-columns: 1fr; }
  .tm-code-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .tm-code-actions > [data-external-share] { grid-column: 1 / -1; }
  .tm-code-more__list { right: 0; left: auto; min-width: min(17rem, calc(100vw - 48px)); }
}
