:root {
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --accent-color: #e62117; /* YouTube red */
    --border-color: #e1e4e8;
    --hover-color: #f8f9fa;
    --success-color: #28a745;
    --danger-color: #dc3545;
}

* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-menu {
    flex-shrink: 0;
}

body > .container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

.top-menu {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.menu-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.top-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

.top-menu li {
    margin-right: 20px;
}

.top-menu a {
    display: block;
    padding: 15px 0;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: color 0.2s;
    border-bottom: 2px solid transparent;
}

.top-menu a:hover {
    color: var(--accent-color);
}

.top-menu a.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

header {
    text-align: center;
    margin-bottom: 10px;
    position: relative;
}

header h1 {
    color: var(--text-primary);
    font-weight: 700;
    margin: 0 0 10px 0;
    font-size: 2rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
    margin: 0 0 24px 0;
    text-align: center;
    line-height: 1.5;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.admin-link, .back-link {
    display: inline-block;
    margin-top: 10px;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.admin-link:hover, .back-link:hover {
    opacity: 0.8;
}

.controls {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1 1 350px;
    min-width: 350px;
    padding: 12px 16px;
    font-size: 1rem;
    font-family: 'Roboto', sans-serif;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(230, 33, 23, 0.1);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.sort-controls-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-select {
    padding: 12px 16px;
    font-size: 1rem;
    font-family: 'Roboto', sans-serif;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 220px;
}

.sort-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(230, 33, 23, 0.1);
}

.sort-direction {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.formula-control {
    margin-bottom: 24px;
    padding: 16px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.formula-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.formula-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.formula-legend-item {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.formula-legend-item strong {
    color: var(--accent-color);
    font-weight: 600;
}

.formula-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.formula-sort-direction {
    flex-shrink: 0;
}

.formula-direction-options {
    display: flex;
    gap: 8px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px;
    height: 48px;
    align-items: center;
    box-sizing: border-box;
}

.formula-direction-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.formula-direction-option:hover {
    background-color: var(--card-bg);
}

.formula-direction-option input[type="radio"] {
    display: none;
}

.formula-direction-option span {
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-secondary);
    transition: color 0.2s;
    line-height: 1;
    padding: 2px 4px;
}

.formula-direction-option input[type="radio"]:checked + span {
    color: var(--accent-color);
    font-weight: 600;
}

.formula-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    font-family: 'Roboto', sans-serif;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.formula-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(230, 33, 23, 0.1);
}

.formula-input::placeholder {
    color: var(--text-secondary);
}

.formula-error {
    display: none;
    margin-top: 8px;
    padding: 10px 12px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.formula-hint {
    display: block;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .container {
        padding: 12px;
    }
    
    .menu-container {
        padding: 0 12px;
    }
    
    .controls {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .search-input {
        width: 100%;
        min-width: unset;
        flex: none;
    }
    
    .sort-controls-group {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    
    .sort-select {
        width: 100%;
        min-width: unset;
    }
    
    .formula-control {
        padding: 12px;
        margin-bottom: 20px;
    }
    
    .formula-input-row {
        gap: 8px;
    }
    
    .formula-direction-options {
        gap: 4px;
        padding: 3px;
    }
    
    .formula-direction-option {
        padding: 3px 6px;
    }
    
    .formula-direction-option span {
        font-size: 1rem;
    }
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
}

.channel-card {
    display: grid;
    grid-template-columns: 80px 1fr 150px;
    gap: 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 20px 20px 20px;
    margin-bottom: 16px;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

@media (max-width: 768px) {
    header {
        margin-bottom: 24px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 1rem;
        margin-bottom: 10px;
    }

    .channel-card {
        grid-template-columns: 70px 1fr 120px;
        gap: 15px;
        padding: 12px 16px 16px 16px;
        margin-bottom: 12px;
    }

    .channel-logo img {
        width: 70px;
        height: 70px;
    }

    .logo-fallback {
        width: 70px;
        height: 70px;
        font-size: 1.5rem;
    }

    .channel-name {
        font-size: 1.1rem;
    }

    .channel-description {
        font-size: 0.85rem;
    }

    .subs-count {
        font-size: 1.3rem;
    }

    .channel-subscribers {
        padding-left: 15px;
    }
}

.channel-card:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    background-color: var(--hover-color);
}

.channel-logo {
    position: relative;
}

.rank-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 2;
    min-width: 28px;
    text-align: center;
}

.channel-logo img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.logo-fallback {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background-color: var(--accent-color);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-logo-fallback {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background-color: var(--accent-color);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.channel-info {
    display: flex;
    flex-direction: column;
}

.channel-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.channel-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--text-primary);
    line-height: 1.3;
}

.youtube-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color);
    opacity: 0.8;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 8px;
    border-radius: 50%;
    margin-left: 4px;
}

.youtube-link:hover {
    opacity: 1;
    background-color: rgba(230, 33, 23, 0.1);
    transform: scale(1.05);
}

.youtube-link svg {
    width: 28px;
    height: 28px;
}

.channel-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.channel-stats-secondary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.video-icon {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.channel-subscribers {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    text-align: right;
    border-left: 1px solid var(--border-color);
    padding-left: 20px;
    height: 100%;
}

.subs-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.subs-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.subs-change {
    display: inline-flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 4px;
}

.change-up {
    color: var(--success-color);
}

.change-down {
    color: var(--danger-color);
}

.arrow {
    margin-right: 4px;
    font-size: 1em;
    line-height: 1;
    display: flex;
    align-items: center;
    height: 1em;
}

.formula-result {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    text-align: right;
}

.formula-result-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.formula-result-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-color);
}

@media (max-width: 650px) {
    .container {
        padding: 10px;
    }

    header {
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 1.3rem;
        line-height: 1.3;
    }

    .subtitle {
        font-size: 0.95rem;
        margin-bottom: 10px;
    }

    .loading {
        padding: 30px 20px;
        font-size: 1rem;
    }

    .error {
        padding: 12px;
        font-size: 0.9rem;
    }

    .channel-card {
        grid-template-columns: 60px 1fr;
        grid-template-areas: 
            "logo info"
            "subs subs";
        gap: 12px;
        padding: 6px 14px 14px 14px;
        margin-bottom: 12px;
        border-radius: 10px;
    }

    .channel-logo {
        grid-area: logo;
    }
    
    .channel-logo img {
        width: 60px;
        height: 60px;
    }

    .logo-fallback {
        width: 60px;
        height: 60px;
        font-size: 1.3rem;
    }

    .rank-badge {
        font-size: 0.75rem;
        padding: 1px 5px;
        top: -4px;
        left: -4px;
        min-width: 22px;
    }

    .channel-info {
        grid-area: info;
        min-width: 0;
    }

    .channel-name {
        font-size: 1rem;
        margin-bottom: 0;
        word-wrap: break-word;
    }

    .channel-description {
        font-size: 0.8rem;
        margin-bottom: 6px;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }

    .channel-stats-secondary {
        font-size: 0.75rem;
        gap: 4px;
    }

    .channel-subscribers {
        grid-area: subs;
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding-left: 0;
        padding-top: 12px;
        padding-right: 0;
        flex-direction: row;
        justify-content: flex-end;
        align-items: center;
        height: auto;
        gap: 8px;
    }
    
    .subs-label {
        margin-bottom: 0;
        font-size: 0.75rem;
    }

    .subs-count {
        font-size: 1.2rem;
    }

    .subs-change {
        font-size: 0.85rem;
        margin-top: 0;
    }
}

@media (max-width: 400px) {
    .container {
        padding: 8px;
    }

    header h1 {
        font-size: 1.15rem;
    }

    .subtitle {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .channel-card {
        padding: 12px;
        gap: 10px;
    }

    .channel-logo img {
        width: 50px;
        height: 50px;
    }

    .channel-name {
        font-size: 0.95rem;
    }

    .channel-description {
        font-size: 0.75rem;
    }

    .subs-count {
        font-size: 1.1rem;
    }
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-form {
    padding: 30px;
}

.modal-form .form-group {
    margin-bottom: 20px;
}

.modal-form .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.modal-form .form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Roboto', sans-serif;
    transition: border-color 0.2s;
    background-color: var(--card-bg);
    color: var(--text-primary);
}

.modal-form .form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(230, 33, 23, 0.1);
}

.modal-form .form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.modal-form .captcha-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.modal-form .captcha-image {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    background-color: #f8f9fa;
    cursor: pointer;
    transition: border-color 0.2s;
}

.modal-form .captcha-image:hover {
    border-color: var(--accent-color);
}

.modal-form .captcha-image img {
    display: block;
    height: 40px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.result-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    display: none;
}

.result-message.success {
    display: block;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.result-message.error {
    display: block;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    font-family: 'Roboto', sans-serif;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    opacity: 0.9;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-secondary {
    background-color: var(--text-secondary);
    color: white;
}

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

@media (max-width: 600px) {
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-form {
        padding: 20px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions .btn {
        width: 100%;
    }
}

/* Footer styles */
footer {
    background-color: #e9ecef;
    border-top: 1px solid #dee2e6;
    margin-top: 60px;
    padding: 20px 20px 30px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-container {
    max-width: 1000px;
    margin: 0 auto;
}

.footer-section {
    display: flex;
    flex-direction: column;
}

.footer-section h3 {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
}

.footer-section p {
    margin: 8px 0;
    line-height: 1.6;
}

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

.footer-section ul li {
    margin-bottom: 10px;
}

.footer-section a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.footer-section a:hover {
    color: var(--accent-color);
    transform: translateX(3px);
}

.footer-section a::before {
    content: '→';
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--accent-color);
}

.footer-section a:hover::before {
    opacity: 1;
}

.footer-bottom {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.footer-bottom p {
    margin: 5px 0;
}

.footer-bottom .footer-brand {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    position: relative;
    padding: 0 5px;
}

.footer-links a:hover {
    color: var(--accent-color);
}

.footer-links a:not(:last-child)::after {
    content: '|';
    position: absolute;
    right: -12px;
    color: #adb5bd;
}

@media (max-width: 768px) {
    .footer-container {
        grid-template-columns: 1fr;
        gap: 25px;
        text-align: center;
    }
    
    .footer-section h3 {
        text-align: center;
    }
    
    footer {
        padding: 30px 15px 20px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 10px;
    }
    
    .footer-links a:not(:last-child)::after {
        display: none;
    }
}

/* Statistics Styles */
.charts-section {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.stats-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: #f8f9fa;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.02);
}

.tab-btn.active {
    color: var(--accent-color);
    font-weight: 600;
    background: var(--card-bg);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-color);
}

.chart-container {
    padding: 20px;
    height: 400px;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.chart-container canvas {
    width: 100% !important;
    max-width: 100%;
}

.daily-stats-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
    overflow: hidden;
}

.daily-stats-section h3 {
    margin: 0 0 20px 0;
    font-size: 1.3rem;
    color: var(--text-primary);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.table-responsive::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.stats-table th {
    text-align: left;
    padding: 12px 15px;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.stats-table th:hover {
    background: #f8f9fa;
}

.stats-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

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

.stat-diff {
    font-size: 0.85rem;
    margin-left: 5px;
    font-weight: 500;
}

.stat-diff.positive, .positive {
    color: var(--success-color);
}

.stat-diff.negative, .negative {
    color: var(--danger-color);
}

.sort-icon {
    margin-left: 5px;
    font-size: 0.8em;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .chart-container {
        height: 300px;
        padding: 10px;
    }
    
    .tab-btn {
        font-size: 0.9rem;
        padding: 12px;
    }
    
    .stats-table th, .stats-table td {
        padding: 10px;
        font-size: 0.9rem;
    }
}

/* Channel page specific styles */
.channel-header {
    margin-bottom: 30px;
}

.channel-header-top {
    margin-bottom: 20px;
}

.channel-profile {
    display: flex;
    gap: 30px;
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    align-items: flex-start;
}

.profile-logo {
    position: relative;
}

.profile-logo img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--bg-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.profile-logo-fallback {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid var(--bg-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background-color: var(--accent-color);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.profile-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.profile-info h1 {
    margin: 0 0 10px 0;
    font-size: 2rem;
    word-wrap: break-word;
}

.profile-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.stat-value-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-change {
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-change.positive {
    color: var(--success-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

.youtube-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.stats-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.stats-table th.sortable:hover {
    background-color: rgba(230, 33, 23, 0.05);
}

.stats-table th.sortable:focus {
    outline: none;
    background-color: transparent;
}

.stats-table th.sortable:active {
    outline: none;
    background-color: rgba(230, 33, 23, 0.1);
}

/* На мобильных устройствах убираем красный фон из :active, чтобы он не залипал */
@media (hover: none) and (pointer: coarse) {
    .stats-table th.sortable:active {
        background-color: transparent;
    }
    
    .stats-table th.sortable:hover {
        background-color: transparent;
    }
}

.stats-table th.sortable::after {
    display: none;
}

.stats-table th.sortable .sort-icon {
    margin-left: 5px;
    font-size: 0.9em;
    color: var(--text-primary);
    opacity: 0.3;
    display: inline-block;
    min-width: 1em;
    text-align: center;
}

.stats-table th.sortable.sorted .sort-icon {
    color: var(--accent-color);
    opacity: 1;
}

@media (max-width: 768px) {
    .channel-profile {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px;
        gap: 20px;
    }
    
    .profile-logo img {
        width: 100px;
        height: 100px;
    }

    .profile-logo-fallback {
        width: 100px;
        height: 100px;
        font-size: 2rem;
    }
    
    .profile-info h1 {
        font-size: 1.5rem;
    }
    
    .profile-actions {
        display: flex;
        justify-content: center;
        width: 100%;
    }
    
    .stats-grid {
        margin-bottom: 30px;
        gap: 12px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .charts-section {
        margin-bottom: 20px;
    }
    
    .daily-stats-section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .daily-stats-section h3 {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }
    
    .stats-table {
        min-width: 500px;
    }
    
    .stats-table th, 
    .stats-table td {
        padding: 10px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .channel-profile {
        padding: 15px;
    }
    
    .profile-logo img {
        width: 80px;
        height: 80px;
    }
    
    .profile-info h1 {
        font-size: 1.25rem;
    }
    
    .profile-description {
        font-size: 0.9rem;
    }
    
    .btn-primary {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
    
    .chart-container {
        padding: 10px 5px;
        height: 250px;
    }
    
    .tab-btn {
        font-size: 0.85rem;
        padding: 10px 8px;
    }
    
    .daily-stats-section {
        padding: 12px;
    }
    
    .daily-stats-section h3 {
        font-size: 1rem;
    }
    
    
    .stats-table th, 
    .stats-table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    .stat-diff {
        font-size: 0.75rem;
    }
}

/* Стили для блока последних видео */
.latest-videos-section {
    margin-top: 40px;
    margin-bottom: 40px;
}

.latest-videos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.latest-videos-section h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.view-all-link {
    display: inline-flex;
    align-items: center;
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.view-all-link:hover {
    opacity: 0.8;
}

.videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.video-card {
    display: flex;
    flex-direction: column;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.video-card:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background-color: var(--hover-color);
}

.video-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    background-color: var(--border-color);
    overflow: hidden;
}

.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-thumbnail-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--border-color);
    color: var(--text-secondary);
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    z-index: 1;
}

.video-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.video-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-stats-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: auto;
}

.video-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    flex: 1;
}

.video-stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.video-stat-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.video-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .latest-videos-section {
        margin-top: 30px;
        margin-bottom: 30px;
    }
    
    .latest-videos-header {
        margin-bottom: 20px;
        flex-wrap: wrap;
    }
    
    .latest-videos-section h3 {
        font-size: 1.3rem;
    }
    
    .view-all-link {
        font-size: 0.9rem;
    }
    
    .videos-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 16px;
    }
    
    .video-info {
        padding: 12px;
        gap: 10px;
    }
    
    .video-title {
        font-size: 0.95rem;
    }
    
    .video-stats {
        gap: 12px;
    }
    
    .video-stat-item {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .videos-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .latest-videos-header {
        margin-bottom: 16px;
    }
    
    .latest-videos-section h3 {
        font-size: 1.2rem;
    }
    
    .video-stats-wrapper {
        align-items: flex-start;
        gap: 8px;
    }
    
    .video-date {
        align-self: flex-end;
    }
}

/* Стили для страницы всех видео */
.videos-page {
    margin-top: 20px;
    margin-bottom: 40px;
}

.videos-page-header {
    margin-bottom: 32px;
}

.videos-page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.videos-page-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Фильтры видео */
.videos-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.filter-btn {
    padding: 8px 16px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    display: inline-block;
}

.filter-btn:hover {
    background-color: var(--hover-color);
    border-color: var(--accent-color);
}

.filter-btn.active {
    background-color: var(--accent-color);
    color: #ffffff;
    border-color: var(--accent-color);
}

/* Стили для карточек видео с аватаркой канала */
.video-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.video-channel-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    position: relative;
}

.video-channel-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.video-channel-avatar-fallback {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: var(--accent-color);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.video-title-wrapper {
    flex: 1;
    min-width: 0;
}

.video-channel-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.3;
}

.video-channel-name a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.video-channel-name a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 40px;
    padding: 20px 0;
}

.pagination-btn {
    padding: 10px 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.pagination-btn:hover:not(.disabled) {
    background-color: var(--hover-color);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

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

.pagination-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 0 16px;
}

.no-videos {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.no-videos p {
    font-size: 1.1rem;
    margin: 0;
}

@media (max-width: 768px) {
    .videos-page-header h1 {
        font-size: 1.5rem;
    }
    
    .videos-filters {
        gap: 8px;
        margin-bottom: 20px;
    }
    
    .filter-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .video-header {
        gap: 10px;
    }
    
    .video-channel-avatar,
    .video-channel-avatar img,
    .video-channel-avatar-fallback {
        width: 32px;
        height: 32px;
    }
    
    .video-channel-avatar-fallback {
        font-size: 0.75rem;
    }
    
    .video-channel-name {
        font-size: 0.8rem;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 12px;
        margin-top: 30px;
    }
    
    .pagination-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    .pagination-info {
        width: 100%;
        text-align: center;
        padding: 0;
    }
}
