/* Zerglytics — Zerg AI design system */
:root {
  --bg:        #f4f0e7;
  --bg-card:   #fffaf0;
  --ink:       #111514;
  --muted:     #41504c;
  --muted-2:   #525d57;
  --accent:    #b3662f;
  --accent-hi: #d57a32;
  --accent-soft: rgba(213, 122, 50, 0.12);
  --blue:      #2f6f9f;
  --green:     #0a8f68;
  --agent-dark:#06100a;
  --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);
  --font-body: var(--sans);
  --font-mono: var(--mono);
  --mono:      ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans:      -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  --radius:    8px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
}

* { 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;
  max-width: 100%;
}
.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);
  white-space: nowrap;
}
.period button:last-child { border-right: 0; }
.period button.active,
.period button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}
@media (max-width: 720px) {
  /* On narrow screens, allow the period selector to scroll horizontally
     instead of wrapping or overflowing the page. */
  .period {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  .period button { scroll-snap-align: start; }
}

@media (max-width: 480px) {
  /* Stack the controls row at phone widths — property select on its own
     line, period buttons span full width, auto-refresh + export get pushed
     below the period bar so the row doesn't pinch. */
  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .controls .control-label { margin-right: 0; }
  .controls .period { width: 100%; }
  .controls .toggle { justify-content: flex-start; }
}

/* ───── 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; }

/* Period-over-period delta pill — visually subordinate to the primary metric. */
.stat-card .delta {
  font-family: var(--mono);
  font-size: 0.62rem;
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: #4a4540;
  background: transparent;
  letter-spacing: 0.04em;
  font-weight: 600;
  opacity: 0.92;
}
/* Darker greens/reds for WCAG AA contrast (4.5:1) on the soft backgrounds. */
.stat-card .delta.up-good   { color: #1a5a3a; border-color: #b9d8c5; background: #ecf6f0; }
.stat-card .delta.down-good { color: #1a5a3a; border-color: #b9d8c5; background: #ecf6f0; }
.stat-card .delta.up-bad,
.stat-card .delta.down-bad  { color: #8a3d12; border-color: #e7c8a8; background: #fbf1e6; }
.stat-card .delta.flat,
.stat-card .delta.neutral   { color: #4a4540; }

/* ───── 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 h2,
.card h3 {
  font-size: 1rem;
  margin: 0 0 1rem 0;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card h2 .hint,
.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 .line-prev {
  fill: none;
  stroke: var(--muted-2);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  opacity: 0.6;
}
.chart-svg .point   { fill: var(--accent-hi); }
.chart-svg .axis    { stroke: var(--border-soft); stroke-width: 1; }
.legend-prev {
  display: inline-block;
  border-bottom: 1.5px dashed #4a4540;
  padding-bottom: 1px;
  margin-left: 0.25rem;
  color: #4a4540;
}
.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); }

/* Action-led empty state for the goals card. */
.list-item.empty-cta {
  display: block;
  padding: 0.75rem 0;
  font-style: normal;
  background: transparent;
}
.list-item.empty-cta .empty-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
  color: var(--ink);
}
.list-item.empty-cta .empty-sub {
  margin: 0 0 0.6rem 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}
.list-item.empty-cta .empty-sub code {
  background: var(--bg);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  font-size: 0.8rem;
}
.list-item.empty-cta .empty-code {
  background: var(--ink);
  color: var(--bg);
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.78rem;
  margin: 0 0 0.5rem 0;
  overflow-x: auto;
}
.list-item.empty-cta .empty-code code { color: inherit; background: transparent; padding: 0; }
.list-item.empty-cta .empty-copy {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted-2);
  cursor: pointer;
}
.list-item.empty-cta .empty-copy:hover { color: var(--ink); border-color: var(--ink); }

/* Sub-headings inside breakdown grid (Devices / Browsers / OS).
   Styled like the old hint text, but a real h3 for screen-reader semantics. */
.breakdown-h {
  margin: 0 0 0.5rem 0;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* Auto-refresh toggle label */
.toggle .toggle-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.toggle input:checked ~ .toggle-label { color: var(--ink); }

/* ───── AI digest card ───── */
.digest-card {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--accent-soft) 100%);
}
.digest-body { font-family: var(--mono); font-size: 0.85rem; }
.digest-cta {
  margin: 0 0 0.75rem 0;
  color: var(--muted-2);
  font-style: italic;
}
.digest-btn, .digest-btn-sm {
  background: var(--ink);
  color: var(--bg);
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
}
.digest-btn-sm {
  padding: 0.25rem 0.7rem;
  font-size: 0.6rem;
  background: transparent;
  color: var(--muted-2);
  border: 1px solid var(--border-soft);
  font-weight: 600;
}
.digest-btn:hover, .digest-btn-sm:hover { opacity: 0.85; }
.digest-loading {
  color: var(--muted-2);
  font-style: italic;
  padding: 0.5rem 0;
}
.digest-loading small { color: var(--muted-2); opacity: 0.7; }
.digest-error {
  color: #b3662f;
  background: #fbf1e6;
  border: 1px solid #e7c8a8;
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
}
.digest-bullets {
  margin: 0;
  padding-left: 1.1rem;
  font-family: var(--font-body, inherit);
  font-size: 0.95rem;
  line-height: 1.5;
}
.digest-bullets li {
  margin-bottom: 0.4rem;
  color: var(--ink);
}
.digest-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.85rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border-soft);
}
.digest-meta {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* ───── Share badge ───── */
.share-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  font-weight: 700;
  vertical-align: middle;
}

