:root {
  --bg: #07111f;
  --panel: rgba(255,255,255,.08);
  --panel2: rgba(255,255,255,.12);
  --line: rgba(255,255,255,.14);
  --text: #edf4ff;
  --muted: #9fb0c7;
  --accent: #6ea8fe;
  --violet: #9b7cff;
  --good: #32d296;
  --bad: #ff6370;
  --warn: #ffd166;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(circle at top left, rgba(62,112,255,.26), transparent 34%),
              radial-gradient(circle at bottom right, rgba(155,124,255,.18), transparent 32%),
              var(--bg);
}
.bg { position: fixed; width: 340px; height: 340px; border-radius: 50%; filter: blur(60px); opacity: .28; pointer-events: none; }
.bg1 { right: 6%; top: 8%; background: var(--accent); }
.bg2 { left: 4%; bottom: 8%; background: var(--violet); }
.topbar {
  width: min(1240px, calc(100% - 32px));
  margin: 18px auto 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.07);
  backdrop-filter: blur(18px);
}
.brand { color: var(--text); text-decoration: none; font-weight: 900; }
.navlinks { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.navlinks a, .user { color: var(--muted); text-decoration: none; font-size: 14px; }
.user { padding: 6px 10px; background: rgba(255,255,255,.08); border-radius: 999px; color: var(--text); }
.shell { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 60px; }
.login-wrap { min-height: 88vh; display: grid; place-items: center; }
.login-card, .panel, .limit-card, .card {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 24px 80px rgba(0,0,0,.36);
  backdrop-filter: blur(18px);
}
.login-card { width: min(480px, 100%); padding: 30px; }
.badge { display: inline-flex; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); color: #cfe0ff; background: rgba(255,255,255,.06); margin-bottom: 14px; }
h1 { margin: 0 0 12px; font-size: clamp(30px, 5vw, 56px); line-height: 1; letter-spacing: -1.6px; }
h2 { margin: 0; }
p { color: var(--muted); line-height: 1.55; }
.form { display: grid; gap: 14px; margin-top: 18px; }
label { color: #dbe7fb; font-weight: 700; }
input {
  width: 100%; margin-top: 7px; padding: 13px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(0,0,0,.25); color: var(--text);
}
button, .download, .small-btn {
  border: 0; border-radius: 14px; padding: 12px 16px;
  color: #07111f; background: linear-gradient(135deg, var(--accent), var(--violet));
  font-weight: 900; text-decoration: none; display: inline-flex; justify-content: center;
  cursor: pointer;
}
.download.secondary, .small-btn.ghost { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--line); }
.hero { display: grid; grid-template-columns: 1.4fr .6fr; gap: 22px; align-items: stretch; margin-bottom: 22px; }
.hero.compact { grid-template-columns: 1fr .9fr; }
.limit-card { padding: 24px; display: grid; align-content: center; }
.limit-card span, .limit-card small { color: var(--muted); }
.limit-card strong { font-size: 46px; }
.panel { padding: 22px; margin-bottom: 22px; }
.panel.narrow { max-width: 680px; margin: 0 auto; }
.upload-form { display: grid; gap: 14px; }
.drop { display: grid; place-items: center; text-align: center; min-height: 170px; border: 1.5px dashed rgba(255,255,255,.26); border-radius: 22px; cursor: pointer; background: rgba(255,255,255,.04); }
.drop input { display: none; }
.drop span { color: var(--muted); margin-top: 7px; font-weight: 400; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.table-wrap { overflow: auto; border: 1px solid rgba(255,255,255,.1); border-radius: 18px; }
.table-wrap.tall { height: 540px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.09); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: rgba(9,17,31,.98); color: #cfe0ff; z-index: 2; }
td { color: #dbe7fb; }
.muted { color: var(--muted); text-align: center; }
.pill { display: inline-flex; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.pill.done, .pill.valid { background: var(--good); color: #041e16; }
.pill.error, .pill.invalid { background: var(--bad); color: #270408; }
.pill.running, .pill.queued { background: var(--warn); color: #221800; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stats-grid div, .card { padding: 18px; }
.stats-grid strong, .card strong { display: block; font-size: 34px; }
.stats-grid span, .card span { color: var(--muted); }
.progress-block { margin: -2px 0 22px; }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 9px; }
.progress { height: 12px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--good)); transition: .25s; }
.downloads { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.hidden { display: none; }
.grid { display: grid; grid-template-columns: .95fr 1.25fr; gap: 22px; }
pre { height: 540px; overflow: auto; margin: 0; padding: 16px; border-radius: 18px; background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.1); color: #d9e7ff; line-height: 1.55; white-space: pre-wrap; }
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.card { color: var(--text); text-decoration: none; }
.flash-wrap { display: grid; gap: 10px; margin-bottom: 16px; }
.flash { padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.08); }
.flash.success { border-color: rgba(50,210,150,.45); }
.flash.danger { border-color: rgba(255,99,112,.55); }
.actions { display: flex; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: auto; margin: 0; }
.danger-btn { background: rgba(255,99,112,.14); color: #ffd7dc; border: 1px solid rgba(255,99,112,.35); margin-top: 0; }
@media (max-width: 940px) {
  .hero, .hero.compact, .grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

select {
  width: 100%;
  margin-top: 7px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.25);
  color: var(--text);
}

hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

.manual-help {
  margin-top: -4px;
  margin-bottom: 16px;
}

.manual-check-form {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
  align-items: end;
}

.manual-check-form input {
  margin-top: 0;
}

.manual-result {
  margin-top: 16px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.22);
}

.manual-result-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.manual-result-head strong {
  font-size: 18px;
}

.manual-result-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr 1fr;
  gap: 12px;
}

.manual-result-grid div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(255,255,255,.08);
}

.manual-result-grid small {
  display: block;
  color: var(--muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 11px;
}

.manual-result-grid p {
  margin: 0;
  color: var(--text);
  word-break: break-word;
}

.manual-loading,
.manual-error {
  color: var(--text);
  font-weight: 800;
}

.manual-error {
  color: #ffd7dc;
}

button:disabled {
  opacity: .6;
  cursor: wait;
}

@media (max-width: 900px) {
  .manual-check-form {
    grid-template-columns: 1fr;
  }

  .manual-result-grid {
    grid-template-columns: 1fr;
  }
}

/* === Responsive task page / results table fix === */

/* Запрещаем странице разъезжаться по горизонтали */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Все основные контейнеры не должны быть шире экрана */
.container,
.page,
.content,
main,
.panel,
.card {
  max-width: 100%;
  box-sizing: border-box;
}

/* Grid-блоки не должны принудительно расширять страницу */
.grid,
.task-grid,
.dashboard-grid,
.panels-grid {
  max-width: 100%;
  min-width: 0;
}

/* Все дочерние элементы внутри grid могут сжиматься */
.grid > *,
.task-grid > *,
.dashboard-grid > *,
.panels-grid > * {
  min-width: 0;
}

/* Таблицы */
table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Ячейки таблиц */
th,
td {
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  vertical-align: top;
}

/* Колонка email */
td:first-child,
th:first-child {
  width: 32%;
}

/* Колонка статуса */
td:nth-child(2),
th:nth-child(2) {
  width: 130px;
}

/* Колонка деталей */
td:nth-child(3),
th:nth-child(3) {
  width: auto;
}

/* Блоки с таблицами не должны ломать страницу */
.table-wrap,
.results-table,
.history-table {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Лог проверки */
.log-box,
.log,
pre,
code {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Если где-то есть внутренние scroll-блоки, скролл только внутри них */
.scroll-box,
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

/* Длинные технические строки SMTP/MX/HELO/FROM */
td,
.result-detail,
.details,
.detail,
.task-detail {
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}

/* Бейджи статусов не должны растягиваться */
.pill,
.badge,
.status,
.status-badge {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Узкие экраны */
@media (max-width: 1100px) {
  table {
    table-layout: auto;
  }

  td:first-child,
  th:first-child,
  td:nth-child(2),
  th:nth-child(2),
  td:nth-child(3),
  th:nth-child(3) {
    width: auto;
  }
}

/* Совсем узкие экраны — таблица превращается в аккуратные карточки */
@media (max-width: 760px) {
  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tr {
    margin-bottom: 14px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255,255,255,.045);
    border: 1px solid rgba(255,255,255,.08);
  }

  td {
    border: none !important;
    padding: 7px 0 !important;
  }

  td:first-child::before {
    content: "Email: ";
    font-weight: 800;
    color: var(--muted);
  }

  td:nth-child(2)::before {
    content: "Статус: ";
    font-weight: 800;
    color: var(--muted);
    margin-right: 6px;
  }

  td:nth-child(3)::before {
    content: "Детали: ";
    display: block;
    font-weight: 800;
    color: var(--muted);
    margin-bottom: 4px;
  }
}

/* === Task results panel specific === */

.task-results,
.latest-results,
.last-results,
.results-panel {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.task-results table,
.latest-results table,
.last-results table,
.results-panel table {
  width: 100%;
  table-layout: fixed;
}

.task-results td,
.latest-results td,
.last-results td,
.results-panel td {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.task-results td:last-child,
.latest-results td:last-child,
.last-results td:last-child,
.results-panel td:last-child {
  font-size: 15px;
  line-height: 1.45;
}

/* === Admin users page: clean layout === */

.users-panel {
  overflow: hidden;
}

.users-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.users-page-head h1 {
  margin: 0;
}

.users-create-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 260px;
  height: 64px;
  padding: 0 28px !important;
  border-radius: 22px;
  text-decoration: none !important;
  white-space: nowrap !important;
}

.users-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.users-table {
  width: 100%;
  table-layout: fixed;
}

.users-table th,
.users-table td {
  vertical-align: middle;
  box-sizing: border-box;
}

.users-table th:nth-child(1),
.users-table td:nth-child(1) {
  width: 13%;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
  width: 25%;
  overflow-wrap: anywhere;
}

.users-table th:nth-child(3),
.users-table td:nth-child(3) {
  width: 8%;
}

.users-table th:nth-child(4),
.users-table td:nth-child(4) {
  width: 10%;
}

.users-table th:nth-child(5),
.users-table td:nth-child(5) {
  width: 9%;
}

.users-table th:nth-child(6),
.users-table td:nth-child(6) {
  width: 15%;
  white-space: nowrap;
}

.users-table th:nth-child(7),
.users-table td:nth-child(7) {
  width: 20%;
}

.users-actions-cell {
  white-space: nowrap;
}

.users-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  max-width: 100%;
}

.users-actions-row form {
  display: flex;
  margin: 0;
  padding: 0;
}

.users-actions-row a,
.users-actions-row button {
  width: 106px !important;
  min-width: 106px !important;
  max-width: 106px !important;
  height: 46px !important;
  padding: 0 10px !important;
  border-radius: 16px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  white-space: nowrap !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  line-height: 1 !important;
  text-decoration: none !important;
  box-sizing: border-box !important;
}

@media (max-width: 1250px) {
  .users-table {
    min-width: 1120px;
  }
}

@media (max-width: 760px) {
  .users-page-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .users-create-btn {
    width: 100%;
    min-width: 0;
  }
}

/* === Fix create user button === */

.users-page-head .users-create-btn,
a.users-create-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  min-width: 280px !important;
  height: 64px !important;
  padding: 0 30px !important;

  border-radius: 22px !important;
  border: 0 !important;

  background: linear-gradient(135deg, #7ea2ff, #8b78f6) !important;
  color: #08111f !important;

  font-weight: 900 !important;
  font-size: 18px !important;
  line-height: 1 !important;
  text-decoration: none !important;
  white-space: nowrap !important;

  box-shadow: 0 18px 45px rgba(91, 120, 255, .28) !important;
}

.users-page-head .users-create-btn:hover,
a.users-create-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

/* === Admin tasks page: clean layout === */

.tasks-panel {
  overflow: hidden;
}

.tasks-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.tasks-table {
  width: 100%;
  table-layout: fixed;
}

.tasks-table th,
.tasks-table td {
  vertical-align: middle;
  box-sizing: border-box;
}

/* Колонки таблицы задач */
.tasks-table th:nth-child(1),
.tasks-table td:nth-child(1) {
  width: 18%;
}

.tasks-table th:nth-child(2),
.tasks-table td:nth-child(2) {
  width: 14%;
  overflow-wrap: anywhere;
}

.tasks-table th:nth-child(3),
.tasks-table td:nth-child(3) {
  width: 13%;
  overflow-wrap: anywhere;
}

.tasks-table th:nth-child(4),
.tasks-table td:nth-child(4) {
  width: 10%;
}

.tasks-table th:nth-child(5),
.tasks-table td:nth-child(5) {
  width: 8%;
}

.tasks-table th:nth-child(6),
.tasks-table td:nth-child(6) {
  width: 10%;
}

.tasks-table th:nth-child(7),
.tasks-table td:nth-child(7) {
  width: 11%;
}

.tasks-table th:nth-child(8),
.tasks-table td:nth-child(8) {
  width: 16%;
}

/* Ячейка с кнопкой */
.tasks-actions-cell {
  white-space: nowrap;
}

/* Кнопка "Открыть" */
.tasks-open-btn {
  width: 120px !important;
  min-width: 120px !important;
  max-width: 120px !important;
  height: 46px !important;
  padding: 0 14px !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  border-radius: 16px !important;
  text-align: center !important;
  text-decoration: none !important;

  white-space: nowrap !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
}

/* Перебиваем старые правила последней колонки */
.tasks-table th:last-child,
.tasks-table td:last-child {
  width: 16% !important;
}

/* Пагинация */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

/* На средних экранах таблица скроллится внутри блока */
@media (max-width: 1250px) {
  .tasks-table {
    min-width: 1050px;
  }
}
