:root {
  color-scheme: dark;
  --bg: #080b0f;
  --panel: #0e141b;
  --panel-2: #111923;
  --panel-3: #151e28;
  --line: #263441;
  --line-strong: #3b4b5a;
  --text: #d9e6ef;
  --muted: #81919f;
  --faint: #5e6d7a;
  --cyan: #2dd4bf;
  --green: #8bd450;
  --amber: #f4b84a;
  --red: #ff5e7a;
  --violet: #b48cff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(45, 212, 191, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(139, 212, 80, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.app-frame {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  min-height: 100vh;
}

.top-chrome {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(240px, 1fr) minmax(180px, auto);
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 15, 0.88);
  backdrop-filter: blur(16px);
}

.brand,
.chrome-center,
.chrome-actions,
.section-head,
.action-row,
.terminal-toolbar,
.terminal-tools,
.rail-head,
.modal-head,
.modal-actions,
.preview-head,
.modal-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(45, 212, 191, 0.5);
  border-radius: 8px;
  background: #0c1718;
  color: var(--cyan);
  font-family: var(--mono);
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  letter-spacing: 0;
}

.brand span,
.chrome-center,
.modal-meta,
.modal-summary {
  color: var(--muted);
}

.brand span,
.chrome-center {
  font-size: 13px;
}

.chrome-center {
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 25, 35, 0.72);
  font-family: var(--mono);
}

.chrome-actions {
  justify-content: flex-end;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px rgba(94, 109, 122, 0.16);
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(139, 212, 80, 0.14), 0 0 18px rgba(139, 212, 80, 0.55);
}

.divider {
  width: 1px;
  height: 16px;
  background: var(--line-strong);
}

.main-stage {
  min-height: 0;
  padding: 18px;
}

.connect-view,
.workbench {
  min-height: calc(100vh - 100px);
}

.connect-view {
  display: grid;
  place-items: center;
}

.connect-grid {
  display: grid;
  grid-template-columns: minmax(360px, 580px) minmax(320px, 520px);
  gap: 18px;
  width: min(1120px, 100%);
}

.access-panel,
.boot-panel,
.terminal-workspace,
.script-rail,
.script-modal {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(14, 20, 27, 0.92);
  box-shadow: var(--shadow);
}

.access-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.section-head,
.rail-head,
.modal-head,
.preview-head,
.terminal-toolbar {
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(21, 30, 40, 0.9);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
}

.badge.safe {
  border-color: rgba(139, 212, 80, 0.45);
  color: var(--green);
}

.badge.medium {
  border-color: rgba(244, 184, 74, 0.48);
  color: var(--amber);
}

.badge.high {
  border-color: rgba(255, 94, 122, 0.48);
  color: var(--red);
}

.host-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.host-chip {
  display: grid;
  gap: 6px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
}

.host-chip.active {
  border-color: rgba(45, 212, 191, 0.7);
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.18);
}

.host-chip small {
  color: var(--muted);
  font-family: var(--mono);
}

.ssh-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 0.32fr);
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a1016;
  color: var(--text);
  outline: none;
}

input,
select {
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.primary-button {
  padding: 0 16px;
  background: var(--cyan);
  color: #06100f;
  font-weight: 850;
}

.secondary-button {
  padding: 0 13px;
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.ghost-button {
  padding: 0 12px;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.icon-button {
  width: 38px;
  padding: 0;
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.icon-button.danger {
  color: var(--red);
}

.boot-panel {
  overflow: hidden;
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  font-family: var(--mono);
  color: var(--muted);
}

.traffic {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.traffic.red {
  background: var(--red);
}

.traffic.amber {
  background: var(--amber);
}

.traffic.green {
  background: var(--green);
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.58;
}

#bootConsole {
  min-height: 430px;
  padding: 18px;
  color: #b9ffd7;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
}

.terminal-workspace,
.script-rail {
  min-height: calc(100vh - 100px);
  overflow: hidden;
}

.terminal-workspace {
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) 54px;
}

.terminal-toolbar {
  min-width: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.tab-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
}

.terminal-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 128px;
  max-width: 230px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1118;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.terminal-tab span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-tab.active {
  border-color: rgba(45, 212, 191, 0.6);
  color: var(--text);
  background: #0d1a1c;
}

.terminal-tab .tab-status {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px rgba(244, 184, 74, 0.44);
}

.terminal-tab .tab-status.ready {
  background: var(--green);
  box-shadow: 0 0 10px rgba(139, 212, 80, 0.52);
}

.terminal-tab .tab-status.error {
  background: var(--red);
  box-shadow: 0 0 10px rgba(255, 94, 122, 0.42);
}

.terminal-tab .tab-status.closed {
  background: var(--faint);
  box-shadow: none;
}

.terminal-screen {
  min-height: 0;
  overflow: auto;
  background: #070b0f;
}

#terminalOutput {
  min-height: 100%;
  padding: 18px;
  color: #c9f7d7;
}

.command-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.command-bar span {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 13px;
}

.command-bar input {
  border-color: transparent;
  background: transparent;
  font-family: var(--mono);
}

.script-rail {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
}

.script-search {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a1016;
  color: var(--muted);
}

.script-search input {
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a1016;
}

.segmented button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
}

.segmented button.active {
  background: var(--panel-3);
  color: var(--cyan);
}

.script-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.script-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1118;
  color: var(--text);
  text-align: left;
}

.script-card:hover {
  border-color: rgba(45, 212, 191, 0.5);
}

.script-meta,
.script-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.script-title {
  font-weight: 850;
}

.script-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 5, 8, 0.76);
  backdrop-filter: blur(14px);
  z-index: 20;
}

.script-modal {
  display: grid;
  gap: 16px;
  width: min(760px, 100%);
  max-height: min(860px, calc(100vh - 40px));
  overflow: auto;
  padding: 18px;
}

.modal-meta {
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
}

.modal-summary {
  line-height: 1.65;
}

.param-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.param-field {
  display: grid;
  gap: 7px;
}

.preview-block {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070b0f;
}

.preview-head {
  min-height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

#commandPreview {
  max-height: 240px;
  overflow: auto;
  padding: 14px;
  color: #b9ffd7;
}

.run-mode {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
}

.run-mode input {
  width: 16px;
  min-height: 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-3);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: 180ms ease;
  pointer-events: none;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .top-chrome {
    grid-template-columns: 1fr;
    height: auto;
    padding: 12px;
  }

  .app-frame {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .chrome-center,
  .chrome-actions {
    justify-content: flex-start;
  }

  .connect-grid,
  .workbench {
    grid-template-columns: 1fr;
  }

  .terminal-workspace,
  .script-rail {
    min-height: 540px;
  }
}

@media (max-width: 680px) {
  .main-stage {
    padding: 10px;
  }

  .connect-view,
  .workbench {
    min-height: auto;
  }

  .host-strip,
  .ssh-form,
  .param-grid {
    grid-template-columns: 1fr;
  }

  .action-row,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}
