:root {
  --primary: #6366f1;
  --success: #10b981;
  --danger: #ef4444;
  --text: #1e293b;
  --border: #e2e8f0;
  --bg: #fafafa;
  --card-bg: #ffffff;
  --shadow: 0 4px 6px rgba(0,0,0,0.05);
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  padding: 2rem 1rem;
  margin: 0;
  min-height: 100vh;
}
.container {
  max-width: 900px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  padding: 2.5rem;
}
.hidden { display: none !important; }
.text-center { text-align: center; }

/* Заголовки */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: bold;
  color: var(--text);
}
h2 { font-size: 1.6rem; margin-bottom: 1.5rem; }

/* Формы */
.form-group { margin-bottom: 1.25rem; }
.form-group > label {
  display: block;
  font-weight: bold;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.9rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--bg);
  transition: all 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-hint { font-size: 0.85rem; color: #64748b; margin-top: 0.3rem; display: block; }

/* Группа ввода домена */
.domain-input-group {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}
#domain { flex: 1; }
#findQueriesBtn {
  padding: 0.875rem 1.25rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
#findQueriesBtn:hover:not(:disabled) {
  background: #4f46e5;
  transform: translateY(-1px);
}
#findQueriesBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
#findQueriesBtn .btn-loader {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  opacity: 0;
  margin-left: 0.5rem;
}
#findQueriesBtn .btn-loader.active { opacity: 1; }

/* Подсказка для запросов */
.queries-hint {
  background: rgba(99, 102, 241, 0.08);
  border-left: 4px solid var(--primary);
  padding: 1rem;
  border-radius: 0 8px 8px 0;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.5;
}
.queries-hint strong { color: var(--primary); font-weight: 600; }
.queries-hint code {
  background: rgba(0,0,0,0.05);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
  color: var(--primary);
}

/* Кнопки */
.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}
.btn:hover { transform: translateY(-1px); }
#checkBtn {
  background: var(--primary);
  color: white;
  width: 100%;
  padding: 1rem;
  font-size: 1.05rem;
  margin-top: 0.5rem;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}
#checkBtn:hover { background: #4f46e5; box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-success:hover { background: #0da271; }
.full-width { width: 100%; justify-content: center; }

/* Статистика */
.stats-card {
  background: rgba(99, 102, 241, 0.05);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td {
  padding: 0.9rem 0.75rem;
  text-align: center;
  border: none;
}
.stats-table th {
  background: rgba(255,255,255,0.7);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 8px;
}
.stats-table td {
  background: white;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* Таблица результатов */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  background: white;
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.results-table th,
.results-table td {
  padding: 1.1rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.results-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #64748b;
  position: sticky;
  top: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.results-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.03);
}
.pos-not-found {
  color: var(--danger);
  font-weight: 600;
  background: rgba(239, 68, 68, 0.1);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  display: inline-block;
}
.pos-found {
  color: var(--primary);
  font-weight: 700;
  font-size: 1.15rem;
  background: rgba(99, 102, 241, 0.1);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  display: inline-block;
}
.result-url {
  display: block;
  font-size: 0.85rem;
  color: var(--primary);
  text-decoration: none;
  margin-top: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-url:hover { text-decoration: underline; }

/* Модалки */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}
.modal:not(.hidden) {
  opacity: 1;
  visibility: visible;
}
.modal-content {
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.modal-header {
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { margin: 0; font-size: 1.3rem; }
.modal-body {
  padding: 1.5rem;
}
.modal-body input {
  width: 100%;
  padding: 0.8rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}
.copy-hint {
  text-align: center;
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 0.5rem;
}

/* Анимации */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Адаптивность */
@media (max-width: 768px) {
  .container { padding: 1.5rem; }
  .domain-input-group { flex-direction: column; }
  #findQueriesBtn { width: 100%; }
  h2 { font-size: 1.4rem; }
  .stats-table th, .stats-table td { padding: 0.6rem 0.4rem; font-size: 0.8rem; }
  .results-table th, .results-table td { padding: 0.8rem 0.6rem; font-size: 0.85rem; }
}