/* =============================================================
   Clover OS — Reporting v2 — "Clover Signal"
   A fresh, chart-forward marketing dashboard. Shadcn-dashboard
   idiom (stat cards, tabs, hairline cards) in the Clover palette.
   Everything is scoped under .rv2 so it can't touch v1 styles.
   ============================================================= */

.rv2 {
  /* Local viz tokens (green-anchored categorical ramp) */
  --rv2-ground:    #eef1f3;          /* slightly deeper than v1 so white cards lift */
  --rv2-card:      #ffffff;
  --rv2-ink:       var(--color-navy);
  --rv2-ink-soft:  #2b3a4f;
  --rv2-muted:     #64748b;
  --rv2-faint:     #94a3b8;
  --rv2-hair:      #e6e9ec;
  --rv2-hair-soft: #eef1f3;
  --rv2-brand:     var(--color-primary);        /* #00d59f */
  --rv2-brand-700: var(--color-primary-700);    /* #008a67 */
  --rv2-brand-600: var(--color-primary-600);    /* #009e76 */

  /* categorical series colors */
  --rv2-c1: #00d59f;
  --rv2-c2: #008a67;
  --rv2-c3: #041e3f;
  --rv2-c4: #6fe6c8;
  --rv2-c5: #33ddb3;
  --rv2-c6: #0e6f8c;
  --rv2-warn: #f0a020;
  --rv2-bad:  #e0533d;

  --rv2-radius: 16px;
  --rv2-radius-sm: 10px;

  min-height: 100vh;
  background:
    radial-gradient(1200px 460px at 78% -8%, rgba(0,213,159,.10), transparent 60%),
    var(--rv2-ground);
  color: var(--rv2-ink);
  font-family: var(--font-body);
  padding-bottom: 64px;
}

.rv2 *,
.rv2 *::before,
.rv2 *::after { box-sizing: border-box; }

.rv2-wrap {
  width: 100%;
  margin: 0;
  padding: 28px 40px 0;
}

/* ---------- Page header ---------- */
.rv2-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.rv2-eyebrow {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--rv2-brand-700);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
}
.rv2-eyebrow::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--rv2-brand);
  box-shadow: 0 0 0 4px rgba(0,213,159,.18);
}
.rv2-title {
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0;
  color: var(--rv2-ink);
}
.rv2-sub {
  margin: 7px 0 0;
  font-size: 13px;
  color: var(--rv2-muted);
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.rv2-sub b { color: var(--rv2-ink-soft); font-weight: 600; }
.rv2-sub .rv2-dot { width: 3px; height: 3px; border-radius: 999px; background: var(--rv2-faint); }

.rv2-controls { display: flex; align-items: center; gap: 10px; }

/* Segmented range control */
.rv2-seg {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--rv2-hair);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow-sm);
}
.rv2-seg button {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--rv2-muted);
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
  font-variant-numeric: tabular-nums;
}
.rv2-seg button:hover { color: var(--rv2-ink); }
.rv2-seg button.is-on {
  background: var(--rv2-ink);
  color: #fff;
  box-shadow: 0 1px 2px rgba(4,30,63,.25);
}

/* ---------- Cards ---------- */
.rv2-card {
  background: var(--rv2-card);
  border: 1px solid var(--rv2-hair);
  border-radius: var(--rv2-radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.rv2-card__hd {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.rv2-card__titles { min-width: 0; }
.rv2-card__title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--rv2-ink);
  margin: 0;
}
.rv2-card__hint {
  font-size: 12px;
  color: var(--rv2-muted);
  margin: 3px 0 0;
}
.rv2-card__hd-spacer { flex: 1; }

/* tabs inside a card header */
.rv2-tabs { display: inline-flex; gap: 2px; background: var(--rv2-hair-soft); border-radius: 999px; padding: 3px; }
.rv2-tabs button {
  appearance: none; border: 0; background: transparent; font: inherit;
  font-size: 12px; font-weight: 600; color: var(--rv2-muted);
  padding: 5px 11px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.rv2-tabs button:hover { color: var(--rv2-ink); }
.rv2-tabs button.is-on { background: #fff; color: var(--rv2-brand-700); box-shadow: var(--shadow-sm); }

/* ---------- Layout grids ---------- */
.rv2-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.rv2-row {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}
.rv2-row--hero  { grid-template-columns: 2fr 1fr; }
.rv2-row--2     { grid-template-columns: 1fr 1fr; }
.rv2-row--3     { grid-template-columns: 1fr 1fr 1fr; }
.rv2-row--attr  { grid-template-columns: 1.3fr 1fr; }

/* ---------- KPI stat card ---------- */
.rv2-kpi { position: relative; gap: 0; padding: 16px 16px 0; overflow: hidden; }
.rv2-kpi__label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--rv2-muted);
}
.rv2-kpi__value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rv2-ink);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.rv2-kpi__foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 20px; }
.rv2-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px 2px 5px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.rv2-delta--pos { color: var(--color-positive-dark); background: var(--color-positive); }
.rv2-delta--neg { color: var(--color-negative-dark); background: var(--color-negative); }
.rv2-delta svg { width: 11px; height: 11px; }
.rv2-kpi__note { font-size: 11.5px; color: var(--rv2-faint); }
.rv2-kpi__spark { margin: 12px -16px -1px; height: 44px; display: block; }
.rv2-kpi.is-muted .rv2-kpi__value { color: var(--rv2-faint); }

