:root{
  --bg: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --primary: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --primary-solid: #3b82f6;
  --success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --info: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  --secondary: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.2);
}

body{
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
}

/* Diff текст в таблице - inline формат */
.diff-text{
  font-size: 0.8rem;
  line-height: 1.4;
  word-wrap: break-word;
  color: #475569;
}

.clickable-diff{
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.clickable-diff:hover{
  opacity: 0.8;
}

.diff-text strong{
  display: inline;
  font-weight: 600;
  color: var(--text);
  margin-right: 0.25rem;
}

.diff-text .text-danger{
  display: inline;
  text-decoration: line-through;
  color: #dc3545;
  margin: 0 0.25rem;
  padding: 0.125rem 0.25rem;
  background-color: #fee2e2;
  border-radius: 2px;
}

.diff-text .text-success{
  display: inline;
  color: #198754;
  margin: 0 0.25rem;
  padding: 0.125rem 0.25rem;
  background-color: #d1fae5;
  border-radius: 2px;
}

.diff-text .separator{
  display: inline;
  color: var(--muted);
  margin: 0 0.25rem;
}

/* Полный diff в модалке */
.diff-full{
  font-size: 0.95rem;
}

.diff-content{
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
}

.diff-old .diff-content{
  color: #991b1b;
}

.diff-new .diff-content{
  color: #065f46;
}

/* Модалка - улучшенное оформление */
.modal-info{
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border);
}


