:root {
  --bg-ink: #0a0806;
  --bg-raised: #13100a;
  --bg-card: #181410;
  --bg-terminal: #0b0805;
  --border: rgba(138, 109, 26, 0.32);
  --border-soft: rgba(138, 109, 26, 0.16);
  --gold: #c49a3e;
  --gold-light: #e8c878;
  --gold-dark: #8a6d1a;
  --gold-metallic: linear-gradient(135deg, #c49a3e 0%, #e8c878 50%, #8a6d1a 100%);
  --on-gold: #231c14;
  --ink: #f6efd8;
  --ink-dim: rgba(246, 239, 216, 0.68);
  --ink-mute: rgba(246, 239, 216, 0.38);
  --red: #e56b6b;
  --green: #7fc48b;
  --blue: #7fb6e0;
  --amber: #e8c878;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: 'Playfair Display', 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(196, 154, 62, 0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(138, 109, 26, 0.06), transparent 60%),
    var(--bg-ink);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--gold-light); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.75rem 2.25rem;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55);
}
.login-mark { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1.75rem; }
.login-mark-dot, .brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold-metallic);
  box-shadow: 0 0 0 4px rgba(196, 154, 62, 0.12);
}
.login-mark-label, .field-label, .group-label, .panel-title, .sidebar-section, .brand-tag, .pill, .chip {
  font-family: var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.login-title, .page-title, .brand-name {
  font-family: var(--serif);
}
.login-title { margin: 0 0 0.4rem; font-size: 2rem; }
.login-sub, .page-sub, .job-desc { color: var(--ink-dim); }
.field { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 1.25rem; }
.field-label { font-size: 0.7rem; color: var(--ink-mute); }
.input {
  width: 100%;
  background: rgba(11, 8, 5, 0.7);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.95rem;
}
.compact-input { max-width: 260px; }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(196, 154, 62, 0.18); }
.toggle { display: flex; align-items: center; gap: 0.7rem; }
.toggle-label { color: var(--ink); font-size: 0.9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.35rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn-gold {
  background: var(--gold-metallic);
  color: var(--on-gold);
  border-color: var(--gold-dark);
  box-shadow: 0 8px 18px rgba(119, 90, 25, 0.28);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 14px 26px rgba(119, 90, 25, 0.4); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-light); }
.btn-danger { background: rgba(229, 107, 107, 0.12); color: var(--red); border-color: rgba(229, 107, 107, 0.45); }
.btn-full { width: 100%; }
.btn-sm { padding: 0.45rem 0.95rem; font-size: 0.68rem; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg-raised) 0%, var(--bg-ink) 100%);
  padding: 1.75rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0.25rem 0.35rem; }
.brand-name { font-size: 1.05rem; font-weight: 700; }
.brand-tag, .sidebar-section { font-size: 0.62rem; color: var(--ink-mute); }
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--ink-dim);
  border: 1px solid transparent;
}
.nav-link:hover { background: rgba(196, 154, 62, 0.06); color: var(--ink); text-decoration: none; }
.nav-link.active { background: rgba(196, 154, 62, 0.11); color: var(--gold-light); border-color: var(--border-soft); }
.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.who { display: flex; align-items: center; gap: 0.55rem; font-size: 0.8rem; color: var(--ink-dim); }
.who-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.main { padding: 1.75rem 2.25rem 3rem; min-width: 0; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-soft);
}
.page-title { margin: 0 0 0.2rem; font-size: 2rem; }
.page-sub { margin: 0; font-size: 0.9rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.group-head { display: flex; align-items: baseline; gap: 1rem; margin: 2rem 0 1rem; }
.group-label, .panel-title { font-size: 0.7rem; color: var(--gold); }
.group-rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }
.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}
.pipeline-card, .panel, .pipeline-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 1.2rem 1.3rem;
}
.pipeline-card-head, .job-row, .pipeline-card-meta, .filter-row, .schedule-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}
.pipeline-card-meta { justify-content: flex-start; flex-wrap: wrap; }
.job-name { margin: 0; font-size: 1rem; font-weight: 600; }
.job-desc { margin: 0; font-size: 0.85rem; }
.job-warn {
  display: flex;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: rgba(229, 107, 107, 0.08);
  border: 1px solid rgba(229, 107, 107, 0.3);
  color: var(--red);
  font-size: 0.78rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: rgba(196, 154, 62, 0.1);
  border: 1px solid var(--border-soft);
  color: var(--gold-light);
  font-size: 0.64rem;
}
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.meta-kv .k { display: block; font-size: 0.62rem; color: var(--ink-mute); margin-bottom: 0.25rem; }
.meta-kv .v, .mono { font-family: var(--mono); color: var(--ink); }
.step-list, .schedule-list, .artifact-list { display: flex; flex-direction: column; gap: 0.7rem; }
.step-list-row { display: flex; gap: 0.6rem; align-items: center; }
.pipeline-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.9fr);
  gap: 1rem;
  align-items: start;
}

