/* ScohVizor — собственные стили, без CSS-фреймворков.
   Две темы через data-theme на <html>; фон — анимированный размытый градиент. */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 10px;
  --ok: #3fb97f; --warn: #e0a93b; --bad: #ec6a6a; --idle: #8693a6;
}
:root[data-theme="dark"] {
  --bg: #0e1218; --panel: rgba(23, 29, 38, .72); --solid: #171d26; --line: rgba(255,255,255,.09);
  --text: #e3e8ef; --muted: #8b97a8; --accent: #38c4d4; --accent-ink: #06222a;
  --field: rgba(255,255,255,.05); --blob1: #0f7c8a; --blob2: #3d3fa8; --blob3: #7a2f66; --blob-o: .5;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef1f5; --panel: rgba(255,255,255,.74); --solid: #ffffff; --line: rgba(20,30,45,.12);
  --text: #18202b; --muted: #5d6b7d; --accent: #0a7283; --accent-ink: #ffffff;
  --field: rgba(255,255,255,.8); --blob1: #8fd6df; --blob2: #b3b6f0; --blob3: #f0b8dc; --blob-o: .75;
  color-scheme: light;
}
* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: .95rem; margin: .4rem 0; }
a { color: var(--accent); }
code, .mono, pre { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.nowrap { white-space: nowrap; }
.pad { padding: 14px 16px; }
.only-light { display: none; }
:root[data-theme="light"] .only-light { display: inline; }
:root[data-theme="light"] .only-dark { display: none; }

/* Фон: три размытых пятна медленно плывут. */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); }
.bg i { position: absolute; width: 52vmax; height: 52vmax; border-radius: 50%; filter: blur(90px); opacity: var(--blob-o); will-change: transform; }
.bg i:nth-child(1) { background: var(--blob1); left: -14vmax; top: -16vmax; animation: drift1 38s ease-in-out infinite alternate; }
.bg i:nth-child(2) { background: var(--blob2); right: -18vmax; top: 10vh; animation: drift2 46s ease-in-out infinite alternate; }
.bg i:nth-child(3) { background: var(--blob3); left: 20vw; bottom: -26vmax; animation: drift3 52s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(18vw, 14vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-16vw, 22vh) scale(.9); } }
@keyframes drift3 { to { transform: translate(14vw, -18vh) scale(1.2); } }
@media (prefers-reduced-motion: reduce) { .bg i { animation: none; } }

/* Каркас */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 18px 12px;
  background: var(--panel); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-right: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.15rem; padding: 4px 10px 14px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.side nav a:hover { background: var(--field); color: var(--text); }
