/* RWF Hub — ops console styling. Dense, calm, data-first.
   Tokens come from /design/tokens.css (imported in index.html). */

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.mono, .rwf-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 52px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.wordmark { display: flex; align-items: baseline; gap: 10px; flex-shrink: 0; }
.wordmark-rwf {
  font-weight: 700; font-size: 18px; letter-spacing: 0.04em; color: var(--lime);
}
.wordmark-sub {
  font-size: 10px; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--faint);
}

.sysdots { display: flex; align-items: center; gap: 18px; flex: 1; min-width: 0; flex-wrap: wrap; }
.sysdot {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  cursor: default; user-select: none; white-space: nowrap;
}
.sysdot .rwf-dot { width: 8px; height: 8px; flex-shrink: 0; }

.topbar-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.sync { font-size: 11px; color: var(--faint); }
.sync--err { color: var(--coral); font-weight: 700; }
.uptime { font-size: 11px; color: var(--muted); }

/* ── Console layout ──────────────────────────────────────────── */
.console {
  max-width: 1440px; margin: 0 auto;
  padding: 16px 20px 32px;
  display: flex; flex-direction: column; gap: 14px;
}

.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

/* ── Stat cards ──────────────────────────────────────────────── */
.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px 11px;
  min-width: 0;
}
.stat-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--faint);
  margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 26px; font-weight: 600; line-height: 1.1; color: var(--text);
}
.stat-value--accent { color: var(--lime); }
.stat-sub { font-size: 11px; color: var(--faint); margin-top: 4px; white-space: nowrap; }

/* ── Panels ──────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-width: 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.panel-head h2 {
  font-size: 11px; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
.panel-sub { font-size: 11px; color: var(--faint); }

.matches-scroll { overflow: auto; max-height: calc(100vh - 300px); }
.feed-scroll { overflow: auto; max-height: calc(100vh - 300px); }

/* ── Matches table ───────────────────────────────────────────── */
.mtable { min-width: 760px; }

.mrow-head, .mrow {
  display: grid;
  grid-template-columns: 96px 84px 96px minmax(170px, 1fr) 72px 92px 84px 22px;
  gap: 10px; align-items: center;
  padding: 0 14px;
}
.mrow-head {
  height: 34px; position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--faint);
}
.mrow-head .num, .mrow-head .r { text-align: right; }

.mrow {
  height: 46px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--ease);
}
.mrow:hover { background: var(--surface-2); }
.mrow.expanded { background: var(--surface-2); }
.mrow.stale { opacity: 0.55; }

