/* Global Styles & Variables */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root {
    /* Обновленная палитра: более светлый и современный Dark Mode */
    --bg-dark: #1e1f2e;       /* Был #0d0e15 - стал мягче */
    --bg-card: #27293d;       /* Было #161522 - теперь карточки выделяются */
    --bg-card-hover: #2f3249;
    
    --text-main: #ffffff;
    --text-muted: #9ea0b5;    /* Более читаемый серый */
    
    --border-color: rgba(255, 255, 255, 0.08); /* Чуть заметнее */
    
    /* Неоновые акценты */
    --accent-primary: #00F0FF; 
    --accent-secondary: #FF007F; 
    --accent-success: #39FF14; 
    --accent-warning: #FFCC00;
    --accent-danger: #ff4444;
    
    /* Цвета площадок */
    --vk-color: #0077FF;
    --youtube-color: #FF0000;
    --site-color: #FFA500;
}

body {
    /* Радиальный градиент: от пыльно-сливового к мягкому темно-синему */
    background: radial-gradient(circle at top right, #2a2538, var(--bg-dark));
    background-attachment: fixed;
    color: var(--text-main);
    font-family: 'Roboto', sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

#canvas-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.8; /* Чуть приглушил паутину под новый фон */
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

/* ================= HEADER ================= */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 40px;
}

.logo {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.logo span {
    color: var(--accent-primary);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 500;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color); /* Заменил розовый на нейтральный */
    object-fit: cover;
}

.btn-logout {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-logout:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* ================= HERO & KPI ================= */
.hero-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 60px;
    text-align: center;
    position: relative;
    z-index: 10; /* Поверх анимации фона */
}

.gauge-container {
    position: relative;
    width: 300px;
    height: 160px; 
    margin-bottom: 20px;
    z-index: 10; /* Поверх анимации фона */
}

.gauge-value-display {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 10; /* Поверх анимации фона */
}

.main-kpi {
    font-size: 72px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
}

.kpi-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 10px;
    z-index: 10;
}

.trend-badge {
    margin-top: 10px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    position: relative;
    z-index: 10; /* Поверх анимации фона */
}

.trend-badge.positive {
    background: rgba(57, 255, 20, 0.1);
    color: var(--accent-success);
    border: 1px solid rgba(57, 255, 20, 0.2);
}

.trend-badge.negative {
    background: rgba(255, 0, 127, 0.1);
    color: var(--accent-secondary);
    border: 1px solid rgba(255, 0, 127, 0.2);
}

/* ================= CARDS ================= */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.card {
    background: rgba(39, 41, 61, 0.7); /* Легкий glassmorphism */
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2); 
}

.card:hover {
    transform: translateY(-5px);
    background: var(--bg-card-hover);
    border-color: rgba(0, 240, 255, 0.3);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 240, 255, 0.05);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

.source-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 12px;
    font-weight: bold;
    background: rgba(255,255,255,0.05);
}

.source-icon.vk { color: var(--vk-color); border-bottom: 2px solid var(--vk-color); }
.source-icon.youtube { color: var(--youtube-color); border-bottom: 2px solid var(--youtube-color); }
.source-icon.site { color: var(--site-color); border-bottom: 2px solid var(--site-color); }

.card-metric-value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--text-main);
}

.card-metric-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sparkline-container {
    height: 60px;
    margin-top: 20px;
    position: relative;
}


/* History Icon */
.history-icon {
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
}
.history-icon:hover {
    color: var(--accent-primary);
    opacity: 1;
}

/* ================= MODAL ================= */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal-overlay.active {
    display: flex;
    opacity: 1;
}

/* Modal Content (White Theme) */
.modal-content.white-theme {
    /* White variation of the project theme */
    background: radial-gradient(circle at top right, #e2e8f0, #f1f3f9);
    color: #333;
    width: 95%;
    max-width: 1200px; /* Шире для горизонтальной таблицы */
    max-height: 85vh;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 0;
    overflow-y: auto;
    background: #ffffff;
}

/* History Table */
.table-container {
    width: 100%;
    overflow-x: auto; /* Горизонтальный скролл */
    background: rgba(255, 255, 255, 0.5);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap; /* Чтобы даты не переносились */
}

.history-table th {
    text-align: center;
    padding: 12px 15px;
    backdrop-filter: blur(5px);
    color: #555;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e0e0e0;
}

/* Первый столбец (названия метрик) фиксируем */
.history-table th:first-child,
.history-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    border-right: 1px solid #e0e0e0;
    text-align: left;
    font-weight: 600;
    color: #333;
    background: #fff;
}
.history-table th:first-child {
    background: #f1f3f5;
    z-index: 3;
}

