/* ============================================================
   FOMO&TEMA · Design System — theme.css
   ------------------------------------------------------------
   Единый источник дизайн-токенов и переиспользуемых компонентов.
   Подключается на всех страницах ПОСЛЕ shell.css.

   Содержание:
     1. Дизайн-токены (dark/light, all accent colors)
     2. Типографика
     3. Компоненты: ft-btn, ft-input, ft-card
     4. Компоненты: ft-table
     5. Компоненты: ft-modal, ft-toast, ft-tooltip, ft-tabs, ft-dropdown
     6. Компоненты: ft-seg / ft-seg-btn (канонические, auth.js = совместимая копия)
     7. Утилитарные классы
   ============================================================ */

/* ─────────────────────────────────────────────────────────
   1. Дизайн-токены — Dark тема (по умолчанию)
   ───────────────────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  /* Фон */
  --bg:  #0b0e11;
  --bg2: #161a1e;
  --bg3: #1e2329;

  /* Граница и текст */
  --border: #2a2e39;
  --text:   #d1d4dc;
  --muted:  #a6b0bd; /* WCAG AA contrast on --bg #0b0e11 ~5.5:1 (was #848e9c ~3.2:1) */
  --strong: #ffffff;

  /* Акцентные цвета — бренд-палитра см. memory/00_core/brand_palette.md */
  --green:        #0d9488;
  --green-hover:  #14b8a6;
  --green-dim:    rgba(13, 148, 136, 0.14);
  --green-border: rgba(13, 148, 136, 0.35);
  /* Text-grade зелёный для inline-текста (WCAG 2.1 AA контраст ≥4.5:1).
     На --bg #0b0e11 даёт ~7:1. В светлой теме переопределяется на тёмно-бирюзовый. */
  --green-text:   #14b8a6;
  /* Акцент-яркий (старый неон) — редкие индикаторы «Live», «Бесплатно», достижения.
     Не для основных кнопок и крупных областей — см. brand_palette.md §1. */
  --green-accent: #00ff88;

  --red:    #f6465d;
  --red-dim:    rgba(246, 70, 93, 0.12);
  --red-border: rgba(246, 70, 93, 0.25);

  --blue:        #0369a1;
  --blue-hover:  #0284c7;
  --blue-dim:    rgba(3, 105, 161, 0.14);
  --blue-border: rgba(3, 105, 161, 0.35);
  /* Text-grade синий для inline-текста (WCAG 2.1 AA контраст ≥4.5:1).
     В тёмной теме fill уже хорошо читается → синоним --blue. */
  --blue-text:   var(--blue);

  --purple: #a855f7;
  --purple-dim:    rgba(168, 85, 247, 0.10);
  --purple-border: rgba(168, 85, 247, 0.25);

  --yellow: #f7c948;
  --yellow-dim:    rgba(247, 201, 72, 0.10);
  --yellow-border: rgba(247, 201, 72, 0.25);

  /* Оранжевый-анонс — семантический «скоро событие» (делистинг, изменение фьючерса).
     Добавлено 2026-05-27, см. brand_palette.md §1 «Семейство системных цветов». */
  --orange-announce: #ff9966;
  --orange-announce-dim: rgba(255, 153, 102, 0.10);
  --orange-announce-border: rgba(255, 153, 102, 0.5);
  /* Text-grade жёлтый/амбер для inline-warning-текста (WCAG 2.1 AA ≥4.5:1).
     В тёмной теме fill читается хорошо → синоним --yellow.
     В светлой переопределяется на тёмно-янтарный. */
  --yellow-text: var(--yellow);

  --orange: #f97316;
  --orange-dim:    rgba(249, 115, 22, 0.10);
  --orange-border: rgba(249, 115, 22, 0.25);

  --cyan:   #06b6d4;
  --cyan-dim:    rgba(6, 182, 212, 0.10);
  --cyan-border: rgba(6, 182, 212, 0.25);

  /* Тени */
  --shadow-sm: 0 1px 4px rgba(0,0,0,.35);
  --shadow:    0 4px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.55);

  /* Компоненты */
  --input-bg:     var(--bg2);
  --input-border: var(--border);
  --card-bg:      var(--bg2);
  --card-border:  var(--border);

  /* Скроллбар */
  --scrollbar-thumb: var(--border);

  /* Контрастный текст на цветном фоне (для кнопок/чипов с акцентным background) */
  --on-bg:      var(--text);          /* текст на --bg */
  --on-card:    var(--text);          /* текст на --card-bg */
  --on-accent:  #ffffff;              /* текст на любом акцентном (зелёный/синий/...) — белый в dark */
  --on-green:   #ffffff;              /* dark: на бирюзовом #0d9488 белый текст читается (~5.5:1) */
  --on-red:     #ffffff;
  --on-yellow:  #000000;              /* yellow яркий → чёрный текст */
  --on-purple:  #ffffff;
  --on-orange:  #ffffff;
  --on-cyan:    #000000;
  --on-blue:    #ffffff;

  /* Backdrop'ы для модалок и оверлеев */
  --overlay-bg:        rgba(0, 0, 0, .45);
  --overlay-bg-strong: rgba(0, 0, 0, .70);
  --shadow-overlay:    0 0 0 100vmax rgba(0, 0, 0, .55);

  /* Brand & chart-палитра (статичная, не меняется по теме) */
  --chart-teal:     #26a69a;
  --chart-teal-dim: rgba(38, 166, 154, .12);
  --chart-red:      #ef5350;
  --chart-red-dim:  rgba(239, 83, 80, .12);
  --gh-green:       #2da44e;
  --gh-green-dim:   rgba(45, 164, 78, .12);
  --cyan-drift:     #00c8ff;
  --cyan-drift-dim: rgba(0, 200, 255, .12);

  /* Founder/премиум-акценты (статичные) */
  --gold:           #ffd24a;
  --gold-dark-text: #1a1200;
  --gold-glow:      rgba(255, 255, 255, .06);

  /* Грейдиент-стопы (статичные) */
  --grad-green-stop:   #00c6ff;
  --grad-purple-stop:  #ec4899;
  --light-surface-overlay: rgba(232, 236, 242, .7);

  /* Полупрозрачная white-подсветка для тёмной темы */
  --white-ghost-08:    rgba(255, 255, 255, .08);

  /* QR-canvas всегда белый (нативное требование) */
  --qr-bg:             #ffffff;
}

