:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card-2: #232733;
  --fg: #e6e9ef;
  --muted: #8a92a3;
  --accent: #4f8cff;
  --accent-2: #2c6ee6;
  --danger: #ff5a5a;
  --ok: #4caf50;
  --warn: #ffb13b;
  --border: #2c3140;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
}
a, .link { color: var(--accent); background: none; border: none; cursor: pointer; padding: 0; }
button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 7px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { background: var(--accent-2); }
button.danger { background: var(--danger); }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--fg); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  background: var(--card-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
}
input { font-family: var(--mono); }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 16px; margin: 0; flex: 1; }
.me { color: var(--muted); }
.card {
  max-width: 520px;
  margin: 60px auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
}
.error { color: var(--danger); }
h2 { font-size: 15px; margin-top: 0; }
main { display: grid; grid-template-columns: 240px 1fr; gap: 14px; padding: 14px; }
nav#apps {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.app-item { cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.app-item:hover { background: var(--card-2); }
.app-item.active { background: var(--card-2); }
.app-item .appname { font-weight: 600; }
.envchip {
  display: block;
  color: var(--muted);
  padding-left: 14px;
  font-size: 12px;
}
#workspace { display: grid; grid-template-rows: auto auto auto; gap: 14px; }
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.envblock {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0;
  background: var(--card-2);
}
.prod { border-color: var(--warn); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.images { width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 5px 7px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); }
pre#log {
  background: #05070c;
  color: #d6e2ff;
  padding: 10px;
  border-radius: 6px;
  height: 360px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid var(--border);
}
.status-succeeded { color: var(--ok); }
.status-failed, .status-interrupted, .status-timed_out { color: var(--danger); }
.status-queued, .status-building, .status-deploying, .status-cloning, .status-checking_health { color: var(--warn); }
.tag { font-family: var(--mono); }
.confirm { background: rgba(255,90,90,.15); border: 1px solid var(--danger); padding: 8px; border-radius: 5px; }
.muted { color: var(--muted); }
ul { list-style: none; padding: 0; margin: 0; }

/* ---- badges ---- */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-succeeded, .badge-ok { background: rgba(76,175,80,.18); color: var(--ok); }
.badge-failed, .badge-interrupted, .badge-timed_out, .badge-error { background: rgba(255,90,90,.18); color: var(--danger); }
.badge-queued, .badge-building, .badge-deploying, .badge-cloning, .badge-checking_health, .badge-warn { background: rgba(255,177,59,.18); color: var(--warn); }
.badge-closed { background: rgba(138,146,163,.18); color: var(--muted); }

/* ---- env blocks ---- */
.env-meta { font-size: 12px; margin-top: 2px; display: flex; gap: 8px; }
.env-deployed {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.deployed-image {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(79,140,255,.12);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.refresh-img {
  font-size: 14px;
  padding: 2px 5px;
  line-height: 1;
  cursor: pointer;
}

/* ---- env var rows ---- */
.env-var-row {
  margin: 4px 0;
}
.env-var-row strong {
  width: 200px;
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

/* ---- images panel ---- */
.images-panel { margin-top: 14px; }
.images-grid { display: flex; flex-direction: column; gap: 12px; }
.image-section { }
.section-h {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0 0 6px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* ---- modal overlay (deploy picker) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  max-width: 680px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.modal-card h3 { margin-top: 0; }
.image-picker-list {
  max-height: 400px;
  overflow-y: auto;
  margin: 8px 0;
}
.picker-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 6px 0 2px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  background: var(--card);
}
.picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  transition: background .12s;
}
.picker-row:hover { background: var(--card-2); }
.picker-row code.tag { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- spinner ---- */
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-left: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- jobs list ---- */
#jobsList li {
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(44,49,64,.4);
}
#jobsList li:last-child { border-bottom: none; }