/* Zerglytics — Zerg AI design system */
:root {
  --bg:        #f4f0e7;
  --bg-card:   #fffaf0;
  --ink:       #111514;
  --muted:     #41504c;
  --muted-2:   #6b766f;
  --accent:    #b3662f;
  --accent-hi: #d57a32;
  --accent-soft: rgba(213, 122, 50, 0.12);
  --border:    rgba(17, 21, 20, 0.15);
  --border-soft: rgba(17, 21, 20, 0.08);
  --grid-line: rgba(17, 21, 20, 0.06);
  --shadow:    0 30px 80px rgba(17, 21, 20, 0.10);
  --mono:      ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans:      -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  --radius:    1.5rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(0deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
}
a { color: inherit; text-decoration: none; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 1.25rem 1.5rem; }
@media (min-width: 1024px) { .wrap { padding: 2rem; } }

/* ───── Header ───── */
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 2rem;
}
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.32em;
}
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--ink);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 4px;
  border-radius: 3px;
  background: var(--accent-hi);
}
.app-nav .meta {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.24em;
}

/* ───── Page header ───── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  color: var(--accent);
  margin: 0 0 0.5rem 0;
}
h1.title {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 0.4rem 0;
}
.sub {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

/* ───── Controls ───── */
.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.select {
  font-family: var(--sans);
  font-size: 0.875rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink);
  border-radius: 0.6rem;
  cursor: pointer;
}
.select:hover { border-color: var(--ink); }
.period {
  display: inline-flex;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 0.6rem;
  overflow: hidden;
}
.period button {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 0.55rem 0.75rem;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border-soft);
  cursor: pointer;
  color: var(--muted);
}
.period button:last-child { border-right: 0; }
.period button.active {
  background: var(--ink);
  color: var(--bg);
}

/* ───── Stat cards ───── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}
.stat-card .label {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--muted-2);
  margin: 0 0 0.5rem 0;
}
.stat-card .value {
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}
.stat-card .trend {
  font-family: var(--mono);
  font-size: 0.7rem;
  margin-top: 0.5rem;
  color: var(--muted-2);
}
.stat-card .trend.up   { color: #2a8556; }
.stat-card .trend.down { color: #b3662f; }

/* ───── Chart card ───── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.card h3 {
  font-size: 1rem;
  margin: 0 0 1rem 0;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card h3 .hint {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted-2);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.24em;
}

/* ───── Time-series SVG chart ───── */
.chart-svg {
  width: 100%;
  height: 240px;
  display: block;
}
.chart-svg .area    { fill: var(--accent-soft); }
.chart-svg .line    { fill: none; stroke: var(--accent-hi); stroke-width: 2; }
.chart-svg .point   { fill: var(--accent-hi); }
.chart-svg .axis    { stroke: var(--border-soft); stroke-width: 1; }
.chart-svg .label   {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--muted-2);
}
.chart-svg .hover {
  fill: var(--ink);
}

/* ───── Top lists ───── */
.lists-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 900px)  { .lists-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1280px) { .lists-grid { grid-template-columns: 1fr 1fr 1fr; } }

