:root,
:root[data-theme="dark"] {
  /* Deep violet: background #0B0917, surface #21143D, primary #693BDB, accent #A477FF, text #F5F1FF */
  --bg: #0B0917; --panel: #0F0B1F; --card: #160F2B; --border: #2A1F4A;
  --text: #F5F1FF; --muted: #A99FC4; --accent: #A477FF; --accent-bg: rgba(164, 119, 255, .16);
  --good: #34D399; --good-bg: rgba(52, 211, 153, .12); --bad: #F87171; --bad-bg: rgba(248, 113, 113, .13);
  --warn: #FBBF24; --warn-bg: rgba(251, 191, 36, .12);
  --hover: #21143D; --btn-bg: #5A34B8; --btn-fg: #F5F1FF;
  --primary: #693BDB; --glow: rgba(105, 59, 219, .2); --shadow: rgba(4, 2, 12, .55);
  --brand-gradient: linear-gradient(135deg, #4C2C9E 0%, #5F3BB8 60%, #74429F 100%); --aura: rgba(105, 59, 219, .1);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F6F3FF; --panel: #FFFFFF; --card: #FFFFFF; --border: #E5DCF8;
  --text: #0B0917; --muted: #5E567A; --accent: #693BDB; --accent-bg: #EFE8FF;
  --good: #15803D; --good-bg: #ECFDF3; --bad: #C62828; --bad-bg: #FEF2F2;
  --warn: #B45309; --warn-bg: #FFFBEB;
  --hover: #F1EBFF; --btn-bg: #693BDB; --btn-fg: #FFFFFF;
  --primary: #693BDB; --glow: rgba(105, 59, 219, .14); --shadow: rgba(33, 20, 61, .12);
  --brand-gradient: linear-gradient(135deg, #5B34C4 0%, #6E45D0 60%, #8150C2 100%); --aura: rgba(105, 59, 219, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }
h1 { margin: 0 0 20px; font-size: 22px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }

[hidden] { display: none !important; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--hover); color: var(--text); }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: var(--btn-bg); color: var(--btn-fg); opacity: .9; }
.btn-block { width: 100%; min-height: 44px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer;
}

/* Auth pages */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 400px; padding: 28px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--card);
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; font-weight: 700; color: var(--accent); }
.brand span { color: var(--text); }
.theme-toggle { position: fixed; top: 16px; right: 16px; }
.form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form label { margin-top: 8px; font-weight: 500; }
.form input {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
.form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form .btn { margin-top: 16px; }
.form-error { padding: 10px 12px; border-radius: 8px; background: var(--bad-bg); color: var(--bad); }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 8px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.steps { margin: 0 0 20px; padding-left: 20px; line-height: 1.9; }
.waiting { margin: 16px 0 0; text-align: center; }

/* App shell */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.sidebar {
  flex: 1 1 220px; padding: 12px; border-right: 1px solid var(--border); background: var(--panel);
  display: flex; flex-direction: column; gap: 2px;
}
.account {
  display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: 10px; min-width: 0;
}
.account-badge {
  flex: none; width: 28px; height: 28px; border-radius: 7px; background: var(--accent-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.account-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The project switcher: the sidebar's top card opens the list of the person's projects */
.project-switch { position: relative; margin-bottom: 14px; }
.project-switch > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
.project-switch > summary::-webkit-details-marker { display: none; }
.project-switch > summary:hover { background: var(--hover); }
.project-switch > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.account-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-chev { flex: none; color: var(--muted); }
.project-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; padding: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px var(--shadow);
  display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow-y: auto;
}
.project-menu form { margin: 0; }
.project-item {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--text); background: none; border: 0;
  padding: 8px 10px; border-radius: 7px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-item:hover, .project-item:focus-visible { background: var(--hover); }
.project-item.active { font-weight: 600; }
.project-item { position: relative; padding-right: 28px; }
.project-item.active::after { content: "✓"; position: absolute; right: 10px; top: 8px; color: var(--accent); }
.project-all { color: var(--muted); border-top: 1px solid var(--border); border-radius: 0 0 7px 7px; margin-top: 2px; }
.danger-zone > summary { cursor: pointer; color: var(--bad); width: fit-content; }
.danger-zone[open] > summary { margin-bottom: 10px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a, .nav-soon {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text);
}
.sidebar nav a:hover, .sidebar nav a.active { background: var(--hover); }
.sidebar nav a.active { font-weight: 600; }
.nav-soon { color: var(--muted); }
.nav-soon::after { content: "скоро"; margin-left: auto; font-size: 11px; }
.nav-group { padding: 14px 10px 4px; color: var(--muted); font-size: 12px; }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: 56px; padding: 8px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1 1 auto; font-weight: 600; font-size: 15px; }
.topbar form { margin: 0; }
.content { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.notice { padding: 14px 16px; }
/* Public status page (/s/<slug>) */
.status-page { max-width: 860px; margin: 0 auto; padding: 32px 16px 48px; display: flex; flex-direction: column; gap: 16px; }
.status-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.status-title { margin: 0 0 4px; font-size: 26px; font-weight: 600; }
.status-top .muted { margin: 0; }
.status-banner { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-radius: 12px; font-size: 18px; font-weight: 600; }
.status-banner-good { background: var(--good-bg); color: var(--good); }
.status-banner-warn { background: var(--warn-bg); color: var(--warn); }
.status-banner-bad { background: var(--bad-bg); color: var(--bad); }
.status-banner-muted { background: var(--hover); color: var(--muted); }
.status-maint { border-color: var(--warn); }
.status-service { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.status-service:last-of-type { border-bottom: 0; }
.status-service-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status-name { flex: 1; font-weight: 500; min-width: 0; }
.uptime-bars-thin { height: 24px; }
.status-axis { padding: 0 16px 12px; }
.status-history { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.status-history li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.status-foot { text-align: center; }
.status-incident-bad { border-color: var(--bad); }
.status-incident-warn, .status-incident-edit.is-open { border-color: var(--warn); }
.status-updates { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.status-updates div { white-space: pre-line; }
.status-past > summary { cursor: pointer; padding: 4px 0; }
.maint-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn); font-size: 13px; white-space: nowrap; }
.maint-badge:hover { color: var(--warn); text-decoration: underline; }
.verify-hint { margin: 0; padding: 8px 12px; border: 1px dashed var(--border); border-radius: 8px; }
.site-hint { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.empty { margin: 0; padding: 16px; }
.rows .row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.rows .row:last-child { border-bottom: 0; }
.row-sel { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); }
.row-sel:last-child { border-bottom: 0; }
.rows .row-sel .row { flex: 1; min-width: 0; border-bottom: 0; }
.bulk-label { display: flex; align-items: center; padding: 0 0 0 14px; cursor: pointer; }
.bulk-bar { display: none; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 16px;
  position: sticky; bottom: 12px; z-index: 5; box-shadow: 0 12px 32px var(--shadow); }
body:has(.bulk-check:checked) .bulk-bar { display: flex; }
.mw-targets { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 0; }
.mw-targets legend { padding: 0 6px; font-weight: 500; }
.mw-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.mw-lists .chk { display: flex; gap: 6px; padding: 2px 0; }
.bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-main { flex: 1 1 220px; min-width: 0; }
.row-seen { width: 130px; text-align: right; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-good { background: var(--good); }
.dot-bad { background: var(--bad); border-radius: 2px; }
.dot-muted { border: 2px solid var(--muted); }
.status { padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.status-good { background: var(--good-bg); color: var(--good); }
.status-bad { background: var(--bad-bg); color: var(--bad); }
.status-muted { background: var(--hover); color: var(--muted); }

/* Cabinet pages */
.page-title { margin: 0; font-size: 24px; font-weight: 600; }
.rename .page-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.rename-btn { display: inline-flex; padding: 5px; border: 0; border-radius: 6px; background: none; color: var(--muted);
  cursor: pointer; opacity: 0; transition: opacity .15s; }
.rename:hover .rename-btn, .rename-btn:focus-visible { opacity: 1; }
.rename-btn:hover { color: var(--text); background: var(--hover); }
@media (hover: none) { .rename-btn { opacity: 1; } }
.rename-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rename-form[hidden], .rename .page-title[hidden] { display: none; }
.rename-input { flex: 1 1 260px; max-width: 520px; min-width: 0; font-size: 20px; font-weight: 600; padding: 4px 10px; }
.text-good { color: var(--good); }
.text-muted { color: var(--muted); }
.report-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.report-toggle input { pointer-events: none; }
.text-bad { color: var(--bad); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.tile { padding: 16px; }
.tile-num { margin-top: 6px; font-size: 28px; font-weight: 600; }
.tile-num .muted { font-size: 15px; font-weight: 500; }
.card-bad { border-color: var(--bad); }
.card-head-split { display: flex; justify-content: space-between; align-items: center; }
.row-link { color: var(--text); }
.row-link:hover { background: var(--hover); color: var(--text); }
.row-nums { display: flex; gap: 22px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; min-width: 560px; border-collapse: collapse; }
.table th {
  padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 500; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }

.server-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.server-icon {
  width: 48px; height: 48px; flex: none; border: 1px solid var(--border); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.server-title { flex: 1 1 280px; min-width: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--card); }
.segmented a { min-height: 30px; padding: 4px 12px; border-radius: 6px; color: var(--muted); }
.segmented a.active { background: var(--hover); color: var(--text); font-weight: 600; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.chart-card { padding: 14px 16px; min-width: 0; }
.chart-title { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.chart { min-height: 180px; }
.chart-empty { margin: 0; padding-top: 70px; text-align: center; }
.chart .u-legend { color: var(--muted); font-size: 12px; }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.kv { padding: 4px 16px; }
.kv .empty { padding: 12px 0; }
.kv-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: 0; }

/* Step 4: forms and actions inside the cabinet */
.pad { padding: 18px 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > p { margin: 0; }
.narrow { max-width: 760px; }
.section-title { margin: 0; font-size: 16px; font-weight: 600; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.page-head p { margin: 6px 0 0; }
.flash { margin: 0; padding: 10px 14px; border-radius: 8px; background: var(--good-bg); color: var(--good); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions form { margin: 0; }
.btn-danger { color: var(--bad); }
.command { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.command pre {
  flex: 1 1 400px; min-width: 0; margin: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); font-size: 13px; white-space: pre-wrap; word-break: break-all;
}
.hints { margin: 0; padding-left: 18px; line-height: 1.7; }
.waiting-box { margin: 0; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 8px; }
.cron-cmd { display: block; margin-top: 6px; word-break: break-all; color: var(--muted); }
.inline-form { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0; }
.inline-form .btn { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1 1 260px; }
.field label { margin: 0; font-weight: 500; }
.field input {
  min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
/* Inputs line up along the bottom even when a label wraps to two lines */
.threshold-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; align-items: end; }
.threshold-grid label { font-size: 13px; color: var(--muted); font-weight: 400; }
.field select {
  min-height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
.field textarea {
  min-height: 88px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; resize: vertical;
  background: var(--bg); color: var(--text); font: inherit; line-height: 1.45;
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; }

/* "Что мониторить" */
.opt {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 46px; padding: 6px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.opt:last-child { border-bottom: 0; }
.opt input { width: 18px; height: 18px; accent-color: var(--accent); }
.pill { margin-left: auto; padding: 2px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); font-size: 12px; }
.pill-accent { background: var(--accent-bg); color: var(--accent); }
.opt-more { border-top: 1px solid var(--border); }
.opt-more summary { padding: 12px 16px; color: var(--accent); cursor: pointer; }
.opt-more .opt { padding-left: 32px; }

/* "О системе" */
.sysinfo summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.sysinfo summary::-webkit-details-marker { display: none; }
.sysinfo summary::after { content: "▾"; color: var(--muted); }
.sysinfo[open] summary::after { content: "▴"; }
.sysinfo:not([open]) summary { border-bottom: 0; }
.sysinfo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 20px; padding: 16px; }

/* Chart hover popup — lives inside uPlot's .u-over, which uPlot itself positions absolutely
   (overriding that position moves the cursor layer out from on top of the plot) */
.chart-tip {
  position: absolute; z-index: 10; pointer-events: none; min-width: 150px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25); font-size: 12px; white-space: nowrap;
}
.chart-tip-time { margin-bottom: 6px; color: var(--muted); }
.chart-tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.chart-tip-row b { margin-left: auto; padding-left: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tip-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chart-tip-dash { width: 10px; border-top: 1px dashed var(--bad); flex: none; }
.chart-tip-threshold { color: var(--muted); }

/* Server page: tabs */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 10px 0; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tab-count { padding: 0 6px; border-radius: 999px; background: var(--bad-bg); color: var(--bad); font-size: 12px; font-weight: 600; }

/* Problems pinned on top */
.problems .problem-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.problems .problem-row:first-of-type { border-top: 0; }
.problem-text { flex: 1 1 280px; }

/* Draggable overview blocks */
.blocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.block-wide { grid-column: 1 / -1; }
.block { min-width: 0; }
.block-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px 0; }
.block-head .chart-title { margin: 0; }
.chart-card .block-head { padding: 0 0 8px; }
.block-body { padding: 12px 16px 16px; }
.push-right { margin-left: auto; }
.drag-handle {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-left: -6px;
  border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: grab; opacity: .55;
}
.block:hover .drag-handle, .drag-handle:focus-visible { opacity: 1; }
.drag-handle:hover { background: var(--hover); }
.block-ghost { opacity: .35; }
.layout-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
form.inline { display: inline; margin: 0; }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; }
.link-btn:hover { color: var(--text); }
.sysinfo summary.block-head { padding-bottom: 12px; }
.sysinfo[open] summary.block-head { border-bottom: 1px solid var(--border); }

/* Current values */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat-tile { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.stat-value { margin-top: 2px; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-warn { border-color: var(--warn); background: var(--warn-bg); }
.stat-warn .stat-value { color: var(--warn); }
.stat-bad { border-color: var(--bad); background: var(--bad-bg); }
.stat-bad .stat-value { color: var(--bad); }

/* Services summary */
.services-ok summary { padding: 9px 0; cursor: pointer; }
.services-ok[open] summary { border-bottom: 1px solid var(--border); }

/* "Заглушить" menu */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 250px; padding: 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card); box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  display: flex; flex-direction: column; gap: 2px;
}
.menu-pop p { margin: 0 0 6px; }
.menu-item { padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--hover); }
.muted-badge { display: flex; align-items: center; gap: 10px; margin: 0; padding: 5px 12px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }

/* Notifications */
.chk { display: flex; align-items: center; gap: 10px; min-height: 32px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }
.indent { padding-left: 28px; }
.btn-on { border-color: var(--good); color: var(--good); }
.rows .row form.inline { flex: none; }
.segmented button { min-height: 30px; padding: 4px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.segmented button.active { background: var(--hover); color: var(--text); font-weight: 600; }
.install-bar .card-head-split { padding: 0; border: 0; }

/* Cron checks: settings rows (label left, control right), mode switch, last 24 h bars */
.status-warn { background: var(--warn-bg); color: var(--warn); }
.dot-warn { background: var(--warn); }
.cron-form { display: flex; flex-direction: column; gap: 18px; }
.cron-form-top { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.cron-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.cron-form .field input, .cron-form .field select { width: 100%; min-width: 0; }
.cron-form .label { font-weight: 500; }
.cron-form .field-hint { color: var(--muted); font-size: 12px; }
.cron-form .pair { display: flex; gap: 8px; }
.cron-form .pair input { flex: 1; }
.cron-form .pair select { flex: 0 0 76px; }
.cron-form .segmented { min-height: 40px; align-items: center; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.cron-form .form-error { margin: 0; }
.segmented label { min-height: 32px; padding: 4px 14px; border-radius: 6px; color: var(--muted); cursor: pointer; display: flex; align-items: center; }
.segmented label input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--hover); color: var(--text); font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.cron-form:has(input[name="mode"][value="cron"]:checked) .only-simple,
.cron-form:has(input[name="mode"][value="simple"]:checked) .only-cron { display: none; }
.tag { padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; font-family: ui-monospace, monospace; font-size: 12px; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.swatch-good, .ping-ok { background: var(--good); }
.swatch-warn, .ping-start { background: var(--warn); }
.ping-bars { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.ping-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; border-bottom: 1px solid var(--border); }
.ping-fill { width: 100%; display: flex; flex-direction: column; border-radius: 3px 3px 0 0; overflow: hidden; min-height: 4px; }
.ping-axis { position: relative; height: 18px; }
.ping-axis span { position: absolute; top: 0; }

/* Servers: address · hostname · agent version; the "new agent" bar */
.row-meta { display: flex; flex-wrap: wrap; gap: 0 10px; }
.text-warn { color: var(--warn); }
.update-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  border-color: var(--warn); background: var(--warn-bg); }
.update-bar > div { flex: 1 1 400px; }
.copyable { display: inline-flex; align-items: center; gap: 4px; }
.copy-btn { display: inline-flex; padding: 2px; border-radius: 4px; color: var(--muted); cursor: pointer; opacity: .7; }
.copy-btn:hover, .copy-btn:focus-visible { opacity: 1; color: var(--text); background: var(--hover); }
.copy-btn.copied { opacity: 1; color: var(--good); }
.addr-list { display: flex; flex-wrap: wrap; gap: 2px 12px; }

/* Monitors: Hyperping-style form sections, list toolbar, the monitor page */
.monitor-form { display: flex; flex-direction: column; gap: 22px; margin-top: 8px; }
.sect { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 12px 28px; }
.sect-head h2 { margin: 0 0 4px; font-size: 15px; }
.sect-head p { margin: 0; }
.sect-body { display: flex; flex-direction: column; }
.sect-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); }
.sect-row:last-child { border-bottom: 0; }
.sect-row > div:first-child { flex: 1 1 240px; }
.sect-row-stack { flex-direction: column; align-items: stretch; }
.sect-row input:not([type=radio]):not([type=checkbox]), .sect-row select {
  min-height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; }
.sect-row > input:not([type=checkbox]), .sect-row > select { flex: 0 1 320px; min-width: 0; width: 100%; }
.sect-row .pair { display: flex; gap: 8px; flex: 0 1 420px; min-width: 0; }
.sect-row-stack .pair { flex: 1 1 auto; }
.sect-row .pair input { flex: 1; min-width: 0; }
.sect-row .pair select.method { flex: 0 0 90px; }
.chk-row { cursor: pointer; }
.switch { width: 38px; height: 22px; accent-color: var(--accent); flex: none; }
.monitor-form:not(:has(input[name="kind"][value="http"]:checked)) .only-http,
.monitor-form:not(:has(input[name="kind"][value="tcp"]:checked)) .only-tcp,
.monitor-form:not(:has(input[name="kind"][value="ping"]:checked)) .only-ping,
.monitor-form:not(:has(input[name="kind"][value="dns"]:checked)) .only-dns,
.monitor-form:has(input[name="kind"][value="dns"]:checked) .not-dns { display: none; }
.monitor-form:not(:has(.status-preset option[value="custom"]:checked)) .status-custom { display: none; }
.form-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px;
  position: sticky; bottom: 12px; z-index: 5; box-shadow: 0 12px 32px var(--shadow); }
.form-bar .test-result { flex: 1 1 300px; }
.test-result.htmx-request { opacity: .5; }
@media (max-width: 760px) { .sect { grid-template-columns: 1fr; } }

.list-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.list-toolbar input[type=search] { flex: 1 1 260px; min-height: 36px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--card); color: var(--text); font: inherit; }
.segmented a .dot { display: inline-block; vertical-align: middle; margin-right: 4px; }

.monitor-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.pill { padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; }
.pill-bad { border-color: var(--bad); color: var(--bad); }
.metric-avg { margin-left: 8px; font-size: 13px; font-weight: 500; }
.uptime-bars { display: flex; gap: 2px; height: 34px; }
.uptime-bar { flex: 1; border-radius: 2px; }
.uptime-good { background: var(--good); }
.uptime-warn { background: var(--warn); }
.uptime-bad { background: var(--bad); }
.uptime-none, .swatch-none { background: var(--hover); }
.swatch-bad { background: var(--bad); }
.uptime-axis { display: flex; justify-content: space-between; }
.monitor-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.monitor-grid .stat-tiles { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1000px) { .monitor-grid { grid-template-columns: 1fr; } }
.server-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.server-title .status { font-size: 13px; vertical-align: middle; margin-left: 6px; }

/* "Что мониторить": warn while no disk is checked */
.disk-warning { margin: 10px 16px; }
.monitoring-form section:has(input[name="disk"]:checked) .disk-warning { display: none; }

/* "?" next to a tile label: how the value is measured (title on hover / focus) */
.hint { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; margin-left: 3px;
  border: 1px solid var(--border); border-radius: 50%; font-size: 10px; line-height: 1; cursor: help; vertical-align: 1px; }
.hint:hover, .hint:focus-visible { color: var(--text); border-color: var(--muted); }
.live-region { display: flex; flex-direction: column; gap: 16px; }

/* Theme button: the icon of the current mode */
.theme-btn .ti { display: none; }
html[data-theme-mode="system"] .theme-btn .ti-system, html[data-theme-mode="light"] .theme-btn .ti-light,
html[data-theme-mode="dark"] .theme-btn .ti-dark { display: block; }
.push-right { margin-left: auto; }

/* Incident journal and page */
.list-toolbar select { min-height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); font: inherit; }
.incident-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 12px; }
.incident-card { border-color: var(--bad); }
.incident-card-main { display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: var(--text); }
.incident-card-main:hover { background: var(--hover); color: var(--text); }
.incident-title { flex: 1; min-width: 0; font-weight: 600; }
.incident-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 14px;
  border-top: 1px solid var(--border); }
.btn-small { min-height: 28px; padding: 2px 10px; font-size: 13px; }
.incident-day { display: flex; flex-direction: column; gap: 8px; }
.day-title { margin: 6px 0 0; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.incident-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .incident-layout { grid-template-columns: 1fr; } }
.incident-side .facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.incident-side dt { color: var(--muted); }
.incident-side dd { margin: 0; }
.btn-block { width: 100%; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 128px 14px 1fr; gap: 10px; padding: 6px 0; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 134px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.timeline li:first-child::before { top: 14px; }
.timeline li:last-child::before { bottom: calc(100% - 14px); }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; background: var(--muted); position: relative; z-index: 1; justify-self: center; }
.tl-opened .tl-dot { background: var(--bad); }
.tl-resolved .tl-dot { background: var(--good); }
.tl-acked .tl-dot, .tl-muted .tl-dot { background: var(--accent); }
.tl-not_sent .tl-dot { background: var(--warn); }
@media (max-width: 600px) { .timeline li { grid-template-columns: 1fr; } .timeline li::before, .tl-dot { display: none; } }

/* Severity per problem type */
.severity-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 310px); gap: 8px 16px; align-items: center; }
.severity-grid select { min-height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; }
@media (max-width: 560px) { .severity-grid { grid-template-columns: 1fr; } }
.sev { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.sev-critical { background: var(--bad-bg); color: var(--bad); }
.sev-major { background: var(--warn-bg); color: var(--warn); }
.sev-minor { background: var(--hover); color: var(--muted); }
.severity-form .field select { width: 100%; }
.tl-severity .tl-dot { background: var(--warn); }

/* Status page settings: several services at once */
.pick-all { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.pick-group { margin-bottom: 2px; }
/* A service row: name field and its «Сохранить» on one line, the order buttons beside */
.svc-rename { flex: 1 1 auto; flex-wrap: nowrap; min-width: 0; }
.svc-rename .field { flex: 1 1 0; min-width: 0; }
.svc-rename .field input { width: 100%; }
@media (max-width: 560px) { .svc-rename { flex-wrap: wrap; } }
.role-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.invite-created { padding: 12px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-bg); }
.row select { min-height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; }
.project-owner { display: block; color: var(--muted); font-size: 12px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.pill-group { margin-left: 6px; vertical-align: 1px; }
.bulk-actions input[name=group] { min-height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; width: 220px; max-width: 100%; }
.list-toolbar select[name=group] { min-height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; }
/* Escalation steps: one row each; the targets follow the chosen kind */
.esc-steps { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.esc-step { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border); }
.esc-step:last-child { border-bottom: 0; }
.esc-num { align-self: center; width: 16px; }
.esc-channels { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 4px 16px; padding-left: 28px; }
.esc-step:not(:has(option[value=channels]:checked)) .esc-channels { display: none; }
.esc-step:not(:has(option[value=sms]:checked)):not(:has(option[value=call]:checked)) .esc-phones { display: none; }
/* Only one empty step shows: the next one appears once it's chosen */
.esc-step:has(option[value=""]:checked) ~ .esc-step:has(option[value=""]:checked) { display: none; }
/* «Что мониторить» → «Логи»: one pattern per row */
.log-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.log-row .field.grow { flex: 1 1 200px; min-width: 0; }
.log-row .field.grow input { width: 100%; }
.log-row .chk { min-height: 40px; }
.log-seen { flex: 1 1 100%; }
.card-head.flush { padding: 0; border: 0; }


/* --- Deep violet: brand touches and motion --- */
.btn-primary { color: var(--btn-fg); background: var(--brand-gradient); background-size: 140% 100%; background-position: 0 0; }
.btn-primary:hover { background: var(--brand-gradient); background-size: 140% 100%; background-position: 100% 0; opacity: 1; }
.brand svg { color: var(--accent); }
.sidebar nav a { position: relative; }
.sidebar nav a::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent); transform: scaleY(0);
}
.sidebar nav a.active::before { transform: scaleY(1); }
.sidebar nav a.active { background: var(--accent-bg); }
.sidebar nav a.active svg { color: var(--accent); }
.dot-good { box-shadow: 0 0 0 3px var(--good-bg); }
.dot-warn { background: var(--warn); }
/* The login pages: a slow violet glow behind the card */
.auth { position: relative; overflow: hidden; isolation: isolate; }
.auth::before, .auth::after {
  content: ""; position: absolute; z-index: -1; width: 520px; height: 520px; border-radius: 50%;
  filter: blur(90px); opacity: .45; pointer-events: none;
}
.auth::before { background: #693BDB; top: -160px; left: -120px; }
.auth::after { background: #A477FF; bottom: -200px; right: -140px; opacity: .3; }
:root[data-theme="light"] .auth::before { opacity: .22; }
:root[data-theme="light"] .auth::after { opacity: .18; }
.auth-card { box-shadow: 0 24px 64px var(--shadow); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes pulse-bad { 0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, .55); } 70%, 100% { box-shadow: 0 0 0 7px rgba(248, 113, 113, 0); } }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(60px, 40px) scale(1.12); } }

