/* ============================================================
   DASHBOARD VIEW  (v2 only)
   Loaded ON TOP of app.css. The Dashboard tab drops the document
   viewer chrome entirely and renders a REAL flat dashboard:
   KPI tiles, a pipeline funnel, cash-collected bar chart, and two
   doughnut charts — all themed via --brand / --accent vars.
   ============================================================ */

/* ---- left-panel tab strip (Documents ⇄ Dashboard) ---- */
.preview-tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.preview-tab {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line); color: var(--muted);
  border-radius: var(--radius-pill); padding: 9px 17px; font: inherit; font-size: 14px;
  font-weight: 600;
  transition: border-color var(--dur-base) var(--ease-standard),
              color var(--dur-base) var(--ease-standard),
              background var(--dur-base) var(--ease-standard);
}
.preview-tab .icon { width: 17px; height: 17px; }
.preview-tab:hover { color: var(--ink); border-color: var(--accent-line); }
.preview-tab.on { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); }
.preview-tab .tab-badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--accent-fg); background: var(--accent); border-radius: var(--radius-pill);
  padding: 2px 7px; margin-left: 2px;
}

/* the two stacked panels toggle by [hidden] */
.view-panel[hidden] { display: none !important; }

/* dashboard is tall — don't pin the left column while it's showing */
.results-left.view-dashboard { position: static; top: auto; }

/* ============================================================
   FLAT DASHBOARD SHELL
   ============================================================ */
.dash-flat-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.dfh-title { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.db-live {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700;
  color: var(--accent-ink); background: var(--accent-wash); border: 1px solid var(--accent-line);
  border-radius: var(--radius-pill); padding: 6px 13px;
}
.db-live .db-pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent);
  animation: db-pulse 1.8s var(--ease-standard) infinite;
}
@keyframes db-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  100% { box-shadow: 0 0 0 8px transparent; }
}
.dash-foot {
  display: flex; align-items: flex-start; gap: 10px; margin: 18px 2px 0;
  color: var(--muted); font-size: 13px; line-height: 1.5; text-wrap: pretty;
}
.dash-foot .icon { width: 17px; height: 17px; color: var(--accent-ink); margin-top: 1px; flex: 0 0 auto; }
.dash-foot b { color: var(--ink); font-weight: 600; }

/* ---- grid of dashboard cards ---- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dcard {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 20px;
}
.dcard-full { grid-column: 1 / -1; }
.dcard-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.dcard-head .icon { width: 15px; height: 15px; color: var(--accent-ink); flex: 0 0 auto; }
.dcard-head .dch-hint {
  margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500;
  font-size: 11.5px; color: var(--muted);
}

/* ============================================================
   KPI STRIP
   ============================================================ */
.dash-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.dash-kpi {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); padding: 16px 17px;
}
.dash-kpi .k-label { font-size: 11.5px; color: var(--muted); font-weight: 500; margin-bottom: 9px;
  line-height: 1.3; min-height: 30px; }
.dash-kpi .k-val { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); line-height: 1; }
.dash-kpi .k-delta {
  display: inline-flex; align-items: center; gap: 3px; margin-top: 9px; white-space: nowrap;
  font-size: 11.5px; font-weight: 700; color: var(--accent-ink);
}
.dash-kpi .k-delta .icon { width: 13px; height: 13px; }

/* ============================================================
   PIPELINE FUNNEL  (intake → converted)
   ============================================================ */
