/* Pyze Execution Intelligence — Custom Styles */

/* ── Minimal Reset (replaces Tailwind preflight dependency) ── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

/* Headings: remove default user-agent margins so layout is controlled
   by component CSS (matches what Tailwind preflight does) */
h1, h2, h3, h4, h5, h6, p {
  margin: 0;
}

/* Buttons: neutralize user-agent styles (matches Tailwind preflight) */
button {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  line-height: inherit;
}

/* Inputs inherit fonts (matches Tailwind preflight) */
input, textarea, select {
  font: inherit;
  color: inherit;
}

/* Sensible default link behavior */
a { color: inherit; text-decoration: none; }

table { border-collapse: collapse; border-spacing: 0; }

img, svg { display: block; max-width: 100%; }

/* Navigation lists: remove bullets (sidebar, in-page nav) — content
   lists keep their bullets via user-agent defaults */
nav ul, nav ol,
.sidebar ul, .sidebar ol,
.findings-list,
.agent-grid,
.kpi-grid {
  list-style: none;
  margin: 0;
  padding: 0;
}

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #334155;
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Agent accent colors */
  --color-rework: #ef4444;
  --color-cycle: #3b82f6;
  --color-handling: #8b5cf6;
  --color-automation: #f59e0b;
  --color-ai-opp: #10b981;
  --color-ai-eff: #06b6d4;
  --color-sop-improvements: #84cc16;
  --color-users: #ec4899;

  /* Impact tiers */
  --impact-high: #dc2626;
  --impact-medium: #d97706;
  --impact-low: #2563eb;

  /* Savings */
  --savings-color: #059669;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f8fafc;
}

.sidebar-logo-img {
  display: block;
  height: 40px;
  width: auto;
  max-width: 200px;
  margin-bottom: 2px;
}

.sidebar-logo .subtitle {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

.sidebar-section {
  padding: 16px 0 8px;
}

.sidebar-section-label {
  padding: 0 20px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
  margin-bottom: 8px;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
  color: #e2e8f0;
  background: var(--sidebar-hover);
}

.sidebar-nav li a.active {
  color: #f8fafc;
  background: var(--sidebar-active);
  border-left-color: #3b82f6;
}

.sidebar-nav li a .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.sidebar-nav li a .nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.1);
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

/* Agent dot indicators */
.agent-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 32px 40px;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.page-header .page-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin: 0;
}

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.kpi-card[data-accent="savings"]::before { background: var(--savings-color); }
.kpi-card[data-accent="rework"]::before { background: var(--color-rework); }
.kpi-card[data-accent="cycle"]::before { background: var(--color-cycle); }
.kpi-card[data-accent="handling"]::before { background: var(--color-handling); }
.kpi-card[data-accent="automation"]::before { background: var(--color-automation); }
.kpi-card[data-accent="ai-opp"]::before { background: var(--color-ai-opp); }
.kpi-card[data-accent="ai-eff"]::before { background: var(--color-ai-eff); }
.kpi-card[data-accent="users"]::before { background: var(--color-users); }
.kpi-card[data-accent="primary"]::before { background: #3b82f6; }

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-value.savings { color: var(--savings-color); }

.kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Agent Cards ── */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.agent-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.agent-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.agent-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.agent-card-name {
  font-size: 16px;
  font-weight: 600;
}

.agent-card-badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: #f0fdf4;
  color: #059669;
}

.agent-card-metric {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.agent-card-savings {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.agent-card-savings .amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--savings-color);
}

.agent-card-savings .unit {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Finding Cards ── */
.findings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.finding-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
  display: block;
}

.finding-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.finding-card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.finding-card-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.finding-card-metrics {
  display: flex;
  gap: 20px;
  flex-shrink: 0;
}

.finding-metric {
  text-align: right;
}

.finding-metric .value {
  font-size: 18px;
  font-weight: 700;
}

.finding-metric .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.finding-card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Impact Badge ── */
.impact-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
}

.impact-badge.high {
  background: #fef2f2;
  color: var(--impact-high);
}

.impact-badge.medium {
  background: #fffbeb;
  color: var(--impact-medium);
}

.impact-badge.low {
  background: #eff6ff;
  color: var(--impact-low);
}

/* ── Remediation Type Badge ── */
.remediation-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
}

/* ── Chart Container ── */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.chart-container h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text-primary);
}

.chart-container .chart-wrapper {
  position: relative;
  height: 300px;
}