/* ─────────────────────────────────────────────────────────
   1. Дизайн-токены — Light тема
   ───────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:  #e8ecf2;
  --bg2: #f6f8fb;
  --bg3: #dde2ea;

  --border: #b8c2d0;
  --text:   #0f1117;
  --muted:  #606878;
  --strong: #000000;

  --green:        #0d9488;
  --green-hover:  #14b8a6;
  --green-dim:    rgba(13, 148, 136, 0.10);
  --green-border: rgba(13, 148, 136, 0.35);
  /* Text-grade: тёмно-бирюзовый. #0f766e на --bg2 (#f6f8fb) ≈ 5.4:1 — WCAG 2.1 AA pass. */
  --green-text:   #0f766e;
  /* Акцент-яркий в light — приглушённая версия неона для редких индикаторов. */
  --green-accent: #00b86b;

  --red:    #c82b45;
  --red-dim:    rgba(200, 43, 69, 0.10);
  --red-border: rgba(200, 43, 69, 0.30);

  --blue:        #0369a1;
  --blue-hover:  #075985;
  --blue-dim:    rgba(3, 105, 161, 0.10);
  --blue-border: rgba(3, 105, 161, 0.35);
  /* Text-grade синий в light — `--blue` уже даёт нужный контраст:
     #0369a1 на --bg (#e8ecf2) → ~6:1 — WCAG AA pass. */
  --blue-text:   var(--blue);

  --purple: #7c3aed;
  --purple-dim:    rgba(124, 58, 237, 0.10);
  --purple-border: rgba(124, 58, 237, 0.30);

  --yellow: #d4a017;
  --yellow-dim:    rgba(212, 160, 23, 0.12);
  --yellow-border: rgba(212, 160, 23, 0.35);

  /* Светлая тема: тот же оттенок оранжевого — хорошо читается и на белом */
  --orange-announce: #e07b3f;
  --orange-announce-dim: rgba(224, 123, 63, 0.10);
  --orange-announce-border: rgba(224, 123, 63, 0.45);
  /* Text-grade: тёмный амбер. Контраст 5.44:1 на --bg (#e8ecf2), 6.04:1 на --bg2 (#f6f8fb).
     #8c6900 (исходный кандидат) на --bg давал лишь 4.28:1 — ниже AA, поэтому затемнили. */
  --yellow-text:   #7a5900;

  --orange: #c2550e;
  --orange-dim:    rgba(194, 85, 14, 0.10);
  --orange-border: rgba(194, 85, 14, 0.30);

  --cyan:   #0284a8;
  --cyan-dim:    rgba(2, 132, 168, 0.10);
  --cyan-border: rgba(2, 132, 168, 0.30);

  --shadow-sm: 0 1px 4px rgba(0,0,0,.10);
  --shadow:    0 4px 16px rgba(0,0,0,.15);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.20);

  --input-bg:     var(--bg2);
  --input-border: var(--border);
  --card-bg:      var(--bg2);
  --card-border:  var(--border);

  --scrollbar-thumb: var(--border);

  /* Контрастный текст на цветном фоне (для кнопок/чипов с акцентным background) */
  --on-bg:      var(--text);
  --on-card:    var(--text);
  --on-accent:  #ffffff;              /* light: на акцентном фоне белый чаще читается */
  --on-green:   #ffffff;
  --on-red:     #ffffff;
  --on-yellow:  #000000;              /* yellow в light — оставляем чёрный */
  --on-purple:  #ffffff;
  --on-orange:  #ffffff;
  --on-cyan:    #ffffff;
  --on-blue:    #ffffff;

  /* Backdrop'ы для модалок и оверлеев */
  --overlay-bg:        rgba(0, 0, 0, .35);
  --overlay-bg-strong: rgba(0, 0, 0, .55);
  --shadow-overlay:    0 0 0 100vmax rgba(0, 0, 0, .40);

  /* В light --ft-z-modal-stack/toast-priority наследуются из общего :root блока — не дублируем здесь */

  /* Brand & chart-палитра — версии для светлой темы */
  --chart-teal:     #1e8a82;
  --chart-teal-dim: rgba(30, 138, 130, .14);
  --chart-red:      #d73a3a;
  --chart-red-dim:  rgba(215, 58, 58, .14);
  --gh-green:       #1f7a3a;
  --gh-green-dim:   rgba(31, 122, 58, .14);
  --cyan-drift:     #0085b5;
  --cyan-drift-dim: rgba(0, 133, 181, .14);

  --gold:           #d4a017;
  --gold-dark-text: #1a1200;
  --gold-glow:      rgba(0, 0, 0, .06);

  --grad-green-stop:   #0085b5;
  --grad-purple-stop:  #c13484;
  --light-surface-overlay: rgba(232, 236, 242, .7);

  --white-ghost-08:    rgba(0, 0, 0, .06);
  --qr-bg:             #ffffff;
}

