﻿// AI Отдел — компоненты (тема + карточки + статус-бары)

const PORTRAIT = {
  elena:   'src/portraits/elena.png',
  lyudmila:'src/portraits/lyudmila.png',
  dmitry:  'src/portraits/dmitry.png',
  igor:    'src/portraits/igor.png',
  kostya:  'src/portraits/kostya.png',
  alina:   'src/portraits/alina.png',
  mark:    'src/portraits/mark.png',
  oleg:    'src/portraits/oleg.png',
};

const PHASES = [
  { key: 'accepted', short: 'Принята',  label: 'Задача принята' },
  { key: 'data',     short: 'Данные',   label: 'Сбор данных' },
  { key: 'analysis', short: 'Анализ',   label: 'Анализирую' },
  { key: 'generate', short: 'Генер.',   label: 'Генерирую варианты' },
  { key: 'review',   short: 'Проверка', label: 'Проверяю результат' },
  { key: 'done',     short: 'Готово',   label: 'Готово' },
];

// ──────────────────────────────────────────────────────────────
// Theme tokens
// ──────────────────────────────────────────────────────────────
const THEMES = {
  light: {
    name: 'light',
    canvas:    '#DCD7EE',   // outside the phone
    bg:        '#EEEBF7',   // phone canvas
    bg2:       '#F4F2FB',
    card:      '#FFFFFF',
    cardSoft:  '#F7F5FD',
    ink:       '#1A1733',
    inkSoft:   '#3A3458',
    mute:      '#8B86A8',
    line:      'rgba(110, 92, 244, 0.10)',
    divider:   'rgba(26, 23, 51, 0.06)',
    accent:    '#6E5CF4',
    ok:        '#22C55E',
    okBg:      'rgba(34,197,94,0.10)',
    okText:    '#15803D',
    portraitBg:'#E8E3F5',
    shadow:    '0 2px 4px -2px rgba(26,23,51,0.06), 0 1px 0 rgba(26,23,51,0.02)',
    shadowHi:  '0 10px 30px -20px rgba(46,32,128,0.30)',
    statusBar: '#1A1733',
    notchBg:   '#0A0A14',
    iosFg:     'rgba(26,23,51,0.28)',
  },
  dark: {
    name: 'dark',
    canvas:    '#0B0918',
    bg:        '#141021',
    bg2:       '#1A1530',
    card:      '#221E3A',
    cardSoft:  '#2A2545',
    ink:       '#FFFFFF',
    inkSoft:   'rgba(255,255,255,0.85)',
    mute:      'rgba(255,255,255,0.55)',
    line:      'rgba(255,255,255,0.08)',
    divider:   'rgba(255,255,255,0.06)',
    accent:    '#8B7BFB',
    ok:        '#34D399',
    okBg:      'rgba(52,211,153,0.12)',
    okText:    '#6EE7B7',
    portraitBg:'#2A2545',
    shadow:    '0 2px 4px -2px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.03) inset',
    shadowHi:  '0 16px 40px -20px rgba(0,0,0,0.6)',
    statusBar: '#FFFFFF',
    notchBg:   '#000000',
    iosFg:     'rgba(255,255,255,0.32)',
  },
};

