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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Левое меню */
.sidebar {
    width: 250px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: #3498db;
    color: white;
}

.nav-item i {
    margin-right: 10px;
    width: 20px;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 10px 0;
}

/* Центральная область */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

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

.page-header h1 {
    font-size: 28px;
    font-weight: 600;
}

/* Правая AI панель */
.ai-panel {
    width: 400px;
    background: white;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 1000;
    overflow: hidden; /* Предотвращаем прокрутку всей панели */
}

.ai-panel-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Заголовок не сжимается */
    height: auto;
}

.ai-panel-header h3 {
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.ai-panel-content {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    min-height: 0;
    /* Высота рассчитывается через flex */
}

.ai-panel-scrollable {
    flex: 1 1 auto;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 20px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    overscroll-behavior: contain;
    /* Убеждаемся, что элемент может прокручиваться */
    /* Убираем max-height: 100% - полагаемся на flex */
}

.ai-review-section,
.ai-response-section {
    margin-bottom: 30px;
}

.ai-review-section h4,
.ai-response-section h4 {
    margin-bottom: 15px;
    color: #555;
}

.review-display {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.review-rating {
    font-size: 18px;
    margin-bottom: 10px;
}

.review-text {
    line-height: 1.6;
    margin-bottom: 10px;
}

.review-product {
    color: #666;
    font-size: 14px;
}

.ai-controls {
    margin-bottom: 15px;
}

.ai-controls label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-controls input[type="range"] {
    flex: 1;
}

.ai-response-text {
    background: #f0f7ff;
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid #3498db;
    line-height: 1.6;
    min-height: 100px;
    margin-bottom: 15px;
}

.ai-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #eee;
    background: white;
    flex-shrink: 0;
    /* Фиксируем кнопки внизу панели */
    position: relative;
    z-index: 10;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-outline {
    background: white;
    border: 1px solid #ddd;
    color: #333;
}

.btn-outline:hover {
    background: #f5f5f5;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Дашборд */
.dashboard h1 {
    margin-bottom: 30px;
}

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

.period-selector {
    display: flex;
    gap: 10px;
    background: white;
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.period-btn {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.period-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.period-btn.active {
    background: #3498db;
    color: white;
}

.period-info {
    margin-bottom: 20px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 14px;
    color: #666;
}

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

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.stat-card-large {
    grid-column: span 2;
}

.stat-icon {
    font-size: 36px;
    color: #3498db;
}

.stat-icon-warning {
    color: #f39c12;
}

.stat-icon-info {
    color: #3498db;
}

.stat-icon-success {
    color: #27ae60;
}

.stat-icon-rating {
    color: #e67e22;
}

.stat-icon-auto {
    color: #9b59b6;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.stat-details {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.dashboard-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.dashboard-section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #333;
}

.detailed-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.detailed-stat-group {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.detailed-stat-group h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detailed-stat-group h3 i {
    color: #3498db;
}

.detailed-stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.detailed-stat-item:last-child {
    border-bottom: none;
}

.detailed-stat-item .label {
    color: #666;
    font-size: 14px;
}

.detailed-stat-item .value {
    color: #333;
    font-weight: 600;
    font-size: 16px;
}

.reviews-preview {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.review-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #3498db;
    transition: all 0.2s;
}

.review-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.review-rating {
    font-size: 16px;
    margin-bottom: 8px;
}

.review-text {
    color: #555;
    line-height: 1.5;
    margin-bottom: 10px;
}

.review-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.sender-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.sender-bot {
    background: #e3f2fd;
    color: #1976d2;
}

.sender-human {
    background: #e8f5e9;
    color: #388e3c;
}

/* Таблицы */
.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters select,
.filters input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.reviews-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.reviews-table table {
    width: 100%;
    border-collapse: collapse;
}

.reviews-table thead {
    background: #f8f9fa;
}

.reviews-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #ddd;
}

.reviews-table td {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.reviews-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

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

.review-text-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-new {
    background: #fff3cd;
    color: #856404;
}

.status-ai_generated {
    background: #d1ecf1;
    color: #0c5460;
}

.status-sent {
    background: #d4edda;
    color: #155724;
}

.status-archived {
    background: #e2e3e5;
    color: #383d41;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: #3498db;
    font-size: 16px;
    padding: 5px;
}

.btn-icon:hover {
    color: #2980b9;
}
