:root {
  --bg-0: #0b1c1f;
  --bg-1: #123038;
  --bg-2: #1a4450;
  --panel: rgba(244, 248, 247, 0.92);
  --panel-solid: #f4f8f7;
  --ink: #102226;
  --ink-muted: #4a646b;
  --line: rgba(16, 34, 38, 0.12);
  --accent: #e8a838;
  --accent-ink: #2a1c00;
  --ok: #1f8a5b;
  --warn: #c47a12;
  --err: #c23b3b;
  --glow: rgba(232, 168, 56, 0.35);
  --radius: 14px;
  --font: "Outfit", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-0);
}

body {
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(232, 168, 56, 0.28), transparent 60%),
    radial-gradient(700px 480px at 90% 10%, rgba(56, 196, 180, 0.22), transparent 55%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 45%, var(--bg-2));
  animation: drift 18s ease-in-out infinite alternate;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 20%, black, transparent 75%);
  opacity: 0.5;
}

@keyframes drift {
  from { filter: hue-rotate(0deg) saturate(1); }
  to { filter: hue-rotate(12deg) saturate(1.08); }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand-mark {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  color: #f7fbfa;
  text-shadow: 0 0 30px var(--glow);
  animation: brandIn 0.7s ease-out;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: rgba(247, 251, 250, 0.62);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes brandIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: rgba(247,251,250,0.82);
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}

.tab:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); }
.tab.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.view { display: none; animation: fadeUp 0.35s ease; }
.view.is-active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.section-head h1 {
  margin: 0;
  color: #f7fbfa;
  font-size: 1.7rem;
  font-weight: 700;
}