.side nav a.on { background: var(--field); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.side-foot { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.side-foot form { display: contents; }
.who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.main { padding: 26px clamp(14px, 3vw, 36px) 60px; min-width: 0; max-width: 1280px; width: 100%; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.scroll { overflow-x: auto; }

/* Кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 6px 13px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.icon { width: 36px; padding: 0; position: relative; }
.btn.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
.btn.wide { width: 100%; }
.btn .e { position: absolute; top: -2px; right: 3px; color: var(--bad); font-weight: 700; font-size: .8rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: .92rem; }
.field small { color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px; width: 100%; }
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--accent); }
textarea { resize: vertical; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline select, .inline input { width: auto; }
.chk, .checks label { display: inline-flex; align-items: center; gap: 8px; }
.checks { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 14px; }
.form { padding: 20px; max-width: 760px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 0 16px; }
.actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
details { margin: 4px 0 16px; } summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; }
.acc { display: flex; gap: 22px; padding: 5px 0; flex-wrap: wrap; } .dim { opacity: .45; }
.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--panel); }
.notice.ok { border-color: var(--ok); } .notice.error { border-color: var(--bad); }
.login { width: min(380px, 100%); padding: 26px; } .login h1 { margin-bottom: 4px; } .login .muted { margin: 0 0 16px; }
.empty { color: var(--muted); padding: 18px 4px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; padding: 10px 16px; border-radius: 8px; background: var(--solid); border: 1px solid var(--ok); max-width: 80vw; }
.toast.err { border-color: var(--bad); }

/* Список проектов */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row { display: grid; grid-template-columns: 120px minmax(0, 1.5fr) minmax(0, 1.4fr) auto; gap: 14px; align-items: center; padding: 12px 16px; }
.state { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .82rem; font-family: var(--mono); }
.state i { width: 9px; height: 9px; border-radius: 50%; background: var(--idle); flex: none; }
.s-running i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.s-starting i, .s-backoff i, .s-stopping i { background: var(--warn); }
.s-fatal i { background: var(--bad); } .s-fatal { color: var(--bad); }
.ident { display: flex; flex-direction: column; min-width: 0; }
.ident .cmd { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-line { color: var(--bad); font-size: .85rem; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .88rem; }
.meta b { color: var(--muted); font-weight: 500; margin-right: 3px; }
.acts, .acts-admin { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; } .acts form { display: contents; }

/* Таблицы */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; padding: 1px 9px; border-radius: 99px; border: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.tag.ok { border-color: var(--ok); color: var(--ok); } .tag.bad { border-color: var(--bad); color: var(--bad); }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
.out { margin: 10px 0 0; padding: 12px 14px; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; background: var(--field); border-radius: 8px; border: 1px solid var(--line); }
.site { margin-bottom: 10px; } .site-head { display: flex; gap: 10px; align-items: center; } .site details { margin: 8px 0 0; }

/* Файловый менеджер */
.fm { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 14px; height: calc(100vh - 150px); min-height: 420px; }
.tree, .editor { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tree-bar { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.tree ul { list-style: none; margin: 0; padding: 6px 0; overflow: auto; flex: 1; }
.tree li button { all: unset; box-sizing: border-box; display: flex; gap: 6px; align-items: baseline; width: 100%; padding: 4px 10px 4px 0; cursor: pointer; font-size: .9rem; }
.tree li:hover { background: var(--field); } .tree li.sel { background: var(--field); box-shadow: inset 2px 0 0 var(--accent); }
.tree li.dir { font-weight: 500; } .tree li small { margin-left: auto; color: var(--muted); }
.chev { width: 12px; color: var(--muted); flex: none; }
.ed-bar { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ta, .cm { flex: 1; min-height: 0; border: 0; border-radius: 0; background: transparent; resize: none; padding: 12px 14px; line-height: 1.55; tab-size: 4; white-space: pre; overflow: auto; }
.cm { padding: 0; } .cm .cm-editor { height: 100%; } .cm .cm-scroller { font-family: var(--mono); }

/* Логи в новом окне */
.logpage { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding: 12px; gap: 10px; }
.logbar { display: flex; gap: 12px; align-items: center; padding: 8px 12px; flex-wrap: wrap; }
.tab { padding: 3px 12px; border-radius: 99px; text-decoration: none; color: var(--muted); font-family: var(--mono); font-size: .85rem; }
.tab.on { background: var(--field); color: var(--text); border: 1px solid var(--line); }
.logbox { flex: 1; overflow: auto; border-radius: var(--r); border: 1px solid var(--line); background: color-mix(in srgb, var(--solid) 88%, transparent); padding: 8px 0; font-family: var(--mono); font-size: .82rem; }
.ln { padding: 0 14px; white-space: pre-wrap; word-break: break-all; border-left: 3px solid transparent; }
.ln .ts { color: var(--muted); margin-right: 10px; }
.ln.err { color: var(--bad); border-left-color: var(--bad); } .ln.warn { color: var(--warn); border-left-color: var(--warn); }
.ln.info { color: var(--text); } .ln.dim { color: var(--muted); }

/* Система */
.sys { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 14px; margin-bottom: 14px; }
.sys h2 { margin-top: 0; } .wide-s { grid-column: 1 / -1; }
dl { margin: 0; } dd { margin: 0 0 8px; } dt { color: var(--muted); font-size: .82rem; }
.kv { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; } .kv dt { font-size: .9rem; } .kv dd { margin: 0; text-align: right; }
.meter { height: 7px; border-radius: 4px; background: var(--field); overflow: hidden; min-width: 90px; margin: 4px 0; border: 1px solid var(--line); }
.meter b { display: block; height: 100%; background: var(--accent); }

/* Новые элементы */
.host { padding: 12px 16px; margin-bottom: 14px; }
.hostgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px 24px; font-size: .88rem; }
.hostgrid b { color: var(--muted); font-weight: 500; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters input { flex: 1 1 220px; max-width: 360px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: .85rem; color: var(--muted); background: var(--field); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; cursor: pointer; }
.chip b { color: var(--text); margin-left: 3px; } .chip.on { color: var(--text); border-color: var(--accent); } .chip.bad b { color: var(--bad); }
.mini { width: 11ch; min-height: 32px; padding: 4px 8px; } .mini.wide { width: 22ch; }
.notice.warn { border-color: var(--warn); }
.warn-line { color: var(--warn); font-size: .82rem; }
.opts { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; max-width: none; }
.wrap { white-space: normal; max-width: 40ch; word-break: break-all; }
.wide-clip { max-width: 60ch; }
.tree-bar { flex-wrap: wrap; }
.sel-info { margin: 0; padding: 6px 12px; color: var(--muted); border-bottom: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.tree li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cm { position: relative; overflow: hidden; }
.cm .cm-editor { position: absolute; inset: 0; height: auto; }
.termbox { flex: 1; min-height: 0; border-radius: var(--r); border: 1px solid var(--line); padding: 6px; background: #0b0f14; overflow: hidden; }
:root[data-theme="light"] .termbox { background: #fff; }
.termbox .xterm { height: 100%; }
.fallback { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.fallback .out { flex: 1; margin: 0; max-height: none; }
.keys { display: flex; gap: 6px; flex-wrap: wrap; }
.keys .btn { min-height: 38px; padding: 4px 12px; font-family: var(--mono); }

/* Мобильная версия */
@media (max-width: 860px) {
  html, body { overflow-x: hidden; }
  input, select, textarea { font-size: 16px; }              /* iOS не должен приближать страницу при фокусе */
  .shell { grid-template-columns: minmax(0, 1fr); overflow-x: clip; }
  .side { position: sticky; height: auto; flex-direction: row; align-items: center; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); z-index: 20; gap: 6px; min-width: 0; }
  .brand { display: none; }
  .side nav { flex-direction: row; overflow-x: auto; flex: 1 1 0; min-width: 0; scrollbar-width: none; gap: 0; }
  .side nav::-webkit-scrollbar { display: none; }
  .side nav a { padding: 10px; flex: none; } .side nav a span { display: none; } .side nav a.on { box-shadow: inset 0 -2px 0 var(--accent); }
  .side-foot { border: 0; padding: 0; flex: none; gap: 4px; } .who { display: none; }
  .main { padding: 14px 12px 40px; }
  h1 { font-size: 1.3rem; } .head { margin-bottom: 12px; }
  .btn.icon { width: 40px; min-height: 40px; }
  .row { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px; }
  .ident .cmd { white-space: normal; word-break: break-all; }
  .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
  .form { padding: 14px; } .filters input { max-width: none; }
  .fm { grid-template-columns: minmax(0, 1fr); height: auto; } .tree { max-height: 42vh; } .editor { min-height: 62vh; }
  .tree-bar .btn span { display: none; } .tree-bar .btn { flex: 1; }
  .logpage { height: 100dvh; padding: 8px; } .logbar { gap: 8px; }
  .mini, .mini.wide { width: 100%; flex: 1; }
  th, td { padding: 8px 10px; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}