.history-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
    vertical-align: middle;
    text-align: center;
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-table tr:hover {
    background: #f8f9fa;
}

/* Dynamics Indicators (Compact) */
.cell-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.cell-value {
    font-size: 14px;
    font-weight: 500;
}
.cell-diff {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
}
.diff-up { 
    color: #28a745; 
    background: rgba(40, 167, 69, 0.1); 
}
.diff-down { 
    color: #dc3545; 
    background: rgba(220, 53, 69, 0.1); 
}
.diff-neutral { 
    color: #999; 
    background: rgba(173, 181, 189, 0.15); 
    border: 1px solid rgba(173, 181, 189, 0.2);
    opacity: 0.8;
}


/* ================= ADMIN PANELS ================= */
.admin-panel {
    background: rgba(39, 41, 61, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2); 
}

.panel-title {
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 20px;
    font-weight: 500;
    color: var(--text-main);
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

/* ================= SLIDER ================= */
.slider-container {
    padding: 10px 0;
}

.weights-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    margin: 20px 0;
}

input[type=range]::-webkit-slider-thumb, input[type=range]::-moz-range-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    margin-top: -8px;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
}

input[type=range]::-webkit-slider-runnable-track, input[type=range]::-moz-range-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* ================= TABLES ================= */
.table-responsive {
    overflow: visible !important;
}

#users-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

#users-table th {
    padding: 15px 12px;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-color);
}

#users-table td {
    padding: 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
    color: var(--text-main);
}

#users-table tbody tr {
    transition: background 0.2s;
}

#users-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ================= COEFFICIENTS TABLE ================= */
.coefficients-table {
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0 4px;
    margin-top: 10px;
    font-size: 13px;
}

.coefficients-table thead th {
    text-align: left;
    padding: 15px 20px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1.5px;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
}

/* Выравнивание заголовков */
.coefficients-table thead th:nth-child(1),
.coefficients-table thead th:nth-child(2) {
    text-align: center;
}
.coefficients-table thead th:last-child {
    text-align: right;
}

.coefficients-table tbody tr {
    background: rgba(30, 31, 46, 0.4);
    transition: background 0.2s ease;
}

.coefficients-table tbody tr:hover {
    background: rgba(0, 240, 255, 0.03);
}

.coefficients-table td {
    padding: 14px 20px;
    vertical-align: middle;
    border: none;
    color: var(--text-main);
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.coefficients-table td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    width: 60px;
    text-align: center;
    padding: 10px;
    background: transparent; 
}

/* Центрируем категорию */
.coefficients-table td:nth-child(2) {
    text-align: center;
    font-weight: 500;
}

.coefficients-table .source-icon {
    width: 36px;
    height: 36px;
    font-size: 10px;
    border-radius: 8px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.coefficients-table td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    text-align: right;
    font-family: 'Roboto Mono', monospace;
    font-size: 15px;
    font-weight: 700;
}

/* ================= BADGES ================= */
.role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    background: rgba(255,255,255,0.05);
}

.role-admin { color: var(--accent-primary); border: 1px solid rgba(0, 240, 255, 0.3); }
.role-smm { color: var(--accent-success); border: 1px solid rgba(57, 255, 20, 0.3); }

.status-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.status-active { background: rgba(57, 255, 20, 0.1); color: var(--accent-success); border: 1px solid rgba(57, 255, 20, 0.3); }
.status-pending { background: rgba(255, 204, 0, 0.1); color: var(--accent-warning); border: 1px solid rgba(255, 204, 0, 0.3); }
.status-blocked { background: rgba(255, 68, 68, 0.1); color: var(--accent-danger); border: 1px solid rgba(255, 68, 68, 0.3); }

