/* ============================================================
   BI AI Generator — prompt card inside Workbench
   ============================================================ */
.bi-ai-card {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid rgba(99, 102, 241, 0.18);
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.04));
  border-radius: 12px;
}
.bi-ai-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.bi-ai-title { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; letter-spacing: -0.01em; color: #4f46e5; }
.bi-ai-hint { font-size: 12px; color: #64748b; }
.bi-ai-textarea {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px;
  font-family: inherit; font-size: 13px; line-height: 1.5;
  color: #0f172a; background: #fff;
  border: 1px solid rgba(15,23,42,0.10); border-radius: 8px;
  resize: vertical;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.bi-ai-textarea:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.14); }
.bi-ai-actions { margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bi-ai-status { font-size: 12px; color: #475569; }

.bi-ai-preview { margin-top: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.bi-ai-preview-card { background: #fff; border: 1px solid rgba(15,23,42,0.08); border-radius: 9px; padding: 10px 12px; }
.bi-ai-preview-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.bi-ai-preview-card header strong { font-size: 13px; color: #0f172a; letter-spacing: -0.01em; display: block; line-height: 1.3; }
.bi-ai-preview-desc { margin: 6px 0 0; font-size: 11px; color: #64748b; line-height: 1.45; }
.btn.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ============================================================
   BI Dashboards — professional grid
   ============================================================ */
.bid-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 18px;
  margin-top: 8px;
}
.bid-card {
  position: relative;
  background: #ffffff;
  border: 1px solid rgba(15,23,42,0.06);
  border-radius: 14px;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
  transition: box-shadow 200ms ease, border-color 200ms ease;
}
.bid-card:hover {
  box-shadow: 0 12px 32px -16px rgba(15,23,42,0.18), 0 2px 6px rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.10);
}
.bid-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; }
.bid-card-title-wrap { min-width: 0; flex: 1; }
.bid-card-title { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.015em; color: #0f172a; line-height: 1.3; }
.bid-card-sub { margin: 4px 0 0; font-size: 12px; color: #64748b; line-height: 1.5; }
.bid-card-actions { display: flex; gap: 2px; flex-shrink: 0; }
.bid-icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  color: #64748b; cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.bid-icon-btn:hover { background: rgba(15,23,42,0.04); color: #0f172a; border-color: rgba(15,23,42,0.06); }
.bid-icon-btn.bid-icon-danger:hover { background: rgba(244,63,94,0.08); color: #e11d48; border-color: rgba(244,63,94,0.14); }
.bid-card-body {
  flex: 1; min-height: 240px;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 18px 14px; position: relative;
}
.bid-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  font-size: 10px; color: #94a3b8;
  border-top: 1px solid rgba(15,23,42,0.04);
  background: linear-gradient(to bottom, #fafbfc, #f6f7f9);
  letter-spacing: 0.06em; font-weight: 600; text-transform: uppercase;
}
.bid-meta, .bid-meta-source { display: inline-flex; align-items: center; gap: 6px; }
.bid-type-icon { display: inline-flex; color: #6366f1; }
.bid-type-icon svg { display: block; }
.bid-draft {
  padding: 2px 7px;
  background: rgba(245,158,11,0.12); color: #b45309;
  border-radius: 4px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-top: 4px; display: inline-block;
}

/* SVG base */
.bid-svg { width: 100%; height: 240px; display: block; font-family: inherit; overflow: visible; }

/* Axis & grid */
.bid-grid-line { stroke: rgba(15,23,42,0.05); stroke-width: 1; stroke-dasharray: 2 3; }
.bid-axis-line { stroke: rgba(15,23,42,0.14); stroke-width: 1; }
.bid-axis-label { font-size: 10px; fill: #94a3b8; font-variant-numeric: tabular-nums; font-family: inherit; letter-spacing: 0.01em; }

/* Bar hover */
.bid-bar-g rect { transition: filter 150ms ease; }
.bid-bar-g:hover rect { filter: brightness(1.08) saturate(1.1); }

/* Line */
.bid-line-path { fill: none; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.bid-line-dot { transition: r 150ms ease; }
.bid-line-dot:hover { r: 5; }

/* Pie / Donut */
.bid-pie-wrap { display: flex; align-items: center; gap: 20px; width: 100%; min-height: 200px; }
.bid-pie-chart { position: relative; width: 200px; height: 200px; flex-shrink: 0; }
.bid-pie-svg { width: 100%; height: 100%; display: block; }
.bid-pie-slice { transition: filter 150ms ease; transform-origin: center; cursor: pointer; }
.bid-pie-slice:hover { filter: brightness(1.1) saturate(1.15); }
.bid-pie-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
.bid-pie-total { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: #0f172a; font-variant-numeric: tabular-nums; line-height: 1; }
.bid-pie-total-label { margin-top: 4px; font-size: 9px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.bid-pie-legend {
  list-style: none; padding: 0; margin: 0;
  font-size: 12px; color: #0f172a; flex: 1; min-width: 0;
  max-height: 200px; overflow: auto;
  display: grid; gap: 2px;
}
.bid-pie-legend li {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 6px;
  transition: background 120ms ease;
}
.bid-pie-legend li:hover { background: rgba(15,23,42,0.03); }
.bid-pie-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.bid-pie-label { color: #334155; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bid-pie-value { color: #0f172a; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12px; }
.bid-pie-pct { color: #94a3b8; font-size: 11px; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

/* KPI */
.bid-kpi { text-align: center; padding: 24px 16px; width: 100%; }
.bid-kpi-value {
  font-size: 44px; font-weight: 700;
  letter-spacing: -0.035em; color: #0f172a;
  font-variant-numeric: tabular-nums; line-height: 1;
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.bid-kpi-label { margin-top: 10px; font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }

/* Table */
.bid-table-wrap { width: 100%; max-height: 280px; overflow: auto; border: 1px solid rgba(15,23,42,0.05); border-radius: 8px; }
.bid-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bid-table th {
  padding: 9px 12px; text-align: left; font-weight: 600;
  color: #64748b; background: #f8fafc;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  position: sticky; top: 0; z-index: 1;
  text-transform: uppercase; font-size: 10px; letter-spacing: 0.06em;
}
.bid-table td { padding: 8px 12px; border-bottom: 1px solid rgba(15,23,42,0.04); color: #0f172a; }
.bid-table tbody tr:last-child td { border-bottom: none; }
.bid-table tbody tr:hover { background: rgba(99,102,241,0.03); }
.bid-th-num, .bid-td-num { text-align: right; font-variant-numeric: tabular-nums; }
.bid-num { font-variant-numeric: tabular-nums; }
.bid-muted { color: #94a3b8; }

/* Skeleton */
.bid-skeleton {
  position: relative; width: 100%; height: 200px;
  background: linear-gradient(90deg, #f1f5f9 0%, #f8fafc 50%, #f1f5f9 100%);
  border-radius: 8px; overflow: hidden;
}
.bid-skeleton-shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.6) 50%, transparent 100%);
  animation: bidShimmer 1.6s ease-in-out infinite;
}
@keyframes bidShimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.bid-skel-line { height: 10px; background: #f1f5f9; border-radius: 4px; margin-bottom: 8px; }
.bid-skel-line.w-60 { width: 60%; }
.bid-skel-line.w-40 { width: 40%; }
.bid-card-skel { padding: 16px 18px; min-height: 240px; }

/* Empty & error */
.bid-empty { text-align: center; padding: 48px 24px; color: #64748b; }
.bid-empty-icon { margin: 0 auto 14px; width: 48px; height: 48px; color: #cbd5e1; display: flex; align-items: center; justify-content: center; }
.bid-empty-icon svg { width: 100%; height: 100%; }
.bid-empty-data { padding: 24px; color: #94a3b8; font-size: 13px; text-align: center; }
.bid-error {
  padding: 16px 18px;
  background: rgba(244,63,94,0.06);
  border: 1px solid rgba(244,63,94,0.16);
  border-radius: 8px; color: #be123c;
  font-size: 12px; line-height: 1.5;
  width: 100%; text-align: center;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .bid-card { background: #0f172a; border-color: rgba(255,255,255,0.06); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
  .bid-card:hover { border-color: rgba(255,255,255,0.12); box-shadow: 0 12px 32px -16px rgba(0,0,0,0.5); }
  .bid-card-title { color: #f1f5f9; }
  .bid-card-sub { color: #94a3b8; }
  .bid-card-foot { background: linear-gradient(to bottom, #0b1220, #080e1a); border-top-color: rgba(255,255,255,0.04); color: #64748b; }
  .bid-icon-btn { color: #94a3b8; }
  .bid-icon-btn:hover { background: rgba(255,255,255,0.05); color: #f1f5f9; }
  .bid-grid-line { stroke: rgba(255,255,255,0.06); }
  .bid-axis-line { stroke: rgba(255,255,255,0.12); }
  .bid-axis-label { fill: #64748b; }
  .bid-kpi-value { background: linear-gradient(135deg, #f1f5f9 0%, #94a3b8 100%); -webkit-background-clip: text; background-clip: text; }
  .bid-kpi-label { color: #64748b; }
  .bid-pie-total { color: #f1f5f9; }
  .bid-pie-total-label { color: #64748b; }
  .bid-pie-label { color: #cbd5e1; }
  .bid-pie-value { color: #f1f5f9; }
  .bid-pie-legend li:hover { background: rgba(255,255,255,0.04); }
  .bid-table-wrap { border-color: rgba(255,255,255,0.06); }
  .bid-table th { background: #0b1220; color: #64748b; border-bottom-color: rgba(255,255,255,0.06); }
  .bid-table td { color: #e2e8f0; border-bottom-color: rgba(255,255,255,0.04); }
  .bid-table tbody tr:hover { background: rgba(99,102,241,0.08); }
  .bid-muted { color: #64748b; }
  .bid-skeleton { background: linear-gradient(90deg, #1e293b 0%, #0f172a 50%, #1e293b 100%); }
  .bid-skeleton-shimmer { background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.05) 50%, transparent 100%); }
  .bid-skel-line { background: #1e293b; }
  .bid-empty { color: #64748b; }
  .bid-empty-icon { color: #334155; }
  .bid-empty-data { color: #64748b; }
  .bid-error { background: rgba(244,63,94,0.10); border-color: rgba(244,63,94,0.22); color: #fb7185; }
}

/* ============================================================
   BI Dashboards — grid editável (dentro de .gd-tile)
   ============================================================ */
.bid-top-bar {
  display: flex; justify-content: flex-end; align-items: center;
  padding: 14px 24px 0;
  position: relative;
  z-index: 2;
}
.bid-top-bar .bi-inline-field { color: #e2e8f0; font-size: 12px; }
.bid-top-bar select {
  background: rgba(15,23,42,0.6);
  border: 1px solid rgba(255,255,255,0.08);
  color: #f1f5f9;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  margin-left: 8px;
}
.bid-top-bar select:focus { outline: none; border-color: rgba(99,102,241,0.5); }

/* Tile interno — herda o frame da .gd-tile, só estiliza conteúdo */
.bid-tile {
  display: flex; flex-direction: column;
  height: 100%; width: 100%;
  overflow: hidden;
}
.bid-tile-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 8px;
  flex-shrink: 0;
}
.bid-tile-title-wrap { min-width: 0; flex: 1; }
.bid-tile-title {
  margin: 0;
  font-size: 13px; font-weight: 600;
  letter-spacing: -0.01em;
  color: #f1f5f9;
  line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bid-tile-sub {
  margin: 2px 0 0;
  font-size: 11px; color: #94a3b8;
  line-height: 1.45;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.bid-tile-actions { display: flex; gap: 2px; flex-shrink: 0; }
.bid-tile-body {
  flex: 1;
  min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 6px 14px 10px;
  position: relative;
  overflow: hidden;
}
.bid-tile-body .bid-svg { max-height: 100%; }
.bid-tile-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  font-size: 9px; color: #64748b;
  border-top: 1px solid rgba(255,255,255,0.04);
  letter-spacing: 0.08em; font-weight: 600; text-transform: uppercase;
  flex-shrink: 0;
}
.bid-tile .bid-type-icon { color: #818cf8; }
.bid-tile .bid-icon-btn { color: #94a3b8; }
.bid-tile .bid-icon-btn:hover { background: rgba(255,255,255,0.06); color: #f1f5f9; border-color: rgba(255,255,255,0.08); }
.bid-tile .bid-icon-btn.bid-icon-danger:hover { background: rgba(244,63,94,0.12); color: #fb7185; border-color: rgba(244,63,94,0.2); }

/* Dentro do tile dark, ajusta cores dos charts */
.bid-tile .bid-grid-line { stroke: rgba(255,255,255,0.06); }
.bid-tile .bid-axis-line { stroke: rgba(255,255,255,0.14); }
.bid-tile .bid-axis-label { fill: #64748b; }
.bid-tile .bid-kpi-value {
  background: linear-gradient(135deg, #f1f5f9 0%, #a5b4fc 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.bid-tile .bid-kpi-label { color: #64748b; }
.bid-tile .bid-pie-total { color: #f1f5f9; }
.bid-tile .bid-pie-total-label { color: #64748b; }
.bid-tile .bid-pie-label { color: #cbd5e1; }
.bid-tile .bid-pie-value { color: #f1f5f9; }
.bid-tile .bid-pie-pct { color: #64748b; }
.bid-tile .bid-pie-legend li:hover { background: rgba(255,255,255,0.04); }
.bid-tile .bid-table-wrap { border-color: rgba(255,255,255,0.06); }
.bid-tile .bid-table th { background: rgba(255,255,255,0.02); color: #64748b; border-bottom-color: rgba(255,255,255,0.06); }
.bid-tile .bid-table td { color: #e2e8f0; border-bottom-color: rgba(255,255,255,0.03); }
.bid-tile .bid-table tbody tr:hover { background: rgba(99,102,241,0.08); }
.bid-tile .bid-muted, .bid-tile .bid-empty-data { color: #64748b; }
.bid-tile .bid-skeleton { background: linear-gradient(90deg, #1e293b 0%, #0f172a 50%, #1e293b 100%); }
.bid-tile .bid-skeleton-shimmer { background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.05) 50%, transparent 100%); }
.bid-tile .bid-error { background: rgba(244,63,94,0.1); border-color: rgba(244,63,94,0.22); color: #fb7185; }