.section-head .btn.primary {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.section-head p {
  margin: 0.35rem 0 0;
  color: rgba(247,251,250,0.68);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.filters-bar {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) repeat(3, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  background: rgba(244, 248, 247, 0.12);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
}

.filters-bar .field {
  margin: 0;
}

.filters-bar .field span {
  color: rgba(247,251,250,0.7);
}

.filters-bar .field.grow {
  min-width: 0;
}

.filters-meta {
  margin: 0 0 1rem;
  color: rgba(247,251,250,0.65) !important;
}

@media (max-width: 900px) {
  .filters-bar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .filters-bar {
    grid-template-columns: 1fr;
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.card, .panel {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
}

.instance-card {
  position: relative;
  padding-top: 1.35rem;
  padding-right: 2.6rem;
}

.instance-card .instance-id {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
}

.instance-card .instance-id code {
  font-size: 0.78rem;
}

.instance-info-btn {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 2;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 34, 38, 0.18);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.instance-info-btn:hover {
  background: #fff;
  border-color: rgba(16, 34, 38, 0.35);
  transform: translateY(-1px);
}

.instance-info-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.info-dl {
  display: grid;
  gap: 0.65rem;
  margin: 0.25rem 0 1rem;
}

.info-dl > div {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
}

.info-dl dt {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.info-dl dd {
  margin: 0;
  font-size: 0.95rem;
}

.info-apps-title {
  margin: 0.5rem 0 0.4rem;
  font-size: 1rem;
}

.info-list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.info-list code {
  font-size: 0.78rem;
  opacity: 0.8;
}

.card.is-deleting {
  opacity: 0.45;
  filter: grayscale(0.85);
  pointer-events: none;
  user-select: none;
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.card.is-pending {
  position: relative;
  pointer-events: none;
  user-select: none;
  opacity: 0.72;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.card.is-pending::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: rgba(120, 130, 135, 0.28);
}

.card.is-pending-start {
  border-color: rgba(31, 138, 91, 0.45);
}

.card.is-pending-start::after {
  background: rgba(31, 138, 91, 0.38);
}

.card.is-pending-stop {
  border-color: rgba(194, 59, 59, 0.45);
}

.card.is-pending-stop::after {
  background: rgba(194, 59, 59, 0.38);
}

.card.is-pending-restart {
  border-color: rgba(196, 122, 18, 0.5);
}

.card.is-pending-restart::after {
  background: rgba(196, 122, 18, 0.4);
}

.card h3, .panel h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.muted {
  color: var(--ink-muted);
  font-size: 0.92rem;
  margin: 0;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.22rem 0.5rem;
  border-radius: 6px;
  background: rgba(16, 34, 38, 0.08);
  color: var(--ink);
}

.chip.ok { background: rgba(31, 138, 91, 0.15); color: var(--ok); }
.chip.warn { background: rgba(196, 122, 18, 0.15); color: var(--warn); }
.chip.err { background: rgba(194, 59, 59, 0.15); color: var(--err); }

.ports-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ports-editor {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: min(42vh, 360px);
  overflow: auto;
}

.port-row {
  display: grid;
  grid-template-columns: 7.5rem 7.5rem 1fr auto auto;
  gap: 0.5rem;
  align-items: end;
  padding: 0.55rem 0.65rem;
  background: rgba(16, 34, 38, 0.04);
  border-radius: 10px;
}

.port-row .field { margin: 0; }
.port-row .port-link-field {
  align-items: center;
  text-align: center;
}
.port-row .port-link-field input { width: auto; margin: 0.35rem auto 0; }
.port-nolink {
  cursor: default;
  opacity: 0.92;
}

@media (max-width: 760px) {
  .port-row {
    grid-template-columns: 1fr 1fr;
  }
}

.ports-row {
  margin-top: 0.55rem;
}

.ports-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 0.35rem;
}

a.chip.port-link {
  text-decoration: none;
  background: rgba(26, 68, 80, 0.12);
  color: #1a4450;
  border: 1px solid rgba(26, 68, 80, 0.2);
  transition: background 0.15s, transform 0.12s;
}

a.chip.port-link.vpn {
  background: rgba(14, 116, 144, 0.14);
  color: #0e7490;
  border-color: rgba(14, 116, 144, 0.28);
}

a.chip.port-link:hover {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  transform: translateY(-1px);
}

.share-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(16, 34, 38, 0.03);
}

.share-item .share-paths {
  min-width: 0;
  word-break: break-all;
}

.fs-toolbar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin: 0.5rem 0 0.75rem;
}

.fs-toolbar .btn.ghost {
  background: rgba(16, 34, 38, 0.05);
  color: var(--ink);
  border-color: var(--line);
}

.fs-path {
  font-family: var(--mono);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fs-list {
  height: min(45vh, 360px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(16, 34, 38, 0.03);
}

.fs-item {
  display: flex;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 0.65rem 0.8rem;
  font: inherit;
  cursor: pointer;
}

.fs-item:hover,
.fs-item.is-selected {
  background: rgba(232, 168, 56, 0.18);
}

.fs-item:last-child {
  border-bottom: none;
}

.fs-folder-mark {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.45rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(16, 34, 38, 0.1);
  color: var(--ink-muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
  align-items: center;
}

.instance-menu {
  position: relative;
  margin-left: auto;
}

.instance-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  padding-left: 0;
  padding-right: 0;
}

.hamburger-icon,
.hamburger-icon::before,
.hamburger-icon::after {
  display: block;
  width: 1rem;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  position: relative;
}

.hamburger-icon::before,
.hamburger-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.hamburger-icon::before { top: -5px; }
.hamburger-icon::after { top: 5px; }

.instance-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 20;
  min-width: 12.5rem;
  padding: 0.35rem;
  background: var(--panel-solid);
  border: 1px solid rgba(16, 34, 38, 0.14);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.instance-menu-panel[hidden] {
  display: none !important;
}

.instance-menu-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
}

.instance-menu-item:hover {
  background: rgba(16, 34, 38, 0.07);
}

.instance-menu-item:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s, border-color 0.2s;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

.btn.danger {
  background: rgba(194, 59, 59, 0.1);
  border-color: rgba(194, 59, 59, 0.25);
  color: var(--err);
}

.btn.btn-start {
  background: rgba(31, 138, 91, 0.16);
  border-color: rgba(31, 138, 91, 0.4);
  color: var(--ok);
}

.btn.btn-start:hover {
  background: rgba(31, 138, 91, 0.28);
}

.btn.btn-stop {
  background: rgba(194, 59, 59, 0.14);
  border-color: rgba(194, 59, 59, 0.4);
  color: var(--err);
}

.btn.btn-stop:hover {
  background: rgba(194, 59, 59, 0.26);
}

.btn.btn-restart {
  background: rgba(196, 122, 18, 0.16);
  border-color: rgba(196, 122, 18, 0.45);
  color: var(--warn);
}

.btn.btn-restart:hover {
  background: rgba(196, 122, 18, 0.3);
}

.btn.btn-term {
  background: rgba(56, 140, 160, 0.16);
  border-color: rgba(56, 140, 160, 0.45);
  color: #1a6a7a;
}

.btn.btn-term:hover {
  background: rgba(56, 140, 160, 0.28);
}

.btn.ghost {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
  color: #f7fbfa;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.field.inline {
  flex-direction: row;
  align-items: center;
}

.field span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.field.inline span { color: rgba(247,251,250,0.7); }

input, select, textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 90px;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.mono {
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  background: rgba(16, 34, 38, 0.06);
  border-radius: 10px;
  padding: 0.75rem;
  max-height: 280px;
  overflow: auto;
}

.progress-log {
  height: min(48vh, 380px);
  max-height: min(48vh, 380px);
  margin: 0.75rem 0 0;
  background: #0f1c1f;
  color: #d7ebe7;
  border: 1px solid rgba(16, 34, 38, 0.2);
}

.empty {
  color: rgba(247,251,250,0.7);
  padding: 2rem 0;
  text-align: center;
}

.toast {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  background: var(--panel-solid);
  color: var(--ink);
  padding: 0.85rem 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: min(420px, calc(100vw - 2rem));
  animation: fadeUp 0.25s ease;
}

.toast.err { border-left: 4px solid var(--err); }
.toast.ok { border-left: 4px solid var(--ok); }

.modal {
  border: none;
  border-radius: 16px;
  padding: 0;
  background: transparent;
  max-width: 520px;
  width: calc(100% - 2rem);
}

.modal.wide {
  width: min(820px, calc(100% - 2rem));
  max-width: 820px;
}

.modal.resizable {
  resize: both;
  overflow: auto;
  width: min(920px, calc(100% - 2rem));
  max-width: 96vw;
  min-width: min(420px, calc(100% - 2rem));
  height: min(78vh, 720px);
  max-height: 92vh;
  min-height: 360px;
}

.modal.resizable .modal-body {
  min-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.modal.resizable #modal-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow: auto;
}

.modal.resizable .modal-actions {
  flex-shrink: 0;
  margin-top: 0.75rem;
}

.modal.resizable .field-fill {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.modal.resizable textarea.os-script-editor,
.modal.resizable textarea.compose-editor {
  flex: 1 1 auto;
  min-height: 180px;
  height: auto;
  resize: none;
}

.modal textarea.compose-editor {
  min-height: 0;
  flex: 1;
  height: 100%;
  font-size: 0.8rem;
  line-height: 1.4;
  resize: none;
}

.apps-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: min(50vh, 420px);
  overflow: auto;
  margin: 0.75rem 0 0.25rem;
}

.apps-check-item {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(16, 34, 38, 0.03);
  cursor: pointer;
}

.apps-check-item:hover {
  background: rgba(16, 34, 38, 0.06);
}

.apps-check-item input {
  margin-top: 0.2rem;
}

.apps-check-item .apps-check-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.apps-check-item strong {
  font-size: 0.95rem;
}

.tpl-apps-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 0.75rem 0;
}

.modal-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0.25rem 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.modal-tab {
  border: 1px solid var(--line);
  background: rgba(16, 34, 38, 0.04);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.modal-tab:hover {
  background: rgba(16, 34, 38, 0.08);
}

.modal-tab.is-active {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

.modal-tab-panels {
  height: min(52vh, 420px);
  position: relative;
}

.modal-tab-panel {
  height: 100%;
  overflow: auto;
  box-sizing: border-box;
}

.modal-tab-panel[hidden] {
  display: none !important;
}

.modal-tab-panel .field-fill {
  height: calc(100% - 1.5rem);
  display: flex;
  flex-direction: column;
}

.modal-tab-panel[data-tpl-panel="variables"] .field-fill {
  height: calc(100% - 3.2rem);
}

.modal::backdrop {
  background: rgba(6, 16, 18, 0.65);
  backdrop-filter: blur(4px);
}

.modal-body {
  background: var(--panel-solid);
  padding: 1.25rem 1.35rem 1.1rem;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.modal-body h2 {
  margin: 0 0 0.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.modal-actions .btn.ghost {
  background: rgba(16, 34, 38, 0.05);
  color: var(--ink);
  border-color: var(--line);
}

.vpn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}

.funnel-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: -0.35rem 0 0.85rem;
}

.funnel-url {
  font-family: var(--mono);
  font-size: 0.88rem;
  word-break: break-all;
}

.stat {
  background: rgba(16, 34, 38, 0.05);
  border-radius: 12px;
  padding: 0.8rem;
}

.stat .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.stat .value {
  font-family: var(--mono);
  font-size: 0.95rem;
  margin-top: 0.25rem;
  word-break: break-all;
}

a.vpn-login-link {
  color: #8a5a00;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.user-label {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  white-space: nowrap;
}

.login-screen {
  min-height: 100vh;
  place-items: center;
  padding: 2rem 1rem;
}

/* display:grid debe ir solo cuando está visible; si no, pisa [hidden] y el login queda encima */
.login-screen:not([hidden]) {
  display: grid;
}

.login-screen[hidden],
#app-shell[hidden] {
  display: none !important;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  animation: login-in 0.45s ease-out;
}

@keyframes login-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.login-brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.25rem;
}

.login-brand .brand-mark {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ink);
  line-height: 1;
}

.login-brand .brand-sub {
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.login-panel h1 {
  margin: 0.4rem 0 0;
  font-size: 1.45rem;
}

.login-submit {
  width: 100%;
  margin-top: 0.35rem;
}

.login-error {
  margin: 0;
  color: var(--err);
  font-size: 0.9rem;
}

body.is-login .topbar,
body.is-login #app-shell {
  display: none !important;
}

/* --- Instancias (admin): pestañas y filtros --- */
.instances-admin-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.instances-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.instances-tab {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  color: rgba(247, 251, 250, 0.85);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.instances-tab:hover {
  background: rgba(255, 255, 255, 0.12);
}

.instances-tab.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.instances-filters {
  margin: 0;
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
}

.instances-filters .field span {
  color: rgba(247, 251, 250, 0.75);
}

.instances-filters select {
  background: rgba(16, 34, 38, 0.55);
  color: #f7fbfa;
  border-color: rgba(255, 255, 255, 0.18);
}

/* --- Configuración --- */
.settings-tabs {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding-bottom: 0.35rem;
}

.settings-tab {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  color: rgba(247,251,250,0.85);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.settings-tab:hover {
  background: rgba(255,255,255,0.12);
}

.settings-tab.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.settings-panel { display: none; }
.settings-panel.is-active { display: block; }

.section-head.compact {
  margin-bottom: 0.85rem;
}

.section-head.compact h2 {
  margin: 0 0 0.2rem;
  font-size: 1.15rem;
  color: #f7fbfa;
  font-weight: 700;
}

.section-head.compact .muted,
.section-head.compact p.muted {
  color: rgba(247,251,250,0.68);
}

.os-script-preview {
  font-family: var(--mono);
  font-size: 0.75rem;
  max-height: 4.5rem;
  overflow: hidden;
  white-space: pre-wrap;
  opacity: 0.75;
  margin: 0.4rem 0 0;
}

textarea.os-script-editor {
  min-height: 220px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.4;
}

.settings-panel[hidden] { display: none !important; }

/* --- Vista Red --- */
.network-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1rem;
  min-height: min(70vh, 720px);
  align-items: stretch;
}

.network-sidebar {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.network-sidebar-title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.network-sidebar-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}

.network-instance-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  padding-right: 0.15rem;
}

.network-inst-card {
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  cursor: grab;
  user-select: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.network-inst-card:active { cursor: grabbing; }

.network-inst-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 168, 56, 0.35);
  transform: translateY(-1px);
}

.network-inst-card h3 {
  margin: 0 0 0.2rem;
  font-size: 0.98rem;
}

.network-inst-card .muted { margin: 0; font-size: 0.8rem; }

.network-workspace {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.network-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.network-tab {
  appearance: none;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.55rem 0.9rem;
  border-radius: 10px 10px 0 0;
  color: var(--ink-muted);
  cursor: pointer;
}

.network-tab.is-active {
  color: var(--ink);
  background: rgba(16, 34, 38, 0.06);
}

.network-tab-add {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--ink);
  background: rgba(16, 34, 38, 0.06);
}

.network-tab-add:hover { background: rgba(232, 168, 56, 0.25); }

.network-canvas-wrap {
  flex: 1;
  min-height: 420px;
  position: relative;
}

.network-canvas {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(232,168,56,0.08), transparent 40%),
    linear-gradient(180deg, rgba(16,34,38,0.03), rgba(16,34,38,0.07));
  background-image:
    linear-gradient(rgba(16,34,38,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16,34,38,0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  overflow: auto;
}

.network-canvas.is-drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
  background-color: rgba(232, 168, 56, 0.08);
}

.network-canvas-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  max-width: 22rem;
  pointer-events: none;
  margin: 0;
}