@media (prefers-reduced-motion: no-preference) {
  .btn, .icon-btn, .sidebar nav a, .project-item, .row-link, .tabs a, .copy-btn, .chk-row,
  .field input, .field select, .field textarea, .form input, .card, .status, .uptime-bar {
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease,
                transform .18s ease, opacity .18s ease;
  }
  .btn:active, .icon-btn:active { transform: scale(.97); }
  .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px var(--glow); }
  .btn-primary:active { transform: translateY(0) scale(.98); box-shadow: none; }
  .sidebar nav a::before { transition: transform .22s cubic-bezier(.2, .7, .2, 1); }
  .sidebar nav a:hover::before { transform: scaleY(.5); }
  .sidebar nav a.active:hover::before { transform: scaleY(1); }
  .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .form input:focus {
    box-shadow: 0 0 0 4px var(--accent-bg);
  }
  .uptime-bar:hover { transform: scaleY(1.12); }
  /* Only where it means "broken now": not the filter chips' legend */
  .row .dot-bad, .server-icon .dot-bad, .status-banner .dot-bad { animation: pulse-bad 1.8s ease-out infinite; }
  .btn-primary { transition: background-position .4s ease, transform .18s ease, box-shadow .18s ease; }
  .flash, .form-error { animation: pop .3s ease both; }
  .project-switch[open] .project-menu { animation: pop .16s ease both; }
  .auth::before { animation: drift 18s ease-in-out infinite alternate; }
  .auth::after { animation: drift 22s ease-in-out infinite alternate-reverse; }
  .auth-card { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
  /* Only on arrival (base.html sets .entering for a moment): live updates every 15 s must not replay it */
  .entering .content > * { animation: rise .42s cubic-bezier(.2, .7, .2, 1) both; }
  .entering .content > :nth-child(2) { animation-delay: .04s; }
  .entering .content > :nth-child(3) { animation-delay: .08s; }
  .entering .content > :nth-child(4) { animation-delay: .12s; }
  .entering .content > :nth-child(5) { animation-delay: .16s; }
  .entering .content > :nth-child(n+6) { animation-delay: .2s; }
  .entering .status-page > * { animation: rise .42s cubic-bezier(.2, .7, .2, 1) both; }
  .entering .uptime-bar { transform-origin: bottom; animation: grow .5s cubic-bezier(.2, .7, .2, 1) both; }
  .entering .uptime-bar:nth-child(3n+1) { animation-delay: .05s; }
  .entering .uptime-bar:nth-child(3n+2) { animation-delay: .1s; }
  .entering .uptime-bar:nth-child(3n) { animation-delay: .15s; }
  .entering .sidebar { animation: fade .3s ease both; }
  /* Switching the theme: colours fade instead of snapping */
  .theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
    transition: background-color .3s ease, border-color .3s ease, color .3s ease, fill .3s ease !important;
  }
}

