/* Unbedlam — design tokens, typography, primitives.
 *
 * One palette, two themes. Terracotta is the only accent: it marks the active
 * nav item, the primary button, and "critical". Nothing else is allowed to use
 * it, which is why "escalated" is the only filled chip in the interface and
 * severity is carried by a 3px rule at the left edge of a row.
 *
 * Theme selection: `data-theme` on <html> wins; with no attribute the OS
 * preference applies. index.html only sets the attribute when someone chose a
 * theme explicitly.
 *
 * Slice stylesheets (../<slice>/ui/*.css) are concatenated AFTER this file and
 * may only use the tokens declared below.
 */

:root {
  /* Native controls (inputs, selects, scrollbars) follow the OS until a theme
   * is chosen explicitly; see the [data-theme] blocks below. */
  color-scheme: light dark;

  /* surfaces */
  --bg: #faf9f5;
  --surface: #ffffff;
  --surface-2: #f4f1e8;

  /* text */
  --ink: #141413;
  --ink-2: #3d3929;
  --muted: #7c786c;

  /* lines */
  --rule: #e8e5db;

  /* accent */
  --accent: #c96442;
  --accent-hover: #b4532f;
  --accent-soft: #f7e9e1;
  --on-accent: #ffffff;

  /* status */
  --warn: #a16207;
  --warn-soft: #f6eedc;
  --ok: #6b8f5e;
  --ok-soft: #e9efe3;

  /* shape */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --menu: 0 8px 24px rgba(20, 20, 19, 0.08);
  --transition-fast: 120ms ease-out;
  --transition-normal: 200ms ease-out;

  /* type */
  --font: "Go", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Go Mono", "SF Mono", ui-monospace, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f1e1c;
    --surface: #292825;
    --surface-2: #2a2824;
    --ink: #f2efe7;
    --ink-2: #d4cfc0;
    --muted: #9c968a;
    --rule: #3b3831;
    --accent: #e0906f;
    --accent-hover: #efa184;
    --accent-soft: #3b2a20;
    --on-accent: #241a14;
    --warn: #e5a66b;
    --warn-soft: #3a3021;
    --ok: #a3c08f;
    --ok-soft: #26301f;
    --menu: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1f1e1c;
  --surface: #292825;
  --surface-2: #2a2824;
  --ink: #f2efe7;
  --ink-2: #d4cfc0;
  --muted: #9c968a;
  --rule: #3b3831;
  --accent: #e0906f;
  --accent-hover: #efa184;
  --accent-soft: #3b2a20;
  --on-accent: #241a14;
  --warn: #e5a66b;
  --warn-soft: #3a3021;
  --ok: #a3c08f;
  --ok-soft: #26301f;
  --menu: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ── fonts ───────────────────────────────────────────────────────────────
 * Served by the binary at <base>/fonts/*.woff2 (see StaticAssets). Relative
 * URLs resolve against main.css, so a base path needs no special handling.
 */
@font-face {
  font-family: "Go";
  src: url("fonts/Go-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Go";
  src: url("fonts/Go-Medium.woff2") format("woff2");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Go Mono";
  src: url("fonts/Go-Mono.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* ── reset ───────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink-2);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  color: var(--ink);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

code,
pre,
kbd {
  font-family: var(--font-mono);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── shell: rail + content ─────────────────────────────────────────────────
 * The rail holds the sections of the app; the content column holds one screen.
 * Collapsed it keeps the icons and drops the words — the same markup, one
 * class on the container. Narrow screens get the collapsed form regardless of
 * the stored preference, which is why the hiding rules appear twice.
 */

.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.app--collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  overflow: hidden;
}

/* Mark and name centred, with equal columns on both sides so a control in the
 * right slot (the drawer's close) does not shift the centre. */
.rail__brand {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 6px;
  padding: 12px 10px 12px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.rail__brand-id {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

/* The tile holds the funnel mark (Ui/Logo), not a letter: 22px of terracotta
 * with 17px of mark inside, which is the smallest size where the drawing still
 * reads as a funnel. */
.rail__mark {
  /* 26px, not 22: the engraved funnel needs the pixels — at 22 the hatching
   * turns to mush on a 1x screen, at 26 it still reads as a funnel with wires. */
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* The glyph is the plate's own funnel, traced — not a redrawing of it. As a
 * mask its colour comes from the tile, so the same file works on the accent
 * tile, in the phone header and on paper. */
.rail__mark-glyph {
  width: 20px;
  height: 20px;
  background-color: var(--on-accent);
  -webkit-mask: url("assets/funnel.svg") center / contain no-repeat;
  mask: url("assets/funnel.svg") center / contain no-repeat;
}

.rail__name {
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
}

/* The collapse toggle lives in the preferences row so it is reachable in both
 * states — a control that disappears when it is the only way back is a trap. */
.rail__collapse {
  margin-right: auto;
}

.mirrored {
  display: inline-flex;
  transform: scaleX(-1);
}

.rail__body {
  padding: 6px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}

.rail__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 9px 6px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 5px;
  color: var(--ink-2);
  font-size: 13.5px;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item--on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.nav-item--on:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail__prefs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--rule);
  flex-shrink: 0;
}

.rail__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 11px;
  border-top: 1px solid var(--rule);
  flex-shrink: 0;
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 500;
  flex-shrink: 0;
}

.rail__user {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.rail__user-name {
  font-size: 12px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail__user-role {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail__logout {
  margin-left: auto;
}

.content {
  min-width: 0;
  padding: 24px 28px 48px;
}

/* Collapsed: icons only. */
.app--collapsed .rail__name,
.app--collapsed .nav-item__label,
.app--collapsed .rail__user,
.app--collapsed .rail__label {
  display: none;
}

.app--collapsed .rail__brand {
  grid-template-columns: minmax(0, 1fr);
  padding: 14px 0 13px;
  gap: 0;
}

.app--collapsed .rail__brand-side {
  display: none;
}

.app--collapsed .rail__collapse {
  margin-right: 0;
}

.app--collapsed .rail__body {
  padding: 8px 6px;
}

.app--collapsed .nav-item {
  justify-content: center;
  padding: 8px 0;
  gap: 0;
}

/* A hairline where a group starts, in place of the words. */
.app--collapsed .rail__body > .nav-item + .nav-item {
  margin-top: 2px;
}

.app--collapsed .rail__prefs {
  flex-direction: column;
  padding: 6px 0;
}

.app--collapsed .rail__foot {
  flex-direction: column;
  align-items: center;
  gap: 4px;
  justify-content: center;
  padding: 9px 0 11px;
}

/* Collapsed to 64px, the person's name goes but the way out stays: the button
 * is an icon, not text, and a control that disappears when it is the only way
 * to sign out is a trap. It sits under the avatar, centred in the rail. */
.app--collapsed .rail__logout {
  margin-left: 0;
}

/* ── icons ───────────────────────────────────────────────────────────────── */

.ic {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── page ────────────────────────────────────────────────────────────────── */

.page {
  animation: none;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

/* The screen's primary action goes to the right edge of the header row; a
 * lone button next to the title reads as decoration, not as the next step. */
.page-header > .btn:last-child {
  margin-left: auto;
}

.page-title {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.012em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: -12px 0 20px;
}

/* ── модальные окна ────────────────────────────────────────────────────────
 * Форма открывается поверх карты: экран не меняется, видно, куда встанет
 * результат. Окно держит прокрутку внутри себя — длинная форма не тянет за
 * собой страницу.
 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 22, 19, 0.38);
  backdrop-filter: blur(1.5px);
}

.modal__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 48px rgba(26, 22, 19, 0.18);
}

/* Правило и маршрут — две колонки матчеров и предпросмотр: им тесно в
 * ширине источника. */
.modal__dialog--wide {
  width: min(880px, 100%);
}

.modal__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
}

.modal__title {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}

.modal__close {
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
}

.modal__body {
  overflow-y: auto;
  padding: 18px;
}

/* Формы внутри окна — та же форма, но без обвязки страницы: у окна своя
 * шапка, и вторая («Правило группировки») только спорит с ней. */
.modal__body .page {
  max-width: none;
  padding: 0;
}

/* Заголовок страницы в окне не нужен: окно называет себя само. А кнопки
 * живут в той же строке — спрятать их вместе с заголовком значит оставить
 * форму без «Сохранить» (так и случилось с правилами группировки). Поэтому
 * прячем только заголовок, а строку разворачиваем к правому краю. */
.modal__body .page-header__title,
.modal__body .page-subtitle {
  display: none;
}

.modal__body .page-header {
  justify-content: flex-end;
  margin-bottom: 14px;
}

/* Поля в окне идут по одному в ряд и не разъезжаются на всю ширину 880px. */
.modal__body .form-field,
.modal__body .form-group {
  max-width: 420px;
}

/* ── cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  /* A card can hold a table directly (the dashboard does): the table keeps its
   * minimum width and the card scrolls, instead of the whole page going wide. */
  overflow-x: auto;
}

.card-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}

.card-header a {
  margin-left: auto;
  font-size: 12.5px;
  font-weight: 400;
}

/* ── badges ────────────────────────────────────────────────────────────────
 * Severity and status share one chip; what differs is the dot: filled,
 * half-filled, outlined, or absent (filled chip = escalated, the loud one).
 */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border: 1px solid transparent;
  border-radius: 20px;
  font-size: 12px;
  line-height: 1.65;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-active {
  background: var(--surface-2);
  border-color: var(--rule);
  color: var(--ink-2);
}

.badge-active::before {
  background: none;
  box-shadow: inset 0 0 0 1.5px currentColor;
}

.badge-acknowledged {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-acknowledged::before {
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
  box-shadow: inset 0 0 0 1.5px currentColor;
}

.badge-resolved {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-firing {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-suppressed {
  background: var(--surface-2);
  border-color: var(--rule);
  color: var(--muted);
}

.badge-info {
  background: var(--surface-2);
  border-color: var(--rule);
  color: var(--muted);
}

.badge-warning {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-critical {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 11px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast);
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--rule);
  color: var(--ink-2);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink-2);
}

.btn-danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
}

.btn-danger:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  padding: 3px 8px;
  font-size: 12px;
}

/* ── tables ──────────────────────────────────────────────────────────────── */

.table-container {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  /* Rounded corners need clipping; narrow screens need scrolling. Both: the
   * table keeps a minimum width and the container scrolls sideways instead of
   * squashing columns until the timestamps are cut in half. */
  overflow: hidden;
  overflow-x: auto;
  margin-bottom: 16px;
}

.table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table thead th {
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  padding: 9px 12px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--surface-2);
}

.table td:first-child {
  color: var(--ink);
}

/* Numbers, ids and timestamps: mono so columns do not wobble, and never
 * wrapped — a timestamp split across two lines doubles a row's height. */
.table .mono,
.table td.numeric {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* A checkbox in a table cell is a switch: the state should be readable at a
 * glance, not decoded from a 12px box. */
.table input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 17px;
  margin: 0;
  border-radius: 20px;
  background: var(--rule);
  position: relative;
  cursor: pointer;
  transition: background var(--transition-fast);
  vertical-align: middle;
}

.table input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--surface);
  transition: left var(--transition-fast);
}

.table input[type="checkbox"]:checked {
  background: var(--accent);
}

.table input[type="checkbox"]:checked::after {
  left: 15px;
}

.table .name {
  color: var(--ink);
  font-weight: 500;
}

.count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 20px;
  padding: 1px 7px;
}

/* ── forms ───────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

input:not([type]),
input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

select {
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ── segmented filter ────────────────────────────────────────────────────── */

.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.seg__item {
  padding: 5px 11px;
  background: none;
  border: 0;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.seg__item + .seg__item {
  border-left: 1px solid var(--rule);
}

.seg__item:hover {
  background: var(--surface-2);
  color: var(--ink-2);
}

.seg__item--on {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 500;
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ── matcher builder rows ────────────────────────────────────────────────── */

.matcher-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 92px minmax(0, 2fr) 24px;
  gap: 6px;
  align-items: center;
  margin-bottom: 0;
  width: 100%;
}

/* Small square icon button (row actions, builder steps). */
.icon-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink-2);
}

