:root {
  --bg: #000;
  --fg: #e8e8e8;
  --muted: #8a8a8a;
  --line: #2a2a2a;
  --ok: #3ddc84;
  --bad: #ff5555;
  --accent: #fff;
  --row: #0a0a0a;
  --row2: #111;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  min-height: 100%;
}
a { color: var(--fg); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 18px;
}
.brand { font-size: 20px; letter-spacing: 0.08em; text-transform: uppercase; }
.brand span { color: var(--muted); font-weight: 400; }
.nav a {
  margin-left: 14px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.nav a:hover, .nav a.active { border-bottom-color: var(--fg); }
.panel {
  border: 1px solid var(--line);
  background: var(--row);
  padding: 14px;
  margin-bottom: 14px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
}
input[type=password], input[type=text] {
  background: #000;
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 8px 10px;
  width: min(320px, 100%);
  font: inherit;
}
button, .btn {
  background: #000;
  color: var(--fg);
  border: 1px solid var(--fg);
  padding: 7px 12px;
  font: inherit;
  cursor: pointer;
}
button:hover, .btn:hover { background: #fff; color: #000; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.danger { border-color: var(--bad); color: var(--bad); }
.status-line { color: var(--muted); margin-bottom: 10px; }
.status-line .on { color: var(--ok); }
.status-line .off { color: var(--bad); }
#hostStatus { letter-spacing: 0.02em; }
.hvnc-overlay {
  position: absolute;
  left: 12px;
  top: 12px;
  right: 12px;
  z-index: 2;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  max-width: calc(100% - 24px);
}
.hvnc-overlay.live { display: none; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
tr:nth-child(even) td { background: var(--row2); }
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--bad);
}
.dot.on { background: var(--ok); }
.fm {
  display: none;
  border: 1px solid var(--line);
  margin-top: 10px;
  padding: 10px;
  background: #050505;
}
.fm.open { display: block; }
.crumbs { color: var(--muted); margin-bottom: 8px; word-break: break-all; }
.crumbs button.link {
  border: 0;
  padding: 0;
  color: var(--fg);
  text-decoration: underline;
  background: transparent;
}
.entries { max-height: 360px; overflow: auto; }
.entry {
  display: grid;
  grid-template-columns: 1fr 110px 150px;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid #1a1a1a;
  align-items: center;
}
.entry .name { cursor: pointer; }
.entry .name:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.progress {
  height: 6px;
  background: #1a1a1a;
  border: 1px solid var(--line);
  margin-top: 8px;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: #fff;
}
.log {
  height: 140px;
  overflow: auto;
  border: 1px solid var(--line);
  padding: 8px;
  background: #000;
  color: var(--muted);
  white-space: pre-wrap;
  font-size: 12px;
}
.hidden { display: none !important; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.kebab-wrap { position: relative; display: inline-block; }
.kebab-btn {
  border: 1px solid var(--line);
  background: #000;
  color: var(--fg);
  padding: 4px 10px;
  letter-spacing: 0.2em;
  line-height: 1;
}
.kebab-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 168px;
  background: #050505;
  border: 1px solid var(--line);
  z-index: 40;
  box-shadow: 0 8px 24px rgba(0,0,0,0.55);
}
.kebab-menu.open { display: block; }
.kebab-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid #1a1a1a;
  background: transparent;
  color: var(--fg);
  padding: 9px 12px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.kebab-item:last-child { border-bottom: 0; }
.kebab-item:hover { background: #161616; }
.kebab-item:disabled { opacity: 0.35; cursor: not-allowed; }
.kebab-item.kebab-danger { color: var(--bad); }
.kebab-item.kebab-danger:hover { background: #1a0808; color: #ff7777; }
.build-progress-track {
  height: 8px;
  background: #1a1a1a;
  border: 1px solid var(--line);
  overflow: hidden;
}
.build-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--fg);
  transition: width 0.25s ease;
}
.kebab-ico {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  opacity: 0.85;
}
.activity-cell { color: var(--muted); white-space: nowrap; }
.activity-cell.active { color: var(--ok); }

dialog.modal {
  position: relative;
  border: 1px solid var(--line);
  background: #050505;
  color: var(--fg);
  padding: 0;
  width: min(1100px, 96vw);
  max-height: 90vh;
  overflow: hidden;
}
dialog.modal.modal-fill {
  width: min(98vw, 1680px);
  height: 94vh;
  max-height: 94vh;
}
dialog.modal.modal-fill[open] {
  display: flex;
  flex-direction: column;
}
.hvnc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #0a0a0a;
}
.hvnc-toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}
.hvnc-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.hvnc-field input[type="number"] {
  width: 56px;
  padding: 4px 6px;
}
.hvnc-field select {
  padding: 4px 8px;
  background: #111;
  color: var(--fg);
  border: 1px solid var(--line);
}
.hvnc-codec {
  font-size: 12px;
  margin-left: 4px;
}
.hvnc-toolbar button.active {
  border-color: var(--fg);
  background: #1a1a1a;
}
.hvnc-stage {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  position: relative;
}
.hvnc-stage.fit #hvncCanvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
.hvnc-stage.zoom {
  overflow: auto;
  align-items: flex-start;
  justify-content: flex-start;
}
.hvnc-stage.zoom #hvncCanvas {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
}
#hvncCanvas {
  background: #0a0a0a;
  display: block;
  cursor: crosshair;
  outline: none;
}
dialog.modal::backdrop { background: rgba(0,0,0,0.72); }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
button.primary { border-color: var(--fg); background: #fff; color: #000; }
button.primary:hover { background: #ddd; }

.shell-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 520px;
  max-height: calc(90vh - 56px);
}
.shell-side {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #000;
}
.shell-side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}
.icon-btn {
  border: 1px solid var(--line);
  padding: 2px 8px;
  line-height: 1.2;
}
.shell-session-list {
  overflow: auto;
  flex: 1;
}
.shell-sess {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #151515;
  cursor: pointer;
}
.shell-sess:hover, .shell-sess.active { background: #121212; }
.shell-sess .meta { color: var(--muted); font-size: 11px; }
.shell-sess .kill {
  border: 0;
  background: transparent;
  color: var(--bad);
  padding: 0 4px;
}
.shell-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}
.shell-empty.show { display: flex; }
.shell-empty-ico {
  font-size: 28px;
  color: var(--fg);
  opacity: 0.5;
  margin-bottom: 4px;
}
.shell-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.shell-term-head {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.shell-out {
  margin: 0;
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: #000;
  color: #c8c8c8;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  min-height: 280px;
}
.shell-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.shell-input-row input {
  flex: 1;
  width: auto;
}
.shell-pick {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
}
.shell-pick.hidden { display: none !important; }

.desktop-wait {
  margin: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #000;
  color: var(--muted);
  font: inherit;
  white-space: pre-wrap;
  max-height: 120px;
  overflow: auto;
}
.desktop-wait.live { display: none; }
.desktop-stage {
  background: #000;
  min-height: 420px;
  max-height: calc(90vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
#desktopCanvas {
  max-width: 100%;
  height: auto;
  background: #0a0a0a;
  display: block;
  cursor: crosshair;
  outline: none;
}
.fm-title {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.kebab-fly {
  position: relative;
}
.kebab-fly > .kebab-sub {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 140px;
  margin-left: 2px;
  background: #050505;
  border: 1px solid var(--line);
  z-index: 50;
}
.kebab-fly:hover > .kebab-sub { display: block; }
.socks-body { min-height: 320px; display: flex; flex-direction: column; }
.socks-list { flex: 1; overflow: auto; padding: 8px 0; }
.socks-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #151515;
  align-items: center;
}
.socks-item .proxy {
  font-family: inherit;
  color: var(--fg);
  word-break: break-all;
}
.socks-item .meta { color: var(--muted); font-size: 11px; margin-top: 4px; }

@media (max-width: 760px) {
  .shell-layout { grid-template-columns: 1fr; }
  .shell-side { max-height: 180px; border-right: 0; border-bottom: 1px solid var(--line); }
  .kebab-fly:hover > .kebab-sub {
    left: auto; right: 0; top: 100%; margin-left: 0;
  }
}
