:root {
  --bg: #0c1016;
  --bg-2: #121821;
  --panel: #171e28;
  --line: #2a3544;
  --text: #e7edf5;
  --muted: #8b98a8;
  --amber: #e8a54b;
  --mint: #6ee7c5;
  --rose: #f07178;
  --blue: #7aa2f7;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(232, 165, 75, 0.08), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(110, 231, 197, 0.06), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: Outfit, ui-sans-serif, system-ui, sans-serif;
}

.hidden { display: none !important; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button {
  background: var(--amber);
  color: #1a1206;
  border: 0;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
button:hover { filter: brightness(1.05); }
input, select, textarea {
  background: #0e141c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--amber); }
.muted { color: var(--muted); }
.error { color: var(--rose); min-height: 1.2em; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
}
.pill.online { color: var(--mint); border-color: rgba(110, 231, 197, 0.4); }
.pill.offline { color: var(--rose); }

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.gate-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
}
.gate-card h1 { margin: 0 0 0.4rem; font-size: 1.4rem; }
.gate-card form { display: grid; gap: 0.75rem; margin-top: 1rem; }
.gate-card label { display: grid; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }
.gate-card a { color: var(--amber); }

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.brand.compact { padding: 0.4rem 0.2rem 0.8rem; }
.brand strong { display: block; letter-spacing: 0.02em; }
.brand small { color: var(--muted); }
.logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 50%, var(--mint) 0 4px, transparent 5px),
    conic-gradient(from 210deg, var(--amber), transparent 40%, var(--mint), transparent 75%, var(--amber));
  box-shadow: inset 0 0 0 6px var(--bg-2);
}

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
}
.rail {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.search-wrap { margin-bottom: 0.6rem; }
.search-wrap input { width: 100%; }
.group-filter { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.7rem; }
.group-filter button { padding: 0.25rem 0.55rem; font-size: 0.78rem; background: #0e141c; color: var(--text); border: 1px solid var(--line); }
.group-filter button.active { border-color: var(--amber); color: var(--amber); }
.device-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.device {
  text-align: left;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0.7rem;
}
.device.active { border-color: var(--amber); }
.device .name { font-weight: 600; }
.device .meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.15rem; }
.dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 0.35rem;
  background: var(--rose);
}
.dot.on { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.rail-foot { display: flex; gap: 0.4rem; padding-top: 0.8rem; }
.rail-foot button { flex: 1; }

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.stage-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.1rem 1.2rem 0.4rem;
}
.stage-head h2 { margin: 0; }
.actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.actions button { background: #223044; color: var(--text); }
.tabs {
  display: flex;
  gap: 0.3rem;
  padding: 0 1.2rem;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  background: transparent;
  color: var(--muted);
  border-radius: 10px 10px 0 0;
  border: 1px solid transparent;
}
.tabs button.active { color: var(--text); border-color: var(--line); border-bottom-color: var(--bg); background: var(--bg); }
.panel {
  flex: 1;
  min-height: 0;
  padding: 0.9rem 1.2rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.toolbar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.desk-wrap, .term-wrap {
  flex: 1;
  min-height: 280px;
  background: #070a0e;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.desk-wrap canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  cursor: crosshair;
  background: #000;
}
.desk-vnc {
  position: absolute;
  inset: 0;
  background: #000;
}
.desk-vnc canvas { max-width: none; }
.upload-btn {
  display: inline-flex;
  align-items: center;
  background: var(--amber);
  color: #1a1206;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.upload-btn input { display: none; }
.roots { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.roots button { padding: 0.25rem 0.55rem; font-size: 0.78rem; background: #0e141c; color: var(--text); border: 1px solid var(--line); }
.pathbar a { color: var(--blue); text-decoration: none; }
.pathbar a:hover { text-decoration: underline; }
.files-browser tr { cursor: pointer; }
.hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}
.pathbar {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  color: var(--blue);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.table table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.9rem;
}
.table th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--panel); }
.table tr:hover td { background: rgba(232, 165, 75, 0.06); }
.table button { padding: 0.25rem 0.5rem; font-size: 0.78rem; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
}
.card h4 { margin: 0 0 0.4rem; color: var(--amber); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }
.card p { margin: 0.2rem 0; font-size: 0.92rem; }
.output {
  background: #070a0e;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
  min-height: 180px;
  overflow: auto;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
}
.settings { display: grid; gap: 1rem; overflow: auto; }
.settings article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.settings h3 { margin: 0 0 0.4rem; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.8rem;
}
.form-grid label { display: grid; gap: 0.35rem; font-size: 0.88rem; color: var(--muted); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .check {
  flex-direction: row;
  align-items: center;
  grid-template-columns: auto 1fr;
  color: var(--text);
}
.form-grid textarea { resize: vertical; min-height: 5rem; }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}
.token, .row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  background: #0e141c;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  word-break: break-all;
}
.events { max-height: 260px; overflow: auto; }
.events div { padding: 0.35rem 0; border-bottom: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { max-height: 40vh; }
}
