/* SEO Panel — стили. Тёмная тема по умолчанию, светлая — через [data-theme="light"]. */

:root[data-theme="dark"] {
  --bg: #0d1014;
  --surface: #151a21;
  --card: #171d26;
  --card-2: #1c232e;
  --line: #262d38;
  --line-soft: #1f2630;
  --text: #e7ebf2;
  --text-2: #aeb6c4;
  --muted: #7b8494;
  --accent: #3b82f6;
  --accent-bg: rgba(59, 130, 246, 0.14);
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.14);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.13);
  --warning: #fbbf24;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
:root[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --card: #ffffff;
  --card-2: #f4f6f8;
  --line: #e4e7ec;
  --line-soft: #eceef1;
  --text: #131720;
  --text-2: #48505e;
  --muted: #8a919e;
  --accent: #2563eb;
  --accent-bg: rgba(37, 99, 235, 0.09);
  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.1);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --warning: #d97706;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

.ic { width: 18px; height: 18px; display: inline-block; vertical-align: middle; flex: none; }
.ic-mut { color: var(--muted); }
.ic-danger { color: var(--danger); }

/* ── Кнопки / инпуты ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  padding: 0 14px; height: 38px; border-radius: 9px; cursor: pointer;
  font-size: 13.5px; font-weight: 500; white-space: nowrap; transition: .13s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-primary:disabled { opacity: .5; cursor: default; filter: none; transform: none; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; height: 40px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text-2);
  border-radius: 9px; cursor: pointer; transition: .13s;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }

input {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  height: 38px; padding: 0 12px; border-radius: 9px; font-size: 14px; font-family: inherit; width: 100%;
}
input::placeholder { color: var(--muted); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

.badge { font-size: 11.5px; padding: 3px 10px; border-radius: 20px; border: 1px solid var(--line); color: var(--text-2); white-space: nowrap; }
.badge.organic, .badge.footprint { color: var(--accent); border-color: transparent; background: var(--accent-bg); }
.badge.done { color: var(--success); border-color: transparent; background: var(--success-bg); }
.badge.error { color: var(--danger); border-color: transparent; background: var(--danger-bg); }

.spinner {
  width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Экран входа ──────────────────────────────────────────────── */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box {
  width: 350px; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 30px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.login-logo {
  width: 46px; height: 46px; border-radius: 12px; background: var(--accent-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
}
.login-logo .ic { width: 24px; height: 24px; }
.login-box h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 12.5px; color: var(--text-2); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }

/* ── Топбар ───────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 22px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.brand-mark .ic { width: 20px; height: 20px; }
.brand-title { font-size: 15px; font-weight: 600; line-height: 1.2; }
.brand-host { font-size: 11.5px; color: var(--muted); }
.search-row { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.search-input { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.search-input .ic { position: absolute; left: 11px; pointer-events: none; }
.search-input input { padding-left: 36px; }
.depth { display: flex; align-items: center; gap: 6px; flex: none; }
.depth label { font-size: 12px; color: var(--muted); }
.depth input { width: 62px; text-align: center; padding: 0 6px; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.serp-indicator { font-size: 12px; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.serp-indicator b { color: var(--text-2); font-weight: 600; }
.serp-indicator.low b { color: var(--warning); }

/* ── Основной контейнер / карточки ────────────────────────────── */
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 22px 60px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 14px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-head h2 .ic { width: 16px; height: 16px; }
.count { color: var(--muted); font-weight: 400; margin-left: 2px; }

/* ── Карточка активного поиска ────────────────────────────────── */
.job-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.job-title { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 9px; min-width: 0; }
.job-title #job-seed { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phase-bar { display: flex; gap: 6px; margin-bottom: 8px; }
.phase-seg { flex: 1; height: 6px; border-radius: 4px; background: var(--line); transition: background .3s; }
.phase-seg.active { background: var(--accent); }
.phase-seg.filled { background: var(--success); }
.phase-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 16px; }
.phase-labels span.active { color: var(--accent); }
.phase-labels span.filled { color: var(--success); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--card-2); border-radius: 10px; padding: 10px 13px; }
.kpi b { font-size: 22px; font-weight: 600; display: block; line-height: 1.15; }
.kpi b.accent { color: var(--accent); }
.kpi b span { font-size: 13px; color: var(--muted); font-weight: 400; }
.kpi > span { font-size: 12px; color: var(--text-2); }

