:root {
  --bg: #0f1117;
  --surface: #181b23;
  --surface-2: #1f232e;
  --border: #2a2f3d;
  --text: #e6e9f0;
  --text-dim: #8b93a7;
  --green: #2dbe60;
  --red: #e5484d;
  --yellow: #f5b50a;
  --blue: #4d8df6;
  --gray: #6b7280;
  --radius: 10px;
  --mono: "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { color: var(--text); text-decoration: none; font-weight: 700; font-size: 16px; }
.refresh-indicator { color: var(--green); font-size: 10px; opacity: .4; transition: opacity .3s; }
.refresh-indicator.active { opacity: 1; }

main { max-width: 1200px; margin: 0 auto; padding: 28px; }
.loading { color: var(--text-dim); padding: 40px; text-align: center; }

h2 { font-size: 15px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; margin: 26px 0 14px; }
h2:first-child { margin-top: 0; }

a { color: var(--blue); text-decoration: none; }

.breadcrumb { color: var(--text-dim); margin-bottom: 18px; font-size: 13px; }
.breadcrumb a { color: var(--text-dim); }
.breadcrumb a:hover { color: var(--text); }

/* ---- pills de estado ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.success { background: rgba(45,190,96,.12); color: var(--green); }
.pill.error { background: rgba(229,72,77,.12); color: var(--red); }
.pill.running { background: rgba(77,141,246,.12); color: var(--blue); }
.pill.running::before { animation: blink 1.2s infinite; }
.pill.skipped { background: rgba(107,114,128,.15); color: var(--gray); }
.pill.healthy { background: rgba(45,190,96,.12); color: var(--green); }
.pill.unhealthy { background: rgba(229,72,77,.12); color: var(--red); }
.pill.exited { background: rgba(229,72,77,.12); color: var(--red); }
.pill.starting { background: rgba(245,181,10,.12); color: var(--yellow); }
@keyframes blink { 50% { opacity: .3; } }

/* ---- grid de dockers ---- */
.docker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.docker-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.docker-card .name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docker-card .meta { color: var(--text-dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docker-unavailable { color: var(--text-dim); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 16px; }

/* ---- cards de automatizaciones ---- */
.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-card {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 18px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  color: var(--text);
  transition: border-color .15s;
}
.project-card:hover { border-color: var(--blue); }
.project-card .pname { font-weight: 700; font-size: 15px; }
.project-card .stat { text-align: right; font-size: 12px; color: var(--text-dim); }
.project-card .stat b { display: block; font-size: 16px; color: var(--text); }
.project-card .stat b.err { color: var(--red); }
.project-card .stat b.ok { color: var(--green); }
.empty-state { color: var(--text-dim); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 24px; text-align: center; }

/* ---- tabla de runs ---- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
td.dim { color: var(--text-dim); }
.filters { margin-bottom: 14px; display: flex; gap: 8px; }
.filters button {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
  font-size: 13px;
}
.filters button.active { color: var(--text); border-color: var(--blue); background: rgba(77,141,246,.1); }

/* ---- detalle de run: timeline estilo Zapier ---- */
.run-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
}
.run-header .field { font-size: 12px; color: var(--text-dim); }
.run-header .field b { display: block; font-size: 14px; color: var(--text); font-weight: 600; }
.run-error {
  background: rgba(229,72,77,.08);
  border: 1px solid rgba(229,72,77,.35);
  color: var(--red);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 24px;
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
}

.timeline { position: relative; padding-left: 38px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}
.step { position: relative; margin-bottom: 14px; }
.step .dot {
  position: absolute;
  left: -38px;
  top: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  background: var(--surface-2);
  border: 2px solid var(--border);
  z-index: 1;
}
.step.success .dot { background: rgba(45,190,96,.15); border-color: var(--green); color: var(--green); }
.step.error .dot { background: rgba(229,72,77,.15); border-color: var(--red); color: var(--red); }
.step.running .dot { border-color: var(--blue); color: var(--blue); animation: blink 1.2s infinite; }
.step.skipped .dot { color: var(--gray); }

.step details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.step.error details { border-color: rgba(229,72,77,.45); }
.step summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.step summary::-webkit-details-marker { display: none; }
.step summary .sname { font-weight: 600; flex: 1; }
.step summary .sdur { color: var(--text-dim); font-size: 12px; font-family: var(--mono); }
.step-body { padding: 0 18px 16px; border-top: 1px solid var(--border); }
.step-body h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin: 14px 0 6px; }
.step-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  max-height: 420px;
}
.step-body .err-text { color: var(--red); font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }

.muted { color: var(--text-dim); }
.mono { font-family: var(--mono); font-size: 12.5px; }