/* ── pagination ──────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

.pagination-controls {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.pagination-info {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

/* ── empty, loading ──────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--muted);
  font-size: 14px;
}

.empty-state svg {
  width: 32px;
  height: 32px;
  opacity: 0.35;
  margin-bottom: 10px;
}

.empty-state p {
  margin: 0;
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px;
  color: var(--muted);
  font-size: 13.5px;
}

/* ── login ───────────────────────────────────────────────────────────────── */

.login-wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 20px;
}

/* The page module renders a .page around its card; in this wrapper the wrapper
 * owns the sizing, so the intermediate block stays out of the way. */
.login-wrapper .page {
  width: 100%;
  max-width: 340px;
}

.login-card {
  width: 340px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 24px 24px 20px;
  box-shadow: var(--menu);
}

.login-title {
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}

.login-error {
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--accent);
  padding: 7px 10px;
  font-size: 13px;
  margin-bottom: 10px;
}

/* The inline-style version of this was repeated on every page; one class. */
.page-error {
  margin-bottom: 16px;
}

/* ── table cell helpers ──────────────────────────────────────────────────── */

/* Actions on the right of a row: same gap everywhere, no per-cell margins. */
.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}

/* A label above a control that is not inside a .form-group. */
.form-label {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.input-inline {
  width: 140px;
  padding: 3px 8px;
  font-size: 13px;
}

/* A quiet line of explanation under a form. */
.hint-row {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ── utilities ───────────────────────────────────────────────────────────── */

.text-muted {
  color: var(--muted);
}

/* ── scrollbars ──────────────────────────────────────────────────────────── */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--rule);
  border: 3px solid var(--bg);
  border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ── phones ────────────────────────────────────────────────────────────────
 * Not a separate layout: the same rail at icon width, tighter padding, and
 * controls that a thumb can hit. The app is used from a laptop most of the
 * time, so this is "works on a phone", not "designed for a phone".
 */
@media (max-width: 640px) {
  .content {
    padding: 14px 12px 32px;
  }

  .page-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-title {
    font-size: 19px;
  }

  /* Bigger hit areas. */
  .btn {
    padding: 9px 12px;
  }

  .btn-sm {
    padding: 7px 10px;
  }

  .rail__body {
    padding: 8px 4px;
  }

  .nav-item {
    padding: 11px 0;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
  }

  .table {
    min-width: 560px;
  }

  /* A matcher is three fields and a button; side by side on a phone each text
   * field gets 58px, which is not a text field. Two rows: label + operator,
   * then the value across the width. */
  .matcher-row {
    grid-template-columns: minmax(0, 1fr) 72px 28px;
    grid-template-areas:
      "label op remove"
      "value value remove";
    row-gap: 6px;
  }

  .matcher-row > *:nth-child(1) {
    grid-area: label;
  }

  .matcher-row > *:nth-child(2) {
    grid-area: op;
  }

  .matcher-row > *:nth-child(3) {
    grid-area: value;
  }

  .matcher-row > *:nth-child(4) {
    grid-area: remove;
    align-self: start;
  }
}

@media (max-width: 900px) {
  .app,
  .app--collapsed {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .rail__name,
  .nav-item__label,
  .rail__user,
  .rail__label,
  .rail__collapse,
  .rail__logout {
    display: none;
  }

  .rail__brand {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px 0 13px;
    gap: 0;
  }

  .rail__brand-side {
    display: none;
  }

  .rail__body {
    padding: 8px 6px;
  }

  .nav-item {
    justify-content: center;
    padding: 8px 0;
    gap: 0;
  }

  .rail__prefs {
    flex-direction: column;
    padding: 6px 0;
  }

  .rail__foot {
    justify-content: center;
    padding: 9px 0 11px;
  }

  .content {
    padding: 18px 16px 40px;
  }
}

/* ── phone shell: top bar and drawer ───────────────────────────────────────
 * Below 640px the rail is not a column, it is a drawer: the content gets the
 * full width and navigation is one tap away, over the content, temporary.
 *
 * Last in the file and specific on purpose: the 900px block earlier also
 * matches at 390px and would otherwise keep the 64px rail column.
 */
@media (max-width: 640px) {
  .app.app--narrow {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 32px;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .topbar__brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 0;
  }

  .topbar__title {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Same width as the menu button so the brand is optically centred, not
   * "centred plus half a button". */
  .topbar__spacer {
    width: 32px;
  }

  .rail__close {
    margin-left: auto;
  }

  .app.app--narrow .rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    height: 100vh;
    height: 100dvh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    box-shadow: var(--menu);
  }

  .app.app--narrow.app--drawer-open .rail {
    transform: translateX(0);
  }

  .app.app.app--narrow .rail__name,
  .app.app--narrow .nav-item__label,
  .app.app--narrow .rail__label,
  .app.app--narrow .rail__user {
    display: flex;
    flex-direction: column;
  }

  .app.app--narrow .topbar {
    z-index: 36; /* above the scrim: the menu button stays usable */
  }

  .app.app--narrow .nav-item {
    justify-content: flex-start;
    padding: 10px;
    gap: 9px;
  }

  .app.app.app--narrow .rail__brand {
    grid-template-columns: 32px minmax(0, 1fr) 32px;
    padding: 12px 10px;
    gap: 6px;
  }

  .app.app--narrow .rail__brand-side {
    display: block;
  }

  .app.app--narrow .rail__prefs {
    flex-direction: row;
    padding: 8px 10px;
  }

  .app.app.app--narrow .rail__foot {
    justify-content: flex-start;
    padding: 9px 10px 11px;
  }

  .app.app.app--narrow .rail__collapse {
    display: none;
  }

  /* The ≤900px block hides the logout because a 64px icon rail has no room for
   * it. The drawer has: 260px with the person's name on the left. Hiding it here
   * left no way to sign out on a phone at all. */
  .app.app.app--narrow .rail__logout {
    display: inline-flex;
    margin-left: auto;
  }

  .drawer-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 19, 0.35);
    z-index: 35;
  }

  .app.app--narrow.app--drawer-open .drawer-scrim {
    display: block;
  }

  .app.app--narrow .content {
    padding: 14px 12px 40px;
}
}

