:root {
  --bg: #f4f6f9; --card: #fff; --line: #e3e7ee; --text: #1f2328; --muted: #6b7280;
  --ok: #1a7f37; --ok-bg: #e7f5ec; --warn: #b35c00; --warn-bg: #fff4e5; --bad: #b42318; --bad-bg: #fde8e6;
  --idle: #4b5563; --idle-bg: #eceff3; --accent: #2b59c3; --accent-bg: #e8eefb; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, "Segoe UI", system-ui, sans-serif; }
header { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand .sub { font-weight: 400; color: var(--muted); margin-left: 6px; font-size: 13px; }
nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav button { border: 0; background: none; padding: 6px 9px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--muted); }
nav button.on { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
nav button:hover { color: var(--text); }
.status { margin-left: auto; color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
@media (max-width: 1250px) { .brand .sub { display: none; } }
#net { width: 8px; height: 8px; border-radius: 50%; background: #c9ced6; display: inline-block; }
#net.ok { background: var(--ok); } #net.bad { background: var(--bad); }
main { padding: 16px 20px 40px; max-width: 1500px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }
h2 { font-size: 16px; margin: 22px 0 10px; } h2:first-child { margin-top: 4px; }
h3 { font-size: 14px; margin: 14px 0 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.card .k { color: var(--muted); font-size: 12px; } .card .v { font-size: 22px; font-weight: 600; margin-top: 2px; } .card .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
code, .mono { font-family: var(--mono); font-size: 12px; }
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; }
pre { background: #0f172a; color: #e5e7eb; padding: 10px 12px; border-radius: 8px; overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.4; margin: 6px 0; white-space: pre-wrap; word-break: break-word; max-height: 420px; }
pre.light { background: #f6f8fa; color: var(--text); border: 1px solid var(--line); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--idle-bg); color: var(--idle); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.accent { background: var(--accent-bg); color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 12px; }
.bar { height: 8px; background: #e9edf2; border-radius: 4px; overflow: hidden; min-width: 90px; }
.bar i { display: block; height: 100%; background: var(--ok); } .bar i.warn { background: #e8a33d; } .bar i.bad { background: var(--bad); }
.alerts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.alert { padding: 8px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); border: 1px solid #f3d9b1; cursor: pointer; }
.alert.bad { background: var(--bad-bg); color: var(--bad); border-color: #f1b7b2; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.group { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.group .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.group .head b { font-size: 15px; }
.group .task { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.map { overflow-x: auto; }
.map svg { display: block; }
.node { cursor: pointer; }
.node rect { stroke-width: 1.5; }
.node text { font-size: 12px; fill: var(--text); }
.node text.role { font-size: 11px; fill: var(--muted); }
.edge { stroke: #a3adbb; stroke-width: 1.5; fill: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 6px 0 2px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: 12px; color: var(--accent); }
.btn:hover { background: var(--accent-bg); }
input.filter { border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; font: inherit; width: 320px; max-width: 100%; }
.clip { max-height: 7.2em; overflow: hidden; position: relative; }
.clip.open { max-height: none; }
details > summary { cursor: pointer; color: var(--accent); font-size: 13px; list-style: none; }
details > summary::before { content: "▸ "; } details[open] > summary::before { content: "▾ "; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); }
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 20; overflow: auto; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 18px 20px; width: min(1000px, 100%); position: relative; }
.modal .close { position: absolute; right: 10px; top: 8px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 14px; }
.chart .col i { display: block; width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .col span { font-size: 10px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.empty { color: var(--muted); padding: 14px; text-align: center; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } main { padding: 12px; } header { padding: 8px 12px; } }
.answer { white-space: pre-wrap; word-break: break-word; font-size: 13px; background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.prompt { white-space: pre-wrap; word-break: break-word; font-size: 13px; background: #fffbe6; border: 1px solid #f1e3a1; border-radius: 8px; padding: 10px 12px; }
.err { color: var(--bad); }

/* --- действия, формы, терминал --- */
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #244aa3; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 2px 8px; font-size: 11px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.user-menu { position: relative; cursor: pointer; color: var(--text); font-weight: 600; }
.user-menu .dd { display: none; position: absolute; right: 0; top: 24px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; min-width: 180px; box-shadow: 0 6px 20px rgba(0,0,0,.08); z-index: 30; }
.user-menu.open .dd { display: block; }
.user-menu .dd a { display: block; padding: 6px 10px; color: var(--text); text-decoration: none; font-weight: 400; border-radius: 6px; font-size: 13px; }
.user-menu .dd a:hover { background: var(--accent-bg); }
form.f label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
form.f input[type=text], form.f input[type=password], form.f select, form.f textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
form.f textarea { min-height: 140px; font-family: inherit; resize: vertical; }
form.f .inline { display: flex; gap: 10px; flex-wrap: wrap; }
form.f .inline > * { flex: 1; min-width: 140px; }
.radio-row label, .check-row label { display: inline-flex; align-items: center; gap: 4px; margin: 2px 10px 2px 0; font-size: 13px; color: var(--text); }
.acc-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.acc-grid label { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12px; cursor: pointer; margin: 0; }
.acc-grid label.busy { background: var(--idle-bg); color: var(--muted); }
.acc-grid label.limit { background: var(--bad-bg); color: var(--bad); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 40; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.job-out { background: #0f172a; color: #e5e7eb; padding: 10px 12px; border-radius: 8px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 50vh; overflow: auto; }
.diff { font-family: var(--mono); font-size: 12px; white-space: pre; overflow: auto; max-height: 70vh; background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 8px 0; }
.diff div { padding: 0 10px; min-height: 1.3em; }
.diff .add { background: #e6ffec; color: #116329; } .diff .del { background: #ffebe9; color: #82071e; } .diff .hunk { background: #ddf4ff; color: #0550ae; } .diff .file { background: #eaeef2; font-weight: 600; }
.test-ok { color: var(--ok); } .test-bad { color: var(--bad); }
#tab-terminal { height: calc(100vh - 80px); }
#tab-terminal iframe { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 10px; background: #000; }
.keys { display: flex; gap: 4px; flex-wrap: wrap; }
.keys .btn { font-family: var(--mono); }
.live { font-size: 11px; color: var(--ok); }
.prompt-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.prompt-card .t { font-weight: 600; }
.linechart { width: 100%; height: 160px; }
.linechart path { fill: none; stroke-width: 1.5; }
.linechart text { font-size: 10px; fill: var(--muted); }
.linechart line { stroke: var(--line); }
.tabs2 { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs2 .btn.on { background: var(--accent-bg); }
@media (max-width: 700px) { .acc-grid { grid-template-columns: repeat(2, 1fr); } }

.term-frame { width: 100%; height: 62vh; border: 1px solid var(--line); border-radius: 8px; background: #000; }
.modal-box.wide { width: min(1300px, 100%); }

.group.ports { border-left: 3px solid #6f42c1; }
.feed { max-height: 50vh; overflow: auto; background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.feed .ev { padding: 4px 0; border-bottom: 1px dashed var(--line); white-space: pre-wrap; word-break: break-word; }
.feed .ev:last-child { border-bottom: 0; }
.feed .ev.tool { color: var(--accent); font-size: 12px; }
.feed .ev.res { color: var(--muted); font-size: 12px; } .feed .ev.res.bad { color: var(--bad); }
.screen-wrap { position: relative; }
pre.screen { max-height: 62vh; min-height: 300px; cursor: text; outline: none; border: 2px solid transparent; margin: 0; }
pre.screen:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.screen-hint { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }

/* --- мобильные устройства --- */
.panel { overflow-x: auto; }
.keys-mobile { display: none; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
@media (pointer: coarse) { .keys-mobile { display: flex; } .screen-hint { display: none; } }
@media (max-width: 900px) {
  header { gap: 8px; padding: 8px 10px; }
  .brand { font-size: 15px; }
  nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  nav::-webkit-scrollbar { display: none; }
  nav button { white-space: nowrap; padding: 6px 10px; }
  #clock { display: none; }
  .status { gap: 6px; }
  .modal { padding: 8px 6px; }
  .modal-box { padding: 14px 12px 16px; border-radius: 10px; }
  .modal .close { right: 6px; top: 2px; font-size: 26px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .card { padding: 10px 12px; } .card .v { font-size: 19px; }
  .groups { grid-template-columns: 1fr; }
  .btn.sm { padding: 6px 10px; font-size: 12px; }
  .btn { padding: 7px 12px; }
  table.wide { min-width: 640px; }
  td, th { padding: 6px 6px; }
  pre.screen { min-height: 200px; max-height: 45vh; font-size: 11px; }
  pre { font-size: 11px; }
  #tab-terminal { height: calc(100dvh - 130px); }
  input.filter { width: 100%; }
  .legend { gap: 8px; }
  .toast { bottom: 12px; left: 12px; right: 12px; transform: none; max-width: none; }
  .acc-grid { grid-template-columns: repeat(3, 1fr); }
  form.f .inline > * { min-width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 1px 0; } .kv div:nth-child(odd) { margin-top: 6px; }
  h2 { font-size: 15px; margin-top: 18px; }
}
