* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #ffffff;
    min-height: 100vh;
}

/* HEADER */
.header {
    background: linear-gradient(90deg, #dc143c 0%, #a00000 100%);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(220, 20, 60, 0.3);
}

.logo {
    background: #dc143c;
    color: white;
    padding: 15px 25px;
    font-size: 28px;
    font-weight: bold;
    border-radius: 8px;
    letter-spacing: 2px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.current-datetime {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 14px;
}

.currency-selector {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 15px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.9);
    color: #dc143c;
    padding: 10px 25px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
}

/* LOGIN SCREEN */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

.login-box {
    background: rgba(255, 255, 255, 0.05);
    padding: 50px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(220, 20, 60, 0.4);
    border: 2px solid rgba(220, 20, 60, 0.3);
    width: 400px;
}

.login-logo {
    background: #dc143c;
    color: white;
    padding: 20px 30px;
    font-size: 36px;
    font-weight: bold;
    border-radius: 8px;
    letter-spacing: 3px;
    text-align: center;
    margin-bottom: 30px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #ffffff;
    font-weight: 500;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid rgba(220, 20, 60, 0.5);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #dc143c;
    background: rgba(255, 255, 255, 0.15);
}

.input-group select option {
    background: #2d2d2d;
    color: white;
}

.login-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(90deg, #dc143c 0%, #a00000 100%);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(220, 20, 60, 0.5);
}

.error-message {
    color: #ff6b6b;
    text-align: center;
    margin-top: 15px;
    display: none;
}

.success-message {
    color: #4caf50;
    text-align: center;
    margin-top: 15px;
    display: none;
}

/* CONTAINER */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 30px;
}

/* NAVIGATION */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 10px;
    flex-wrap: wrap;
}

.nav-tab {
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    color: white;
    font-weight: 500;
}

.nav-tab:hover {
    background: rgba(220, 20, 60, 0.2);
    border-color: rgba(220, 20, 60, 0.5);
}

.nav-tab.active {
    background: linear-gradient(90deg, #dc143c 0%, #a00000 100%);
    border-color: #dc143c;
    box-shadow: 0 4px 15px rgba(220, 20, 60, 0.4);
}

/* TABS */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

/* CARDS */
.card {
    background: rgba(255, 255, 255, 0.05);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid rgba(220, 20, 60, 0.2);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.card h2,
.card h3 {
    color: #4caf50;
    margin-bottom: 20px;
    font-size: 24px;
    border-bottom: 2px solid rgba(76, 175, 80, 0.3);
    padding-bottom: 10px;
}

/* DASHBOARD */
.dashboard-header {
    margin-bottom: 30px;
    padding: 0 5px;
}

.dashboard-title {
    font-size: 36px;
    font-weight: 300;
    color: #ffffff;
    margin: 0;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.month-selector {
    font-size: 18px;
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #ffffff;
    cursor: pointer;
    min-width: 180px;
}

.month-selector:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.month-selector option {
    background: #2d2d2d;
    color: #ffffff;
}

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.stat-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label::before {
    content: '';
    width: 4px;
    height: 16px;
    background: currentColor;
    border-radius: 2px;
    opacity: 0.5;
}

.stat-value {
    font-size: 32px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
    letter-spacing: -1px;
    line-height: 1.2;
}

.stat-value.positive {
    color: #4caf50;
}

.stat-value.negative {
    color: #f44336;
}

.stat-change {
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    margin-top: 8px;
}

.stat-change.positive {
    color: #4caf50;
    background: rgba(76, 175, 80, 0.15);
}

.stat-change.positive::before {
    content: '↗';
    font-size: 16px;
}

.stat-change.negative {
    color: #f44336;
    background: rgba(244, 67, 54, 0.15);
}

.stat-change.negative::before {
    content: '↘';
    font-size: 16px;
}

.stat-card.income .stat-label::before {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
}

.stat-card.margin .stat-label::before {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
}

.stat-card.expenses .stat-label::before {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
}

.stat-card.employees .stat-label::before {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
}

.stat-icon {
    font-size: 24px;
    opacity: 0.3;
    margin-left: auto;
}

/* GOALS */
.goals-section {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1) 0%, rgba(76, 175, 80, 0.05) 100%);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(76, 175, 80, 0.2);
    margin-bottom: 30px;
}

.goals-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: #4caf50;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.goal-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid transparent;
}

.goal-item.income {
    border-left-color: #4caf50;
}

.goal-item.margin {
    border-left-color: #2196f3;
}

.goal-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
    background: linear-gradient(90deg, #4caf50 0%, #45a049 100%);
}

/* CEO NOTES */
.ceo-notes {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.1) 0%, rgba(244, 67, 54, 0.05) 100%);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(244, 67, 54, 0.2);
    margin-bottom: 30px;
}

.ceo-notes h3 {
    font-size: 18px;
    font-weight: 600;
    color: #f44336;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ceo-notes-content {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
    font-size: 14px;
}

.ceo-notes-box {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #dc143c;
    margin-top: 15px;
}

.ceo-notes-box strong {
    color: #dc143c;
}

/* FORMS */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid rgba(220, 20, 60, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 16px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #dc143c;
    background: rgba(255, 255, 255, 0.1);
}

.form-group select option {
    background: #2d2d2d;
    color: white;
}