/* ../alerting/ui/alerting.css */
/* Стили слайса alerting: дашборд дежурного, сборщики правил и подавлений,
 * экраны деталей. Сборка (frontend/build.sh) кладёт этот файл после
 * frontend/globals.css; цвета и размеры — через токены оболочки. */

.card-title {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 8px;
}

/* ── the shift console ───────────────────────────────────────────────────────
 *
 * One column, ordered by what a duty officer needs. The headline is the worst
 * thing that is true: a queue of things waiting for a person, or a source that
 * stopped speaking, or a calm that can be backed by evidence.
 */

.dash-head {
  margin-bottom: 20px;
}

/* The one line that has to win the eye at three in the morning. */
.dash-head__count {
  display: inline-block;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -0.025em;
}

.dash-head__quiet {
  margin-top: 8px;
  padding: 8px 12px;
  border-left: 3px solid var(--warn);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 13px;
}

/* Инциденты, о которых никто не узнал. Не «тихо» и не «ошибка», а дыра в
 * оповещении: поэтому терракота, а не жёлтый. Стоит над очередью и не
 * исчезает, пока в ней есть число. */
.dash-silent {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin-bottom: 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}

.dash-silent__text {
  font-size: 13px;
  color: var(--ink);
}

.dash-silent__act {
  margin-left: auto;
  font: inherit;
  font-size: 12.5px;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}