.chart-source {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ── Evidence Section ── */
.evidence-section {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.evidence-section h3 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 16px;
}

/* ── Alert Callouts ── */
.callout {
  border-radius: 8px;
  padding: 16px 20px;
  border-left: 4px solid;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.6;
}

.callout-info {
  border-left-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
}

.callout-success {
  border-left-color: #059669;
  background: #f0fdf4;
  color: #065f46;
}

.callout-warning {
  border-left-color: #d97706;
  background: #fffbeb;
  color: #92400e;
}

.callout-savings {
  border-left-color: #059669;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  color: #065f46;
}

.callout strong {
  display: block;
  margin-bottom: 4px;
}

/* ── Savings Opportunity Box ── */
.savings-box {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.savings-box h3 {
  color: #059669;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.savings-box .caveat {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 16px;
}

.savings-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.savings-metric-card {
  background: rgba(255,255,255,0.7);
  border-radius: 8px;
  padding: 16px;
}

.savings-metric-card .metric-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.savings-metric-card .metric-value {
  font-size: 24px;
  font-weight: 700;
}

.savings-metric-card .metric-detail {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

/* ── Data Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: #f8fafc;
}

.data-table tr[onclick]:hover td {
  background: #eff6ff;
}

.data-table tr[onclick]:hover td:first-child a {
  color: #1d4ed8 !important;
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: #3b82f6;
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.breadcrumb .sep { color: #cbd5e1; }

/* ── Floating Chat Widget ── */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  z-index: 200;
  transition: all 0.2s;
}

.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(37,99,235,0.5);
}

.chat-fab-tooltip {
  position: fixed;
  bottom: 88px;
  right: 24px;
  background: var(--sidebar-bg);
  color: #e2e8f0;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 200;
}

.chat-fab:hover + .chat-fab-tooltip { opacity: 1; }

/* ── Finding Type Header (Opportunity vs Benchmark) ── */
.finding-type-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.finding-type-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.finding-type-label::before {
  content: '';
  width: 6px;
  height: 14px;
  border-radius: 2px;
  display: inline-block;
}

.finding-type-label.opportunity {
  color: #059669;
}

.finding-type-label.opportunity::before {
  background: #059669;
}

.finding-type-label.benchmark {
  color: #0891b2;
}

.finding-type-label.benchmark::before {
  background: #0891b2;
}

.finding-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.finding-meta-row .left-group {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Collapsible Methodology Sections ── */
details.method-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

details.method-section[open] {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

details.method-section > summary {
  padding: 18px 24px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 16px;
  user-select: none;
}

details.method-section > summary::-webkit-details-marker {
  display: none;
}

details.method-section > summary::after {
  content: '\25BC';
  margin-left: auto;
  color: var(--text-muted);
  font-size: 11px;
  transition: transform 0.2s;
  flex-shrink: 0;
}

details.method-section[open] > summary::after {
  transform: rotate(180deg);
}

details.method-section > summary:hover {
  background: #f8fafc;
}

.method-summary-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.method-summary-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.method-summary-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.method-body {
  padding: 8px 24px 24px;
  border-top: 1px solid var(--border-color);
}

.method-body h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 20px 0 8px;
}

.method-body h4:first-child {
  margin-top: 16px;
}

.method-body p, .method-body li {
  color: var(--text-secondary);
  line-height: 1.7;
}

.method-example {
  background: #f8fafc;
  border-left: 3px solid var(--color-cycle);
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.method-example strong { color: var(--text-primary); }

.method-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.method-signal {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
}

.method-toc {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
}

.method-toc h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.method-toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.method-toc a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}

.method-toc a:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

/* ── Validation Questions ── */
.validation-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.validation-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.validation-card-header h3 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0;
  flex: 1;
}

.validation-progress-bar {
  height: 6px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0 16px;
}

.validation-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #22c55e);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.validation-progress-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.validation-progress-label strong {
  color: var(--text-primary);
  font-weight: 700;
}

.validation-intro {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
  border-radius: 0 6px 6px 0;
}

.validation-q {
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  margin-top: 20px;
}

.validation-q:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.validation-q-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.validation-q-number {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #eff6ff;
  color: #1d4ed8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.validation-q.answered .validation-q-number {
  background: #dcfce7;
  color: #15803d;
}

.validation-q-text {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-primary);
  flex: 1;
}

.validation-q-rationale {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  margin: 6px 0 12px 38px;
  line-height: 1.5;
}

.validation-q-rationale::before {
  content: "Why we ask: ";
  font-weight: 600;
  color: var(--text-secondary);
  font-style: normal;
}

.validation-q-answer {
  margin-left: 38px;
}

.validation-q-textarea {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  resize: vertical;
  transition: border-color 0.15s;
}

.validation-q-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.validation-q-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 12px;
  flex-wrap: wrap;
}