/* ─────────────────────────────────────────────────────────
   2. Типографика
   ───────────────────────────────────────────────────────── */
:root {
  --font-base:    'Lato', 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Urbanist', var(--font-base);
  --font-mono:    'JetBrains Mono', 'Fira Mono', ui-monospace, monospace;

  --text-xs:   11px;
  --text-sm:   12px;
  --text-base: 13px;
  --text-md:   14px;
  --text-lg:   16px;
  --text-xl:   18px;
  --text-2xl:  24px;
  --text-3xl:  32px;
  --text-4xl:  42px;

  --lh-tight:  1.2;
  --lh-snug:   1.4;
  --lh-normal: 1.6;
  --lh-relaxed:1.75;

  --radius-sm: 4px;
  --radius:    6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  --transition: .15s ease;
  --transition-md: .22s ease;

  --ft-z-base: 1; --ft-z-dropdown: 10; --ft-z-sticky: 100; --ft-z-fixed: 200;
  --ft-z-overlay: 900; --ft-z-modal: 1000; --ft-z-popover: 1100; --ft-z-toast: 1200;
  /* HI-04: tooltip поднят до 9100 — выше --sh-z-modal (9000), ниже --sh-z-toast (9500).
     Tooltip должен перекрывать модалки, но не перекрывать системные тосты. */
  --ft-z-tooltip:        9100;
  --ft-z-modal-stack:    1400;        /* модалки поверх обычных */
  --ft-z-toast-priority: 1500;        /* toast приоритетный */
  --ft-z-ctx-menu:       1600;        /* поверх toast-priority (1500) */
}

/* ─────────────────────────────────────────────────────────
   3. Компонент: ft-btn
   Использование: <button class="ft-btn ft-btn-green">Текст</button>
   ───────────────────────────────────────────────────────── */
