:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --text: #1d2b3a;
    --muted: #64748b;
    --border: #e2e8f0;
    --brand: #3b5b7a;
    --brand-dark: #2a4460;
    --link: #3b5b7a;
    --accent: #f4c430;
    --accent-dark: #d9a90f;
    --on-accent: #1d2b3a;
    --ok: #16a34a;
    --bad: #dc2626;
    --soft: #f1f5f9;
    --bad-soft: #fef2f2;
    --bad-line: #fecaca;
    --ok-soft: #f0fdf4;
    --ok-ring: #dcfce7;
    --accent-soft: #fdf4d3;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
    /* цвета графиков (cabinet.js читает их при смене темы) */
    --chart-1: #3b5b7a;
    --chart-1-fill: rgba(59, 91, 122, .12);
    --chart-2: #d9a90f;
    --chart-2-fill: rgba(244, 196, 48, .2);
    --chart-3: #16a34a;
    --chart-4: #dc2626;
    --chart-5: #7c5cbf;
    --chart-6: #0e9fa8;
    --chart-muted: #94a3b8;
    --chart-grid: #eef2f6;
    color-scheme: light;
}

/* Тёмная тема: data-theme ставит скрипт в <head> (выбор пользователя или системная тема) */
:root[data-theme="dark"] {
    --bg: #0e151d;
    --surface: #16202b;
    --text: #e2e8f0;
    --muted: #8b9bb0;
    --border: #253343;
    --brand: #3b5b7a;
    --brand-dark: #1c2f43;
    --link: #8fb3d9;
    --ok: #4ade80;
    --bad: #f87171;
    --soft: #1f2c3a;
    --bad-soft: rgba(248, 113, 113, .12);
    --bad-line: rgba(248, 113, 113, .4);
    --ok-soft: rgba(74, 222, 128, .12);
    --ok-ring: rgba(74, 222, 128, .2);
    --accent-soft: rgba(244, 196, 48, .15);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --chart-1: #7fa7cf;
    --chart-1-fill: rgba(127, 167, 207, .15);
    --chart-2: #f4c430;
    --chart-2-fill: rgba(244, 196, 48, .14);
    --chart-3: #4ade80;
    --chart-4: #f87171;
    --chart-5: #b49cf0;
    --chart-6: #3fd0d8;
    --chart-muted: #64748b;
    --chart-grid: #1f2c3a;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main { flex: 1; }
a { color: var(--link); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* ---------- Кнопки и формы ---------- */
.btn {
    display: inline-block;
    padding: 12px 22px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s;
}
.btn:hover { background: var(--accent-dark); }
.btn--small { padding: 8px 14px; font-size: 14px; }
.btn--ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--border); }
.btn--ghost:hover { background: var(--surface); }
.btn--danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad-line); }
.btn--danger:hover { background: var(--bad-soft); }

.link { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
}
.field textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; line-height: 1.5; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--link); outline-offset: -1px; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; background: var(--bad-soft); color: var(--bad); }
.alert--ok { background: var(--ok-soft); color: var(--ok); }
.small { font-size: 14px; }

/* Формы настроек */
.page--form { max-width: 820px; }
.page--form .card { margin-bottom: 20px; }
.page--form h3 { font-size: 16px; margin-top: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.field--wide { grid-column: 1 / -1; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin-bottom: 16px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 3px 0 0; flex: none; accent-color: var(--brand); }
.check--big { font-weight: 600; font-size: 17px; }

/* Настройки аккаунта */
.howto { margin: 0 0 16px; padding-left: 22px; line-height: 1.6; }
.howto li { margin-bottom: 6px; }
.howto code { background: var(--soft); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* Помощь */
.page--doc { max-width: 900px; }
.doc .card { margin-bottom: 20px; scroll-margin-top: 16px; }
.doc h2 { font-size: 22px; }
.doc h3 { font-size: 17px; margin-top: 22px; }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin-bottom: 6px; }
.doc code { background: var(--soft); padding: 1px 5px; border-radius: 5px; font-size: .9em; overflow-wrap: anywhere; }
.doc .cmd { margin: 8px 0 14px; }
.toc ol { columns: 2; margin: 10px 0 0; }
.table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 15px; }
.table th, .table td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; }
.table td:first-child { width: 36%; }
.page__links { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

/* ---------- Шапка и подвал ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; color: var(--text); text-decoration: none; }
.logo img { border-radius: 9px; box-shadow: 0 0 0 1px var(--border); }
.nav { display: flex; align-items: center; gap: 20px; }
.nav a:not(.btn) { color: var(--text); text-decoration: none; font-weight: 500; }
.nav__logout { margin: 0; }

/* Кнопки-иконки: переключатель темы, полный экран */
.icon-btn {
    display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
    border: 0; border-radius: 10px; background: none; color: var(--text); cursor: pointer; transition: background .15s;
}
.icon-btn:hover { background: var(--soft); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn--framed { background: var(--surface); border: 1px solid var(--border); width: 38px; height: 38px; }
.theme-toggle .i-sun, :root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
.kiosk-toggle .i-exit, .kiosk .kiosk-toggle .i-enter { display: none; }
.kiosk .kiosk-toggle .i-exit { display: block; }

.footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 64px; }
.footer__inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-top: 20px; padding-bottom: 20px; font-size: 14px; color: var(--muted); }