.dash-silent__act:hover {
  text-decoration: underline;
}

/* Not a card among cards: a tinted block with a heavy alarm rule, so the queue
 * reads as a different kind of thing from the calm below it. */
.queue {
  margin-top: 14px;
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--rule));
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.queue-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 15px 16px 15px 16px;
}

.queue-row + .queue-row {
  border-top: 1px solid var(--rule);
}

.queue-row__sev {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.queue-row__sev.sev--crit {
  background: var(--accent);
}

.queue-row__sev.sev--warn {
  background: var(--warn);
}

.queue-row__sev.sev--info {
  background: var(--muted);
}

.queue-row__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.queue-row__title {
  font-size: 16.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-row__body:hover .queue-row__title {
  color: var(--accent);
}

.queue-row__meta {
  font-size: 13px;
  color: var(--muted);
}

/* ── what is already being handled ───────────────────────────────────────── */

.dash-block {
  margin-bottom: 20px;
}

/* The section title of the console. The caps-and-mono voice is right, but at
 * 10.5px in the muted grey it measured 4.19:1 — an invitation to squint. At
 * 12px in ink-2 it is 10.98:1 and still reads as a label, not as content. */
.dash-block__title {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding-bottom: 9px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 6px;
}

.progress-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  padding-left: 16px;
  color: inherit;
  text-decoration: none;
}

.progress-row + .progress-row {
  border-top: 1px solid var(--rule);
}

.progress-row__title {
  font-size: 13.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-row:hover .progress-row__title {
  color: var(--accent);
}

.progress-row__meta {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* Escalation travels with the row into "already being handled": the fact
 * stays true and stays visible, it just stops being a reason to call it a
 * fire. */
.progress-row__escalated {
  margin-left: 8px;
  font-size: 10.5px;
  vertical-align: 1px;
}

.progress-row .queue-row__sev {
  width: 6px;
  height: 6px;
}

/* ── calm ────────────────────────────────────────────────────────────────── */

/* The one place the interface is allowed to be warm: nothing is wrong, and it
 * says so in a size that cannot be mistaken for a widget. */
.dash-calm {
  padding: 56px 0 60px;
  text-align: center;
}

.dash-calm__title {
  font-size: 30px;
  line-height: 1.2;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.dash-calm__line {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--muted);
}

/* ── blind ───────────────────────────────────────────────────────────────── */

/* Quieter than a fire and louder than calm: nothing has broken, and we do not
 * know what is going on. */
.dash-blind {
  padding: 40px 0 44px;
  text-align: center;
}

.dash-blind__title {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 500;
  color: var(--warn);
  letter-spacing: -0.015em;
}

.dash-blind__line {
  margin-top: 10px;
  font-size: 15px;
  color: var(--ink-2);
}

.badge-escalated {
  background: var(--accent);
  color: var(--on-accent);
}

.badge-escalated::before {
  display: none;
}

.clickable {
  cursor: pointer;
}

/* Severity lives at the left edge of the row, so the eye finds critical
 * incidents before reading a single word. */
.table td.sev {
  width: 3px;
  padding: 0;
  box-shadow: inset 3px 0 0 var(--rule);
}

.table td.sev--crit {
  box-shadow: inset 3px 0 0 var(--accent);
}

.table td.sev--warn {
  box-shadow: inset 3px 0 0 var(--warn);
}

.table td.sev--info {
  box-shadow: inset 3px 0 0 var(--muted);
}

/* A label is a machine string; mono keeps "key value" columns aligned. */
.label {
  display: inline-flex;
  gap: 4px;
  padding: 0 5px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
}

.label-key {
  color: var(--muted);
}

.label-value {
  color: var(--ink-2);
}

/* Several chips in one cell (status + who acknowledged + escalated). */
.badge-stack {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
  overflow: hidden;
}

/* A row of several chips keeps chips intact: each one is one line. */
.badge-stack .badge,
.badge-stack .label {
  flex-shrink: 0;
}

/* In a card (not a table cell) the chips may wrap: there is room. */
.card > .badge-stack {
  flex-wrap: wrap;
  overflow: visible;
}

.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 11px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.filter-bar select {
  width: auto;
  min-width: 140px;
}

/* Specificity matters: the generic input rule below is an attribute selector,
 * so a bare .filter-input would lose and stretch to 100%. */
.filter-bar .filter-input {
  width: 260px;
  flex: 0 0 auto;
}

.matcher-remove {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.matcher-remove:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── rule builders (three panels: alerts · rules · preview) ──────────────── */

.rule-builder {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rule-builder-top,
.rule-builder-bottom {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.rule-builder-divider {
  height: 1px;
  background: var(--rule);
}

.rule-builder-panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 14px;
}

.rule-builder-panel--left {
  flex: 0 0 34%;
  min-width: 0;
}

.rule-builder-panel--middle {
  flex: 1;
  min-width: 0;
}

.builder-step-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── alert browser (source list inside a builder) ────────────────────────── */

.alert-browser-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 2px;
}

.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.alert-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--rule));
  background: var(--surface-2);
}

.alert-card--dragging {
  opacity: 0.5;
}

.alert-card--in-bag {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

/* A flex item's default min-width is its content, so a long alert name pushed
 * past the card and ran underneath the add button. The card is a small grid
 * now: name across the top, status under it, button in its own column. In a
 * 190px panel the badge beside the name left 82px for characters. */
.alert-browser-list .alert-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px 8px;
}

.alert-card > div:first-child {
  min-width: 0;
  overflow: hidden;
}

.alert-browser-list .alert-card > div:first-child {
  grid-column: 1;
  grid-row: 1;
}

.alert-browser-list .alert-card .badge {
  grid-column: 1;
  grid-row: 2;
  justify-self: start;
}

.alert-browser-list .alert-card-add,
.alert-browser-list .alert-card-check {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}

.alert-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-card-add,
.alert-card-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  border: 1px solid var(--rule);
  color: var(--muted);
  font-size: 11px;
}

