/* ============================================================
   pages.css — per-page styles.
   ============================================================ */

/* ----- Login ----- */
.login-card {
  width: min(380px, 92vw);
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-4);
  padding: var(--sp-8);
  box-shadow: var(--shadow-2);
}
.login-brand {
  text-align: center;
  margin-bottom: var(--sp-6);
}
.login-brand .mark {
  font-weight: 700; letter-spacing: 0.2em;
  color: var(--text-1);
  font-size: var(--fs-lg);
}
.login-brand .sub {
  margin-top: 4px;
  color: var(--brand-red);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.login-form-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 6px;
  display: block;
}
.login-error {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--fs-sm);
  border-radius: var(--r-2);
}

/* ----- Overview ----- */
.overview-hero {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: var(--sp-6);
}
.overview-hero h1 { margin: 0; }

/* ----- Agents list ----- */
.agents-filter-bar {
  display: flex; gap: var(--sp-3); flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--sp-4);
}
.agents-search {
  flex: 1; min-width: 240px; max-width: 360px;
}
/* Clean 4-column matrix: every tile uniform size + position.
   Row 1 = Total + per-system (4 tiles)
   Row 2 = All three + pairwise overlap (4 tiles)
   Row 3 = Single-system only (4 tiles)
   Each row has a small left-side label. */
