:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --border: #e7e7ea;
  --text: #1a1a1e;
  --text-muted: #6b6b72;
  --accent: #3b5bfd;
  --accent-soft: #eef0ff;
  --badge-empty-bg: #ececef;
  --badge-empty-text: #9a9aa1;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 6px 16px rgba(20, 20, 30, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f13;
    --surface: #1a1c22;
    --border: #2b2e36;
    --text: #f0f0f2;
    --text-muted: #9497a1;
    --accent: #8296ff;
    --accent-soft: #232647;
    --badge-empty-bg: #23252c;
    --badge-empty-text: #6c6f78;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 20px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

header.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 20px;
}

header.top .wrap {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  font-size: 1.15rem;
  margin: 0;
  letter-spacing: -0.01em;
}

nav.crumb a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

nav.crumb a:hover {
  text-decoration: underline;
}

/* Portfolio grid */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
}

.card .name {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.card .ticker {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.card .count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge.empty {
  background: var(--badge-empty-bg);
  color: var(--badge-empty-text);
}

/* Feed / today view */
ul.feed {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feed-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.feed-item a.title {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
  margin-bottom: 8px;
}

.feed-item a.title:hover {
  color: var(--accent);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pill {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.time-rel {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.time-abs {
  color: var(--text-muted);
  font-size: 0.72rem;
  opacity: 0.8;
}

/* Timeline view */
.ticker-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 18px;
}

.ticker-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

ul.timeline {
  list-style: none;
  padding: 0 0 0 22px;
  margin: 0;
  border-left: 2px solid var(--border);
}

li.timeline-item {
  position: relative;
  margin-bottom: 18px;
}

li.timeline-item .dot {
  position: absolute;
  left: -28px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

li.timeline-item.status-updated .dot {
  background: #e0a000;
  box-shadow: 0 0 0 3px color-mix(in srgb, #e0a000 18%, transparent);
}

.status-pill.status-new {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-pill.status-updated {
  background: color-mix(in srgb, #e0a000 18%, transparent);
  color: #b8860b;
}

li.timeline-item .card-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

li.timeline-item a.title {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.93rem;
  display: block;
  margin-bottom: 6px;
}

li.timeline-item a.title:hover {
  color: var(--accent);
}

.empty-state {
  color: var(--text-muted);
  padding: 24px 0;
  text-align: center;
  font-size: 0.9rem;
}

/* Runs view */
ul.run-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.run-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.run-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.run-duration {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.run-counts {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.run-counts strong {
  color: var(--text);
}

.run-error {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, #d64545 12%, transparent);
  color: #d64545;
  font-size: 0.78rem;
  word-break: break-word;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-ok {
  background: color-mix(in srgb, #2fa84f 16%, transparent);
  color: #2fa84f;
}

.status-error {
  background: color-mix(in srgb, #d64545 16%, transparent);
  color: #d64545;
}

/* Pipeline flow view — a live diagram, not a list */
.pipeline-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 0 8px;
}

.pipeline-cadence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 32px;
}

.pipeline-track {
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
}

.pipeline-node {
  flex: 1 1 130px;
  max-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pipeline-node.is-endpoint {
  background: transparent;
  box-shadow: none;
  border: 1px dashed var(--border);
}

.pipeline-node.is-process {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.pipeline-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.pipeline-node.is-endpoint .pipeline-icon {
  background: var(--badge-empty-bg);
}

.pipeline-name {
  font-weight: 700;
  font-size: 0.85rem;
}

.pipeline-node.is-endpoint .pipeline-name {
  color: var(--text-muted);
  font-weight: 600;
}

.pipeline-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.pipeline-connector {
  flex: 0 0 24px;
  position: relative;
  align-self: center;
  height: 2px;
  background: linear-gradient(
    to right,
    var(--border),
    color-mix(in srgb, var(--accent) 55%, var(--border))
  );
}

.pipeline-connector .flow-dot {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 70%, transparent);
  transform: translate(-50%, -50%);
  animation: pipeline-flow-x 2.4s linear infinite;
}

@keyframes pipeline-flow-x {
  0% {
    left: 0%;
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  88% {
    opacity: 1;
  }
  100% {
    left: 100%;
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .pipeline-track {
    flex-direction: column;
    align-items: center;
  }

  .pipeline-node {
    max-width: 280px;
    width: 100%;
  }

  .pipeline-connector {
    width: 2px;
    height: 28px;
    flex: 0 0 28px;
    background: linear-gradient(
      to bottom,
      var(--border),
      color-mix(in srgb, var(--accent) 55%, var(--border))
    );
  }

  .pipeline-connector .flow-dot {
    top: 0%;
    left: 50%;
    animation-name: pipeline-flow-y;
  }

  @keyframes pipeline-flow-y {
    0% {
      top: 0%;
      opacity: 0;
    }
    12% {
      opacity: 1;
    }
    88% {
      opacity: 1;
    }
    100% {
      top: 100%;
      opacity: 0;
    }
  }
}

/* Landing + login: full-bleed pages without the app header/crumb */
body.bare {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
}

.hero-kicker {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 12px 28px;
  border: none;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}

.cta:hover {
  transform: translateY(-1px);
}

.invite-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

/* Landing page */
.landing-wrap {
  flex: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 72px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 56px;
}

.hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.hero-title {
  margin: 0;
  font-size: 2.1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  max-width: 22ch;
}

.hero-sub {
  margin: 0;
  max-width: 52ch;
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
}

.feature-icon {
  font-size: 1.4rem;
  display: block;
  margin-bottom: 10px;
}

.feature-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.feature-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Login page */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.login-title {
  margin: 2px 0 6px;
  font-size: 1.3rem;
}

.login-error {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, #d64545 12%, transparent);
  color: #d64545;
  font-size: 0.82rem;
}

.login-field {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.login-field input {
  font: inherit;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.login-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-card .cta {
  width: 100%;
  margin-top: 6px;
}
