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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

header h1 {
    font-size: 2.5em;
    color: #667eea;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

.controls {
    margin-bottom: 30px;
}

.domains-section {
    background: #f7fafc;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.domains-section h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.domains-section h3 {
    color: #4a5568;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.domains-list {
    margin-bottom: 20px;
}

.domains-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.domain-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.domain-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.domain-info {
    flex: 1;
}

.domain-info strong {
    color: #2d3748;
    display: block;
    margin-bottom: 5px;
}

.domain-meta {
    font-size: 0.85em;
    color: #718096;
}

.delete-domain-btn {
    background: #f56565;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.9em;
    cursor: pointer;
    transition: background 0.3s;
}

.delete-domain-btn:hover {
    background: #e53e3e;
}

.no-domains {
    text-align: center;
    color: #718096;
    padding: 20px;
    font-style: italic;
}

.add-domain-form {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.current-domain-section {
    background: #f7fafc;
    padding: 20px;
    border-radius: 12px;
}

.input-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.input-group select {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    background: white;
}

.input-group select:focus {
    outline: none;
    border-color: #667eea;
}

.input-group label {
    font-weight: 600;
    color: #555;
    min-width: 120px;
}

.input-group input {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.input-group button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

#load-btn {
    background: #667eea;
    color: white;
}

#load-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#auto-refresh-btn {
    background: #48bb78;
    color: white;
}

#auto-refresh-btn:hover {
    background: #38a169;
}

#auto-refresh-btn.active {
    background: #f56565;
}

#auto-refresh-btn.active:hover {
    background: #e53e3e;
}

#add-domain-btn {
    background: #48bb78;
    color: white;
}

#add-domain-btn:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

#add-domain-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    opacity: 0.7;
}

#add-domain-btn.loading {
    position: relative;
    color: transparent;
}

#add-domain-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f7fafc;
    border-radius: 8px;
    font-size: 14px;
}

#status-text {
    color: #4a5568;
    font-weight: 500;
}

#last-update {
    color: #718096;
    font-size: 12px;
}

.error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #c53030;
    font-weight: 500;
}

.charts-container {
    margin-bottom: 30px;
    background: #f7fafc;
    padding: 20px;
    border-radius: 12px;
}

.search-section {
    margin-bottom: 20px;
    background: #f7fafc;
    padding: 20px;
    border-radius: 12px;
}

#views-chart {
    max-height: 500px;
}

#active-pages-chart {
    max-height: 500px;
    margin-top: 30px;
}

.pages-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.page-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s;
    width: 100%;
}

.page-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.page-card h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1em;
    word-break: break-all;
}

.page-card .views-count {
    font-size: 1.8em;
    font-weight: bold;
    color: #2d3748;
    margin: 10px 0;
}

.page-card .views-label {
    color: #718096;
    font-size: 0.9em;
}

.page-card canvas {
    width: 100% !important;
    height: auto !important;
}

/* Для графиков групп делаем больше высоту */
.page-card canvas[id^="chart-group-"] {
    min-height: 300px !important;
    max-height: 400px !important;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #667eea;
    font-size: 1.2em;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Стили для tooltip Chart.js в стиле Яндекс.Метрики */
.chartjs-tooltip {
    position: absolute !important;
    pointer-events: none !important;
    z-index: 1000 !important;
}

.chartjs-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0, 0, 0, 0.85);
}

.chartjs-tooltip-header {
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.chartjs-tooltip-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chartjs-tooltip-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.chartjs-tooltip-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chartjs-tooltip-label {
    flex: 1;
    color: rgba(255, 255, 255, 0.9);
}

.chartjs-tooltip-value {
    font-weight: 600;
    color: #fff;
    min-width: 60px;
    text-align: right;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group label {
        min-width: auto;
    }

    .input-group input,
    .input-group button {
        width: 100%;
    }
}