.ft-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-base);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
}
.ft-btn:hover { background: var(--bg3); color: var(--text); }
/* A11Y (S92 v2.0 fix WCAG 2.1 SC 2.4.7 Focus Visible AA) */
.ft-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ft-btn:disabled { opacity: .45; pointer-events: none; }

.ft-btn-sm { height: 28px; padding: 0 12px; font-size: var(--text-xs); }
.ft-btn-lg { height: 40px; padding: 0 22px; font-size: var(--text-md); }
.ft-btn-xl { height: 48px; padding: 0 28px; font-size: var(--text-lg); font-weight: 700; }

/* Варианты */
.ft-btn-primary { background: var(--green); border-color: var(--green-text); color: #000; font-weight: 700; }
.ft-btn-primary:hover { filter: brightness(1.12); color: #000; }

.ft-btn-green { border-color: var(--green-border); color: var(--green-text); }
.ft-btn-green:hover { background: var(--green-dim); border-color: var(--green-text); color: var(--green-text); }

.ft-btn-blue { border-color: var(--blue-border); color: var(--blue); }
.ft-btn-blue:hover { background: var(--blue-dim); border-color: var(--blue); color: var(--blue); }

.ft-btn-red { border-color: var(--red-border); color: var(--red); }
.ft-btn-red:hover { background: var(--red-dim); border-color: var(--red); color: var(--red); }

.ft-btn-purple { border-color: var(--purple-border); color: var(--purple); }
.ft-btn-purple:hover { background: var(--purple-dim); border-color: var(--purple); color: var(--purple); }

.ft-btn-ghost { border-color: transparent; background: transparent; }
.ft-btn-ghost:hover { background: var(--bg3); border-color: var(--border); }

.ft-btn-icon { padding: 0; width: 34px; }
.ft-btn-icon.ft-btn-sm { width: 28px; }
.ft-btn-icon.ft-btn-lg { width: 40px; }

/* ─────────────────────────────────────────────────────────
   3b. Простой .btn — используется на страницах копитрейда
       (copytrade/, copytrade/master/, copytrade/subscriptions/)
   ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-base);
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--bg2);
  color: var(--text);
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:hover:not(:disabled) { background: var(--bg3); }
/* A11Y (S92 v2.0 fix WCAG 2.1 SC 2.4.7 Focus Visible AA) */
.btn:focus-visible { outline: 2px solid var(--blue, #4fc3f7); outline-offset: 2px; }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn i { font-size: 12px; }

.btn-primary   { background: var(--accent, var(--green)); border-color: var(--accent, var(--green)); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); background: var(--accent, var(--green)); color: #fff; }

.btn-secondary { background: var(--bg3); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent, var(--green)); color: var(--accent, var(--green)); background: var(--bg3); }

.btn-ghost     { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent, var(--green)); color: var(--accent, var(--green)); }

.btn-danger    { background: transparent; border-color: var(--red, #e55); color: var(--red, #e55); }
.btn-danger:hover:not(:disabled) { background: var(--red-dim, rgba(238,85,85,.1)); color: var(--red, #e55); }

.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-lg        { padding: 10px 20px; font-size: 14px; }

/* ─────────────────────────────────────────────────────────
   4. Компонент: ft-input
   Использование: <input class="ft-input" ...>
   ───────────────────────────────────────────────────────── */
.ft-input {
  display: block;
  width: 100%;
  height: 34px;
  padding: 0 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-base);
  transition: border-color var(--transition);
  outline: none;
  -webkit-appearance: none;
}
.ft-input::placeholder { color: var(--muted); opacity: .7; }
.ft-input:focus { border-color: var(--blue); }
/* A11Y (S92 v2.0 fix WCAG 2.1 SC 2.4.7 Focus Visible AA) — keyboard-only focus indicator */
.ft-input:focus-visible { border-color: var(--blue); outline: 2px solid var(--blue); outline-offset: 1px; box-shadow: 0 0 0 3px rgba(79,195,247,.25); }
.ft-input:disabled { opacity: .45; cursor: not-allowed; }

.ft-input-sm { height: 28px; padding: 0 10px; font-size: var(--text-xs); }
.ft-input-lg { height: 40px; padding: 0 14px; font-size: var(--text-md); }

.ft-textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-base);
  line-height: var(--lh-normal);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
}
.ft-textarea:focus { border-color: var(--blue); }
.ft-textarea:focus-visible { border-color: var(--blue); outline: 2px solid var(--blue); outline-offset: 1px; box-shadow: 0 0 0 3px rgba(79,195,247,.25); }

.ft-select {
  display: block;
  height: 34px;
  padding: 0 32px 0 12px;
  background: var(--input-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23848e9c'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-base);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition);
}
.ft-select:focus { border-color: var(--blue); }
.ft-select:focus-visible { border-color: var(--blue); outline: 2px solid var(--blue); outline-offset: 1px; box-shadow: 0 0 0 3px rgba(79,195,247,.25); }

/* Input-group */
.ft-input-group { display: flex; }
.ft-input-group .ft-input { border-radius: 0; border-right: none; }
.ft-input-group .ft-input:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.ft-input-group .ft-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }

/* ─────────────────────────────────────────────────────────
   5. Компонент: ft-card
   Использование: <div class="ft-card"> ... </div>
   ───────────────────────────────────────────────────────── */
.ft-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
}
.ft-card-sm { padding: 14px 16px; border-radius: var(--radius-md); }
.ft-card-lg { padding: 28px 32px; }

.ft-card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.ft-card-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--strong);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ft-card-sub { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; }

/* ─────────────────────────────────────────────────────────
   6. Компонент: ft-table
   ───────────────────────────────────────────────────────── */
.ft-table-wrap { overflow-x: auto; }
.ft-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
  color: var(--text);
}
.ft-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ft-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ft-table tr:last-child td { border-bottom: none; }
.ft-table tr:hover td { background: var(--bg3); }
.ft-table.striped tr:nth-child(even) td { background: rgba(255,255,255,.02); }
[data-theme="light"] .ft-table.striped tr:nth-child(even) td { background: rgba(0,0,0,.02); }

