:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-soft: #475569;
  --muted: #7c8798;
  --accent: #1d4ed8;
  --accent-soft: #e8eefc;
  --navy: #12233b;
  --ok: #0f7a4d;
  --ok-soft: #e6f6ee;
  --warn: #9a5b00;
  --warn-soft: #fdf3e2;
  --err: #b4271f;
  --err-soft: #fdecea;
  --info: #1d4ed8;
  --info-soft: #eaf0fd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -16px rgba(15, 23, 42, .25);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 16px; }

code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  background: #eef2f7;
  border-radius: 5px;
  padding: 1px 5px;
}

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }

/* ---- шапка ---- */
.topbar {
  background: var(--navy);
  color: #e6edf7;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
.topbar__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 26px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, #3b82f6, #1d4ed8);
  color: #fff;
  border-radius: 9px;
  font-weight: 800;
  font-size: 15px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3);
}
.brand__mark--lg { width: 46px; height: 46px; font-size: 21px; border-radius: 12px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__text strong { font-size: 15px; letter-spacing: .2px; }
.brand__text small { font-size: 11px; color: #93a7c4; letter-spacing: .3px; }

.nav { display: flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }
.nav a {
  color: #b9c9dd;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .13); color: #fff; }

.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user { color: #cdd9e8; font-size: 13px; }
.user__logout { color: #93a7c4; font-size: 12.5px; }
.user__logout:hover { color: #fff; }

/* ---- контейнер ---- */
.container {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 24px 48px;
  flex: 1;
}

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 24px;
  text-align: center;
  color: var(--text-soft);
  font-size: 12.5px;
}
.footer__muted { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

/* ---- заголовок страницы ---- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head p { margin: 4px 0 0; font-size: 13.5px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* ---- всплывающие сообщения ---- */
.flash {
  max-width: 1320px;
  margin: 14px auto 0;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  border: 1px solid;
}
.flash--ok { background: var(--ok-soft); border-color: #bfe6d2; color: var(--ok); }
.flash--err { background: var(--err-soft); border-color: #f5c9c4; color: var(--err); }

.alert {
  padding: 13px 16px;
  border-radius: 11px;
  border: 1px solid;
  margin-bottom: 18px;
  font-size: 13.5px;
}
.alert--warn { background: var(--warn-soft); border-color: #f0dbb6; color: #6d4100; }
.alert--info { background: var(--info-soft); border-color: #cfdcf8; color: #1e3a8a; }

/* ---- сетки ---- */
.grid { display: grid; gap: 18px; align-items: start; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* ---- карточки ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card--muted { background: var(--surface-muted); }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card__actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ---- статистика ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat--warn { border-color: #f0dbb6; background: linear-gradient(180deg, #fffdf8, #fffaf0); }
.stat__label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat__value { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; }
.stat__hint { font-size: 12px; color: var(--text-soft); }
.stat__hint--err { color: var(--err); }

/* ---- таблицы ---- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding: 0 12px 9px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid #eef1f6;
  vertical-align: top;
}
.table tbody tr:hover { background: #fafbfd; }
.table--compact td { padding: 8px 12px; }
.table--findings td { font-size: 13px; }
.table td:first-child, .table th:first-child { padding-left: 0; }
.table td:last-child, .table th:last-child { padding-right: 0; }
.row--new { background: #f7fbff; }
.row--new td:first-child { box-shadow: inset 3px 0 0 var(--accent); padding-left: 10px; }

/* ---- бейджи и статусы ---- */
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  background: #eef2f7;
  color: var(--text-soft);
  vertical-align: middle;
}
.badge--accent { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge--warn { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.badge--muted { background: #eef2f7; color: var(--muted); }

.status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.status--ok { background: var(--ok-soft); color: var(--ok); }
.status--warn { background: var(--warn-soft); color: var(--warn); }
.status--err { background: var(--err-soft); color: var(--err); }
.status--info { background: var(--info-soft); color: var(--info); }
.status--muted { background: #eef2f7; color: var(--text-soft); }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.chip--court { background: #eaf0fd; color: #1e40af; }
.chip--fssp { background: #f4ecfd; color: #6b21a8; }

/* ---- кнопки ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 15px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(29, 78, 216, .3); }
.btn--primary:hover { background: #1740b8; }
.btn--ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-muted); color: var(--text); }
.btn--danger { background: var(--surface); border-color: #f0c7c2; color: var(--err); }
.btn--danger:hover { background: var(--err-soft); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn--xs { padding: 4px 9px; font-size: 12px; }
.btn--block { width: 100%; }

/* ---- формы ---- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form--row { flex-direction: row; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.form__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.field > span { color: var(--text-soft); font-weight: 550; }
.field > span small { font-weight: 400; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 9px 11px;
  width: 100%;
  transition: border-color .14s ease, box-shadow .14s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.input--sm { padding: 6px 9px; font-size: 12.5px; width: auto; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }
.checkbox--inline { padding-bottom: 9px; }

/* ---- списки ---- */
.source-list { list-style: none; margin: 0; padding: 0; }
.source-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #eef1f6;
}
.source-list li:last-child { border-bottom: 0; }
.source-list__main { display: flex; flex-direction: column; }
.source-list__title { font-weight: 550; font-size: 13.5px; }
.source-list__meta { font-size: 12px; color: var(--muted); }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.feed li { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.feed .muted { font-size: 12px; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 14px 0 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.empty { text-align: center; padding: 28px 12px; color: var(--text-soft); }
.empty p { margin: 0 0 12px; }

/* ---- капча ---- */
.captcha {
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  margin-bottom: 14px;
}
.captcha img { border-radius: 6px; background: #fff; }
.captcha + form .input, .form--row .input { flex: 1 1 220px; }
.form--row .field { flex: 1 1 180px; }

/* ---- вход ---- */
.login-wrap { display: grid; place-items: center; min-height: 62vh; }
.login-card { width: 100%; max-width: 380px; padding: 30px 28px; }
.login-card__head { text-align: center; margin-bottom: 22px; }
.login-card__head h1 { font-size: 21px; margin: 12px 0 4px; }
.login-card__head p { margin: 0; font-size: 12.5px; }
.login-card__hint { font-size: 11.5px; margin: 16px 0 0; text-align: center; }

/* ---- пагинация ---- */
.pager { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .grid--2 { grid-template-columns: 1fr; }
  .nav { display: none; }
  .container { padding: 18px 14px 36px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}