/* ================= ADMIN BUTTONS ================= */
.action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    margin-right: 5px;
    margin-bottom: 5px;
    transition: all 0.2s;
    font-weight: 500;
}

.action-btn:hover { background: rgba(255,255,255,0.1); }
.btn-approve-smm { border-color: var(--accent-success); color: var(--accent-success); }
.btn-approve-smm:hover { background: rgba(57, 255, 20, 0.1); }
.btn-approve-admin { border-color: var(--accent-primary); color: var(--accent-primary); }
.btn-approve-admin:hover { background: rgba(0, 240, 255, 0.1); }
.btn-block { border-color: var(--accent-secondary); color: var(--accent-secondary); }
.btn-block:hover { background: rgba(255, 0, 127, 0.1); }
.btn-delete { border-color: var(--accent-danger); color: var(--accent-danger); }
.btn-delete:hover { background: rgba(255, 68, 68, 0.1); }

/* ================= AUTH PAGE ================= */
.auth-page {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 20px;
}

.btn-yandex {
    display: inline-block;
    background: #FFCC00;
    color: #000;
    padding: 16px 36px;
    border-radius: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-decoration: none;
    margin-top: 20px;
    transition: all 0.2s;
    box-shadow: 0 10px 20px rgba(255, 204, 0, 0.2);
}

.btn-yandex:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px rgba(255, 204, 0, 0.4);
}

/* ================= DROPDOWN ACTIONS MENU ================= */
.actions-wrapper {
    position: relative;
    display: inline-block;
}

.btn-action-menu {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px; /* Расстояние между текстом и стрелочкой */
}

.btn-action-menu:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.3); /* Легкое неоновое свечение рамки */
}

.btn-action-menu svg {
    transition: transform 0.2s;
}

/* Если меню открыто - стрелочка переворачивается (по желанию, можно добавить класс через JS) */
.btn-action-menu.active svg {
    transform: rotate(180deg);
}

.btn-kebab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    padding: 2px 12px;
    border-radius: 6px;
    transition: all 0.2s;
    line-height: 1;
}

.btn-kebab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    min-width: 180px;
    z-index: 9999; /* ИСПРАВЛЕНИЕ: Меню всегда поверх всего */
    overflow: hidden;
    padding: 6px 0;
    margin-top: 5px;
}

.dropdown-menu.show {
    display: block;
    animation: fadeInMenu 0.2s ease-out forwards;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 10px 16px;
    color: var(--text-main);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.dropdown-item.danger {
    color: var(--accent-danger);
}

.dropdown-item.danger:hover {
    background: rgba(255, 68, 68, 0.1);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

@keyframes fadeInMenu {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================= CARD DETAILS (Сырые данные) ================= */
.card-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Строго 2 колонки */
    gap: 16px 12px; /* Увеличенный вертикальный отступ */
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    align-items: start;
}

/* VK card - 2 columns layout to ensure text fits */
#details-vk {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 12px;
}

/* On smaller screens */
@media (max-width: 768px) {
    .card-details, #details-vk {
        grid-template-columns: repeat(2, 1fr);
    }
}

.detail-item {
    display: flex;
    flex-direction: column;
    min-height: 42px; /* Фиксированная минимальная высота для выравнивания */
    justify-content: center;
    position: relative; /* Для позиционирования тултипа */
}

.detail-label {
    font-size: 10px; /* Чуть меньше */
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
    /* Разрешаем перенос строк, чтобы длинные названия влезали */
    white-space: normal; 
}

.detail-val {
    font-size: 18px; /* Крупнее цифры */
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
    letter-spacing: -0.5px; /* Чуть плотнее */
}

/* Иконка вопроса */
.info-icon {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.3); /* Более прозрачная */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 12px;
    height: 12px;
    min-width: 12px; /* Чтобы не сжималась */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    transition: all 0.2s;
}

.detail-item:hover .info-icon {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    opacity: 1;
}

/* Тултип (подсказка) при наведении на весь блок */
.tooltip-wrap {
    /* position: relative;  - Убрали relative отсюда, перенесли в .detail-item */
    cursor: help;
}

/* Группа бейджей под главным KPI */
.trend-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    position: relative;
    z-index: 10; /* Поверх анимации фона */
}

