:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --text: #121211;
  --muted: #6a6964;
  --line: #e5e4df;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --s1: #2a78d6;
  --s2: #eb6834;
  --ok: #1f9d55;
  --warn: #d99a00;
  --err: #e03e3e;
  --off: #b4b3ad;
  --run: #2a78d6;
  --mark: #fff1b8;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 4px 16px rgb(0 0 0 / 4%);
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f0f0e;
  --surface: #1a1a19;
  --surface-2: #232322;
  --text: #f0efec;
  --muted: #a3a29b;
  --line: #2e2e2c;
  --accent: #3987e5;
  --s1: #3987e5;
  --s2: #d95926;
  --ok: #2fb36a;
  --warn: #e0a100;
  --err: #ef5a5a;
  --off: #5f5e59;
  --run: #3987e5;
  --mark: #5a4a00;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 4px; }
h2 { font-size: 17px; letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 4px 0 6px; line-height: 1.35; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 28px; padding-bottom: 64px; }

/* ---------- Шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.top__inner { max-width: 1160px; margin: 0 auto; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; white-space: nowrap; font-size: 14px; }
.nav a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.nav a.is-active { color: var(--text); background: var(--surface); box-shadow: var(--shadow); font-weight: 500; }
.top__right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.top__right form { margin: 0; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.i-moon { display: none; }
[data-theme='dark'] .i-sun { display: none; }
[data-theme='dark'] .i-moon { display: block; }
.link-btn { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 6px 4px; white-space: nowrap; }
.link-btn:hover { color: var(--text); }

.banner { border-bottom: 1px solid var(--line); font-size: 14px; }
.banner .wrap { padding-top: 10px; padding-bottom: 10px; }
.banner--warn { background: color-mix(in srgb, var(--warn) 16%, var(--bg)); }
.banner--err { background: color-mix(in srgb, var(--err) 14%, var(--bg)); }
.banner--info { background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }

/* ---------- Блоки ---------- */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead p { margin: 0; }
.section { margin: 32px 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; text-transform: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.alert { background: color-mix(in srgb, var(--err) 12%, var(--surface)); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.notice { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border-radius: 10px; padding: 10px 12px; }
.legend { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.legend .lamp { margin-left: 6px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat__n { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat__l { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stat--big .stat__n { font-size: 32px; }
.stat--warn { border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); }

/* ---------- Лампочки ---------- */
.lamp { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; vertical-align: middle; background: var(--off); }
.lamp--ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent), 0 0 10px color-mix(in srgb, var(--ok) 45%, transparent); }
.lamp--err { background: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 20%, transparent), 0 0 10px color-mix(in srgb, var(--err) 45%, transparent); }
.lamp--warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }
.lamp--off { background: var(--off); }
.lamp--run { background: var(--run); animation: blink 1.1s ease-in-out infinite; box-shadow: 0 0 0 3px color-mix(in srgb, var(--run) 22%, transparent); }
@keyframes blink { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .lamp--run { animation: none; } }

/* ---------- Карточки ресурсов ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.src { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; transition: border-color 0.2s; }
.src[data-status='error'], .src[data-status='captcha'], .src[data-status='blocked'] { border-color: color-mix(in srgb, var(--err) 45%, var(--line)); }
.src[data-status='running'] { border-color: color-mix(in srgb, var(--run) 50%, var(--line)); }
.src__head { display: flex; align-items: center; gap: 10px; }
.src__title { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.src__title a { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src__label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.src__msg { margin: 0; font-size: 13.5px; color: var(--text); min-height: 2.6em; }
.src[data-status='never'] .src__msg, .src[data-status='disabled'] .src__msg, .src[data-status='no_access'] .src__msg { color: var(--muted); }
.src__foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; }
.src__foot b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Кнопки и формы ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--err); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
input, select {
  height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; min-width: 0;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
.form { padding: 20px; margin-bottom: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form label input, .form label select { color: var(--text); }
.form__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; align-items: start; }
.form__end { grid-column: 1 / -1; }
.form__row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.form__row input { flex: 1 1 180px; }
.form__row--tight { margin: 0; }
.form__row--tight input { flex: 0 1 170px; height: 30px; }
.form--inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 16px; }
.form--inline h2 { width: 100%; margin: 0; }
.hint { font-size: 12px; color: var(--muted); }
.checklist { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; font-size: 14px !important; }
.check input { height: 16px; width: 16px; accent-color: var(--accent); }

.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login .form { display: flex; flex-direction: column; gap: 14px; text-align: left; margin-top: 24px; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .msg { color: var(--muted); max-width: 520px; }
.table .pos { color: var(--ok); }
.table .neg { color: var(--text); }
.table tr.is-off { opacity: 0.5; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.actions form { margin: 0; }
.pill { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 99px; font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.pill--ok { background: color-mix(in srgb, var(--ok) 16%, transparent); }
.pill--err { background: color-mix(in srgb, var(--err) 16%, transparent); }
.pill--off { background: var(--surface-2); color: var(--muted); }

/* ---------- Упоминания ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { padding: 6px 12px; border-radius: 9px; color: var(--muted); font-size: 14px; }
.tab:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--line); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input[type='search'] { flex: 1 1 220px; }
.feed { display: flex; flex-direction: column; gap: 10px; }
.mention { padding: 14px 16px; }
.mention p { margin: 0 0 10px; color: var(--text); font-size: 14px; }
.mention--done, .mention--not_ours { opacity: 0.72; }
.mention__meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mention__actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.tag { border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; font-size: 12px; }
.tag--strong { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 20px; }

/* ---------- Аналитика ---------- */
.viz { padding: 18px 20px; margin-top: 16px; }
.viz__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.viz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.viz-grid .viz { margin-top: 16px; }
.chart { width: 100%; height: auto; display: block; margin: 8px 0; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--muted); stroke-width: 1; opacity: 0.5; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .s1 { fill: var(--s1); }
.chart .s2 { fill: var(--s2); }
.chart .hit { fill: transparent; }
.chart .col:hover .hit { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.legend-row { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.key--s1 { background: var(--s1); }
.key--s2 { background: var(--s2); }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bars li { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.bars__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars__track { height: 10px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bars__fill { display: block; height: 100%; background: var(--s1); border-radius: 4px; }
.bars__value { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 2ch; text-align: right; }
details summary { cursor: pointer; color: var(--muted); margin-top: 8px; }
.tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12.5px; padding: 6px 9px; border-radius: 8px; max-width: 280px; }

@media (max-width: 720px) {
  h1 { font-size: 24px; }
  .top__inner { gap: 12px; }
  .brand { font-size: 0; gap: 0; }
  .brand__dot { margin-right: 4px; }
  .link-btn { font-size: 0; }
  .link-btn::after { content: 'Выйти'; font-size: 13px; }
  .grid { grid-template-columns: 1fr; }
  .table .msg { min-width: 220px; }
}