/* BUTTONS */
.btn {
    padding: 12px 30px;
    background: linear-gradient(90deg, #dc143c 0%, #a00000 100%);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(220, 20, 60, 0.5);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-edit {
    background: linear-gradient(90deg, #4caf50 0%, #388e3c 100%);
}

.btn-edit:hover {
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.5);
}

.btn-delete {
    background: linear-gradient(90deg, #f44336 0%, #d32f2f 100%);
}

.btn-delete:hover {
    box-shadow: 0 5px 20px rgba(244, 67, 54, 0.5);
}

/* TABLES */
/* Таблицы */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    table-layout: fixed; /* ДОБАВЛЕНО для фиксированной ширины колонок */
}

table thead {
    background: rgba(255, 255, 255, 0.1);
}

table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #4caf50;
    border-bottom: 2px solid rgba(76, 175, 80, 0.3);
}

table td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    word-wrap: break-word; /* ДОБАВЛЕНО для переноса длинного текста */
}

table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ДОБАВЬТЕ эти стили для контейнера таблицы со скроллом */
.table-container {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 8px;
    margin-top: 20px;
}

.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: rgba(76, 175, 80, 0.5);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(76, 175, 80, 0.7);
}

/* Фиксированная шапка таблицы */
.table-container table {
    margin-top: 0;
}

.table-container thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(45, 45, 45, 0.95);
}

/* Плановые и фактические платежи — 10 колонок, фикс. раскладка их слишком сжимает */
#plannedExpensesTableWrap table {
    table-layout: auto;
    width: auto;
    min-width: 100%;
}

#plannedExpensesTableWrap th,
#plannedExpensesTableWrap td {
    white-space: nowrap;
}

#plannedExpensesTableWrap th:first-child,
#plannedExpensesTableWrap td:first-child {
    white-space: normal;
    min-width: 160px;
}

/* CHARTS */
.chart-container {
    position: relative;
    height: 400px;
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 10px;
}

/* LOADING */
.loading {
    text-align: center;
    padding: 40px;
    color: #dc143c;
    font-size: 18px;
}

.spinner {
    border: 4px solid rgba(220, 20, 60, 0.1);
    border-left-color: #dc143c;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* MODAL */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s;
}

.modal-content {
    background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
    margin: 5% auto;
    padding: 30px;
    border: 2px solid rgba(220, 20, 60, 0.5);
    border-radius: 15px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(220, 20, 60, 0.5);
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #dc143c;
}

/* Стили для таблицы ТОП пользователей */
.utm-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.pagination-numbers {
    display: flex;
    gap: 5px;
}

.pagination-btn {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.pagination-btn.active {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    border-color: #4caf50;
    font-weight: 600;
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Выпадающий фильтр для графиков */
.chart-filter-select {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.chart-filter-select:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.chart-filter-select:focus {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.chart-filter-select option {
    background: #2a2a3e;
    color: white;
    padding: 10px;
}


/* FILTER ROW */
.filter-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* COEFFICIENT INFO */
.coeff-info-box {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1) 0%, rgba(56, 142, 60, 0.1) 100%);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid rgba(76, 175, 80, 0.3);
    margin-bottom: 20px;
}

.coeff-info-box h3 {
    color: #4caf50;
    margin-bottom: 15px;
}

.coeff-detail {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.coeff-detail:last-child {
    border-bottom: none;
}

.motivational-message {
    background: rgba(76, 175, 80, 0.1);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border-left: 4px solid #4caf50;
}

/* PLACEHOLDER */
.placeholder-box {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.1) 0%, rgba(25, 118, 210, 0.1) 100%);
    padding: 30px;
    border-radius: 10px;
    border: 2px solid rgba(33, 150, 243, 0.3);
    text-align: center;
}

.placeholder-box h3 {
    color: #2196f3;
    margin-bottom: 15px;
}

.placeholder-box p {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
    line-height: 1.6;
}

/* MANAGEMENT */
.management-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.management-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid rgba(220, 20, 60, 0.2);
}

.management-card h3 {
    color: #4caf50;
    margin-bottom: 20px;
    font-size: 20px;
}

.item-list {
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 10px;
}

