:root {
  color-scheme: light dark;
  --bg: #f3f5f8;
  --surface: #fff;
  --text: #17212b;
  --muted: #5c6b7a;
  --border: #d8dee6;
  --accent: #1456b8;
  --accent-text: #fff;
  --badge: #e8eef8;
  --warning-bg: #fff4d6;
  --warning-text: #6b4c00;
  --danger-bg: #fde8e8;
  --danger-text: #8a1c1c;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151c;
    --surface: #161f29;
    --text: #e6edf3;
    --muted: #94a3b8;
    --border: #2a3644;
    --accent: #6ea8fe;
    --accent-text: #08121e;
    --badge: #1e2c3c;
    --warning-bg: #3a2f16;
    --warning-text: #f6d98a;
    --danger-bg: #3a1f1f;
    --danger-text: #ffb4b4;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { color: var(--text); font-size: 18px; font-weight: 650; }
.brand:hover, .button:hover { text-decoration: none; }
.nav { display: flex; gap: 18px; }
.nav a, .link-button { color: var(--muted); }
.nav a:hover, .link-button:hover { color: var(--text); }
.logout { margin-left: auto; }
.link-button {
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
}
.link-button:hover { text-decoration: underline; }
.page { max-width: 1180px; margin: 0 auto; padding: 26px 20px 56px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1 { margin: 0 0 4px; font-size: 26px; line-height: 1.2; }
h2 { margin: 0 0 12px; font-size: 18px; }
.muted { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button {
  display: inline-block;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.button.secondary { background: var(--badge); color: var(--accent); }

.card {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 420px; margin: 40px auto 0; }
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.stat-label { display: block; color: var(--muted); font-size: 13px; }
.stat-value {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.block { margin-top: 26px; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--badge) 55%, transparent); }
td { overflow-wrap: anywhere; }

.events-table { table-layout: fixed; }
.events-table th, .events-table td { padding: 10px 8px; }
.events-table .cell-title { overflow-wrap: break-word; word-break: normal; }
.events-table .cell-type,
.events-table .cell-cve,
.events-table .cell-lang,
.events-table .cell-coverage {
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.events-table .cell-type,
.events-table .cell-lang,
.events-table .cell-coverage { font-size: 14px; }
.events-table .cell-cve {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}
.event-title { color: var(--accent); font-weight: 600; }
.event-title--plain { cursor: help; }
.event-score {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--badge);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: 1px;
}
.excluded-wrap { max-height: 60vh; overflow: auto; }
.excluded-table .cell-title { overflow-wrap: break-word; word-break: normal; }
.excluded-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--badge);
  border-radius: 999px;
  font-size: 13px;
}
.pager { display: flex; align-items: center; gap: 16px; margin-top: 14px; color: var(--muted); }

.form { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.form label { font-weight: 600; }
.form input, .form select {
  width: 100%;
  max-width: 420px;
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
.form button {
  align-self: flex-start;
  margin-top: 8px;
  padding: 9px 16px;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: var(--accent-text);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.field-error { color: var(--danger-text); font-size: 13px; }
.error-box {
  padding: 10px 12px;
  background: var(--danger-bg);
  border-radius: 8px;
  color: var(--danger-text);
}
.error-box p, .footer p { margin: 0; }

.notice { margin: 16px 0; padding: 12px 14px; background: var(--badge); border-radius: 8px; }
.notice.warning { background: var(--warning-bg); color: var(--warning-text); }
.recipients { margin: 0 0 16px; padding-left: 20px; }
.models {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 18px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.models dt { color: var(--muted); }
.models dd, .models ul { margin: 0; }
.models ul { padding-left: 18px; }
.messages { margin: 0 0 18px; padding: 0; list-style: none; }
.message { padding: 10px 14px; background: var(--badge); border-radius: 8px; }
.message.error { background: var(--danger-bg); color: var(--danger-text); }
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .page { padding: 20px 14px 40px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 22px; }
}

@media (max-width: 720px) {
  .responsive-table { table-layout: auto; }
  .responsive-table colgroup,
  .responsive-table thead { display: none; }
  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td { display: block; width: 100%; }
  .responsive-table tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .responsive-table tbody tr:last-child { border-bottom: 0; }
  .responsive-table td { padding: 0; border: 0; }
  .responsive-table .cell-title { margin-bottom: 4px; }
  .responsive-table .cell-type,
  .responsive-table .cell-cve,
  .responsive-table .cell-lang,
  .responsive-table .cell-coverage,
  .responsive-table .cell-source,
  .responsive-table .cell-reason {
    display: inline;
    margin-right: 10px;
    overflow: visible;
    color: var(--muted);
    font-size: 13px;
    white-space: normal;
  }
  .responsive-table .cell-type::before,
  .responsive-table .cell-cve::before,
  .responsive-table .cell-lang::before,
  .responsive-table .cell-coverage::before,
  .responsive-table .cell-source::before,
  .responsive-table .cell-reason::before {
    content: attr(data-label) ": ";
    color: var(--muted);
  }
}

/* WHY: заголовок в таблице событий обрезается многоточием, а колонка «Язык» была уже
   самого длинного значения («португальский»). Расширили колонку и разрешили заголовку
   две строки - так видно суть и не рвётся слово. SOURCE: визуальная приёмка 27.11.2026. */
.events-table .cell-title .event-title,
.events-table .cell-title .event-title--plain {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.events-table .col-lang, .events-table td:nth-child(4) { white-space: nowrap; }
