/* Outreach Ops — ops-console look.
 * Flat panels on a cool slate ground, 1px rules, one petrol accent.
 * Status is always a tone: attention · warn · working · waiting · done · idle (· muted = idle).
 * Type: IBM Plex Sans (UI), Plex Sans Condensed (figures, headings), Plex Mono (ids, raw errors).
 */

:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f5;
  --line: #e2e6ec;
  --line-strong: #cdd4dd;
  --ink: #17202b;
  --ink-2: #3a4554;
  --muted: #667180;
  --accent: #0b5563;
  --accent-hover: #09414c;
  --accent-text: #0b5563;
  --accent-soft: #e3eff1;
  --on-accent: #ffffff;
  --focus: #2f8fa3;

  --attention: #d14343;
  --attention-ink: #b03030;
  --attention-soft: #fbeaea;
  --warn: #c98a12;
  --warn-ink: #8e5f00;
  --warn-soft: #fbf2df;
  --working: #22874a;
  --working-ink: #1a6b3a;
  --working-soft: #e5f3ea;
  --waiting: #2f6fd0;
  --waiting-ink: #2459a8;
  --waiting-soft: #e7effb;
  --done: #7357c6;
  --done-ink: #5b42a6;
  --done-soft: #efebfa;
  --idle: #8c96a5;
  --idle-ink: #5d6776;
  --idle-soft: #eef0f3;

  /* legacy names still used by older markup */
  --ok: var(--working);
  --ok-soft: var(--working-soft);
  --fail: var(--attention);
  --fail-soft: var(--attention-soft);
  --skip: var(--idle);
  --accent-2: var(--accent-text);

  --log-bg: #111820;
  --log-ink: #d7dee6;
  --overlay: rgba(16, 24, 32, 0.42);
  --pop-shadow: 0 12px 32px rgba(16, 24, 32, 0.16);

  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-cond: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 6px;
  --r-sm: 4px;
  --sidebar-w: 216px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1318;
  --surface: #151b22;
  --surface-2: #1a2129;
  --surface-3: #212a34;
  --line: #263039;
  --line-strong: #34414d;
  --ink: #e3e8ee;
  --ink-2: #b9c2cc;
  --muted: #8a95a3;
  --accent: #2c8396;
  --accent-hover: #3596aa;
  --accent-text: #7cc6d4;
  --accent-soft: rgba(62, 155, 173, 0.16);
  --on-accent: #ffffff;
  --focus: #7cc6d4;

  --attention: #f06a6a;
  --attention-ink: #f58b8b;
  --attention-soft: rgba(240, 106, 106, 0.14);
  --warn: #e2a93b;
  --warn-ink: #ebbd62;
  --warn-soft: rgba(226, 169, 59, 0.14);
  --working: #3fb56e;
  --working-ink: #62c98b;
  --working-soft: rgba(63, 181, 110, 0.14);
  --waiting: #5c93ea;
  --waiting-ink: #84adf0;
  --waiting-soft: rgba(92, 147, 234, 0.15);
  --done: #9a82e8;
  --done-ink: #b3a1ee;
  --done-soft: rgba(154, 130, 232, 0.15);
  --idle: #7d8896;
  --idle-ink: #9ba5b2;
  --idle-soft: rgba(125, 136, 150, 0.14);

  --log-bg: #0a0e12;
  --log-ink: #d7dee6;
  --overlay: rgba(0, 0, 0, 0.55);
  --pop-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

/* —— Base —— */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3 {
  font-family: var(--font-cond);
  font-weight: 600;
  letter-spacing: -0.005em;
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

code {
  color: var(--ink-2);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

[hidden],
.screen[hidden],
.toolbar[hidden],
.panel[hidden],
.board[hidden],
.kpis[hidden] {
  display: none !important;
}

/* —— Shell —— */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  width: 100%;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 0.75rem;
  background: var(--surface);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.25rem 0.375rem 0.875rem;
  border-bottom: 1px solid var(--line);
}

/* The three lanes, as the mark. */
.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: var(--r);
  background: var(--accent);
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 0 0.4375rem;
  flex: 0 0 auto;
}

.brand-mark i {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--on-accent);
}

.brand-mark i:nth-child(1) {
  width: 55%;
  opacity: 0.7;
}

.brand-mark i:nth-child(2) {
  width: 100%;
}

.brand-mark i:nth-child(3) {
  width: 75%;
  opacity: 0.85;
}

.brand-copy {
  display: grid;
  min-width: 0;
}

.brand-copy strong {
  font-family: var(--font-cond);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

.brand-copy span {
  font-size: 0.75rem;
  color: var(--muted);
}

.side-nav {
  display: grid;
  gap: 2px;
  align-content: start;
  flex: 1;
}

.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.side-link:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.side-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.side-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 0.375rem;
  bottom: 0.375rem;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}

