:root {
  --bg: #0b0f14;
  --surface: #121821;
  --surface-2: #1a2230;
  --border: rgba(148, 163, 184, 0.22);
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #38bdf8;
  --green: #22c55e;
  --red: #ef4444;
  --warn: #f59e0b;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  min-height: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 260px;
  flex: none;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 14px 40px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}
.sidebar h1 {
  font-size: 0.95rem;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.sidebar .sub {
  color: var(--muted);
  font-size: 0.75rem;
}
.tt-manager-link {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-decoration: none;
}
.tt-manager-link:hover {
  border-color: rgba(143, 215, 189, 0.55);
  background: #15202b;
  text-decoration: none;
}
.tt-manager-link img {
  display: block;
}
.nav-section { margin-bottom: 14px; }
.nav-section > .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 700;
}
.nav-section ul { list-style: none; margin: 0; padding: 0; }
.nav-section li { margin: 2px 0; }
.nav-section a {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.88rem;
}
.nav-section a.active, .nav-section a:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.nav-section .group-label {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 8px 10px 4px;
}
.nav-section .nested { padding-left: 10px; }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h2 { margin: 0 0 6px; font-size: 1.45rem; letter-spacing: -0.02em; }
.meta { color: var(--muted); font-size: 0.88rem; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-family: var(--mono);
}
.badge.ok { border-color: rgba(34,197,94,.4); color: var(--green); }
.badge.bad { border-color: rgba(239,68,68,.4); color: var(--red); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px 20px;
  margin-bottom: 18px;
}
.card h3 { margin: 0 0 12px; font-size: 1rem; }

/* Pipeline diagram */
.pipeline {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding: 8px 4px 16px;
}
.step {
  position: relative;
  min-width: 140px;
  max-width: 160px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 12px 14px;
  margin-right: 28px;
}
.step:last-child { margin-right: 0; }
.step-title { font-weight: 700; font-size: 0.82rem; margin-bottom: 4px; }
.step-detail { color: var(--muted); font-size: 0.72rem; line-height: 1.35; min-height: 2.4em; }
.step-running {
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  animation: blink 1s ease-in-out infinite;
}
.step-state {
  margin-top: 8px;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.step.is-running {
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.15);
}

.status-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #475569;
  box-shadow: 0 0 0 2px rgba(71,85,105,.35);
}
.status-dot.pending { background: #475569; }
.status-dot.running {
  background: var(--green);
  animation: blink 1s ease-in-out infinite;
  box-shadow: 0 0 0 3px rgba(34,197,94,.25);
}
.status-dot.done, .status-dot.approved { background: var(--green); box-shadow: 0 0 0 2px rgba(34,197,94,.3); }
.status-dot.error, .status-dot.rejected { background: var(--red); box-shadow: 0 0 0 2px rgba(239,68,68,.3); }
.status-dot.warning, .status-dot.skipped { background: var(--warn); box-shadow: 0 0 0 2px rgba(245,158,11,.3); }

@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

/* Dotted connector with moving dots */
.step::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -26px;
  width: 24px;
  height: 2px;
  background-image: linear-gradient(90deg, var(--accent) 40%, transparent 40%);
  background-size: 8px 2px;
  background-repeat: repeat-x;
  animation: dashmove 0.8s linear infinite;
  opacity: 0.7;
}
.step:last-child::after { display: none; }
@keyframes dashmove {
  from { background-position: 0 0; }
  to { background-position: 8px 0; }
}

.branches {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 150px;
  margin-right: 28px;
}
.branch-step {
  position: relative;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.runs-list { display: flex; flex-direction: column; gap: 10px; }
.run-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.run-row .name { font-weight: 600; font-size: 0.9rem; }
.run-row .when { color: var(--muted); font-size: 0.78rem; font-family: var(--mono); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: #041018;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
}
.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.mini-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface);
}
.mini-card h3 { margin: 0 0 6px; font-size: 1rem; }
.login-wrap {
  max-width: 380px;
  margin: 12vh auto;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.login-wrap label { display: block; font-size: 0.8rem; color: var(--muted); margin: 12px 0 6px; }
.login-wrap input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.error { color: var(--red); font-size: 0.85rem; margin-top: 10px; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
}
