/* The One Ring — тёмная тема: чёрный, тёмно-синий, холодный синий акцент,
   золото только в знаке. Без внешних шрифтов и картинок. */

:root {
  --bg: #05070d;
  --bg-side: #070a13;
  --panel: #0b111f;
  --panel-2: #0f172a;
  --panel-3: #141e36;
  --line: #18213a;
  --line-2: #24304f;
  --text: #e8ecf5;
  --text-2: #a5afc6;
  --text-3: #6c7895;
  --accent: #4f7dff;
  --accent-2: #6d94ff;
  --accent-soft: rgba(79, 125, 255, .13);
  --accent-line: rgba(79, 125, 255, .38);
  --gold: #c9a65c;
  --ok: #3fcf8e;
  --ok-soft: rgba(63, 207, 142, .12);
  --warn: #f2b84b;
  --warn-soft: rgba(242, 184, 75, .12);
  --err: #f0627a;
  --err-soft: rgba(240, 98, 122, .12);
  --radius: 10px;
  --radius-s: 7px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", ui-monospace, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(79, 125, 255, .35); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
svg { display: block; flex: none; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1 1 auto; }

/* ------------------------------------------------------------- shell -- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 12px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 12.5px; font-weight: 650; letter-spacing: .19em; text-transform: uppercase; }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: .04em; margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-s);
  color: var(--text-2); font-weight: 500;
  border: 1px solid transparent;
}
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, .03); text-decoration: none; }
.nav a.on { color: var(--text); background: var(--accent-soft); border-color: rgba(79, 125, 255, .2); }
.nav a.on svg { color: var(--accent-2); }
.nav .count {
  margin-left: auto; font-size: 11px; color: var(--text-3);
  background: rgba(255, 255, 255, .05); border-radius: 20px; padding: 0 7px; line-height: 18px;
}
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #1b2a55, #101a36); border: 1px solid var(--line-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase;
}
.side-build { margin-top: 10px; font-size: 11px; color: var(--text-3); }

.main { min-width: 0; }
.page { max-width: 1240px; margin: 0 auto; padding: 26px 30px 60px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-title { font-size: 21px; font-weight: 650; letter-spacing: -.01em; }
.page-sub { color: var(--text-2); margin-top: 3px; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12.5px; margin-bottom: 8px; }
.crumbs a { color: var(--text-2); }

/* ----------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border-radius: var(--radius-s); border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, opacity .12s;
  user-select: none;
}
.btn:hover { background: var(--panel-3); border-color: #31406a; text-decoration: none; }
.btn:focus-visible, .input:focus-visible, .seg button:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.btn.danger { color: var(--err); border-color: rgba(240, 98, 122, .3); background: transparent; }
.btn.danger:hover { background: var(--err-soft); border-color: rgba(240, 98, 122, .5); }
.btn.danger.solid { background: var(--err); border-color: var(--err); color: #1a0509; }
.btn.small { height: 28px; padding: 0 9px; font-size: 12.5px; gap: 5px; }
.btn.wide { width: 100%; height: 38px; }
.icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center;
  border-radius: var(--radius-s); border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.icon-btn.ok { color: var(--ok); }

/* ------------------------------------------------------------ panels -- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-title { font-weight: 620; font-size: 14.5px; }
.card-body { padding: 16px; }
.card-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.section-title {
  font-size: 11.5px; font-weight: 620; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-3); margin: 26px 0 10px;
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: rgba(255, 255, 255, .05); color: var(--text-2); border: 1px solid var(--line-2);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(63, 207, 142, .25); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(242, 184, 75, .25); }
.badge.err { background: var(--err-soft); color: var(--err); border-color: rgba(240, 98, 122, .28); }
.badge.accent { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.err { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.busy { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, .025); color: var(--text-2);
  font-size: 13px;
}
.notice svg { margin-top: 2px; }
.notice.warn { border-color: rgba(242, 184, 75, .28); background: var(--warn-soft); color: #f0d59b; }
.notice.err { border-color: rgba(240, 98, 122, .3); background: var(--err-soft); color: #f7b3bf; }
.notice.info { border-color: var(--accent-line); background: var(--accent-soft); color: #c3d2ff; }

/* ------------------------------------------------------------- forms -- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12.5px; font-weight: 560; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.45; }
.hint.warn { color: var(--warn); }
.input {
  height: 36px; width: 100%; padding: 0 11px;
  background: #080c17; border: 1px solid var(--line-2); border-radius: var(--radius-s);
  color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: #33426c; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1 1 auto; min-width: 0; }
.input-affix { display: flex; align-items: stretch; }
.input-affix .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-affix .affix {
  display: flex; align-items: center; padding: 0 11px; white-space: nowrap;
  border: 1px solid var(--line-2); border-left: 0; border-radius: 0 var(--radius-s) var(--radius-s) 0;
  background: var(--panel-2); color: var(--text-2);
}
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; color: var(--text-2); font-size: 13px; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: #080c17; border: 1px solid var(--line-2); border-radius: var(--radius-s);
}
.seg button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 5px; background: transparent;
  color: var(--text-2); font-weight: 550; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

/* ------------------------------------------------------- copy field -- */
.copy {
  display: flex; align-items: center; gap: 4px;
  background: #070b15; border: 1px solid var(--line-2); border-radius: var(--radius-s);
  padding: 0 4px 0 11px; min-height: 36px;
}
.copy .val {
  flex: 1 1 auto; min-width: 0; font-family: var(--mono); font-size: 12px; color: #c6d1ea;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: all;
}
.copy.multi { align-items: flex-start; padding: 9px 4px 9px 11px; }
.copy.multi .val { white-space: pre-wrap; word-break: break-all; user-select: text; max-height: 190px; overflow: auto; }
.link-row { display: flex; flex-direction: column; gap: 6px; }
.link-row .label { display: flex; align-items: center; gap: 8px; }

/* ------------------------------------------------------ servers list -- */
.srv-list { display: flex; flex-direction: column; gap: 10px; }
.srv {
  display: grid; grid-template-columns: minmax(200px, 1.25fr) minmax(170px, 1fr) minmax(250px, 1.5fr) auto;
  align-items: center; gap: 18px;
  padding: 14px 16px; color: inherit;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .12s, background .12s;
}
.srv:hover { border-color: var(--line-2); background: #0d1424; text-decoration: none; }
.srv-name { font-weight: 620; font-size: 14.5px; display: flex; align-items: center; gap: 9px; }
.srv-host { color: var(--text-3); font-family: var(--mono); font-size: 12px; margin-top: 3px; padding-left: 17px; }
.srv-meta { color: var(--text-2); font-size: 12.5px; }
.srv-meta div + div { color: var(--text-3); margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid var(--line); color: var(--text-3); background: transparent;
}
.chip.on { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }
.chip .dot { width: 6px; height: 6px; box-shadow: none; }
.chip .up { color: var(--warn); font-weight: 700; }

.empty {
  border: 1px dashed var(--line-2); border-radius: var(--radius);
  padding: 46px 24px; text-align: center; color: var(--text-2);
}
.empty h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }

/* ------------------------------------------------------- server page -- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.stat .k { font-size: 11.5px; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; }
.stat .v { font-size: 15px; font-weight: 600; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s { font-size: 12px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { height: 4px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter i.warn { background: var(--warn); }
.meter i.err { background: var(--err); }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.protos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.proto .card-head { padding: 13px 16px; }
.proto-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--panel-3); border: 1px solid var(--line-2); color: var(--accent-2);
}
.proto-icon.off { color: var(--text-3); background: transparent; }
.proto-desc { color: var(--text-2); font-size: 13px; }
.proto-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); }
.proto-meta b { color: var(--text); font-weight: 560; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: rgba(255, 255, 255, .02); }
.tbl .actions { text-align: right; white-space: nowrap; }
.tbl .actions .icon-btn { margin-left: 2px; }

/* ------------------------------------------------------------ modals -- */
.overlay {
  position: fixed; inset: 0; z-index: 50; padding: 5vh 16px;
  background: rgba(2, 4, 9, .72); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; overflow-y: auto;
  animation: fade .14s ease-out;
}
.modal {
  width: 100%; max-width: 540px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow);
  animation: rise .16s ease-out;
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; }
.modal-title { font-size: 16px; font-weight: 640; }
.modal-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.modal-body { padding: 4px 18px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.qr { background: #fff; border-radius: 10px; padding: 6px; width: min(340px, 100%); margin: 0 auto; }
.qr svg { width: 100%; height: auto; }

/* ----------------------------------------------------------- console -- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(620px, 100vw);
  background: #070a13; border-left: 1px solid var(--line-2); box-shadow: var(--shadow);
  display: flex; flex-direction: column; animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-title { font-weight: 630; font-size: 14.5px; }
.console {
  flex: 1 1 auto; overflow: auto; padding: 12px 16px 20px;
  font-family: var(--mono); font-size: 12px; line-height: 1.6; color: #b5c0d9;
}
.console .ln { white-space: pre-wrap; overflow-wrap: anywhere; padding-left: 22px; }
.console .step {
  display: flex; align-items: center; gap: 8px; margin: 12px 0 4px;
  font-family: var(--font); font-size: 13px; font-weight: 620; color: var(--text);
}
.console .step:first-child { margin-top: 0; }
.console .step .mark { width: 14px; height: 14px; display: grid; place-items: center; color: var(--ok); }
.console .warnln { color: var(--warn); }
.console .failln { color: var(--err); font-weight: 600; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.job-pill {
  position: fixed; right: 18px; bottom: 18px; z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: var(--panel-2); border: 1px solid var(--accent-line); border-radius: 30px;
  box-shadow: var(--shadow); cursor: pointer; font-weight: 560;
}

.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .18); border-top-color: var(--accent-2); animation: spin .7s linear infinite; flex: none; }
.spin.big { width: 26px; height: 26px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; padding: 70px 0; }

/* ------------------------------------------------------------ toasts -- */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 9px 14px; max-width: min(560px, 92vw);
  background: #121b31; border: 1px solid var(--line-2); border-radius: 9px; box-shadow: var(--shadow);
  font-weight: 520; animation: rise .16s ease-out;
}
.toast.ok svg { color: var(--ok); }
.toast.err { border-color: rgba(240, 98, 122, .45); }
.toast.err svg { color: var(--err); }

/* -------------------------------------------------------------- auth -- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 480px at 50% -8%, rgba(49, 86, 200, .2), transparent 70%),
    radial-gradient(600px 400px at 85% 110%, rgba(30, 52, 120, .16), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 392px; padding: 30px 28px 26px;
  background: rgba(11, 17, 31, .88); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow);
}
.auth-card.wide { max-width: 460px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; text-align: center; }
.auth-brand .brand-name { font-size: 14px; letter-spacing: .24em; }
.auth-title { font-size: 17px; font-weight: 640; text-align: center; margin-bottom: 4px; }
.auth-sub { color: var(--text-2); text-align: center; font-size: 13px; margin-bottom: 20px; }
.code-input { font-family: var(--mono); font-size: 18px; letter-spacing: .32em; text-align: center; height: 44px; }
.steps { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.steps i { width: 28px; height: 3px; border-radius: 3px; background: var(--line-2); }
.steps i.on { background: var(--accent); }

/* -------------------------------------------------------- responsive -- */
@media (max-width: 1080px) {
  .protos { grid-template-columns: 1fr; }
  .srv { grid-template-columns: minmax(0, 1fr) auto; }
  .srv .srv-meta { display: none; }
  .srv .chips { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 4px; }
  .brand-text { display: none; }
  .nav { flex-direction: row; flex: 1 1 auto; overflow-x: auto; }
  .nav a span.t { display: none; }
  .nav .count { display: none; }
  .side-foot { margin: 0; padding: 0; border: 0; }
  .side-build, .side-user .grow { display: none; }
  .page { padding: 18px 14px 50px; }
  .page-head { flex-wrap: wrap; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}

/* Переключатель не растягивается на всю ширину поля. */
.field > .seg { align-self: flex-start; }
.field > label { cursor: default; }

@media (max-width: 1220px) {
  .protos { grid-template-columns: 1fr; }
}

/* Тем, кто просил систему обходиться без анимации. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