.side-ico {
  width: 1.125rem;
  height: 1.125rem;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-count {
  margin-left: auto;
  min-width: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: var(--attention);
  color: #fff;
  font-family: var(--font-cond);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25rem;
  text-align: center;
}

.side-foot {
  display: grid;
  gap: 0.375rem;
  padding: 0.75rem 0.375rem 0;
  border-top: 1px solid var(--line);
}

.sys-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 0;
}

.sys-line span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-foot .btn {
  margin-top: 0.25rem;
  justify-self: start;
}

.shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.875rem;
  flex-shrink: 0;
}

.top-copy {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
}

.lede {
  margin: 0.25rem 0 0;
  color: var(--muted);
  max-width: 48rem;
}

.lede:empty {
  display: none;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.125rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.crumb-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.crumb-link:hover {
  text-decoration: underline;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.window-note {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
}

.content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0 1.5rem 1.5rem;
  overflow-x: hidden;
  overflow-y: auto;
}

.app[data-view="analytics"] .content,
.app[data-view="settings"] .content,
.app[data-view="user"][data-section="analytics"] .content {
  overflow: hidden;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.screen.fill {
  flex: 1 1 auto;
}

/* Content-height screens (Overview) scroll with the page; never squeezed to the viewport. */
.screen:not(.fill) {
  flex: 0 0 auto;
}

#analyticsScreen,
#settingsScreen,
#userScreen[data-section="analytics"] {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* —— Controls —— */
.btn,
.icon-btn,
.chip,
.section-tab {
  font: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 2rem;
  padding: 0 0.875rem;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn.ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn.ghost:hover {
  background: var(--surface-3);
}

.btn.small,
.btn.compact {
  height: 1.75rem;
  padding: 0 0.625rem;
  font-size: 0.8125rem;
}

.btn.block {
  width: 100%;
}

.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn.danger {
  background: var(--attention);
  color: #fff;
}

a.btn {
  text-decoration: none;
}

.btn-text {
  padding: 0.25rem 0.375rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-text:hover {
  color: var(--ink);
}

.icon-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 1.25rem;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--surface-3);
}

.chip {
  height: 1.75rem;
  padding: 0 0.625rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.8125rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip:hover {
  background: var(--surface-3);
}

.chip[aria-selected="true"] {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: 500;
}

/* Segmented filter (users list) */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 1.875rem;
  padding: 0 0.625rem;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.seg-btn:hover {
  color: var(--ink);
  background: var(--surface-3);
}

.seg-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.seg-btn .n {
  font-family: var(--font-cond);
  font-weight: 600;
  color: var(--muted);
}

.seg-btn[data-hot] .n {
  color: var(--attention-ink);
}

.search {
  flex: 1 1 220px;
}

.search.compact {
  flex: 0 1 240px;
  min-width: 10rem;
}

.search input,
.custom-range input[type="date"],
.filter-select select {
  height: 2rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
}

.search input {
  width: 100%;
  padding: 0 0.625rem;
}

.search input:focus,
.custom-range input[type="date"]:focus,
.filter-select select:focus {
  outline: 2px solid var(--focus);
  outline-offset: -1px;
}

.custom-range {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.custom-range input[type="date"] {
  padding: 0 0.5rem;
}

.custom-range-sep {
  color: var(--muted);
  font-size: 0.8125rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
  flex: 1 1 320px;
  min-width: 0;
  justify-content: flex-end;
}

.filter-bar,
.filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 0.5rem;
  align-items: center;
  justify-content: flex-end;
  max-width: 100%;
}

.filter-chips {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.filter-chips .chip {
  border: 0;
  background: transparent;
  height: 1.625rem;
}

.filter-chips .chip[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.filter-sep {
  width: 1px;
  height: 1.25rem;
  background: var(--line);
  flex-shrink: 0;
}

.filter-select {
  display: inline-flex;
  align-items: center;
}

.filter-select-label {
  display: none;
}

.filter-select select {
  min-width: 8.5rem;
  max-width: min(16rem, 55vw);
  padding: 0 0.5rem;
}

.hr-date-range {
  flex: 0 1 auto;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.analytics-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0.25rem 0 0.5rem;
  background: var(--bg);
}

.analytics-toolbar .meta {
  margin: 0 0 0 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* —— Status primitives —— */
.dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--idle);
  flex: 0 0 auto;
}

[data-tone="attention"] > .dot,
.dot[data-tone="attention"],
.dot[data-tone="down"],
.dot[data-tone="err"] {
  background: var(--attention);
}

.dot[data-tone="warn"],
[data-tone="warn"] > .dot {
  background: var(--warn);
}

.dot[data-tone="working"],
[data-tone="working"] > .dot,
.dot[data-tone="ok"] {
  background: var(--working);
}

.dot[data-tone="waiting"],
[data-tone="waiting"] > .dot {
  background: var(--waiting);
}

.dot[data-tone="done"],
[data-tone="done"] > .dot {
  background: var(--done);
}

.dot[data-tone="loading"] {
  background: var(--idle);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* Tone colour carried as custom props so one rule styles pills, bars and borders. */
[data-tone] {
  --tone: var(--idle);
  --tone-ink: var(--idle-ink);
  --tone-soft: var(--idle-soft);
}

[data-tone="attention"],
[data-tone="down"],
[data-tone="err"] {
  --tone: var(--attention);
  --tone-ink: var(--attention-ink);
  --tone-soft: var(--attention-soft);
}

[data-tone="warn"] {
  --tone: var(--warn);
  --tone-ink: var(--warn-ink);
  --tone-soft: var(--warn-soft);
}

[data-tone="working"],
[data-tone="ok"] {
  --tone: var(--working);
  --tone-ink: var(--working-ink);
  --tone-soft: var(--working-soft);
}

[data-tone="waiting"] {
  --tone: var(--waiting);
  --tone-ink: var(--waiting-ink);
  --tone-soft: var(--waiting-soft);
}

[data-tone="done"] {
  --tone: var(--done);
  --tone-ink: var(--done-ink);
  --tone-soft: var(--done-soft);
}

/* State pill: dot + label */
.state {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 1.375rem;
  padding: 0 0.5rem;
  border-radius: var(--r-sm);
  background: var(--tone-soft);
  color: var(--tone-ink);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.state .dot {
  background: var(--tone);
}

/* Lane rail: discovery · warm-up · messaging, one segment each. */
.rail {
  display: inline-grid;
  grid-template-columns: repeat(3, 1rem);
  gap: 2px;
  flex: 0 0 auto;
}

.rail i {
  display: block;
  height: 0.375rem;
  border-radius: 1px;
  background: var(--tone);
  opacity: 0.9;
}

.rail i[data-tone="idle"],
.rail i[data-tone="muted"] {
  background: var(--line-strong);
}

.rail i[data-head] {
  height: 0.5rem;
  margin-top: -1px;
  opacity: 1;
}

time[title] {
  text-decoration: underline dotted var(--line-strong);
  text-underline-offset: 3px;
}

/* —— Panels —— */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.panel.fill {
  flex: 1 1 auto;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-head-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.panel-lede,
.meta {
  margin: 0.125rem 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.panel-body {
  flex: 1;
  min-height: 0;
}

.panel-body.scroll,
.scroll-y,
.table-wrap {
  overflow: auto;
}

.panel-foot {
  margin: 0;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem !important;
}

.eyebrow {
  margin: 0 0 0.125rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

/* —— Overview —— */
.health-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.health-card {
  position: relative;
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem 1rem 0.75rem 1.125rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  min-width: 0;
}

.health-card::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 3px;
  border-radius: var(--r) 0 0 var(--r);
  background: var(--tone);
}

.health-card[data-tone="ok"]::before {
  background: var(--working);
}

.health-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.health-top strong {
  font-weight: 600;
}

.health-top .state {
  margin-left: auto;
  height: 1.25rem;
  font-size: 0.75rem;
}

.health-detail {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-at {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

/* Users by tab: each card opens that tab on the Users page */
.tab-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.tab-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.125rem 0.75rem;
  padding: 0.75rem 1rem 0.75rem 1.125rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

.tab-card::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 3px;
  border-radius: var(--r) 0 0 var(--r);
  background: var(--tone);
}

.tab-card:hover {
  background: var(--surface-2);
}

.tab-card-label {
  font-weight: 600;
}

.tab-card-n {
  grid-row: span 2;
  font-family: var(--font-cond);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--tone-ink, var(--ink));
}

.tab-card-sub {
  color: var(--muted);
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attn-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0 1rem 0.75rem 1.25rem;
}

.attn-foot .btn {
  height: 1.625rem;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.attn-list {
  display: grid;
}

.attn-group {
  border-bottom: 1px solid var(--line);
}

.attn-group:last-child {
  border-bottom: 0;
}

.attn-group > summary {
  display: grid;
  grid-template-columns: 3px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0.75rem 0;
  cursor: pointer;
  list-style: none;
}

.attn-group > summary::-webkit-details-marker {
  display: none;
}

.attn-group > summary:hover {
  background: var(--surface-2);
}

.attn-bar {
  align-self: stretch;
  border-radius: 0 2px 2px 0;
  background: var(--tone);
}

.attn-copy {
  display: grid;
  gap: 0.125rem;
  min-width: 0;
}

.attn-copy strong {
  font-weight: 600;
}

.attn-copy span {
  color: var(--muted);
  font-size: 0.8125rem;
}

.attn-count {
  font-family: var(--font-cond);
  font-weight: 600;
  color: var(--tone-ink);
  white-space: nowrap;
}

.chev {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  transition: transform 0.15s ease;
}

.attn-group[open] .chev {
  transform: rotate(90deg);
}

.attn-users {
  margin: 0;
  padding: 0 0 0.5rem;
  list-style: none;
}

.attn-user {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.4375rem 1rem 0.4375rem 1.25rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.attn-user:hover {
  background: var(--surface-2);
}

.attn-user strong {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attn-user span {
  color: var(--ink-2);
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attn-user em {
  color: var(--accent-text);
  font-size: 0.8125rem;
  font-style: normal;
  white-space: nowrap;
}

.all-clear {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem;
  color: var(--ink-2);
}

.all-clear svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: var(--working);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.all-clear strong {
  display: block;
  color: var(--ink);
}

.today-figs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.fig {
  padding: 0.75rem 1rem;
  min-width: 0;
}

.fig:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.fig:nth-child(-n + 2) {
  border-bottom: 1px solid var(--line);
}

.fig .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.fig .value {
  margin: 0.125rem 0 0;
  font-family: var(--font-cond);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.15;
}

.fig .value small {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.fig .sub {
  margin: 0.125rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.fig .sub .bad {
  color: var(--attention-ink);
}

.action-bars {
  display: grid;
  gap: 0.375rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
}

.action-bars h3,
.today-facts h3 {
  margin: 0 0 0.25rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

.abar {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) 2.5rem;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.8125rem;
}

.abar-track {
  height: 0.5rem;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.abar-track span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.abar b {
  font-family: var(--font-cond);
  font-weight: 600;
  text-align: right;
}

.today-facts {
  padding: 0.75rem 1rem;
}

.fact {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.3125rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.8125rem;
}

.fact:last-child {
  border-bottom: 0;
}

.fact span {
  color: var(--ink-2);
}

.fact b {
  font-family: var(--font-cond);
  font-weight: 600;
  text-align: right;
}

/* —— Users list —— */
.users-head {
  flex-wrap: wrap;
}

.users-subhead {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.users-subhead[hidden] {
  display: none;
}

.users-subhead .chip .n {
  margin-left: 0.375rem;
  font-family: var(--font-cond);
  font-weight: 600;
  opacity: 0.75;
}

/* Count + pager under a paged list */
.list-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.list-foot[hidden] {
  display: none;
}

.list-foot p {
  margin: 0;
}

.user-table-wrap {
  min-height: 100%;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.user-table th,
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.user-table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.user-table tbody tr {
  cursor: pointer;
}

.user-table tbody tr:hover {
  background: var(--surface-2);
}

.user-table tbody tr[data-tone="attention"] td:first-child {
  box-shadow: inset 3px 0 0 var(--attention);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  border-radius: 50%;
  display: inline-block;
  line-height: 2rem;
  text-align: center;
  background: var(--surface-3);
  color: var(--ink-2);
  font-family: var(--font-cond);
  font-weight: 600;
  text-transform: uppercase;
  user-select: none;
}

.user-copy {
  display: grid;
  min-width: 0;
  max-width: 14rem;
}

.user-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-plan {
  color: var(--muted);
  font-size: 0.75rem;
}

/* State takes whatever width is left and truncates its detail line. */
.user-table td.state-td {
  width: 100%;
  max-width: 0;
}

.state-cell {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.state-line {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.state-detail {
  color: var(--ink-2);
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-detail b {
  font-weight: 500;
  color: var(--muted);
}

.today-cell {
  display: grid;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.today-cell b {
  font-family: var(--font-cond);
  font-size: 0.9375rem;
  font-weight: 600;
}

.today-cell .bad {
  color: var(--attention-ink);
}

.today-cell .none {
  color: var(--muted);
}

.today-last {
  display: none;
  color: var(--muted);
  font-size: 0.75rem;
}

.funnel {
  display: grid;
  grid-template-columns: repeat(6, 3.25rem);
  align-items: center;
}

.funnel span {
  position: relative;
  font-family: var(--font-cond);
  font-weight: 600;
  text-align: right;
  padding-right: 0.75rem;
}

.funnel span + span::before {
  content: "›";
  position: absolute;
  left: 0.25rem;
  color: var(--line-strong);
  font-weight: 400;
}

.funnel span[data-zero] {
  color: var(--muted);
  font-weight: 500;
}

.funnel.head span {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
}

.funnel.head span + span::before {
  content: none;
}

.when-cell {
  white-space: nowrap;
  font-size: 0.8125rem;
  color: var(--ink-2);
}

/* —— User page —— */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  flex-shrink: 0;
}

.kpi {
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.kpi .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.kpi .value {
  margin: 0.125rem 0 0;
  font-family: var(--font-cond);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
}

.kpi .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

/* Now card + 48-h timeline */
.user-now {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  flex-shrink: 0;
}

.timeline-card .panel-body {
  max-height: 25rem;
}

.lanes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lane {
  position: relative;
  display: grid;
  gap: 0.375rem;
  align-content: start;
  padding: 0.875rem 1rem;
  border-right: 1px solid var(--line);
}

.lane:last-child {
  border-right: 0;
}

/* The rail again, one segment per lane. */
.lane::before {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  top: 0;
  height: 3px;
  border-radius: 0 0 2px 2px;
  background: var(--tone);
}

.lane[data-tone="idle"]::before,
.lane[data-tone="muted"]::before {
  background: var(--line-strong);
}

.lane-name {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.lane .state {
  justify-self: start;
}

.lane-detail {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.8125rem;
}

.now-section {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
}

.now-section h3 {
  margin: 0 0 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

.issue {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--tone);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.issue + .issue {
  margin-top: 0.5rem;
}

.issue-copy {
  display: grid;
  gap: 0.125rem;
  min-width: 0;
}

.issue-copy strong {
  font-weight: 600;
}

.issue-copy span {
  color: var(--ink-2);
  font-size: 0.8125rem;
}

.issue-copy .issue-hint {
  color: var(--muted);
}

.raw summary {
  margin-top: 0.25rem;
  color: var(--accent-text);
  font-size: 0.75rem;
  cursor: pointer;
}

.raw pre {
  max-height: 10rem;
  margin: 0.375rem 0 0;
  padding: 0.5rem 0.625rem;
  overflow: auto;
  border-radius: var(--r-sm);
  background: var(--log-bg);
  color: var(--log-ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.resume-result {
  margin: 0;
  padding: 0.625rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--tone-soft);
  color: var(--tone-ink);
  font-size: 0.8125rem;
}

.resume-result[data-tone="loading"] {
  background: var(--surface-2);
  color: var(--muted);
}

.resolved ul {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.resolved li {
  display: flex;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.resolved .tick {
  color: var(--working);
}

.tl {
  margin: 0;
  padding: 0 0 0.5rem;
  list-style: none;
}

.tl-day {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.375rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.tl-item {
  display: grid;
  grid-template-columns: 2.5rem 0.5rem minmax(0, 1fr);
  align-items: start;
  gap: 0.625rem;
  padding: 0.4375rem 1rem;
}

.tl-item time {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45rem;
  text-decoration: none;
}

.tl-item .dot {
  margin-top: 0.5rem;
}

.tl-copy {
  min-width: 0;
}

.tl-title {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45rem;
}

.tl-detail {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-item[data-tone="attention"] .tl-title {
  color: var(--attention-ink);
  font-weight: 500;
}

.tl-item.resolved .tl-title {
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.confirm-copy {
  margin: 0;
  color: var(--ink-2);
}

.confirm-note {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  color: var(--warn-ink);
  font-size: 0.8125rem;
}

.section-tabs {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}

.section-tab {
  position: relative;
  padding: 0.5rem 0.75rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.section-tab:hover {
  color: var(--ink);
}

.section-tab[aria-selected="true"] {
  color: var(--ink);
  font-weight: 600;
}

.section-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

#detailToolbar {
  overflow: visible;
}

.board.panel {
  flex: 1 1 auto;
  min-height: 0;
}

.app[data-view="user"]:not([data-section="analytics"]) #userScreen {
  flex: 0 0 auto;
}

.app[data-view="user"]:not([data-section="analytics"]) .board.panel {
  flex: 0 0 auto;
  min-height: 22rem;
}

.app[data-view="user"]:not([data-section="analytics"]) .board.panel .table-wrap {
  min-height: 20rem;
  max-height: min(70vh, 42rem);
  overflow: auto;
}

.table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.table td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr {
  cursor: pointer;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table th.num,
.table td.num {
  text-align: right;
  white-space: nowrap;
}

.table.dense th,
.table.dense td {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.table.dense th {
  background: var(--surface);
}

.person {
  display: grid;
  gap: 0.125rem;
  min-width: 10rem;
}

.person strong {
  font-weight: 600;
}

.person span {
  color: var(--muted);
  font-size: 0.8125rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 26rem;
}

td.warm-error {
  max-width: 18rem;
  color: var(--attention-ink);
  font-size: 0.8125rem;
  word-break: break-word;
}

td.warm-error.muted {
  color: var(--muted);
}

/* Warm-up step track */
.pipeline {
  display: flex;
  align-items: flex-start;
  min-width: 260px;
}

.pipe-step {
  display: flex;
  align-items: flex-start;
  flex: 1;
}

.pipe-step:last-child {
  flex: 0 0 auto;
}

.pipe-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1875rem;
}

.pipe-node {
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.625rem;
  font-weight: 600;
}

.pipe-node[data-kind="done"] {
  border-color: var(--working);
  background: var(--working);
  color: #fff;
}

.pipe-node[data-kind="skipped"] {
  border-color: var(--idle);
  background: var(--idle);
  color: #fff;
}

.pipe-node[data-kind="retrying"] {
  border-color: var(--warn);
  background: var(--warn-soft);
  color: var(--warn-ink);
}

/* Attempts used up: an HR outcome, not an alert — muted red. */
.pipe-node[data-kind="gave_up"] {
  border-color: var(--attention);
  background: var(--attention-soft);
  color: var(--attention-ink);
}

.pipe-node[data-kind="parked"] {
  border-style: dashed;
  border-color: var(--waiting);
  color: var(--waiting-ink);
}

.row-state {
  display: grid;
  justify-items: start;
  gap: 0.25rem;
  max-width: 20rem;
}

.row-why {
  max-width: 100%;
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipe-label {
  max-width: 3.5rem;
  color: var(--muted);
  font-size: 0.6875rem;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipe-line {
  flex: 1;
  height: 1.5px;
  min-width: 6px;
  margin-top: 0.625rem;
  background: var(--line-strong);
}

.pipe-line[data-done="true"] {
  background: var(--working);
}

/* Badges & message states */
.pill,
.badge,
.badge-priority,
.msg-status {
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  padding: 0 0.5rem;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.pill.hot,
.badge[data-action="day0"],
.badge[data-action="visit"],
.badge[data-action="like"],
.badge[data-action="follow"],
.badge-priority[data-priority="P1"] {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.pill.ok,
.badge[data-action="done"],
.msg-status[data-status="COMPLETE"],
.msg-status[data-status="COMPLETED"],
.msg-status[data-status="SUCCESS"] {
  background: var(--done-soft);
  color: var(--done-ink);
}

.msg-status[data-status="SENT"] {
  background: var(--working-soft);
  color: var(--working-ink);
}

.msg-status[data-status="WAITING_CONNECTION"],
.msg-status[data-status="DEFERRED_DAILY_LIMIT"] {
  background: var(--waiting-soft);
  color: var(--waiting-ink);
}

/* A failed send is being retried: never styled like a quiet skip. */
.msg-status[data-status="FAILED"] {
  background: var(--attention-soft);
  color: var(--attention-ink);
}

.msg-status[data-status="SKIPPED"],
.msg-status[data-status="INCOMPLETE"] {
  background: var(--idle-soft);
  color: var(--idle-ink);
}

.msg-status[data-status="PENDING"],
.msg-status[data-status="QUEUED"] {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.chip-ok,
.chip-warn,
.chip-fail {
  display: inline-block;
  padding: 0.0625rem 0.375rem;
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: middle;
}

.chip-ok {
  background: var(--working-soft);
  color: var(--working-ink);
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.chip-fail {
  background: var(--attention-soft);
  color: var(--attention-ink);
}

.progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 6.5rem;
}

.bar {
  flex: 1;
  height: 0.375rem;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.pct {
  width: 2.5rem;
  color: var(--muted);
  font-size: 0.75rem;
}

/* —— Modal —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
}

.modal-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(600px, calc(100% - 2rem));
  max-height: min(84vh, 760px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--pop-shadow);
  animation: popIn 0.16s ease;
}

@keyframes popIn {
  from {
    opacity: 0.4;
    transform: translate(-50%, -48.5%);
  }
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.125rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.125rem;
}

.modal-body {
  display: grid;
  gap: 0.75rem;
  padding: 1rem 1.125rem 1.25rem;
}

.block {
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.block h3 {
  margin: 0 0 0.375rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

.block p,
.block a {
  margin: 0;
  color: var(--ink);
  text-decoration: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.block a:hover,
.block .link-out {
  color: var(--accent-text);
}

.block .link-out {
  font-weight: 500;
}

.block .muted-copy {
  margin-top: 0.375rem !important;
  color: var(--muted);
  font-size: 0.8125rem;
  word-break: break-all;
}

.block .lede {
  margin: 0 0 0.5rem !important;
  font-size: 0.8125rem;
}

.stage-list {
  display: grid;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage-list li {
  display: grid;
  grid-template-columns: 5.25rem 1fr;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

.stage-list .st {
  font-weight: 600;
  text-transform: capitalize;
}

.stage-list .st[data-kind="done"] {
  color: var(--working-ink);
}

.stage-list .st[data-kind="retrying"] {
  color: var(--warn-ink);
}

.stage-list .st[data-kind="gave_up"] {
  color: var(--attention-ink);
}

.stage-list .st[data-kind="parked"] {
  color: var(--waiting-ink);
}

.stage-list .st[data-kind="skipped"],
.stage-list .st[data-kind="pending"],
.stage-list .detail {
  color: var(--muted);
}

/* —— Analytics —— */
.analytics-root {
  display: grid;
  gap: 1rem;
  align-content: start;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding-bottom: 0.5rem;
}

.user-analytics-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.user-analytics-panel .analytics-root,
#analyticsScreen .analytics-root {
  flex: 1 1 auto;
}

.analytics-welcome h2 {
  margin: 0;
  font-size: 1.25rem;
}

.analytics-welcome p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.hero-grid,
.user-count-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.hero-kpi,
.user-count {
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  min-width: 0;
}

.hero-kpi .label,
.user-count .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.hero-kpi .value,
.user-count .value {
  margin: 0.125rem 0 0;
  font-family: var(--font-cond);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.hero-kpi .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.hero-kpi.accent .value {
  color: var(--accent-text);
}

.analytics-panel {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.875rem 1rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  min-width: 0;
}

.analytics-head {
  display: grid;
  gap: 0.125rem;
  flex-shrink: 0;
}

.analytics-panel h3,
.analytics-head h3 {
  margin: 0;
  font-size: 1rem;
}

.analytics-panel .panel-lede,
.analytics-head .panel-lede {
  margin: 0;
}

.mini-label {
  margin: 0.5rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.rate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 0.5rem;
}

.rate-card {
  padding: 0.625rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  min-width: 0;
}

.rate-card .step {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  text-transform: capitalize;
}

.rate-card .big {
  margin: 0.125rem 0;
  font-family: var(--font-cond);
  font-size: 1.25rem;
  font-weight: 600;
}

.rate-card .sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.bar-stack {
  display: flex;
  height: 0.375rem;
  margin-top: 0.5rem;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar-stack span {
  display: block;
  height: 100%;
}

.bar-stack .ok {
  background: var(--working);
}

.bar-stack .fail {
  background: var(--attention);
}

.bar-stack .skip {
  background: var(--idle);
}

.stat-stack,
.cost-user-list {
  display: grid;
  max-height: 14rem;
  overflow: auto;
  padding: 0.125rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.cost-user-list {
  max-height: 16rem;
  margin-top: 0.125rem;
}

.stat-stack.compact {
  max-height: none;
  overflow: visible;
  padding: 0;
  border: 0;
  background: transparent;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.stat-row:last-child {
  border-bottom: 0;
}

.stat-row .label {
  color: var(--ink-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-row .value {
  max-width: 58%;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.stat-row .muted {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.8em;
}

.cost-user-row .value {
  display: grid;
  gap: 0.125rem;
  justify-items: end;
  max-width: 62%;
}

.analytics-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.analytics-panel.list-host {
  min-height: 16rem;
  max-height: 28rem;
  overflow: hidden;
}

.analytics-panel.list-host.analytics-span {
  grid-column: 1 / -1;
  max-height: 32rem;
}

.list-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 0.5rem;
  min-height: 0;
  overflow: hidden;
}

.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.8125rem;
}

.pager {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.pager .btn {
  height: 1.625rem;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
}

.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 2.5rem;
  padding: 0 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.spark-bar {
  flex: 1 1 0;
  min-width: 3px;
  max-width: 14px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  opacity: 0.8;
}

.list-scroll {
  flex: 1 1 auto;
  min-height: 8rem;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.list-scroll .table,
.table.analytics-table {
  min-width: 0;
}

.leader-list {
  display: grid;
  max-height: 22rem;
  overflow: auto;
}

.leader-row {
  display: grid;
  grid-template-columns: 1.5rem 2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.leader-row:last-child {
  border-bottom: 0;
}

.leader-idx {
  color: var(--muted);
  font-size: 0.8125rem;
}

.leader-avatar {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-2);
  font-family: var(--font-cond);
  font-weight: 600;
}

.leader-copy {
  display: grid;
  min-width: 0;
}

.leader-copy strong,
.leader-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-copy span {
  color: var(--muted);
  font-size: 0.8125rem;
}

.scope-tag {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0 0.375rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.125rem;
  vertical-align: 0.125rem;
  white-space: nowrap;
}

.scope-tag[data-scope="range"] {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.table td.open-n {
  color: var(--attention-ink);
  font-weight: 600;
}

/* Limits today */
.limits-table tbody tr {
  cursor: default;
}

.limits-table tbody tr:hover {
  background: transparent;
}

.limits-table th:first-child,
.limits-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
}

.limits-table th:first-child {
  background: var(--surface-2);
}

.limits-table tbody tr[data-tone="attention"] td:first-child {
  box-shadow: inset 3px 0 0 var(--attention);
}

.limits-table tbody tr[data-tone="warn"] td:first-child {
  box-shadow: inset 3px 0 0 var(--warn);
}

.acct {
  display: grid;
  max-width: 13rem;
}

.acct span {
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meter {
  display: grid;
  gap: 0.25rem;
  min-width: 5.5rem;
}

.meter-n b {
  font-family: var(--font-cond);
  font-weight: 600;
}

.meter-n small {
  color: var(--muted);
  font-size: 0.75rem;
}

.meter[data-tone="attention"] .meter-n b {
  color: var(--attention-ink);
}

.meter[data-tone="warn"] .meter-n b {
  color: var(--warn-ink);
}

.meter-bar {
  height: 0.25rem;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.meter-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.meter[data-tone="warn"] .meter-bar i {
  background: var(--warn);
}

.meter[data-tone="attention"] .meter-bar i {
  background: var(--attention);
}

/* —— Settings —— */
.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  overflow: auto;
}

.settings-export-panel {
  flex: 0 0 auto;
}

.export-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.875rem 1rem 1rem;
}

.export-card {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.export-card h3 {
  margin: 0;
  font-size: 0.9375rem;
}

.export-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.export-card .btn {
  align-self: flex-start;
  margin-top: 0.25rem;
}

.settings-panel {
  flex: 1 1 auto;
  min-height: 0;
}

.settings-body {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
  gap: 1rem;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.875rem 1rem 1rem;
  overflow: hidden;
}

.logs-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-height: 0;
  overflow: auto;
}

.logs-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}

.logs-row.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.logs-row-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.logs-name {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  word-break: break-all;
}

.logs-meta-line {
  color: var(--muted);
  font-size: 0.75rem;
}

.logs-preview-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  padding: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}

.logs-preview-head h3 {
  margin: 0;
  font-size: 0.9375rem;
}

.logs-preview {
  flex: 1 1 auto;
  min-height: 12rem;
  margin: 0;
  padding: 0.75rem;
  overflow: auto;
  border-radius: var(--r-sm);
  background: var(--log-bg);
  color: var(--log-ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* —— Responsive —— */
@media (max-width: 1280px) {
  .health-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Users table down to 1024 px: last activity folds into Today, funnel keeps HRs › Conn. › DM'd › Replied. */
@media (max-width: 1200px) {
  :root {
    --sidebar-w: 184px;
  }

  .user-table {
    min-width: 0;
  }

  .user-table th,
  .user-table td {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .user-table .col-last {
    display: none;
  }

  .today-last {
    display: block;
  }

  .user-copy {
    max-width: 9rem;
  }

  .funnel {
    grid-template-columns: repeat(4, 3rem);
  }

  .funnel > span:nth-child(1),
  .funnel > span:nth-child(3) {
    display: none;
  }

  .funnel > span:nth-child(2)::before {
    content: none;
  }
}

@media (max-width: 1100px) {
  .overview-grid,
  .user-now {
    grid-template-columns: 1fr;
  }
}

/* Narrow or short viewports: document scroll instead of nested fixed-height panes. */
@media (max-width: 960px), (max-height: 720px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 0;
    border: 0;
  }

  .side-nav {
    display: flex;
    flex-wrap: wrap;
    flex: 1 1 auto;
  }

  .side-link {
    width: auto;
  }

  .side-link[aria-current="page"]::before {
    content: none;
  }

  .side-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0;
    border: 0;
  }

  .side-foot .btn {
    margin: 0 0 0 auto;
  }

  .content {
    flex: none;
    overflow: visible;
  }

  .app[data-view="analytics"] .content,
  .app[data-view="settings"] .content,
  .app[data-view="user"][data-section="analytics"] .content,
  #analyticsScreen,
  #settingsScreen,
  #userScreen[data-section="analytics"],
  .screen.fill,
  .panel.fill,
  .board.panel,
  .user-analytics-panel {
    flex: none;
    overflow: visible;
    height: auto;
  }

  .panel-body.scroll,
  .analytics-root,
  .user-analytics-panel .analytics-root {
    overflow: visible;
    max-height: none;
  }

  .user-table-wrap,
  .table-wrap {
    overflow-x: auto;
  }

  .kpis,
  .hero-grid,
  .user-count-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-two,
  .settings-body,
  .export-body {
    grid-template-columns: 1fr;
  }

  .analytics-panel.list-host {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1rem 0.75rem;
  }

  .content {
    padding: 0 1rem 1.5rem;
  }

  .health-strip,
  .tab-cards {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .search.compact {
    flex: 1 1 100%;
  }

  .attn-user {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .attn-user span {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .lanes {
    grid-template-columns: 1fr;
  }

  .lane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .analytics-toolbar .meta {
    margin-left: 0;
    white-space: normal;
  }
}

@media (max-width: 520px) {
  .kpis,
  .hero-grid,
  .user-count-grid,
  .today-figs {
    grid-template-columns: 1fr;
  }

  .fig:nth-child(odd) {
    border-right: 0;
  }

  .fig {
    border-bottom: 1px solid var(--line);
  }

  .brand-copy span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
