/* Snap HRT pilot design system — tokens ported from the activation playbook deck. */
:root {
  --red: #e21b2d;
  --ink: #151719;
  --graphite: #3a3f45;
  --slate: #68717a;
  --mist: #f4f6f8;
  --rule: #d9dee4;
  --teal: #007f7a;
  --blue: #3366cc;
  --amber: #d99000;
  --green: #1f8a4c;
  --cream: #fff8e8;
  --rose: #fff5f5;
  --pale-teal: #f2fbfa;
  --pale-blue: #f3f6ff;
  --pale-green: #f2fbf4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--mist);
  font-size: 15px;
  line-height: 1.45;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 24px 48px; }

/* ---------- header / brand ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid var(--rule);
  padding: 14px 24px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { height: 92px; display: block; } /* asset has internal padding; box is larger than the wordmark */
.brand-logo-lg { height: 64px; }
.brand-stack { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; }
.brand-sub { color: var(--slate); font-size: 14px; }
.brand .brand-sub { border-left: 1px solid var(--rule); padding-left: 14px; }
.header-meta { display: flex; align-items: center; gap: 16px; }
.as-of { color: var(--slate); font-size: 13px; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--red);
  display: inline-block; margin-right: 2px;
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1); }
}
.logout-btn {
  padding: 5px 14px; border: 1px solid var(--rule); border-radius: 999px;
  background: #fff; color: var(--graphite); font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }

/* ---------- banners ---------- */
.banner { padding: 10px 14px; border-radius: 6px; margin: 16px 0; font-size: 14px; }
.banner-amber { background: var(--cream); border: 1px solid var(--amber); color: var(--graphite); }
.banner-rose { background: var(--rose); border: 1px solid var(--red); color: var(--graphite); }

/* ---------- headline tiles ---------- */
.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin: 20px 0;
}
.tile {
  background: #fff; border: 1px solid var(--rule); border-radius: 8px;
  padding: 16px 18px 14px;
}
.tile-number { font-size: 30px; font-weight: 800; line-height: 1.1; }
.tile-denom { font-size: 18px; font-weight: 400; color: var(--slate); }
.tile-label { font-size: 13px; font-weight: 600; color: var(--graphite); margin-top: 6px; }
.tile-note { font-size: 12px; color: var(--slate); margin-top: 3px; }

/* ---------- cards / sections ---------- */
.card {
  background: #fff; border: 1px solid var(--rule); border-radius: 8px;
  padding: 20px 22px; margin: 18px 0;
}
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card h3 { margin: 20px 0 8px; font-size: 14.5px; }
.card-sub { margin: 0 0 14px; color: var(--slate); font-size: 13px; }
.chart-box { position: relative; height: 340px; }
.chart-box-short { height: 260px; }
.chart-box-pulse { height: 130px; }

