/* ==========================================================================
   SEO Duck - общая база стилей: токены, типографика, кнопки, карточки, поля,
   статусы, таблицы, баннеры. Её грузят и кабинет (перед app.css), и лендинг
   со страницами входа и legal (перед site.css). Правила каркаса кабинета -
   в app.css, страниц сайта - в site.css; сюда только то, что нужно обоим.
   ========================================================================== */

/* ---------- Токены ---------- */
:root {
  /* бренд */
  --brand-900: #1B2668;
  --brand-700: #2B3A8F;   /* основной цвет: кнопки, активные пункты, ссылки */
  --brand-600: #3549A6;   /* hover */
  --brand-100: #E4E8F7;
  --brand-50:  #F2F4FB;

  --accent-500: #F0921E;  /* оранжевый - только акценты, не кнопки */
  --accent-600: #D97D0A;
  --accent-50:  #FEF4E6;

  /* текст */
  --ink:   #161B2E;
  --ink-2: #4A5064;
  --ink-3: #6B7285;       /* подписи, вторичный текст (4.8:1 на белом) */
  --ink-4: #9AA0B1;       /* плейсхолдеры, иконки */

  /* поверхности */
  --bg:       #F5F6FA;
  --surface:  #FFFFFF;
  --line:     #E5E8EF;
  --line-2:   #EFF1F6;

  /* статусы */
  --ok:      #177A3E;  --ok-bg:   #E7F5EC;  --ok-dot:  #22A355;
  --bad:     #C13A3A;  --bad-bg:  #FCECEC;
  --warn:    #9A5B00;  --warn-bg: #FFF3DE;
  --idle:    #6B7285;  --idle-bg: #EFF1F6;

  /* диапазоны позиций: зелёный - хорошо, оранжевый - плохо, серый - не найден.
     Соседние цвета проверены на различимость, в т.ч. при дальтонизме. */
  --pos-top3:  #146C43;  /* 1-3 */
  --pos-top10: #34A36A;  /* 4-10 */
  --pos-top30: #E9A42C;  /* 11-30 */
  --pos-top50: #E0663F;  /* 31-50 */
  --pos-out:   #D5DAE3;  /* дальше 50 / не найден */

  /* очередь: судьба каждого клика в пачке. Всегда с подписью, не только цветом. */
  --q-done:     #1E9A50;  /* выполнен */
  --q-notfound: #E9A42C;  /* сайт не найден в выдаче */
  --q-error:    #C93636;  /* ошибка */
  --q-cancel:   #C5CAD5;  /* отменён */
  --q-run:      #3549A6;  /* выполняется */
  --q-wait:     #A9B6E6;  /* ждёт в очереди */

  /* форма */
  --r-sm: 8px;
  --r:    10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(22, 27, 46, .05);
  --shadow:    0 1px 2px rgba(22, 27, 46, .04), 0 2px 8px rgba(22, 27, 46, .04);
  --shadow-pop: 0 8px 28px rgba(22, 27, 46, .14), 0 1px 3px rgba(22, 27, 46, .08);

  --sidebar-w: 248px;
  --topbar-h: 64px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-600); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn svg { width: 16px; height: 16px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 7px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-primary { background: var(--brand-700); color: #fff; }
.btn-primary:hover { background: var(--brand-600); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: var(--bg); color: var(--ink); border-color: #D5D9E3; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-pill { border-radius: 999px; }

.link-arrow { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 13.5px; }
.link-arrow svg { width: 16px; height: 16px; transition: transform .12s; }
.link-arrow:hover svg { transform: translateX(2px); }
/* ---------- Карточка ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 24px; }
.card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 18px 24px 0;
}
.card-head h2 { font-size: 16px; }
.card-head .sub { color: var(--ink-3); font-size: 13px; }
.card-head .sp { flex: 1; }
/* ---------- Статус ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.is-on   { background: var(--ok-bg);   color: var(--ok); }
.status.is-on::before { background: var(--ok-dot); box-shadow: 0 0 0 3px rgba(34, 163, 85, .18); }
.status.is-off  { background: var(--idle-bg); color: var(--idle); }
.status.is-warn { background: var(--warn-bg); color: var(--warn); }
.status.is-bad  { background: var(--bad-bg);  color: var(--bad); }
.status.is-run  { background: var(--brand-50); color: var(--brand-700); }
.status.is-run::before { animation: pulse 1.6s ease-in-out infinite; }
.status.is-wait { background: var(--brand-50); color: var(--brand-600); }
.status.is-wait::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.is-on { background: var(--ok-dot); }
.dot.is-off { background: var(--ink-4); }

/* ---------- Изменение (дельта) ---------- */
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.delta svg { width: 14px; height: 14px; }
.delta.up   { color: var(--ok); }
.delta.down { color: var(--bad); }

/* ---------- Сегментированный переключатель ---------- */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
}
.seg button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-3); font-size: 13px; font-weight: 500; cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ---------- Прогресс ---------- */
.meter { height: 6px; border-radius: 999px; background: var(--brand-100); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--brand-700); }
/* ---------- Таблица ---------- */
.table-wrap { position: relative; overflow-x: auto; } /* relative - чтобы скрытые подписи .sr-only не вылезали за прокрутку */
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  color: var(--ink-3); font-size: 12.5px; font-weight: 500; text-align: left; white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FAFBFD; }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child,  .table td:last-child  { padding-right: 24px; }
.table .r { text-align: right; }
.table td.r { font-variant-numeric: tabular-nums; }
/* ---------- Пустое состояние ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 24px; text-align: center; }
.empty .ic {
  width: 44px; height: 44px; margin-bottom: 6px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-50); color: var(--brand-700);
}
.empty .ic svg { width: 22px; height: 22px; }
.empty h3 { font-size: 15px; }
.empty p { max-width: 380px; color: var(--ink-3); font-size: 13.5px; }
.empty .btn { margin-top: 10px; }

/* ---------- Баннер ---------- */
.banner {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 12px 12px 16px; margin-bottom: 24px;
  border: 1px solid #F8DDB5; border-radius: var(--r);
  background: var(--accent-50);
}
.banner .ic {
  width: 32px; height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: var(--accent-600);
}
.banner .ic svg { width: 18px; height: 18px; }
.banner .txt { flex: 1; color: var(--ink-2); }
.banner .txt b { color: var(--ink); font-weight: 600; }
.banner .close { width: 32px; height: 32px; }
.banner[data-flash] { transition: opacity .25s; }
.banner[data-flash].is-leaving { opacity: 0; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #A83131; color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--bad); border-color: #F1C9C9; }
.btn-danger-ghost:hover { background: var(--bad-bg); color: var(--bad); }
.btn[disabled] { opacity: .5; pointer-events: none; }
/* ---------- Теги ---------- */
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px;
  background: var(--line-2); color: var(--ink-2); font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.tag.is-brand { background: var(--brand-50); color: var(--brand-700); }
/* ---------- Поля ---------- */
.field + .field { margin-top: 20px; }
.label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.label .opt { font-weight: 400; color: var(--ink-3); }
.hint { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); }
.hint b { color: var(--ink-2); font-weight: 600; }
.field-error { margin-top: 6px; font-size: 12.5px; color: var(--bad); }
.input, .select, .textarea {
  display: block; width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 132px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { border-color: #D2D6E0; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(53, 73, 166, .15); }
.input:disabled { background: var(--bg); color: var(--ink-3); cursor: not-allowed; }
.input.is-invalid, .textarea.is-invalid { border-color: var(--bad); }
.input.sm { height: 32px; padding: 0 8px; font-size: 13px; }
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239AA0B1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.select.sm { height: 32px; font-size: 13px; padding-right: 30px; background-position: right 8px center; }
.input-group { display: flex; }
.input-group .addon {
  display: flex; align-items: center; padding: 0 12px; flex-shrink: 0;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-3); font-size: 14px;
}
.input-group .addon:first-child { border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .addon:last-child { border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input-group .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row2 > .field + .field { margin-top: 0; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--brand-700); cursor: pointer; }
.check-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check-row input { margin-top: 2px; }
.check-row b { display: block; font-weight: 600; font-size: 14px; }

.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--ink-4); pointer-events: none; }
.search .input { padding-left: 36px; }