/* ─────────────────────────────────────────────────────────
   7. Компонент: ft-tabs
   Использование:
     <div class="ft-tabs">
       <button class="ft-tab active">Tab 1</button>
       <button class="ft-tab">Tab 2</button>
     </div>
   ───────────────────────────────────────────────────────── */
.ft-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.ft-tabs::-webkit-scrollbar { display: none; }

.ft-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-base);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}
.ft-tab:hover { color: var(--text); }
.ft-tab.active { color: var(--strong); border-bottom-color: var(--green-text); }
.ft-tab .ft-tab-badge {
  background: var(--red);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  min-width: 16px;
  text-align: center;
}

/* ─────────────────────────────────────────────────────────
   8. Компонент: ft-dropdown
   Управление JS-классом .open
   ───────────────────────────────────────────────────────── */
.ft-dropdown-wrap { position: relative; display: inline-flex; }

.ft-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: var(--sh-z-dropdown, 1000);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
  overflow: hidden;
}
.ft-dropdown-wrap.open .ft-dropdown,
.ft-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.ft-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-base);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.ft-dropdown-item:hover { background: var(--bg3); color: var(--strong); }
.ft-dropdown-item.danger { color: var(--red); }
.ft-dropdown-item.danger:hover { background: var(--red-dim); }
.ft-dropdown-item i { width: 16px; text-align: center; color: var(--muted); font-size: var(--text-sm); }
.ft-dropdown-item:hover i { color: inherit; }
.ft-dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }
.ft-dropdown-label {
  padding: 6px 14px 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* ─────────────────────────────────────────────────────────
   9. Компонент: ft-modal
   JS управляет атрибутом [open] на .ft-modal-overlay
   ───────────────────────────────────────────────────────── */
.ft-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: var(--sh-z-modal, 9000);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s, visibility .22s;
}
.ft-modal-overlay[open] {
  opacity: 1;
  visibility: visible;
}
.ft-modal-overlay[open] .ft-modal {
  transform: none;
}

.ft-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform .22s;
  overflow: hidden;
}
.ft-modal-sm { max-width: 380px; }
.ft-modal-lg { max-width: 720px; }
.ft-modal-xl { max-width: 960px; }

.ft-modal-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ft-modal-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--strong);
  flex: 1;
}
.ft-modal-x {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  border: none;
  background: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.ft-modal-x:hover { background: var(--bg3); color: var(--text); }

.ft-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.ft-modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────
   10. Компонент: ft-toast
   Создаётся JS-компонентом FT.ui.toast(...)
   ───────────────────────────────────────────────────────── */
#ft-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: var(--sh-z-toast, 9500);
  pointer-events: none;
}