/* ---------- world map ---------- */
.world-map { margin-top: 14px; }
.world-map svg { display: block; width: 100%; height: auto; }
.map-night { fill: rgba(21, 23, 25, 0.10); pointer-events: none; }
.play-btn {
  margin-left: 10px; padding: 3px 12px; border: 1px solid var(--rule); border-radius: 999px;
  background: #fff; color: var(--graphite); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.play-btn:hover { border-color: var(--graphite); }
.playback-label { margin-left: 10px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- country flag chips ---------- */
.country-chips { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 2px; }
.flag-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; color: var(--graphite); font-variant-numeric: tabular-nums; }
.flag { width: 20px; height: 15px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(21,23,25,0.10); object-fit: cover; vertical-align: middle; }
.flag-inline { width: 18px; height: 13px; margin: 0 1px; position: relative; top: 1px; }
.map-dot { fill: var(--slate); opacity: 0.45; }
.map-dot-active { fill: var(--red); opacity: 0.85; }
.map-ping {
  fill: none; stroke: var(--red); stroke-width: 2;
  transform-origin: center; transform-box: fill-box;
  animation: map-ping 2.2s ease-out infinite;
}
@keyframes map-ping {
  0%   { opacity: 0.9; transform: scale(0.6); }
  80%  { opacity: 0;   transform: scale(2.4); }
  100% { opacity: 0;   transform: scale(2.4); }
}

/* ---------- funnel ---------- */
.attach-toggle { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toggle-pill input { position: absolute; opacity: 0; }
.toggle-pill span {
  display: inline-block; padding: 5px 12px; border: 1px solid var(--rule);
  border-radius: 999px; font-size: 13px; color: var(--graphite); cursor: pointer;
}
.toggle-pill input:checked + span {
  background: var(--ink); color: #fff; border-color: var(--ink);
}
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-label { width: 185px; flex: none; font-size: 13px; color: var(--graphite); text-align: right; }
/* Funnel palette: slate -> teal -> blue -> green. Red and ink stay exclusive
   to the Network trend chart above so the two sections read independently. */
.funnel-bar {
  background: var(--slate); color: #fff; border-radius: 4px;
  padding: 6px 10px; font-size: 13px; font-weight: 600;
  min-width: 78px; white-space: nowrap; transition: width 0.25s ease;
}
.bar-teal { background: var(--teal); }
.bar-blue { background: var(--blue); }
.bar-green { background: var(--green); }
.funnel-note { font-size: 13px; color: var(--graphite); margin: 12px 0 0; }

/* ---------- club table ---------- */
.table-scroll { overflow-x: auto; }
/* Right-edge fade signals there's more to scroll (class toggled by dashboard.js) */
.table-scroll-wrap { position: relative; }
.table-scroll-wrap.has-more-right::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 28px;
  background: linear-gradient(to left, rgba(21, 23, 25, 0.12), transparent);
  pointer-events: none;
}
/* border-collapse: separate so position: sticky works on cells (mobile pinned columns) */
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
th, td { padding: 7px 10px; text-align: left; }
th {
  border-bottom: 2px solid var(--rule); font-size: 12px; color: var(--slate);
  cursor: pointer; user-select: none; white-space: nowrap;
}
th:hover { color: var(--ink); }
tbody tr:nth-child(even) { background: var(--mist); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.zero { color: var(--rule); } /* zero months render as a faint dash */
th.sorted-asc::after { content: " \2191"; }
th.sorted-desc::after { content: " \2193"; }

/* ---------- deck-aligned club table ---------- */
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px; color: var(--graphite); }
.legend-chip { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.rank-col { color: var(--slate); text-align: right; font-variant-numeric: tabular-nums; width: 26px; }
.club-cell { min-width: 175px; }
.club-sub { color: var(--slate); font-size: 11px; margin-top: 1px; white-space: nowrap; }
.metric-cell { min-width: 145px; }
.metric-flex { display: flex; align-items: center; gap: 8px; }
.bar-track { background: var(--rule); border-radius: 3px; height: 10px; flex: 1; min-width: 60px; overflow: hidden; }
.bar-track-thin { height: 6px; }
.bar-fill { height: 100%; border-radius: 3px; display: block; }
.seg-strong { background: var(--green); }
.seg-moderate { background: var(--slate); } /* not teal — too close to strong's green next to it */
.seg-low { background: var(--amber); }
.seg-none { background: var(--red); }
.bar-util { background: var(--blue); }
.act-pct { font-weight: 700; min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.util-pct { color: var(--blue); font-size: 12px; font-weight: 600; min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- network projection ---------- */
.proj-input-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 14px; color: var(--graphite); }
.pill-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pill-label { font-size: 12px; color: var(--slate); min-width: 108px; }
#clubCount {
  width: 92px; padding: 6px 8px; border: 1px solid var(--rule); border-radius: 6px;
  font-size: 16px; font-family: inherit; font-weight: 700; text-align: right; /* >=16px: no iOS focus zoom */
}
#clubCount:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.proj-table th.num { text-align: right; }
.proj-table td:first-child { color: var(--graphite); }
.proj-table td.num { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- status badges ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-growing { background: var(--pale-green); color: var(--green); }
.badge-steady { background: var(--pale-teal); color: var(--teal); }
.badge-softening { background: var(--cream); color: var(--amber); }
.badge-quiet { background: var(--rose); color: var(--red); }
.badge-never-started { background: var(--rose); color: var(--red); }

/* ---------- login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: #fff; border: 1px solid var(--rule); border-radius: 10px;
  padding: 34px 38px; width: 380px; max-width: calc(100vw - 40px);
}
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form label { font-size: 13px; color: var(--graphite); font-weight: 600; }
.login-form input {
  padding: 9px 12px; border: 1px solid var(--rule); border-radius: 6px;
  font-size: 16px; font-family: inherit; /* >=16px: prevents iOS focus auto-zoom */
}
.login-form input:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.btn-primary {
  background: var(--red); color: #fff; border: none; border-radius: 6px;
  padding: 10px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-primary:hover { filter: brightness(0.93); }
.login-note { color: var(--slate); font-size: 12px; text-align: center; margin: 16px 0 0; }
.login-note-fine { font-size: 10.5px; color: var(--rule); margin-top: 6px; letter-spacing: 0.1px; }

/* ---------- footer ---------- */
.page-foot { color: var(--slate); font-size: 12px; margin-top: 22px; line-height: 1.6; }

/* ---------- error page ---------- */
.error-card { text-align: center; }
.error-card h1 { font-size: 20px; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .wrap { padding: 12px 12px 40px; }
  .site-header { flex-wrap: wrap; gap: 6px; padding: 10px 14px; }
  .header-meta { width: 100%; justify-content: flex-start; }
  .header-meta form { margin-left: auto; } /* logout right; live-dot stays beside the timestamp */
  .brand { gap: 10px; flex-wrap: wrap; }
  .brand-logo { height: 64px; }
  .brand-sub { font-size: 12px; }
  .brand .brand-sub { padding-left: 10px; }
  .card { padding: 14px; }
  .tile { padding: 12px 14px 11px; }
  .tile-number { font-size: 26px; }
  .chart-box { height: 250px; }
  .chart-box-short { height: 210px; }
  .chart-box-pulse { height: 100px; }
  /* Funnel: stack labels above bars instead of a fixed left column */
  .funnel-row { flex-direction: column; align-items: stretch; gap: 2px; }
  .funnel-label { width: auto; flex: none; text-align: left; font-size: 12px; }
  .legend-row { gap: 10px; font-size: 11.5px; }
  th, td { padding: 6px 7px; }
  table { font-size: 12.5px; }
  .metric-cell { min-width: 125px; }

  /* Pinned rank + club columns while the rest of the table scrolls.
     box-sizing is border-box: the 30px rank width INCLUDES its padding, so the
     club column pins at 29px — 1px overlap so no seam can open between them. */
  #clubTable .rank-col,
  #clubTable th:first-child {
    position: sticky; left: 0; z-index: 2;
    width: 30px; min-width: 30px; background: #fff;
  }
  #clubTable .club-cell,
  #clubTable th:nth-child(2) {
    position: sticky; left: 29px; z-index: 2;
    min-width: 140px; max-width: 140px; background: #fff;
    border-right: 1px solid var(--rule);
  }
  #clubTable .club-sub { white-space: normal; }
  #clubTable tbody tr:nth-child(even) .rank-col,
  #clubTable tbody tr:nth-child(even) .club-cell { background: var(--mist); }
}