.network-node {
  position: absolute;
  width: 160px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  box-shadow: 0 8px 22px rgba(0,0,0,0.12);
  cursor: grab;
  z-index: 2;
}

.network-node:active { cursor: grabbing; }

.network-node h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.network-node .node-actions {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.35rem;
}

.network-node .btn { padding: 0.25rem 0.5rem; font-size: 0.78rem; }

.network-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.net-type-actions {
  display: flex;
  gap: 0.75rem;
  margin: 1rem 0 0.5rem;
}

.net-type-actions .btn { flex: 1; }

@media (max-width: 900px) {
  .network-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .network-instance-list { max-height: 220px; }
  .network-canvas-wrap { min-height: 360px; }
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
  }
  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .user-bar {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
}

/* —— Ventanas de terminal —— */
.term-win {
  position: fixed;
  z-index: 40;
  display: flex;
  flex-direction: column;
  min-width: 360px;
  min-height: 220px;
  background: #0d1a1d;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  color: #e8f0ee;
}

.term-win.is-maximized {
  border-radius: 0;
}

.term-win.is-minimized,
.term-win[hidden] {
  display: none !important;
}

.term-win-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.45rem 0.35rem 0.75rem;
  background: linear-gradient(180deg, #1a3238, #14262b);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.term-win-titlebar:active {
  cursor: grabbing;
}