.validation-q-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.validation-q-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #22c55e;
}

.validation-q-share {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
}

.validation-q-share input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: #3b82f6;
}

.validation-q-share:hover {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

/* Counter badge on finding cards */
.validation-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.validation-badge.complete {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}

/* ── Process Map — Level 1 flow nodes ── */
.process-map {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.process-map-flow {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: min-content;
  padding: 8px 4px 12px;
}

.process-node {
  flex: 0 0 auto;
  background: white;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 20px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  min-width: 180px;
  max-width: 220px;
  transition: all 0.2s;
  position: relative;
}

.process-node:hover {
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
  transform: translateY(-2px);
}

.process-node.active {
  border-color: #6366f1;
  background: #eef2ff;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.25);
}

.process-node-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eef2ff;
  color: #4338ca;
  font-size: 11px;
  font-weight: 700;
  margin-right: 8px;
}

.process-node.active .process-node-num {
  background: #4338ca;
  color: white;
}

.process-node-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 6px;
}

.process-node-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.process-arrow {
  flex: 0 0 auto;
  width: 24px;
  height: 2px;
  background: #cbd5e1;
  position: relative;
  margin: 0 -2px;
}

.process-arrow::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -4px;
  border-left: 8px solid #cbd5e1;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

/* ── Level 2 — App Journey panel ── */
.level2-panel {
  display: none;
  background: #fafafa;
  border: 1px solid var(--border-color);
  border-top: 3px solid #6366f1;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
  animation: slideDown 0.2s ease-out;
}

.level2-panel.open {
  display: block;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.level2-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.level2-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4338ca;
  margin-bottom: 4px;
}

