/* ════════════════════════════════════════════════════════════════════
   SHARED PERFORMANCE DASHBOARD — PerfDashboard.astro
   Forked from the styles.css .dash-* block (legacy /reporting mock) and
   made self-contained: loaded by /reporting (Control Room) and the
   homepage proof embed, neither of which may depend on styles.css.
   Animation start-states are applied by /js/mx/dashboard.js only —
   with no JS this renders the complete settled dashboard.
   ════════════════════════════════════════════════════════════════════ */

.dash-frame {
  /* self-contained tokens (machine.css look, styles.css independence) */
  --dash-white: #ffffff;
  --dash-green: #22C55E;
  --dash-cyan: #00D4FF;
  --dash-blue: #0088FF;
  --dash-font: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --dash-ease: cubic-bezier(0.22, 1, 0.36, 1);

  max-width: 1180px;
  margin: 0 auto;
  background: linear-gradient(180deg, #0F2238 0%, #122740 100%);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(15,34,56,0.25), 0 4px 16px rgba(15,34,56,0.15);
  color: var(--dash-white);
  font-family: var(--dash-font);
}

/* Toolbar */
.dash-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid rgba(0,212,255,0.1);
  flex-wrap: wrap;
}
.dash-toolbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dash-toolbar-left h3 {
  font-size: 18px; font-weight: 700; color: var(--dash-white);
  margin: 0; letter-spacing: -0.01em;
}
.dash-period { font-size: 13px; color: rgba(255,255,255,0.78); font-weight: 500; }
.dash-period-meta { font-size: 12px; color: rgba(255,255,255,0.6); font-weight: 500; letter-spacing: 0.02em; }
.dash-live {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--dash-green);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.dash-live-pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--dash-green);
  box-shadow: 0 0 0 0 rgba(34,197,94,0.7);
  animation: dash-pulse 2s infinite;
}
@keyframes dash-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.6); }
  70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* Tabs */
.dash-tabs {
  display: flex; gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(0,212,255,0.1);
  overflow-x: auto;
  scrollbar-width: none;
}
.dash-tabs::-webkit-scrollbar { display: none; }
.dash-tab {
  position: relative;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.55);
  font-family: inherit;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s;
}
.dash-tab:hover { color: rgba(255,255,255,0.85); }
.dash-tab.active { color: var(--dash-white); }
.dash-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 16px; right: 16px; height: 2px;
  background: linear-gradient(90deg, var(--dash-blue), var(--dash-cyan));
  border-radius: 1px 1px 0 0;
}

/* Panes */
.dash-panes { padding: 24px 28px 28px; }
.dash-pane { display: none; }
.dash-pane.active { display: block; animation: dash-fade-in 0.35s ease; }
@keyframes dash-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* KPI grid */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.dash-kpi-grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px) { .dash-kpi-grid, .dash-kpi-grid--4 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 540px) { .dash-kpi-grid, .dash-kpi-grid--4 { grid-template-columns: 1fr 1fr; } }

.dash-kpi-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 10px;
  padding: 14px 14px 12px;
  transition: border-color 0.2s, background 0.2s;
}
.dash-kpi-card:hover { border-color: rgba(0,212,255,0.4); background: rgba(255,255,255,0.08); }
.dash-kpi-card-label {
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.78);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.dash-kpi-card-value {
  font-size: 24px; font-weight: 800; color: var(--dash-white);
  line-height: 1.1; margin-bottom: 4px; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.dash-kpi-card-meta { font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.72); }

/* 2-col panel rows */
.dash-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 820px) { .dash-row { grid-template-columns: 1fr; } }

.dash-panel {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(0,212,255,0.1);
  border-radius: 10px;
  padding: 18px;
  min-width: 0;
}
.dash-panel-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 14px;
}
.dash-panel-title { font-size: 13px; font-weight: 600; color: var(--dash-white); }
.dash-panel-meta { font-size: 11px; color: rgba(255,255,255,0.45); }

/* Funnel */
.dash-funnel { display: flex; flex-direction: column; gap: 10px; }
.dash-funnel-bar {
  position: relative;
  height: 36px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(0,136,255,0.3), rgba(0,212,255,0.3));
  border: 1px solid rgba(0,212,255,0.2);
  display: flex; align-items: center;
  padding: 0 14px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: width 0.9s var(--dash-ease);
}
.dash-funnel-bar.b2 { background: linear-gradient(90deg, rgba(0,136,255,0.4), rgba(0,212,255,0.4)); }
.dash-funnel-bar.b3 { background: linear-gradient(90deg, rgba(34,197,94,0.4), rgba(34,197,94,0.5)); border-color: rgba(34,197,94,0.3); }
.dash-funnel-rate { text-align: center; font-size: 11px; color: rgba(255,255,255,0.5); margin-top: -4px; }