/* Section icons: a gradient tile before each section's page title (the drawing comes from _icons.html) */
.has-section-icon .page-title { display: flex; align-items: center; gap: 12px; }
.has-section-icon .page-title::before {
  content: ""; flex: none; width: 36px; height: 36px; border-radius: 10px;
  background-repeat: no-repeat; background-position: center, 0 0; background-size: 20px 20px, 100% 100%;
  box-shadow: 0 4px 12px var(--glow);
}
.tile-head { display: flex; align-items: center; gap: 8px; }
.tile-icon {
  width: 28px; height: 28px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: var(--hover); color: var(--muted);
}
.tile-icon-bad { background: var(--bad-bg); color: var(--bad); }
.brand svg { color: #fff; padding: 5px; width: 30px; height: 30px; border-radius: 9px; background: var(--brand-gradient); }
.account-badge { background: var(--brand-gradient); color: #fff; }
/* A faint violet aura at the top of the working area */
.main { background: radial-gradient(900px 420px at 30% -120px, var(--aura), transparent 70%) no-repeat; }

/* Living status (app.js initLiveStatus): what changed since the last refresh */
@keyframes beat { 0% { box-shadow: 0 0 0 0 var(--good); } 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes alarm { 0%, 30% { background-color: var(--bad-bg); box-shadow: inset 3px 0 0 var(--bad); } 100% { background-color: transparent; box-shadow: inset 3px 0 0 transparent; } }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes tilt-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .dot.live-beat { animation: beat .9s ease-out; }
  .dot-bad.live-beat { animation: pulse-bad 1.8s ease-out infinite; }
  .live-alarm { animation: alarm 2.4s ease-out; }
  .row.live-recover, .server-icon.live-recover { position: relative; overflow: hidden; }
  .live-recover::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--good-bg), rgba(52, 211, 153, .28), var(--good-bg), transparent);
    animation: sweep 1.4s ease-in-out;
  }
  [data-num] { transition: color .4s ease; }
  .num-up, .num-down { color: var(--accent); }
  .tile-icon { transition: transform .25s cubic-bezier(.2, .7, .2, 1); }
  .tile:hover .tile-icon { transform: scale(1.1) rotate(-6deg); }
  .tile:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
  .has-section-icon .page-title::before { transition: transform .3s cubic-bezier(.2, .7, .2, 1); }
  .page-head:hover .page-title::before, .page-title:hover::before { transform: rotate(-6deg) scale(1.05); }
  .entering .has-section-icon .page-title::before { animation: tilt-in .5s cubic-bezier(.2, .7, .2, 1) both .05s; }
}