.agents-kpi-grid {
  display: grid;
  grid-template-columns: 110px repeat(4, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  align-items: stretch;
}
.agents-kpi-row-label {
  display: flex; align-items: center; justify-content: flex-end;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--text-mute);
  padding-right: var(--sp-3);
  text-align: right;
  line-height: 1.3;
}
.agents-kpi-grid .stat-card {
  padding: var(--sp-3) var(--sp-4);
  min-height: 92px;
  display: flex; align-items: center; gap: var(--sp-3);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.agents-kpi-grid .stat-card::before {
  /* Already exists on .stat-card — strengthen for KPI tiles */
  height: 4px;
}
.agents-kpi-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
  background: var(--bg-2);
  color: var(--text-3);
  border: 1px solid var(--border-1);
  flex-shrink: 0;
}
.agents-kpi-grid .stat-card.kpi-accent-crm   .agents-kpi-icon { background: #dbe7ff; color: #1d3a8a; border-color: #93b7ff; }
.agents-kpi-grid .stat-card.kpi-accent-voice .agents-kpi-icon { background: #d1fae5; color: #047857; border-color: #6ee7b7; }
.agents-kpi-grid .stat-card.kpi-accent-cal   .agents-kpi-icon { background: #ede9fe; color: #6d28d9; border-color: #c4b5fd; }
.agents-kpi-grid .stat-card.kpi-accent-all   .agents-kpi-icon { background: #fef2f4; color: var(--brand-red); border-color: #fecdd3; }
[data-theme="dark"] .agents-kpi-grid .stat-card.kpi-accent-crm   .agents-kpi-icon { background: #182f5a; color: #cfe1ff; border-color: #2851a3; }
[data-theme="dark"] .agents-kpi-grid .stat-card.kpi-accent-voice .agents-kpi-icon { background: #103627; color: #34d399; border-color: #1f6049; }
[data-theme="dark"] .agents-kpi-grid .stat-card.kpi-accent-cal   .agents-kpi-icon { background: #2a1e4d; color: #c4b5fd; border-color: #5b3da0; }
[data-theme="dark"] .agents-kpi-grid .stat-card.kpi-accent-all   .agents-kpi-icon { background: #3a0d14; color: #fb7185; border-color: #5c1a26; }
.agents-kpi-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.agents-kpi-grid .stat-card-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-weight: 700;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agents-kpi-grid .stat-card-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 2px;
  line-height: 1.1;
}
.agents-kpi-grid .stat-card-hint {
  margin-top: 2px;
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Active/selected KPI (matches current filter) */
.agents-kpi-grid .stat-card.kpi-active {
  border-color: var(--brand-red);
  box-shadow: var(--ring-brand), var(--shadow-2);
  transform: translateY(-1px);
}
.agents-kpi-grid .stat-card.kpi-active::before {
  opacity: 1; transform: translateY(0);
}
.agents-kpi-grid .stat-card:hover .agents-kpi-icon {
  transform: scale(1.08);
  transition: transform var(--dur-fast) var(--ease-out);
}
@media (max-width: 1100px) {
  .agents-kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .agents-kpi-row-label { display: none; }
}
@media (max-width: 700px) {
  .agents-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Mini-bar variant for KPIs (sidebar accent in the brand color) */
.stat-card.kpi-accent-crm { border-left: 3px solid #2563eb; }
.stat-card.kpi-accent-voice { border-left: 3px solid #047857; }
.stat-card.kpi-accent-cal { border-left: 3px solid #6d28d9; }
.stat-card.kpi-accent-all { border-left: 3px solid var(--brand-red); }
.agent-avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-3), var(--bg-active));
  color: var(--text-1);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: var(--fs-xs);
  flex-shrink: 0;
  border: 1px solid var(--border-1);
}
.agent-avatar-wrap {
  position: relative; display: inline-block;
}

/* ----- Timeline page ----- */
.tl-legend {
  display: flex; flex-wrap: wrap; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-2);
  border-radius: var(--r-2);
  font-size: var(--fs-xs);
}
.tl-legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tl-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  vertical-align: middle;
}
.tl-dot.tl-sq { border-radius: 2px; }
.tl-dot.tl-tri { background: transparent !important; width: 0; height: 0; border-style: solid; border-width: 0 6px 10px 6px; border-color: transparent transparent #6d28d9 transparent; }
.tl-dot.tl-bar { border-radius: 2px; width: 16px; height: 6px; }

.tl-totals { display: flex; gap: var(--sp-4); }
.tl-total { color: var(--text-2); font-size: var(--fs-sm); }
.tl-total strong { color: var(--text-1); font-size: var(--fs-lg); }

.tl-chart {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  padding: 28px 0 0;
  overflow: hidden;
}
.tl-hour-grid {
  position: absolute; inset: 0;
  pointer-events: none;
}
.tl-hour-line {
  position: absolute; top: 0; bottom: 0;
  width: 1px;
  background: var(--border-1);
}
.tl-hour-label {
  position: absolute; top: 4px;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-3);
  background: var(--bg-2);
  padding: 0 4px;
  white-space: nowrap;
}
.tl-lane {
  position: relative;
  display: flex; align-items: center;
  height: 44px;
  border-top: 1px solid var(--border-1);
}
.tl-lane:first-of-type { border-top: 0; margin-top: 24px; }
.tl-lane-label {
  width: 90px;
  flex-shrink: 0;
  padding: 0 var(--sp-3);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-3);
  background: var(--bg-2);
  position: sticky; left: 0; z-index: 1;
  border-right: 1px solid var(--border-1);
  height: 100%;
  display: flex; align-items: center;
}
.tl-lane-track {
  flex: 1;
  position: relative;
  height: 100%;
}
.tl-event {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out);
}
.tl-event:hover { transform: translate(-50%, -50%) scale(1.4); z-index: 2; }
.tl-event.tl-call {
  width: 11px; height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg-2);
}
.tl-event.tl-task {
  width: 11px; height: 11px;
  background: #b45309;
  border-radius: 2px;
  box-shadow: 0 0 0 2px var(--bg-2);
}
.tl-event.tl-sms {
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 6px 11px 6px;
  border-color: transparent transparent #6d28d9 transparent;
}
.tl-event.tl-sms.in { border-color: transparent transparent #7c3aed transparent; }
.tl-event.tl-sms.out { border-color: transparent transparent #4c1d95 transparent; }

/* Meeting bar — stretched across [start, end]. Single-mode lane gets
   a taller bar with a subtle border; team-mode rows get a thinner one
   that sits behind the call/task/sms dots. */
.tl-meeting {
  position: absolute; top: 50%; transform: translateY(-50%);
  height: 16px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.18);
  transition: transform 140ms, box-shadow 140ms;
  cursor: default;
  z-index: 1;
}
.tl-meeting:hover { transform: translateY(-50%) scaleY(1.15); z-index: 3; box-shadow: 0 2px 6px rgba(15,23,42,0.28); }
.tl-team-track .tl-meeting-team {
  position: absolute; top: 50%; transform: translateY(-50%);
  height: 14px;
  border-radius: 3px;
  pointer-events: auto;
  z-index: 0;
}
.tl-team-track .tl-meeting-team:hover { opacity: 0.85; }
.tl-team-track .tl-event { z-index: 1; } /* keep dots above meeting bars */
.tl-empty {
  font-size: var(--fs-xs);
  color: var(--text-mute);
  font-style: italic;
  padding-left: var(--sp-3);
  display: flex; align-items: center; height: 100%;
}

.tl-activity-bar {
  background: var(--bg-3);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}
.tl-activity-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-red), #f59e0b);
  border-radius: 4px;
  transition: width var(--dur-med) var(--ease-out);
}

/* ----- Compare page ----- */
.cmp-picker {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.cmp-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: 999px;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.cmp-chip:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.cmp-chip.selected {
  background: linear-gradient(180deg, var(--brand-red-bg) 0%, var(--bg-1) 100%);
  border-color: var(--brand-red);
  font-weight: 600;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-red) 18%, transparent);
}
.cmp-chip .agent-avatar-sm { width: 24px; height: 24px; font-size: 9px; }
.cmp-chip-name { color: var(--text-1); }

.cmp-table .cmp-row-label {
  text-align: left !important;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 700;
  background: var(--bg-2);
  width: 130px;
}
.cmp-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}
.cmp-val.best { color: var(--brand-red); font-weight: 800; }
.cmp-bar {
  margin-top: 6px;
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
}
.cmp-bar-fill { height: 100%; border-radius: 3px; transition: width var(--dur-med) var(--ease-out); }

/* Leaderboard rank badge (gold/silver/bronze for top 3) */
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-weight: 800;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.rank-badge.gold   { background: linear-gradient(135deg, #fcd34d, #f59e0b); color: #78350f; box-shadow: 0 2px 6px color-mix(in srgb, #f59e0b 40%, transparent); }
.rank-badge.silver { background: linear-gradient(135deg, #e5e7eb, #9ca3af); color: #1f2937; box-shadow: 0 2px 6px color-mix(in srgb, #6b7280 30%, transparent); }
.rank-badge.bronze { background: linear-gradient(135deg, #fcd9b6, #d97706); color: #5c2c0d; box-shadow: 0 2px 6px color-mix(in srgb, #d97706 30%, transparent); }
.rank-badge.muted  { background: var(--bg-2); color: var(--text-3); border: 1px solid var(--border-1); }

/* Live status strip on Agents page */
.live-status-grid {
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
}
.live-status-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: 999px;
  font-size: var(--fs-xs);
  transition: all var(--dur-fast) var(--ease-out);
  cursor: pointer;
}
.live-status-chip:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.live-status-chip .agent-avatar-wrap .agent-avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.live-status-chip .agent-avatar-wrap .online-dot { width: 8px; height: 8px; }
.live-status-chip-text { display: flex; flex-direction: column; line-height: 1.2; }
.live-status-chip-name { color: var(--text-1); font-weight: 600; }
.live-status-chip-meta { color: var(--text-3); font-size: 10px; margin-top: 2px; }
.online-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-1);
  display: inline-block;
}

/* ----- Agent detail header ----- */
.agent-head {
  display: flex; align-items: center; gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.agent-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--text-1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: var(--fs-lg);
}
.agent-head-meta { display: flex; flex-direction: column; gap: 2px; }
.agent-name { font-size: var(--fs-2xl); font-weight: 600; }
.agent-email { color: var(--text-3); font-size: var(--fs-sm); }

/* ----- Admin sync page ----- */
.sync-cursor-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- Placeholder pages ----- */
.placeholder-canvas {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-12);
  text-align: center;
  border: 1px dashed var(--border-2);
  border-radius: var(--r-3);
  background: var(--bg-1);
  color: var(--text-3);
}
.placeholder-canvas .pc-icon { font-size: 32px; color: var(--text-mute); }
.placeholder-canvas .pc-title { color: var(--text-1); font-weight: 600; font-size: var(--fs-lg); }
.placeholder-canvas .pc-phase { color: var(--brand-amber); font-size: var(--fs-xs); letter-spacing: 0.14em; text-transform: uppercase; }

/* ============================================================
   Dashboards page
   ============================================================ */
.db-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}
@media (max-width: 1100px) { .db-grid { grid-template-columns: 1fr; } }
.db-span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .db-span-2 { grid-column: span 1; } }

.db-chart-card { background: var(--bg-1); border: 1px solid var(--border-1); border-radius: var(--r-3); }
.db-chart-card .panel-body { padding: var(--sp-4); }

.db-kpi {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 6px;
  overflow: hidden;
  transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.db-kpi:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.db-kpi-head { display: flex; align-items: center; gap: 8px; }
.db-kpi-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.db-kpi-label { font-size: var(--fs-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.db-kpi-value { font: 700 24px/1.1 "Inter", -apple-system, sans-serif; color: var(--text-1); }
.db-kpi-trend { font-size: 11px; }
.db-kpi-delta { font-weight: 700; }
.db-kpi-delta.up   { color: var(--success); }
.db-kpi-delta.down { color: var(--danger); }
.db-kpi-spark { width: 100%; height: 32px; margin-top: 2px; }

/* Heatmap (CSS grid; no chart library needed) */
.db-heatmap {
  display: grid;
  grid-template-columns: 50px repeat(24, 1fr);
  gap: 2px;
  font-size: 10px;
}
.db-hm-row-label { color: var(--text-3); font-weight: 600; text-transform: uppercase; padding: 4px 6px 4px 0; text-align: right; align-self: center; }
.db-hm-col-label { color: var(--text-3); text-align: center; padding: 4px 0; font-weight: 500; }
.db-hm-cell {
  height: 26px; border-radius: 3px;
  cursor: default;
  background: var(--bg-2);
  transition: outline 100ms;
}
.db-hm-cell:hover { outline: 2px solid var(--brand-red); outline-offset: 1px; }

/* ============================================================
   Analytics page
   ============================================================ */
.an-filter-bar {
  display: flex; flex-wrap: wrap; align-items: end; gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-3);
  margin-bottom: var(--sp-4);
}
.an-filter-bar .form-label { font-size: var(--fs-xs); color: var(--text-3); margin-bottom: 4px; }

/* New filter panel layout — top row has the three pickers + apply.
   Chip drawer collapses underneath and only opens when the user
   clicks "Choose agents". The drawer never pushes the top row around. */
.an-filter-panel { margin-bottom: var(--sp-4); }
.an-filter-panel-body { padding: var(--sp-3) var(--sp-4) !important; }
.an-filter-row {
  display: grid;
  grid-template-columns: 200px 220px 1fr auto;
  gap: var(--sp-4);
  align-items: end;
}
@media (max-width: 900px) {
  .an-filter-row { grid-template-columns: 1fr 1fr; }
  .an-filter-agents, .an-filter-apply { grid-column: 1 / -1; }
}
.an-filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.an-filter-label {
  font: 600 10px/1 -apple-system, "Segoe UI", sans-serif;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3);
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap;
}
.an-filter-agents { min-width: 0; }
.an-filter-apply { display: flex; align-items: end; }
.an-agent-controls {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  min-width: 0;
}

/* Chip drawer — separated from the top row so chips never push
   inputs around. Scrolls vertically when overflowing. */
.an-agent-chips {
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  animation: anAgentChipsIn 160ms ease-out;
}
@keyframes anAgentChipsIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.an-agent-chips-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline;
  gap: var(--sp-3); margin-bottom: var(--sp-2);
  font: 500 11.5px/1.3 -apple-system, sans-serif;
}
.an-agent-chips-head .muted { color: var(--text-2); }
.an-agent-chips-body {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 220px; overflow-y: auto;
  padding: 2px;
}
.an-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px;
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: 99px;
  font: 500 12px/1.2 -apple-system, "Segoe UI", sans-serif;
  color: var(--text-2);
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
  white-space: nowrap;
}
.an-chip:hover { border-color: var(--brand-red); color: var(--text-1); }
.an-chip.selected {
  background: var(--brand-red); border-color: var(--brand-red); color: #fff;
}
.an-chip.selected i { color: #fff; }

/* "N agents with no <metric>" — collapsible pill rendered below charts/tables. */
.an-no-data {
  margin: var(--sp-3) var(--sp-4) 0;
  padding: 0;
}
.an-no-data-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  background: var(--bg-2);
  border: 1px dashed var(--border-2);
  border-radius: 99px;
  font: 500 12px/1.2 -apple-system, "Segoe UI", sans-serif;
  color: var(--text-2);
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.an-no-data-trigger:hover { background: var(--bg-1); border-color: var(--brand-red); color: var(--text-1); }
.an-no-data-trigger strong { color: var(--text-1); }
.an-no-data-list {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 8px;
  padding: var(--sp-2);
  background: var(--bg-2);
  border-radius: var(--r-2);
}
.an-no-data-chip {
  display: inline-block;
  padding: 3px 9px;
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: 99px;
  font: 500 11px/1.4 -apple-system, "Segoe UI", sans-serif;
  color: var(--text-3);
}
.an-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-4);
}
@media (max-width: 1100px) { .an-grid { grid-template-columns: 1fr; } }