.alert-card--in-bag .alert-card-check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* ── drop zone ───────────────────────────────────────────────────────────── */

.rule-bag {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
  padding: 10px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.rule-bag--empty {
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12.5px;
}

.rule-bag--drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.alert-browser-list--drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  border-radius: var(--radius-md);
}

.rule-bag-source {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.rule-bag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.rule-bag-item-remove {
  margin-left: auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
}

.rule-bag-item-remove:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── inference panel (what the rule will do) ─────────────────────────────── */

.inference-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 14px;
}

.inference-section {
  margin-bottom: 14px;
}

.inference-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.inference-hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── preview ─────────────────────────────────────────────────────────────── */

.preview-table-container {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.preview-table {
  margin-top: 12px;
  margin-bottom: 0;
}

.preview-summary {
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px dashed var(--rule);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--ink-2);
}

.preview-summary strong {
  font-family: var(--font-mono);
  color: var(--ink);
  font-weight: 500;
}

/* ── detail screens: content + side rail ─────────────────────────────────── */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.split__main,
.split__side {
  min-width: 0;
}

.split__main > .card:last-child,
.split__side > .card:last-child {
  margin-bottom: 0;
}

/* A definition list reads as metadata: mono keys, values in the body face. */
.kv {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 14px;
  margin: 0;
  font-size: 12.5px;
}