.dash-funnel { display: flex; flex-direction: column; gap: 11px; }
.fn-row { display: grid; gap: 6px; }
.fn-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.fn-stage { font-size: 13.5px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.fn-nums { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.fn-nums b { color: var(--ink); font-weight: 700; }
/* centered bars → funnel silhouette */
.fn-track { height: 30px; display: flex; justify-content: center; }
.fn-bar {
  height: 100%; border-radius: 6px; min-width: 8px;
  background: color-mix(in srgb, var(--accent) 26%, #fff);
  border: 1px solid var(--accent-line);
  transition: width .6s var(--ease-standard);
}
.fn-row.leak .fn-bar { background: var(--accent); border-color: var(--accent); }
.fn-row.leak .fn-stage { color: var(--accent-ink); }
.fn-flag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .02em; text-transform: uppercase; color: var(--accent-fg);
  background: var(--accent); border-radius: var(--radius-pill); padding: 2px 9px;
  white-space: nowrap; flex: 0 0 auto;
}
.fn-flag .icon { width: 12px; height: 12px; }
.leak-note {
  display: grid; grid-template-columns: 18px 1fr; gap: 11px; align-items: start;
  background: var(--accent-wash); border: 1px solid var(--accent-line);
  border-radius: var(--radius-md); padding: 13px 15px; font-size: 13px; color: var(--ink);
  line-height: 1.5; margin-top: 16px; text-wrap: pretty;
}
.leak-note .icon { width: 17px; height: 17px; color: var(--accent-ink); margin-top: 1px; }

/* ============================================================
   CASH COLLECTED  (bar chart)
   ============================================================ */
.cash-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.cash-total { font-size: 38px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; color: var(--ink); }
.cash-delta { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px;
  font-size: 12.5px; font-weight: 700; color: var(--accent-ink); }
.cash-delta .icon { width: 14px; height: 14px; }
.cash-out { text-align: right; }
.cash-out-v { font-size: 19px; font-weight: 700; color: var(--ink); line-height: 1; }
.cash-out-l { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.cash-bars { display: flex; align-items: flex-end; gap: 12px; height: 150px; }
.cash-col { flex: 1; height: 100%; display: flex; flex-direction: column; }
.cash-bar-area { flex: 1; display: flex; align-items: flex-end; min-height: 0; }
.cash-bar {
  width: 100%; border-radius: 7px 7px 0 0; min-height: 4px;
  background: color-mix(in srgb, var(--accent) 30%, #fff);
  border: 1px solid var(--accent-line); border-bottom: 0;
  transition: height .6s var(--ease-standard);
}
.cash-col.cur .cash-bar { background: var(--accent); border-color: var(--accent); }
.cash-m { height: 20px; line-height: 20px; text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.cash-col.cur .cash-m { color: var(--ink); font-weight: 700; }

/* ============================================================
   DOUGHNUT CHARTS
   ============================================================ */
.dn-body { display: grid; grid-template-columns: 122px 1fr; gap: 18px; align-items: center; }
.dn-chart { position: relative; width: 122px; height: 122px; }
.donut-svg { width: 122px; height: 122px; transform: rotate(0deg); display: block; }
.dn-seg { transition: stroke-dasharray .6s var(--ease-standard); }
.dn-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.dn-c-val { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); line-height: 1; }
.dn-c-lab { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.dn-legend { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dn-li { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.dn-sw { width: 11px; height: 11px; border-radius: 3px; }
.dn-name { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dn-pct { font-weight: 700; color: var(--ink); }

/* ============================================================
   ONBOARDING PHASE STRIP
   ============================================================ */
.onb-caption { font-size: 12.5px; color: var(--muted); margin: 0 0 18px; }
.onb-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.onb-phase { position: relative; padding: 0 14px; text-align: center; }
.onb-phase:first-child { padding-left: 0; }
.onb-phase:last-child { padding-right: 0; }
.onb-node {
  width: 42px; height: 42px; border-radius: 50%; margin: 0 auto 11px; position: relative; z-index: 1;
  display: grid; place-items: center; background: var(--accent-wash);
  border: 2px solid var(--accent-line); color: var(--accent-ink); font-size: 16px; font-weight: 800;
}
.onb-phase.filled .onb-node { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.onb-phase::before {
  content: ""; position: absolute; top: 21px; left: -50%; width: 100%; height: 2px;
  background: var(--accent-line); z-index: 0;
}
.onb-phase:first-child::before { display: none; }
.onb-label { font-size: 12px; color: var(--ink); font-weight: 600; line-height: 1.3; text-wrap: balance; }
.onb-count { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ============================================================
   BIGGER-PICTURE  LEAD-IN TILE  (flips left panel to dashboard)
   ============================================================ */
.bp-dash-card {
  width: 100%; text-align: left; cursor: pointer; display: grid;
  grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  background: var(--brand); color: var(--brand-fg); border: 0;
  border-radius: var(--radius-md); padding: 16px 18px; margin: 16px 0 4px;
  transition: transform var(--dur-fast) var(--ease-standard), box-shadow var(--dur-base) var(--ease-standard);
}
.bp-dash-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }
.bp-dash-ic {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-fg); flex: 0 0 auto;
}
.bp-dash-ic .icon { width: 22px; height: 22px; }
.bp-dash-text { min-width: 0; }
.bp-dash-text .bp-dash-k {
  display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--brand-fg) 66%, var(--accent)); margin-bottom: 4px;
}
.bp-dash-text .bp-dash-t { display: block; font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.bp-dash-text .bp-dash-s { display: block; font-size: 12.5px; color: color-mix(in srgb, var(--brand-fg) 74%, transparent); margin-top: 3px; text-wrap: pretty; }
.bp-dash-go {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  background: color-mix(in srgb, var(--brand-fg) 14%, transparent);
  display: grid; place-items: center; color: var(--brand-fg);
  transition: background var(--dur-base) var(--ease-standard);
}
.bp-dash-card:hover .bp-dash-go { background: var(--accent); color: var(--accent-fg); }
.bp-dash-go .icon { width: 17px; height: 17px; }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .dash-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 940px) {
  .results-left.view-dashboard { position: static; }
}
@media (max-width: 680px) {
  .preview-tabs { flex-wrap: wrap; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-kpis { grid-template-columns: 1fr 1fr; }
  .dn-body { grid-template-columns: 1fr; justify-items: center; gap: 14px; }
  .dn-legend { width: 100%; max-width: 260px; }
  .onb-strip { grid-template-columns: 1fr 1fr; gap: 20px 0; }
  .onb-phase:nth-child(odd)::before { display: none; }
  .bp-dash-card { grid-template-columns: auto 1fr; }
  .bp-dash-go { display: none; }
  .cash-bars { gap: 7px; }
}