/* Donut */
.dash-donut-wrap { display: flex; align-items: center; gap: 18px; }
.dash-donut { width: 120px; height: 120px; flex-shrink: 0; position: relative; }
.dash-donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dash-donut svg circle[data-arc] { transition: stroke-dasharray 1s var(--dash-ease); }
.dash-donut-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.dash-donut-label .v { font-size: 22px; font-weight: 700; color: var(--dash-white); line-height: 1; }
.dash-donut-label .l { font-size: 10px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.dash-donut-legend { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.dash-donut-legend-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: rgba(255,255,255,0.85); }
.dash-donut-legend-item .swatch { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; margin-right: auto; }
.dash-donut-legend-item .name { color: rgba(255,255,255,0.7); margin-right: auto; }

/* Area / bar charts */
.dash-chart { height: 140px; }
.dash-chart svg { width: 100%; height: 100%; display: block; }
.dash-chart[data-chart] rect { transform-box: fill-box; transform-origin: bottom; }
.mx-js .dash-chart.dash-anim rect { animation: dash-rise 0.7s var(--dash-ease) backwards; }
.mx-js .dash-chart.dash-anim rect:nth-child(2n) { animation-delay: 0.08s; }
.mx-js .dash-chart.dash-anim rect:nth-child(3n) { animation-delay: 0.16s; }
@keyframes dash-rise {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

/* Stacked mini-panels */
.dash-stack { display: grid; grid-template-rows: 1fr 1fr; gap: 16px; min-width: 0; }
.dash-stack .dash-chart { height: 100px; }

.dash-axis {
  display: flex; justify-content: space-between;
  font-size: 10px; color: rgba(255,255,255,0.4);
  margin-top: 6px; padding: 0 4px;
}
.dash-axis.dash-axis-7 > span { flex: 1; text-align: center; }

/* Table */
.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table th {
  text-align: left; padding: 10px 12px;
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.5);
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(0,212,255,0.1);
}
.dash-table td { padding: 12px; color: rgba(255,255,255,0.85); border-bottom: 1px solid rgba(255,255,255,0.04); }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table .dash-pill { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.dash-pill.google { background: rgba(66,133,244,0.18); color: #79a7f5; }
.dash-pill.meta { background: rgba(0,119,255,0.18); color: #5fa1ff; }
.dash-pill.lsa { background: rgba(34,197,94,0.18); color: #6ed897; }
.dash-pill.shopping { background: rgba(244,128,36,0.18); color: #f4a04a; }
.dash-table-numeric { text-align: right; font-variant-numeric: tabular-nums; color: var(--dash-white); font-weight: 500; }
.dash-qs { font-weight: 600; }
.dash-qs--good { color: var(--dash-green); }
.dash-qs--ok { color: #facc15; }

/* Channel bars */
.dash-channel-bars { display: flex; flex-direction: column; gap: 12px; }
.dash-channel-row { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.dash-channel-row .lbl { width: 90px; color: rgba(255,255,255,0.6); }
.dash-channel-row .val { width: 60px; text-align: right; color: var(--dash-white); font-weight: 600; }
.dash-channel-bg { flex: 1; height: 8px; background: rgba(255,255,255,0.06); border-radius: 4px; overflow: hidden; }
.dash-channel-fill { height: 100%; border-radius: 4px; transition: width 0.9s var(--dash-ease); }

/* Notes / footnotes */
.dash-note { font-size: 13px; line-height: 1.6; color: rgba(255,255,255,0.7); }
.dash-footnote {
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid rgba(0,212,255,0.08);
  font-size: 12px; color: rgba(255,255,255,0.6); line-height: 1.5;
}
.dash-footnote strong { color: var(--dash-white); }

/* Compact variant (homepage embed) */
.dash-frame--compact .dash-panes { padding: 18px 20px 22px; }
.dash-frame--compact .dash-kpi-card-value { font-size: 20px; }
.dash-frame--compact .dash-toolbar { padding: 16px 20px; }

@media (max-width: 700px) {
  .dash-toolbar { padding: 16px 18px; }
  .dash-panes { padding: 18px 16px 20px; }
  .dash-kpi-card-value { font-size: 18px; }
}

/* Reduced motion: everything lands settled instantly */
@media (prefers-reduced-motion: reduce) {
  .dash-frame *, .dash-frame *::before, .dash-frame *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