/* ---------- Chart primitives ---------- */
.rv2-chart { width: 100%; display: block; }
.rv2-chart-host { position: relative; width: 100%; }

.rv2-tip {
  position: absolute;
  pointer-events: none;
  background: var(--rv2-ink);
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: var(--shadow-md);
  transform: translate(-50%, -115%);
  white-space: nowrap;
  z-index: 5;
}
.rv2-tip__day { font-weight: 700; margin-bottom: 2px; font-size: 11px; opacity: .8; }
.rv2-tip__val { font-weight: 700; font-variant-numeric: tabular-nums; }
.rv2-tip__row { display: flex; align-items: center; gap: 6px; }
.rv2-tip__sw { width: 8px; height: 8px; border-radius: 2px; }

.rv2-axis-x {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--rv2-faint);
  font-variant-numeric: tabular-nums;
}

/* legend */
.rv2-legend { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; min-width: 0; }
.rv2-legend__item { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.rv2-legend__sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.rv2-legend__name { color: var(--rv2-ink-soft); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv2-legend__val { font-weight: 700; color: var(--rv2-ink); font-variant-numeric: tabular-nums; }
.rv2-legend__pct { color: var(--rv2-muted); font-size: 11.5px; width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

/* donut center */
.rv2-donut-wrap { display: flex; align-items: center; gap: 18px; }
.rv2-donut-center { text-align: center; }
.rv2-donut-center__v { font-family: var(--font-heading); font-size: 19px; font-weight: 800; color: var(--rv2-ink); font-variant-numeric: tabular-nums; }
.rv2-donut-center__l { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--rv2-muted); margin-top: 2px; }

/* ---------- Horizontal ranked bars ---------- */
.rv2-hbars { display: flex; flex-direction: column; gap: 12px; }
.rv2-hbar__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.rv2-hbar__name { font-size: 12.5px; color: var(--rv2-ink-soft); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv2-hbar__val { font-size: 12.5px; font-weight: 700; color: var(--rv2-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rv2-hbar__sub { font-size: 11px; color: var(--rv2-faint); font-weight: 500; margin-left: 6px; }
.rv2-hbar__track { height: 8px; border-radius: 999px; background: var(--rv2-hair-soft); overflow: hidden; }
.rv2-hbar__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--rv2-brand-700), var(--rv2-brand));
  transform-origin: left;
}
.rv2-hbar__fill--warn { background: linear-gradient(90deg, #c97c10, var(--rv2-warn)); }

/* ---------- Funnel ---------- */
.rv2-funnel { display: flex; flex-direction: column; gap: 8px; }
.rv2-funnel__step { display: grid; grid-template-columns: 1fr; gap: 4px; }
.rv2-funnel__top { display: flex; align-items: baseline; justify-content: space-between; }
.rv2-funnel__label { font-size: 12.5px; color: var(--rv2-ink-soft); font-weight: 500; }
.rv2-funnel__val { font-size: 13px; font-weight: 700; color: var(--rv2-ink); font-variant-numeric: tabular-nums; }
.rv2-funnel__bar { height: 26px; border-radius: 7px; background: linear-gradient(90deg, var(--rv2-c2), var(--rv2-c1)); display: flex; align-items: center; min-width: 2%; }
.rv2-funnel__rate { font-size: 11px; color: var(--rv2-muted); font-variant-numeric: tabular-nums; }

/* ---------- Mini metric cards (website / polk) ---------- */
.rv2-mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.rv2-mini {
  border: 1px solid var(--rv2-hair);
  border-radius: var(--rv2-radius-sm);
  padding: 13px 14px;
  background: linear-gradient(180deg, #fff, #fcfdfd);
}
.rv2-mini__label { font-size: 11.5px; color: var(--rv2-muted); font-weight: 600; }
.rv2-mini__value { font-family: var(--font-heading); font-size: 21px; font-weight: 800; color: var(--rv2-ink); margin-top: 5px; font-variant-numeric: tabular-nums; }
.rv2-mini__bar { height: 6px; border-radius: 999px; background: var(--rv2-hair-soft); margin-top: 10px; overflow: hidden; }
.rv2-mini__bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--rv2-brand-700), var(--rv2-brand)); }
.rv2-mini__sub { font-size: 11px; color: var(--rv2-faint); margin-top: 7px; }
.rv2-mini__sub b { color: var(--rv2-brand-700); }

/* ---------- Data table ---------- */
.rv2-table-wrap { overflow-x: auto; margin: 0 -4px; }
.rv2-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rv2-table th {
  text-align: right;
  font-weight: 600;
  color: var(--rv2-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--rv2-hair);
  white-space: nowrap;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.rv2-table th:first-child, .rv2-table td:first-child { text-align: left; }
.rv2-table td { padding: 9px 12px; border-bottom: 1px solid var(--rv2-hair-soft); font-variant-numeric: tabular-nums; color: var(--rv2-ink-soft); white-space: nowrap; }
.rv2-table tr:last-child td { border-bottom: 0; }
.rv2-table tbody tr:hover td { background: #f7faf9; }
.rv2-table .rv2-table__share { display: inline-block; width: 46px; height: 6px; border-radius: 999px; background: var(--rv2-hair-soft); vertical-align: middle; margin-left: 8px; overflow: hidden; }
.rv2-table .rv2-table__share > span { display: block; height: 100%; background: var(--rv2-brand); }

/* ---------- CTA (empty section w/ action) ---------- */
.rv2-cta {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 24px 16px;
  border: 1px dashed var(--rv2-hair);
  border-radius: var(--rv2-radius-sm);
  background: linear-gradient(180deg, #fff, #f5fbf9);
  min-height: 158px;
}
.rv2-cta svg { width: 30px; height: 30px; color: var(--rv2-brand-700); }
.rv2-cta__msg { margin: 0; font-size: 13px; color: var(--rv2-muted); }
.rv2-cta__btn {
  appearance: none; border: 0; font: inherit; cursor: pointer;
  background: var(--rv2-brand); color: #04231b;
  font-weight: 700; font-size: 13px;
  padding: 9px 18px; border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: background .15s, transform .1s;
}
.rv2-cta__btn:hover { background: var(--rv2-brand-600); }
.rv2-cta__btn:active { transform: translateY(1px); }

/* ---------- Empty / loading states ---------- */
.rv2-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--rv2-muted); font-size: 13px; gap: 6px;
  padding: 28px 16px; min-height: 120px;
}
.rv2-empty svg { width: 26px; height: 26px; color: var(--rv2-faint); }
.rv2-skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, #eef1f3 25%, #f6f8f9 37%, #eef1f3 63%);
  background-size: 400% 100%;
  animation: rv2-shimmer 1.3s ease infinite;
}
@keyframes rv2-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* section eyebrow between bands */
.rv2-section-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--rv2-faint);
  margin: 26px 2px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.rv2-section-label::after { content: ""; flex: 1; height: 1px; background: var(--rv2-hair); }

/* entrance animation */
@keyframes rv2-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rv2-anim { animation: rv2-fade-up .5s cubic-bezier(.22,.61,.36,1) both; }

/* ---------- Responsive ---------- */
@media (max-width: 1040px) {
  .rv2-row--hero, .rv2-row--2, .rv2-row--3, .rv2-row--attr { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .rv2-wrap { padding: 20px 16px 0; }
  .rv2-title { font-size: 24px; }
  .rv2-topbar { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .rv2-anim, .rv2-skeleton { animation: none; }
  .rv2 { background: var(--rv2-ground); }
}
