:root {
    --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #6b7385; --line: #e2e5eb;
    --accent: #2f6fed; --ok: #1f9d55; --ok-bg: #e5f6ec; --warn: #b7791f; --warn-bg: #fdf3dc; --fail: #c53030; --fail-bg: #fde8e8;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.top { display: flex; align-items: center; gap: 24px; padding: 0 20px; background: #1d2330; color: #fff; min-height: 50px; flex-wrap: wrap; }
.top .brand { font-weight: 600; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.top nav a { color: #c9cfdb; padding: 6px 10px; border-radius: 6px; }
.top nav a.active, .top nav a:hover { background: #333c50; color: #fff; text-decoration: none; }
.top .cnt { background: var(--fail); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
.top .logout { display: flex; gap: 8px; align-items: center; color: #c9cfdb; }
.top .logout .link { background: none; color: #c9cfdb; padding: 0; text-decoration: underline; }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.card h2 { margin-top: 0; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #fafbfc; font-weight: 600; color: var(--muted); font-size: 12px; }
tr.test td { background: #fbfbf3; }
tr.row-fail td { background: var(--fail-bg); }
table.kv th { width: 260px; }
table.small th, table.small td { padding: 4px 8px; font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.err { color: var(--fail); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 20px; }
.nowrap { white-space: nowrap; }
pre { background: #1d2330; color: #e3e7ef; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12.5px; max-height: 500px; white-space: pre-wrap; word-break: break-all; }
details pre { max-height: 300px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eceef2; color: var(--muted); font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.fail { background: var(--fail-bg); color: var(--fail); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; word-break: break-all; }
.flash.ok { background: var(--ok-bg); border-color: #b5e3c7; }
.flash.warn { background: var(--warn-bg); border-color: #f1d9a4; }
.flash.fail { background: var(--fail-bg); border-color: #f5baba; }
button, .button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 7px 14px; font: inherit; cursor: pointer; display: inline-block; }
button.secondary, .button.secondary { background: #e7ebf3; color: var(--text); }
button.small { padding: 3px 8px; font-size: 12px; }
.button:hover { text-decoration: none; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #cfd4dd; border-radius: 6px; background: #fff; max-width: 100%; }
textarea { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filters input[name=q] { min-width: 320px; }
.actions { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.actions form, form.inline { display: inline; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pager { margin: 8px 0 20px; color: var(--muted); display: flex; gap: 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; color: var(--muted); }
.tile .num { font-size: 26px; font-weight: 700; color: var(--text); }
.tile.warn { border-color: #f1d9a4; background: var(--warn-bg); }
.tile.fail { border-color: #f5baba; background: var(--fail-bg); }
.health-short { list-style: none; padding: 0; }
.health-short li { margin-bottom: 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
.check { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 8px; padding: 12px; }
.check.warn { border-left-color: var(--warn); }
.check.fail { border-left-color: var(--fail); }
.check-msg { margin: 6px 0 8px; }
.check table { margin: 0; }
fieldset { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; }
.field { display: grid; grid-template-columns: 300px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.field:last-child { border-bottom: 0; }
.field > label { font-weight: 500; padding-top: 6px; }
.field input:not([type=checkbox]), .field select { width: 420px; }
.field input.short { width: 140px; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
label.inline { font-size: 12px; color: var(--muted); margin-left: 6px; }
.sticky-save { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login { width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login label { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 900px) {
    .grid2, .field { grid-template-columns: 1fr; }
    .field input:not([type=checkbox]), .field select, .filters input[name=q] { width: 100%; min-width: 0; }
    .checks { grid-template-columns: 1fr; }
}
.top .version { font-weight: 400; font-size: 11px; color: #8b93a7; margin-left: 8px; }
footer.perf { max-width: 1400px; margin: 0 auto; padding: 0 20px 16px; color: var(--muted); font-size: 11px; }
.center { text-align: center; }
.stage-map table { width: auto; overflow: visible; } /* у таблиц overflow: hidden — обрезал бы выпадающие списки */
.stage-map td { vertical-align: middle; }
.stage-map input:not([type=checkbox]) { width: 250px; }
/* Chosen — в размер обычных полей формы */
.chosen-container { font-size: 14px; }
.chosen-container-single .chosen-single { height: 34px; line-height: 32px; padding: 0 0 0 8px; border-color: #cfd4dd; border-radius: 6px; background: #fff; box-shadow: none; color: var(--text); }
.chosen-container-single .chosen-single div b { background-position: 0 7px; }
.chosen-container-active.chosen-with-drop .chosen-single div b { background-position: -18px 7px; }
.chosen-container-single .chosen-search input[type=text] { height: 30px; font: inherit; }
.chosen-container .chosen-drop { border-color: #cfd4dd; border-radius: 0 0 6px 6px; }
.chosen-container .chosen-results li.highlighted { background: var(--accent); }
.chosen-container .chosen-results li { line-height: 1.35; }

/* ---- Журнал ---- */
.badge.info { background: #e6effd; color: var(--accent); }
.badge.sub { background: #fff; border: 1px solid var(--line); font-weight: 500; }
a.badge:hover { text-decoration: none; filter: brightness(.95); }
.chip { display: inline-block; padding: 2px 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 12px; color: var(--text); }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.reset { color: var(--fail); }
.log-filters { padding: 12px 16px; }
.log-ranges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.log-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 8px; }
.log-row:last-child { margin-bottom: 0; }
.log-row > label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.log-row > label.grow { flex: 1; min-width: 320px; }
.log-row input, .log-row select { color: var(--text); }
.input-group { display: flex; }
.input-group select { border-radius: 6px 0 0 6px; border-right: 0; width: auto; }
.input-group input { border-radius: 0 6px 6px 0; flex: 1; min-width: 0; }
.seg { display: flex; flex-wrap: wrap; align-items: flex-end; }
.seg .seg-label { width: 100%; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.seg label { border: 1px solid #cfd4dd; padding: 6px 10px; cursor: pointer; background: #fff; margin-left: -1px; font-size: 13px; }
.seg label:nth-of-type(1) { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg label:last-of-type { border-radius: 0 6px 6px 0; }
.seg label.active { background: var(--accent); border-color: var(--accent); color: #fff; position: relative; }
.seg input { display: none; }
.log-table tr[data-log-id] { cursor: pointer; }
.log-table tr[data-log-id]:hover td { background: #f3f6fc; }
.log-table tr.lvl-error td { background: #fdf1f1; }
.log-table tr.lvl-warning td { background: #fffaf0; }
.log-table tr.current td { box-shadow: inset 0 0 0 9999px rgba(47, 111, 237, .08); }
.log-table td.dir, .log-head .dir { color: var(--accent); font-weight: 700; }
.log-table td.msg { word-break: break-word; }
.log-table .meta { display: inline-flex; gap: 8px; margin-left: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; vertical-align: middle; }
.log-table .meta .badge { font-size: 11px; padding: 0 6px; }
a.trace { text-decoration: underline dotted; }
.pager { align-items: center; flex-wrap: wrap; gap: 12px; }
.pager .pages { display: inline-flex; gap: 4px; }
.pager .pages a, .pager .pages b { min-width: 28px; text-align: center; padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pager .pages b { background: var(--accent); border-color: var(--accent); color: #fff; }

.log-dialog { width: min(1200px, 96vw); max-height: 92vh; padding: 0; border: 0; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.log-dialog::backdrop { background: rgba(20, 25, 35, .45); }
.log-dialog.full { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; margin: 0; }
.log-dialog-bar { position: sticky; top: 0; z-index: 1; display: flex; gap: 6px; align-items: center; padding: 8px 12px; background: #fafbfc; border-bottom: 1px solid var(--line); }
.log-dialog-bar .grow { flex: 1; }
.log-dialog-body { padding: 16px; }
.log-dialog.full .log-dialog-body pre { max-height: none; }
.log-card h3 { font-size: 13px; margin: 14px 0 6px; }
.log-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.log-message { font-size: 15px; font-weight: 500; margin-bottom: 12px; word-break: break-word; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs .tab { background: none; color: var(--muted); border-radius: 6px 6px 0 0; padding: 7px 14px; border: 1px solid transparent; margin-bottom: -1px; }
.tabs .tab.active { color: var(--text); background: var(--card); border-color: var(--line); border-bottom-color: var(--card); font-weight: 600; }
.http-line { background: #f3f5f8; border: 1px solid var(--line); border-radius: 6px 6px 0 0; padding: 6px 10px; font-weight: 600; }
table.headers { border-radius: 0 0 6px 6px; }
table.headers th { width: 240px; color: var(--text); font-weight: 600; background: #fafbfc; }
.body-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.body-head .body-actions { margin-left: auto; display: flex; gap: 6px; }
.log-card pre { max-height: 60vh; }
.log-ranges .tz { margin-left: auto; }

/* ---- Удаление с подтверждением ---- */
button.danger, .button.danger { background: var(--fail); }
button.danger:disabled { opacity: .45; cursor: not-allowed; }
button.danger-outline { background: #fff; color: var(--fail); border: 1px solid #f5baba; }
button.danger-outline:hover { background: var(--fail-bg); }
.actions .grow { flex: 1; }
.confirm-dialog { width: min(560px, 94vw); border: 0; border-radius: 10px; padding: 20px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.confirm-dialog::backdrop { background: rgba(20, 25, 35, .45); }
.confirm-dialog h2 { margin-top: 0; }
.confirm-dialog input[name=confirm] { width: 100%; font-size: 16px; padding: 8px 10px; margin-bottom: 14px; }
.confirm-dialog .inline-check { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Связки: в таблицах с выпадающими списками Chosen обрезка мешает */
table.maps { overflow: visible; }
table.maps tr.new-row td { background: rgba(127, 127, 127, .06); }
table.maps tr.muted td { opacity: .6; }

/* ---------- Справка ---------- */
.help-q { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; margin-left: 5px;
    border-radius: 50%; background: #e3e8f0; color: #456; font-size: 11px; font-weight: 700; text-decoration: none; vertical-align: 1px; cursor: help; }
.help-q:hover { background: #2f6fde; color: #fff; }
.help-page { display: grid; grid-template-columns: 250px 1fr; gap: 24px; align-items: start; }
.help-nav { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.help-nav > a { padding: 5px 8px; border-radius: 6px; text-decoration: none; }
.help-nav > a.active { background: #eef3fc; font-weight: 600; }
.help-toc { display: flex; flex-direction: column; margin: 2px 0 6px 10px; border-left: 2px solid var(--line); }
.help-toc a { font-size: 12.5px; padding: 2px 8px; text-decoration: none; color: var(--muted); }
.help-toc a.lvl3 { padding-left: 18px; }
.md { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px 26px; line-height: 1.55; max-width: 980px; }
.md h2 { margin-top: 28px; padding-top: 6px; border-top: 1px solid var(--line); }
.md h2:first-child, .md .md-title + h2 { border-top: 0; margin-top: 6px; }
.md h3 { margin-top: 20px; }
.md .md-anchor { color: #b8c0cc; text-decoration: none; font-weight: 400; visibility: hidden; }
.md .md-h:hover .md-anchor { visibility: visible; }
.md .md-hl { background: #fff6cf; border-radius: 4px; box-shadow: 0 0 0 6px #fff6cf; }
.md code { background: #f0f2f6; padding: 1px 5px; border-radius: 4px; font-size: 92%; word-break: break-all; }
.md pre.md-code { white-space: pre-wrap; }
.md ul, .md ol { padding-left: 22px; }
.md li { margin: 3px 0; }
.md table.md-table { width: auto; max-width: 100%; margin: 10px 0 14px; }
.md table.md-table td, .md table.md-table th { vertical-align: top; }
.md-callout { border-left: 4px solid #2f6fde; background: #f1f6ff; padding: 6px 14px; border-radius: 6px; margin: 12px 0; }
.md-callout.warn { border-color: #e0a100; background: #fff8e5; }
.md-callout p { margin: 6px 0; }
.md-title { margin-top: 0; }
dialog.help-dialog { width: min(900px, 94vw); max-height: 86vh; padding: 0; border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; }
dialog.help-dialog:not([open]) { display: none; }
dialog.help-dialog::backdrop { background: rgba(20, 28, 40, .45); }
.help-dialog-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
.help-dialog-bar .grow { flex: 1; }
.help-dialog-body { overflow: auto; padding: 0; }
.help-dialog-body .md { border: 0; border-radius: 0; max-width: none; }
.card h2 .help-q, h2 .help-q { vertical-align: 3px; }
