* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --purple: #a855f7;
}
body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.3rem; }
.topbar .user { color: var(--muted); font-size: 0.9rem; }
.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.btn:hover { background: #475569; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: var(--green); border-color: var(--green); color: white; }
.btn-danger { background: var(--red); border-color: var(--red); color: white; }
.btn-warn { background: var(--yellow); border-color: var(--yellow); color: white; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.container { max-width: 1400px; margin: 0 auto; padding: 2rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 1.25rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem; }
.card-head h3 { font-size: 1.05rem; }
.card-head .label { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }

.status-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}
.status-online { background: rgba(34,197,94,0.15); color: var(--green); }
.status-stopped, .status-errored { background: rgba(239,68,68,0.15); color: var(--red); }
.status-static { background: rgba(168,85,247,0.15); color: var(--purple); }
.status-remote { background: rgba(59,130,246,0.15); color: var(--blue); }
.status-unknown { background: rgba(245,158,11,0.15); color: var(--yellow); }
.status-partial { background: rgba(245,158,11,0.15); color: var(--yellow); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.kv { display: grid; grid-template-columns: 90px 1fr; gap: 0.4rem 1rem; font-size: 0.8rem; margin: 0.75rem 0; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); word-break: break-all; }
.kv a { color: var(--blue); text-decoration: none; }
.kv a:hover { text-decoration: underline; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

/* Jobs panel */
.jobs-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-top: 2rem;
}
.jobs-panel h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.job-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 1rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 0.85rem;
}
.job-row:last-child { border-bottom: none; }
.job-row:hover { background: rgba(255,255,255,0.03); cursor: pointer; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--panel); border-radius: 10px; max-width: 900px; width: 90%; max-height: 85vh; display: flex; flex-direction: column; border: 1px solid var(--border); }
.modal-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1rem 1.25rem; overflow-y: auto; flex: 1; }
.log-output {
  background: #0a0f1c;
  color: #cbd5e1;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 0.78rem;
  padding: 1rem;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 60vh;
  overflow-y: auto;
}

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); padding: 2rem; border-radius: 10px; width: 360px; border: 1px solid var(--border); }
.login-card h1 { margin-bottom: 1.5rem; text-align: center; }
.login-card label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.login-card input { width: 100%; padding: 0.6rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); margin-bottom: 1rem; font-size: 0.9rem; }
.login-card .err { color: var(--red); font-size: 0.8rem; margin-bottom: 1rem; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* App form */
.app-form .form-field { margin-bottom: 1rem; }
.app-form label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.app-form input, .app-form textarea {
  width: 100%; padding: 0.55rem 0.75rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.85rem; font-family: inherit;
}
.app-form input:focus, .app-form textarea:focus { outline: none; border-color: var(--blue); }
.app-form textarea { font-family: 'Menlo', 'Consolas', monospace; resize: vertical; }
.form-help { font-size: 0.7rem; color: var(--muted); margin-top: 0.25rem; }
.err { color: var(--red); font-size: 0.85rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }
.form-section { font-size: 0.7rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.08em; margin: 1.25rem 0 0.5rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); font-weight: 600; }
.app-form select { width: 100%; padding: 0.55rem 0.75rem; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; }

/* Git branch pill near status */
.branch-pill {
  display: inline-flex; align-items: center;
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'Menlo', 'Consolas', monospace;
  white-space: nowrap;
}
.branch-inline {
  display: inline-block;
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: 'Menlo', 'Consolas', monospace;
}

/* Multi-app deploy: pick apps, then deploy them in one action */
.batch-toolbar {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
  font-size: 0.85rem; color: var(--muted);
}
.batch-toolbar strong { color: var(--text); }
.batch-count { color: var(--blue); font-weight: 600; }
.card.selected { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.card-select { width: 16px; height: 16px; margin-top: 0.15rem; cursor: pointer; accent-color: var(--blue); flex: none; }
.batch-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.85rem 2rem;
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
  font-size: 0.85rem;
}
.batch-opt { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); }
.batch-opt select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0.3rem 0.5rem; font-size: 0.8rem;
}
.batch-opt input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--blue); cursor: pointer; }
.batch-warn { color: var(--yellow); font-size: 0.75rem; max-width: 32rem; }
.batch-pill {
  display: inline-block; margin-left: 0.5rem;
  background: rgba(59,130,246,0.15); color: var(--blue);
  border: 1px solid rgba(59,130,246,0.35);
  padding: 0.05rem 0.4rem; border-radius: 999px;
  font-size: 0.68rem; font-weight: 600;
}
.batch-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.batch-row {
  display: grid; grid-template-columns: 7.5rem 1fr auto auto;
  gap: 0.75rem; align-items: center;
  padding: 0.6rem 0.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.batch-row:last-child { border-bottom: none; }
.batch-row .status-pill { justify-content: center; }
.batch-list { margin: 0.5rem 0 0.75rem 1.25rem; font-size: 0.85rem; }
.batch-list li { margin-bottom: 0.25rem; }