.job-sites { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; }
.site-row {
  display: flex; align-items: center; gap: 11px; background: var(--card-2);
  border: 1px solid transparent; border-radius: 9px; padding: 8px 12px; font-size: 13px;
}
.site-row.processing { border-color: var(--accent); }
.site-row.pending { opacity: .5; }
.site-row .pos { width: 34px; color: var(--muted); font-size: 12px; flex: none; }
.site-row .dom { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-row .st { font-size: 12px; display: flex; align-items: center; gap: 5px; flex: none; }
.site-row .st.done { color: var(--success); }
.site-row .st.processing { color: var(--accent); }
.site-row .st.error { color: var(--danger); }
.site-row .st.pending { color: var(--muted); }
.site-row .st .ic { width: 14px; height: 14px; }

/* ── Таблица доноров ──────────────────────────────────────────── */
.card-head-tools { display: flex; gap: 8px; }
.filter-input { position: relative; display: flex; align-items: center; width: 260px; max-width: 46vw; }
.filter-input .ic { position: absolute; left: 10px; pointer-events: none; }
.filter-input input { padding-left: 34px; height: 34px; }
.table-wrap { overflow-x: auto; }
.donors-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.donors-table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .4px; padding: 0 10px 9px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.donors-table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.donors-table tbody tr:last-child td, .donors-table tr:last-child td { border-bottom: none; }
.donors-table tr:hover td { background: var(--card-2); }
.ta-c { text-align: center; } .ta-r { text-align: right; }
.donor-domain { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); text-decoration: none; font-weight: 500; }
.donor-domain:hover { text-decoration: underline; }
.donor-domain .ic { width: 13px; height: 13px; opacity: 0; transition: .12s; }
.donors-table tr:hover .donor-domain .ic { opacity: .6; }
.uc { display: inline-block; min-width: 26px; text-align: center; background: var(--accent-bg); color: var(--accent); border-radius: 20px; padding: 2px 9px; font-weight: 600; font-size: 12.5px; }
.xsites { color: var(--text-2); font-size: 12.5px; }
.xsites .pos-tag { color: var(--muted); }
.donor-minus { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; display: inline-flex; }
.donor-minus:hover { color: var(--danger); background: var(--danger-bg); }
.donor-minus .ic { width: 17px; height: 17px; }
tr.excluded td { opacity: .42; }
tr.excluded .donor-domain { color: var(--muted); text-decoration: line-through; }
.restore-link { color: var(--success); cursor: pointer; font-size: 12.5px; }
.restore-link:hover { text-decoration: underline; }
.empty { color: var(--muted); text-align: center; padding: 22px; font-size: 13px; }

/* ── Низ: минус-листы + история ───────────────────────────────── */
.bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ex-block { margin-bottom: 16px; }
.ex-block:last-child { margin-bottom: 0; }
.ex-label { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.ex-add { display: flex; gap: 6px; margin-bottom: 10px; }
.ex-add input { height: 32px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--danger-bg);
  color: var(--danger); padding: 4px 6px 4px 10px; border-radius: 20px;
}
.chip button { background: none; border: none; color: inherit; cursor: pointer; display: inline-flex; padding: 1px; border-radius: 50%; opacity: .7; }
.chip button:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
.chip button .ic { width: 13px; height: 13px; }
.chips-empty { font-size: 12px; color: var(--muted); }

.history-list { display: flex; flex-direction: column; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.history-row:last-child { border-bottom: none; }
.history-main { min-width: 0; }
.history-seed { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.history-repeat { color: var(--accent); cursor: pointer; font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; flex: none; }
.history-repeat:hover { text-decoration: underline; }
.history-repeat .ic { width: 14px; height: 14px; }

.boot { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.boot .spinner { width: 26px; height: 26px; border-width: 3px; }

/* ── Адаптив ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .search-row { order: 3; flex-basis: 100%; }
  .bottom-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