.trend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 15px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    z-index: 10;
}

.trend-item .trend-val {
    font-weight: 700;
    font-size: 14px;
}

.trend-item .trend-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 2px;
}

/* Кастомный тултип для Chart.js */
#chartjs-tooltip {
    background: rgba(20, 21, 33, 0.95) !important;
    border: 1px solid var(--accent-primary) !important;
    border-radius: 8px !important;
    padding: 8px !important;
    backdrop-filter: blur(5px);
}

.manual-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    box-sizing: border-box;
}

.manual-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(0, 240, 255, 0.05);
}

/* Убираем стандартные стрелочки у input type="number" для красоты */
.manual-input::-webkit-outer-spin-button,
.manual-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.manual-input[type=number] {
    appearance: textfield;
}

/* ================= TOOLTIPS ================= */
/* 
   Тултипы теперь всплывают относительно .detail-item (родитель),
   чтобы они не обрезались внутри узкого контента и всегда были поверх.
*/
.tooltip-wrap::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%; /* Над элементом */
    left: 50%; /* По центру */
    transform: translateX(-50%) translateY(10px); /* Центрирование + смещение для анимации */
    
    background: rgba(20, 21, 33, 0.98);
    border: 1px solid var(--accent-primary);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 400;
    white-space: normal;
    width: max-content;
    max-width: 200px; /* Ограничиваем ширину */
    
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 9999; /* Максимальный Z-Index */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    line-height: 1.4;
    letter-spacing: normal;
    text-transform: none;
    text-align: center;
}

/* Стрелочка вниз у тултипа */
.tooltip-wrap::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    border: 6px solid transparent;
    border-top-color: var(--accent-primary);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    z-index: 9999;
    pointer-events: none;
    margin-bottom: -12px; /* Подгонка */
}

.tooltip-wrap:hover::after,
.tooltip-wrap:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-8px); /* Всплытие вверх */
}

.detail-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.info-icon {
    font-size: 10px;
    color: var(--text-muted);
    border: 1px solid rgba(158, 160, 181, 0.5);
    border-radius: 50%;
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-style: normal;
    font-family: monospace;
    opacity: 0.8;
}

.tooltip-wrap:hover .info-icon {
    color: var(--text-main);
    border-color: var(--text-main);
    opacity: 1;
}
/* ================= INFO / FAQ PANEL ================= */
.info-panel {
    transition: all 0.3s ease;
}

.panel-header-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding-bottom: 0;
}

.panel-header-toggle .panel-title {
    margin: 0;
    border: none;
    padding: 0;
    transition: color 0.2s;
}

.panel-header-toggle:hover .panel-title {
    color: var(--accent-primary);
}

.toggle-icon {
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.info-panel.open .toggle-icon {
    transform: rotate(180deg);
}

.info-content {
    display: none;
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    animation: fadeInMenu 0.3s ease-out forwards;
}

.info-panel.open .info-content,
.info-content.open {
    display: block;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.info-box {
    background: rgba(0, 0, 0, 0.15);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.info-box h3 {
    color: #fff;
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-box ul {
    padding-left: 0;
    margin: 0;
    list-style-type: none;
}

.info-box li {
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.info-box li:last-child {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .info-grid { grid-template-columns: 1fr; }
}

/* ================= DETAILED DOCS ================= */
.doc-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.doc-section h3 {
    color: #fff;
    font-size: 18px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.formula-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px dashed rgba(0, 240, 255, 0.3);
    padding: 15px;
    border-radius: 8px;
    font-family: monospace;
    color: var(--accent-primary);
    font-size: 14px;
    margin-bottom: 20px;
    text-align: center;
    letter-spacing: 0.5px;
    overflow-x: auto;
}

.metrics-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 13px;
}

.metrics-table th {
    text-align: left;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.metrics-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    color: #ddd;
}

.metrics-table tr:last-child td {
    border-bottom: none;
}

.multiplier {
    display: inline-block;
    background: rgba(57, 255, 20, 0.15);
    color: var(--accent-success);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 11px;
    margin-left: 5px;
}

.penalty {
    background: rgba(255, 68, 68, 0.15);
    color: var(--accent-danger);
}