/* ---------- Переключатель вкл/выкл ---------- */
.switch { position: relative; display: inline-flex; width: 36px; height: 20px; flex-shrink: 0; vertical-align: middle; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch span { width: 100%; height: 100%; border-radius: 999px; background: #CDD2DD; transition: background .15s; }
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(22, 27, 46, .25); transition: transform .15s;
}
.switch input:checked + span { background: var(--ok-dot); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand-600); outline-offset: 2px; }
/* цена действия прямо на кнопке: «Снять позиции · 1 клик» */
.btn .cost { margin-left: 2px; padding-left: 8px; border-left: 1px solid var(--line); color: var(--ink-3); font-weight: 500; }
.btn-primary .cost { border-left-color: rgba(255, 255, 255, .3); color: rgba(255, 255, 255, .8); }

/* ---------- Подсказка-плашка ---------- */
.note { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--brand-50); color: var(--ink-2); font-size: 13px; }
.note svg { width: 16px; height: 16px; margin-top: 2px; color: var(--brand-700); }
.note b { color: var(--ink); font-weight: 600; }
/* Чипы-пресеты: суммы пополнения, фильтры истории */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.chip:hover { border-color: #D2D6E0; color: var(--ink); }
.chip.is-on, .chip[aria-pressed="true"], .chip[aria-current="page"] { border-color: var(--brand-700); background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.chip small { color: var(--ink-3); font-weight: 500; }
.chip.is-on small { color: var(--brand-600); }
/* Деньги в таблицах: приход зелёный, расход обычный */
.money { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.money.in { color: var(--ok); }
.money.out { color: var(--ink-2); }
/* Пейджер с номерами страниц (история операций, приглашённые) */
.pager-pages { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.pager-pages a, .pager-pages span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px;
  border-radius: 7px; color: var(--ink-2); font-size: 13px; font-weight: 500;
}
.pager-pages a:hover { background: var(--bg); color: var(--ink); }
.pager-pages .is-current { background: var(--brand-700); color: #fff; font-weight: 600; }
.pager-pages .is-disabled { color: var(--ink-4); }
.pager-pages svg { width: 16px; height: 16px; }

/* ---------- Общее для кабинета и сайта: строки «ключ - значение», полоска позиций, три шага ---------- */
/* ---------- Баланс ---------- */
.bal-main { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; }
.bal-main .unit { font-size: 14px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.bal-note { margin-top: 6px; color: var(--ink-3); font-size: 13px; }
.bal-rows { margin: 16px 0; border-top: 1px solid var(--line-2); }
.bal-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.bal-row .k { color: var(--ink-3); }
.bal-row .v { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.bal-row .tag { padding: 1px 7px; border-radius: 6px; background: var(--accent-50); color: var(--accent-600); font-size: 12px; font-weight: 600; }
/* ---------- Мини-распределение позиций (список проектов, шапка проекта) ---------- */
.posbar { display: flex; gap: 2px; height: 8px; border-radius: 3px; overflow: hidden; background: var(--line-2); }
.posbar i { background: var(--c); }
.pos-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex-shrink: 0; }
/* Три шага «как это работает» */
.steps3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.steps3 > div { padding: 20px 24px; }
.steps3 > div + div { border-left: 1px solid var(--line-2); }
.steps3 .n {
  width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-50); color: var(--brand-700); font-size: 13px; font-weight: 700;
}
.steps3 b { display: block; margin-top: 10px; font-size: 14px; font-weight: 600; }
.steps3 p { margin-top: 4px; color: var(--ink-3); font-size: 13px; }

/* ---------- Круглая кнопка-иконка ---------- */
.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-3); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot {
  position: absolute; top: 9px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-500); box-shadow: 0 0 0 2px var(--surface);
}
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