.add-item-form {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.add-item-form input {
    flex: 1;
    padding: 12px;
    border: 2px solid rgba(220, 20, 60, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

/* SERVICE BADGES */
.service-impact {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.service-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.service-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.4);
}

.service-badge.all {
    background: rgba(220, 20, 60, 0.2);
    color: #dc143c;
    border-color: rgba(220, 20, 60, 0.4);
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .dashboard-title {
        font-size: 28px;
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .month-selector {
        width: 100%;
        font-size: 16px;
    }

    .stat-value {
        font-size: 28px;
    }

    .management-section {
        grid-template-columns: 1fr;
    }

    /* Предпросмотр текста с сохранением форматирования */
    .preview-text-simple {
        color: #e9edef;
        line-height: 20px;
        font-size: 15px;
        padding-right: 42px;
        white-space: pre-wrap; /* Сохраняет переносы и пробелы */
        word-wrap: break-word;
        min-height: 20px;
        overflow-wrap: break-word;
    }

    .preview-text-simple b,
    .preview-text-simple strong {
        font-weight: 600;
    }

    .preview-text-simple i,
    .preview-text-simple em {
        font-style: italic;
    }

    .preview-text-simple code {
        background: rgba(255, 255, 255, 0.08);
        padding: 2px 5px;
        border-radius: 3px;
        font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
        font-size: 14px;
        color: #64b5f6;
        white-space: pre-wrap;
    }

    .preview-text-simple a {
        color: #5d9bd5;
        text-decoration: none;
    }

    .preview-text-simple a:hover {
        text-decoration: underline;
    }

    /* Сохранение переносов строк */
    .preview-text-simple br {
        display: block;
        content: "";
        margin: 0;
    }

    /* Панель форматирования текста - УВЕЛИЧЕННЫЕ КНОПКИ */
    .text-editor-toolbar {
        display: flex;
        gap: 8px;
        margin-bottom: 10px;
        padding: 12px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 6px;
    }

    .format-btn,
    .text-editor-toolbar button {
        min-width: 44px;
        min-height: 44px;
        padding: 10px 14px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: white;
        border-radius: 6px;
        cursor: pointer;
        transition: all 0.3s;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
    }

    .format-btn:hover,
    .text-editor-toolbar button:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    .format-btn:active,
    .text-editor-toolbar button:active {
        transform: translateY(0);
    }

    /* Поле URL медиафайла */
    #mediaUrlGroup {
        animation: slideDown 0.3s ease;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            max-height: 0;
            overflow: hidden;
        }
        to {
            opacity: 1;
            max-height: 200px;
        }
    }

    #mailingMediaUrl {
        width: 100%;
        padding: 12px;
        background: rgba(255, 255, 255, 0.05);
        border: 2px solid rgba(93, 155, 215, 0.3);
        border-radius: 6px;
        color: white;
        font-size: 14px;
        transition: all 0.3s;
    }

    #mailingMediaUrl:focus {
        outline: none;
        border-color: #5d9ad8;
        background: rgba(255, 255, 255, 0.08);
    }

    #mailingMediaUrl::placeholder {
        color: rgba(255, 255, 255, 0.4);
    }

    /* Селектор типа медиа */
    #mailingMediaType {
        width: 100%;
        padding: 12px;
        background: rgba(255, 255, 255, 0.05);
        border: 2px solid rgba(220, 20, 60, 0.3);
        border-radius: 6px;
        color: white;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.3s;
    }

    #mailingMediaType:focus {
        outline: none;
        border-color: #dc143c;
        background: rgba(255, 255, 255, 0.08);
    }

    #mailingMediaType option {
        background: #2d2d2d;
        color: white;
        padding: 10px;
    }

    /* Responsive для мобильных */
    @media (max-width: 768px) {
        .format-btn,
        .text-editor-toolbar button {
            min-width: 40px;
            min-height: 40px;
            padding: 8px 12px;
            font-size: 16px;
        }
    }

    /* Предпросмотр в стиле Telegram */
    .telegram-preview-simple {
        background: linear-gradient(to bottom, #0f1419 0%, #17212b 100%);
        padding: 16px;
        border-radius: 12px;
        min-height: 200px;
        max-height: 400px;
        font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }

    /* Контейнер медиафайла */
    .preview-media-container {
        max-width: 300px;
        margin-bottom: 4px;
        border-radius: 12px;
        overflow: hidden;
        background: #1f2d3a;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    }

    .preview-media-img {
        width: 100%;
        height: auto;
        display: block;
        max-height: 280px;  /* Было 400px */
        object-fit: cover;
    }

    .preview-media-video {
        width: 100%;
        height: auto;
        display: block;
        max-height: 280px;
        background: #000;
    }

    .preview-media-audio {
        padding: 20px;
        background: rgba(93, 155, 215, 0.1);
    }

    .audio-icon {
        text-align: center;
        font-size: 48px;
        margin-bottom: 15px;
    }

    .preview-media-error {
        padding: 40px 20px;
        text-align: center;
        background: rgba(33, 150, 243, 0.15);
        color: #ef5350;
        font-size: 14px;
    }

    .preview-media-error small {
        font-size: 12px;
        opacity: 0.7;
    }

    /* Caption под медиа */
    .preview-caption {
        color: #e9edef;
        line-height: 20px;
        font-size: 15px;
        padding: 8px 12px;
        white-space: pre-wrap;
        word-wrap: break-word;
        max-width: 400px;
        position: relative;
    }

    .preview-caption b,
    .preview-caption strong {
        font-weight: 600;
    }

    .preview-caption i,
    .preview-caption em {
        font-style: italic;
    }

    .preview-caption code {
        background: rgba(255, 255, 255, 0.08);
        padding: 2px 5px;
        border-radius: 3px;
        font-family: monospace;
        font-size: 14px;
        color: #64b5f6;
    }

    .preview-caption a {
        color: #5d9bd5;
        text-decoration: none;
    }

    /* Пузырь текстового сообщения (без медиа) */
    .tg-message-bubble {
        background: #1f2d3a;
        border-radius: 12px 12px 12px 4px;
        padding: 6px 9px 17px 9px;
        max-width: 400px;
        position: relative;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
        margin-bottom: 4px;
    }

    .preview-text-simple {
        color: #e9edef;
        line-height: 20px;
        font-size: 15px;
        padding-right: 42px;
        white-space: pre-wrap;
        word-wrap: break-word;
        min-height: 20px;
    }

    .preview-text-simple b,
    .preview-text-simple strong {
        font-weight: 600;
    }

    .preview-text-simple i,
    .preview-text-simple em {
        font-style: italic;
    }

    .preview-text-simple code {
        background: rgba(255, 255, 255, 0.08);
        padding: 2px 5px;
        border-radius: 3px;
        font-family: 'SF Mono', Monaco, monospace;
        font-size: 14px;
        color: #64b5f6;
    }

    .preview-text-simple a {
        color: #5d9bd5;
        text-decoration: none;
    }

    .tg-time {
        position: absolute;
        bottom: 2px;
        right: 7px;
        font-size: 11px;
        color: #6d7885;
        line-height: 1;
        font-weight: 400;
    }

    /* Кнопки */
    .preview-buttons-simple {
        display: flex;
        flex-direction: column;
        gap: 4px;
        max-width: 400px;
    }

    .preview-button {
        background: rgba(93, 155, 215, 0.14);
        border: none;
        color: #5d9ad8;
        padding: 9px 12px;
        border-radius: 8px;
        text-align: center;
        font-size: 14px;
        font-weight: 500;
        cursor: default;
        font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
    }

    .stat-card-warning {
    border-left: 4px solid #ff9800 !important;
    background: rgba(255, 152, 0, 0.05) !important;
    }

    .stat-card-error {
        border-left: 4px solid #f44336 !important;
        background: rgba(244, 67, 54, 0.05) !important;
    }

    .btn-small {
        padding: 6px 12px;
        font-size: 13px;
        background: #4caf50;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .btn-small:hover {
        background: #45a049;
        transform: translateY(-2px);
    }

    .form-input {
        width: 100%;
        padding: 10px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 4px;
        color: white;
        font-size: 14px;
    }

    .form-input:focus {
        outline: none;
        border-color: #4caf50;
        background: rgba(255, 255, 255, 0.08);
    }

    .form-label {
        display: block;
        margin-bottom: 8px;
        color: rgba(255, 255, 255, 0.9);
        font-weight: 500;
        font-size: 14px;
    }
}

/* ══════════════════════════════════════════════════════════════
   СТИЛИ ПАГИНАЦИИ UTM ТАБЛИЦЫ (ДЕСКТОП И МОБИЛЬНЫЕ)
   ══════════════════════════════════════════════════════════════ */

/* Контейнер пагинации */
.utm-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    padding: 20px 0;
}