.ft-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  min-width: 240px;
  max-width: 360px;
  pointer-events: all;
  animation: ft-toast-in .2s ease;
}
.ft-toast.removing { animation: ft-toast-out .2s ease forwards; }

.ft-toast-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.ft-toast-body { flex: 1; min-width: 0; }
.ft-toast-title { font-size: var(--text-base); font-weight: 600; color: var(--strong); }
.ft-toast-text { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; line-height: 1.4; }
.ft-toast-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; flex-shrink: 0; transition: color var(--transition); }
.ft-toast-x:hover { color: var(--text); }

.ft-toast.success { border-left: 3px solid var(--green); }
.ft-toast.success .ft-toast-icon { color: var(--green-text); }
.ft-toast.error { border-left: 3px solid var(--red); }
.ft-toast.error .ft-toast-icon { color: var(--red); }
.ft-toast.warning { border-left: 3px solid var(--yellow); }
.ft-toast.warning .ft-toast-icon { color: var(--yellow-text); }
.ft-toast.info { border-left: 3px solid var(--blue); }
.ft-toast.info .ft-toast-icon { color: var(--blue); }

@keyframes ft-toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes ft-toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* ─────────────────────────────────────────────────────────
   11. Компонент: ft-tooltip (CSS-only через data-tip)
   Использование: <span data-ft-tip="Текст подсказки">...</span>
   ───────────────────────────────────────────────────────── */
[data-ft-tip] {
  position: relative;
  cursor: default;
}
[data-ft-tip]::after {
  content: attr(data-ft-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-xs);
  font-weight: 400;
  white-space: nowrap;
  max-width: 240px;
  white-space: normal;
  text-align: left;
  line-height: var(--lh-snug);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition), visibility var(--transition);
  z-index: var(--ft-z-tooltip, 9100);
}
[data-ft-tip]:hover::after { opacity: 1; visibility: visible; }
[data-ft-tip-right]::after { left: auto; right: 0; transform: none; }
[data-ft-tip-bottom]::after { top: calc(100% + 6px); bottom: auto; }

/* ─────────────────────────────────────────────────────────
   12. Компонент: ft-seg / ft-seg-btn
   КАНОНИЧЕСКИЕ стили (auth.js содержит идентичную копию для
   обратной совместимости — будет удалена в K3+)
   ───────────────────────────────────────────────────────── */
.ft-seg {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg2);
  flex-shrink: 0;
  height: 34px;
}
.ft-seg > .ft-seg-btn:first-child { border-radius: 7px 0 0 7px; }
.ft-seg > .ft-seg-btn:last-child,
.ft-seg > :last-child .ft-seg-btn { border-radius: 0 7px 7px 0; }

.ft-seg-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-base);
  white-space: nowrap;
  position: relative;
  text-decoration: none;
}
.ft-seg-btn + .ft-seg-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%; bottom: 20%;
  width: 1px;
  background: var(--border);
}
.ft-seg-btn i { font-size: 12px; transition: color var(--transition); }
.ft-seg-btn:hover { background: var(--bg3); color: var(--text); }

.ft-seg-btn.h-green:hover { color: var(--green-text); }
.ft-seg-btn.h-green:hover i { color: var(--green-text); }
.ft-seg-btn.h-blue:hover { color: var(--blue); }
.ft-seg-btn.h-blue:hover i { color: var(--blue); }
.ft-seg-btn.h-red:hover { color: var(--red); }
.ft-seg-btn.h-red:hover i { color: var(--red); }
.ft-seg-btn.h-purple:hover { color: var(--purple); }
.ft-seg-btn.h-purple:hover i { color: var(--purple); }
.ft-seg-btn.h-yellow:hover { color: var(--yellow-text); }
.ft-seg-btn.h-yellow:hover i { color: var(--yellow-text); }

.ft-seg-btn.icon-only { padding: 0 10px; }
.ft-seg-btn.active { color: var(--blue); background: var(--blue-dim); }
.ft-seg-btn.active i { color: var(--blue); }
.ft-seg-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.ft-seg-acc-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(0,255,136,.4);
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────
   13. Компонент: ft-ctx-menu (глобальное контекстное меню)
   Создаётся и управляется FT.ui.ctxmenu(...)
   ───────────────────────────────────────────────────────── */
