:root {
  --bg: #10141a;
  --panel: #1a2029;
  --panel-2: #222a35;
  --border: #2e3947;
  --text: #d7dee8;
  --muted: #8494a7;
  --accent: #4da3ff;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }

button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: #1f4d80; border-color: #2a6cb3; }
button.primary:hover { background: #266099; }
button.danger:hover { border-color: var(--red); color: var(--red); }
button.small { padding: 3px 9px; font-size: 13px; }

input, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

.hidden { display: none !important; }

/* ---- шапка ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .spacer { flex: 1; }

/* ---- логин ---- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100% - 53px);
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  width: 340px;
}
.login-box h2 { margin: 0 0 16px; font-size: 16px; }
.login-box input { margin-bottom: 10px; }
.login-box button { width: 100%; margin-top: 12px; }
.error-text { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---- таблица машин ---- */
.content { padding: 20px; max-width: 1200px; margin: 0 auto; }

table.machines {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.machines th, .machines td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.machines th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--panel-2);
}
.machines tr:last-child td { border-bottom: none; }
.machines .name { font-weight: 600; }
.machines .note, .machines .host { color: var(--muted); font-size: 12px; }
.machines .note.mig { color: var(--yellow); }
.machines .note.mig-err { color: var(--red); }
.machines .actions { white-space: nowrap; text-align: right; }
.machines .actions button { margin-left: 6px; }
.empty-row td { color: var(--muted); text-align: center; padding: 30px; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge.on { background: rgba(63,185,80,.15); color: var(--green); }
.badge.off { background: rgba(132,148,167,.15); color: var(--muted); }
.badge.setup { background: rgba(210,153,34,.15); color: #d29922; }
.badge.err { background: rgba(248,81,73,.15); color: var(--red); }
.setup-detail { color: var(--muted); font-size: 12px; margin-top: 4px; max-width: 260px; }
.setup-detail.err { color: var(--red); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---- модалки ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  width: 560px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  overflow: auto;
}
.modal h3 { margin: 0 0 16px; font-size: 15px; }
.modal label { display: block; color: var(--muted); font-size: 12px; margin: 12px 0 4px; }
.modal label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.modal label.check input { width: auto; }
.users-table { margin-bottom: 16px; }
.modal .row { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

.code-box {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 26px;
  letter-spacing: .15em;
  text-align: center;
  color: var(--yellow);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  user-select: all;
}
.cmd-box {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.cmd-box textarea {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  resize: none;
  height: 74px;
  white-space: pre;
}
.hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ---- страницы VNC/SSH ---- */
.session-page { display: flex; flex-direction: column; height: 100%; }
.session-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.session-bar .status { color: var(--muted); font-size: 13px; }
.session-bar .status.ok { color: var(--green); }
.session-bar .status.err { color: var(--red); }
.session-body { flex: 1; min-height: 0; position: relative; background: #000; }
#vnc-screen { width: 100%; height: 100%; }
#term { width: 100%; height: 100%; padding: 4px; }

/* ---- лог обновления сервера ---- */
.update-log {
  max-height: 240px;
  overflow: auto;
  background: #0d1117;
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}