.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.list-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  background: linear-gradient(90deg, var(--accent-soft) var(--bar, 0%), transparent var(--bar, 0%));
  overflow: hidden;
}
.list-item .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .value {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.list-item.empty {
  color: var(--muted-2);
  font-style: italic;
  background: transparent;
}

/* ───── Breakdown grid (browsers / os / devices) ───── */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.bd-list .list-item .value::after {
  content: " · " attr(data-pct);
  color: var(--muted-2);
}

/* ───── Footer / privacy notice ───── */
.privacy {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  border: 1px dashed var(--border);
  border-radius: 1rem;
  background: var(--bg-card);
  font-size: 0.85rem;
  color: var(--muted);
}
.privacy strong { color: var(--ink); }
.privacy code {
  font-family: var(--mono);
  background: rgba(17, 21, 20, 0.05);
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
  font-size: 0.85em;
}

/* ───── Empty state ───── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state h2 { color: var(--ink); margin-bottom: 0.5rem; }

/* ───── Loading ───── */
.skeleton {
  background: linear-gradient(90deg, var(--border-soft) 0%, var(--accent-soft) 50%, var(--border-soft) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 0.5rem;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ───── Live (right now) widget ───── */
.live-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "dot meta"
    "pages pages";
  gap: 0.6rem 0.85rem;
  align-items: center;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  padding: 1rem 1.5rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
@media (min-width: 768px) {
  .live-card {
    grid-template-columns: auto 1fr 2.5fr;
    grid-template-areas: "dot meta pages";
    gap: 0 1.5rem;
    padding: 1rem 1.5rem;
  }
}
.live-dot {
  grid-area: dot;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #2a8556;
  box-shadow: 0 0 0 0 rgba(42, 133, 86, 0.55);
  animation: live-blink 2.4s ease-in-out infinite;
}
@keyframes live-blink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(42, 133, 86, 0.6); }
  50%      { box-shadow: 0 0 0 6px rgba(42, 133, 86, 0); }
}
.live-meta {
  grid-area: meta;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: rgba(244, 240, 231, 0.85);
  white-space: nowrap;
}
.live-meta strong {
  color: var(--accent-hi);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-right: 0.4rem;
  font-family: var(--sans);
  vertical-align: -2px;
}
.live-meta .hint {
  color: rgba(244, 240, 231, 0.5);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  margin-left: 0.6rem;
}
.live-pages {
  grid-area: pages;
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.4rem;
  margin: 0;
  padding: 0;
}
.live-pages .list-item {
  background: linear-gradient(90deg, rgba(213, 122, 50, 0.30) var(--bar, 0%), rgba(244, 240, 231, 0.06) var(--bar, 0%));
  font-size: 0.78rem;
  padding: 0.45rem 0.7rem;
  border-radius: 0.4rem;
}
.live-pages .name { color: var(--bg); }
.live-pages .value { color: var(--accent-hi); }
.live-pages .empty { color: rgba(244, 240, 231, 0.5); background: transparent; }

/* ───── Auto-refresh toggle ───── */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 0.6rem;
  user-select: none;
}
.toggle input { margin: 0; cursor: pointer; }

/* ───── Goals: extra dim percentage ───── */
.goal-value em {
  color: var(--muted-2);
  font-style: normal;
  font-size: 0.7rem;
  margin-left: 0.25rem;
}

/* ───── Funnel ───── */
.funnel {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  counter-reset: funnel;
}
.funnel-step {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.funnel-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.875rem;
}
.funnel-label {
  font-weight: 600;
  color: var(--ink);
}
.funnel-numbers {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  display: inline-flex;
  gap: 0.45rem;
  align-items: baseline;
}
.funnel-numbers strong {
  color: var(--ink);
  font-size: 0.9rem;
  font-family: var(--sans);
  font-weight: 700;
}
.funnel-numbers em {
  font-style: normal;
  color: var(--muted-2);
}
.funnel-drop {
  color: var(--accent);
  font-weight: 600;
}
.funnel-bar {
  height: 10px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}
.funnel-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-hi), var(--accent));
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ───── Deploys list ───── */
.deploys {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.deploy-item {
  border: 1px solid var(--border-soft);
  border-radius: 0.6rem;
  background: var(--bg-card);
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  transition: border-color 0.15s ease;
}
.deploy-item:hover { border-color: var(--border); }
.deploy-item.empty { color: var(--muted-2); font-style: italic; padding: 1rem; text-align: center; }

.deploy-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.deploy-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.deploy-item.status-success .deploy-dot { background: #2a8556; }
.deploy-item.status-failure .deploy-dot { background: #c0392b; }
.deploy-item.status-running .deploy-dot {
  background: var(--accent-hi);
  animation: live-blink 1.6s ease-in-out infinite;
}
.deploy-item.status-unknown .deploy-dot { background: var(--muted-2); }

.deploy-pill {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
  flex-shrink: 0;
}
.deploy-pill.prod    { background: var(--ink); color: var(--bg); }
.deploy-pill.preview { background: var(--accent-soft); color: var(--accent-deep, var(--accent)); border: 1px solid var(--accent); }

.deploy-repo a {
  color: var(--ink);
  font-weight: 600;
  border-bottom: 1px dotted var(--muted-2);
}
.deploy-repo a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.deploy-branch {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted-2);
  background: rgba(17, 21, 20, 0.04);
  padding: 0.1rem 0.45rem;
  border-radius: 0.3rem;
}
.deploy-item code {
  font-family: var(--mono);
  font-size: 0.7rem;
  background: rgba(17, 21, 20, 0.05);
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
  color: var(--ink);
}
.deploy-actor {
  color: var(--muted-2);
  font-size: 0.75rem;
}
.deploy-when {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted-2);
}
.deploy-row a[target="_blank"] {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.deploy-row a[target="_blank"]:hover { color: var(--accent-hi); }