.ft-ctx-menu {
  position: fixed;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: calc(var(--sh-z-modal, 9000) - 1);
  min-width: 160px;
  overflow: hidden;
  animation: ft-ctx-in .12s ease;
}
@keyframes ft-ctx-in {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}
.ft-ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-base);
  cursor: pointer;
  transition: background var(--transition);
  text-align: left;
}
.ft-ctx-item:hover { background: var(--bg3); }
.ft-ctx-item:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.ft-ctx-item.danger { color: var(--red); }
.ft-ctx-item.danger:hover { background: var(--red-dim); }
.ft-ctx-item i { width: 16px; text-align: center; color: var(--muted); font-size: var(--text-sm); }
.ft-ctx-item:hover i { color: inherit; }
.ft-ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ─────────────────────────────────────────────────────────
   14. Компонент: ft-badge / ft-tag
   ───────────────────────────────────────────────────────── */
.ft-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--bg3);
  color: var(--muted);
  border: 1px solid var(--border);
}
.ft-badge-green { background: var(--green-dim); color: var(--green-text); border-color: var(--green-border); }
.ft-badge-red   { background: var(--red-dim);   color: var(--red);   border-color: var(--red-border); }
.ft-badge-blue  { background: var(--blue-dim);  color: var(--blue);  border-color: var(--blue-border); }
.ft-badge-yellow{ background: var(--yellow-dim);color: var(--yellow-text);border-color: var(--yellow-border); }
.ft-badge-purple{ background: var(--purple-dim);color: var(--purple);border-color: var(--purple-border); }

/* ─────────────────────────────────────────────────────────
   15. Утилиты
   ───────────────────────────────────────────────────────── */
/* Flex */
.ft-flex   { display: flex; }
.ft-flex-col { display: flex; flex-direction: column; }
.ft-center { display: flex; align-items: center; justify-content: center; }
.ft-between { display: flex; align-items: center; justify-content: space-between; }
.ft-gap-2  { gap: 4px; }
.ft-gap-4  { gap: 8px; }
.ft-gap-6  { gap: 12px; }
.ft-gap-8  { gap: 16px; }

/* Text */
.ft-text-muted  { color: var(--muted); }
.ft-text-strong { color: var(--strong); }
.ft-text-green  { color: var(--green-text); }
.ft-text-red    { color: var(--red); }
.ft-text-blue   { color: var(--blue); }
.ft-text-yellow { color: var(--yellow-text); }
.ft-text-sm     { font-size: var(--text-sm); }
.ft-text-xs     { font-size: var(--text-xs); }
.ft-fw-600      { font-weight: 600; }
.ft-fw-700      { font-weight: 700; }
.ft-truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Spacing */
.ft-mt-4  { margin-top: 8px; }
.ft-mt-6  { margin-top: 12px; }
.ft-mt-8  { margin-top: 16px; }
.ft-mb-4  { margin-bottom: 8px; }
.ft-mb-6  { margin-bottom: 12px; }
.ft-mb-8  { margin-bottom: 16px; }
.ft-p-4   { padding: 8px; }
.ft-p-6   { padding: 12px; }
.ft-p-8   { padding: 16px; }

/* Dividers */
.ft-sep { height: 1px; background: var(--border); margin: 12px 0; border: none; }
.ft-sep-v { width: 1px; background: var(--border); align-self: stretch; }

/* Loading spinner */
.ft-spin {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--green-text);
  border-radius: 50%;
  animation: ft-spin .7s linear infinite;
  flex-shrink: 0;
}
.ft-spin-sm { width: 14px; height: 14px; }
.ft-spin-lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes ft-spin { to { transform: rotate(360deg); } }

/* Empty state */
.ft-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  gap: 10px;
}
.ft-empty i { font-size: 36px; opacity: .35; }
.ft-empty-title { font-size: var(--text-md); font-weight: 600; color: var(--text); }
.ft-empty-text { font-size: var(--text-sm); line-height: var(--lh-normal); }

/* Scrollbar */
.ft-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
.ft-scroll::-webkit-scrollbar { width: 4px; height: 4px; }
.ft-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 2px;
}

/* Screen-reader only — WCAG 2.1 AA (1.3.1) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus-visible ring — reusable helper (A11Y-02, Закон 15).
   Добавь class="focus-visible-ring" на любую кастомную кнопку
   для гарантированного outline при keyboard-навигации. */
.focus-visible-ring:focus-visible {
  outline: 2px solid var(--blue, #4fc3f7);
  outline-offset: 2px;
}