/* ---------- Лендинг ---------- */
.hero { background: linear-gradient(160deg, var(--brand-dark), var(--brand)); color: #fff; padding: 72px 0 80px; }
.hero__grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(32px, 5vw, 52px); letter-spacing: -.02em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { font-size: 19px; opacity: .9; max-width: 34em; }
.hero__cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero .btn--ghost { color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.hero .btn--ghost:hover { background: rgba(255,255,255,.1); }
/* Края картинки растворяются в фоне hero: у логотипа свой тёмный фон */
.hero__logo { display: block; justify-self: center; width: 100%; max-width: 440px; }
.hero__logo img {
    display: block; width: 100%; height: auto;
    -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
    mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
}
.terminal--how { max-width: 760px; margin: 32px auto 0; }

.terminal {
    background: #0f1a26;
    border-radius: var(--radius);
    padding: 20px;
    font-size: 14px;
    color: #cbd5e1;
    box-shadow: 0 20px 50px rgba(0,0,0,.3);
    overflow-x: auto;
}
.terminal__dots { display: flex; gap: 6px; margin-bottom: 14px; }
.terminal__dots i { width: 10px; height: 10px; border-radius: 50%; background: #334155; }
.terminal pre { margin: 0; white-space: pre-wrap; word-break: break-all; }
.terminal .prompt { color: var(--accent); }
.terminal .ok { color: #4ade80; }

.section { padding-top: 72px; }
.section__title { text-align: center; font-size: clamp(26px, 3.5vw, 36px); }
.section__lead { text-align: center; color: var(--muted); max-width: 40em; margin: 0 auto 40px; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature__icon { width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; font-size: 22px; margin-bottom: 14px; }
.feature p { color: var(--muted); margin: 0; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; counter-reset: step; }
.step { position: relative; padding-top: 56px; }
.step::before {
    counter-increment: step;
    content: counter(step);
    position: absolute; top: 20px; left: 24px;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--brand); color: #fff; font-weight: 700;
    display: grid; place-items: center; font-size: 14px;
}
.step p { color: var(--muted); margin: 0; }

.cta { margin-top: 72px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 48px 24px; }
.cta p { color: var(--muted); }

/* ---------- Страницы кабинета ---------- */
.page { padding-top: 40px; }
.page--narrow { max-width: 440px; }
.page__head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page__head h1 { margin: 0; }
.back { display: inline-block; margin-bottom: 8px; font-size: 14px; text-decoration: none; }

.add-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.add-form .field { flex: 1; min-width: 220px; margin: 0; }

.servers { display: grid; gap: 12px; margin-top: 24px; }
.server-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr;
    gap: 16px;
    align-items: center;
    padding: 18px 24px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s;
}
.server-row:hover { border-color: var(--link); }
.server-row__name { font-weight: 600; }
.server-row__host { font-size: 13px; color: var(--muted); }
.metric-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.metric-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status--online { color: var(--ok); }
.status--online::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-ring); }
.status--offline { color: var(--muted); }

.empty { text-align: center; padding: 48px 24px; color: var(--muted); }

/* ---------- Плитки страницы сервера ---------- */
.tiles { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.tile { position: relative; min-width: 0; }
.tile[hidden] { display: none; }
.tile--add, .tile--stat { grid-column: span 3; }
.tile--chart { grid-column: span 6; }
.tile--wide { grid-column: span 12; }
.tile--add { min-height: 110px; }

.tile__tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 2px; }
.tile__drag, .tile__close, .tile__bell {
    display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: none;
    color: var(--muted); font-size: 20px; line-height: 1; opacity: .5; transition: opacity .15s, background .15s;
}
.tile__drag { cursor: grab; font-size: 16px; touch-action: none; user-select: none; }
.tile__close, .tile__bell { cursor: pointer; }
.tile:hover .tile__drag, .tile:hover .tile__close, .tile:hover .tile__bell,
.tile__close:focus-visible, .tile__bell:focus-visible { opacity: 1; }
.tile__bell svg { width: 16px; height: 16px; }
.tile__bell:hover { background: var(--soft); color: var(--text); }
/* задан порог: колокольчик виден всегда и закрашен */
.tile__bell--on { opacity: 1; color: var(--accent-dark); }
.tile__bell--on svg { fill: currentColor; }
.tile__drag:hover { background: var(--soft); color: var(--text); }
.tile__close:hover { background: var(--bad-soft); color: var(--bad); }
.tile > .metric-label, .tile > h2, .tile > h3 { padding-right: 64px; }
.tile[data-alerts] > .metric-label, .tile[data-alerts] > h2, .tile[data-alerts] > h3 { padding-right: 96px; }

/* Перетаскивание (SortableJS) */
.tile--ghost { opacity: .35; outline: 2px dashed var(--link); outline-offset: -2px; }
.tile--drag { box-shadow: 0 12px 32px rgba(15, 23, 42, .18); }
.tiles--dragging, .tiles--dragging .tile__drag { cursor: grabbing; }

.tile-add__btn {
    width: 100%; height: 100%; min-height: 110px;
    border: 2px dashed var(--border); border-radius: var(--radius); background: transparent;
    color: var(--muted); font: 300 40px/1 system-ui, sans-serif; cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.tile-add__btn:hover, .tile-add__btn[aria-expanded="true"] { border-color: var(--link); color: var(--link); background: var(--surface); }
.tile-add__menu {
    position: absolute; z-index: 10; top: calc(100% + 6px); left: 0; min-width: 100%; width: max-content; max-width: 320px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px;
}
.tile-add__menu button {
    display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px;
    border-radius: 7px; font: inherit; font-size: 15px; color: var(--text); cursor: pointer;
}
.tile-add__menu button:hover, .tile-add__menu button:focus-visible { background: var(--soft); }
.tile-add__menu button[hidden] { display: none; }
.tile-add__empty { padding: 8px 12px; font-size: 14px; }

/* Дашборд: на плитке — подпись её сервера (точка — онлайн); [+] — модалка выбора сервера и показателя с предпросмотром */
#dashboard .tiles { align-items: start; } /* плитки разных серверов вперемешку: значение рядом с графиком не растягиваем */
.modal--wide { width: min(680px, calc(100vw - 32px)); }
.widget-pick { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: 12px; margin: 16px 0; }
.widget-pick span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.widget-pick select {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; font-size: 15px;
    color: var(--text); background: var(--surface);
}
.widget-pick select:focus { outline: 2px solid var(--link); outline-offset: -1px; }
.widget-preview {
    display: grid; place-items: safe center; height: min(420px, 55vh); padding: 16px; overflow-y: auto; /* высокая плитка (список ошибок) прокручивается */
    border-radius: var(--radius); background: var(--bg);
}
.widget-preview__tile { width: 100%; transition: opacity .15s; }
.widget-preview__tile:empty { display: none; }
.widget-preview--loading { opacity: .5; }
.widget-preview #widget-note { margin: 0; text-align: center; }
.widget-preview .tile__tools { display: none; }
.widget-preview .tile__server { max-width: 100%; }
.tile__server {
    display: flex; align-items: center; gap: 6px; width: fit-content; max-width: calc(100% - 64px); margin-bottom: 6px;
    font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tile__server span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__server::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.tile__server--online::before { background: var(--ok); }
.tile__server:hover { color: var(--link); }
/* Группировка по серверам: разделитель на всю ширину сетки, подпись сервера на плитках не нужна */
.dash-sep { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.dash-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.dash-sep .tile__server { max-width: 70%; margin: 0; font-size: 15px; color: var(--text); }
.dash-sep .tile__server:hover { color: var(--link); }
.tiles--grouped .tile > .tile__server { display: none; }
/* Слайдер высоты графиков дашборда: --chart-h ставит cabinet.js; не задана — высота по умолчанию */
#dashboard .chart-box { height: var(--chart-h, 260px); }
.kiosk #dashboard .chart-box { height: var(--chart-h, clamp(260px, 34vh, 520px)); }
.height-range {
    display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--muted); cursor: pointer;
}
.height-range svg { width: 18px; height: 18px; flex: none; }
.height-range input { width: 110px; margin: 0; accent-color: var(--link); cursor: pointer; }
.group-toggle { color: var(--muted); }
.group-toggle[aria-pressed="true"] { color: var(--link); border-color: var(--link); }
.dash__empty { margin-top: 16px; }

.stat__value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Заполненность дисков: от 80% — предупреждение, от 90% — авария (disk_level() / diskLevel()) */
.stat__value--warn, .metric-value--warn { color: var(--accent-dark); }
.stat__value--bad, .metric-value--bad { color: var(--bad); }
.disks { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.disk__head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.disk__mount { font-family: ui-monospace, monospace; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disk__bar { height: 8px; margin: 6px 0 4px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.disk__bar span { display: block; height: 100%; border-radius: 4px; background: var(--ok); transition: width .3s; }
.disk--warn .disk__bar span { background: var(--accent-dark); }
.disk--bad .disk__bar span { background: var(--bad); }
.disk--bad .disk__pct { color: var(--bad); }

.chart-card h3 { font-size: 16px; }
.chart-box { position: relative; height: 260px; }
.tile__hint { margin: -4px 0 8px; }

.ranges { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.ranges button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font: inherit; font-size: 14px; cursor: pointer; color: var(--muted); }
.ranges button.active { background: var(--brand); color: #fff; }

.install h2 { font-size: 20px; }
.install ol { padding-left: 20px; }
.install li { margin-bottom: 14px; }
.cmd { position: relative; background: #0f1a26; color: #e2e8f0; border-radius: 10px; padding: 14px 90px 14px 16px; font-size: 13px; overflow-x: auto; margin-top: 8px; }
.cmd pre { margin: 0; white-space: pre-wrap; word-break: break-all; }
.cmd .copy { position: absolute; right: 10px; top: 10px; }
.token { font-family: ui-monospace, monospace; background: var(--soft); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

/* Ошибки приложения: плитка на странице сервера и страница /errors (views/_error.php, errorRow в cabinet.js) */
.errs { list-style: none; margin: 0 0 10px; padding: 0; }
.errs .err + .err { border-top: 1px solid var(--border); }
.err { padding: 8px 0; min-width: 0; }
.err__head { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.err__body { min-width: 0; flex: 1; }
.err__msg { overflow-wrap: anywhere; font-size: 15px; }
.err__meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.err__where { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.err__level { flex: none; font-size: 12px; font-weight: 600; line-height: 1; padding: 5px 7px; border-radius: 6px; margin-top: 2px; background: var(--soft); color: var(--muted); min-width: 72px; text-align: center; }
.err__level--fatal, .err__level--error { background: var(--bad-soft); color: var(--bad); }
.err__level--warning { background: var(--accent-soft); color: var(--text); }
.err--new { animation: err-flash 1.5s ease-out; }
@keyframes err-flash { from { background: var(--accent-soft); } to { background: transparent; } }
.errs__empty { margin: 0 0 10px; }
.errs:not(.errs--page) .err__msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.errs--page { display: grid; gap: 10px; }
.errs--page .err + .err { border-top: 0; }
.errs--page .err { padding: 0; }
.errs--page summary { list-style: none; cursor: pointer; padding: 16px 20px; }
.errs--page summary::-webkit-details-marker { display: none; }
.errs--page details[open] summary { border-bottom: 1px solid var(--border); }
.err__details { padding: 12px 20px 16px; }
.err__details h4 { margin: 12px 0 6px; font-size: 14px; }
.err__pre { background: var(--soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 0 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.err__details .table td:first-child { color: var(--muted); white-space: nowrap; width: 1%; padding-right: 16px; }
.err__details .table code { overflow-wrap: anywhere; }
.err-filter { margin-bottom: 16px; flex-wrap: wrap; }
.err-filter a { padding: 6px 12px; border-radius: 7px; font-size: 14px; color: var(--muted); text-decoration: none; }
.err-filter a.active { background: var(--brand); color: #fff; }
.err-filter a.active .muted { color: inherit; opacity: .75; }

/* Модалка порогов уведомлений (колокольчик плитки) */
.modal {
    width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal__body { position: relative; padding: 22px 24px 20px; }
.modal__body h2 { margin: 0 40px 2px 0; font-size: 20px; }
.modal__close {
    position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: 0; border-radius: 8px;
    background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer;
}
.modal__close:hover { background: var(--soft); color: var(--text); }
.modal__actions { display: flex; gap: 10px; margin-top: 16px; }
.alert-rows { display: grid; gap: 14px; margin: 16px 0; }
.alert-row__name { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.alert-row__inputs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.alert-row__inputs input, .alert-row__inputs select {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; font-size: 15px;
    color: var(--text); background: var(--surface);
}
.alert-row__inputs input { width: 120px; }
.alert-row__inputs input:focus, .alert-row__inputs select:focus { outline: 2px solid var(--link); outline-offset: -1px; }
.alert--warn { background: var(--accent-soft); color: var(--text); }
/* Уведомление о потере связи: кнопка в шапке страницы сервера (закрашена, если включено) и модалка */
.offline-toggle--on { color: var(--accent-dark); }
.offline-toggle--on svg { fill: currentColor; }
.offline-delay { margin: 10px 0 16px 30px; }
.offline-delay select:disabled { opacity: .5; }

.danger-zone { margin-top: 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

/* Режим киоска: без шапки, подвала и инструментов плиток, плитки на всю ширину экрана */
.kiosk .topbar, .kiosk .footer, .kiosk .back, .kiosk .danger-zone,
.kiosk .tile--add, .kiosk .tile__tools, .kiosk .offline-toggle, .kiosk .group-toggle { display: none; }
.kiosk .page.wrap { max-width: none; padding: 16px 20px; }
.kiosk .page__head { margin-bottom: 16px; }
.kiosk .page__head h1 { font-size: 26px; }
.kiosk .tile > .metric-label, .kiosk .tile > h2, .kiosk .tile > h3 { padding-right: 0; }
.kiosk .tile__server { max-width: 100%; }
.kiosk .dash__empty { display: none; }
.kiosk .chart-box { height: clamp(260px, 34vh, 520px); }

@media (max-width: 860px) {
    .hero__grid, .features, .steps { grid-template-columns: 1fr; }
    .hero { padding: 48px 0 56px; }
    .hero__logo { max-width: 300px; order: -1; }
    .server-row { grid-template-columns: 1fr 1fr; }
    .tile--add, .tile--stat { grid-column: span 6; }
    .tile--chart { grid-column: span 12; }
}
@media (max-width: 600px) {
    .form-grid, .checks { grid-template-columns: 1fr; }
    .toc ol { columns: 1; }
    .table td:first-child { width: auto; }
}
@media (max-width: 520px) {
    .nav { gap: 12px; }
    .nav .btn--small { display: none; }
    .tile--add, .tile--stat { grid-column: span 12; }
    .widget-pick { grid-template-columns: 1fr; }
    .height-range input { width: 80px; }
}

/* WebStat: сайты на странице настроек, плитка «сайты сегодня», статистика сайта */
.web-site { padding: 16px 0; border-top: 1px solid var(--border); scroll-margin-top: 16px; }
.web-site:first-of-type { border-top: 0; padding-top: 4px; }
.web-site--new { animation: err-flash 2s ease-out; }
.web-site__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.web-site__head .muted:not(.small) { margin-left: 6px; }
.web-site__actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.web-site__actions form { margin: 0; }
.web-site .alert { margin: 10px 0 0; }
.checks--one { grid-template-columns: 1fr; }
.table--stats td:first-child { width: auto; }
.table--stats td { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.table--stats a { text-decoration: none; }
.web-sel { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--soft); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.stat__value--small { font-size: 22px; }
.web--new { animation: err-flash 1.5s ease-out; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; line-height: 1; padding: 3px 6px; border-radius: 6px; background: var(--ok-soft); color: var(--ok); vertical-align: 1px; }
.table--rows tbody tr[data-href], .table--rows tbody tr[data-i] { cursor: pointer; }
.table--rows tbody tr[data-href]:hover, .table--rows tbody tr[data-i]:hover { background: var(--soft); }
.table--rows tbody tr.is-current { background: var(--accent-soft); }
.visitor-events td:nth-child(2) { white-space: nowrap; }
.visitor-events td:nth-child(3) { min-width: 120px; overflow-wrap: anywhere; }
.visitor-session td { font-size: 14px; font-weight: 600; background: var(--soft); }
.visitor-info td:first-child { color: var(--muted); white-space: nowrap; width: 1%; padding-right: 16px; }
.visitor-info td { overflow-wrap: anywhere; }

/* Ошибки JavaScript (WebStat): плитка-гистограмма, список и страница ошибки */
.js-err-chart canvas { cursor: pointer; }
.js-err__sum { margin: 6px 0 4px; }
.js-kind { display: inline-block; font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 7px; border-radius: 6px; background: var(--bad-soft); color: var(--bad); white-space: nowrap; }
.js-kind--console, .js-kind--resource { background: var(--accent-soft); color: var(--text); }
h1 .js-kind { font-size: 14px; vertical-align: 4px; margin-right: 4px; }
.js-error__title { overflow-wrap: anywhere; }
.js-errors__msg { overflow-wrap: anywhere; min-width: 200px; }
.js-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 16px; }
.js-filter { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 5px 6px 5px 12px; border-radius: 7px; background: var(--soft); }
.js-filter > a[aria-label] { text-decoration: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 4px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 16px 0; }

/* Повтор действий посетителя: iframe в ширину окна посетителя, уменьшенный под карточку, поверх — точки кликов */
.replay__bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.replay__bar .btn { min-width: 40px; }
.replay__bar .php-site-select { display: inline-block; margin: 0; width: auto; }
.replay__url { margin-left: auto; overflow-wrap: anywhere; text-decoration: none; }
.replay__stage { position: relative; max-height: 70vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--soft); }
.replay__canvas { position: relative; overflow: hidden; }
.replay__frame { position: absolute; top: 0; left: 0; border: 0; background: #fff; transform-origin: 0 0; pointer-events: none; }
.replay__dots { position: absolute; inset: 0; }
.replay__dot {
    position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
    display: grid; place-items: center; font-size: 11px; font-weight: 700; line-height: 1;
    background: var(--chart-1); color: #fff; opacity: .75; box-shadow: 0 0 0 2px var(--surface);
}
.replay__dot--current { background: var(--bad); opacity: 1; z-index: 1; animation: replay-pulse 1.2s ease-out infinite; }
@keyframes replay-pulse {
    0% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 2px var(--bad); }
    100% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 16px transparent; }
}
.replay__note { position: absolute; top: 12px; left: 12px; right: 12px; padding: 8px 12px; border-radius: 8px; background: var(--surface); }
@media (max-width: 600px) {
    .table--rows { display: block; overflow-x: auto; }
}

/* Мониторинг PHP: сайты с логами на странице настроек, плитка «ошибки по сайтам» */
.php-site { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 32px; gap: 0 16px; align-items: start; padding-top: 12px; border-top: 1px solid var(--border); }
.php-site:first-child { border-top: 0; padding-top: 0; }
.php-site .field { margin-bottom: 12px; }
.php-site__remove {
    margin-top: 30px; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none;
    color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer;
}
.php-site__remove:hover { background: var(--bad-soft); color: var(--bad); }
@media (max-width: 600px) {
    .php-site { grid-template-columns: minmax(0, 1fr) 32px; }
    .php-site .field:first-child { grid-column: 1; }
    .php-site .field:nth-child(2) { grid-column: 1; grid-row: 2; }
    .php-site__remove { grid-column: 2; grid-row: 1; }
}
.php-sites-table td.php-zero { color: var(--muted); }
.php-sites-table td.php-bad { color: var(--bad); font-weight: 600; }
.php-site-select { display: block; margin: 0 0 8px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; color: var(--text); background: var(--surface); max-width: 100%; }
