/* Veritium · мониторинг. Стиль взят из знака: почти чёрный, белый, сталь.
   Красный и голубой - только эффект «сбоя»; цвета состояний свои и больше ни для чего. */

:root {
  --bg: #050506;
  --surface: #0b0b0d;
  --surface-2: #111114;
  --border: #1d1d22;
  --border-strong: #2a2a31;
  --text: #f4f4f6;
  --muted: #8e8e94;
  --faint: #5a5a61;
  --warn: #ffb020;
  --warn-soft: rgba(255, 176, 32, 0.12);
  --crit: #ff3b4e;
  --crit-soft: rgba(255, 59, 78, 0.12);
  --glitch-r: #ff2a4f;
  --glitch-c: #28e7ff;
  --line: #f4f4f6;
  --line-2: #8e8e94;
  --grid: #19191d;
  --mark-tile: transparent;
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f2f2f4;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --border: #e1e1e6;
  --border-strong: #cfcfd6;
  --text: #0b0b0d;
  --muted: #5d5d64;
  --faint: #9a9aa1;
  --warn: #a86300;
  --warn-soft: rgba(168, 99, 0, 0.1);
  --crit: #d01c33;
  --crit-soft: rgba(208, 28, 51, 0.08);
  --line: #0b0b0d;
  --line-2: #8e8e94;
  --grid: #ececf0;
  --mark-tile: #050506;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Строки развёртки - как на знаке. Только в тёмной теме и почти незаметно. */
:root:not([data-theme="light"]) body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px);
  z-index: 50;
}

a { color: inherit; }
button { font: inherit; color: inherit; }

.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- Шапка ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 10px;
  background: var(--mark-tile);
  display: grid;
  place-items: center;
  padding: 3px;
}
.brand-name { font-family: var(--mono); font-weight: 700; letter-spacing: 0.22em; font-size: 14px; }
.brand-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }

.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn[aria-pressed="true"] { color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Раскладка ---------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

section { margin-top: 32px; }
.sec-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.sec-title small { font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--faint); }