.level2-subtitle {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.level2-close {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.level2-close:hover { background: white; color: var(--text-primary); }

.app-journey-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.app-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  font-family: inherit;
}

.app-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.app-card.active {
  border-color: #6366f1;
  background: #eef2ff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.app-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.app-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.tier-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

.tier-badge.DOM      { background: #f0fdf4; color: #059669; border: 1px solid #bbf7d0; }
.tier-badge.Document { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.tier-badge.Message  { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.tier-badge.App      { background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; }

.app-card-metrics {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.app-card-metrics strong { color: var(--text-primary); font-weight: 600; }

/* ── Level 3 — Per-app detail panel ── */
.level3-panel {
  display: none;
  margin-top: 14px;
  background: white;
  border: 1px solid var(--border-color);
  border-left: 3px solid #6366f1;
  border-radius: 8px;
  padding: 16px 20px;
  animation: slideDown 0.2s ease-out;
}

.level3-panel.open { display: block; }

.level3-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.level3-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4338ca;
  margin-bottom: 2px;
}

.level3-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.level3-tier-context {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 12px;
  line-height: 1.5;
}

.level3-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.level3-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #fafafa;
  border: 1px solid #f1f5f9;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
}

.level3-item .event-type {
  background: #e0e7ff;
  color: #3730a3;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  min-width: 70px;
  text-align: center;
}

.level3-item .tag {
  color: #6366f1;
  font-weight: 600;
  min-width: 56px;
}

.level3-item .text {
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level3-item .freq {
  color: var(--text-muted);
  font-size: 11px;
}

.level3-note {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: #92400e;
  line-height: 1.5;
  margin-top: 6px;
}

/* ── Opportunity Lifecycle ── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid;
}

.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}

.status-pill.surfaced {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.status-pill.accepted {
  background: #faf5ff;
  color: #7e22ce;
  border-color: #e9d5ff;
}

.status-pill.remediating {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.status-pill.remediating::before {
  animation: status-pulse 1.5s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.status-pill.remediated {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.status-pill.declined {
  background: #f8fafc;
  color: #64748b;
  border-color: #e2e8f0;
}

/* Lifecycle progress bar */
.lifecycle-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.lifecycle-card h3 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.lifecycle-progress {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-bottom: 20px;
  position: relative;
}

.lifecycle-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 0 8px;
}

.lifecycle-step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: white;
  border: 2px solid #e2e8f0;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  z-index: 2;
  margin-bottom: 8px;
  transition: all 0.3s;
}

.lifecycle-step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  transition: color 0.3s;
}

/* Connector lines between steps */
.lifecycle-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 15px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: #e2e8f0;
  z-index: 1;
  transition: background 0.3s;
}

/* Completed step */
.lifecycle-step.completed .lifecycle-step-dot {
  background: #22c55e;
  border-color: #22c55e;
  color: white;
}
.lifecycle-step.completed .lifecycle-step-label {
  color: #15803d;
}
.lifecycle-step.completed::after {
  background: #22c55e;
}

/* Current / active step */
.lifecycle-step.active .lifecycle-step-dot {
  background: white;
  border-color: var(--step-color, #3b82f6);
  color: var(--step-color, #3b82f6);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}
.lifecycle-step.active .lifecycle-step-label {
  color: var(--step-color, #3b82f6);
}

/* Declined state overrides */
.lifecycle-progress.declined .lifecycle-step-dot {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #94a3b8;
}
.lifecycle-progress.declined::after {
  background: #e2e8f0;
}

/* Action buttons */
.lifecycle-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.lifecycle-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lifecycle-btn-primary {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.lifecycle-btn-primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.lifecycle-btn-secondary {
  background: white;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.lifecycle-btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: var(--text-primary);
}

.lifecycle-btn-success {
  background: #22c55e;
  color: white;
  border-color: #22c55e;
}

.lifecycle-btn-success:hover {
  background: #16a34a;
  border-color: #16a34a;
}

.lifecycle-btn-danger {
  background: white;
  color: #b91c1c;
  border-color: #fca5a5;
}

.lifecycle-btn-danger:hover {
  background: #fef2f2;
}

.lifecycle-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  font-style: italic;
}

/* Value realization strip (shown on Remediated) */
.value-realization-strip {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.value-realization-strip .vr-spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #bbf7d0;
  border-top-color: #15803d;
  border-radius: 50%;
  animation: calibrating-spin 1.2s linear infinite;
  flex-shrink: 0;
}

.value-realization-strip .vr-text {
  flex: 1;
  font-size: 13px;
  color: #15803d;
  line-height: 1.5;
}

.value-realization-strip .vr-text strong {
  display: block;
  margin-bottom: 2px;
  color: #166534;
}

/* Lifecycle summary counters (agent overview + dashboard) */
.lifecycle-summary {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.lifecycle-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.lifecycle-counter .count {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lifecycle-counter .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lifecycle-counter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ── Finding States: Benchmark & Calibrating ── */
.benchmark-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  background: #ecfeff;
  color: #0e7490;
  border: 1px solid #a5f3fc;
}

.benchmark-metric {
  text-align: right;
}

.benchmark-metric .value {
  font-size: 18px;
  font-weight: 700;
  color: #0891b2;
}

.benchmark-metric .label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.3;
  max-width: 140px;
}

.calibrating-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.calibrating-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: calibrating-spin 1s linear infinite;
  flex-shrink: 0;
}

@keyframes calibrating-spin {
  to { transform: rotate(360deg); }
}

.calibrating-text {
  font-weight: 500;
}

.calibrating-text .primary {
  color: var(--text-secondary);
}

/* Full-width calibrating banner on finding detail */
.calibrating-banner {
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.calibrating-banner .calibrating-spinner {
  width: 20px;
  height: 20px;
  border-width: 3px;
}

.calibrating-banner-text strong {
  display: block;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.calibrating-banner-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Benchmark banner on finding detail */
.benchmark-banner {
  background: linear-gradient(135deg, #ecfeff 0%, #e0f2fe 100%);
  border: 1px solid #a5f3fc;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.benchmark-banner-metric {
  flex-shrink: 0;
  text-align: center;
  padding-right: 24px;
  border-right: 1px solid #a5f3fc;
}

.benchmark-banner-metric .value {
  font-size: 36px;
  font-weight: 700;
  color: #0891b2;
  line-height: 1;
}

.benchmark-banner-metric .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0e7490;
  margin-top: 4px;
  font-weight: 600;
}

.benchmark-banner-text strong {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.benchmark-banner-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Automation Readiness Score ── */
.readiness-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.readiness-card h3 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.readiness-layout {
  display: flex;
  align-items: flex-start;
  gap: 32px;
}

.readiness-gauge {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(
    var(--gauge-color) calc(var(--gauge-pct) * 1%),
    #e2e8f0 calc(var(--gauge-pct) * 1%)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.readiness-gauge-inner {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.readiness-gauge-score {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.readiness-gauge-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 4px;
}

.readiness-factors {
  flex: 1;
  min-width: 0;
}

.readiness-factor {
  margin-bottom: 12px;
}

.readiness-factor:last-child {
  margin-bottom: 0;
}

.readiness-factor-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.readiness-factor-name {
  font-weight: 600;
  color: var(--text-primary);
}

.readiness-factor-detail {
  color: var(--text-muted);
}

.readiness-factor-track {
  background: #e2e8f0;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}

.readiness-factor-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main-content { margin-left: 220px; padding: 24px; }
  :root { --sidebar-width: 220px; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .agent-grid { grid-template-columns: 1fr; }
}