// ──────────────────────────────────────────────────────────────
// Icons
// ──────────────────────────────────────────────────────────────
const I = {
  home:   (c) => <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><path d="M4 11l8-7 8 7v9a1 1 0 01-1 1h-4v-6h-6v6H5a1 1 0 01-1-1v-9z" stroke={c} strokeWidth="1.8" strokeLinejoin="round"/></svg>,
  tasks:  (c) => <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><rect x="4" y="4" width="16" height="17" rx="2.5" stroke={c} strokeWidth="1.8"/><path d="M8 9h8M8 13h8M8 17h5" stroke={c} strokeWidth="1.8" strokeLinecap="round"/></svg>,
  team:   (c) => <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><circle cx="9" cy="9" r="3.2" stroke={c} strokeWidth="1.8"/><circle cx="17" cy="10" r="2.5" stroke={c} strokeWidth="1.8"/><path d="M3.5 19c0-2.8 2.5-5 5.5-5s5.5 2.2 5.5 5M15 19c0-2.2 1.5-4 3.5-4s2.5 1 2.5 1" stroke={c} strokeWidth="1.8" strokeLinecap="round"/></svg>,
  profile:(c) => <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="8.5" r="3.5" stroke={c} strokeWidth="1.8"/><path d="M4.5 20c0-3.6 3.4-6.5 7.5-6.5s7.5 2.9 7.5 6.5" stroke={c} strokeWidth="1.8" strokeLinecap="round"/></svg>,
  bell:   (c) => <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M6 16V11a6 6 0 1112 0v5l1.5 2.5h-15L6 16z" stroke={c} strokeWidth="1.8" strokeLinejoin="round"/><path d="M10 19a2 2 0 004 0" stroke={c} strokeWidth="1.8" strokeLinecap="round"/></svg>,
  spark:  (c, s=14) => <svg width={s} height={s} viewBox="0 0 24 24" fill="none"><path d="M12 3l1.7 5.3L19 10l-5.3 1.7L12 17l-1.7-5.3L5 10l5.3-1.7L12 3z" fill={c}/></svg>,
  plus:   (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M12 5v14M5 12h14" stroke={c} strokeWidth="2.2" strokeLinecap="round"/></svg>,
  chevron:(c) => <svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M9 6l6 6-6 6" stroke={c} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  diamond:(c) => <svg width="14" height="14" viewBox="0 0 24 24"><path d="M12 3l9 9-9 9-9-9 9-9z" fill={c} opacity="0.9"/></svg>,
  moon:   (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M20 14.5A8 8 0 019.5 4a8.5 8.5 0 1010.5 10.5z" stroke={c} strokeWidth="1.8" strokeLinejoin="round"/></svg>,
  sun:    (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="4" stroke={c} strokeWidth="1.8"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M5.6 18.4L7 17M17 7l1.4-1.4" stroke={c} strokeWidth="1.8" strokeLinecap="round"/></svg>,
  chat:   (c) => <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><path d="M21 12c0 4.4-4 8-9 8a10.4 10.4 0 01-4-.8L3 20l1-3.5A8 8 0 013 12c0-4.4 4-8 9-8s9 3.6 9 8z" stroke={c} strokeWidth="1.8" strokeLinejoin="round"/></svg>,
  send:   (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M3 12L21 4l-7 18-3-7-8-3z" fill={c}/></svg>,
  clip:   (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M21 11.5l-8.5 8.5a5 5 0 11-7-7l8.5-8.5a3.5 3.5 0 014.95 4.95L10.5 18" stroke={c} strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  chat:   (c) => <svg width="22" height="22" viewBox="0 0 24 24" fill="none"><path d="M4 5a2 2 0 012-2h12a2 2 0 012 2v10a2 2 0 01-2 2h-7l-4 4v-4H6a2 2 0 01-2-2V5z" stroke={c} strokeWidth="1.8" strokeLinejoin="round"/></svg>,
  telegram:(c) => <svg width="14" height="14" viewBox="0 0 24 24"><path d="M21.5 3.5L2.5 11l5.5 2 2 6 3-3.5 5.5 4 3-16z" fill={c}/></svg>,
  send:   (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M4 12L20 4l-7 16-2-7-7-1z" fill={c}/></svg>,
  mic:    (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><rect x="9" y="3" width="6" height="12" rx="3" stroke={c} strokeWidth="1.8"/><path d="M5 11a7 7 0 0014 0M12 18v3" stroke={c} strokeWidth="1.8" strokeLinecap="round"/></svg>,
  clip:   (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M21 11.5l-8.5 8.5a5 5 0 11-7-7l8.5-8.5a3.5 3.5 0 014.95 4.95L10.5 18" stroke={c} strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  mega:   (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M4 9v6h3l9 5V4L7 9H4z" stroke={c} strokeWidth="1.8" strokeLinejoin="round"/><path d="M18 8.5a4 4 0 010 7" stroke={c} strokeWidth="1.8" strokeLinecap="round"/></svg>,
  code:   (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M9 8l-4 4 4 4M15 8l4 4-4 4" stroke={c} strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  globe:  (c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="8.5" stroke={c} strokeWidth="1.8"/><path d="M3.5 12h17M12 3.5c2.5 2.4 2.5 14.6 0 17M12 3.5c-2.5 2.4-2.5 14.6 0 17" stroke={c} strokeWidth="1.6"/></svg>,
  briefcase:(c) => <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><rect x="3" y="7.5" width="18" height="12" rx="2.5" stroke={c} strokeWidth="1.8"/><path d="M9 7.5V6a2 2 0 012-2h2a2 2 0 012 2v1.5" stroke={c} strokeWidth="1.8"/></svg>,
  chevDown:(c) => <svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M6 9l6 6 6-6" stroke={c} strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/></svg>,
  grid:   (c) => <svg width="20" height="20" viewBox="0 0 24 24" fill="none"><rect x="4" y="4" width="7" height="7" rx="2" stroke={c} strokeWidth="1.8"/><rect x="13" y="4" width="7" height="7" rx="2" stroke={c} strokeWidth="1.8"/><rect x="4" y="13" width="7" height="7" rx="2" stroke={c} strokeWidth="1.8"/><rect x="13" y="13" width="7" height="7" rx="2" stroke={c} strokeWidth="1.8"/></svg>,
};

// ──────────────────────────────────────────────────────────────
// Phone shell — PRODUCTION VIEW (Telegram Mini App / browser).
// Бутафория iPhone (notch, status bar, home indicator, рамка 390×844)
// убрана — Telegram WebView и обычный браузер уже дают свой UI.
// Бэкап оригинала с mock-обвёрткой: components.jsx.with-mock-frame.bak
// ──────────────────────────────────────────────────────────────
function Phone({ children, T }) {
  return (
    <div style={{
      width: '100%',
      height: '100dvh',
      position: 'relative',
      display: 'flex',
      flexDirection: 'column',
      background: T.bg,
      color: T.ink,
      fontFamily: '"SF Pro Display", "Inter", -apple-system, system-ui, sans-serif',
      paddingBottom: 80,
      overflow: 'hidden',
    }}>
      {children}
    </div>
  );
}

// ──────────────────────────────────────────────────────────────
// Portrait — static (no animations on face)
// ──────────────────────────────────────────────────────────────
function Portrait({ id, portrait, size = 64, working, T }) {
  return (
    <div style={{
      position: 'relative', width: size, height: size,
      borderRadius: size, flexShrink: 0,
    }}>
      {working && (
        <>
          <div className="aura-pulse" style={{
            position: 'absolute', inset: -6, borderRadius: '50%',
            background: `radial-gradient(circle, ${T.accent}55, ${T.accent}00 70%)`,
          }} />
          <div className="aura-ring" style={{
            position: 'absolute', inset: -2, borderRadius: '50%',
            border: `2px solid ${T.accent}`,
          }} />
        </>
      )}
      <div style={{
        width: size, height: size, borderRadius: size, overflow: 'hidden',
        background: T.portraitBg, position: 'relative', zIndex: 2,
      }}>
        <img src={PORTRAIT[portrait || id]} alt="" style={{
          width: '100%', height: '100%', objectFit: 'cover', display: 'block',
        }} />
      </div>
      <div style={{
        position: 'absolute', right: 0, bottom: 2, zIndex: 3,
        width: size * 0.24, height: size * 0.24, borderRadius: '50%',
        background: working ? T.accent : T.ok,
        boxShadow: `0 0 0 ${Math.max(2, size * 0.05)}px ${T.card}`,
      }}>
        {working && (
          <div className="dot-pulse" style={{
            position: 'absolute', inset: 0, borderRadius: '50%',
            background: T.accent, opacity: 0.5,
          }} />
        )}
      </div>
    </div>
  );
}

// ──────────────────────────────────────────────────────────────
// Live "writing" text
// ──────────────────────────────────────────────────────────────
function LiveText({ text, T }) {
  const [shown, setShown] = React.useState('');
  React.useEffect(() => {
    let i = 0; setShown('');
    const id = setInterval(() => {
      i++; setShown(text.slice(0, i));
      if (i >= text.length) clearInterval(id);
    }, 40);
    return () => clearInterval(id);
  }, [text]);
  return (
    <span style={{ color: T.ink, fontWeight: 500 }}>
      {shown}
      <span className="caret" style={{
        display: 'inline-block', width: 2, height: '0.9em', verticalAlign: '-1px',
        background: T.accent, marginLeft: 1, borderRadius: 1,
      }} />
    </span>
  );
}

// ──────────────────────────────────────────────────────────────
// Progress bar
// ──────────────────────────────────────────────────────────────
function MiniProgress({ pct, T, height = 4 }) {
  return (
    <div style={{
      width: '100%', height, borderRadius: 99,
      background: T.name === 'light' ? 'rgba(110, 92, 244, 0.14)' : 'rgba(255,255,255,0.08)',
      overflow: 'hidden', position: 'relative',
    }}>
      <div className="bar-shimmer" style={{
        width: `${pct}%`, height, borderRadius: 99,
        background: `linear-gradient(90deg, ${T.accent}, ${T.accent}AA)`,
        position: 'relative', transition: 'width 0.5s ease',
      }} />
    </div>
  );
}

// ──────────────────────────────────────────────────────────────
// Employee card
// ──────────────────────────────────────────────────────────────
function EmployeeCard({ p, T }) {
  const working = !!p.task;
  const phase = working ? PHASES.find(ph => ph.key === p.task.phase) : null;
  const phaseIdx = working ? PHASES.findIndex(ph => ph.key === p.task.phase) : -1;
  // #4 — живой спринт даёт реальный прогресс (livePct); иначе оценка по фазе
  const pct = working
    ? (typeof p.task.livePct === 'number' ? p.task.livePct : Math.round(((phaseIdx + 0.7) / PHASES.length) * 100))
    : 0;
  return (
    <div style={{
      background: T.card, borderRadius: 22, padding: 14,
      border: `1px solid ${working ? T.accent + '40' : T.line}`,
      boxShadow: working
        ? `0 10px 24px -16px ${T.accent}AA, ${T.shadow}`
        : T.shadow,
      display: 'flex', flexDirection: 'column', gap: 10,
    }}>
      <div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
        <Portrait id={p.id} portrait={p.portrait || p.id} size={56} working={working} T={T} />
        <div style={{ flex: 1, minWidth: 0 }}>
          <div style={{ fontSize: 15, fontWeight: 700, letterSpacing: -0.2, color: T.ink }}>{p.name}</div>
          <div style={{ fontSize: 11.5, color: T.mute, marginTop: 1 }}>{p.role}</div>
        </div>
      </div>
      {working ? (
        <div style={{ display: 'flex', flexDirection: 'column', gap: 7 }}>
          <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
            <span style={{
              fontSize: 11, fontWeight: 700, color: T.accent,
              letterSpacing: 0.3, textTransform: 'uppercase',
              display: 'flex', alignItems: 'center', gap: 6,
            }}>
              <span className="thinking-dots" style={{ display: 'inline-flex', gap: 2 }}>
                <span className="td" style={{ width: 4, height: 4, borderRadius: 4, background: T.accent }} />
                <span className="td" style={{ width: 4, height: 4, borderRadius: 4, background: T.accent }} />
                <span className="td" style={{ width: 4, height: 4, borderRadius: 4, background: T.accent }} />
              </span>
              {phase.label}
            </span>
            <span style={{ fontSize: 10.5, color: T.mute, fontWeight: 600 }}>{pct}%</span>
          </div>
          <div style={{
            fontSize: 11.5, lineHeight: 1.35,
            background: T.name === 'light' ? 'rgba(110, 92, 244, 0.06)' : 'rgba(139, 123, 251, 0.10)',
            border: `1px solid ${T.accent}1A`,
            borderRadius: 10, padding: '7px 9px',
            color: T.ink, minHeight: 32, display: 'flex', alignItems: 'center',
          }}>
            <LiveText key={p.task.live} text={p.task.live} T={T} />
          </div>
          <MiniProgress pct={pct} T={T} />
        </div>
      ) : (
        <div style={{ display: 'flex', flexDirection: 'column', gap: 7 }}>
          <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
            <span style={{
              fontSize: 11, fontWeight: 700, color: T.ok,
              letterSpacing: 0.3, textTransform: 'uppercase',
              display: 'flex', alignItems: 'center', gap: 6,
            }}>
              <span style={{ width: 5, height: 5, borderRadius: 5, background: T.ok }} />
              Свободен
            </span>
            <span style={{ fontSize: 10.5, color: T.mute, fontWeight: 600 }}>{p.short}</span>
          </div>
          <div style={{
            fontSize: 11.5, lineHeight: 1.35,
            background: T.okBg,
            border: `1px solid ${T.ok}26`,
            borderRadius: 10, padding: '7px 9px',
            color: T.okText, minHeight: 32, fontWeight: 600,
            display: 'flex', alignItems: 'center', justifyContent: 'center',
          }}>Готов к задаче</div>
          <div style={{
            width: '100%', height: 4, borderRadius: 99,
            background: T.name === 'light' ? 'rgba(34,197,94,0.18)' : 'rgba(52,211,153,0.18)',
          }} />
        </div>
      )}
    </div>
  );
}

// ──────────────────────────────────────────────────────────────
// Global status bar
// ──────────────────────────────────────────────────────────────
function GlobalStatusBar({ working, T, onClick }) {
  if (working.length === 0) {
    return (
      <div style={{
        margin: '0 14px 12px', padding: '12px 16px',
        background: T.card, borderRadius: 18,
        border: `1px solid ${T.line}`,
        display: 'flex', justifyContent: 'space-between', alignItems: 'center',
        boxShadow: T.shadowHi,
      }}>
        <div>
          <div style={{ fontSize: 13, fontWeight: 700, color: T.ink, letterSpacing: -0.2 }}>Команда отдыхает</div>
          <div style={{ fontSize: 11, color: T.mute, marginTop: 2 }}>Опиши задачу — и AI-отдел возьмётся за неё</div>
        </div>
        <button onClick={onClick} style={{
          padding: '8px 14px', background: T.accent, color: '#fff',
          border: 'none', borderRadius: 12, fontSize: 12.5, fontWeight: 700,
          fontFamily: 'inherit', display: 'flex', alignItems: 'center', gap: 6,
          cursor: 'pointer',
        }}>{I.plus('#fff')} Задача</button>
      </div>
    );
  }
  const avgPct = Math.round(
    working.reduce((s, p) => {
      const idx = PHASES.findIndex(ph => ph.key === p.task.phase);
      return s + ((idx + 0.7) / PHASES.length) * 100;
    }, 0) / working.length
  );
  return (
    <button onClick={onClick} className="tap-btn" style={{
      all: 'unset', cursor: 'pointer',
      margin: '0 14px 12px', padding: '12px 14px',
      background: T.card, borderRadius: 18,
      border: `1px solid ${T.accent}40`,
      boxShadow: `0 10px 30px -20px ${T.accent}AA, ${T.shadow}`,
      position: 'relative', overflow: 'hidden',
      display: 'block',
    }}>
      <div className="busy-shimmer" style={{
        position: 'absolute', inset: 0, opacity: T.name === 'light' ? 0.06 : 0.10,
        background: `linear-gradient(90deg, ${T.accent}00, ${T.accent}, ${T.accent}00)`,
        backgroundSize: '200% 100%', pointerEvents: 'none',
      }} />
      <div style={{ position: 'relative', display: 'flex', alignItems: 'center', gap: 12 }}>
        <div style={{ display: 'flex' }}>
          {working.slice(0, 4).map((p, i) => (
            <div key={p.id} style={{ marginLeft: i ? -10 : 0, position: 'relative', zIndex: 10 - i }}>
              <div style={{
                width: 32, height: 32, borderRadius: 32, overflow: 'hidden',
                boxShadow: `0 0 0 2px ${T.card}`, background: T.portraitBg,
              }}>
                <img src={PORTRAIT[p.portrait || p.id]} style={{ width: '100%', height: '100%', objectFit: 'cover' }}/>
              </div>
            </div>
          ))}
        </div>
        <div style={{ flex: 1, minWidth: 0 }}>
          <div style={{ fontSize: 13, fontWeight: 700, color: T.ink, letterSpacing: -0.2, display: 'flex', alignItems: 'center', gap: 6 }}>
            <span className="pulse-dot" style={{ width: 7, height: 7, borderRadius: 7, background: T.accent }} />
            {working.length} {pluralRu(working.length, ['работает','работают','работают'])} · ~{14 - Math.floor(avgPct/10)} мин
          </div>
          <div style={{ marginTop: 5 }}>
            <MiniProgress pct={avgPct} T={T} height={3} />
          </div>
        </div>
        <div style={{
          padding: 7, border: `1px solid ${T.line}`, borderRadius: 10,
          display: 'flex', alignItems: 'center', justifyContent: 'center',
        }}>{I.chevron(T.ink)}</div>
      </div>
    </button>
  );
}

function pluralRu(n, [one, few, many]) {
  const m = n % 100; if (m >= 11 && m <= 14) return many;
  const r = n % 10;
  if (r === 1) return one;
  if (r >= 2 && r <= 4) return few;
  return many;
}

// ──────────────────────────────────────────────────────────────
// Tab bar
// ──────────────────────────────────────────────────────────────
function TabBar({ T, activeTab, onChange, unreadChat }) {
  const tabs = [
    { key: 'home',    i: I.home,    l: 'Главная' },
    { key: 'tasks',   i: I.tasks,   l: 'Задачи' },
    { key: 'chat',    i: I.chat,    l: 'Чат' },
    { key: 'team',    i: I.team,    l: 'Команда' },
    { key: 'profile', i: I.profile, l: 'Профиль' },
  ];
  return (
    <div style={{
      paddingTop: 6, paddingBottom: 26,
      borderTop: `1px solid ${T.line}`,
      background: T.name === 'light' ? 'rgba(255,255,255,0.92)' : 'rgba(20,16,33,0.92)',
      backdropFilter: 'blur(20px)',
      display: 'grid', gridTemplateColumns: 'repeat(5,1fr)',
      // ── FIX: TabBar прижат к низу viewport, что бы ни было выше ──
      position: 'fixed',
      bottom: 0,
      left: 0,
      right: 0,
      zIndex: 100,
    }}>
      {tabs.map((t) => {
        const active = activeTab === t.key;
        const c = active ? T.accent : T.mute;
        return (
          <button key={t.key} onClick={() => onChange(t.key)} className="tap-btn" style={{
            all: 'unset', cursor: 'pointer',
            display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 3,
            color: c, padding: '6px 0', position: 'relative',
          }}>
            {t.i(c)}
            {t.key === 'chat' && unreadChat > 0 && (
              <span style={{
                position: 'absolute', top: 2, right: '50%', marginRight: -18,
                minWidth: 16, height: 16, padding: '0 4px', borderRadius: 99,
                background: T.accent, color: '#fff',
                fontSize: 9.5, fontWeight: 700,
                display: 'flex', alignItems: 'center', justifyContent: 'center',
              }}>{unreadChat > 99 ? '99+' : unreadChat}</span>
            )}
            <span style={{ fontSize: 10, fontWeight: active ? 700 : 500, letterSpacing: -0.05 }}>{t.l}</span>
          </button>
        );
      })}
    </div>
  );
}

Object.assign(window, {
  PORTRAIT, PHASES, THEMES, I,
  Phone, Portrait, LiveText, MiniProgress,
  EmployeeCard, GlobalStatusBar, TabBar, pluralRu,
});
