/* GainProfit — панель сбора данных.
   Тёмная тема в одном файле: панель небольшая, и разносить стили по десятку
   файлов здесь дороже, чем поддерживать один. Переменные в :root — единственное
   место, где задаются цвета: статусы и кнопки берут их оттуда. */

:root {
  --bg: #0a0b0d;
  --bg-soft: #0e1014;
  --panel: #12141a;
  --panel-2: #171a21;
  --panel-3: #1d2129;
  --border: #232732;
  --border-strong: #2f3542;
  --text: #e7eaf0;
  --muted: #8c95a8;
  --muted-2: #69718a;
  --accent: #3ddc84;
  --accent-2: #1fbf6b;
  --accent-ink: #04240f;
  --blue: #5b9dff;
  --amber: #ffb020;
  --red: #ff6b6b;
  --violet: #a78bfa;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Фон: та же сетка и свечение, что на лендинге — панель не должна выглядеть
   чужим сайтом. Оба слоя декоративные и отключены для prefers-reduced-motion. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  top: -280px;
  left: 50%;
  width: 900px;
  height: 560px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(61, 220, 132, 0.14), transparent 62%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: min(1180px, 100% - 40px); margin: 0 auto; position: relative; z-index: 1; }

/* --- Шапка ---------------------------------------------------------------- */

.header {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 11, 13, 0.82);
  backdrop-filter: blur(10px);
}

.header__inner {
  display: flex;
  align-items: center;
  gap: 26px;
  height: 66px;
}

.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; }
.logo:hover { text-decoration: none; }
.logo__mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-weight: 800; font-size: 13px; letter-spacing: 0.3px;
}
.logo__text { font-size: 16px; letter-spacing: 0.2px; }

.nav { display: flex; gap: 4px; margin-left: 10px; }
.nav a {
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
}
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.is-active { background: var(--panel-3); color: var(--text); }

.header__spacer { flex: 1; }

.userbox { display: flex; align-items: center; gap: 12px; }
.userbox__email { color: var(--muted); font-size: 13.5px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox form { margin: 0; }

/* --- Каркас страницы ------------------------------------------------------ */

.main { flex: 1; padding: 30px 0 64px; position: relative; z-index: 1; }

.page-title { font-size: 25px; font-weight: 660; margin: 0 0 6px; letter-spacing: -0.2px; }
.page-sub { color: var(--muted); margin: 0 0 24px; font-size: 14.5px; }

.grid { display: grid; gap: 18px; }
.grid--cols { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card__head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.012);
}
.card__title { font-size: 15.5px; font-weight: 620; margin: 0; }
.card__hint { color: var(--muted-2); font-size: 13px; margin-left: auto; }
.card__body { padding: 20px; }
.card--flush .card__body { padding: 0; }

/* --- Метрики -------------------------------------------------------------- */

.stat { padding: 16px 18px; }
.stat__label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.6px; }
.stat__value { font-size: 27px; font-weight: 680; margin-top: 6px; letter-spacing: -0.5px; }
.stat__value--accent { color: var(--accent); }
.stat__value--amber { color: var(--amber); }
.stat__value--red { color: var(--red); }
.stat__value--violet { color: var(--violet); }

/* --- Формы ---------------------------------------------------------------- */

.field { margin-bottom: 16px; }
.field__label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 7px; }
.field__row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }

.input, .textarea, .select {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { min-height: 132px; resize: vertical; font-family: inherit; }
.textarea--mono { font-family: var(--mono); font-size: 13.5px; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.14);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.hint { color: var(--muted-2); font-size: 12.5px; margin-top: 7px; }
.hint--inline { display: flex; justify-content: space-between; gap: 10px; }
.hint b { color: var(--muted); font-weight: 600; }
.hint.is-over b { color: var(--red); }

.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* --- Кнопки --------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  font: inherit; font-size: 14px; font-weight: 560;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--panel-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 660;
}
.btn--primary:hover { filter: brightness(1.05); background: linear-gradient(145deg, var(--accent), var(--accent-2)); }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--red); border-color: rgba(255, 107, 107, 0.35); background: transparent; }
.btn--danger:hover { background: rgba(255, 107, 107, 0.1); }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--link { padding: 0; border: none; background: none; color: var(--accent); cursor: pointer; font: inherit; }
.btn--link:hover { text-decoration: underline; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* --- Статусы -------------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.is-queued { color: var(--blue); background: rgba(91, 157, 255, 0.12); border-color: rgba(91, 157, 255, 0.28); }
.badge.is-running { color: var(--amber); background: rgba(255, 176, 32, 0.12); border-color: rgba(255, 176, 32, 0.3); }
.badge.is-running::before { animation: pulse 1.4s ease-in-out infinite; }
.badge.is-done { color: var(--accent); background: rgba(61, 220, 132, 0.12); border-color: rgba(61, 220, 132, 0.3); }
.badge.is-failed { color: var(--red); background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.3); }
.badge.is-blocked { color: var(--violet); background: rgba(167, 139, 250, 0.12); border-color: rgba(167, 139, 250, 0.3); }
.badge.is-canceled { color: var(--muted); background: rgba(140, 149, 168, 0.1); border-color: rgba(140, 149, 168, 0.25); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* --- Прогресс ------------------------------------------------------------- */

.progress { height: 6px; background: var(--panel-3); border-radius: 999px; overflow: hidden; }
.progress__bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: 999px;
  transition: width 0.4s ease;
}
.progress__bar.is-failed { background: linear-gradient(90deg, #b34545, var(--red)); }
.progress__bar.is-blocked { background: linear-gradient(90deg, #6d55c9, var(--violet)); }

/* --- Таблицы -------------------------------------------------------------- */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted-2); font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.016); }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .muted { color: var(--muted); }
.table .right { text-align: right; }
.table--tight td, .table--tight th { padding: 10px 12px; }

/* Подсветка только что созданной задачи: после отправки формы надо сразу
   увидеть, что она появилась, а не искать её глазами в списке. */
.row-flash { animation: flash 2.4s ease-out; }
@keyframes flash {
  0% { background: rgba(61, 220, 132, 0.16); }
  100% { background: transparent; }
}

.task-title { font-weight: 560; color: var(--text); display: block; margin-bottom: 3px; }
.task-meta { color: var(--muted-2); font-size: 12.5px; display: flex; gap: 12px; flex-wrap: wrap; }
.task-title:hover { color: var(--accent); text-decoration: none; }

/* --- Служебные сообщения -------------------------------------------------- */

.flash {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 14px;
  border: 1px solid;
}
.flash--error { background: rgba(255, 107, 107, 0.09); border-color: rgba(255, 107, 107, 0.3); color: #ffc9c9; }
.flash--info { background: rgba(91, 157, 255, 0.08); border-color: rgba(91, 157, 255, 0.28); color: #cfe0ff; }
.flash--ok { background: rgba(61, 220, 132, 0.09); border-color: rgba(61, 220, 132, 0.28); color: #c6f5d9; }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty__title { font-size: 16px; color: var(--text); margin-bottom: 6px; font-weight: 600; }

/* --- Лог задачи ----------------------------------------------------------- */

.log {
  margin: 0;
  padding: 16px 18px;
  max-height: 340px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: #b9c2d4;
  background: #0b0c0f;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}
.log__line { display: block; }
.log__line--warn { color: var(--amber); }
.log__line--err { color: var(--red); }

/* --- Страницы входа ------------------------------------------------------- */

.auth { display: grid; place-items: center; padding: 60px 20px; flex: 1; }
.auth__card { width: min(430px, 100%); }
.auth__brand { text-align: center; margin-bottom: 26px; }
.auth__brand .logo { justify-content: center; font-size: 20px; }
.auth__brand p { color: var(--muted); margin: 10px 0 0; font-size: 14px; }
.auth__foot { text-align: center; color: var(--muted-2); font-size: 13.5px; margin-top: 18px; }

/* --- Подвал --------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 30px;
  color: var(--muted-2);
  font-size: 13px;
  position: relative;
  z-index: 1;
}
.footer__inner { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.footer__spacer { flex: 1; }

/* --- Мобильный вид -------------------------------------------------------- */

@media (max-width: 820px) {
  .header__inner { height: auto; padding: 12px 0; flex-wrap: wrap; gap: 12px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .userbox__email { max-width: 130px; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 11px 12px; }
  .table--scroll { display: block; overflow-x: auto; white-space: nowrap; }
  .page-title { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
