/* ============================================
   Operations Dashboard - Enterprise SaaS
   $50M Manufacturing Intelligence Platform
   Design System: #f4f6f9, 14px radius, 8px grid
   ============================================ */

/* ---- Global Layout ---- */
.ops-dashboard-page {
  min-height: 100vh;
  background: #f4f6f9;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.dark .ops-dashboard-page {
  background: #0f172a;
}
/* Wide layout: ~95% of available space, max 1800px */
.ops-dashboard-container {
  width: 100%;
  max-width: 1800px;
  margin-left: auto;
  margin-right: auto;
}
@media (min-width: 1400px) {
  .ops-dashboard-container {
    width: 95%;
  }
}

/* ---- Executive Header (Hero + Glassmorphism) ---- */
.ops-executive-header {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e40af 100%);
  border-radius: 24px;
  padding: 32px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.45);
}
.ops-executive-header.operations-panel::before {
  content: none;
}
.panel-content {
  position: relative;
  z-index: 3;
}
.animated-bg-circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: ops-pulse-scale 8s ease-in-out infinite;
  pointer-events: none;
}
.animated-bg-circle.circle-1 {
  top: -120px;
  right: -120px;
  width: 384px;
  height: 384px;
  background: rgba(56,189,248,0.38);
  animation-duration: 8s;
}
.animated-bg-circle.circle-2 {
  bottom: -110px;
  left: -80px;
  width: 288px;
  height: 288px;
  background: rgba(34,211,238,0.28);
  animation-duration: 6s;
}
@keyframes ops-pulse-scale {
  0%, 100% { transform: scale(1); opacity: 0.32; }
  50% { transform: scale(1.2); opacity: 0.5; }
}
.ops-executive-header h1 {
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: clamp(2rem, 4.5vw, 2.25rem);
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}
.ops-executive-header .ops-subtitle {
  color: rgba(255,255,255,0.9);
  font-size: 1rem;
  margin-bottom: 20px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  margin-bottom: 16px;
}
.ops-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}
.ops-date-filter {
  display: inline-flex;
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 4px;
  gap: 6px;
  backdrop-filter: blur(8px);
}
.ops-date-filter button {
  padding: 8px 22px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ops-date-filter button:hover {
  background: rgba(255,255,255,0.2);
}
.ops-date-filter button.active {
  background: #fff;
  color: #1e40af;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.ops-last-updated {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.9);
  font-size: 0.875rem;
  font-weight: 500;
}
.ops-last-updated .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34,197,94,0.35);
}
.ops-last-updated .dot.pulsing {
  animation: ops-pulse-dot 2s ease-in-out infinite;
}
@keyframes ops-pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}
.ops-refresh-btn {
  margin-left: 0;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.28);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  transition: transform 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 8px 20px rgba(15,23,42,0.22);
}
.ops-refresh-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.3);
  transform: scale(1.05);
  box-shadow: 0 12px 24px rgba(15,23,42,0.3);
}
.ops-refresh-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ---- Operational Health Score (NEW) ---- */
.ops-health-widget {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.22);
  padding: 26px 28px;
  margin-bottom: 24px;
  box-shadow: 0 20px 40px rgba(15,23,42,0.18);
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 28px;
}
.dark .ops-health-widget {
  background: rgba(30,41,59,0.5);
  border-color: rgba(148,163,184,0.28);
}
.status-left h3,
.status-right h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 16px;
}
.dark .status-left h3,
.dark .status-right h3 {
  color: #f8fafc;
}
.status-display {
  display: flex;
  align-items: center;
  gap: 24px;
}
.status-circle {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 55%, #1d4ed8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(59,130,246,0.58);
  animation: ops-glow-pulse 2s ease-in-out infinite;
}
@keyframes ops-glow-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(59,130,246,0.5); }
  50% { box-shadow: 0 0 40px rgba(59,130,246,0.8); }
}
.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(96,165,250,0.46);
  animation: ops-pulse-ring 2s ease-in-out infinite;
}
@keyframes ops-pulse-ring {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.5); opacity: 0; }
}
.status-number {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.15rem;
  font-weight: 700;
  color: #fff;
}
.status-info {
  flex: 1;
}
.status-label {
  color: #64748b;
  font-size: 0.875rem;
  margin-bottom: 4px;
}
.status-text {
  color: #0f172a;
  font-weight: 600;
  font-size: 1rem;
}
.status-text.is-stable {
  color: #16a34a;
}
.status-text.is-warning {
  color: #b45309;
}
.ops-status-activity-chart {
  width: 100%;
  height: 116px;
  display: block;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(219,234,254,0.8) 0%, rgba(191,219,254,0.45) 100%);
  border: 1px solid rgba(59,130,246,0.2);
}
.ops-status-activity-chart .activity-area {
  fill: rgba(59,130,246,0.28);
}
.ops-status-activity-chart .activity-line {
  fill: none;
  stroke: #2563eb;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Section containers ---- */
.ops-section {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.04);
  transition: box-shadow 0.25s ease;
}
.ops-section:hover {
  box-shadow: 0 16px 40px rgba(0,0,0,0.08);
}
.dark .ops-section {
  background: #1e293b;
  border-color: #334155;
}
.ops-section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}
.ops-section-title.mb-0 { margin-bottom: 0; }
.dark .ops-section-title { color: #f1f5f9; }
.ops-kpi-legend {
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.5;
  margin: -8px 0 20px 0;
  max-width: 560px;
}
.dark .ops-kpi-legend { color: #94a3b8; }

/* ---- KPI Cards (3x2) - Modern Gradient + Glassmorphism ---- */
.ops-kpi-card {
  min-height: 180px;
  border-radius: 16px;
  padding: 24px;
  background: #f1f5f9;
}
.ops-kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 640px) {
  .ops-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .ops-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
.ops-kpi-card.kpi-card-modern {
  min-height: 220px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 24px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.22);
  transition: transform 0.28s ease, box-shadow 0.28s ease;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
}
.ops-kpi-card.kpi-card-modern:hover {
  transform: translateY(-4px) scale(1.015);
  box-shadow: 0 14px 36px rgba(15,23,42,0.3);
}
@media (prefers-reduced-motion: reduce) {
  .ops-kpi-card.kpi-card-modern:hover { transform: none; }
}
.kpi-hover-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.02) 60%, rgba(255,255,255,0.16) 100%);
  transition: opacity 0.28s ease;
}
.ops-kpi-card.kpi-card-modern:hover .kpi-hover-overlay {
  opacity: 1;
}
/* Decorative circles */
.kpi-decorations {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.kpi-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.kpi-circle-tr {
  width: 100px;
  height: 100px;
  top: -30px;
  right: -30px;
}
.kpi-circle-bl {
  width: 60px;
  height: 60px;
  bottom: -15px;
  left: -15px;
}
.kpi-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.kpi-icon-box {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
}
.kpi-icon {
  width: 23px;
  height: 23px;
  color: rgba(255,255,255,0.95);
}
.kpi-trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.kpi-trend-badge.down { background: rgba(0,0,0,0.2); }
.kpi-trend-badge.neutral { background: rgba(15,23,42,0.28); }
.kpi-trend-arrow {
  width: 14px;
  height: 14px;
}
.kpi-value {
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #fff;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.kpi-title {
  font-size: 0.92rem;
  color: rgba(255,255,255,0.9);
  margin-top: 4px;
  font-weight: 600;
  line-height: 1.4;
}
.kpi-subtext {
  margin-top: 2px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.78);
}
.kpi-sparkline {
  margin-top: auto;
  padding-top: 14px;
  width: 100%;
  height: 42px;
  opacity: 0.9;
}
.kpi-sparkline svg {
  width: 100%;
  height: 100%;
  display: block;
}
.dark .ops-kpi-card.kpi-card-modern {
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

/* ---- Pipeline (horizontal segmented blocks) ---- */
.ops-pipeline-section {
  padding: 24px 0;
}
.ops-pipeline-bar {
  display: flex;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  background: #e2e8f0;
  margin-bottom: 20px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
}
.dark .ops-pipeline-bar { background: #334155; }
.ops-pipeline-bar .ops-pipeline-seg {
  transition: all 0.35s ease;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.ops-pipeline-bar .ops-pipeline-seg.bottleneck {
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.9);
  filter: brightness(1.2);
}
.ops-pipeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 28px;
  font-size: 0.8125rem;
  color: #64748b;
}
.dark .ops-pipeline-legend { color: #94a3b8; }
.ops-pipeline-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ops-pipeline-legend .dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

/* ---- Charts (70/30 layout) ---- */
.ops-charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 1024px) {
  .ops-charts-grid {
    grid-template-columns: 7fr 3fr;
  }
}
.ops-chart-card {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.04);
  min-height: 300px;
}
.dark .ops-chart-card {
  background: #1e293b;
  border-color: #334155;
}
.ops-chart-card.ops-chart-dominant {
  min-height: 360px;
}
.ops-chart-card .ops-chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 20px;
}
.dark .ops-chart-card .ops-chart-title { color: #f1f5f9; }
.ops-chart-right-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.ops-chart-right-stack .ops-chart-card {
  min-height: 220px;
}
.ops-chart-wrap {
  width: 100%;
}
.ops-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.ops-chart-painting-wrap {
  height: clamp(185px, 26vw, 240px);
}
.ops-chart-monthly-wrap {
  height: clamp(170px, 22vw, 220px);
}

/* ---- Logistics (with icon circles) ---- */
.ops-logistics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 560px) {
  .ops-logistics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1200px) {
  .ops-logistics-grid { grid-template-columns: repeat(4, 1fr); }
}
.ops-logistics-card {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.04);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
}
.ops-logistics-card:nth-child(1) { --log-accent: #3b82f6; }
.ops-logistics-card:nth-child(2) { --log-accent: #8b5cf6; }
.ops-logistics-card:nth-child(3) { --log-accent: #10b981; }
.ops-logistics-card:nth-child(4) { --log-accent: #64748b; }
.ops-logistics-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px -8px rgba(0,0,0,0.1);
}
.dark .ops-logistics-card {
  background: #1e293b;
  border-color: #334155;
}
.ops-logistics-card .ops-log-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(59,130,246,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.ops-logistics-card:nth-child(1) .ops-log-icon { background: rgba(59,130,246,0.12); color: #3b82f6; }
.ops-logistics-card:nth-child(2) .ops-log-icon { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.ops-logistics-card:nth-child(3) .ops-log-icon { background: rgba(16,185,129,0.12); color: #10b981; }
.ops-logistics-card:nth-child(4) .ops-log-icon { background: rgba(100,116,139,0.15); color: #64748b; }
.ops-logistics-card .val {
  font-size: 1.75rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}
.dark .ops-logistics-card .val { color: #f1f5f9; }
.ops-logistics-card .label {
  font-size: 0.8125rem;
  color: #64748b;
  margin-top: 6px;
}
.dark .ops-logistics-card .label { color: #94a3b8; }

/* ---- Smart Alerts (with counter + View All) ---- */
.ops-alerts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.ops-alerts-badge {
  background: #ef4444;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 10px;
}
.ops-alerts-view-all {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #3b82f6;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}
.ops-alerts-view-all:hover { text-decoration: underline; }
.ops-alerts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ops-alert-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 12px;
  border-left: 4px solid;
  transition: all 0.2s ease;
}
.ops-alert-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.ops-alert-card .ops-alert-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ops-alert-card .ops-alert-content { flex: 1; min-width: 0; }
.ops-alert-card .ops-alert-title {
  font-weight: 700;
  font-size: 0.9375rem;
  margin-bottom: 4px;
}
.ops-alert-card .ops-alert-detail {
  font-size: 0.8125rem;
  opacity: 0.9;
}
.ops-alert-card .ops-alert-date {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 4px;
}
.ops-alert-critical {
  background: #fef2f2;
  border-left-color: #dc2626;
}
.ops-alert-critical .ops-alert-icon {
  background: rgba(220,38,38,0.12);
  color: #dc2626;
}
.ops-alert-critical .ops-alert-title { color: #991b1b; }
.ops-alert-critical .ops-alert-detail { color: #b91c1c; }
.dark .ops-alert-critical {
  background: rgba(127,29,29,0.25);
  border-left-color: #f87171;
}
.dark .ops-alert-critical .ops-alert-icon { background: rgba(248,113,113,0.2); color: #fca5a5; }
.dark .ops-alert-critical .ops-alert-title { color: #fecaca; }
.dark .ops-alert-critical .ops-alert-detail { color: #fca5a5; }
.ops-alert-warning {
  background: #fffbeb;
  border-left-color: #d97706;
}
.ops-alert-warning .ops-alert-icon {
  background: rgba(217,119,6,0.12);
  color: #d97706;
}
.ops-alert-warning .ops-alert-title { color: #92400e; }
.ops-alert-warning .ops-alert-detail { color: #b45309; }
.dark .ops-alert-warning {
  background: rgba(120,53,15,0.25);
  border-left-color: #fbbf24;
}
.dark .ops-alert-warning .ops-alert-icon { background: rgba(251,191,36,0.2); color: #fde68a; }
.dark .ops-alert-warning .ops-alert-title { color: #fde68a; }
.dark .ops-alert-warning .ops-alert-detail { color: #fcd34d; }
.ops-alert-info {
  background: #eff6ff;
  border-left-color: #2563eb;
}
.ops-alert-info .ops-alert-icon {
  background: rgba(37,99,235,0.12);
  color: #2563eb;
}
.ops-alert-info .ops-alert-title { color: #1e40af; }
.ops-alert-info .ops-alert-detail { color: #1d4ed8; }
.dark .ops-alert-info {
  background: rgba(29,78,216,0.2);
  border-left-color: #60a5fa;
}
.dark .ops-alert-info .ops-alert-icon { background: rgba(96,165,250,0.2); color: #93c5fd; }
.dark .ops-alert-info .ops-alert-title { color: #93c5fd; }
.dark .ops-alert-info .ops-alert-detail { color: #bfdbfe; }

/* ---- Activity section ---- */
.ops-activity-section {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.04);
}
.dark .ops-activity-section {
  background: #1e293b;
  border-color: #334155;
}

/* ---- Animations ---- */
@keyframes ops-fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.ops-animate-in {
  animation: ops-fadeIn 0.5s cubic-bezier(0.4,0,0.2,1) forwards;
}

/* Botón de Análisis IA */
.ops-ai-analysis-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  border: 1px solid rgba(59,130,246,0.85);
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(59,130,246,0.38);
}
.ops-ai-analysis-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #2563eb 0%, #0891b2 100%);
  transform: scale(1.05);
  box-shadow: 0 14px 28px rgba(37,99,235,0.42);
}
.ops-ai-analysis-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Modal de Análisis Operativo IA */
.ops-analysis-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.ops-analysis-modal {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
  max-width: 1000px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}

.ops-analysis-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
  flex-shrink: 0;
}

.ops-analysis-modal__title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.ops-analysis-modal__close-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  color: #6b7280;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ops-analysis-modal__close-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.ops-analysis-modal__language-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 28px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.ops-analysis-modal__lang-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #6b7280;
}

.ops-analysis-modal__lang-btn:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #374151;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ops-analysis-modal__lang-btn--active {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.ops-analysis-modal__lang-btn--active:hover {
  background: #7c3aed;
  border-color: #7c3aed;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.ops-analysis-modal__lang-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #9ca3af;
}

.ops-analysis-modal__lang-btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

.ops-analysis-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  background: #ffffff;
}

.ops-analysis-modal__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
  color: #6b7280;
}

.ops-analysis-modal__loading p {
  font-size: 1rem;
  margin: 0;
}

/* Fuente de datos y métricas (backend) en modal de análisis */
.ops-analysis-datasource-section {
  margin-bottom: 24px;
  padding: 20px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}
.ops-analysis-datasource-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 16px 0;
}
.ops-analysis-datasource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.ops-analysis-datasource-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.ops-analysis-datasource-label {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
}
.ops-analysis-datasource-value {
  font-size: 0.95rem;
  color: #0f172a;
  word-break: break-word;
}
.ops-analysis-week-metrics {
  font-size: 0.85rem;
  color: #475569;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
}
.ops-analysis-week-metrics .ops-analysis-datasource-label {
  margin-right: 6px;
}
.ops-analysis-datasource-item--scope .ops-analysis-datasource-value {
  color: #1d4ed8;
}
.ops-analysis-next-week {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid #cbd5e1;
  background: #f1f5f9;
  padding: 12px;
  border-radius: 8px;
}
.ops-analysis-next-week .ops-analysis-datasource-label {
  display: block;
  margin-top: 6px;
  margin-bottom: 2px;
}
.ops-analysis-next-week .ops-analysis-datasource-label:first-child {
  margin-top: 0;
}

.ops-analysis-modal__content {
  color: #374151;
  line-height: 1.7;
  font-size: 0.95rem;
}

.ops-analysis-modal__content .analysis-h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin: 24px 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
}

.ops-analysis-modal__content .analysis-h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1f2937;
  margin: 20px 0 12px 0;
}

.ops-analysis-modal__content .analysis-h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #374151;
  margin: 16px 0 8px 0;
}

.ops-analysis-modal__content .analysis-ul {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.ops-analysis-modal__content .analysis-li {
  padding: 8px 0 8px 24px;
  position: relative;
  color: #4b5563;
}

.ops-analysis-modal__content .analysis-li::before {
  content: "•";
  position: absolute;
  left: 8px;
  color: #8b5cf6;
  font-weight: bold;
  font-size: 1.2rem;
}

.ops-analysis-modal__content strong {
  color: #111827;
  font-weight: 600;
}

.ops-analysis-modal__content em {
  color: #6b7280;
  font-style: italic;
}

.ops-analysis-modal__error {
  padding: 40px 20px;
  text-align: center;
  color: #dc2626;
}

.ops-analysis-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 28px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.ops-analysis-modal__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.ops-analysis-modal__btn--regenerate {
  background: #8b5cf6;
  color: #ffffff;
}

.ops-analysis-modal__btn--regenerate:hover:not(:disabled) {
  background: #7c3aed;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.ops-analysis-modal__btn--regenerate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ops-analysis-modal__btn--export {
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
}

.ops-analysis-modal__btn--export:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ops-analysis-modal__btn--copy {
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
}

.ops-analysis-modal__btn--copy:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ops-analysis-modal__btn--close {
  background: transparent;
  color: #6b7280;
  border: 1px solid transparent;
}

.ops-analysis-modal__btn--close:hover {
  background: #f3f4f6;
  color: #374151;
}

/* Responsive */
@media (max-width: 768px) {
  .ops-analysis-modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 12px;
  }

  .ops-analysis-modal__header {
    padding: 20px;
  }

  .ops-analysis-modal__title {
    font-size: 1.25rem;
  }

  .ops-analysis-modal__language-selector {
    padding: 12px 20px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .ops-analysis-modal__lang-btn {
    flex: 1;
    min-width: calc(33.333% - 4px);
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .ops-analysis-modal__body {
    padding: 20px;
  }

  .ops-analysis-modal__footer {
    flex-direction: column;
    padding: 16px 20px;
  }

  .ops-analysis-modal__btn {
    width: 100%;
    justify-content: center;
  }
}

/* ---- Dashboard responsive optimization (iPad + phones) ---- */
@media (max-width: 1200px) {
  .ops-executive-header {
    padding: 28px 28px;
    margin-bottom: 24px;
  }

  .panel-actions {
    margin-top: 16px;
    margin-bottom: 12px;
  }

  .ops-header-meta {
    gap: 12px;
  }

  .ops-section,
  .ops-activity-section {
    padding: 22px;
    margin-bottom: 20px;
  }

  .ops-chart-card {
    padding: 20px;
  }

  .ops-chart-card.ops-chart-dominant {
    min-height: 300px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .ops-dashboard-page {
    padding-top: 20px;
  }

  .ops-executive-header h1 {
    font-size: clamp(1.7rem, 3vw, 2rem);
  }

  .ops-charts-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .ops-chart-right-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  .ops-chart-right-stack .ops-chart-card {
    min-height: 200px;
  }

  .ops-chart-card.ops-chart-dominant > div {
    height: 280px !important;
  }

  .ops-chart-painting-wrap { height: clamp(190px, 24vw, 230px); }
  .ops-chart-monthly-wrap { height: clamp(172px, 20vw, 210px); }
}

/* iPad + tablets: keep charts stacked for readability */
@media (min-width: 768px) and (max-width: 1279px) {
  .ops-charts-grid {
    grid-template-columns: 1fr !important;
    gap: 18px;
  }

  .ops-chart-right-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  .ops-chart-right-stack .ops-chart-card {
    min-height: 200px;
  }

  .ops-chart-card.ops-chart-dominant > div {
    height: 290px !important;
  }

  .ops-chart-painting-wrap {
    height: clamp(192px, 24vw, 236px) !important;
  }

  .ops-chart-monthly-wrap {
    height: clamp(174px, 20vw, 214px) !important;
  }
}

/* Use 70/30 only on large desktop screens */
@media (min-width: 1280px) {
  .ops-charts-grid {
    grid-template-columns: 7fr 3fr !important;
  }

  .ops-chart-right-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }
}

@media (max-width: 767px) {
  .ops-dashboard-page {
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 14px;
    padding-bottom: 20px;
  }

  .ops-executive-header {
    padding: 20px 16px;
    border-radius: 12px;
  }

  .ops-executive-header .ops-subtitle {
    margin-bottom: 14px;
    font-size: 0.85rem;
  }

  .ops-header-meta {
    gap: 10px;
    align-items: stretch;
  }

  .ops-date-filter {
    width: 100%;
    justify-content: space-between;
  }

  .ops-date-filter button {
    flex: 1;
    padding: 9px 10px;
    font-size: 0.78rem;
  }

  .ops-last-updated {
    width: 100%;
    font-size: 0.75rem;
  }

  .panel-actions {
    width: 100%;
  }

  .ops-refresh-btn,
  .ops-ai-analysis-btn {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }

  .ops-health-widget {
    padding: 16px;
    gap: 16px;
    grid-template-columns: 1fr;
  }

  .status-display {
    gap: 14px;
  }

  .status-circle {
    width: 84px;
    height: 84px;
  }

  .status-number {
    font-size: 1.65rem;
  }

  .status-left h3,
  .status-right h3 {
    font-size: 1.05rem;
    margin-bottom: 12px;
  }

  .ops-status-activity-chart {
    height: 90px;
  }

  .ops-section,
  .ops-activity-section {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
  }

  .ops-section-title {
    font-size: 1.05rem;
    margin-bottom: 14px;
  }

  .ops-kpi-card,
  .ops-kpi-card.kpi-card-modern {
    min-height: 198px;
    padding: 16px;
    border-radius: 12px;
  }

  .kpi-header {
    margin-bottom: 12px;
  }

  .kpi-icon-box {
    width: 38px;
    height: 38px;
    border-radius: 999px;
  }

  .kpi-icon {
    width: 18px;
    height: 18px;
  }

  .kpi-value {
    font-size: 2.15rem;
    line-height: 1;
  }

  .kpi-title {
    font-size: 0.82rem;
    margin-top: 4px;
  }
  .kpi-subtext {
    font-size: 0.7rem;
  }
  .kpi-sparkline {
    height: 36px;
    padding-top: 10px;
  }

  .ops-pipeline-bar {
    height: 48px;
    margin-bottom: 14px;
  }

  .ops-pipeline-bar .ops-pipeline-seg {
    font-size: 0.66rem;
    min-width: 26px;
  }

  .ops-pipeline-legend {
    gap: 10px 14px;
    font-size: 0.75rem;
  }

  .ops-chart-card {
    padding: 14px;
    min-height: unset;
    border-radius: 12px;
  }

  .ops-chart-card .ops-chart-title {
    font-size: 0.92rem;
    margin-bottom: 12px;
  }

  .ops-chart-card.ops-chart-dominant > div {
    height: 240px !important;
  }

  .ops-chart-right-stack {
    gap: 14px;
  }

  .ops-chart-painting-wrap { height: clamp(200px, 52vw, 260px); }
  .ops-chart-monthly-wrap { height: clamp(180px, 46vw, 230px); }

  .ops-logistics-toggle {
    width: 100%;
    justify-content: stretch;
  }

  .ops-logistics-toggle button {
    flex: 1;
    font-size: 0.8rem;
    padding: 7px 8px;
  }

  .ops-logistics-card {
    padding: 16px;
    border-radius: 12px;
  }

  .ops-logistics-card .ops-log-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    margin-bottom: 10px;
  }

  .ops-logistics-card .val {
    font-size: 1.45rem;
  }

  .ops-logistics-card .label {
    font-size: 0.75rem;
    margin-top: 2px;
  }

  .ops-alerts-header {
    align-items: flex-start;
    gap: 8px;
  }

  .ops-alert-card {
    gap: 10px;
    padding: 12px 12px;
    border-radius: 10px;
  }

  .ops-alert-card .ops-alert-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .ops-alert-card .ops-alert-title {
    font-size: 0.84rem;
  }

  .ops-alert-card .ops-alert-detail {
    font-size: 0.75rem;
  }
}

@media (max-width: 420px) {
  .ops-dashboard-page {
    padding-left: 10px;
    padding-right: 10px;
  }

  .ops-kpi-grid {
    gap: 12px;
  }

  .ops-kpi-card,
  .ops-kpi-card.kpi-card-modern {
    min-height: 186px;
    padding: 14px;
  }

  .kpi-value {
    font-size: 1.95rem;
  }
  .kpi-title {
    font-size: 0.78rem;
  }
  .kpi-subtext {
    font-size: 0.68rem;
  }
  .kpi-icon-box {
    width: 34px;
    height: 34px;
  }
  .kpi-sparkline {
    height: 32px;
    padding-top: 8px;
  }

  .ops-chart-card.ops-chart-dominant > div {
    height: 210px !important;
  }

  .ops-chart-painting-wrap { height: clamp(192px, 56vw, 248px); }
  .ops-chart-monthly-wrap { height: clamp(172px, 50vw, 220px); }

  .ops-date-filter button {
    padding: 8px 10px;
    font-size: 0.72rem;
  }

  .status-circle {
    width: 76px;
    height: 76px;
  }

  .status-number {
    font-size: 1.45rem;
  }

  .status-label {
    font-size: 0.8rem;
  }

  .status-text {
    font-size: 0.9rem;
  }
}
