:root {
  --bg: #08090c;
  --surface: #101218;
  --surface-2: #161922;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef1f7;
  --muted: #8e96a8;
  --accent: #38e2b5;
  --accent-dim: rgba(56, 226, 181, 0.12);
  --blue: #58a6ff;
  --amber: #f5b942;
  --red: #f26464;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(8, 9, 12, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 13px;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--accent);
  border-radius: 5px;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
}
.brand-sub { color: var(--muted); font-weight: 500; letter-spacing: 0.04em; }

.nav-tabs { display: flex; gap: 6px; }
.tab-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s ease;
}
.tab-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab-btn.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.top-actions { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill.ok { color: var(--accent); border-color: rgba(56, 226, 181, 0.35); background: var(--accent-dim); }
.pill.warn { color: var(--amber); border-color: rgba(245, 185, 66, 0.35); }
.pill.err { color: var(--red); border-color: rgba(242, 100, 100, 0.35); }

.container { max-width: 1280px; margin: 0 auto; padding: 24px; }
.view { display: none; flex-direction: column; gap: 20px; }
.view.active { display: flex; }

.hero-strip {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.hero-strip h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.hero-strip p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.card-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.card-title { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.card-body { padding: 16px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat-val { font-size: 22px; font-weight: 600; font-family: var(--mono); margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.15s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.08); }
.btn-primary { background: var(--accent); color: #051610; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { border-color: rgba(242, 100, 100, 0.45); color: var(--red); }
.btn-sm { padding: 4px 9px; font-size: 11.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.est-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.notice {
  padding: 12px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
}
.notice strong { color: var(--text); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  z-index: 50;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  overflow: hidden;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13px;
  display: none;
  z-index: 60;
  max-width: 420px;
}
.toast.show { display: block; }
.toast.ok { border-color: var(--accent); }
.toast.err { border-color: var(--red); color: #ffb3b3; }

/* ─── Inline Real-CLI Cloud Shell & Per-VM Terminal ─── */
.btn-shell {
  border-color: rgba(57, 217, 138, 0.45);
  color: var(--accent);
  background: rgba(57, 217, 138, 0.08);
}
.btn-shell:hover { background: rgba(57, 217, 138, 0.18); }
.btn-shell:disabled { opacity: 0.4; cursor: not-allowed; }

.term-window {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 128px);
  min-height: 520px;
  background: #06090e;
  border: 1px solid rgba(57, 217, 138, 0.35);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

.term-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: #0d121a;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}

.term-window-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
  flex-shrink: 0;
}
.term-window-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.term-window-dots .dot.red { background: #ff5f57; }
.term-window-dots .dot.yellow { background: #febc2e; }
.term-window-dots .dot.green { background: #28c840; }

.term-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
}
.term-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #131a24;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.term-tab.active {
  background: rgba(57, 217, 138, 0.14);
  border-color: rgba(57, 217, 138, 0.55);
  color: var(--text);
}
.term-tab .tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.term-tab .tab-dot.live { background: var(--accent); }
.term-tab .tab-close {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
}
.term-tab .tab-close:hover { color: var(--red); }

.term-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.term-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #0a0e15;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.term-chip {
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.term-chip:hover { color: var(--accent); border-color: rgba(57, 217, 138, 0.5); }

.term-ssh-auth {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(245, 166, 35, 0.09);
  border-bottom: 1px solid rgba(245, 166, 35, 0.35);
}

.term-screen {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 28px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  color: #dbe7f3;
  background: #06090e;
  cursor: text;
  outline: none;
}
.term-scrollback {
  white-space: pre-wrap;
  word-break: break-word;
}
.term-line { margin: 0 0 2px 0; white-space: pre-wrap; word-break: break-word; }
.term-line.banner { color: #7ee3b0; margin-bottom: 8px; }
.term-line.err { color: #ff8a84; }
.term-line.sys { color: #8b9bb4; font-style: italic; }

.term-live-line {
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
  margin: 0;
  padding: 0;
  min-height: 1.55em;
}
.term-prompt-user { color: #39d98a; font-weight: 600; }
.term-prompt-sep { color: #7c8aa5; }
.term-prompt-cwd { color: #7ea6ff; font-weight: 600; }
.term-prompt-sig { color: #dbe7f3; }

.term-buf-before, .term-buf-after { color: #f3f7fc; }
.term-cursor {
  display: inline-block;
  min-width: 0.6em;
  background: #39d98a;
  color: #06090e;
  border-radius: 1px;
  animation: nxCursorBlink 1.05s steps(1, end) infinite;
}
.term-screen:not(.focused) .term-cursor {
  background: transparent;
  color: #f3f7fc;
  outline: 1px solid rgba(57, 217, 138, 0.75);
  animation: none;
}
@keyframes nxCursorBlink {
  0%, 49% { background: #39d98a; color: #06090e; }
  50%, 100% { background: transparent; color: #f3f7fc; }
}

.term-hidden-input {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