.table-wrap { overflow-x: auto; }
.runs-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
}
.runs-table thead th {
  background: #000;
  color: var(--gold-light);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.95rem 1rem;
}
.runs-table tbody td { padding: 0.85rem 1rem; border-top: 1px solid var(--border-soft); vertical-align: middle; }
.runs-table tbody tr:hover { background: rgba(196, 154, 62, 0.05); cursor: pointer; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 100px;
  font-size: 0.68rem;
  border: 1px solid transparent;
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; }
.pill.running { color: var(--blue); border-color: rgba(127, 182, 224, 0.35); background: rgba(127, 182, 224, 0.08); }
.pill.running .pill-dot { background: var(--blue); box-shadow: 0 0 10px var(--blue); }
.pill.success { color: var(--green); border-color: rgba(127, 196, 139, 0.35); background: rgba(127, 196, 139, 0.07); }
.pill.success .pill-dot { background: var(--green); }
.pill.failed { color: var(--red); border-color: rgba(229, 107, 107, 0.4); background: rgba(229, 107, 107, 0.08); }
.pill.failed .pill-dot { background: var(--red); }
.pill.cancelled, .pill.skipped { color: var(--ink-mute); border-color: var(--border-soft); background: rgba(246, 239, 216, 0.03); }
.pill.cancelled .pill-dot, .pill.skipped .pill-dot { background: var(--ink-mute); }
.pill.queued { color: var(--amber); border-color: rgba(232, 200, 120, 0.35); background: rgba(232, 200, 120, 0.06); }
.pill.queued .pill-dot { background: var(--amber); }

.detail-head { margin-bottom: 1rem; }
.detail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.run-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.step-rail {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 0.85rem;
}
.step-row {
  width: 100%;
  display: grid;
  grid-template-columns: 14px 32px minmax(0, 1fr) auto auto;
  gap: 0.7rem;
  align-items: center;
  text-align: left;
  padding: 0.75rem 0.8rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.step-row:hover, .step-row.active { background: rgba(196, 154, 62, 0.08); border-color: var(--border-soft); }
.step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-mute); }
.step-dot.running { background: var(--gold-light); box-shadow: 0 0 12px var(--gold-light); }
.step-dot.success { background: var(--green); }
.step-dot.failed { background: var(--red); }
.step-dot.skipped, .step-dot.cancelled { background: var(--ink-mute); }
.step-dot.queued { background: var(--amber); }
.step-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-log-pane {
  min-height: 520px;
  height: calc(100vh - 280px);
  overflow-y: auto;
  background: var(--bg-terminal);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.2rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.terminal-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.6rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px dashed var(--border-soft);
  color: var(--ink-mute);
  font-size: 0.7rem;
}
.term-dot { width: 9px; height: 9px; border-radius: 50%; }
.term-dot.r { background: var(--red); }
.term-dot.y { background: var(--amber); }
.term-dot.g { background: var(--green); }
.log-line { white-space: pre-wrap; word-break: break-word; padding: 1px 0; }
.log-seq, .log-ts { color: var(--ink-mute); margin-right: 0.8rem; user-select: none; }
.log-stream-meta .log-text { color: var(--gold-light); }
.log-stream-stderr .log-text { color: var(--red); }
.terminal-empty, .empty { color: var(--ink-mute); padding: 1rem 0; text-align: center; }
.sparkline { display: flex; align-items: end; gap: 0.35rem; margin-top: 1rem; min-height: 48px; }
.sparkline-bar { width: 12px; border-radius: 6px 6px 0 0; background: var(--gold-metallic); }
.artifact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: rgba(196, 154, 62, 0.04);
}

.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 2000;
}
.modal {
  width: min(560px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
}
.modal-title { margin: 0 0 0.8rem; }
.modal-body { color: var(--ink-dim); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.7rem; margin-top: 1rem; }
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.8rem 1rem;
  border-radius: 10px;
  margin-top: 0.6rem;
}
#toast-root { position: fixed; right: 1rem; bottom: 1rem; z-index: 3000; }
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(196, 154, 62, 0.2);
  border-top-color: var(--gold-light);
  display: inline-block;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .main { padding: 1.25rem; }
  .pipeline-detail-grid, .run-layout { grid-template-columns: 1fr; }
  .step-log-pane { height: 420px; min-height: 420px; }
}

@media (max-width: 768px) {
  .page-head, .toolbar, .filter-row, .job-row, .pipeline-card-head, .schedule-row { flex-direction: column; align-items: flex-start; }
  .main { padding: 1rem; }
  .step-row { grid-template-columns: 14px 28px minmax(0, 1fr); }
  .step-duration, .step-exit { display: none; }
}