.an-section-title {
  font: 600 11px/1 -apple-system, sans-serif; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3);
  margin: 0 0 var(--sp-3);
  display: flex; align-items: center; gap: 6px;
}

.an-distribution { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
@media (max-width: 900px) { .an-distribution { grid-template-columns: 1fr; } }

/* ============================================================
   Chart sizing — Chart.js v4 needs a positioned, fixed-height
   parent OR it will grow on every resize tick. Wrap every canvas
   in a `.chart-box` (with a sizing modifier) and the chart will
   stay put. Without this, with `maintainAspectRatio: false` the
   canvas grows infinitely off-screen.
   ============================================================ */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.chart-box.h-32  { height: 32px; margin-top: 4px; }
.chart-box.h-180 { height: 180px; }
.chart-box.h-220 { height: 220px; }
.chart-box.h-260 { height: 260px; }
.chart-box.h-300 { height: 300px; }
.chart-box.h-340 { height: 340px; }

/* ============================================================
   Loading indicators — NavLoader (top bar) + ContentLoading (veil)
   ============================================================ */
.nav-loader {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 2000;
  background: transparent; pointer-events: none;
}
.nav-loader.hidden { display: none; }
.nav-loader-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-red, #c8102e), #f43f5e, var(--brand-red, #c8102e));
  background-size: 200% 100%;
  width: 0%;
  transition: width 240ms ease;
  box-shadow: 0 0 6px rgba(200,16,46,0.45);
  animation: navLoaderShine 1.2s linear infinite;
}
.nav-loader.active .nav-loader-fill {
  /* Two-phase creep — quick to 70%, then crawl until finish() snaps to 100% */
  animation: navLoaderShine 1.2s linear infinite, navLoaderCreep 12s cubic-bezier(0.05, 0.7, 0.1, 1) forwards;
}
@keyframes navLoaderShine {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}
@keyframes navLoaderCreep {
  0%   { width: 0%; }
  20%  { width: 45%; }
  50%  { width: 75%; }
  100% { width: 92%; }
}