/* Контейнер для номеров страниц */
.pagination-numbers {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Кнопки пагинации */
.pagination-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 40px;
    text-align: center;
}

/* Hover эффект для кнопок */
.pagination-btn:hover:not(:disabled) {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4caf50;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

/* Клик по кнопке */
.pagination-btn:active:not(:disabled) {
    transform: translateY(0);
}

/* Активная страница */
.pagination-btn.active {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    border-color: #4caf50;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    pointer-events: none;
}

/* Неактивная кнопка (disabled) */
.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    transform: none;
    box-shadow: none;
}

/* Троеточие между страницами */
.pagination-numbers span {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: bold;
    padding: 0 5px;
}

/* Анимация появления таблицы при смене страницы */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#utmStatisticsTable table {
    animation: fadeInUp 0.3s ease;
}

/* Дополнительные эффекты */
.pagination-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

/* Плавная прокрутка для всего контейнера */
#utmStatisticsTable {
    scroll-margin-top: 20px;
}

/* ══════════════════════════════════════════════════════════════
   АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .utm-pagination {
        flex-wrap: wrap;
        gap: 8px;
        padding: 15px 0;
    }

    .pagination-btn {
        padding: 6px 12px;
        font-size: 13px;
        min-width: 36px;
    }

    .pagination-numbers {
        gap: 4px;
    }
}

/* ══════════════════════════════════════════════════════════════
   КОНЕЦ СТИЛЕЙ ПАГИНАЦИИ
   ══════════════════════════════════════════════════════════════ */

.bonus-input {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    text-align: right;
}

.bonus-input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.bonus-input.edited {
    background-color: #fff3cd !important;
    border-color: #ffc107 !important;
    color: #000 !important;
}

/* Стили для прогноза дохода */
.stat-card.forecast {
    background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%);
}

/* Переключатель периодов */
.period-toggle-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.period-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.period-toggle-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Индикаторы роста */
.growth-indicator {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    text-align: center;
}

.growth-indicator.up {
    border-left: 3px solid #4caf50;
}

.growth-indicator.down {
    border-left: 3px solid #f44336;
}

.growth-indicator.neutral {
    border-left: 3px solid #9e9e9e;
}

.growth-indicator .month {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 5px;
}

.growth-indicator .change {
    font-size: 14px;
    font-weight: 600;
}

.growth-indicator.up .change {
    color: #4caf50;
}

.growth-indicator.down .change {
    color: #f44336;
}

.growth-indicator.neutral .change {
    color: #9e9e9e;
}


/* Стили для прогноза дохода */
.stat-card.forecast {
    background: linear-gradient(135deg, #9c27b0 0%, #7b1fa2 100%);
}

/* Переключатель периодов */
.period-toggle-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.period-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.period-toggle-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Индикаторы роста */
.growth-indicator {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    text-align: center;
}

.growth-indicator.up {
    border-left: 3px solid #4caf50;
}

.growth-indicator.down {
    border-left: 3px solid #f44336;
}

.growth-indicator.neutral {
    border-left: 3px solid #9e9e9e;
}

.growth-indicator .month {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 5px;
}

.growth-indicator .change {
    font-size: 14px;
    font-weight: 600;
}

.growth-indicator.up .change {
    color: #4caf50;
}

.growth-indicator.down .change {
    color: #f44336;
}

.growth-indicator.neutral .change {
    color: #9e9e9e;
}

/* Базовые стили для контейнера редактора */
.mailing-editor-container {
    display: flex;
    gap: 0;
    align-items: stretch;
    min-width: 0;
    position: relative;
}

.mailing-editor-panel {
    flex: 0 0 65%;
    width: 65%;
    min-width: 20%;
    max-width: 80%;
    overflow: hidden;
    box-sizing: border-box;
}

.mailing-preview-panel {
    flex: 0 0 calc(35% - 12px);
    width: calc(35% - 12px);
    min-width: 20%;
    max-width: 80%;
    overflow: hidden;
    box-sizing: border-box;
}

#previewMediaImage {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    max-height: 400px;
    object-fit: contain;
}