.info-row{
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

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

.info-row i{
  font-size: 1.1rem;
  flex-shrink: 0;
}

.info-row strong{
  margin-right: 0.5rem;
  color: var(--text);
}

.info-row a{
  color: var(--primary-solid);
  word-break: break-all;
}

.info-row a:hover{
  text-decoration: underline;
}

/* Расширенная рабочая зона с адаптивными отступами */
.container-fluid{
  max-width: 1800px;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 576px) {
  .container-fluid{ padding-left: 1.25rem; padding-right: 1.25rem; }
}

@media (min-width: 768px) {
  .container-fluid{ padding-left: 1.5rem; padding-right: 1.5rem; }
}

@media (min-width: 992px) {
  .container-fluid{ padding-left: 2rem; padding-right: 2rem; }
}

@media (min-width: 1200px) {
  .container-fluid{ padding-left: 2.5rem; padding-right: 2.5rem; }
}

@media (min-width: 1400px) {
  .container-fluid{ padding-left: 3rem; padding-right: 3rem; }
}

/* Адаптивная таблица */
@media (max-width: 767px){
  /* Горизонтальный скролл для таблицы на мобильных */
  .card-body .table{
    min-width: 800px;
  }
}

/* Navbar - современный с тенью */
.navbar{
  background: #fff !important;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

.navbar-brand{
  font-weight: 600;
  color: var(--text) !important;
}

.nav-link{
  color: var(--muted) !important;
  font-weight: 500;
}

.nav-link:hover{
  color: var(--primary) !important;
}

/* Cards - современные с тенями */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-header{
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 12px 12px 0 0 !important;
}

/* Card body - объединены все свойства */
.card-body{
  padding: 1.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Статистические карточки с градиентами */
.stat-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-md);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before{
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-solid);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card:hover{
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-card:hover::before{
  opacity: 1;
}

.stat-card.text-primary::before{
  background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.stat-card.text-danger::before{
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

.stat-card.text-warning::before{
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.stat-card.text-info::before{
  background: linear-gradient(90deg, #06b6d4, #0891b2);
}

.stat-card h3{
  font-size: 2rem;
  font-weight: 700;
  margin: 0.5rem 0;
  background: var(--primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Специфичные цвета для разных типов карточек */
.stat-card.text-primary h3{
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card.text-danger h3{
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card.text-warning h3{
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card.text-info h3{
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card h6{
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
  line-height: 1.2;
}

.stat-card .icon{
  font-size: 1.5rem;
  opacity: 0.7;
}

/* Таблицы - улучшенные */
.table{
  margin-bottom: 0;
  width: 100%;
}

#changesTable{
  width: 100% !important;
}

.table thead th{
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.6rem 0.5rem;
}

.table tbody tr{
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease;
}

.table tbody td{
  padding: 0.5rem;
  font-size: 0.85rem;
  vertical-align: middle;
}

.table tbody tr:hover{
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* Формы - стилизованные */
.form-control, .form-select{
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus{
  border-color: var(--primary-solid);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
  outline: none;
}

.form-check-input:checked{
  background-color: var(--primary-solid);
  border-color: var(--primary-solid);
}

/* Кнопки - современные */
.btn{
  border-radius: 8px;
  font-weight: 500;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline-success{
  border: 2px solid #10b981;
  color: #10b981;
}

.btn-outline-success:hover{
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: #10b981;
  color: white;
}

/* Бейджи - стилизованные */
.badge{
  padding: 0.375rem 0.75rem;
  font-weight: 500;
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.badge.bg-danger{
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
}

.badge.bg-warning{
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}

.badge.bg-info{
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%) !important;
}

/* Utilities */
.text-muted-ux{
  color: var(--muted) !important;
}

/* DataTables - стилизованные */
.dataTables_wrapper .dataTables_filter input{
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dataTables_wrapper .dataTables_filter input:focus{
  border-color: var(--primary-solid);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
  outline: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button{
  border-radius: 8px !important;
  border: 1px solid var(--border) !important;
  transition: all 0.2s ease;
  margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover{
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current{
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  color: #fff !important;
  border-color: #3b82f6 !important;
  box-shadow: var(--shadow-md);
}

/* List items */
.list-item{
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.list-item:hover{
  background: #f8fafc;
}

/* Фильтры таблицы - упрощенная сетка */
.table-filters{
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  align-items: flex-end;
}

.filter-group{
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 0 0 auto;
  flex-shrink: 0;
}

/* Группы с селекторами/инпутами */
.filter-group:not(.filter-group-checkbox){
  min-width: 140px;
}

/* Группы с чекбоксами */
.filter-group-checkbox{
  min-width: auto;
  width: auto;
  flex: 0 0 auto;
  margin-right: 1rem;
}

.filter-group-checkbox:last-child{
  margin-right: 0;
}


.filter-label{
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0;
  line-height: 1.2;
  height: 16px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.table-filters .form-control,
.table-filters .form-select{
  font-size: 0.875rem;
  width: 140px;
  min-width: 140px;
  max-width: 140px;
  height: 38px;
  padding: 0.5rem 0.75rem;
  box-sizing: border-box;
}

.table-filters .form-check{
  margin: 0;
  padding: 0;
  height: 38px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}

.table-filters .form-check-inline{
  display: flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}

.table-filters .form-check-input{
  margin-top: 0;
  margin-right: 0.5rem;
  width: 1.1em;
  height: 1.1em;
  cursor: pointer;
}

.table-filters .form-check-label{
  margin-bottom: 0;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  line-height: 1.5;
}

.table-filters .form-check-label i{
  margin-right: 0.375rem;
}

/* График - стилизация */
.chart-container{
  position: relative;
  height: 250px;
  padding: 1rem;
}

.chart-container canvas{
  max-height: 250px;
}

/* Responsive - мобильные устройства */
@media (max-width: 575px){
  .container-fluid{
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  .stat-card{
    padding: 0.875rem;
    margin-bottom: 0.75rem;
  }
  
  .stat-card h3{
    font-size: 1.25rem;
  }
  
  .card-body{
    padding: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table-filters{
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 0.75rem;
  }
  
  .filter-group-checkbox{
    margin-right: 0;
    margin-bottom: 0.75rem;
  }
  
  .filter-group-checkbox:last-child{
    margin-bottom: 0;
  }
  
  .table-filters .filter-group{
    flex: 0 0 auto;
    width: 100%;
  }
  
  .table-filters .form-control,
  .table-filters .form-select{
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    font-size: 0.875rem;
  }
  
  .table thead th{
    font-size: 0.75rem;
    padding: 0.5rem 0.375rem;
  }
  
  .table tbody td{
    font-size: 0.8rem;
    padding: 0.5rem 0.375rem;
  }
  
  .chart-container{
    height: 180px;
    padding: 0.75rem;
  }
  
  .diff-text{
    font-size: 0.75rem;
  }
}

/* Responsive - планшеты */
@media (min-width: 576px) and (max-width: 767px){
  .stat-card{
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .stat-card h3{
    font-size: 1.5rem;
  }
  
  .table-filters{
    flex-wrap: wrap;
    gap: 1.75rem;
  }
  
  .table-filters .form-control,
  .table-filters .form-select{
    min-width: 140px;
    max-width: 140px;
    flex: 0 0 auto;
  }
  
  .table-filters .filter-group{
    flex: 0 0 auto;
  }
  
  .chart-container{
    height: 220px;
  }
}

/* Responsive - планшеты (горизонтальная ориентация) и маленькие десктопы */
@media (min-width: 768px) and (max-width: 991px){
  .stat-card h3{
    font-size: 1.75rem;
  }
  
  .table-filters .form-control,
  .table-filters .form-select{
    min-width: 130px;
    max-width: 130px;
    flex: 0 0 auto;
  }
  
  .table-filters .filter-group{
    flex: 0 0 auto;
  }
  
  .chart-container{
    height: 240px;
  }
}

/* Responsive - средние десктопы */
@media (min-width: 992px) and (max-width: 1199px){
  .stat-card h3{
    font-size: 1.875rem;
  }
  
  .table-filters .form-control,
  .table-filters .form-select{
    min-width: 120px;
    max-width: 120px;
    flex: 0 0 auto;
  }
  
  .table-filters .filter-group{
    flex: 0 0 auto;
  }
}

/* Улучшение адаптивности для больших экранов */
@media (min-width: 1200px){
  .stat-card h3{
    font-size: 2rem;
  }
  
  .table-filters{
    padding: 1rem 1.5rem;
  }
  
  .chart-container{
    height: 280px;
    padding: 1.5rem;
  }
}

@media (min-width: 1600px){
  .stat-card{
    padding: 1.5rem;
  }
  
  .table-filters{
    padding: 1.25rem 2rem;
  }
  
  .chart-container{
    height: 300px;
    padding: 2rem;
  }
}

/* Анимации */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-card,
.card{
  animation: fadeIn 0.5s ease;
}

/* Дополнительные стили для поля diff */
.diff-text em {
  font-style: italic;
  color: #64748b;
  font-weight: 500;
}

/* Компактные подсказки - иконки не увеличивают высоту элементов */
/* Иконки подсказок - компактные, не влияют на высоту строки */
.bi-question-circle[data-bs-toggle="tooltip"] {
  font-size: 0.7rem !important;
  line-height: 1;
  vertical-align: middle;
  display: inline;
  cursor: help;
  margin-left: 0.25rem;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.bi-question-circle[data-bs-toggle="tooltip"]:hover {
  opacity: 1;
}

/* Справка в заголовке таблицы - компактная ссылка */
.card-header .text-muted[data-bs-toggle="tooltip"] {
  cursor: help;
  transition: color 0.2s ease, opacity 0.2s ease;
  text-decoration: none;
}

.card-header .text-muted[data-bs-toggle="tooltip"]:hover {
  opacity: 1;
  color: var(--primary-solid) !important;
}

/* Для статистических карточек - компактные иконки в заголовке */
.stat-card h6 .bi-question-circle[data-bs-toggle="tooltip"] {
  font-size: 0.65rem !important;
  margin-left: 0.2rem;
}

/* Для фильтров - компактные иконки в лейблах */
.filter-label .bi-question-circle[data-bs-toggle="tooltip"] {
  font-size: 0.65rem !important;
  margin-left: 0.15rem;
}

/* Для чекбоксов - компактные иконки */
.form-check-label .bi-question-circle[data-bs-toggle="tooltip"] {
  font-size: 0.65rem !important;
  margin-left: 0.15rem;
  vertical-align: text-top;
}

/* Убеждаемся что заголовки и лейблы не растягиваются */
.stat-card h6 {
  white-space: nowrap;
}

.filter-label {
  white-space: nowrap;
}

/* Компактное отображение частоты с гистограммой */
.freq-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 8rem;
}

.freq-number {
  font-weight: 600;
  min-width: 3rem;
  text-align: right;
  font-size: 0.875rem;
  color: var(--text);
}

.freq-bar {
  flex: 1;
  height: 0.5rem;
  background: #e2e8f0;
  border-radius: 0.25rem;
  overflow: hidden;
  position: relative;
  min-width: 4rem;
}

.freq-bar-fill {
  height: 100%;
  transition: width 0.3s ease;
  border-radius: 0.25rem;
}

/* Иконка поисковой системы - компактная */
.search-engine-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}

.search-engine-icon i {
  font-size: 1.2rem;
}

.search-engine-yandex i {
  color: #ff0000;
}

.search-engine-google i {
  color: #4285f4;
}

/* Улучшенное отображение недоступных дат в календаре */
.flatpickr-day.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Ссылка на историю домена */
.domain-link {
  color: var(--text) !important;
  transition: color 0.2s ease;
  cursor: pointer;
}

.domain-link:hover {
  color: var(--primary-solid) !important;
  text-decoration: underline !important;
}

.domain-link i {
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.domain-link:hover i {
  opacity: 1;
}