/* ---------- Главная строка: всё ли в порядке ---------- */
.hero { margin-top: 8px; }
.hero-state {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(26px, 6vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.hero-sub { margin-top: 8px; color: var(--muted); font-size: 14px; }
.hero.is-down .hero-state { color: var(--crit); }
.hero.is-warn .hero-state { color: var(--warn); }

/* ---------- Карточки сайтов ---------- */
.sites {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 14px;
}

.card, .site {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.site { padding: 16px 16px 14px; position: relative; overflow: hidden; }
.site.is-down { border-color: color-mix(in srgb, var(--crit) 55%, var(--border)); background: linear-gradient(var(--crit-soft), var(--crit-soft)), var(--surface); }
.site.is-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }

.site-head { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: start; }
.site-name { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; position: relative; }
.site-host { grid-column: 1; font-family: var(--mono); font-size: 12px; color: var(--muted); text-decoration: none; }
.site-host:hover { color: var(--text); }
.site-ms { grid-column: 2; grid-row: 1 / span 2; text-align: right; }
.site-ms b { font-family: var(--mono); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.site-ms span { color: var(--muted); font-size: 12px; margin-left: 2px; }
.site-ms .when { display: block; font-size: 11px; color: var(--faint); margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.site.is-warn .badge { color: var(--warn); }
.site.is-warn .badge i { background: var(--warn); }
.site.is-down .badge { color: var(--crit); }
.site.is-down .badge i { background: var(--crit); box-shadow: 0 0 0 4px var(--crit-soft); }

.site-alerts { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.site-alerts li {
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--text);
}
.site-alerts li.crit { background: var(--crit-soft); }
.site-alerts li b { font-weight: 600; }

/* ---------- Графики ---------- */
.chart { position: relative; margin-top: 14px; height: 64px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .l1 { fill: none; stroke: var(--line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .l2 { fill: none; stroke: var(--line-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .fail { fill: var(--crit); opacity: 0.55; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .dot { fill: var(--line); stroke: var(--surface); stroke-width: 2; }
.chart .dot2 { fill: var(--line-2); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  margin-top: 4px;
}
.chart-empty {
  height: 100%;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--faint);
  font-size: 12px;
}

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 2px; border-radius: 1px; background: var(--line); }
.legend i.l2 { background: var(--line-2); }

.tip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.tip b { font-weight: 600; }
.tip .crit { color: var(--crit); }

/* ---------- Цифры под графиком ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 10px;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.stats div { min-width: 0; }
.stats dt { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats dd { margin: 2px 0 0; font-family: var(--mono); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats dd small { font-size: 11px; color: var(--muted); font-weight: 400; }
.stats dd.warn { color: var(--warn); }
.stats dd.crit { color: var(--crit); }
.stats dd.dim { color: var(--faint); font-weight: 400; }

/* ---------- Машина заведения ---------- */
.machine { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.machine-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; }
.machine-head b { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.machine-head .dim { color: var(--faint); font-size: 12px; }
.machine-head .warn { color: var(--warn); font-size: 12px; }
.machine-stats { border-top: 0; padding-top: 0; margin-top: 10px; }
.cmd-status { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.cmd-status.crit { color: var(--crit); }
.restart-btn { margin-top: 12px; width: 100%; }

.dlg {
  width: min(400px, calc(100vw - 32px));
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 20px;
}
.dlg::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(2px); }
.dlg h3 { margin: 0 0 8px; font-size: 17px; }
.dlg p { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.dlg input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: 15px var(--mono);
}
.dlg .err { min-height: 18px; font-size: 13px; color: var(--crit); margin: 6px 0 8px; }
.dlg .row { display: flex; gap: 8px; }
.btn.danger { background: var(--crit); border-color: var(--crit); color: #fff; }

/* ---------- Сервер ---------- */
.host { padding: 16px; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.meter-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.meter-value { font-family: var(--mono); font-size: 22px; font-weight: 600; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.meter-value small { font-size: 12px; color: var(--muted); font-weight: 400; }
.bar { height: 4px; border-radius: 2px; background: var(--grid); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 2px; background: var(--line); }
.bar.warn > i { background: var(--warn); }
.bar.crit > i { background: var(--crit); }

/* ---------- Ленты событий и входов ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 4px 12px;
  align-items: baseline;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.feed li:last-child { border-bottom: 0; }
.feed time { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.feed .what b { font-weight: 600; }
.feed .what small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.feed .tag {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  white-space: nowrap;
}
.feed .tag.crit { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 45%, transparent); }
.feed .tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.feed .tag.ok { color: var(--text); }
.feed .tag.live { color: var(--bg); background: var(--crit); border-color: var(--crit); }
.feed-empty { padding: 18px 14px; color: var(--faint); font-size: 13px; }
.note { margin: -4px 0 12px; font-size: 13px; color: var(--faint); }

/* ---------- Журнал сайтов ---------- */
.online { margin: 0 0 12px; font-size: 13px; line-height: 1.6; }
.online.dim, .online .dim { color: var(--faint); }
.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
  margin-right: 8px;
  vertical-align: 1px;
}
.audit-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.chip {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.audit-site {
  min-height: 34px;
  margin-left: auto;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.audit-feed li { grid-template-columns: 92px 1fr; }
.audit-feed .who-sub { color: var(--muted); font-family: var(--mono); font-size: 12px; font-weight: 400; }
.audit-feed .warn { color: var(--warn); }
.audit-feed .crit { color: var(--crit); }
.audit-feed .export { font-weight: 600; }
@media (max-width: 560px) {
  .audit-feed li { grid-template-columns: 1fr; }
  .audit-site { margin-left: 0; }
}
@media (pointer: coarse) {
  .chip, .audit-site { min-height: 44px; }
}
.more {
  display: block;
  width: 100%;
  padding: 10px;
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.more:hover { color: var(--text); }

/* ---------- Окно уведомлений ---------- */
.pop {
  position: fixed;
  right: 16px;
  top: 70px;
  z-index: 40;
  width: min(340px, calc(100vw - 32px));
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.pop h3 { margin: 0 0 6px; font-size: 15px; }
.pop p { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.pop .row { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 560;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Сбой: карточка упавшего сайта «глючит» ---------- */
.glitch { position: relative; display: inline-block; }
.site.is-down .glitch::before,
.site.is-down .glitch::after,
.hero.is-down .glitch::before,
.hero.is-down .glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.site.is-down .glitch::before, .hero.is-down .glitch::before { color: var(--glitch-c); transform: translateX(2px); mix-blend-mode: screen; opacity: 0.8; }
.site.is-down .glitch::after, .hero.is-down .glitch::after { color: var(--glitch-r); transform: translateX(-2px); mix-blend-mode: screen; opacity: 0.8; }
:root[data-theme="light"] .glitch::before,
:root[data-theme="light"] .glitch::after { mix-blend-mode: multiply; opacity: 0.55; }

@media (prefers-reduced-motion: no-preference) {
  .site.is-down .glitch::before, .hero.is-down .glitch::before { animation: g-c 2.2s steps(1) infinite; }
  .site.is-down .glitch::after, .hero.is-down .glitch::after { animation: g-r 2.2s steps(1) infinite; }
  .site.is-down { animation: jolt 2.2s steps(1) infinite; }

  /* Знак в шапке: при аварии сбоит не раз в 6 секунд, а постоянно. */
  body.is-down .vx-ab-r { animation: vx-glitch-r 1.1s infinite; }
  body.is-down .vx-ab-c { animation: vx-glitch-c 1.1s infinite; }
  body.is-down .vx-main { animation: vx-jolt 1.1s infinite; }
}
body.is-down .vx-dot { fill: var(--crit); }

@keyframes g-c {
  0%, 100% { clip-path: inset(0 0 100% 0); }
  8% { clip-path: inset(10% 0 60% 0); transform: translateX(4px); }
  12% { clip-path: inset(55% 0 20% 0); transform: translateX(-3px); }
  16% { clip-path: inset(0 0 100% 0); }
  60% { clip-path: inset(70% 0 5% 0); transform: translateX(3px); }
  63% { clip-path: inset(0 0 100% 0); }
}
@keyframes g-r {
  0%, 100% { clip-path: inset(0 0 100% 0); }
  9% { clip-path: inset(40% 0 35% 0); transform: translateX(-4px); }
  13% { clip-path: inset(5% 0 80% 0); transform: translateX(3px); }
  17% { clip-path: inset(0 0 100% 0); }
  61% { clip-path: inset(20% 0 55% 0); transform: translateX(-3px); }
  64% { clip-path: inset(0 0 100% 0); }
}
@keyframes jolt {
  0%, 100% { transform: none; }
  9% { transform: translateX(1px); }
  12% { transform: translateX(-1px); }
  14% { transform: none; }
}

/* ---------- Загрузка ---------- */
.boot {
  min-height: 50vh;
  display: grid;
  place-items: center;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 13px;
}

/* ---------- Телефон ---------- */
@media (max-width: 560px) {
  main { padding-top: 14px; }
  section { margin-top: 26px; }
  .brand-sub { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feed li { grid-template-columns: 1fr auto; }
  .feed time { grid-column: 1 / -1; }
}

@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .btn { min-height: 44px; }
}