.preview-media-container {
    max-width: 100% !important;
    overflow: hidden;
}

.mailing-resizer {
    flex: 0 0 12px;
    width: 12px;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background 0.2s;
    z-index: 10;
    user-select: none;
}

.mailing-resizer:hover,
.mailing-resizer.dragging {
    background: rgba(220, 20, 60, 0.15);
}

.mailing-resizer-handle {
    width: 4px;
    height: 60px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    transition: background 0.2s, height 0.2s;
    pointer-events: none;
}

.mailing-resizer:hover .mailing-resizer-handle,
.mailing-resizer.dragging .mailing-resizer-handle {
    background: #dc143c;
    height: 80px;
}

@media (max-width: 768px) {
    .mailing-editor-container {
        flex-direction: column;
    }
    .mailing-resizer {
        display: none;
    }
    .mailing-editor-panel,
    .mailing-preview-panel {
        flex: none !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

/* Кнопки управления */
.mailing-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

/* На мобильных - одна колонка */
@media screen and (max-width: 768px) {
    .mailing-editor-container {
        grid-template-columns: 1fr;
    }

    .mailing-actions {
        flex-direction: column;
    }
}

/* Анимация пульсации для активных рассылок */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Анимация мерцания для прогресс-бара */
@keyframes shimmer {
    0% {
        background-position: -100% 0;
    }
    100% {
        background-position: 100% 0;
    }
}

.date-filter {
    display: flex;
    gap: 5px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 8px;
}

.date-filter-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.date-filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.date-filter-btn.active {
    background: #2196f3;
    color: white;
}

/* ── Адаптация шапки для мобильных ───────────────────────────── */
/* ── Полная ширина и компактная навигация на мобильных ── */
@media (max-width: 768px) {
    /* Контейнер на всю ширину */
    .container {
        padding: 12px;
        max-width: 100%;
    }

    /* Навигация: сетка 2 колонки */
    .nav-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 8px;
        border-radius: 10px;
    }

    .nav-tab {
        padding: 11px 8px;
        font-size: 13px;
        text-align: center;
        border-radius: 8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Первый таб (Дашборд) — на всю ширину */
    .nav-tab:first-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    .header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
    }

    .header h1 {
        font-size: 18px !important;
    }

    .user-info {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        margin-left: auto;
    }

    .user-info #currentDateTime {
        display: none;
    }

    .currency-selector {
        font-size: 13px;
        padding: 4px 6px;
    }

    .logout-btn {
        padding: 6px 12px;
        font-size: 13px;
        white-space: nowrap;
    }
}

/* ═══════════════════════════════════════════════════════════
   TELEGRAM PREVIEW SHELL — точный дизайн Telegram Dark
   ═══════════════════════════════════════════════════════════ */

