ros_control: централизованное управление парком MikroTik RouterOS

Control Server (FastAPI) с WEB UI (Jinja2 + HTMX) и JSON API для группового
администрирования устройств RouterOS 7 через REST.

- Устройства: список, статус (модель, канал, версии ROS/FW, uptime, доступные
  обновления), примечания, пароли шифруются (Fernet); фоновый опрос каждые 30 с
  и быстрое обнаружение недоступности (таймаут соединения 4 с).
- Группы устройств и фильтры (устройства, резервные копии).
- Резервные копии: .backup и .rsc (show-sensitive) создаются через REST,
  скачиваются сервером и загружаются в S3 (Yandex Object Storage).
- Обновление ROS/FW и выбор канала, групповые операции задачами.
- Интерфейс по утверждённому макету: светлая/тёмная темы, окна, шрифты IBM Plex
  локально. Docker Compose, SQLite в томе, минимальный набор тестов.
- Планы и итоги каждого изменения — в docs/changes/.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5 committed 2026-09-19 13:13:29 +03:00
commit 4c1841b61b
85 files changed
+3579

No files matched your search

+105
View File
@@ -0,0 +1,105 @@
// ros_control UI: выбор строк, меню, окна, состояние фильтров. Без внешних библиотек (кроме htmx).
(() => {
const $ = (s, r = document) => r.querySelector(s);
const $$ = (s, r = document) => [...r.querySelectorAll(s)];
// --- выбор строк: панель фильтров ⇄ панель действий над выбранными ---
function syncSelection() {
const boxes = $$("input[name=device_ids]");
const n = boxes.filter((b) => b.checked).length;
boxes.forEach((b) => b.closest("tr")?.classList.toggle("sel", b.checked));
const all = $("#check-all");
if (all) { all.checked = boxes.length > 0 && n === boxes.length; all.indeterminate = n > 0 && n < boxes.length; }
const bulk = $("#tools-bulk"), filters = $("#tools-filters");
if (bulk && filters) { bulk.hidden = n === 0; filters.hidden = n > 0; }
const cnt = $("#sel-count"); if (cnt) cnt.textContent = n;
}
// --- фильтры устройств: подсветка включённых полей и кнопка «Сбросить (N)» ---
function syncFilters() {
const form = $("#dev-filters"); if (!form) return;
let active = 0;
$$("select.field", form).forEach((s) => { const on = s.value !== ""; s.classList.toggle("on", on); active += on; });
if ($("input[name=f_q]", form)?.value.trim()) active += 1;
const reset = $("#filters-reset", form);
if (reset) { reset.hidden = active === 0; reset.textContent = `Сбросить (${active})`; }
}
// Выпадающие списки позиционируются от кнопки в координатах окна: их не обрезает прокручиваемая
// таблица, а внизу экрана список раскрывается вверх.
function placeMenu(menu) {
const panel = $(".menu-panel", menu), btn = $("summary", menu);
if (!panel || !btn) return;
panel.style.position = "fixed"; panel.style.top = "0"; panel.style.left = "0"; panel.style.right = "auto";
const b = btn.getBoundingClientRect(), w = panel.offsetWidth, h = panel.offsetHeight, gap = 4, edge = 8;
let left = menu.classList.contains("right") ? b.right - w : b.left;
left = Math.max(edge, Math.min(left, window.innerWidth - w - edge));
const below = b.bottom + gap, above = b.top - gap - h;
panel.style.left = `${left}px`;
panel.style.top = `${below + h > window.innerHeight - edge && above >= edge ? above : below}px`;
}
document.addEventListener("toggle", (e) => { if (e.target.matches?.("details.menu[open]")) placeMenu(e.target); }, true);
// при прокрутке/изменении размера список следует за кнопкой; если кнопка ушла за пределы окна — закрывается
function reflowMenu(e) {
if (e?.target?.closest?.(".menu-panel")) return;
const menu = $("details.menu[open]"); if (!menu) return;
const r = $("summary", menu).getBoundingClientRect();
if (r.bottom < 0 || r.top > window.innerHeight || r.right < 0 || r.left > window.innerWidth) menu.removeAttribute("open");
else placeMenu(menu);
}
window.addEventListener("scroll", reflowMenu, true);
window.addEventListener("resize", reflowMenu);
const closeMenus = (keep) => $$("details.menu[open]").forEach((m) => { if (m !== keep) m.removeAttribute("open"); });
document.addEventListener("change", (e) => {
const t = e.target;
if (t.matches("input[name=device_ids]")) syncSelection();
if (t.id === "check-all") { $$("input[name=device_ids]").forEach((b) => (b.checked = t.checked)); syncSelection(); }
if (t.closest("#dev-filters")) syncFilters();
// «Новая группа…» в списке групп окна устройства
if (t.matches("select[name=group_id][data-newgroup]")) $("#new-group-field").hidden = t.value !== "__new__";
// предупреждение о HTTP
if (t.matches("input[name=use_tls]")) $("#http-note").hidden = t.checked;
});
document.addEventListener("input", (e) => { if (e.target.closest("#dev-filters")) syncFilters(); });
document.addEventListener("click", (e) => {
const t = e.target;
if (t.closest("#clear-sel")) { $$("input[name=device_ids]").forEach((b) => (b.checked = false)); syncSelection(); }
// меню: закрывается по клику вне и после выбора пункта; открыто не более одного
if (t.closest("details.sub > summary")) return; // раскрытие подменю («Сменить канал…») меню не закрывает
const menu = t.closest("details.menu");
closeMenus(t.closest(".menu-panel") ? null : menu);
// окно: закрытие по кнопке и по клику на подложку
const modal = $("#modal");
if (modal && (t.closest("[data-close]") || t === modal)) modal.close();
});
document.addEventListener("keydown", (e) => { if (e.key === "Escape") closeMenus(null); });
// окно открывается, когда HTMX положил в него содержимое
document.addEventListener("htmx:afterSwap", (e) => {
const modal = $("#modal");
if (e.detail.target.id === "modal-body") {
if (modal && !modal.open) modal.showModal();
$("#modal-body [autofocus], #modal-body input:not([type=hidden])")?.focus();
const sel = $("select[name=group_id][data-newgroup]"); if (sel) $("#new-group-field").hidden = sel.value !== "__new__";
}
syncSelection(); syncFilters();
});
// --- автообновление статусов: сервер опрашивает устройства сам, страница подтягивает результат ---
const REFRESH_MS = 15000;
function autoRefresh() {
const form = $("#dev-filters"), target = $("#devices");
if (!form || !target || document.hidden) return;
const busy = $$("input[name=device_ids]:checked").length || $("details[open]") || $("#modal")?.open || $("#dev-card .htmx-request");
if (busy || form.contains(document.activeElement)) return; // не мешаем работе пользователя
const params = new URLSearchParams(new FormData(form)); params.set("poll", "1");
htmx.ajax("GET", `/ui/devices?${params}`, { target: "#devices", swap: "innerHTML" });
}
setInterval(autoRefresh, REFRESH_MS);
const init = () => { syncSelection(); syncFilters(); };
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", init) : init();
})();
+93
View File
@@ -0,0 +1,93 @@
Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
+1
View File
@@ -0,0 +1 @@
var htmx=function(){"use strict";const Q={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){const n=cn(e,t||"post");return n.values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,allowScriptTags:true,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:true,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null,disableInheritance:false,responseHandling:[{code:"204",swap:false},{code:"[23]..",swap:true},{code:"[45]..",swap:false,error:true}],allowNestedOobSwaps:true},parseInterval:null,_:null,version:"2.0.4"};Q.onLoad=j;Q.process=kt;Q.on=ye;Q.off=be;Q.trigger=he;Q.ajax=Rn;Q.find=u;Q.findAll=x;Q.closest=g;Q.remove=z;Q.addClass=K;Q.removeClass=G;Q.toggleClass=W;Q.takeClass=Z;Q.swap=$e;Q.defineExtension=Fn;Q.removeExtension=Bn;Q.logAll=V;Q.logNone=_;Q.parseInterval=d;Q._=e;const n={addTriggerHandler:St,bodyContains:le,canAccessLocalStorage:B,findThisElement:Se,filterValues:hn,swap:$e,hasAttribute:s,getAttributeValue:te,getClosestAttributeValue:re,getClosestMatch:o,getExpressionVars:En,getHeaders:fn,getInputValues:cn,getInternalData:ie,getSwapSpecification:gn,getTriggerSpecs:st,getTarget:Ee,makeFragment:P,mergeObjects:ce,makeSettleInfo:xn,oobSwap:He,querySelectorExt:ae,settleImmediately:Kt,shouldCancel:ht,triggerEvent:he,triggerErrorEvent:fe,withExtensions:Ft};const r=["get","post","put","delete","patch"];const H=r.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function d(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function ee(e,t){return e instanceof Element&&e.getAttribute(t)}function s(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function te(e,t){return ee(e,t)||ee(e,"data-"+t)}function c(e){const t=e.parentElement;if(!t&&e.parentNode instanceof ShadowRoot)return e.parentNode;return t}function ne(){return document}function m(e,t){return e.getRootNode?e.getRootNode({composed:t}):ne()}function o(e,t){while(e&&!t(e)){e=c(e)}return e||null}function i(e,t,n){const r=te(t,n);const o=te(t,"hx-disinherit");var i=te(t,"hx-inherit");if(e!==t){if(Q.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function re(t,n){let r=null;o(t,function(e){return!!(r=i(t,ue(e),n))});if(r!=="unset"){return r}}function h(e,t){const n=e instanceof Element&&(e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function T(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function q(e){const t=new DOMParser;return t.parseFromString(e,"text/html")}function L(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function A(e){const t=ne().createElement("script");se(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Q.config.inlineScriptNonce){t.nonce=Q.config.inlineScriptNonce}return t}function N(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function I(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(N(e)){const t=A(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){O(e)}finally{e.remove()}}})}function P(e){const t=e.replace(/<head(\s[^>]*)?>[\s\S]*?<\/head>/i,"");const n=T(t);let r;if(n==="html"){r=new DocumentFragment;const i=q(e);L(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=q(t);L(r,i.body);r.title=i.title}else{const i=q('<body><template class="internal-htmx-wrapper">'+t+"</template></body>");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){o.remove();r.title=o.innerText}}if(r){if(Q.config.allowScriptTags){I(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function oe(e){if(e){e()}}function t(e,t){return Object.prototype.toStrinLine truncated
+202
View File
@@ -0,0 +1,202 @@
/* ros_control UI — перенос утверждённого макета. Значения (размеры, радиусы, цвета) взяты из макета 1:1.
Формы: контролы h36 r8 · метки h22 r6 · панели/карточки r12. Шрифты — IBM Plex (локально, OFL). */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-mono-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
:root {
--font: "IBM Plex Sans", system-ui, sans-serif;
--mono: "IBM Plex Mono", ui-monospace, monospace;
--bg: #f4f6f9; --surf: #ffffff; --head: #f8fafc; --sel: #f3f7ff;
--line: #dde3ea; --line2: #c5ced9;
--text: #18212f; --muted: #58657a; --faint: #8a95a5;
--acc: #2450c8; --acc-solid: #2450c8; --acc50: #eaf0ff; --acc100: #d5e2ff; --accd: #1e449e;
--ok-t: #14683a; --ok-b: #e3f4ea; --warn-t: #7c4a00; --warn-b: #fdf0d5; --bad-t: #a32020; --bad-b: #fbe6e6;
--neu-t: #3c4859; --neu-b: #eef1f5;
--dot-on: #1f8a4c; --dot-off: #c62828; --dot-unk: #8a95a5;
--shadow-menu: 0 8px 24px rgba(20, 33, 60, .14); --shadow-modal: 0 16px 48px rgba(20, 33, 60, .25);
--backdrop: rgba(24, 33, 47, .45); --disabled-bg: #f4f6f9; --disabled-t: #8a95a5;
color-scheme: light;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #0f141b; --surf: #171e27; --head: #1b2430; --sel: #1a2540;
--line: #2a3441; --line2: #3a4759;
--text: #e6ebf2; --muted: #97a3b6; --faint: #7a8699;
--acc: #7ea1ff; --acc-solid: #3d68de; --acc50: #1c2a4a; --acc100: #26385f; --accd: #a9c1ff;
--ok-t: #6fd39a; --ok-b: #12301f; --warn-t: #f0b04a; --warn-b: #3a2a0c; --bad-t: #ff8f8f; --bad-b: #3b1616;
--neu-t: #b6c0cf; --neu-b: #232c39;
--dot-on: #3fbf78; --dot-off: #ff6b6b; --dot-unk: #7a8699;
--shadow-menu: 0 8px 24px rgba(0, 0, 0, .5); --shadow-modal: 0 16px 48px rgba(0, 0, 0, .6);
--backdrop: rgba(0, 0, 0, .6); --disabled-bg: #1b2430; --disabled-t: #6b7789;
color-scheme: dark;
}
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/1.4 var(--font); }
a { color: var(--acc); text-decoration: none; }
h1, h2 { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.mono { font: 400 13px/1.2 var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { flex: none; }
/* ---------- 1 · Приложение ---------- */
.app-header { height: 56px; display: flex; align-items: center; gap: 32px; padding: 0 24px; background: var(--surf); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font: 600 16px/1 var(--font); color: var(--text); }
.brand-logo { width: 28px; height: 28px; border-radius: 8px; background: var(--acc-solid); color: #fff; display: flex; align-items: center; justify-content: center; }
.nav { display: flex; height: 100%; gap: 4px; }
.nav a { display: flex; align-items: center; height: 100%; padding: 0 14px; font: 500 14px/1 var(--font); color: var(--muted); border-bottom: 2px solid transparent; }
.nav a.on { color: var(--text); border-bottom-color: var(--acc); }
.user { color: var(--muted); }
.container { max-width: 1600px; margin: 0 auto; padding: 0 24px 48px; }
/* ---------- 2 · Страница ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin: 24px 0 16px; gap: 16px; }
.page-head h1 { font: 600 24px/1.2 var(--font); }
.page-head .sub { margin-top: 4px; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; }
/* ---------- Кнопки: h36 · r8 · 14/500 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; margin: 0; padding: 0 14px; border-radius: 8px;
border: 1px solid var(--line2); background: var(--surf); color: var(--text); font: 500 14px/1 var(--font); white-space: nowrap; cursor: pointer; }
.btn:hover { border-color: var(--acc); }
.btn.primary { background: var(--acc-solid); border-color: var(--acc-solid); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--acc); padding: 0 10px; }
.btn.ghost-n { background: transparent; border-color: transparent; color: var(--muted); padding: 0 10px; }
.btn.ghost:hover, .btn.ghost-n:hover { background: var(--acc50); border-color: transparent; }
.btn.icon { width: 36px; padding: 0; }
.btn.danger { color: var(--bad-t); }
.btn:disabled { background: var(--disabled-bg); color: var(--disabled-t); border-color: var(--line); cursor: not-allowed; }
summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
/* ---------- Поля: та же форма, что у кнопок ---------- */
.field, .input { height: 36px; margin: 0; border-radius: 8px; border: 1px solid var(--line2); background-color: var(--surf); color: var(--text); font: 400 14px/1 var(--font); }
.input { width: 100%; padding: 0 12px; }
textarea.input { height: 72px; padding: 10px 12px; font-family: var(--font); line-height: 1.4; resize: vertical; }
select.field { appearance: none; -webkit-appearance: none; padding: 0 36px 0 14px; font-weight: 500; cursor: pointer;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2358657a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
background-repeat: no-repeat; background-position: right 12px center; }
select.field.on { background-color: var(--acc50); border-color: var(--acc); color: var(--accd); }
select.field option { color: var(--text); background: var(--surf); font-weight: 400; }
.search { position: relative; display: inline-flex; align-items: center; flex: none; }
.search .ico { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { height: 36px; width: 280px; padding: 0 12px 0 36px; border-radius: 8px; border: 1px solid var(--line2); background: var(--surf); color: var(--text); font: 400 14px/1 var(--font); }
.search input::placeholder { color: var(--faint); }
.datefield { display: inline-flex; align-items: center; gap: 8px; height: 36px; width: 170px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line2); background: var(--surf); color: var(--muted); font: 400 14px/1 var(--font); }
.datefield input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: 400 13px/1 var(--mono); padding: 0; }
.datefield input::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
/* ---------- Метки: h22 · r6 ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--neu-b); color: var(--neu-t); font: 500 12px/1 var(--font); white-space: nowrap; }
.badge.warn { background: var(--warn-b); color: var(--warn-t); }
.badge.ok { background: var(--ok-b); color: var(--ok-t); }
.badge.bad { background: var(--bad-b); color: var(--bad-t); }
.badge.run { background: var(--acc50); color: var(--accd); }
.okmark { display: inline-flex; align-items: center; gap: 4px; color: var(--ok-t); font: 500 13px/1 var(--font); }
.dash { color: var(--faint); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--dot-unk); }
.dot.on { background: var(--dot-on); } .dot.off { background: var(--dot-off); }
/* ---------- 3 · Область: вкладки-подчёркивание ---------- */
.tabs { display: flex; align-items: center; gap: 24px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 2px 12px; margin-bottom: -1px; font: 500 14px/1 var(--font); color: var(--muted); border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.on { font-weight: 600; color: var(--text); border-bottom-color: var(--acc); }
.tab .count { margin-left: 2px; font-weight: 400; color: var(--muted); }
.tab-link { display: inline-flex; align-items: center; gap: 6px; padding-bottom: 10px; font: 500 14px/1 var(--font); color: var(--acc); }
/* ---------- Карточка, 4 · инструменты таблицы ---------- */
.card { background: var(--surf); border: 1px solid var(--line); border-radius: 12px; }
.tools { display: flex; align-items: center; gap: 8px; height: 64px; padding: 0 16px; }
.tools.bulk { background: var(--acc50); border-radius: 12px 12px 0 0; }
.tools form { display: contents; }
.sel-count { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; font: 600 14px/1 var(--font); color: var(--accd); }
.busy { opacity: 0; color: var(--muted); } .htmx-request .busy, .busy.htmx-request { opacity: 1; }
/* ---------- 5 · Данные: таблица ---------- */
table.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.grid th { height: 40px; padding: 0 6px; text-align: left; font: 600 12px/1 var(--font); color: var(--muted); background: var(--head); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.grid td { height: 60px; padding: 0 6px; border-bottom: 1px solid var(--line); vertical-align: middle; font: 400 14px/1.3 var(--font); }
.grid th:first-child, .grid td:first-child { padding-left: 16px; }
.grid th:last-child, .grid td:last-child { padding-right: 16px; }
.grid tr.sel td { background: var(--sel); }
.grid input[type=checkbox], .modal input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--acc-solid); }
.dev { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dev-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-link { color: inherit; }
.dev-link:hover { color: var(--acc); text-decoration: underline; }
.dev-sub { margin-top: 2px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-sub.bad { color: var(--bad-t); }
.c-mono { font: 400 13px/1.2 var(--mono); }
.c-small { font-size: 13px; color: var(--muted); }
.c-menu { text-align: right; }
.tfoot { display: flex; align-items: center; height: 44px; padding: 0 16px; font: 400 13px/1 var(--font); color: var(--muted); }
.empty { height: 88px; text-align: center; color: var(--muted); }
.table-wrap { overflow-x: auto; }
@media (min-width: 1360px) { .table-wrap { overflow: visible; } }
.grid.jobs td { height: 48px; }
.grid.files td { height: 52px; }
.grid.groups td { height: 56px; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 32px 0 12px; }
.section-head h2 { font: 600 16px/1.2 var(--font); }
.msg { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.err { color: var(--bad-t); }
/* ---------- Меню «⋯» и выпадающие списки ---------- */
.menu { position: relative; display: inline-flex; }
.menu-panel { position: absolute; top: 40px; left: 0; z-index: 30; width: 250px; padding: 6px; text-align: left; background: var(--surf);
border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-menu); }
.menu.right .menu-panel { left: auto; right: 0; }
.w200 { width: 200px; } .w270 { width: 270px; } .w330 { width: 330px; }
.mi { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; margin: 0; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent;
color: var(--text); text-align: left; font: 500 14px/1.3 var(--font); cursor: pointer; }
.mi small { font: 400 12px/1.3 var(--font); color: var(--muted); }
.mi:hover { background: var(--acc50); }
.mi.warn { color: var(--warn-t); } .mi.bad { color: var(--bad-t); }
.mi.on { flex-direction: row; align-items: center; gap: 6px; }
.mi.on::before { content: "✓"; }
summary.mi { list-style: none; } summary.mi::-webkit-details-marker { display: none; }
.menu-panel hr { height: 1px; margin: 6px 0; border: 0; background: var(--line); }
details.sub .sub-list { padding-left: 10px; }
/* ---------- Окна ---------- */
dialog.modal { width: 560px; max-width: calc(100vw - 32px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surf); color: var(--text); box-shadow: var(--shadow-modal); }
dialog.modal::backdrop { background: var(--backdrop); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 0 24px; }
.modal-head h2 { font: 600 18px/1.2 var(--font); }
.modal-body { display: flex; flex-direction: column; gap: 16px; padding: 16px 24px 24px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }
.form-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-row.host { grid-template-columns: 1fr 110px; }
.lbl { display: flex; flex-direction: column; gap: 6px; font: 500 13px/1.3 var(--font); }
.lbl small { font-size: inherit; font-weight: 400; color: var(--muted); }
.check { display: flex; align-items: flex-start; gap: 10px; font: 500 14px/1.3 var(--font); }
.check small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.note { padding: 10px 12px; border-radius: 8px; background: var(--warn-b); color: var(--warn-t); font: 400 13px/1.4 var(--font); }
.form-err { padding: 10px 12px; border-radius: 8px; background: var(--bad-b); color: var(--bad-t); font: 500 13px/1.4 var(--font); }
.page-card { max-width: 560px; margin: 24px auto; }
/* ---------- Вход ---------- */
.login { max-width: 400px; margin: 96px auto 0; }
.login h1 { font: 600 24px/1.2 var(--font); margin-bottom: 16px; }
/* таблица в карточке без собственной верхней/нижней границы (её даёт карточка) */
.card > table.grid:first-child thead th { border-top: 0; }
.card > table.grid:first-child thead th:first-child { border-top-left-radius: 11px; }
.card > table.grid:first-child thead th:last-child { border-top-right-radius: 11px; }
.card > table.grid:last-child tbody tr:last-child td { border-bottom: 0; }