    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Unbounded:ital,wght@0,400;0,600;0,800;1,800&family=Roboto+Mono:wght@700&display=swap');
    :root {
        --primary: #FFC107; --primary-hover: #ffcf33; --primary-light: rgba(255, 193, 7, 0.15);
        --bg-body: #0a0a0e; --bg-sidebar: #121218; --bg-surface: #181820; --bg-surface-hover: #22222d;
        --text-main: #ffffff; --text-muted: #8a8d9b; --border: #262631;
        --msg-mine: #FFC107; --msg-mine-text: #000000;
        --msg-theirs: #22222d; --msg-theirs-text: #ffffff;
        --danger: #ff3366; --success: #00e676; --info: #3b82f6;
        --radius-lg: 20px; --radius-md: 12px; --radius-sm: 8px;
        --nav-height: 65px;
    }

    [data-theme="light"] {
        --bg-body: #f0f2f5; --bg-sidebar: #ffffff; --bg-surface: #ffffff; --bg-surface-hover: #f8fafc;
        --text-main: #0f172a; --text-muted: #64748b; --border: #e2e8f0;
        --msg-mine: #FFC107; --msg-mine-text: #000000;
        --msg-theirs: #f1f5f9; --msg-theirs-text: #0f172a;
    }

    [data-theme="yellow"] {
        --primary: #FF8F00; --primary-hover: #FF6F00; --primary-light: rgba(255, 143, 0, 0.15);
        --bg-body: #FFFDE7; --bg-sidebar: #FFC107; --bg-surface: #FFECB3; --bg-surface-hover: #FFE082;
        --text-main: #212121; --text-muted: #5D4037; --border: #FFCA28;
        --msg-mine: #FF8F00; --msg-mine-text: #FFFFFF;
        --msg-theirs: #FFFFFF; --msg-theirs-text: #212121;
    }

    /* БАЗОВЫЕ СТИЛИ */
    html, body { margin: 0; padding: 0; height: 100vh; height: 100dvh; width: 100vw; overflow: hidden; background: var(--bg-body); font-family: 'Inter', sans-serif; color: var(--text-main); transition: background-color 0.3s ease, color 0.3s ease; overscroll-behavior-y: none; overscroll-behavior-x: none; }
    * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
    h1, h2, h3, h4 { font-family: 'Unbounded', sans-serif; margin: 0; text-transform: uppercase; }
    ::-webkit-scrollbar { width: 4px; height: 4px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: rgba(138, 141, 155, 0.3); border-radius: 10px; }

    /* МЕССЕНДЖЕР И ЛЕЙАУТ */
    .messenger-layout { display: flex; height: 100vh !important; height: 100dvh !important; width: 100vw; max-width: 1400px; margin: 0 auto; background: var(--bg-surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border); position: relative; overflow: hidden; }
    .sidebar { width: 380px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg-sidebar); flex-shrink: 0; z-index: 10; position: relative; height: 100%;}
    .sidebar-header { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg-sidebar); z-index: 2;}
    .app-brand { font-family: 'Unbounded', sans-serif; font-size: 20px; font-weight: 800; font-style: italic; color: var(--text-main); letter-spacing: -0.5px; }
    .app-brand span { color: var(--primary); }
    [data-theme="yellow"] .app-brand { color: #000; }
    [data-theme="yellow"] .app-brand span { color: #FFFFFF; }
    
    .btn-circle { background: var(--bg-surface-hover); border: 1px solid var(--border); color: var(--text-main); border-radius: 50%; width: 36px; height: 36px; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; flex-shrink: 0; }
    .btn-circle:hover { background: var(--primary); color: #000; border-color: var(--primary); }
    [data-theme="yellow"] .btn-circle { border-color: rgba(0,0,0,0.2); color: #000; background: rgba(0,0,0,0.05); }

    .tab-content { flex: 1; overflow-y: auto; display: none; flex-direction: column; padding-bottom: var(--nav-height); }
    .tab-content.active { display: flex; }

    .bottom-nav { 
        position: absolute; /* 🔥 Вернули absolute для ПК */
        bottom: 0; 
        left: 0; 
        width: 100%; 
        height: calc(var(--nav-height) + env(safe-area-inset-bottom)); 
        background: var(--bg-surface); 
        border-top: 1px solid var(--border); 
        display: flex; 
        justify-content: space-around; 
        align-items: center; 
        z-index: 9999; 
        padding-bottom: env(safe-area-inset-bottom); 
    }
    .nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-muted); cursor: pointer; transition: 0.2s; height: 100%; font-size: 10px; font-weight: 600; font-family: 'Inter'; }
    .nav-item:hover { color: var(--text-main); background: var(--bg-surface-hover); }
    .nav-item.active { color: var(--primary); }
    [data-theme="yellow"] .nav-item.active { color: #000; font-weight: 800; }

    .search-box { padding: 15px; border-bottom: 1px solid var(--border); }
    .search-input { width: 100%; background: var(--bg-surface-hover); border: 1px solid var(--border); color: var(--text-main); padding: 12px 20px; border-radius: 50px; font-family: 'Inter'; outline: none; transition: 0.2s; font-size: 13px;}
    .search-input:focus { border-color: var(--primary); }

    /* СПИСКИ И ЧАТЫ */
    .chat-list { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 100px 10px; } 
    .chat-item { display: flex; align-items: center; gap: 15px; padding: 12px 15px; border-radius: 12px; cursor: pointer; transition: 0.2s; position: relative;}
    .contact-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; max-height: 300px; }
    .contact-item { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 10px 15px; border-radius: 12px; cursor: pointer; transition: 0.2s; background: transparent; border: 1px solid transparent; }
    .contact-item:hover { background: var(--bg-surface-hover); border-color: var(--border); }
    [data-theme="yellow"] .contact-item:hover { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.1); }
    .chat-item:hover { background: var(--bg-surface-hover); }
    .chat-item.active { background: var(--primary-light); border-left: 3px solid var(--primary); }
    [data-theme="yellow"] .chat-item.active { border-left-color: #000; background: rgba(0,0,0,0.1); }
    [data-theme="yellow"] #chat-item-newsfeed .chat-name { color: #ffffff !important; }
    
    .avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--bg-surface-hover); border: 1px solid var(--border); display: flex; justify-content: center; align-items: center; font-family: 'Unbounded'; font-weight: 800; color: var(--primary); flex-shrink: 0; font-size:18px; text-transform:uppercase; transition: 0.2s;}
    .avatar.clickable:hover { box-shadow: 0 0 10px var(--primary); border-color: var(--primary); cursor: pointer; }
    [data-theme="yellow"] .avatar { border-color: rgba(0,0,0,0.2); background: rgba(0,0,0,0.05); color: #000; }
    
    .chat-info { flex: 1; overflow: hidden; pointer-events: none;}
    .chat-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); }
    .chat-preview { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; display: flex; align-items: center; gap: 4px; }

    /* ОКНО ЧАТА */
    .chat-area { flex: 1; display: flex; flex-direction: column; background: var(--bg-surface); position: relative; min-width: 0; transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); height: 100%; }
    .chat-header { padding: 12px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 15px; background: var(--bg-surface); z-index: 10; }
    
    .header-status-badge { font-size: 9px; font-family: 'Unbounded'; font-weight: 800; padding: 3px 8px; border-radius: 4px; text-transform: uppercase; border: 1px solid var(--border); cursor: default;}
    .role-super { color: var(--danger); border-color: rgba(255,51,102,0.3); background: rgba(255,51,102,0.1); }
    .role-admin { color: #ff9100; border-color: rgba(255,145,0,0.3); background: rgba(255,145,0,0.1); }
    .role-judge { color: #a855f7; border-color: rgba(168,85,247,0.3); background: rgba(168,85,247,0.1); }
    .role-cap { color: var(--info); border-color: rgba(59,130,246,0.3); background: rgba(59,130,246,0.1); }
    .role-rider { color: var(--text-muted); }

    .messages-container-wrapper { 
        flex: 1; position: relative; display: flex; flex-direction: column; overflow: hidden; 
        background-color: var(--bg-body); 
        background-image: url("data:image/svg+xml,%3Csvg width='60' height='30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 15 Q 15 0, 30 15 T 60 15' stroke='%23ffffff' fill='none' stroke-width='1' opacity='0.08'/%3E%3C/svg%3E"); 
        background-repeat: repeat; background-size: 60px 40px; 
    }
    [data-theme="light"] .messages-container-wrapper,
    [data-theme="yellow"] .messages-container-wrapper {
        background-image: url("data:image/svg+xml,%3Csvg width='60' height='30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 15 Q 15 0, 30 15 T 60 15' stroke='%23000000' fill='none' stroke-width='1' opacity='0.1'/%3E%3C/svg%3E");
    }
    
    .messages-container { flex: 1; overflow-y: auto; padding: 25px 20px; display: flex; flex-direction: column; gap: 15px; scroll-behavior: smooth; }
    .scroll-bottom-btn { position: absolute; right: 20px; bottom: 20px; width: 45px; height: 45px; border-radius: 50%; background: var(--bg-surface-hover); border: 1px solid var(--border); color: var(--text-main); display: none; justify-content: center; align-items: center; cursor: pointer; box-shadow: 0 5px 15px rgba(0,0,0,0.3); z-index: 20; transition: 0.2s; }
    .scroll-bottom-btn:hover { background: var(--primary); color: #000; border-color: var(--primary); }
    
    .message-row { display: flex; flex-direction: column; max-width: 85%; position: relative; cursor: pointer; -webkit-user-select: none; user-select: none; }
    .message-row.mine { align-self: flex-end; align-items: flex-end; }
    .message-row.theirs { align-self: flex-start; align-items: flex-start; }

    .msg-sender-name { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; margin-left: 4px; display: flex; gap: 6px; align-items: center; transition: 0.2s;}
    .msg-sender-name.clickable:hover { color: var(--primary); }
    
    .message-bubble { padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.4; position: relative; word-wrap: break-word; min-width: 100px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
    .message-row.mine .message-bubble { background: var(--msg-mine); color: var(--msg-mine-text); border-bottom-right-radius: 4px; }
    .message-row.theirs .message-bubble { background: var(--msg-theirs); color: var(--msg-theirs-text); border-bottom-left-radius: 4px; border: 1px solid var(--border); }
    .msg-meta-row { display: flex; justify-content: flex-end; align-items: center; gap: 5px; margin-top: 4px; font-size: 10px; opacity: 0.7; font-weight: 600;}
    .msg-edited { font-style: italic; }

    .message-row.system-bot { align-self: center; align-items: center; max-width: 90%; margin: 15px 0; cursor: default; }
    .bot-bubble { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 16px; padding: 15px 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); position: relative; overflow: hidden; min-width: 250px; }
    .bot-bubble::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--primary); }
    .bot-name { font-family: 'Unbounded', sans-serif; font-size: 11px; font-weight: 800; color: var(--primary); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
    .bot-badge { background: rgba(255, 193, 7, 0.2); color: var(--primary); padding: 2px 6px; border-radius: 4px; font-size: 8px; border: 1px solid rgba(255, 193, 7, 0.3);}
    .bot-text { font-size: 14px; line-height: 1.5; color: var(--text-main); }
    .bot-time { font-size: 10px; color: var(--text-muted); text-align: right; margin-top: 10px; font-weight: 600; }

    .reactions-box { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
    .reaction-tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; background: rgba(0,0,0,0.15); border: 1px solid var(--border); border-radius: 12px; font-size: 12px; transition: 0.2s; font-weight: bold;}
    [data-theme="light"] .reaction-tag { background: rgba(0,0,0,0.05); }
    .reaction-tag.voted { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
    [data-theme="yellow"] .reaction-tag.voted { background: #000; border-color: #000; color: #FF8F00; }

    /* МЕНЮ ДЕЙСТВИЙ И ПОЛЯ ВВОДА */
    .ctx-menu-overlay { display: none; position: fixed; top:0; left:0; width:100vw; height:100vh; height:100dvh; background: rgba(0,0,0,0.5); z-index: 999999; backdrop-filter: blur(2px); flex-direction: column; justify-content: flex-end; align-items: center; }
    .ctx-menu-box { background: var(--bg-surface); width: 100%; max-width: 400px; border-top-left-radius: 24px; border-top-right-radius: 24px; padding: 20px; box-shadow: 0 -10px 40px rgba(0,0,0,0.3); border-top: 1px solid var(--border); animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
    @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
    
    .ctx-reactions-row { display: flex; justify-content: space-between; padding: 10px 20px; background: var(--bg-surface-hover); border-radius: 50px; margin-bottom: 20px; border: 1px solid var(--border); }
    .ctx-react-btn { width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; background: transparent; }
    .ctx-react-btn:hover { transform: scale(1.2); background: rgba(255,255,255,0.1); }
    
    .ctx-action-list { display: flex; flex-direction: column; gap: 4px; }
    .ctx-action-item { display: flex; align-items: center; gap: 15px; padding: 15px; border-radius: 12px; cursor: pointer; color: var(--text-main); font-weight: 600; font-size: 15px; transition: 0.2s; }
    .ctx-action-item:hover { background: var(--bg-surface-hover); color: var(--primary); }
    .ctx-action-item.danger { color: var(--danger); }
    .ctx-action-item.danger:hover { background: rgba(255,51,102,0.1); }

    .input-wrapper { display:flex; flex-direction:column; background: var(--bg-surface); border-top: 1px solid var(--border); position: relative; z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
    .reply-edit-bar { display: none; padding: 10px 20px; background: var(--bg-surface-hover); border-bottom: 1px solid var(--border); align-items: center; justify-content: space-between; font-size: 13px; border-left: 4px solid var(--primary);}
    .input-area { padding: 12px 20px; display: flex; gap: 10px; align-items: flex-end; position: relative; }
    
    #filePreviewBox { display:none; position:absolute; bottom:calc(100% + 10px); left:20px; background:var(--bg-surface-hover); padding:10px 15px; border:1px solid var(--primary); border-radius:12px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); align-items:center; gap:10px; z-index:20; max-width: calc(100% - 40px); }
    
    .attach-btn { width: 46px !important; height: 46px !important; min-width: 46px !important; min-height: 46px !important; border-radius: 50%; background: transparent; border: none; color: var(--text-muted); display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; flex-shrink: 0 !important; }
    .attach-btn:hover { color: var(--primary); background: var(--bg-surface-hover); }
    
    .chat-input { flex: 1 1 auto; min-width: 0; background: var(--bg-surface-hover); border: 1px solid var(--border); color: var(--text-main); padding: 12px 20px; border-radius: 24px; font-family: 'Inter'; font-size: 15px; resize: none; outline: none; height: 46px; min-height: 46px; max-height: 120px; overflow-y: auto; line-height: 1.4; box-sizing: border-box; }
    .chat-input:focus { border-color: var(--primary); }
    
    .send-btn { width: 46px !important; height: 46px !important; min-width: 46px !important; min-height: 46px !important; border-radius: 50%; background: var(--primary); border: none; color: #000; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; flex-shrink: 0 !important; }
    .send-btn:active { transform: scale(0.9); }
    [data-theme="yellow"] .send-btn { background: #000; color: #FF8F00; }
    
    @keyframes v-fly { 0% { transform: rotate(0deg) translateY(0); } 20% { transform: rotate(180deg) translateY(0); } 50% { transform: rotate(180deg) translateY(-15px); } 80% { transform: rotate(180deg) translateY(0); } 100% { transform: rotate(0deg) translateY(0); } }
    .v-fly { animation: v-fly 0.8s ease-in-out; }

    /* МОДАЛЬНЫЕ ОКНА И КНОПКИ */
    .modal-overlay { display: none; position: fixed; top:0; left:0; width:100vw; height:100vh; height:100dvh; background: rgba(0,0,0,0.8); z-index: 99999; justify-content: center; align-items: center; backdrop-filter: blur(8px); }
    .modal-box { background: var(--bg-surface); padding: 30px; border-radius: var(--radius-lg); width: 480px; max-width: 90%; max-height: 85vh; display: flex; flex-direction: column; border: 1px solid var(--border); box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
    .modal-select, .modal-input { width: 100%; padding: 14px 16px; margin-bottom: 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--bg-body); font-family: 'Inter', sans-serif; outline: none; transition: 0.2s; color: var(--text-main); }
    .modal-select:focus, .modal-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.15); }
    .btn-black { background: var(--text-main); color: var(--bg-body); border: none; border-radius: var(--radius-sm); cursor: pointer; font-weight: 800; font-family: 'Unbounded', sans-serif; text-transform: uppercase; font-size: 13px; transition: all 0.2s; padding: 16px; width: 100%; }
    .btn-black:hover { opacity: 0.9; transform: translateY(-2px); }

    .main-fab { position: absolute; bottom: calc(var(--nav-height) + 20px); right: 20px; width: 60px; height: 60px; border-radius: 50%; background: var(--primary); color: #000; display: flex; justify-content: center; align-items: center; box-shadow: 0 5px 20px rgba(255,193,7,0.4); z-index: 50; cursor: pointer; border: none; transition: 0.2s; }
    .main-fab:active { transform: scale(0.9); }
    [data-theme="yellow"] .main-fab { background: #000; color: #FF8F00; }

    .empty-chat { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; width: 100%; margin: auto; color: var(--text-muted); font-family: 'Unbounded'; font-size: 14px; opacity: 0.5; text-align: center; }

    /* ПРОФИЛЬ И ДАШБОРДЫ */
    .dash-container { padding: 20px; display: flex; flex-direction: column; gap: 20px; }
    .dash-license-card { background: linear-gradient(135deg, var(--bg-body) 0%, var(--bg-surface) 100%); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px; display: flex; justify-content: space-between; align-items: center; position: relative; overflow: hidden; box-shadow: 0 10px 25px rgba(0,0,0,0.1); min-height: 160px; }
    .dash-license-card::before { content:''; position:absolute; top:0; right:0; width: 150px; height: 100%; background: var(--primary); transform: skewX(-25deg) translateX(50px); opacity: 0.1; }
    .dash-rider-info { display: flex; flex-direction: column; gap: 8px; z-index: 2; }
    .dash-rider-name { font-size: 24px; font-weight: 800; color: var(--text-main); letter-spacing: -1px; line-height: 1.1; }
    .dash-rider-meta { font-size: 12px; color: var(--text-muted); font-weight: 500; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;}
    
    .dash-cluster { text-align: right; z-index: 2; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; }
    .dash-cluster-letter { font-size: 54px; font-family: 'Unbounded'; font-weight: 800; color: var(--primary); line-height: 1; text-shadow: 0 0 20px rgba(255, 193, 7, 0.3); }
    .dash-cluster-label { font-size: 10px; color: var(--text-muted); font-weight: 700; letter-spacing: 2px; margin-bottom: -2px; }

    .dash-stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .dash-stat-card { background: var(--bg-surface-hover); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 15px; display: flex; flex-direction: column; gap: 5px; }
    .dash-stat-val { font-family: 'Roboto Mono', monospace; font-size: 20px; font-weight: 700; color: var(--text-main); }
    .dash-stat-lbl { font-size: 10px; font-family: 'Unbounded'; color: var(--text-muted); font-weight: 600; text-transform: uppercase;}

    .dash-chart-container { background: var(--bg-surface-hover); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 15px; height: 220px; }
    
    .dash-section-title { font-size: 16px; color: var(--text-main); margin-bottom: 12px; display: flex; align-items: center; gap: 10px; font-family: 'Unbounded'; font-weight:700;}
    .dash-table-wrapper { background: var(--bg-surface-hover); border: 1px solid var(--border); border-radius: var(--radius-md); overflow-x: auto; width: 100%;}
    .dash-table { width: 100%; border-collapse: collapse; min-width: 400px; }
    .dash-table th { text-align: left; padding: 12px 15px; font-family: 'Unbounded'; font-size: 10px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
    .dash-table td { padding: 12px 15px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 500; color: var(--text-main); vertical-align: middle; }
    .dash-table tr:last-child td { border-bottom: none; }
    .dash-status { font-size:9px; font-family:'Unbounded'; font-weight:800; padding:4px 8px; border-radius:4px; display:inline-block; text-transform:uppercase;}
    
    .role-block { border: 1px dashed var(--border); border-radius: var(--radius-md); padding: 20px; margin-top: 10px; background: rgba(0,0,0,0.05); }
    .role-block-title { display:flex; align-items:center; gap:8px; font-family:'Unbounded'; font-size:14px; margin-bottom:15px; font-weight:700;}

    /* 🏛️ АРХИТЕКТУРА SUPER APP (ВИЛКА + ПЕЛОТОН) */
    body.peloton-mode #mainChatArea { display: none !important; }
    body.peloton-mode #pelotonWorkspace { display: flex !important; }

    #pelotonWorkspace {
        display: none; flex: 1; flex-direction: column;
        background: var(--bg-body); height: 100vh; height: 100dvh;
        overflow: hidden; position: relative; z-index: 10;
    }

    .crm-top-nav {
        display: flex; gap: 12px; padding: 20px 40px;
        background: var(--bg-surface); border-bottom: 1px solid var(--border);
        overflow-x: auto; scrollbar-width: none; flex-shrink: 0;
    }
    .crm-top-nav::-webkit-scrollbar { display: none; }
    .crm-tab-btn {
        background: var(--bg-body); border: 1px solid var(--border);
        padding: 12px 24px; font-family: 'Unbounded', sans-serif; font-size: 11px;
        font-weight: 800; color: var(--text-muted); text-transform: uppercase;
        border-radius: 50px; cursor: pointer; transition: 0.3s; white-space: nowrap;
        display: flex; align-items: center; gap: 8px;
    }
    .crm-tab-btn:hover { color: var(--text-main); border-color: var(--text-muted); }
    .crm-tab-btn.active {
        background: var(--primary); color: #000; border-color: var(--primary);
        box-shadow: 0 4px 15px rgba(255,193,7,0.3);
    }
    .crm-content { flex: 1; padding: 20px 40px; overflow-y: auto; position: relative; }
    .crm-mobile-back { 
        display: none; align-items: center; gap: 8px; padding: 15px 20px; 
        background: var(--bg-surface); border-bottom: 1px solid var(--border); 
        color: var(--text-muted); font-family: 'Unbounded'; font-size: 11px; 
        font-weight: 800; cursor: pointer; transition: 0.2s;
    }
    .crm-mobile-back:active { background: var(--bg-body); }

    /* 📊 СТИЛИ КОНТЕНТА ПЕЛОТОНА (ТАБЛИЦЫ/КАРТОЧКИ) */
    .peloton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; padding: 20px; }
    .peloton-card { background: linear-gradient(135deg, var(--bg-surface-hover) 0%, var(--bg-surface) 100%); border: 1px solid var(--border); border-radius: 16px; padding: 20px; cursor: pointer; transition: 0.2s; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
    .peloton-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); }
    .peloton-card.active { border-color: var(--primary); background: var(--primary-light); }
    .peloton-icon { width: 50px; height: 50px; border-radius: 50%; background: var(--bg-body); display: flex; justify-content: center; align-items: center; color: var(--primary); }

    .p-team-dashboard { display: none; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
    .p-team-dashboard.active { display: flex; }
    .p-stat-card { flex: 1; min-width: 150px; background: var(--bg-surface); border: 1px solid var(--border); padding: 16px 20px; border-radius: var(--radius-lg); box-shadow: var(--shadow-card); display: flex; flex-direction: column; justify-content: center; gap: 6px; }
    .p-stat-title { font-size: 10px; color: var(--text-muted); font-family: 'Unbounded', sans-serif; text-transform: uppercase; font-weight: 800; letter-spacing: 0.5px; }
    .p-stat-value { font-size: 24px; color: var(--text-main); font-family: 'Roboto Mono', monospace; font-weight: bold; }
    .p-stat-value.highlight { color: var(--primary); text-shadow: 0 0 15px rgba(255, 193, 7, 0.3); }
    
    .chat-link-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: rgba(255, 193, 7, 0.1); color: var(--primary); padding: 0 20px; height: 100%; min-height: 48px; border-radius: var(--radius-sm); font-family: 'Unbounded'; font-size: 11px; font-weight: 800; text-decoration: none; transition: 0.2s; border: 1px dashed var(--primary); cursor: pointer; width: 100%; }
    .chat-link-btn:hover { background: var(--primary); color: #000; box-shadow: var(--shadow-glow); border-style: solid; }
    
    .p-calendar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; padding-bottom: 20px; }
    .p-race-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; transition: all 0.3s ease; box-shadow: var(--shadow-card); }
    .p-race-card:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: 0 15px 35px rgba(0,0,0,0.6), 0 0 15px rgba(255,193,7,0.1); }
    .p-race-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.05); display: flex; justify-content: space-between; align-items: flex-start; background: linear-gradient(180deg, rgba(255,193,7,0.05) 0%, transparent 100%); }
    .p-race-date { display: flex; flex-direction: column; align-items: center; background: var(--bg-body); padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); min-width: 60px; }
    .p-race-day { font-family: 'Unbounded', sans-serif; font-size: 20px; font-weight: 800; color: var(--primary); line-height: 1; }
    .p-race-month { font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; margin-top: 4px; text-align: center; }
    .p-race-tags { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
    .p-race-tag { font-size: 9px; font-family: 'Unbounded', sans-serif; font-weight: 800; padding: 4px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
    .tag-peloton { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(255,51,102,0.2); }
    .tag-team { background: rgba(59,130,246,0.15); color: var(--info); border: 1px solid rgba(59,130,246,0.2); }
    .tag-personal { background: var(--bg-body); color: var(--text-muted); border: 1px solid var(--border); }
    .tag-type { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(255,193,7,0.2); }
    .p-race-body { padding: 20px; flex: 1; display: flex; flex-direction: column; }
    .p-race-title { font-family: 'Unbounded', sans-serif; font-size: 16px; font-weight: 800; color: var(--text-main); margin: 0 0 8px 0; line-height: 1.3; }
    .p-race-org { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-bottom: 16px; }
    .p-race-meta { display: flex; gap: 16px; margin-bottom: 20px; background: var(--bg-body); padding: 12px; border-radius: var(--radius-sm); }
    .p-meta-item { display: flex; flex-direction: column; gap: 4px; }
    .p-meta-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
    .p-meta-value { font-family: 'Roboto Mono', monospace; font-size: 14px; font-weight: 700; color: var(--text-main); }
    .p-race-footer { padding: 16px 20px; border-top: 1px solid var(--border); background: rgba(0,0,0,0.2); display: flex; gap: 10px; flex-wrap: wrap; }
    
    .p-btn { flex: 1; padding: 12px; border-radius: var(--radius-sm); font-family: 'Unbounded', sans-serif; font-size: 11px; font-weight: 800; text-transform: uppercase; border: none; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center; gap: 8px; white-space: nowrap; }
    .p-btn-black { background: var(--text-main); color: var(--bg-body); border: none; border-radius: var(--radius-sm); cursor: pointer; font-weight: 800; font-family: 'Unbounded'; text-transform: uppercase; font-size: 11px; transition: all 0.2s; padding: 12px; width: 100%; display: flex; justify-content: center; align-items: center; gap: 8px; }
    .p-btn-black:hover { opacity: 0.9; transform: translateY(-2px); }
    .p-btn-reg { background: var(--bg-body); color: var(--text-main); border: 1px solid var(--border); }
    .p-btn-reg:hover { border-color: var(--primary); color: var(--primary); }
    .p-btn-live { background: rgba(255,51,102,0.1); color: var(--danger); border: 1px solid var(--danger); }
    .p-btn-live:hover { background: var(--danger); color: #fff; box-shadow: 0 4px 15px rgba(255,51,102,0.3); }
    .p-btn-res { background: var(--success); color: #000; }

    .p-table-container { background: var(--bg-surface); border-radius: var(--radius-lg); border: 1px solid var(--border); overflow-x: auto; margin-bottom: 20px; }
    .p-roster-table { width: 100%; border-collapse: collapse; min-width: 600px; }
    .p-roster-table th { text-align: left; color: var(--text-muted); padding: 16px; font-size: 10px; text-transform: uppercase; font-family: 'Unbounded'; font-weight: 800; border-bottom: 1px solid var(--border); }
    .p-roster-table td { padding: 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13px; color: var(--text-main); white-space: nowrap; }
    .p-roster-table tr:hover { background: var(--bg-surface-hover); }

    .tab-btn { background: transparent; color: var(--text-muted); font-family: 'Unbounded', sans-serif; font-size: 11px; font-weight: 700; text-transform: uppercase; border: none; padding: 8px 16px; border-radius: 50px; cursor: pointer; transition: 0.2s; }
    .tab-btn.active { background: var(--primary); color: #000; }

    @keyframes dot-pulse { 0% { transform: scale(0.8); opacity: 0.5; } 50% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(0.8); opacity: 0.5; } }
    .live-group-header td { padding: 10px 8px; background: var(--bg-surface-hover); color: var(--primary); font-family: 'Unbounded'; font-weight: 800; font-size: 11px; text-transform: uppercase; }

    /* ⚙️ ПАНЕЛЬ УПРАВЛЕНИЯ И РЕДАКТОР СОСТАВА */
    .admin-bar { background: var(--bg-surface); border: 1px solid var(--primary); color: var(--text-main); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-glow); margin-bottom: 20px; }
    .admin-bar-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; }
    .admin-bar-header h3 { color: var(--primary) !important; font-size: 13px; margin: 0; display: flex; align-items: center; gap: 10px; font-family:'Unbounded';}
    .admin-bar-content { margin-top: 20px; display: none; }
    .admin-bar.open .admin-bar-content { display: flex; }
    .admin-controls-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; width: 100%; }
    .admin-select { flex:1; min-width: 200px; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-body); color: var(--text-main); font-family: 'Inter'; outline: none; }
    .admin-select:focus { border-color: var(--primary); }
    .admin-btn { padding: 12px 20px; border-radius: var(--radius-sm); border: none; font-family: 'Unbounded', sans-serif; font-size: 11px; font-weight: 800; cursor: pointer; transition: 0.2s; white-space: nowrap; display:flex; align-items:center; justify-content:center;}
    .admin-btn-primary { background: var(--primary); color: #000; }
    .admin-btn-secondary { background: var(--bg-body); color: var(--text-main); border: 1px solid var(--border); }
    .admin-btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }

    .inline-add-row { background-color: var(--primary-light) !important; }
    .inline-add-row td { padding: 12px 16px !important; border-bottom: 2px solid var(--primary) !important; }
    .inline-form-grid { display: grid; grid-template-columns: 120px minmax(150px, 1fr) 80px 140px 80px; gap: 10px; align-items: center; width: 100%; }    
    .inline-input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: 'Inter'; font-size: 13px; outline: none; background: var(--bg-body); color: var(--text-main); box-sizing: border-box; }
    .inline-input:focus { border-color: var(--primary); }
    .btn-edit { color: var(--text-main); border: 1px solid var(--border); background: transparent; width: 30px; height: 30px; border-radius: 6px; cursor: pointer; display:inline-flex; align-items:center; justify-content:center; transition: 0.2s;}
    .btn-edit:hover { background: var(--primary); color: #000; border-color: var(--primary); }
    .btn-del { color: var(--danger); border: 1px solid rgba(255,51,102,0.3); background: rgba(255,51,102,0.1); width: 30px; height: 30px; border-radius: 6px; cursor: pointer; display:inline-flex; align-items:center; justify-content:center; transition: 0.2s;}
    .btn-del:hover { background: var(--danger); color: #fff; }

    /* ЗАГЛУШКА VILKA SPLASH */
    .vilka-splash {
        position: fixed; 
        top: 0; left: 0; width: 100%; height: 100vh; height: 100dvh; 
        background-color: #ffbf00; display: flex; justify-content: center; align-items: center; 
        z-index: 999999; margin: 0; padding: 0; opacity: 1; 
        transition: opacity 0.5s ease-out, visibility 0.5s; visibility: visible;
    }
    .vilka-splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
    .vilka-splash-content { text-align: center; }
    .vilka-splash-logo { max-width: 200px; height: auto; animation: vilka-heartbeat 1.5s ease-in-out infinite; }
    @keyframes vilka-heartbeat { 0% { transform: scale(1); } 15% { transform: scale(1.15); } 30% { transform: scale(1); } 45% { transform: scale(1.20); } 60% { transform: scale(1); } 100% { transform: scale(1); } }

    /* 🔥 РАСШИРЯЕМ МОДАЛЬНОЕ ОКНО LIVE-ПРОТОКОЛА */
    #liveBoardModal > div {
        width: 95vw !important; max-width: 1200px !important; 
        height: 90vh !important; max-height: 90vh !important;
        overflow-y: auto !important; border-radius: 20px !important; padding: 30px !important;
    }
    #liveBoardTable { width: 100% !important; min-width: 600px; }
    #liveBoardModal > div::-webkit-scrollbar { width: 8px; }
    #liveBoardModal > div::-webkit-scrollbar-thumb { background-color: var(--primary); border-radius: 10px; }
/* 🔥 СТИЛИ ДЛЯ РАДАРА */
    @keyframes radar-pulse {
        0% { box-shadow: 0 0 0 0 rgba(255, 51, 102, 0.7); }
        70% { box-shadow: 0 0 0 10px rgba(255, 51, 102, 0); }
        100% { box-shadow: 0 0 0 0 rgba(255, 51, 102, 0); }
    }
    .radar-pulse-anim {
        animation: radar-pulse 2s infinite;
    }
    /* 🔥 МЕДИАЗАПРОСЫ (МОБИЛКИ) */
    @media (max-width: 768px) {
        .bottom-nav { position: fixed !important; } /* 🔥 Лекарство от багов клавиатуры только для телефонов */
        .sidebar { width: 100%; position: absolute; height: 100%; z-index: 10; }
        .chat-area { width: 100%; position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 20; transform: translateX(100%); }
        .chat-area.mobile-open { transform: translateX(0); }
        .back-btn { display: flex !important; align-items: center; justify-content: center; width: 40px; height: 40px; background: transparent; border: none; color: var(--text-main); cursor: pointer; margin-right: 5px; }
        .dash-license-card { flex-direction: column; align-items: flex-start; gap: 20px; padding:20px;}
        .dash-cluster { align-items: flex-start; }
        .ctx-menu-box { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }

        /* CRM Мобилка */
        #pelotonWorkspace { position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; z-index: 200; padding-bottom: 80px; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
        #pelotonWorkspace.mobile-open { transform: translateX(0); }
        .crm-top-nav { padding: 15px 20px; overflow-x: auto; flex-wrap: nowrap; }
        .crm-content { padding: 15px 20px; }
        .crm-mobile-back { display: flex !important; }
        body.peloton-mode .app-sidebar { z-index: 201; }
        
        /* Инлайн форма */
        input#pelotonSearchInput { max-width: 100% !important; }
        .inline-add-row td { position: sticky !important; left: 0 !important; padding: 15px !important; background: var(--bg-surface) !important; border-left: 4px solid var(--primary) !important; z-index: 5; }
        .inline-form-grid { display: flex !important; flex-direction: column !important; gap: 12px !important; width: calc(100vw - 70px) !important; box-sizing: border-box; }
        .inline-form-grid > div:nth-child(5) { display: none !important; }
        .inline-input { height: 44px !important; font-size: 14px !important; }
        .admin-controls-row { flex-direction: column; align-items: stretch; }
    }
	
	/* Анимация и стили шторки */
#curtainContainer {
    position: relative;
    z-index: 10;
}
.chat-curtain {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: var(--bg-surface);
}
.chat-curtain.open {
    max-height: 600px;
    overflow-y: auto;
}
.curtain-toggle-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background-color 0.2s;
}
.curtain-toggle-bar:hover {
    background: var(--bg-surface-hover);
}
.curtain-toggle-bar span {
    font-family: 'Unbounded', sans-serif;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 4px; /* Тот самый разреженный стильный текст */
    color: var(--text-muted);
    text-transform: uppercase;
    transition: color 0.2s;
}
.curtain-toggle-bar:hover span, 
.curtain-toggle-bar.open span {
    color: var(--primary);
}
.curtain-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    margin-top: 5px;
    transition: background-color 0.3s, transform 0.3s;
}
.curtain-toggle-bar:hover .curtain-handle,
.curtain-toggle-bar.open .curtain-handle {
    background: var(--primary);
}
/* Остальные внутренности шторки оставляем без изменений */
.curtain-content { padding: 15px; font-size: 13px; color: var(--text-main); line-height: 1.5; }
.curtain-image { width: 100%; max-height: 200px; object-fit: cover; border-radius: 8px; margin-bottom: 10px; }
.curtain-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.curtain-btn { flex: 1 1 calc(50% - 8px); min-width: 120px; padding: 8px; text-align: center; background: var(--bg-surface-hover); border: 1px solid var(--primary); color: var(--primary) !important; border-radius: 6px; text-decoration: none; font-family: 'Unbounded', sans-serif; font-size: 10px; font-weight: 800; transition: 0.2s; }
.curtain-btn:hover { background: var(--primary); color: #000 !important; } /* 🔥 ВЕРНУЛИ ЗАКРЫВАЮЩУЮ СКОБКУ */

/* 🔥 QA FIX: Адаптация таблиц (рейтинг и ростер) под мобильные экраны */
    @media (max-width: 768px) {
        .p-roster-table { 
            min-width: 100% !important; 
        }
        .p-roster-table th, 
        .p-roster-table td { 
            padding: 12px 8px !important; /* Уменьшаем конские отступы */
            white-space: normal !important; /* Разрешаем тексту переноситься */
        }
        /* Уменьшаем шрифт значений, чтобы точно всё влезло */
        .p-roster-table td b {
            font-size: 13px !important;
        }
    }
	
/* 🔥 QA FIX: Скрываем стандартный плавающий кружок кабинета Тильды */
#tilda-personal-cabinet-widget,
.tilda-personal-cabinet,
.t-personal-cabinet__icon-wrapper,
.t-personal-cabinet-widget,
.t-login-widget,
.t-member-widget,
[id^="tilda-personal-cabinet-"],
[class^="tilda-personal-cabinet-"],
.tbase-widget-container {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: -99999 !important;
}