/* =============================================================================
   BI DASHBOARD — Cockpit professionnel gestion-dechets
   Version 2.0 — Refonte complète avec Chart.js + animations
   ============================================================================= */

/* -----------------------------------------------------------------------------
   CSS Custom Properties
   ----------------------------------------------------------------------------- */
:root {
  /* — Cascade depuis la charte graphique de l'application — */
  --bi-primary:     var(--gdm-primary-color,   #00A040);
  --bi-accent:      var(--gdm-accent-color, #0078C0);
  --bi-secondary:   var(--gdm-secondary-color, #111827);
  /* — Couleurs sémantiques fixes — */
  --bi-success:     #16a34a;
  --bi-warning:     #0078C0;
  --bi-danger:      #dc2626;
  --bi-info:        #0284c7;
  --bi-neutral:     #475569;
  --bi-bg:          #f1f5f9;
  --bi-card-bg:     #ffffff;
  --bi-card-radius: 16px;
  --bi-shadow:      0 2px 12px rgba(15,23,42,.08), 0 0 0 1px rgba(15,23,42,.05);
  --bi-shadow-hover:0 8px 32px rgba(15,23,42,.14), 0 0 0 1px rgba(15,23,42,.12);
  --bi-transition:  all .22s cubic-bezier(.4,0,.2,1);
}

/* -----------------------------------------------------------------------------
   Hero Header
   ----------------------------------------------------------------------------- */
.bi-hero-header {
  background: var(--bi-primary);
  background: linear-gradient(135deg, var(--bi-primary) 0%, color-mix(in srgb, var(--bi-primary) 70%, #fff 30%) 50%, color-mix(in srgb, var(--bi-primary) 85%, #000 15%) 100%);
  border-radius: 20px;
  padding: 2rem 2.5rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 8px 32px rgba(30,58,95,.35);
  position: relative;
  overflow: hidden;
}

.bi-hero-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.bi-hero-left { position: relative; }

.bi-hero-eyebrow {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.6);
  margin-bottom: .35rem;
}

.bi-hero-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0 0 .4rem;
  line-height: 1.15;
}

.bi-hero-subtitle {
  font-size: .82rem;
  color: rgba(255,255,255,.65);
  max-width: 480px;
}

.bi-hero-clock {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,.9);
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.bi-hero-date {
  font-size: .78rem;
  color: rgba(255,255,255,.55);
  text-align: right;
  margin-top: .25rem;
}

.bi-hero-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.bi-hero-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .6rem 1.2rem;
  border-radius: 10px;
  font-size: .8rem;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: var(--bi-transition);
}

.bi-hero-btn-primary {
  background: #fff;
  color: var(--bi-primary);
}

.bi-hero-btn-primary:hover {
  background: #e8f4fd;
  transform: translateY(-2px);
}

.bi-hero-btn-ghost {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
}

.bi-hero-btn-ghost:hover {
  background: rgba(255,255,255,.22);
  transform: translateY(-2px);
}

/* -----------------------------------------------------------------------------
   Alert Ribbon
   ----------------------------------------------------------------------------- */
.bi-alert-ribbon {
  display: flex;
  gap: .65rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.bi-alert-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 700;
  text-decoration: none;
  transition: var(--bi-transition);
  animation: bi-chip-in .4s ease both;
}

.bi-alert-chip:hover { transform: translateY(-2px); filter: brightness(1.08); }

.bi-alert-chip.danger  { background: #fef2f2; color: #0078C0; border: 1px solid #fecaca; }
.bi-alert-chip.warning { background: #fffbeb; color: #0078C0; border: 1px solid #fde68a; }
.bi-alert-chip.info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.bi-alert-chip.success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

.bi-alert-chip-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.danger .bi-alert-chip-dot  { background: #dc2626; animation: bi-pulse 1.2s ease infinite; }
.warning .bi-alert-chip-dot { background: #f59e0b; }
.info .bi-alert-chip-dot    { background: #3b82f6; }
.success .bi-alert-chip-dot { background: #22c55e; }

@keyframes bi-pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.4); opacity: .6; }
}

@keyframes bi-chip-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* -----------------------------------------------------------------------------
   KPI Counter Grid
   ----------------------------------------------------------------------------- */
.bi-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.bi-kpi-card {
  background: var(--bi-card-bg);
  border-radius: var(--bi-card-radius);
  padding: 1.25rem 1.1rem;
  box-shadow: var(--bi-shadow);
  display: flex;
  flex-direction: column;
  gap: .45rem;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: var(--bi-transition);
  border: 1.5px solid transparent;
  animation: bi-card-in .5s ease both;
  position: relative;
  overflow: hidden;
}

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

.bi-kpi-card.tone-info    { border-color: rgba(2,132,199,.15); }
.bi-kpi-card.tone-info::before    { background: var(--bi-info); }
.bi-kpi-card.tone-success { border-color: rgba(22,163,74,.15); }
.bi-kpi-card.tone-success::before { background: var(--bi-success); }
.bi-kpi-card.tone-warning { border-color: rgba(217,119,6,.15); }
.bi-kpi-card.tone-warning::before { background: var(--bi-warning); }
.bi-kpi-card.tone-danger  { border-color: rgba(220,38,38,.15); }
.bi-kpi-card.tone-danger::before  { background: var(--bi-danger); }
.bi-kpi-card.tone-neutral { border-color: rgba(71,85,105,.12); }
.bi-kpi-card.tone-neutral::before { background: var(--bi-neutral); }

.bi-kpi-card:hover {
  box-shadow: var(--bi-shadow-hover);
  transform: translateY(-3px);
}

.bi-kpi-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.bi-kpi-card.tone-info    .bi-kpi-icon { background: #e0f2fe; color: #0284c7; }
.bi-kpi-card.tone-success .bi-kpi-icon { background: #dcfce7; color: #16a34a; }
.bi-kpi-card.tone-warning .bi-kpi-icon { background: #fef3c7; color: #0078C0; }
.bi-kpi-card.tone-danger  .bi-kpi-icon { background: #fee2e2; color: #dc2626; }
.bi-kpi-card.tone-neutral .bi-kpi-icon { background: #f1f5f9; color: #475569; }

.bi-kpi-value {
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: color .2s;
}

.bi-kpi-card.tone-info    .bi-kpi-value { color: #0369a1; }
.bi-kpi-card.tone-success .bi-kpi-value { color: #15803d; }
.bi-kpi-card.tone-warning .bi-kpi-value { color: #b45309; }
.bi-kpi-card.tone-danger  .bi-kpi-value { color: #0078C0; }
.bi-kpi-card.tone-neutral .bi-kpi-value { color: #334155; }

.bi-kpi-label {
  font-size: .72rem;
  font-weight: 600;
  color: #64748b;
  letter-spacing: .01em;
  line-height: 1.25;
}

.bi-kpi-meta {
  font-size: .66rem;
  color: #94a3b8;
  margin-top: .1rem;
}

@keyframes bi-card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Staggered animation delay */
.bi-kpi-card:nth-child(1)  { animation-delay: .03s; }
.bi-kpi-card:nth-child(2)  { animation-delay: .06s; }
.bi-kpi-card:nth-child(3)  { animation-delay: .09s; }
.bi-kpi-card:nth-child(4)  { animation-delay: .12s; }
.bi-kpi-card:nth-child(5)  { animation-delay: .15s; }
.bi-kpi-card:nth-child(6)  { animation-delay: .18s; }
.bi-kpi-card:nth-child(7)  { animation-delay: .21s; }
.bi-kpi-card:nth-child(8)  { animation-delay: .24s; }
.bi-kpi-card:nth-child(9)  { animation-delay: .27s; }
.bi-kpi-card:nth-child(10) { animation-delay: .30s; }
.bi-kpi-card:nth-child(11) { animation-delay: .33s; }
.bi-kpi-card:nth-child(12) { animation-delay: .36s; }

/* -----------------------------------------------------------------------------
   Chart Grid
   ----------------------------------------------------------------------------- */
.bi-chart-grid {
  display: grid;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}

.bi-chart-grid-3 { grid-template-columns: repeat(3, 1fr); }
.bi-chart-grid-2 { grid-template-columns: repeat(2, 1fr); }
.bi-chart-grid-4 { grid-template-columns: repeat(4, 1fr); }
.bi-chart-grid-32 { grid-template-columns: 2fr 1fr; }
.bi-chart-grid-23 { grid-template-columns: 1fr 2fr; }

@media (max-width: 1280px) {
  .bi-chart-grid-3  { grid-template-columns: repeat(2, 1fr); }
  .bi-chart-grid-4  { grid-template-columns: repeat(2, 1fr); }
  .bi-chart-grid-32 { grid-template-columns: 1fr; }
  .bi-chart-grid-23 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .bi-chart-grid-3,
  .bi-chart-grid-2,
  .bi-chart-grid-4,
  .bi-chart-grid-32,
  .bi-chart-grid-23 { grid-template-columns: 1fr; }
}

/* -----------------------------------------------------------------------------
   Chart Card
   ----------------------------------------------------------------------------- */
.bi-chart-panel {
  background: var(--bi-card-bg);
  border-radius: var(--bi-card-radius);
  box-shadow: var(--bi-shadow);
  padding: 1.4rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  transition: var(--bi-transition);
  animation: bi-card-in .5s ease both;
  border: 1px solid rgba(15,23,42,.06);
}

.bi-chart-panel:hover {
  box-shadow: var(--bi-shadow-hover);
  transform: translateY(-2px);
}

.bi-chart-panel.full-width {
  grid-column: 1 / -1;
}

.bi-chart-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.bi-chart-eyebrow {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: .2rem;
}

.bi-chart-title {
  font-size: .95rem;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: -.01em;
}

.bi-chart-badge {
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .66rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
}

.bi-chart-canvas-wrap {
  position: relative;
  height: 220px;
}

.bi-chart-canvas-wrap.tall { height: 280px; }
.bi-chart-canvas-wrap.short { height: 160px; }

.bi-chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Empty state */
.bi-chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 160px;
  color: #94a3b8;
  font-size: .8rem;
  gap: .5rem;
}

.bi-chart-empty-icon {
  font-size: 2rem;
  opacity: .4;
}

/* Skeleton loading */
.bi-chart-skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: bi-skeleton 1.5s ease infinite;
  border-radius: 8px;
  height: 180px;
}

@keyframes bi-skeleton {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* -----------------------------------------------------------------------------
   Gauge / Progress widgets
   ----------------------------------------------------------------------------- */
.bi-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .5rem 0;
  gap: .8rem;
}

.bi-gauge-svg {
  width: 140px;
  height: 80px;
  overflow: visible;
}

.bi-gauge-track {
  fill: none;
  stroke: #f1f5f9;
  stroke-width: 12;
  stroke-linecap: round;
}

.bi-gauge-fill {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
  transform-origin: 70px 70px;
  transition: stroke-dasharray 1.2s cubic-bezier(.4,0,.2,1);
}

.bi-gauge-text-wrap {
  text-align: center;
}

.bi-gauge-value {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1;
}

.bi-gauge-label {
  font-size: .72rem;
  color: #64748b;
  font-weight: 600;
}

/* -----------------------------------------------------------------------------
   Stacked metrics bar (Flux opérationnel)
   ----------------------------------------------------------------------------- */
.bi-flux-pipeline {
  display: flex;
  gap: 0;
  align-items: stretch;
  background: var(--bi-card-bg);
  border-radius: var(--bi-card-radius);
  box-shadow: var(--bi-shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(15,23,42,.06);
}

.bi-flux-stage {
  flex: 1;
  padding: 1.4rem 1.2rem;
  border-right: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: var(--bi-transition);
  text-decoration: none;
  color: inherit;
  position: relative;
}

.bi-flux-stage:last-child { border-right: none; }

.bi-flux-stage:hover {
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: inset 0 -3px 0 var(--bi-accent);
}

.bi-flux-stage-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  background: #f1f5f9;
}

.bi-flux-stage-num {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -.04em;
  color: #1e293b;
  font-variant-numeric: tabular-nums;
}

.bi-flux-stage-label {
  font-size: .72rem;
  font-weight: 700;
  color: #64748b;
}

.bi-flux-stage-sub {
  font-size: .66rem;
  color: #94a3b8;
}

.bi-flux-arrow {
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  font-size: 1rem;
  flex-shrink: 0;
  align-self: center;
}

@media (max-width: 900px) {
  .bi-flux-pipeline {
    flex-direction: column;
  }
  .bi-flux-stage { border-right: none; border-bottom: 1px solid #f1f5f9; }
  .bi-flux-arrow { transform: rotate(90deg); }
}

/* -----------------------------------------------------------------------------
   Operations Queues
   ----------------------------------------------------------------------------- */
.bi-queues-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .bi-queues-grid { grid-template-columns: 1fr; }
}

.bi-queue-panel {
  background: var(--bi-card-bg);
  border-radius: var(--bi-card-radius);
  box-shadow: var(--bi-shadow);
  border: 1px solid rgba(15,23,42,.06);
  overflow: hidden;
  animation: bi-card-in .5s ease both;
}

.bi-queue-header {
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.bi-queue-title {
  font-size: .9rem;
  font-weight: 800;
  color: #1e293b;
}

.bi-queue-count {
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  background: #fee2e2;
  color: #0078C0;
}

.bi-queue-count.safe {
  background: #dcfce7;
  color: #15803d;
}

.bi-queue-link {
  font-size: .72rem;
  font-weight: 600;
  color: var(--bi-info);
  text-decoration: none;
}

.bi-queue-link:hover { text-decoration: underline; }

.bi-queue-list {
  padding: .5rem 0;
}

.bi-queue-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.4rem;
  border-bottom: 1px solid #f8fafc;
  transition: background .14s;
}

.bi-queue-item:last-child { border-bottom: none; }
.bi-queue-item:hover { background: #f8fafc; }

.bi-queue-status {
  padding: .2rem .55rem;
  border-radius: 6px;
  font-size: .64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.bi-queue-status.pending_validation,
.bi-queue-status.field_completed,
.bi-queue-status.in_progress { background: #fef3c7; color: #0078C0; }
.bi-queue-status.validated   { background: #dcfce7; color: #15803d; }
.bi-queue-status.rejected,
.bi-queue-status.incident,
.bi-queue-status.hazardous_deposit { background: #fee2e2; color: #0078C0; }
.bi-queue-status.assigned    { background: #e0f2fe; color: #0369a1; }
.bi-queue-status.planned     { background: #f1f5f9; color: #475569; }

.bi-queue-code {
  font-size: .8rem;
  font-weight: 700;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bi-queue-meta {
  font-size: .68rem;
  color: #94a3b8;
  margin-top: .1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bi-queue-date {
  font-size: .68rem;
  color: #94a3b8;
  white-space: nowrap;
}

.bi-queue-empty {
  padding: 2rem 1.4rem;
  text-align: center;
  color: #94a3b8;
  font-size: .8rem;
}

/* -----------------------------------------------------------------------------
   Role Shortcuts
   ----------------------------------------------------------------------------- */
.bi-roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.bi-role-card {
  background: var(--bi-card-bg);
  border-radius: var(--bi-card-radius);
  box-shadow: var(--bi-shadow);
  padding: 1.2rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  border: 1.5px solid transparent;
  transition: var(--bi-transition);
}

.bi-role-card:hover {
  border-color: rgba(30,58,95,.18);
  box-shadow: var(--bi-shadow-hover);
  transform: translateY(-3px);
}

.bi-role-tag {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 700;
  background: #e0f2fe;
  color: #0369a1;
  width: fit-content;
}

.bi-role-title {
  font-size: .88rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1.25;
}

.bi-role-desc {
  font-size: .72rem;
  color: #64748b;
  line-height: 1.45;
}

/* -----------------------------------------------------------------------------
   Reports / KPI Page
   ----------------------------------------------------------------------------- */
.bi-reports-page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Tab Navigation */
.bi-tab-nav {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  background: var(--bi-card-bg);
  border-radius: 14px;
  padding: .45rem;
  box-shadow: var(--bi-shadow);
  border: 1px solid rgba(15,23,42,.06);
}

.bi-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border-radius: 10px;
  font-size: .78rem;
  font-weight: 700;
  text-decoration: none;
  color: #64748b;
  border: none;
  cursor: pointer;
  background: transparent;
  transition: var(--bi-transition);
  white-space: nowrap;
}

.bi-tab-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.bi-tab-btn.active {
  background: var(--bi-primary);
  background: linear-gradient(135deg, var(--bi-primary), color-mix(in srgb, var(--bi-primary) 70%, #fff 30%));
  color: #fff;
  box-shadow: 0 2px 8px rgba(30,58,95,.3);
}

.bi-tab-btn .bi-tab-count {
  background: rgba(255,255,255,.2);
  padding: .1rem .4rem;
  border-radius: 999px;
  font-size: .62rem;
}

.bi-tab-btn:not(.active) .bi-tab-count {
  background: #e2e8f0;
  color: #64748b;
}

/* Report KPI Cards */
.bi-report-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 900px) {
  .bi-report-kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .bi-report-kpis { grid-template-columns: 1fr; }
}

.bi-report-kpi-card {
  background: var(--bi-card-bg);
  border-radius: var(--bi-card-radius);
  box-shadow: var(--bi-shadow);
  padding: 1.5rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  border-top: 3px solid transparent;
  transition: var(--bi-transition);
}

.bi-report-kpi-card:hover { transform: translateY(-3px); box-shadow: var(--bi-shadow-hover); }
.bi-report-kpi-card.tone-info    { border-top-color: var(--bi-info); }
.bi-report-kpi-card.tone-success { border-top-color: var(--bi-success); }
.bi-report-kpi-card.tone-warning { border-top-color: var(--bi-warning); }
.bi-report-kpi-card.tone-danger  { border-top-color: var(--bi-danger); }

.bi-report-kpi-num {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
}

.bi-report-kpi-card.tone-info    .bi-report-kpi-num { color: #0369a1; }
.bi-report-kpi-card.tone-success .bi-report-kpi-num { color: #15803d; }
.bi-report-kpi-card.tone-warning .bi-report-kpi-num { color: #b45309; }
.bi-report-kpi-card.tone-danger  .bi-report-kpi-num { color: #0078C0; }

.bi-report-kpi-label {
  font-size: .75rem;
  font-weight: 700;
  color: #64748b;
}

/* Period Filter bar */
.bi-period-bar {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
  background: var(--bi-card-bg);
  border-radius: 12px;
  padding: .75rem 1.2rem;
  box-shadow: var(--bi-shadow);
  border: 1px solid rgba(15,23,42,.06);
}

.bi-period-bar label {
  font-size: .75rem;
  font-weight: 700;
  color: #475569;
}

.bi-period-btn {
  padding: .35rem .85rem;
  border-radius: 8px;
  font-size: .74rem;
  font-weight: 700;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  color: #475569;
  cursor: pointer;
  transition: var(--bi-transition);
}

.bi-period-btn:hover, .bi-period-btn.active {
  border-color: var(--bi-primary);
  background: var(--bi-primary);
  color: #fff;
}

.bi-period-sep { color: #cbd5e1; font-size: .8rem; }

.bi-period-input {
  padding: .35rem .7rem;
  border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  font-size: .74rem;
  color: #1e293b;
  font-family: inherit;
  font-weight: 600;
}

/* Report Data Table */
.bi-data-table-wrap {
  background: var(--bi-card-bg);
  border-radius: var(--bi-card-radius);
  box-shadow: var(--bi-shadow);
  border: 1px solid rgba(15,23,42,.06);
  overflow: hidden;
}

.bi-data-table-head {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.bi-data-table-title {
  font-size: .9rem;
  font-weight: 800;
  color: #1e293b;
}

.bi-data-search {
  padding: .4rem .85rem;
  border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  font-size: .74rem;
  width: 200px;
  font-family: inherit;
  color: #1e293b;
  transition: var(--bi-transition);
}

.bi-data-search:focus {
  outline: none;
  border-color: var(--bi-primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,.1);
}

.bi-data-table-scroll {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

.bi-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
}

.bi-data-table th {
  padding: .7rem 1rem;
  text-align: left;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.bi-data-table td {
  padding: .65rem 1rem;
  border-bottom: 1px solid #f8fafc;
  color: #334155;
  font-size: .78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.bi-data-table tr:last-child td { border-bottom: none; }
.bi-data-table tr:hover td { background: #f8fafc; }

/* Status badges in table */
.bi-status-badge {
  padding: .18rem .55rem;
  border-radius: 6px;
  font-size: .64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  display: inline-block;
}

.bi-status-badge.validated, .bi-status-badge.completed { background: #dcfce7; color: #15803d; }
.bi-status-badge.pending_validation, .bi-status-badge.in_progress, .bi-status-badge.field_completed { background: #fef3c7; color: #0078C0; }
.bi-status-badge.rejected, .bi-status-badge.incident { background: #fee2e2; color: #0078C0; }
.bi-status-badge.planned, .bi-status-badge.draft { background: #f1f5f9; color: #475569; }
.bi-status-badge.assigned { background: #e0f2fe; color: #0369a1; }

/* -----------------------------------------------------------------------------
   Global Stats Summary
   ----------------------------------------------------------------------------- */
.bi-global-stats {
  background: var(--bi-primary);
  background: linear-gradient(135deg, var(--bi-primary) 0%, color-mix(in srgb, var(--bi-primary) 70%, #fff 30%) 100%);
  border-radius: 20px;
  padding: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.5rem;
  color: #fff;
  margin-bottom: 1.5rem;
}

.bi-global-stat {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding-left: 1rem;
  border-left: 2px solid rgba(255,255,255,.2);
}

.bi-global-stat-num {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.bi-global-stat-label {
  font-size: .7rem;
  font-weight: 600;
  color: rgba(255,255,255,.6);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* -----------------------------------------------------------------------------
   Tooltip custom (Chart.js override)
   ----------------------------------------------------------------------------- */
.bi-chart-tooltip-custom {
  background: rgba(15,23,42,.95) !important;
  border-radius: 10px !important;
  border: 1px solid rgba(255,255,255,.08) !important;
  padding: .6rem .8rem !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.4) !important;
  font-family: inherit !important;
}

/* -----------------------------------------------------------------------------
   Export actions
   ----------------------------------------------------------------------------- */
.bi-export-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: 1rem 1.4rem;
  background: var(--bi-card-bg);
  border-radius: 12px;
  box-shadow: var(--bi-shadow);
  border: 1px solid rgba(15,23,42,.06);
}

.bi-export-select {
  padding: .4rem .75rem;
  border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  font-size: .74rem;
  font-family: inherit;
  color: #1e293b;
  font-weight: 600;
  background: #fff;
}

.bi-btn-export {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: 9px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--bi-transition);
  text-decoration: none;
}

.bi-btn-primary {
  background: var(--bi-primary);
  color: #fff;
}

.bi-btn-primary:hover {
  background: color-mix(in srgb, var(--bi-primary) 70%, #fff 30%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30,58,95,.3);
}

.bi-btn-ghost {
  background: #f1f5f9;
  color: #475569;
  border: 1.5px solid #e2e8f0;
}

.bi-btn-ghost:hover {
  background: #e2e8f0;
  color: #1e293b;
}

/* -----------------------------------------------------------------------------
   Responsive helpers
   ----------------------------------------------------------------------------- */
@media print {
  .bi-hero-actions,
  .bi-export-bar,
  .bi-tab-nav { display: none !important; }

  .bi-chart-panel,
  .bi-kpi-card,
  .bi-queue-panel { break-inside: avoid; box-shadow: none; border: 1px solid #e2e8f0; }
}

/* -----------------------------------------------------------------------------
   Number counter animation
   ----------------------------------------------------------------------------- */
@keyframes bi-count-up {
  from { opacity: .3; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bi-counting { animation: bi-count-up .4s ease both; }
