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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f8fafc;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><defs><linearGradient id="grad"><stop offset="0%" stop-color="%23ffffff" stop-opacity="0.1"/><stop offset="100%" stop-color="%23ffffff" stop-opacity="0"/></linearGradient></defs><polygon fill="url(%23grad)" points="0,20 100,0 100,20"/></svg>') repeat-x;
}

.header-nav {
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding: 0.75rem 0;
    position: relative;
    z-index: 2;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav-menu a:hover {
    color: white;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.header-stats {
    display: flex;
    gap: 2rem;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.8);
}

.login-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.login-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.header-content {
    text-align: center;
    padding: 3rem 0;
    position: relative;
    z-index: 2;
}

.header h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    font-weight: 800;
    text-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-subtitle {
    font-size: 1.3rem;
    opacity: 0.95;
    max-width: 900px;
    margin: 0 auto 1.5rem;
    padding: 0 1rem;
    line-height: 1.4;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.description {
    background: white;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.filters {
    background: white;
    padding: 1.2rem;
    margin: 1.5rem 0;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
}

.filter-group {
    margin-bottom: 0.8rem;
}

.filter-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #1f2937;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.filter-buttons {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    margin-top: 1rem;
}

input, select {
    padding: 0.5rem 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    width: 100%;
    background-color: #f9fafb;
}

input:focus, select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
    background-color: white;
}

input:focus, select:focus {
    outline: none;
    border-color: #4f46e5;
}

.range-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.3rem;
    align-items: center;
}

