:root {
  --bg: #080a12;
  --surface: #111625;
  --surface-2: #182036;
  --border: #263252;
  --text: #f3f6fc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #a855f7;
  --good: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  overflow-x: hidden;
  max-width: 100vw;
}

.app-shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top, 0px))
           calc(14px + env(safe-area-inset-right, 0px))
           calc(28px + env(safe-area-inset-bottom, 0px))
           calc(14px + env(safe-area-inset-left, 0px));
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.status-pill, .badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.status-pill.online {
  border-color: rgba(16, 185, 129, 0.5);
  color: #34d399;
}

.badge-accent {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(168, 85, 247, 0.2));
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 16px;
}

.full-span {
  grid-column: 1 / -1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  min-width: 0;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.card-head h2 {
  margin: 0;
  font-size: 1.02rem;
}

.row-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.row-form input {
  flex: 1 1 200px;
  min-width: 0;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 0;
}

input, select {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  background: var(--surface-2);
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
  border-color: transparent;
  color: #fff;
}

.btn-ghost:hover {
  border-color: var(--accent);
}

.btn-danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.nodes-grid, .jobs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.job-row, .node-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.job-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.job-title {
  font-weight: 600;
  font-size: 0.93rem;
  overflow-wrap: anywhere;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.muted-text {
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
}

.preview-video {
  width: 100%;
  max-height: 72vh;
  border-radius: 12px;
  background: #000;
}