.tg-preview-shell {
    background: #0e1621;
    border-radius: 10px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Шапка чата */
.tg-ps-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    background: #17212b;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tg-ps-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(140deg, #2196f3 0%, #0d47a1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.tg-ps-name  { color: #e9edef; font-size: 14px; font-weight: 600; line-height: 1.3; }
.tg-ps-sub   { color: #6d7885; font-size: 12px; line-height: 1.3; }

/* Область чата */
.tg-ps-body {
    background: #17212b;
    padding: 12px 10px 14px;
    min-height: 100px;
    max-height: 560px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

/* Обёртка поста */
.tg-msg-block {
    max-width: 320px;
}

/* Пустое состояние */
.tg-empty-hint {
    color: #4a5568;
    font-style: italic;
    font-size: 13px;
    text-align: center;
    padding: 28px 0 10px;
}

/* ── Текстовый пузырь (без медиа) ─────────────────────────── */
.tg-text-bubble {
    background: #1f2d3a;
    border-radius: 12px 12px 12px 3px;
    padding: 7px 10px 22px 10px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.tg-bubble-text {
    color: #e9edef;
    font-size: 15px;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
    padding-right: 46px;
    min-height: 20px;
}

/* ── Caption под медиа ────────────────────────────────────── */
.tg-caption-bubble {
    background: #1f2d3a;
    border-radius: 0 0 12px 12px;
    padding: 7px 10px 22px 10px;
    position: relative;
    box-shadow: 0 2px 3px rgba(0,0,0,0.25);
}
.tg-caption-text {
    color: #e9edef;
    font-size: 15px;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
    padding-right: 46px;
}

/* ── Временна́я метка ──────────────────────────────────────── */
/* В тексте/подписи */
.tg-ts {
    position: absolute;
    bottom: 5px;
    right: 9px;
    font-size: 11px;
    color: #6d7885;
    line-height: 1;
    white-space: nowrap;
}
/* На фото/видео — тёмная пилюля */
.tg-ts-photo {
    position: absolute;
    bottom: 7px;
    right: 8px;
    font-size: 11px;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.45);
    padding: 2px 6px;
    border-radius: 8px;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2;
}

/* ── Альбом ───────────────────────────────────────────────── */
.tg-media-area {
    border-radius: 12px;
    overflow: hidden;
    line-height: 0;
    background: #0a0f15;
}
.tg-media-area.with-caption {
    border-radius: 12px 12px 0 0;
}
.tg-album-row {
    display: flex;
    gap: 2px;
}
.tg-album-row + .tg-album-row {
    margin-top: 2px;
}
.tg-album-cell {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: #1a2535;
}
.tg-album-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Видео ────────────────────────────────────────────────── */
.tg-video-area {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    line-height: 0;
}
.tg-video-area.with-caption { border-radius: 12px 12px 0 0; }
.tg-video-area video {
    width: 100%;
    display: block;
    max-height: 240px;
    object-fit: contain;
}

/* ── Аудио ────────────────────────────────────────────────── */
.tg-audio-block {
    background: #1f2d3a;
    border-radius: 12px;
    padding: 14px 12px 22px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.tg-audio-icon  { font-size: 26px; flex-shrink: 0; }
.tg-audio-player { flex: 1; min-width: 0; }
.tg-audio-player audio { width: 100%; }

/* ── Inline keyboard ──────────────────────────────────────── */
.tg-kbd {
    max-width: 320px;
    margin-top: 3px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.tg-kbd-btn {
    background: rgba(93,155,215,0.14);
    color: #5d9ad8;
    border: none;
    border-radius: 8px;
    padding: 9px 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    cursor: default;
    font-family: inherit;
}
.tg-kbd-btn.callback {
    border: 1px dashed rgba(93,155,215,0.4);
}

/* ── Rich text helpers ────────────────────────────────────── */
.tg-bubble-text b,  .tg-bubble-text strong,
.tg-caption-text b, .tg-caption-text strong { font-weight: 600; }

.tg-bubble-text i,  .tg-bubble-text em,
.tg-caption-text i, .tg-caption-text em     { font-style: italic; }

.tg-bubble-text code, .tg-caption-text code {
    background: rgba(255,255,255,0.08);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    color: #64b5f6;
}

.tg-bubble-text a, .tg-caption-text a {
    color: #5d9bd5;
    text-decoration: none;
}

/* ===== MAILING redesign ===== */
.ml{display:flex;flex-direction:column;gap:16px}
.ml-head{
  display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;
  padding:22px 26px;border-radius:18px;
  background:linear-gradient(135deg,rgba(220,20,60,.1) 0%,rgba(12,12,20,.96) 55%);
  border:1px solid rgba(220,20,60,.18);position:relative;overflow:hidden;
}
.ml-head::before{
  content:"";position:absolute;top:-60px;left:-40px;
  width:220px;height:220px;border-radius:50%;
  background:radial-gradient(circle,rgba(220,20,60,.14),transparent 65%);
  pointer-events:none;
}
.ml-title{font-size:22px;font-weight:700;letter-spacing:-.02em;display:flex;align-items:center;gap:10px;position:relative}
.ml-emoji{font-size:26px;filter:drop-shadow(0 0 10px rgba(220,20,60,.55))}
.ml-sub{font-size:13px;color:rgba(255,255,255,.5);margin-top:5px;line-height:1.45;position:relative}
.ml-sub b{color:#fff;font-weight:600}
.ml-tips-toggle{
  display:inline-flex;align-items:center;gap:8px;
  padding:9px 16px;border-radius:10px;
  background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.12);
  color:rgba(255,255,255,.6);font-size:12.5px;cursor:pointer;
  transition:all .2s;white-space:nowrap;position:relative;font-family:inherit;
}
.ml-tips-toggle:hover{background:rgba(220,20,60,.1);border-color:rgba(220,20,60,.3);color:#fff}
.ml-chev{display:inline-block;transition:transform .25s;color:rgba(255,255,255,.4)}
.ml-chev.open{transform:rotate(90deg)}
.ml-tips{
  padding:14px 16px;border-radius:14px;
  background:rgba(220,20,60,.04);
  border:1px solid rgba(220,20,60,.14);border-left:3px solid #dc143c;
  max-height:260px;overflow-y:auto;
}
.ml-tips-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px 20px;font-size:11.5px;color:rgba(255,255,255,.65);line-height:1.5}
.ml-tips-grid b{color:#fff;font-weight:600;display:block;margin-bottom:2px}
.ml-tips-grid code{background:rgba(255,255,255,.07);padding:1px 6px;border-radius:4px;font-size:11.5px;color:#f43f5e}
.ml-grid{display:grid;grid-template-columns:1fr 360px;gap:16px;align-items:flex-start}
.ml-col{display:flex;flex-direction:column;gap:16px;min-width:0}
.ml-col-preview{position:sticky;top:14px}
.ml-card{
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.09);border-radius:16px;padding:18px 20px;
  transition:border-color .2s;
}
.ml-card:hover{border-color:rgba(255,255,255,.14)}
.ml-card-h{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap}
.ml-card-h .ml-dot{
  width:7px;height:7px;border-radius:50%;flex-shrink:0;
  background:#dc143c;box-shadow:0 0 8px #dc143c,0 0 0 3px rgba(220,20,60,.12);
}
.ml-card-h h4{margin:0;font-size:13.5px;font-weight:600;letter-spacing:-.01em;color:#fff}
.ml-card-h .ml-card-sub{font-size:11.5px;color:rgba(255,255,255,.35);margin-left:auto}
.ml-pill{
  margin-left:auto;font-size:11px;padding:3px 10px;border-radius:999px;
  background:rgba(220,20,60,.12);border:1px solid rgba(220,20,60,.25);
  color:#f43f5e;font-variant-numeric:tabular-nums;font-weight:500;
}
.ml-select{
  width:100%;padding:11px 14px;border-radius:10px;
  background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.1);
  color:#fff;font-family:inherit;font-size:13.5px;cursor:pointer;outline:none;
  transition:border-color .2s,background .2s;
}
.ml-select:focus{border-color:rgba(220,20,60,.5);background:rgba(220,20,60,.04)}
.tg-input-wrap{
  position:relative;
  background:rgba(0,0,0,.2);border:1px solid rgba(255,255,255,.1);border-radius:14px;
  transition:border-color .2s,box-shadow .2s;
}
.tg-input-wrap:focus-within{border-color:rgba(220,20,60,.45);box-shadow:0 0 0 3px rgba(220,20,60,.07)}
.tg-input{
  width:100%;min-height:130px;resize:vertical;
  background:transparent;border:none;outline:none;
  color:#fff;font-family:inherit;font-size:14px;line-height:1.55;
  padding:14px 16px;box-sizing:border-box;
}
.tg-input::placeholder{color:rgba(255,255,255,.3)}
.tg-toolbar{
  display:flex;align-items:center;
  padding:8px 10px;border-top:1px solid rgba(255,255,255,.07);
  border-radius:0 0 14px 14px;background:rgba(255,255,255,.015);
}
.tg-fmt{display:flex;gap:2px}
.tg-fmt button{
  width:34px;height:32px;display:grid;place-items:center;
  background:transparent;border:none;border-radius:8px;
  color:rgba(255,255,255,.4);cursor:pointer;font-family:inherit;font-size:13px;
  transition:background .15s,color .15s;
}
.tg-fmt button:hover{background:rgba(255,255,255,.07);color:#fff}
.tg-fmt-mode{
  display:flex;gap:2px;margin-left:auto;
  background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.08);
  border-radius:8px;padding:2px;
}
.tg-fmt-mode button{
  border:none;background:transparent;border-radius:6px;
  padding:5px 10px;font-family:inherit;font-size:11.5px;font-weight:500;
  color:rgba(255,255,255,.4);cursor:pointer;transition:background .15s,color .15s;
}
.tg-fmt-mode button:hover{color:#fff}
.tg-fmt-mode button.active{background:rgba(220,20,60,.25);color:#fff}
.ml-row{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:14px}
.ml-field label{
  display:block;font-size:10.5px;letter-spacing:.08em;text-transform:uppercase;
  color:rgba(255,255,255,.35);margin-bottom:6px;font-weight:500;
}
.ml-field select,.ml-field input[type="url"]{
  width:100%;padding:10px 12px;border-radius:10px;
  background:rgba(255,255,255,.04);border:1px solid rgba(255,255,255,.1);
  color:#fff;font-family:inherit;font-size:13px;cursor:pointer;outline:none;
  transition:border-color .2s;box-sizing:border-box;
}
.ml-field select:focus,.ml-field input[type="url"]:focus{border-color:rgba(220,20,60,.45)}
.ml-opts{display:flex;flex-direction:column;gap:12px}
.ml-check{
  display:flex;align-items:center;gap:10px;cursor:pointer;
  font-size:13px;color:#fff;user-select:none;
}
.ml-check input[type="checkbox"]{position:absolute;opacity:0;width:0;height:0}
.ml-check .bx{
  width:18px;height:18px;border-radius:5px;border:1.5px solid rgba(255,255,255,.2);
  background:rgba(255,255,255,.04);flex-shrink:0;position:relative;transition:all .15s;
}
.ml-check input[type="checkbox"]:checked + .bx{background:#dc143c;border-color:#dc143c;box-shadow:0 0 8px rgba(220,20,60,.3)}
.ml-check input[type="checkbox"]:checked + .bx::after{
  content:"✓";position:absolute;inset:0;display:grid;place-items:center;
  font-size:12px;color:#fff;font-weight:700;
}
.ml-check .hint{color:rgba(255,255,255,.35);font-size:12px}
.ml-schedule-panel{
  margin-left:28px;padding:12px 16px;border-radius:10px;
  background:rgba(59,130,246,.06);border:1px solid rgba(59,130,246,.2);
  margin-top:8px;
}
.ml-cta{display:flex;gap:10px;justify-content:flex-end;margin-top:16px;padding-top:16px;border-top:1px solid rgba(255,255,255,.07)}
.ml-btn{
  display:inline-flex;align-items:center;gap:8px;
  padding:11px 20px;border-radius:11px;
  font-family:inherit;font-size:13px;font-weight:600;cursor:pointer;
  border:1px solid transparent;transition:all .2s;
}
.ml-btn.ghost{background:transparent;border-color:rgba(255,255,255,.12);color:rgba(255,255,255,.6)}
.ml-btn.ghost:hover{background:rgba(255,255,255,.04);color:#fff}
.ml-btn.primary{
  background:linear-gradient(135deg,#dc143c,#f43f5e);color:#fff;
  box-shadow:0 4px 18px -4px rgba(220,20,60,.55),0 0 0 1px rgba(255,255,255,.07) inset;
}
.ml-btn.primary:hover:not(:disabled){
  transform:translateY(-1px);
  box-shadow:0 8px 26px -6px rgba(220,20,60,.7),0 0 0 1px rgba(255,255,255,.1) inset;
}
.ml-btn.primary:disabled{opacity:.38;cursor:not-allowed;box-shadow:none}

/* Telegram phone preview */
.tg-phone{
  background:#17212b;border-radius:20px;overflow:hidden;
  border:1px solid rgba(255,255,255,.07);
  box-shadow:0 24px 60px -20px rgba(0,0,0,.8),0 0 0 1px rgba(255,255,255,.04) inset;
  display:flex;flex-direction:column;
  max-height:calc(100vh - 60px);
}
.tg-phone-h{
  display:flex;align-items:center;gap:10px;padding:12px 14px;
  background:linear-gradient(135deg,#2b5278,#1e3d5c);color:#fff;
  border-bottom:1px solid rgba(0,0,0,.25);
}
.tg-back{background:transparent;border:none;color:rgba(255,255,255,.8);font-size:20px;cursor:pointer;width:24px;height:24px;padding:0;line-height:1}
.tg-ch-av{
  width:36px;height:36px;border-radius:50%;
  background:linear-gradient(135deg,#4fc3f7,#0288d1);color:#fff;
  display:grid;place-items:center;font-weight:700;font-size:15px;
  flex-shrink:0;box-shadow:0 2px 8px rgba(0,0,0,.3);
}
.tg-ch-info{flex:1;min-width:0}
.tg-ch-name{font-size:14px;font-weight:600;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tg-ch-sub{font-size:11px;opacity:.7;margin-top:2px}
.tg-more{background:transparent;border:none;color:rgba(255,255,255,.8);font-size:18px;cursor:pointer}
.tg-chat-body{
  flex:1;background:#17212b;
  padding:12px 10px 14px;min-height:260px;
  overflow-y:auto;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.1) transparent;
}
.tg-phone-foot{
  display:flex;align-items:center;gap:10px;padding:10px 14px;
  background:#17212b;border-top:1px solid rgba(255,255,255,.05);
  font-size:13px;color:rgba(255,255,255,.35);
}
.ml-history .ml-card-h{margin-bottom:12px}

/* ============ История рассылок — десктоп ============ */
.mailing-history-scroll {
    overflow-x: auto;
    width: 100%;
}
#mailingHistory table {
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 13px;
    width: 1200px;
    min-width: 1200px !important;
}
#mailingHistory th:nth-child(1),  #mailingHistory td:nth-child(1)  { width: 105px; }
#mailingHistory th:nth-child(2),  #mailingHistory td:nth-child(2)  { width: 90px; }
#mailingHistory th:nth-child(3),  #mailingHistory td:nth-child(3)  { width: 100px; }
#mailingHistory th:nth-child(4),  #mailingHistory td:nth-child(4)  { width: 110px; }
#mailingHistory th:nth-child(5),  #mailingHistory td:nth-child(5)  { width: 130px; }
#mailingHistory th:nth-child(6),  #mailingHistory td:nth-child(6)  { width: 220px; }
#mailingHistory th:nth-child(7),  #mailingHistory td:nth-child(7)  { width: 75px; }
#mailingHistory th:nth-child(8),  #mailingHistory td:nth-child(8)  { width: 70px; }
#mailingHistory th:nth-child(9),  #mailingHistory td:nth-child(9)  { width: 75px; }
#mailingHistory th:nth-child(10), #mailingHistory td:nth-child(10) { width: 70px; }
#mailingHistory th:nth-child(11), #mailingHistory td:nth-child(11) { width: 145px; }
#mailingHistory th:nth-child(12), #mailingHistory td:nth-child(12) { width: 100px; }
#mailingHistory th {
    padding: 9px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 2px solid rgba(255,255,255,.1);
    background: rgba(33,150,243,.08);
}
#mailingHistory td {
    padding: 9px 8px;
    border-bottom: 1px solid rgba(255,255,255,.05);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255,255,255,.85);
    vertical-align: middle;
}
#mailingHistory td:nth-child(6) {
    white-space: normal;
    overflow: hidden;
}
#mailingHistory td:nth-child(6) span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#mailingHistory td:nth-child(6) > div {
    overflow: hidden;
}
#mailingHistory td:nth-child(11) {
    white-space: normal;
    word-break: break-word;
    font-size: 11px;
    line-height: 1.4;
}
#mailingHistory tbody tr { transition: background .15s; }
#mailingHistory tbody tr:hover { background: rgba(255,255,255,.02); }
#segmentInfo.stat-card{padding:8px 12px;border-radius:10px;transform:none!important}
#segmentInfo.stat-card::before{display:none}
#segmentInfo .stat-label{font-size:11px;margin-bottom:2px}
#segmentInfo .stat-value{font-size:18px;margin-bottom:0;letter-spacing:-.5px;line-height:1}
@media(max-width:1180px){
  .ml-grid{grid-template-columns:1fr}
  .ml-col-preview{position:static !important;max-width:420px;width:100%;margin:0 auto}
  .tg-phone{max-height:520px}
  .tg-chat-body{overflow-y:auto}
}
@media(max-width:700px){
  .ml-row{grid-template-columns:1fr}
  .ml-cta{flex-direction:column-reverse}
  .ml-cta .ml-btn{width:100%;justify-content:center}
  .ml-head{flex-direction:column;align-items:flex-start}
  .ml-tips-toggle{align-self:stretch;justify-content:center}
  .ml-col-preview{max-width:100%}
  .tg-phone{max-height:400px}
}

.th-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.45);
    font-size: 9px;
    font-weight: 700;
    cursor: help;
    margin-left: 4px;
    vertical-align: middle;
    position: relative;
    font-style: normal;
    transition: background 0.15s, color 0.15s;
}
.th-tip:hover {
    background: rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.9);
}
.th-tip::after {
    content: attr(data-tip);
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e1e2e;
    color: rgba(255,255,255,0.85);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    padding: 8px 11px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    white-space: pre-wrap;
    width: max-content;
    max-width: 240px;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    pointer-events: none;
}
.th-tip:hover::after {
    display: block;
}