.kv dt {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 2px;
}

.kv dd {
  margin: 0;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

/* Ids and fingerprints are 64 characters of hex: one line, ellipsis, and the
 * full value on hover (title attribute set by the caller). */
.kv dd.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  margin-right: 10px;
}

.back-link:hover {
  color: var(--accent);
}

/* ── list as cards (phones) ────────────────────────────────────────────────
 * The same records as the table, shaped for a 390px screen: one card per row,
 * severity at the left edge, the title, the chips, and one line of context.
 * A slice chooses this when `Context.narrow` — the shell does not decide what
 * a screen shows.
 */

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.list-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--rule);
  border-radius: var(--radius-md);
  color: var(--ink-2);
}

.list-card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--rule));
}

.list-card.sev--crit {
  border-left-color: var(--accent);
}

.list-card.sev--warn {
  border-left-color: var(--warn);
}

.list-card.sev--info {
  border-left-color: var(--muted);
}

.list-card__title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
}

.list-card__meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The value the operator must copy: mono, bordered, still selectable. */
.webhook {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1px 6px;
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* The row of actions under a detail header. */
/* Pushed to the far end of an action bar: the destructive-looking one. */
.action-bar__end {
  margin-left: auto;
}

.header-action {
  margin-left: auto;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

/* A quiet line at the bottom of a page: counts, hints, refresh cadence. */
.page-note {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

/* ── narrow screens ──────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .rule-builder-top,
  .rule-builder-bottom {
    flex-direction: column;
  }

  .rule-builder-panel--left {
    flex: 1 1 auto;
    width: 100%;
  }
}

@media (max-width: 640px) {
  /* Right-aligned, this line broke after "10" and left "секунд" alone on a
   * line of its own. As ordinary left text it wraps without the orphan. */
  .page-note {
    text-align: left;
  }

  /* Filters stack instead of squeezing the search box to nothing. */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .filter-bar .seg {
    overflow-x: auto;
    max-width: 100%;
  }

  .filter-bar .filter-input {
    width: 100%;
  }

  .kv {
    gap: 6px 10px;
  }

  /* A list card on a phone has room for the chips to wrap, as a card does. */
  .app.app--narrow .list-card .badge-stack {
    flex-wrap: wrap;
    overflow: visible;
  }

  /* Three columns do not fit 390px: the name was ellipsised to nothing and
   * the meta wrapped under the button. The row becomes a stack — name, then
   * who and how long, then a thumb-sized action across the width. */
  .queue-row {
    grid-template-columns: 10px minmax(0, 1fr);
    row-gap: 10px;
    padding: 14px 14px 14px 16px;
  }

  .queue-row__sev {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    margin-top: 7px;
  }

  .queue-row__body {
    grid-column: 2;
    grid-row: 1;
  }

  .queue-row__title {
    white-space: normal;
  }

  .queue-row .btn {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
  }

  .progress-row {
    grid-template-columns: 10px minmax(0, 1fr);
    row-gap: 2px;
    padding-left: 0;
  }

  .progress-row .queue-row__sev {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: start;
    margin-top: 7px;
  }

  .progress-row__title,
  .progress-row__meta {
    grid-column: 2;
    white-space: normal;
  }
}

/* ../identity/ui/identity.css */
/* Стили слайса identity: страница входа и смена пароля. Сборка кладёт
 * этот файл после frontend/globals.css; цвета — через токены оболочки. */

/* The engraved plate, where it has room to be an engraving: the login card
 * hosts the drawing itself, while the chrome uses the 22px reduction of it
 * (Ui/Logo). Served by the binary under /assets/, addressed relatively so a
 * base path needs no special case — same trick as the faces above.
 *
 * The file is a traced mask, not a picture: its shape is the drawing's alpha
 * and the colour is the element's background, so the plate is drawn in the
 * theme's ink with no second file and no filter to invert it. */
.login-plate {
  width: 250px;
  height: 250px;
  margin: 0 auto 16px;
  background-color: var(--ink);
  /* Two masks: the drawing, intersected with a soft vignette. The engraver's
   * rays run to the plate's edge because the frame used to stop them; with the
   * frame gone they would end on a ruler-straight line and look cropped, so
   * they fade instead. Same reason a print is trimmed inside the plate mark. */
  -webkit-mask-image: url("assets/logo.svg"), radial-gradient(ellipse at 50% 44%, #000 52%, transparent 86%);
  -webkit-mask-size: contain, 100% 100%;
  -webkit-mask-repeat: no-repeat, no-repeat;
  -webkit-mask-composite: source-in;
  mask-image: url("assets/logo.svg"), radial-gradient(ellipse at 50% 44%, #000 52%, transparent 86%);
  mask-size: contain, 100% 100%;
  mask-repeat: no-repeat, no-repeat;
  mask-composite: intersect;
}

/* A button that owns the width of its container (login forms). */
.btn-block {
  width: 100%;
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}

/* A control that sits inside a dense row: narrow and quiet. */
.select-inline {
  width: auto;
  min-width: 130px;
  padding: 3px 8px;
  font-size: 13px;
}

@media (max-width: 640px) {
  /* The login page renders outside the shell, so it gets no `.app--narrow`
   * to hook onto: the plate has to answer the width itself. */
  .login-plate {
    width: 190px;
    height: 190px;
    margin-bottom: 12px;
  }
}

/* ../notify/ui/notify.css */
/* Стили слайса notify: получатели, дежурства, редактор маршрута. Сборка
 * кладёт этот файл после frontend/globals.css; цвета — через токены оболочки. */

.check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

/* Two fields side by side when there is room, one when there is not. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 4px;
}

/* ── редактор маршрута ─────────────────────────────────────────────────────
 *
 * Форма решает, кого зовут. Поэтому блоки идут в порядке вопроса: как
 * называется, когда зовут, кого именно это касается, кого звать.
 */

.route-form {
  max-width: 720px;
}

/* Ответ на главный вопрос страницы стоит до формы: дежурный приходит сюда
 * узнать «кто сейчас», а не завести смену. */
.duty-now {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 16px;
  margin-bottom: 20px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
}

.duty-now--empty {
  background: var(--accent-soft);
}

.duty-now__who {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}

.duty-now__meta {
  font-size: 12.5px;
  color: var(--muted);
}

.duty-row--now {
  background: var(--surface-2);
}

.duty-row--past {
  color: var(--muted);
}

.duty-state {
  font-size: 11px;
  margin-top: 2px;
}

.duty-state--now {
  color: var(--accent);
}

.duty-state--past,
.duty-state--ahead {
  color: var(--muted);
}

.form-field {
  display: block;
  margin-bottom: 18px;
}

.form-field > .form-label {
  margin-bottom: 6px;
}

.form-section {
  margin-bottom: 18px;
}

.form-section__title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding-bottom: 7px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 10px;
}

.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

.form-hint--bad {
  color: var(--accent);
  margin-top: 10px;
}

/* Варианты выбора — рядами: получателей и моментов немного, и списком они
 * читаются быстрее, чем выпадающим меню. */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--muted);
}

.chip input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.matcher-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.matcher-row__value--empty {
  font-size: 13px;
  color: var(--muted);
  padding: 7px 10px;
}

.matcher-row__remove {
  font-size: 15px;
  line-height: 1;
}

/* Кнопка поменьше — там, где это не главное действие экрана. */
.btn--small {
  padding: 4px 10px;
  font-size: 12.5px;
}

/* ../pipeline/ui/pipeline.css */
/* Стили слайса pipeline. Сборка кладёт этот файл после frontend/globals.css. */

/* ── пайплайн ─────────────────────────────────────────────────────────────
 *
 * Карта из пяти колонок: источники, правила, инциденты, маршруты,
 * получатели. Позиции колонок и линий считает Elm из геометрии, здесь —
 * только внешний вид. Свободных координат в CSS нет намеренно: если карта
 * начнёт разваливаться, причина будет в одном месте.
 */

/* Подсказка нужна только там, где карта шире экрана. */
.pipeline__hint {
  display: none;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 10px;
}

@media (max-width: 1250px) {
  .pipeline__hint {
    display: block;
  }
}

/* Цвет линии — единственный носитель смысла «работает / висит / выключено»,
 * поэтому состояния различимы и по штриху, а не только по цвету. */
.pipeline__wire {
  fill: none;
  stroke-width: 1.1;
}

.pipeline__wire--fires {
  stroke: var(--accent);
}

.pipeline__wire--idle {
  stroke: var(--muted);
  opacity: 0.5;
}

.pipeline__wire--off {
  stroke: var(--muted);
  opacity: 0.45;
  stroke-dasharray: 4 4;
}

.pipeline__caption {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Карта — воронка: ступени стопкой, карточки в ряд внутри ступени.
 * Едет вбок вся целиком (когда карточек много), а не каждая ступень сама по
 * себе — иначе линии между ступенями перестают попадать в карточки. */
.pipeline {
  position: relative;
}

.pipeline__scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
  cursor: grab;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.pipeline__scroll.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.pipeline__scroll::-webkit-scrollbar {
  height: 10px;
}

.pipeline__scroll::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 999px;
}

.pipeline__scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* Пока тянем, карточки не отвечают наведением: это один жест, а не десять. */
.pipeline__scroll.is-dragging .pipeline__card--link:hover {
  border-color: var(--rule);
}

.pipeline__wires {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.pipeline__stage {
  position: absolute;
  left: 0;
}

/* Подпись ступени: сверху над рядом (телефон) или в левом поле (стол).
 * В поле линии её не задевают — за этим и переносили. */
.pipeline__caption-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.pipeline__caption-row--above {
  flex-direction: row;
}

.pipeline__caption-row--side {
  position: absolute;
  left: 0;
  top: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding-right: 12px;
  z-index: 2;
}

.pipeline__add {
  padding: 0;
  font-size: 11px;
  color: var(--muted);
  background: transparent;
  border: 0;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.pipeline__add:hover {
  color: var(--accent);
}

.pipeline__row {
  display: flex;
  gap: 12px;
}

/* Карточка занимает свой слот: ширина и высота приходят из геометрии, чтобы
 * линия попадала в её центр. */
.pipeline__slot {
  position: relative;
  z-index: 1;
  display: flex;
  /* Слот не сжимается: его ширина — часть геометрии, по ней считаются линии.
   * Сжатие на пару пикселей уводит центр карточки от конца провода. */
  flex: 0 0 auto;
}

.pipeline__slot > * {
  flex: 1;
}

.pipeline__card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
}

/* Маршрут несёт на строку больше: условие, «кроме», моменты. */
.pipeline__card--tall {
  gap: 2px;
}

/* Карточка маршрута — ссылка: маршрут правят там, где его видно. */
.pipeline__card--link {
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.pipeline__card--link:hover {
  border-color: var(--muted);
}

/* Ответвление: ветка игнора и псевдосинк. Рамка пунктиром — это не адресат,
 * а ответвление от потока, и путать их нельзя. */
.pipeline__card--branch {
  border-style: dashed;
}

.pipeline__card--off {
  opacity: 0.6;
}

.pipeline__card--bad {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.pipeline__card--ghost {
  justify-content: center;
  border-style: dashed;
  background: transparent;
}

/* Заглушка — это фраза, а не метка: ей разрешено переноситься. */
.pipeline__card--ghost .pipeline__card-title {
  white-space: normal;
  font-weight: 400;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink-2);
}

.pipeline__card--ghost.pipeline__card--bad {
  background: var(--accent-soft);
}

.pipeline__card--ghost.pipeline__card--bad .pipeline__card-title {
  color: var(--ink);
}

.pipeline__card-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

/* Длинное название уступает слову «изменить», а не наоборот: слово — это
 * действие, название — данные. */
.pipeline__card-head .pipeline__card-title {
  min-width: 0;
  flex: 1 1 auto;
}

.pipeline__card-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline__card-chip {
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0 6px;
}

.pipeline__card-cap,
.pipeline__card-meta {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Сроки эскалации — отдельной строкой: правило не только собирает инцидент,
 * но и решает, как быстро о нём начнут долбить. */
.pipeline__card-meta--policy {
  color: var(--ink-2);
  opacity: 0.8;
}

.pipeline__card-cap--not {
  color: var(--ink-2);
  opacity: 0.75;
}

/* Маршрут зовёт дежурного, а дежурства выключены: адресат молчит, и это
 * предупреждение, а не справка. */
.pipeline__card-meta--warn {
  color: var(--warn);
}

/* Слово «изменить» стоит на карточке всегда, а не появляется по наведению:
 * на телефоне наведения нет, и значок «это нажимается» там не увидеть. */
.pipeline__card-edit {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.pipeline__card--link:hover .pipeline__card-edit {
  color: var(--accent);
}

/* Ствол: в него сходятся все правила и из него выходят все маршруты. Он
 * один, поэтому выглядит не как карточка, а как участок: рамка толще. */
.pipeline__trunk {
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-2);
  border-radius: var(--radius-lg);
}

.pipeline__trunk-title {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.pipeline__trunk-count {
  font-size: 11.5px;
  color: var(--muted);
}

/* Ствол — баланс за сутки: сколько дошло и сколько потерялось. Полоса не
 * украшение: рядом стоящие числа без неё приходится складывать в голове. */
.pipeline__trunk-bar {
  display: flex;
  /* flex-элементы сжимаются, и в тесном стволе полоса сплющивалась в ноль:
   * высоту держим жёстко. */
  flex: 0 0 6px;
  min-height: 6px;
  margin: 2px 0 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--rule);
}

.pipeline__trunk-bar-ok {
  background: var(--ok);
}

.pipeline__trunk-bar-leak {
  background: var(--accent);
}

/* Две стороны одного счёта стоят по краям: так видно, что это баланс, а не
 * два независимых факта. */
.pipeline__trunk-ledger {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.pipeline__trunk-bad {
  font-size: 11.5px;
  color: var(--accent);
}

.pipeline__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
}

.pipeline__legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
}

.pipeline__legend-item::before {
  content: "";
  width: 22px;
  border-top: 1.1px solid currentColor;
}

.pipeline__legend-item--fires {
  color: var(--accent);
}

.pipeline__legend-item--idle {
  color: var(--muted);
}

.pipeline__legend-item--off {
  color: var(--muted);
  opacity: 0.7;
}

.pipeline__legend-item--off::before {
  border-top-style: dashed;
}