.multi-select {
    position: relative;
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.multi-select-item {
    padding: 0.3rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.75rem;
}

.multi-select-item:hover {
    background: #f3f4f6;
}

.multi-select-item.selected {
    background: #dbeafe;
    color: #1d4ed8;
}

.selected-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.selected-item {
    background: #4f46e5;
    color: white;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.remove-item {
    cursor: pointer;
    font-weight: bold;
}

.btn {
    background: #4f46e5;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-block;
    min-width: 120px;
    text-align: center;
}

.btn:hover {
    background: #4338ca;
}

.btn-secondary {
    background: #10b981;
}

.btn-secondary:hover {
    background: #059669;
}

.additional-filters {
    margin-top: 0.8rem;
    border-top: 1px solid #e5e7eb;
    padding-top: 0.8rem;
    display: none;
}

.toggle-additional {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    margin-bottom: 0.8rem;
}

.toggle-additional:hover {
    background: #e5e7eb;
}

.results-info {
    background: white;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.results-warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.table-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin: 1rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    table-layout: fixed;
}

th, td {
    padding: 0.4rem 0.3rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 50px;
}

/* Optimized column widths for single page display */
th:nth-child(1), td:nth-child(1) { 
    width: 300px; 
    max-width: 300px; 
    overflow: hidden;
    word-break: break-all;
    text-overflow: ellipsis;
} /* Channel name */
th:nth-child(2), td:nth-child(2) { width: 8%; min-width: 70px; }  /* Subscribers */
th:nth-child(3), td:nth-child(3) { width: 8%; min-width: 70px; }  /* Views */
th:nth-child(4), td:nth-child(4) { width: 7%; min-width: 60px; }  /* ERR(24h) */
th:nth-child(5), td:nth-child(5) { width: 7%; min-width: 60px; }  /* ERR(7d) */
th:nth-child(6), td:nth-child(6) { width: 8%; min-width: 70px; }  /* Age */
th:nth-child(7), td:nth-child(7) { width: 7%; min-width: 60px; }  /* Posts */
th:nth-child(8), td:nth-child(8) { width: 17.5%; min-width: 100px; } /* Category */
th:nth-child(9), td:nth-child(9) { width: 17.5%; min-width: 100px; } /* Subject */

th {
    background: #f8fafc;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    font-size: 0.65rem;
    line-height: 1.2;
}

th:hover {
    background: #f1f5f9;
}

.sort-icon {
    position: absolute;
    right: 0.2rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6rem;
}

tr:hover {
    background: #f8fafc;
}

.channel-link {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 600;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 290px;
    width: 100%;
    white-space: nowrap;
    word-break: break-all;
}

.channel-link:hover {
    text-decoration: underline;
}

.language-tag {
    display: inline-block;
    background: #87CEEB;
    color: #1e40af;
    padding: 0.05rem 0.2rem;
    border-radius: 2px;
    font-size: 0.55rem;
    font-weight: 600;
    border: 1px solid #60a5fa;
    margin-right: 0.2rem;
    vertical-align: top;
}

.channel-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    max-width: 220px;
    min-width: 0;
    word-break: break-all;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.pagination a, .pagination span {
    padding: 0.4rem 0.8rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    text-decoration: none;
    color: #374151;
    font-size: 0.85rem;
}

.pagination .current {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

.pagination a:hover {
    background: #f3f4f6;
}

.footer {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    color: #e5e7eb;
    padding: 3rem 0 2rem;
    margin-top: 4rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    color: #f9fafb;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.footer-section p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
    color: #d1d5db;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.5rem;
    padding-left: 1rem;
    position: relative;
    color: #d1d5db;
}

.footer-section li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: #6366f1;
}

.footer-bottom {
    border-top: 1px solid #374151;
    padding-top: 1rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.9rem;
}

@media (max-width: 1200px) {
    /* For screens up to 1200px */
    table {
        font-size: 0.7rem;
    }
    
    th, td {
        padding: 0.35rem 0.25rem;
    }
    
    th {
        font-size: 0.6rem;
    }
    
    .language-tag {
        font-size: 0.5rem;
        padding: 0.03rem 0.15rem;
    }
}

@media (max-width: 1024px) {
    .container {
        padding: 0 0.8rem;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }

    .nav-menu {
        display: none;
    }

    .header-right {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-end;
    }
    
    .header-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-top: 0;
    }
    
    .login-btn {
        font-size: 0.8rem;
        padding: 0.4rem 1rem;
        order: -1;
    }
    
    .filter-row {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
    
    .filter-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .filter-buttons .btn {
        flex: 1;
        min-width: 120px;
    }
    
    .results-info {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
        padding: 0.8rem;
        font-size: 0.85rem;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 1rem -0.8rem;
        width: calc(100% + 1.6rem);
    }
    
    table {
        min-width: 900px;
        font-size: 0.65rem;
    }
    
    th, td {
        padding: 0.3rem 0.2rem;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 0.3rem;
        padding: 0 0.8rem;
    }
    
    .pagination a, .pagination span {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .header-right {
        gap: 0.8rem;
    }
    
    .header-stats {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
    
    .login-btn {
        font-size: 0.75rem;
        padding: 0.35rem 0.8rem;
        width: 100%;
        text-align: center;
    }
    
    .filter-buttons {
        flex-direction: column;
    }
    
    .filter-buttons .btn {
        width: 100%;
    }
    
    .results-info {
        font-size: 0.8rem;
    }
    
    .popup-header h3 {
        font-size: 1.1rem;
    }
    
    .telegram-btn {
        font-size: 0.9rem;
        padding: 0.9rem 1.3rem;
    }
}

/* Стили для попапа входа */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.popup-overlay.active {
    display: flex;
}

.popup-content {
    background: white;
    border-radius: 12px;
    max-width: 450px;
    width: 90%;
    max-height: 90%;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: popupSlide 0.3s ease-out;
}

@keyframes popupSlide {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.popup-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
}

.popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.popup-body {
    padding: 2rem;
}

.telegram-info {
    margin-bottom: 2rem;
    text-align: center;
}

.telegram-info p {
    color: #6b7280;
    line-height: 1.6;
    margin: 0 0 1rem 0;
}

.telegram-info p:last-child {
    margin-bottom: 0;
}

.telegram-btn {
    width: 100%;
    background: linear-gradient(135deg, #0088cc 0%, #0066aa 100%);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 136, 204, 0.3);
}

.telegram-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 136, 204, 0.4);
}

.telegram-btn:active {
    transform: translateY(0);
}

/* Адаптивные стили для попапа и кнопки входа */
@media (max-width: 1024px) {
    .header-right {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-end;
    }
    
    .login-btn {
        font-size: 0.8rem;
        padding: 0.4rem 1rem;
    }
}

@media (max-width: 768px) {
    .popup-content {
        margin: 1rem;
        width: calc(100% - 2rem);
    }
    
    .popup-header {
        padding: 1rem 1.5rem;
    }
    
    .popup-body {
        padding: 1.5rem;
    }
}