/* Login through Yandex ID / GitHub (oauth.py) */
.provider-list { display: flex; flex-direction: column; gap: 8px; }
.btn-provider { font-weight: 600; }
.provider-mark { width: 28px; height: 28px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: var(--hover); }

/* Two-step login (twofactor.py) */
.twofactor-setup { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.twofactor-setup > .stack { flex: 1 1 320px; min-width: 0; }
.twofactor-qr { flex: none; padding: 8px; border-radius: 12px; background: #FFFFFF; line-height: 0; }
.twofactor-actions { display: flex; flex-direction: column; gap: 12px; }
.code-input { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.recovery-codes { columns: 2; column-gap: 32px; line-height: 1.9; }

/* Public documentation (/docs, web_docs.py) */
.docs-shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.docs-nav { flex: 1 1 240px; max-width: 280px; padding: 20px 12px; border-right: 1px solid var(--border); background: var(--panel);
  display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; align-self: flex-start; min-height: 100vh; }
.docs-brand { margin: 0 8px; }
.docs-nav nav { display: flex; flex-direction: column; gap: 2px; }
.docs-nav nav a { padding: 7px 10px; border-radius: 8px; color: var(--text); }
.docs-nav nav a:hover { background: var(--hover); }
.docs-nav nav a.active { background: var(--accent-bg); color: var(--text); font-weight: 600; }
.docs-cabinet { margin: 8px; }
.docs-main { flex: 999 1 560px; min-width: 0; padding: 16px 32px 64px; background: radial-gradient(900px 420px at 30% -120px, var(--aura), transparent 70%) no-repeat; }
.docs-top { display: flex; justify-content: flex-end; }
.docs-body { max-width: 820px; margin: 0 auto; font-size: 15px; line-height: 1.65; }
.docs-body h1 { font-size: 30px; margin: 8px 0 12px; }
.docs-body h2 { font-size: 20px; margin: 36px 0 8px; padding-top: 8px; }
.docs-body h1 + p { color: var(--muted); font-size: 16px; }
.docs-body p, .docs-body ul, .docs-body ol { margin: 0 0 12px; }
.docs-body li { margin: 4px 0; }
.docs-body code { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  padding: 1px 6px; border-radius: 6px; background: var(--hover); }
.docs-body pre { margin: 0 0 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); overflow-x: auto; }
.docs-body pre code { padding: 0; background: none; font-size: 13px; line-height: 1.55; }
.docs-body table { width: 100%; border-collapse: collapse; margin: 4px 0 18px; font-size: 14px; display: block; overflow-x: auto; }
.docs-body th, .docs-body td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.docs-body th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.docs-figure { margin: 8px 0 16px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.docs-diagram { width: 100%; height: auto; display: block; }
.docs-diagram .dg-ink { fill: var(--text); }
.docs-diagram .dg-quiet { fill: var(--muted); }
.docs-diagram .dg-line { stroke: var(--muted); }
.docs-diagram .dg-head { fill: var(--muted); }
.docs-diagram .dg-box { fill: none; stroke: var(--border); stroke-width: 1.25; }
.docs-diagram .dg-main { fill: var(--accent-bg); stroke: var(--accent); stroke-width: 2; }
.docs-pager { max-width: 820px; margin: 40px auto 0; display: flex; justify-content: space-between; gap: 16px; }
.docs-pager a { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-weight: 600; min-width: 200px; }
.docs-pager a:hover { border-color: var(--accent); }
.docs-next { text-align: right; margin-left: auto; }
@media (max-width: 760px) {
  .docs-nav { position: static; max-width: none; min-height: 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .docs-nav nav { flex-direction: row; flex-wrap: wrap; }
  .docs-main { padding: 16px; }
  .docs-pager a { min-width: 0; flex: 1; }
}

/* Landing (/ for visitors, templates/landing.html; motion in static/landing.js) */
.landing { position: relative; min-height: 100vh; overflow-x: hidden;
  background: radial-gradient(1100px 560px at 70% -180px, var(--aura), transparent 70%),
              radial-gradient(700px 420px at 0% 30%, color-mix(in srgb, var(--aura) 70%, transparent), transparent 70%); background-repeat: no-repeat; }
.lp-fleet { position: relative; }
.lp-pulse { position: absolute; left: -24px; width: calc(100% + 48px); top: 50%; height: 120px; transform: translateY(-58%);
  z-index: 0; pointer-events: none; opacity: .7; }
.lp-pulse path { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  stroke-dasharray: 340 1300; stroke-dashoffset: 1640; }
.lp-top { position: relative; z-index: 2; max-width: 1180px; margin: 0 auto; padding: 16px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.lp-brand { margin: 0; }
.lp-links { display: flex; flex-wrap: wrap; gap: 20px; flex: 1; }
.lp-links a { color: var(--muted); }
.lp-links a:hover { color: var(--text); }
.lp-actions { display: flex; align-items: center; gap: 8px; }
.landing main { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.lp-hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 48px; align-items: center; padding: 64px 0 40px; }
.lp-badge { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 20px; padding: 5px 12px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent); font-size: 13px; font-weight: 600; }
.lp-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.lp-hero h1 { font-size: clamp(32px, 4.6vw, 54px); line-height: 1.08; margin: 0 0 20px; letter-spacing: -.02em; }
.lp-accent { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: brightness(1.5) saturate(1.2); }
:root[data-theme="light"] .lp-accent { filter: none; }
.lp-lead { font-size: 18px; line-height: 1.6; color: var(--muted); margin: 0 0 28px; max-width: 620px; }
.lp-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.lp-big { min-height: 48px; padding: 0 24px; font-size: 15px; }
.lp-install { max-width: 620px; }
.lp-install pre { min-height: 3.2em; }
.lp-note { margin: 12px 0 0; max-width: 620px; }
.lp-typing-cursor::after { content: "▋"; margin-left: 1px; color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* the demo chat */
.lp-demo { perspective: 1200px; }
.lp-chat { border: 1px solid var(--border); border-radius: 18px; background: var(--card); overflow: hidden;
  box-shadow: 0 30px 80px var(--shadow), 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent);
  transform: rotateY(-8deg) rotateX(3deg); transform-origin: left center; }
.lp-chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel); }
.lp-chat-head div { display: flex; flex-direction: column; line-height: 1.25; }
.lp-chat-avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-gradient); color: #fff; }
.lp-chat-body { height: 330px; padding: 16px; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; overflow: hidden;
  background: radial-gradient(circle at 20% 10%, var(--accent-bg), transparent 60%); }
.lp-bubble { max-width: 92%; padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: var(--panel); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; line-height: 1.45; }
.lp-bubble b { font-size: 14px; }
.lp-bad { border-left: 3px solid var(--bad); }
.lp-warn { border-left: 3px solid var(--warn); }
.lp-good { border-left: 3px solid var(--good); }
.lp-note-msg { align-self: center; max-width: none; padding: 4px 12px; border-radius: 999px; background: var(--accent-bg);
  color: var(--accent); border: 0; font-size: 12.5px; font-weight: 600; }
.lp-bbtn { display: flex; gap: 6px; margin-top: 8px; }
.lp-bbtn span { flex: 1; text-align: center; padding: 5px 8px; border-radius: 8px; background: var(--hover); font-size: 12.5px; }
.lp-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--border); }
.lp-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typing 1s infinite ease-in-out; }
.lp-typing i:nth-child(2) { animation-delay: .15s; }
.lp-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes bubble-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.lp-bubble-new { animation: bubble-in .45s cubic-bezier(.2, .8, .2, 1) both; }
.lp-bubble-old { transition: opacity .35s ease, transform .35s ease; opacity: 0; transform: translateY(-10px); }