.m-crew {
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; color: var(--lime);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-crew--none { color: var(--faint); font-weight: 400; }

.m-platform {
  font-size: 11px; font-weight: 600; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.m-platform .plat-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.plat-dot--whatsapp { background: var(--lime); }
.plat-dot--slack { background: var(--sky); }
.plat-dot--unknown { background: var(--faint); }

.m-status {
  display: inline-flex; align-items: center; gap: 6px; justify-self: start;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  border-radius: var(--pill); padding: 3px 9px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.m-status .sdot { width: 6px; height: 6px; border-radius: 50%; }
.m-status--live { color: var(--lime); border-color: color-mix(in srgb, var(--lime) 40%, var(--line)); background: var(--lime-glow); }
.m-status--live .sdot { background: var(--lime); box-shadow: 0 0 6px var(--lime); }
.m-status--open { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); }
.m-status--open .sdot { background: var(--amber); }
.m-status--complete { color: var(--sky); border-color: color-mix(in srgb, var(--sky) 35%, var(--line)); }
.m-status--complete .sdot { background: var(--sky); }
.m-status--unknown .sdot { background: var(--faint); }

.m-leader { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.m-leader-name {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-leader-name .none { color: var(--faint); font-weight: 400; }
.m-bar { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.m-bar-fill { height: 100%; background: var(--lime); border-radius: 2px; transition: width 400ms ease; }
.m-bar-fill--done { background: var(--sky); }

.m-players, .m-pot, .m-updated {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap;
}
.m-pot { color: var(--text); }
.m-updated { color: var(--faint); font-size: 11px; }

.m-chev { color: var(--faint); font-size: 10px; text-align: center; transition: transform var(--ease); }
.mrow.expanded .m-chev { transform: rotate(90deg); color: var(--lime); }

/* Player detail rows */
.prow {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 84px 84px 96px 84px;
  gap: 10px; align-items: center;
  padding: 7px 14px 7px 120px;   /* indent nests under the leader column */
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
  font-size: 12px;
}
.prow:last-child { border-bottom: 1px solid var(--line-bright); }
.p-name { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-name .lead-mark { color: var(--lime); margin-right: 5px; font-family: var(--font-mono); font-size: 10px; }
.p-tier {
  justify-self: start;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--pill); padding: 2px 8px;
  white-space: nowrap;
}
.p-raw, .p-adj, .p-ver {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 12px; text-align: right; color: var(--muted); white-space: nowrap;
}
.p-adj { color: var(--text); font-weight: 600; }
.p-ver--full { color: var(--lime); }
.p-ver--low { color: var(--amber); }

/* Empty / error states */
.empty {
  padding: 44px 20px; text-align: center; color: var(--faint);
  font-size: 12.5px; line-height: 1.7;
}
.empty .empty-glyph { font-size: 18px; margin-bottom: 8px; color: var(--line-bright); }
.empty .empty-hint { font-size: 11px; }
.err-state { color: var(--coral); }

/* ── Activity feed ───────────────────────────────────────────── */
.feed { display: flex; flex-direction: column; }
.fitem {
  display: flex; gap: 10px; align-items: baseline;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px; line-height: 1.5;
}
.fitem:last-child { border-bottom: none; }
.f-ts { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); flex-shrink: 0; }
.f-kind {
  flex-shrink: 0;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line);
}
.f-text { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.f-text .hl { color: var(--text); font-family: var(--font-mono); font-size: 11.5px; }

.f-kind--created  { color: var(--sky);  border-color: color-mix(in srgb, var(--sky) 35%, var(--line)); }
.f-kind--started  { color: var(--lime); border-color: color-mix(in srgb, var(--lime) 35%, var(--line)); }
.f-kind--completed{ color: var(--sky);  border-color: color-mix(in srgb, var(--sky) 35%, var(--line)); }
.f-kind--leader   { color: var(--amber);border-color: color-mix(in srgb, var(--amber) 35%, var(--line)); }
.f-kind--joined   { color: var(--muted); }
.f-kind--left     { color: var(--faint); }
.f-kind--removed  { color: var(--faint); }
.f-kind--status   { color: var(--muted); }
.f-kind--error    { color: var(--coral); border-color: color-mix(in srgb, var(--coral) 35%, var(--line)); }
.f-kind--restored { color: var(--lime); border-color: color-mix(in srgb, var(--lime) 35%, var(--line)); }

.feed-empty { padding: 36px 16px; text-align: center; color: var(--faint); font-size: 12px; }

/* ── Responsive fallback (desktop-first, but don't break) ────── */
@media (max-width: 1100px) {
  .cols { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .matches-scroll, .feed-scroll { max-height: none; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; }
}

/* ══════════════════════════════════════════════════════════════ */
/* CORPORATE TAB — tab shell, org leagues, pots, wellbeing,       */
/* renewal. Same tokens; HR-friendly, aggregate-only framing.     */
/* ══════════════════════════════════════════════════════════════ */

/* ── Tab bar (Operations ↔ Corporate) ────────────────────────── */
.tabbar {
  position: sticky; top: 52px; z-index: 9;
  display: flex; gap: 2px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tabbtn {
  position: relative;
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  background: none; border: none; cursor: pointer;
  padding: 12px 14px 10px;
  transition: color var(--ease);
}
.tabbtn::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; border-radius: 2px; background: transparent;
  transition: background var(--ease);
}
.tabbtn:hover { color: var(--muted); }
.tabbtn:focus-visible {
  outline: 1px solid var(--line-bright); outline-offset: -2px;
  border-radius: 6px; color: var(--text);
}
.tabbtn--active, .tabbtn--active:hover { color: var(--lime); }
.tabbtn--active::after { background: var(--lime); box-shadow: 0 0 10px var(--lime-glow); }

/* ── k-anonymity banner ──────────────────────────────────────── */
.agg-banner {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid color-mix(in srgb, var(--sky) 30%, var(--line));
  background: color-mix(in srgb, var(--sky) 6%, var(--surface));
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px; color: var(--muted); line-height: 1.5;
}
.agg-banner strong { color: var(--text); }
.agg-banner-k {
  flex-shrink: 0;
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  color: var(--sky);
  border: 1px solid color-mix(in srgb, var(--sky) 40%, var(--line));
  border-radius: var(--pill); padding: 3px 9px;
}

/* ── Aggregate wellbeing panel ───────────────────────────────── */
.wellbeing-body { padding: 14px; }
.spark { width: 100%; height: 44px; display: block; margin-top: 8px; }
.spark polyline {
  fill: none; stroke: var(--lime); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.spark circle { fill: var(--lime); }
.spark-labels {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 9.5px; color: var(--faint);
  margin-top: 3px;
}
.trend-delta--up { color: var(--lime); }
.trend-delta--down { color: var(--coral); }

/* ── Corporate layout ────────────────────────────────────────── */
.cols-corp {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr);
  gap: 14px; align-items: start;
}
.corp-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ── Org leagues table ───────────────────────────────────────── */
.otable { min-width: 660px; }
.orow {
  display: grid;
  grid-template-columns: 40px minmax(150px, 1fr) 56px 92px 84px 128px 22px;
  gap: 10px; align-items: center;
  padding: 0 14px;
}
.orow-head {
  height: 34px; position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--faint);
}
.orow-head .num { text-align: right; }
.orow:not(.orow-head) {
  height: 46px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--ease);
}
.orow:not(.orow-head):hover { background: var(--surface-2); }
.orow.expanded { background: var(--surface-2); }
.o-rank { font-size: 12px; color: var(--faint); }
.o-name {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.o-num {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap;
}
.o-pts { color: var(--text); font-weight: 600; }
.o-dim { color: var(--faint); }
.crow {
  height: 36px; cursor: default;
  background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
  font-size: 12px;
}
.crow:hover { background: color-mix(in srgb, var(--surface-2) 75%, var(--surface)); }
.crow .o-indent { color: var(--faint); text-align: center; }
.o-crew { display: flex; align-items: center; gap: 8px; min-width: 0; }
.o-crewcode {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; color: var(--lime); flex-shrink: 0;
}
.o-crewname {
  color: var(--muted); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Status pills (install / live) — same family as .m-status */
.opill {
  display: inline-flex; align-items: center; gap: 6px; justify-self: start;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  border-radius: var(--pill); padding: 3px 8px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.opill .sdot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.opill--slack { color: var(--sky); border-color: color-mix(in srgb, var(--sky) 35%, var(--line)); }
.opill--slack .sdot { background: var(--sky); }
.opill--pending {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 40%, var(--line));
  background: color-mix(in srgb, var(--amber) 8%, transparent);
}
.opill--pending .sdot { background: var(--amber); }
.opill--live { color: var(--lime); border-color: color-mix(in srgb, var(--lime) 35%, var(--line)); }
.opill--live .sdot { background: var(--lime); box-shadow: 0 0 6px var(--lime); }

/* ── Employer-funded pots panel ──────────────────────────────── */
.pots-framing {
  padding: 10px 14px;
  font-size: 12px; color: var(--muted); line-height: 1.55;
  border-bottom: 1px solid var(--line);
}
.pots-framing strong { color: var(--text); }
.pot-org {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 7px;
}
.pot-line1 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pot-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.pot-amt { font-size: 12px; color: var(--faint); white-space: nowrap; }
.pot-amt strong { color: var(--text); font-weight: 600; }
.pot-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.pot-bar-fill { height: 100%; background: var(--lime); border-radius: 3px; transition: width 400ms ease; }
.pot-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--faint); }
.pot-total {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
  font-size: 12px; color: var(--muted);
  background: var(--surface-2);
  border-top: 1px solid var(--line-bright);
}

/* ── Renewal outlook panel ───────────────────────────────────── */
.renewal-headline {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.65; color: var(--muted);
}
.renewal-headline strong { color: var(--text); font-weight: 600; }
.rec--good { color: var(--lime); font-weight: 600; }
.rec--hold { color: var(--amber); font-weight: 600; }
.rec--risk { color: var(--coral); font-weight: 600; }
.rrow {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 64px 56px minmax(120px, 1.1fr);
  gap: 10px; align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.rrow:last-child { border-bottom: none; }
.r-name {
  font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.r-pct { text-align: right; color: var(--muted); }
.r-rec { font-size: 11px; }
.r-rec--good { color: var(--lime); }
.r-rec--hold { color: var(--amber); }
.r-rec--risk { color: var(--coral); }
.days-pill {
  justify-self: start;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--pill);
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.days-pill--soon { color: var(--coral); border-color: color-mix(in srgb, var(--coral) 40%, var(--line)); }
.days-pill--mid  { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); }
.days-pill--ok   { color: var(--sky);   border-color: color-mix(in srgb, var(--sky) 35%, var(--line)); }

/* ── Corporate responsive ─────────────────────────────────────── */
@media (max-width: 1100px) {
  .tabbar { position: static; }
  .cols-corp { grid-template-columns: 1fr; }
}