/* ───── Filter bar ───── */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0 0 1.25rem 0;
  padding: 0.6rem 0.85rem;
  background: var(--bg-card);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
}
.filter-bar[hidden] { display: none; }
.filter-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.filter-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink);
}
.filter-chip .chip-field {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.65rem;
  color: var(--muted-2);
}
.filter-chip .chip-value { font-weight: 600; }
.filter-chip .chip-x {
  background: transparent;
  border: 0;
  padding: 0 0.25rem;
  cursor: pointer;
  color: var(--muted-2);
  font-size: 1rem;
  line-height: 1;
}
.filter-chip .chip-x:hover { color: var(--ink); }
.filter-clear {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  cursor: pointer;
  color: var(--muted-2);
}
.filter-clear:hover { color: var(--ink); border-color: var(--ink); }

/* Clickable list items */
.list-item.clickable {
  cursor: pointer;
  outline-offset: -2px;
  transition: background-color 120ms ease;
}
.list-item.clickable:hover,
.list-item.clickable:focus-visible {
  background-color: var(--accent-soft);
}

/* ───── Campaign matrix table ───── */
.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.matrix thead th {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--muted-2);
  font-weight: 600;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-soft);
}
.matrix thead th.num,
.matrix tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.matrix tbody tr {
  position: relative;
  background: linear-gradient(
    to right,
    var(--accent-soft) 0,
    var(--accent-soft) var(--bar, 0%),
    transparent var(--bar, 0%),
    transparent 100%
  );
}
.matrix tbody td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink);
}
.matrix tbody td.matrix-name { font-weight: 600; }
.matrix tbody tr.matrix-empty td {
  color: var(--muted-2);
  font-style: italic;
  text-align: center;
}

/* ───── Org rollup table embellishments ───── */
.matrix tbody tr.empty td { color: var(--muted-2); }
.matrix tbody tr.empty td:first-child a { color: inherit; }
.spark { display: block; }
.spark-bar { fill: var(--accent, #d57a32); }
.spark-bar.empty { fill: var(--grid, #e4dec7); }

/* Visible label sitting against the property select; matches the period
   group height so the controls line up. */
.control-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-2, #41504c);
  align-self: center;
  margin-right: 0.25rem;
}

/* Empty state inside the rollup table — renders as a single tall row spanning
   all columns with an inline tracker-snippet hint. */
.matrix tbody tr.empty-row td {
  padding: 1.25rem 1rem;
  background: transparent;
}
.empty-state strong { font-size: 1rem; display: block; margin-bottom: 0.4rem; }
.empty-state p { margin: 0 0 0.6rem 0; color: var(--muted-2); max-width: 60ch; }
.empty-state code { font-size: 0.8rem; background: var(--grid, #e4dec7); padding: 0 4px; border-radius: 3px; }
.empty-domains { list-style: none; padding: 0; margin: 0.4rem 0 0 0; display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; font-size: 0.85rem; }
.empty-domains li { line-height: 1.3; }
.empty-domains .hint { color: var(--muted-2); margin-left: 0.4rem; }

/* ───── Sortable matrix headers ───── */
.matrix.sortable thead th[data-sort] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.matrix.sortable thead th[data-sort]:hover { color: var(--ink); }
.matrix.sortable thead th[data-sort]:focus-visible {
  outline: 2px solid var(--accent, #d57a32);
  outline-offset: -2px;
}
.matrix.sortable thead th .sort-icon {
  margin-left: 0.25rem;
  opacity: 0.45;
  font-size: 0.7rem;
}
.matrix.sortable thead th[aria-sort="ascending"] .sort-icon,
.matrix.sortable thead th[aria-sort="descending"] .sort-icon {
  opacity: 1;
  color: var(--accent, #d57a32);
}

/* ───── Privacy posture (collapsible) ───── */
details.privacy {
  margin-top: 1.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--muted-2);
  line-height: 1.55;
}
details.privacy summary {
  cursor: pointer;
  list-style: none;
}
details.privacy summary::-webkit-details-marker { display: none; }
details.privacy summary::after {
  content: " ▸";
  color: var(--muted-2);
  font-size: 0.7rem;
}
details.privacy[open] summary::after { content: " ▾"; }
details.privacy summary strong { color: var(--ink); }
details.privacy .privacy-tech {
  margin: 0.6rem 0 0 0;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border-soft);
  font-size: 0.78rem;
}
details.privacy code {
  font-size: 0.78rem;
  background: var(--grid, #e4dec7);
  padding: 0 4px;
  border-radius: 3px;
}

/* ───── Zerg assistant drawer ───── */
.zerg-drawer {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.zerg-drawer-toggle {
  pointer-events: auto;
  border: 1px solid rgba(10, 143, 104, 0.42);
  background: var(--ink);
  color: var(--bg-card);
  border-radius: 8px;
  padding: 0.7rem 0.95rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow: 0 16px 48px rgba(17, 21, 20, 0.22);
  cursor: pointer;
}
.zerg-drawer-toggle:hover {
  border-color: rgba(47, 111, 159, 0.75);
}
.zerg-drawer-panel {
  pointer-events: auto;
  width: min(430px, calc(100vw - 24px));
  height: min(680px, calc(100vh - 104px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(10, 143, 104, 0.36);
  border-radius: 8px;
  background: var(--agent-dark);
  box-shadow: 0 28px 90px rgba(6, 16, 10, 0.36);
}
.zerg-drawer-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(10, 143, 104, 0.25);
  background: linear-gradient(90deg, rgba(10, 143, 104, 0.16), rgba(47, 111, 159, 0.12));
}
.zerg-drawer-panel > header strong {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(223, 245, 235, 0.94);
}
.zerg-drawer-panel > header span {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(223, 245, 235, 0.62);
}

@media (max-width: 640px) {
  .zerg-drawer {
    right: 10px;
    bottom: 10px;
  }
  .zerg-drawer-panel {
    height: min(620px, calc(100vh - 88px));
  }
}