/* the fleet */
.lp-fleet { padding: 8px 0 40px; }
.lp-fleet-row { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.lp-node { position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.lp-node b { flex: 1; font-size: 13.5px; font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
.lp-node .mono { color: var(--muted); font-size: 13px; }

.lp-section { padding: 64px 0; border-top: 1px solid var(--border); }
.lp-section h2, .lp-final h2 { font-size: clamp(24px, 3.2vw, 34px); margin: 0 0 32px; text-align: center; letter-spacing: -.01em; }
.lp-alert-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; max-width: 920px; margin: 0 auto; }
.lp-alert { padding: 18px 20px; border: 1px solid var(--accent); border-radius: 14px; background: var(--card); box-shadow: 0 16px 40px var(--shadow); }
.lp-alert-plain { border-color: var(--border); box-shadow: none; opacity: .8; }
.lp-alert p { margin: 0 0 8px; }
.lp-msg { line-height: 1.6; }
.lp-guess { font-style: italic; margin-top: 14px !important; }
.lp-buttons { display: flex; gap: 8px; }
.lp-buttons span { padding: 6px 12px; border-radius: 8px; background: var(--hover); font-size: 13px; }
.lp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.lp-card { position: relative; overflow: hidden; padding: 22px; border: 1px solid var(--border); border-radius: 16px; background: var(--card); }
.lp-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), var(--accent-bg), transparent 70%); transition: opacity .3s ease; }
.lp-card:hover::before { opacity: 1; }
.lp-card > * { position: relative; }
.lp-card h3 { margin: 14px 0 8px; font-size: 17px; }
.lp-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.lp-steps { list-style: none; max-width: 980px; margin: 0 auto 32px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.lp-steps li { display: flex; gap: 14px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
.lp-steps p { margin: 4px 0 0; color: var(--muted); }
.lp-step-n { flex: none; width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-gradient); color: #fff; font-weight: 700; }
#how .docs-figure, #how .lp-note { max-width: 920px; margin-left: auto; margin-right: auto; }
#how .lp-note { text-align: center; }
.dg-flow circle { fill: var(--accent); }
.lp-faq { max-width: 760px; margin: 0 auto 10px; padding: 14px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.lp-faq summary { cursor: pointer; font-weight: 600; }
.lp-faq p { margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
.lp-final { margin: 0 auto 48px; padding: 56px 24px; text-align: center; border-radius: 24px; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  background: radial-gradient(600px 240px at 50% 0%, var(--accent-bg), transparent 80%), var(--card); }
.lp-final h2 { margin-bottom: 8px; }
.lp-final p { margin: 0 0 24px; }
.lp-foot { max-width: 1180px; margin: 0 auto; padding: 24px; display: flex; flex-wrap: wrap; gap: 20px; border-top: 1px solid var(--border); }
.lp-foot span { margin-right: auto; }
.lp-node.live-recover { position: relative; overflow: hidden; }

@media (prefers-reduced-motion: no-preference) {
  .lp-pulse path { animation: pulse-run 6s linear infinite; }
  @keyframes pulse-run { to { stroke-dashoffset: 0; } }
  .lp-live-dot { animation: live 2s ease-out infinite; }
  @keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }
  .lp-chat { transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
  .lp-demo:hover .lp-chat { transform: rotateY(0) rotateX(0); }
  .entering .lp-chat { animation: chat-in .9s cubic-bezier(.2, .7, .2, 1) both .15s; }
  @keyframes chat-in { from { opacity: 0; transform: rotateY(-24deg) rotateX(6deg) translateX(40px); } }
  .reveal-wait { opacity: 0; transform: translateY(24px); transition: opacity .6s cubic-bezier(.2, .7, .2, 1), transform .6s cubic-bezier(.2, .7, .2, 1); }
  .reveal-wait.reveal-in { opacity: 1; transform: none; }
  .lp-card { transition: transform .3s cubic-bezier(.2, .7, .2, 1), border-color .3s ease, box-shadow .3s ease, opacity .6s ease; }
  .lp-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: 0 16px 36px var(--shadow); }
  .lp-card:hover .tile-icon { transform: scale(1.12) rotate(-6deg); }
  .lp-node { transition: border-color .4s ease; }
  .lp-node.live-alarm { border-color: var(--bad); }
  .entering .lp-hero-copy > * { animation: rise .55s cubic-bezier(.2, .7, .2, 1) both; }
  .entering .lp-hero-copy > :nth-child(2) { animation-delay: .06s; }
  .entering .lp-hero-copy > :nth-child(3) { animation-delay: .12s; }
  .entering .lp-hero-copy > :nth-child(n+4) { animation-delay: .18s; }
}
@media (prefers-reduced-motion: reduce) { .dg-flow { display: none; } }
@media (max-width: 900px) {
  .lp-hero { grid-template-columns: 1fr; gap: 32px; padding-top: 40px; }
  .lp-chat { transform: none; }
  .lp-chat-body { height: 300px; }
}
@media (max-width: 640px) {
  .lp-links { order: 3; flex-basis: 100%; gap: 14px; }
}

/* «Написать нам» (support.py) */
.support-text { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.support-reply { margin-top: 12px; padding: 10px 14px; border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; background: var(--accent-bg); }
.form-textarea { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
  font: inherit; resize: vertical; }
.form-textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }


/* projects page: what the plan allows and how much is used */
.plan-usage { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 24px; }
.plan-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.plan-full .mono { color: var(--warn, #c9822b); }

/* Where a probe's time went (templates/_phases.html): one bar split by phase */
.ph-dns { background: #60A5FA; } .ph-connect { background: #22D3EE; } .ph-tls { background: #F472B6; }
.ph-ttfb { background: var(--accent); }
.phase-bar { display: inline-flex; align-items: center; gap: 10px; vertical-align: middle; }
.phase-track { display: inline-flex; width: 72px; height: 6px; border-radius: 3px; overflow: hidden; gap: 1px;
  background: var(--border); }
.phase-track > span { min-width: 2px; }
.latency-cell .phase-bar { margin-right: 10px; }
/* «Последние проверки» is a narrow block: no IP (it's in the header), the number with the split in its tooltip */
[data-block=latest] .table { min-width: 0; }
[data-block=latest] .ip-cell, [data-block=latest] .latency-cell .phase-bar { display: none; }
.phase-bar-labeled { flex-wrap: wrap; }
.phase-bar-labeled .phase-track { width: 160px; }
.phase-labels, .phase-legend { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }
.phase-labels { color: var(--muted); }
.phase-labels i, .phase-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.phase-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 0 0 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