.term-win-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.term-win-icon {
  color: var(--accent);
  font-size: 0.7rem;
}

.term-win-status {
  font-weight: 400;
  font-size: 0.72rem;
  opacity: 0.75;
}

.term-win-controls {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.term-ctrl {
  width: 1.85rem;
  height: 1.55rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #e8f0ee;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.term-ctrl:hover {
  background: rgba(255, 255, 255, 0.14);
}

.term-ctrl.term-close:hover {
  background: rgba(194, 59, 59, 0.75);
  border-color: transparent;
}

.term-win-body {
  flex: 1;
  min-height: 0;
  padding: 0.35rem 0.45rem 0.55rem;
  background: #0d1a1d;
}

.term-xterm {
  width: 100%;
  height: 100%;
}

.term-xterm .xterm {
  height: 100%;
}

.term-xterm .xterm-viewport {
  overflow-y: auto !important;
}

.term-win-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 50%, rgba(255, 255, 255, 0.35) 50%);
  border-bottom-right-radius: 12px;
}

.term-win.is-maximized .term-win-resize {
  display: none;
}

.term-taskbar {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 45;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  pointer-events: none;
}

.term-taskbar[hidden] {
  display: none !important;
}

.term-task-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(16, 34, 38, 0.92);
  color: #f4f8f7;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.term-task-btn:hover {
  background: rgba(26, 68, 80, 0.95);
}

.term-task-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #38c4b4;
  box-shadow: 0 0 8px rgba(56, 196, 180, 0.7);
}