.has-loading-veil { position: relative; }
.content-veil {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  border-radius: inherit;
  animation: contentVeilIn 140ms ease-out;
}
[data-theme="dark"] .content-veil { background: rgba(15,23,42,0.62); }
.content-veil-inner {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 26px;
  background: var(--bg-1, #fff);
  border: 1px solid var(--border-1, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(15,23,42,0.12);
}
.content-veil-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border-1, #e5e7eb);
  border-top-color: var(--brand-red, #c8102e);
  animation: contentVeilSpin 700ms linear infinite;
}
.content-veil-label {
  font: 500 12px/1.2 "Inter", -apple-system, sans-serif;
  color: var(--text-2, #475569);
}
@keyframes contentVeilSpin { to { transform: rotate(360deg); } }
@keyframes contentVeilIn { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   Timeline mode toggle (single agent vs all-active)
   ============================================================ */
.tl-mode-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-2, #f1f5f9);
  border: 1px solid var(--border-1, #e5e7eb);
  border-radius: 99px;
  gap: 2px;
}
.tl-mode-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: transparent;
  border: 0;
  border-radius: 99px;
  font: 600 12px/1 "Inter", -apple-system, sans-serif;
  color: var(--text-2, #475569);
  cursor: pointer;
  transition: background 140ms, color 140ms;
}
.tl-mode-btn:hover { color: var(--text-1, #0f172a); }
.tl-mode-btn.active {
  background: var(--bg-1, #fff);
  color: var(--brand-red, #c8102e);
  box-shadow: 0 1px 3px rgba(15,23,42,0.10);
}

/* Team-mode stacked-rows layout */
.tl-team-board { display: flex; flex-direction: column; gap: 4px; }
.tl-team-head {
  display: grid; grid-template-columns: 220px 1fr; gap: var(--sp-3);
  padding: 8px 12px;
  font: 700 10px/1 -apple-system, sans-serif;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3, #6b7280);
  border-bottom: 1px solid var(--border-1, #e5e7eb);
}
.tl-team-row {
  display: grid; grid-template-columns: 220px 1fr; gap: var(--sp-3);
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 120ms;
}
.tl-team-row:hover { background: var(--bg-2, #f8fafc); }
.tl-team-name {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-1, #0f172a);
  min-width: 0;
}
.tl-team-name strong { font-weight: 600; }
.tl-team-name .tz { color: var(--text-3, #94a3b8); font-size: 10.5px; }
.tl-team-track {
  position: relative;
  height: 28px;
  background: var(--bg-2, #f8fafc);
  border-radius: 6px;
  overflow: hidden;
}
.tl-team-track .tl-event {
  position: absolute; top: 50%;
  width: 7px; height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
}
.tl-team-track .tl-event.task { border-radius: 1px; background: #b45309; }
.tl-team-track .tl-event.sms { background: #6d28d9; }
.tl-team-empty {
  font-size: 11px; color: var(--text-3, #9ca3af);
  text-align: center; line-height: 28px;
  font-style: italic;
}
.tl-team-stats {
  font: 500 11px/1 -apple-system, sans-serif;
  color: var(--text-3, #6b7280);
}
.tl-team-stats strong { color: var(--text-1, #0f172a); font-weight: 700; }

/* ============================================================
   Leaderboard polish — podium highlights + per-row metric bar
   ============================================================ */
tr.lb-podium { position: relative; }
tr.lb-podium > td:first-child { position: relative; }
tr.lb-podium > td:first-child::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 4px; border-radius: 2px;
}
tr.lb-podium.gold   > td:first-child::before { background: linear-gradient(180deg, #fde68a, #f59e0b); }
tr.lb-podium.silver > td:first-child::before { background: linear-gradient(180deg, #e5e7eb, #94a3b8); }
tr.lb-podium.bronze > td:first-child::before { background: linear-gradient(180deg, #fcd9b6, #b45309); }
tr.lb-podium.gold   { background: linear-gradient(90deg, rgba(245,158,11,0.06), transparent 35%); }
tr.lb-podium.silver { background: linear-gradient(90deg, rgba(148,163,184,0.05), transparent 35%); }
tr.lb-podium.bronze { background: linear-gradient(90deg, rgba(180,83,9,0.05), transparent 35%); }

.lb-metric-bar {
  margin-top: 5px; height: 4px; width: 100%;
  background: var(--bg-2, #f1f5f9); border-radius: 99px; overflow: hidden;
}
.lb-metric-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--brand-red, #c8102e), #f43f5e);
  border-radius: 99px;
}

/* ============================================================
   Compare polish — sectioned card, agent header chips,
   per-metric mini bars with delta vs row peak
   ============================================================ */
.cmp-result-grid {
  display: grid;
  gap: var(--sp-3);
}
.cmp-agent-head {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 10px 14px;
  border-bottom: 1px solid var(--border-1, #e5e7eb);
  background: linear-gradient(180deg, var(--bg-2, #f8fafc), var(--bg-1, #fff));
}
.cmp-agent-head .cmp-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand-red, #c8102e); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 13px/1 -apple-system, sans-serif; letter-spacing: 0.04em;
}
.cmp-agent-head .cmp-name { font: 600 13px/1.2 -apple-system, sans-serif; color: var(--text-1, #0f172a); text-align: center; }
.cmp-agent-head .cmp-role { font-size: 11px; color: var(--text-3, #6b7280); }

.cmp-metric-row .cmp-row-label {
  font: 600 11px/1.2 -apple-system, sans-serif;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3, #6b7280);
  padding: 14px 12px;
  background: var(--bg-2, #fafbfc);
  border-right: 1px solid var(--border-1, #e5e7eb);
  white-space: nowrap;
}
.cmp-val {
  font: 700 16px/1.1 -apple-system, sans-serif;
  color: var(--text-1, #0f172a);
}
.cmp-val.best {
  color: var(--brand-red, #c8102e);
}
.cmp-val.best::after {
  content: " ★";
  color: #f59e0b;
  font-size: 11px;
  vertical-align: super;
}
.cmp-bar { margin-top: 6px; height: 5px; background: var(--bg-2, #f1f5f9); border-radius: 99px; overflow: hidden; }
.cmp-bar-fill { height: 100%; border-radius: 99px; transition: width 200ms ease-out; }

/* ============================================================
   Gaps page — day-grouped idle audit. One card per day, one
   row per flagged agent, each with a 9–5 "work bar".
   ============================================================ */
.gp-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.gp-check input { cursor: pointer; }

.gp-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.gp-legend { display: flex; gap: var(--sp-4); align-items: center; font-size: var(--fs-xs); color: var(--text-3); }
.gp-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }
.gp-legend .sw.active { background: color-mix(in srgb, var(--success) 26%, transparent); }
.gp-legend .sw.idle   { background: color-mix(in srgb, var(--danger) 62%, transparent); }
.gp-legend .sw.future { background: repeating-linear-gradient(45deg, var(--bg-3), var(--bg-3) 4px, var(--bg-2) 4px, var(--bg-2) 8px); }

/* Day card */
.gp-day { margin-bottom: var(--sp-4); }
.gp-day-head { cursor: pointer; user-select: none; }
.gp-day-head:hover { background: var(--bg-3); }
.gp-day-title { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-md); color: var(--text-1); }
.gp-day-title strong { font-weight: 700; }
.gp-day-title .muted { font-weight: 400; }
.gp-day-caret { transition: transform 160ms var(--ease-out); color: var(--text-3); font-size: 12px; }
.gp-day.collapsed .gp-day-caret { transform: rotate(-90deg); }
.gp-day.collapsed .gp-day-body { display: none; }
.gp-day-chips { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.gp-day-chip { font-size: var(--fs-xs); color: var(--text-3); background: var(--bg-3); padding: 2px 9px; border-radius: var(--r-pill); font-weight: 600; font-variant-numeric: tabular-nums; }
.gp-day-chip.danger { background: var(--danger-bg); color: var(--danger); }

/* Agent row */
.gp-row {
  display: grid; grid-template-columns: 210px 1fr 170px; gap: var(--sp-4);
  align-items: center; padding: 11px var(--sp-4);
  border-bottom: 1px solid var(--border-1); cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.gp-row:last-child { border-bottom: 0; }
.gp-row:hover { background: var(--bg-active); }
.gp-row:focus-visible { outline: none; box-shadow: inset 3px 0 0 var(--brand-red); background: var(--bg-active); }
.gp-row-name { min-width: 0; }
.gp-row-name strong { display: block; font-weight: 600; font-size: var(--fs-sm); color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gp-row-name .tz { font-size: var(--fs-xs); color: var(--text-3); }

/* The work bar — green base = covered, red = idle, hatched = not yet elapsed */
.gp-bar {
  position: relative; height: 22px; border-radius: 6px; overflow: hidden;
  background: color-mix(in srgb, var(--success) 16%, transparent);
  border: 1px solid var(--border-1);
}
.gp-bar-idle { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--danger) 62%, transparent); transition: background var(--dur-fast) var(--ease-out); }
.gp-bar-idle:hover { background: var(--danger); }
.gp-bar-future { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, var(--bg-3), var(--bg-3) 5px, var(--bg-2) 5px, var(--bg-2) 10px); }
.gp-bar-ticks { position: relative; height: 13px; margin-top: 2px; }
.gp-tick { position: absolute; transform: translateX(-50%); font-size: 9px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gp-tick:first-child { transform: translateX(0); }
.gp-tick:last-child { transform: translateX(-100%); }

/* Idle-window chips under the bar */
.gp-windows { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gp-win-label { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.gp-win { font-size: var(--fs-xs); color: var(--text-2); font-variant-numeric: tabular-nums; background: var(--bg-2); border: 1px solid var(--border-1); border-radius: var(--r-2); padding: 1px 7px; }
.gp-win em { font-style: normal; color: var(--danger); font-weight: 700; }
.gp-win-note { font-size: var(--fs-xs); color: var(--text-3); }

/* Right-hand stats */
.gp-row-stats { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.gp-stat-idle { font-size: var(--fs-sm); color: var(--text-2); }
.gp-stat-idle .gp-idle { font-weight: 700; color: var(--danger); }
.gp-cov { font-size: var(--fs-xs); }

@media (max-width: 760px) {
  .gp-row { grid-template-columns: 1fr; gap: 8px; }
  .gp-row-stats { flex-direction: row; align-items: center; text-align: left; gap: 10px; }
}
