/* ==========================================================================
   TG Lead Radar — базовый слой дизайн-системы.
   Загружается всеми публичными страницами, поэтому здесь живут только токены,
   сброс, типографика и примитивы. Специфика страниц — в отдельных файлах
   (landing.css, auth.css, cabinet.css, admin.css, wizard.css, legal.css).

   ВАЖНО: CSP запрещает inline-стили и внешние шрифты
   (`style-src 'self'`, нет `font-src`). Ни <style>, ни style="...",
   ни Google Fonts использовать нельзя — только этот и соседние файлы.
   ========================================================================== */

:root {
  /* Фирменный синий из макета. */
  --brand: #238cdf;
  --brand-strong: #1877c4;
  --brand-deep: #1763ad;
  --brand-soft: #edf7ff;
  --brand-softer: #f5fafe;

  /* Текст. */
  --ink: #121721;
  --ink-muted: #637080;
  --ink-faint: #8c96a8;

  /* Тёмная панель (сайдбар кабинета, футер лендинга). */
  --night: #09111f;
  --night-raised: #111c2c;
  --night-active: #12243a;
  --night-line: #1c2b40;
  --night-ink: #aeb8c7;

  /* Поверхности. */
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-sunken: #f6f9fd;
  --surface-muted: #f5f8fc;

  /* Границы. */
  --line: #e1e8f1;
  --line-strong: #d7e0ec;
  --line-input: #cfd8e4;

  /* Семантика. */
  --green: #159f6b;
  --green-soft: #eaf8f2;
  --orange: #f47728;
  --orange-soft: #fff3e9;
  --red: #cf3231;
  --red-soft: #fef2f2;
  --violet: #7655d7;

  /* Радиусы. */
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* Тени. */
  --shadow-xs: 0 1px 2px rgba(20, 35, 58, .06);
  --shadow-sm: 0 6px 16px rgba(20, 35, 58, .06);
  --shadow-md: 0 10px 30px rgba(20, 35, 58, .08);
  --shadow-lg: 0 22px 60px rgba(20, 35, 58, .14);

  /* Движение. Все переходы идут через эти токены, чтобы одним
     prefers-reduced-motion-блоком отключить анимацию целиком. */
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-fast: .14s;
  --t: .22s;
  --t-slow: .42s;

  --font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  color-scheme: light;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  margin: 0 0 .4em;
  line-height: 1.18;
  letter-spacing: -.02em;
  font-weight: 700;
}
h1 { font-size: 32px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }

code, pre, .mono { font-family: var(--font-mono); }

img, svg { max-width: 100%; }

hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

::selection { background: #cde8ff; color: var(--ink); }

/* Видимый фокус обязателен: половина кабинета управляется с клавиатуры. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Утилиты
   -------------------------------------------------------------------------- */

.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
}

.note {
  color: var(--ink-muted);
  font-size: 13px;
}

.note.warning { color: #b45309; }

.error-text {
  color: var(--red);
  min-height: 1.4em;
  font-size: 14px;
}

.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Кнопки. Базовый вид один на весь продукт; страницы меняют только размер.
   -------------------------------------------------------------------------- */

button,
.button-link,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--brand);
  color: #fff;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              box-shadow var(--t) var(--ease),
              transform var(--t-fast) var(--ease);
}

button:hover,
.button-link:hover,
.btn:hover {
  background: var(--brand-strong);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(35, 140, 223, .28);
}

button:active,
.button-link:active,
.btn:active { transform: translateY(1px); box-shadow: none; }

button:disabled,
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Вторичная кнопка. Исторически задавалась с !important, поэтому оставляем
   тот же вес — иначе старые страницы поедут. */
button.secondary,
.button-link.secondary,
.btn.secondary,
.secondary {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border-color: var(--line-strong);
}

button.secondary:hover,
.button-link.secondary:hover,
.btn.secondary:hover,
.secondary:hover {
  background: var(--surface-muted) !important;
  border-color: var(--line-input);
  box-shadow: var(--shadow-xs);
}

button.ghost,
.btn.ghost {
  background: transparent;
  color: var(--ink-muted);
  border-color: transparent;
}
button.ghost:hover,
.btn.ghost:hover {
  background: var(--surface-muted);
  color: var(--ink);
  box-shadow: none;
}

button.danger,
.btn.danger {
  background: var(--red);
  color: #fff;
}
button.danger:hover,
.btn.danger:hover {
  background: #b32826;
  box-shadow: 0 6px 18px rgba(207, 50, 49, .26);
}

/* --------------------------------------------------------------------------
   Поля ввода
   -------------------------------------------------------------------------- */

input, select, textarea {
  border: 1px solid var(--line-input);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  max-width: 100%;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(35, 140, 223, .16);
}

input::placeholder, textarea::placeholder { color: var(--ink-faint); }

input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  padding: 0;
  cursor: pointer;
}

textarea { resize: vertical; line-height: 1.5; }

select {
  appearance: none;
  padding-right: 30px;
  /* Стрелка — data:-URI, единственный тип внешнего ресурса, разрешённый CSP. */
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23637080' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

label { font-size: 13px; }

/* --------------------------------------------------------------------------
   Карточки и служебные блоки, которые переиспользуют юридические страницы,
   /billing/return.php, /invite.php, /reset.php и /verify.php.
   -------------------------------------------------------------------------- */

.shell,
.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 48px 20px;
  display: grid;
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.card.subtle { background: var(--surface-sunken); box-shadow: none; }

.hero h1 { font-size: clamp(30px, 5vw, 44px); margin: 10px 0 12px; }

.lead {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-muted);
  max-width: 68ch;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 24px;
}
.grid > div {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  background: var(--surface);
}
.grid span {
  display: block;
  color: var(--ink-muted);
  font-size: 12px;
  margin-bottom: 5px;
}
.grid strong { font-size: 14px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--surface);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--r-pill);
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.pill.green  { background: var(--green-soft);  color: var(--green); }
.pill.orange { background: var(--orange-soft); color: #c4590f; }
.pill.red    { background: var(--red-soft);    color: var(--red); }
.pill.grey   { background: var(--surface-muted); color: var(--ink-muted); }

.warning {
  background: #fff8e6;
  border: 1px solid #f2dda1;
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 13px;
  color: #8a5b06;
}

/* Формы входа/регистрации на служебных страницах. */
.login-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.login-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.login-form .check {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-weight: 400;
}
.login-form .check input { width: auto; margin-top: 3px; }
.login-form .check a { color: inherit; text-decoration: underline; }

.auth-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

@media (max-width: 760px) {
  .shell, .container { padding: 28px 16px; }
  .card { padding: 20px; border-radius: var(--r-lg); }
  .login-form { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Анимации. Используются лендингом, кабинетом и служебными страницами.
   -------------------------------------------------------------------------- */

@keyframes lr-fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@keyframes lr-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes lr-pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(21, 159, 107, .45); }
  70%  { box-shadow: 0 0 0 7px rgba(21, 159, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(21, 159, 107, 0); }
}

@keyframes lr-shimmer {
  from { background-position: -420px 0; }
  to   { background-position: 420px 0; }
}

@keyframes lr-spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, #eef2f7 25%, #f7fafd 50%, #eef2f7 75%);
  background-size: 420px 100%;
  animation: lr-shimmer 1.3s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
